Commit graph

326 commits

Author SHA1 Message Date
andrey@example.com
a4093f31d8 Fix for bug#21311: Possible stack overrun if SP has non-latin1 name
There was possible stack overrun in an edge case which handles invalid body of
a SP in mysql.proc . That should be case when mysql.proc has been changed
manually. Though, due to bug 21513, it can be exploited without having access
to mysql.proc only being able to create a stored routine.
2006-09-27 21:23:17 +02:00
gluh@mysql.com/gluh.(none)
c3d63bef2b after merge fix 2006-09-27 19:21:29 +05:00
kroki/tomash@moonlight.intranet
a53e628181 Merge moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.1
into  moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.1-bug21414
2006-09-27 12:22:16 +04:00
kroki/tomash@moonlight.intranet
18dda5abaf Merge moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0
into  moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0-bug21414
2006-09-27 11:46:29 +04:00
tsmith@maint2.mysql.com
6a31ec2cad Merge maint2.mysql.com:/data/localhome/tsmith/bk/mrg50/50
into  maint2.mysql.com:/data/localhome/tsmith/bk/mrg50/51
2006-09-13 09:03:52 +02:00
kroki/tomash@moonlight.intranet
ed0cb3e4ba BUG#21414: SP: Procedure undroppable, to some extent
The problem was that if after FLUSH TABLES WITH READ LOCK the user
issued DROP/ALTER PROCEDURE/FUNCTION the operation would fail (as
expected), but after UNLOCK TABLE any attempt to execute the same
operation would lead to the error 1305 "PROCEDURE/FUNCTION does not
exist", and an attempt to execute any stored function will also fail.

This happened because under FLUSH TABLES WITH READ LOCK we couldn't open
and lock mysql.proc table for update, and this fact was erroneously
remembered by setting mysql_proc_table_exists to false, so subsequent
statements believed that mysql.proc doesn't exist, and thus that there
are no functions and procedures in the database.

As a solution, we remove mysql_proc_table_exists flag completely.  The
reason is that this optimization didn't work most of the time anyway.
Even if open of mysql.proc failed for some reason when we were trying to
call a function or a procedure, we were setting mysql_proc_table_exists
back to true to force table reopen for the sake of producing the same
error message (the open can fail for number of reasons).  The solution
could have been to remember the reason why open failed, but that's a lot
of code for optimization of a rare case.  Hence we simply remove this
optimization.
2006-09-12 14:56:25 +04:00
gluh@mysql.com/gluh.(none)
e2684ad5d7 after merge fix 2006-09-07 18:09:49 +05:00
kostja@bodhi.local
ebb7070430 Merge bodhi.local:/opt/local/work/mysql-5.0-runtime-safemerge
into  bodhi.local:/opt/local/work/mysql-5.1-runtime-merge
2006-08-30 03:00:19 +04:00
andrey@example.com
85e6c3bfc1 Fix for bug#21416 SP: Recursion level higher than zero needed for non-recursive call
The following procedure was not possible if max_sp_recursion_depth is 0
create procedure show_proc() show create procedure show_proc;
  
Actually there is no recursive call but the limit is checked.
  
Solved by temporarily increasing the thread's limit just before the fetch from cache
and decreasing after that.
2006-08-24 19:36:26 +02:00
kostja@bodhi.local
04c97488f9 Merge bodhi.local:/opt/local/work/tmp_merge
into  bodhi.local:/opt/local/work/mysql-5.1-runtime-merge
2006-08-12 21:06:51 +04:00
andrey@example.com
81efea724e revert part of the code
how did it get in?!? (it's only in local csets so no other tree is affected)
2006-08-10 12:26:43 +02:00
andrey@lmy004.
9a325ac786 Merge ahristov@bk-internal.mysql.com:/home/bk/mysql-5.1-runtime
into  lmy004.:/work/mysql-5.1-runtime
2006-08-09 17:19:39 +02:00
kroki/tomash@moonlight.intranet
5c272816ca Merge moonlight.intranet:/home/tomash/src/mysql_ab/tmp_merge
into  moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.1-merge
2006-08-09 13:37:20 +04:00
andrey@lmy004.
9c59cfe4d7 Fix for bug#21416 SP: Recursion level higher than zero needed for non-recursive call
The following procedure was not possible if max_sp_recursion_depth is 0
create procedure show_proc() show create procedure show_proc;

Actually there is no recursive call but the limit is checked.

Solved by temporarily increasing the thread's limit just before the fetch from cache
and decreasing after that.
2006-08-04 12:50:49 +02:00
kostja@bodhi.local
4bfc67fc3c Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  bodhi.local:/opt/local/work/mysql-5.0-runtime-merge
2006-08-02 14:13:01 +04:00
anozdrin/alik@booka.
2d082d86c9 Fix for BUG#20438: CREATE statements for views, stored routines and triggers
can be not replicable.

Now CREATE statements for writing in the binlog are created as follows:
  - the beginning of the statement is re-created;
  - the rest of the statement is copied from the original query.

The problem appears when there is a version-specific comment (produced by
mysqldump), started in the re-created part of the statement and closed in the
copied part -- there is closing comment-parenthesis, but there is no opening
one.

The proper fix could be to re-create original statement, but we can not
implement it in 5.0. So, for 5.0 the fix is just to cut closing
comment-parenthesis. This technique is also used for SHOW CREATE PROCEDURE
statement (so we are able to reuse existing code).
2006-07-28 02:49:18 +04:00
anozdrin/alik@booka.
b7f403b546 Fix for BUG#16211: Stored function return type for strings is ignored.
Fix for BUG#16676: Database CHARSET not used for stored procedures

The problem in BUG#16211 is that CHARSET-clause of the return type for
stored functions is just ignored.

The problem in BUG#16676 is that if character set is not explicitly
specified for sp-variable, the server character set is used instead
of the database one.

The fix has two parts:

  - always store CHARSET-clause of the return type along with the
    type definition in mysql.proc.returns column. "Always" means that
    CHARSET-clause is appended even if it has not been explicitly
    specified in CREATE FUNCTION statement (this affects BUG#16211 only).

    Storing CHARSET-clause if it is not specified is essential to avoid
    changing character set if the database character set is altered in
    the future.

    NOTE: this change is not backward compatible with the previous releases.

  - use database default character set if CHARSET-clause is not explicitly
    specified (this affects both BUG#16211 and BUG#16676).

    NOTE: this also breaks backward compatibility.
2006-07-27 17:57:43 +04:00
msvensson@shellback.(none)
a1ec4fe7f0 Bug#21039 Transaction cache not flushed after SELECT CREATE
- Add prelocking for stored procedures that uses sp or sf
 - Update test result for sp_error(reported as bug#21294)
 - Make note about new error message from sp-error(bug#17244)
2006-07-26 12:40:26 +02:00
kostja@bodhi.local
f22a4ce1a1 A fix and a test case for Bug#21002 "Derived table not selecting from a
"real" table fails in JOINs".

This is a regression caused by the fix for Bug 18444. 
This fix removed the assignment of empty_c_string to table->db performed 
in add_table_to_list, as neither me nor anyone else knew what it was 
there for. Now we know it and it's covered with tests: the only case 
when a table database name can be empty is when the table is a derived 
table. The fix puts the assignment back but makes it a bit more explicit.

Additionally, finally drop sp.result.orig which was checked in by mistake.
2006-07-19 22:33:19 +04:00
mkindahl@dl145k.mysql.com
9415b24139 Merge dl145k.mysql.com:/data0/mkindahl/bkroot/mysql-5.1-new-rpl
into  dl145k.mysql.com:/data0/mkindahl/bk/MERGE/mysql-5.1-merge
2006-07-11 12:17:19 +02:00
guilhem@gbichot3.local
fdb0f85a0c * Mixed replication mode * :
1) Fix for BUG#19630 "stored function inserting into two auto_increment breaks
statement-based binlog":
a stored function inserting into two such tables may fail to replicate
(inserting wrong data in the slave's copy of the second table) if the slave's
second table had an internal auto_increment counter different from master's.
Because the auto_increment value autogenerated by master for the 2nd table
does not go into binlog, only the first does, so the slave lacks information.
To fix this, if running in mixed binlogging mode, if the stored function or
trigger plans to update two different tables both having auto_increment
columns, we switch to row-based for the whole function.
We don't have a simple solution for statement-based binlogging mode, there
the bug remains and will be documented as a known problem.
Re-enabling rpl_switch_stm_row_mixed.
2) Fix for BUG#20630 "Mixed binlogging mode does not work with stored
functions, triggers, views", which was a documented limitation (in mixed
mode, we didn't detect that a stored function's execution needed row-based
binlogging (due to some UUID() call for example); same for
triggers, same for views (a view created from a SELECT UUID(), and doing
INSERT INTO sometable SELECT theview; would not replicate row-based).
This is implemented by, after parsing a routine's body, remembering in sp_head
that this routine needs row-based binlogging. Then when this routine is used,
the caller is marked to require row-based binlogging too.
Same for views: when we parse a view and detect that its SELECT needs
row-based binary logging, we mark the calling LEX as such.
3) Fix for BUG#20499 "mixed mode with temporary table breaks binlog":
a temporary table containing e.g. UUID has its changes not binlogged,
so any query updating a permanent table with data from the temporary table
will run wrongly on slave. Solution: in mixed mode we don't switch back
from row-based to statement-based when there exists temporary tables.
4) Attempt to test mysqlbinlog on a binlog generated by mysqlbinlog;
impossible due to BUG#11312 and BUG#20329, but test is in place for when
they are fixed.
2006-07-09 17:00:47 +02:00
konstantin@bodhi.netgear
01bc761690 Merge bodhi.netgear:/opt/local/work/tmp_merge
into  bodhi.netgear:/opt/local/work/mysql-5.1-runtime-merge-with-5.0
2006-07-06 22:55:48 +04:00
konstantin@mysql.com
117b76a562 A fix and a test case for
Bug#19022 "Memory bug when switching db during trigger execution"
 Bug#17199 "Problem when view calls function from another database."
 Bug#18444 "Fully qualified stored function names don't work correctly in
            SELECT statements"

 Documentation note: this patch introduces a change in behaviour of prepared
 statements.

 This patch adds a few new invariants with regard to how THD::db should
 be used. These invariants should be preserved in future:

  - one should never refer to THD::db by pointer and always make a deep copy
    (strmake, strdup)
  - one should never compare two databases by pointer, but use strncmp or
    my_strncasecmp
  - TABLE_LIST object table->db should be always initialized in the parser or
    by creator of the object.

    For prepared statements it means that if the current database is changed
    after a statement is prepared, the database that was current at prepare
    remains active. This also means that you can not prepare a statement that
    implicitly refers to the current database if the latter is not set.
    This is not documented, and therefore needs documentation. This is NOT a
    change in behavior for almost all SQL statements except:
     - ALTER TABLE t1 RENAME t2 
     - OPTIMIZE TABLE t1
     - ANALYZE TABLE t1
     - TRUNCATE TABLE t1 --
     until this patch t1 or t2 could be evaluated at the first execution of
     prepared statement. 

     CURRENT_DATABASE() still works OK and is evaluated at every execution
     of prepared statement.

     Note, that in stored routines this is not an issue as the default
     database is the database of the stored procedure and "use" statement
     is prohibited in stored routines.

  This patch makes obsolete the use of check_db_used (it was never used in the
  old code too) and all other places that check for table->db and assign it
  from THD::db if it's NULL, except the parser.

 How this patch was created: THD::{db,db_length} were replaced with a
 LEX_STRING, THD::db. All the places that refer to THD::{db,db_length} were
 manually checked and:
  - if the place uses thd->db by pointer, it was fixed to make a deep copy
  - if a place compared two db pointers, it was fixed to compare them by value
    (via strcmp/my_strcasecmp, whatever was approproate)
 Then this intermediate patch was used to write a smaller patch that does the
 same thing but without a rename.

 TODO in 5.1:
   - remove check_db_used
   - deploy THD::set_db in mysql_change_db

 See also comments to individual files.
2006-06-27 00:47:52 +04:00
serg@serg.mylan
d00b56549c String::set(double) and set(longlong) -> set_real() and set_int()
fix Field::store(double) being used instead of store(longlong)

NB: overloading functions is evil
2006-06-16 12:17:20 +02:00
monty@mysql.com
c46fb742b8 Merge bk-internal.mysql.com:/home/bk/mysql-5.1-new
into  mysql.com:/home/my/mysql-5.1
2006-06-04 21:05:22 +03:00
monty@mysql.com
74cc73d461 This changeset is largely a handler cleanup changeset (WL#3281), but includes fixes and cleanups that was found necessary while testing the handler changes
Changes that requires code changes in other code of other storage engines.
(Note that all changes are very straightforward and one should find all issues
by compiling a --debug build and fixing all compiler errors and all
asserts in field.cc while running the test suite),

- New optional handler function introduced: reset()
  This is called after every DML statement to make it easy for a handler to
  statement specific cleanups.
  (The only case it's not called is if force the file to be closed)

- handler::extra(HA_EXTRA_RESET) is removed. Code that was there before
  should be moved to handler::reset()

- table->read_set contains a bitmap over all columns that are needed
  in the query.  read_row() and similar functions only needs to read these
  columns
- table->write_set contains a bitmap over all columns that will be updated
  in the query. write_row() and update_row() only needs to update these
  columns.
  The above bitmaps should now be up to date in all context
  (including ALTER TABLE, filesort()).

  The handler is informed of any changes to the bitmap after
  fix_fields() by calling the virtual function
  handler::column_bitmaps_signal(). If the handler does caching of
  these bitmaps (instead of using table->read_set, table->write_set),
  it should redo the caching in this code. as the signal() may be sent
  several times, it's probably best to set a variable in the signal
  and redo the caching on read_row() / write_row() if the variable was
  set.

- Removed the read_set and write_set bitmap objects from the handler class

- Removed all column bit handling functions from the handler class.
  (Now one instead uses the normal bitmap functions in my_bitmap.c instead
  of handler dedicated bitmap functions)

- field->query_id is removed. One should instead instead check
  table->read_set and table->write_set if a field is used in the query.

- handler::extra(HA_EXTRA_RETRIVE_ALL_COLS) and
  handler::extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) are removed. One should now
  instead use table->read_set to check for which columns to retrieve.

- If a handler needs to call Field->val() or Field->store() on columns
  that are not used in the query, one should install a temporary
  all-columns-used map while doing so. For this, we provide the following
  functions:

  my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set);
  field->val();
  dbug_tmp_restore_column_map(table->read_set, old_map);

  and similar for the write map:

  my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set);
  field->val();
  dbug_tmp_restore_column_map(table->write_set, old_map);

  If this is not done, you will sooner or later hit a DBUG_ASSERT
  in the field store() / val() functions.
  (For not DBUG binaries, the dbug_tmp_restore_column_map() and
  dbug_tmp_restore_column_map() are inline dummy functions and should
  be optimized away be the compiler).

- If one needs to temporary set the column map for all binaries (and not
  just to avoid the DBUG_ASSERT() in the Field::store() / Field::val()
  methods) one should use the functions tmp_use_all_columns() and
  tmp_restore_column_map() instead of the above dbug_ variants.

- All 'status' fields in the handler base class (like records,
  data_file_length etc) are now stored in a 'stats' struct. This makes
  it easier to know what status variables are provided by the base
  handler.  This requires some trivial variable names in the extra()
  function.

- New virtual function handler::records().  This is called to optimize
  COUNT(*) if (handler::table_flags() & HA_HAS_RECORDS()) is true.
  (stats.records is not supposed to be an exact value. It's only has to
  be 'reasonable enough' for the optimizer to be able to choose a good
  optimization path).

- Non virtual handler::init() function added for caching of virtual
  constants from engine.

- Removed has_transactions() virtual method. Now one should instead return
  HA_NO_TRANSACTIONS in table_flags() if the table handler DOES NOT support
  transactions.

- The 'xxxx_create_handler()' function now has a MEM_ROOT_root argument
  that is to be used with 'new handler_name()' to allocate the handler
  in the right area.  The xxxx_create_handler() function is also
  responsible for any initialization of the object before returning.

  For example, one should change:

  static handler *myisam_create_handler(TABLE_SHARE *table)
  {
    return new ha_myisam(table);
  }

  ->

  static handler *myisam_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root)
  {
    return new (mem_root) ha_myisam(table);
  }

- New optional virtual function: use_hidden_primary_key().
  This is called in case of an update/delete when
  (table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined
  but we don't have a primary key. This allows the handler to take precisions
  in remembering any hidden primary key to able to update/delete any
  found row. The default handler marks all columns to be read.

- handler::table_flags() now returns a ulonglong (to allow for more flags).

- New/changed table_flags()
  - HA_HAS_RECORDS	    Set if ::records() is supported
  - HA_NO_TRANSACTIONS	    Set if engine doesn't support transactions
  - HA_PRIMARY_KEY_REQUIRED_FOR_DELETE
                            Set if we should mark all primary key columns for
			    read when reading rows as part of a DELETE
			    statement. If there is no primary key,
			    all columns are marked for read.
  - HA_PARTIAL_COLUMN_READ  Set if engine will not read all columns in some
			    cases (based on table->read_set)
 - HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS
   			    Renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION.
 - HA_DUPP_POS              Renamed to HA_DUPLICATE_POS
 - HA_REQUIRES_KEY_COLUMNS_FOR_DELETE
			    Set this if we should mark ALL key columns for
			    read when when reading rows as part of a DELETE
			    statement. In case of an update we will mark
			    all keys for read for which key part changed
			    value.
  - HA_STATS_RECORDS_IS_EXACT
			     Set this if stats.records is exact.
			     (This saves us some extra records() calls
			     when optimizing COUNT(*))
			    

- Removed table_flags()
  - HA_NOT_EXACT_COUNT     Now one should instead use HA_HAS_RECORDS if
			   handler::records() gives an exact count() and
			   HA_STATS_RECORDS_IS_EXACT if stats.records is exact.
  - HA_READ_RND_SAME	   Removed (no one supported this one)

- Removed not needed functions ha_retrieve_all_cols() and ha_retrieve_all_pk()

- Renamed handler::dupp_pos to handler::dup_pos

- Removed not used variable handler::sortkey


Upper level handler changes:

- ha_reset() now does some overall checks and calls ::reset()
- ha_table_flags() added. This is a cached version of table_flags(). The
  cache is updated on engine creation time and updated on open.


MySQL level changes (not obvious from the above):

- DBUG_ASSERT() added to check that column usage matches what is set
  in the column usage bit maps. (This found a LOT of bugs in current
  column marking code).

- In 5.1 before, all used columns was marked in read_set and only updated
  columns was marked in write_set. Now we only mark columns for which we
  need a value in read_set.

- Column bitmaps are created in open_binary_frm() and open_table_from_share().
  (Before this was in table.cc)

- handler::table_flags() calls are replaced with handler::ha_table_flags()

- For calling field->val() you must have the corresponding bit set in
  table->read_set. For calling field->store() you must have the
  corresponding bit set in table->write_set. (There are asserts in
  all store()/val() functions to catch wrong usage)

- thd->set_query_id is renamed to thd->mark_used_columns and instead
  of setting this to an integer value, this has now the values:
  MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE
  Changed also all variables named 'set_query_id' to mark_used_columns.

- In filesort() we now inform the handler of exactly which columns are needed
  doing the sort and choosing the rows.

- The TABLE_SHARE object has a 'all_set' column bitmap one can use
  when one needs a column bitmap with all columns set.
  (This is used for table->use_all_columns() and other places)

- The TABLE object has 3 column bitmaps:
  - def_read_set     Default bitmap for columns to be read
  - def_write_set    Default bitmap for columns to be written
  - tmp_set          Can be used as a temporary bitmap when needed.
  The table object has also two pointer to bitmaps read_set and write_set
  that the handler should use to find out which columns are used in which way.

- count() optimization now calls handler::records() instead of using
  handler->stats.records (if (table_flags() & HA_HAS_RECORDS) is true).

- Added extra argument to Item::walk() to indicate if we should also
  traverse sub queries.

- Added TABLE parameter to cp_buffer_from_ref()

- Don't close tables created with CREATE ... SELECT but keep them in
  the table cache. (Faster usage of newly created tables).


New interfaces:

- table->clear_column_bitmaps() to initialize the bitmaps for tables
  at start of new statements.

- table->column_bitmaps_set() to set up new column bitmaps and signal
  the handler about this.

- table->column_bitmaps_set_no_signal() for some few cases where we need
  to setup new column bitmaps but don't signal the handler (as the handler
  has already been signaled about these before). Used for the momement
  only in opt_range.cc when doing ROR scans.

- table->use_all_columns() to install a bitmap where all columns are marked
  as use in the read and the write set.

- table->default_column_bitmaps() to install the normal read and write
  column bitmaps, but not signaling the handler about this.
  This is mainly used when creating TABLE instances.

- table->mark_columns_needed_for_delete(),
  table->mark_columns_needed_for_delete() and
  table->mark_columns_needed_for_insert() to allow us to put additional
  columns in column usage maps if handler so requires.
  (The handler indicates what it neads in handler->table_flags())

- table->prepare_for_position() to allow us to tell handler that it
  needs to read primary key parts to be able to store them in
  future table->position() calls.
  (This replaces the table->file->ha_retrieve_all_pk function)

- table->mark_auto_increment_column() to tell handler are going to update
  columns part of any auto_increment key.

- table->mark_columns_used_by_index() to mark all columns that is part of
  an index.  It will also send extra(HA_EXTRA_KEYREAD) to handler to allow
  it to quickly know that it only needs to read colums that are part
  of the key.  (The handler can also use the column map for detecting this,
  but simpler/faster handler can just monitor the extra() call).

- table->mark_columns_used_by_index_no_reset() to in addition to other columns,
  also mark all columns that is used by the given key.

- table->restore_column_maps_after_mark_index() to restore to default
  column maps after a call to table->mark_columns_used_by_index().

- New item function register_field_in_read_map(), for marking used columns
  in table->read_map. Used by filesort() to mark all used columns

- Maintain in TABLE->merge_keys set of all keys that are used in query.
  (Simplices some optimization loops)

- Maintain Field->part_of_key_not_clustered which is like Field->part_of_key
  but the field in the clustered key is not assumed to be part of all index.
  (used in opt_range.cc for faster loops)

-  dbug_tmp_use_all_columns(), dbug_tmp_restore_column_map()
   tmp_use_all_columns() and tmp_restore_column_map() functions to temporally
   mark all columns as usable.  The 'dbug_' version is primarily intended
   inside a handler when it wants to just call Field:store() & Field::val()
   functions, but don't need the column maps set for any other usage.
   (ie:: bitmap_is_set() is never called)

- We can't use compare_records() to skip updates for handlers that returns
  a partial column set and the read_set doesn't cover all columns in the
  write set. The reason for this is that if we have a column marked only for
  write we can't in the MySQL level know if the value changed or not.
  The reason this worked before was that MySQL marked all to be written
  columns as also to be read. The new 'optimal' bitmaps exposed this 'hidden
  bug'.

- open_table_from_share() does not anymore setup temporary MEM_ROOT
  object as a thread specific variable for the handler. Instead we
  send the to-be-used MEMROOT to get_new_handler().
  (Simpler, faster code)



Bugs fixed:

- Column marking was not done correctly in a lot of cases.
  (ALTER TABLE, when using triggers, auto_increment fields etc)
  (Could potentially result in wrong values inserted in table handlers
  relying on that the old column maps or field->set_query_id was correct)
  Especially when it comes to triggers, there may be cases where the
  old code would cause lost/wrong values for NDB and/or InnoDB tables.

- Split thd->options flag OPTION_STATUS_NO_TRANS_UPDATE to two flags:
  OPTION_STATUS_NO_TRANS_UPDATE and OPTION_KEEP_LOG.
  This allowed me to remove some wrong warnings about:
  "Some non-transactional changed tables couldn't be rolled back"

- Fixed handling of INSERT .. SELECT and CREATE ... SELECT that wrongly reset
  (thd->options & OPTION_STATUS_NO_TRANS_UPDATE) which caused us to loose
  some warnings about
  "Some non-transactional changed tables couldn't be rolled back")

- Fixed use of uninitialized memory in ha_ndbcluster.cc::delete_table()
  which could cause delete_table to report random failures.

- Fixed core dumps for some tests when running with --debug

- Added missing FN_LIBCHAR in mysql_rm_tmp_tables()
  (This has probably caused us to not properly remove temporary files after
  crash)

- slow_logs was not properly initialized, which could maybe cause
  extra/lost entries in slow log.

- If we get an duplicate row on insert, change column map to read and
  write all columns while retrying the operation. This is required by
  the definition of REPLACE and also ensures that fields that are only
  part of UPDATE are properly handled.  This fixed a bug in NDB and
  REPLACE where REPLACE wrongly copied some column values from the replaced
  row.

- For table handler that doesn't support NULL in keys, we would give an error
  when creating a primary key with NULL fields, even after the fields has been
  automaticly converted to NOT NULL.

- Creating a primary key on a SPATIAL key, would fail if field was not
  declared as NOT NULL.


Cleanups:

- Removed not used condition argument to setup_tables

- Removed not needed item function reset_query_id_processor().

- Field->add_index is removed. Now this is instead maintained in
  (field->flags & FIELD_IN_ADD_INDEX)

- Field->fieldnr is removed (use field->field_index instead)

- New argument to filesort() to indicate that it should return a set of
  row pointers (not used columns). This allowed me to remove some references
  to sql_command in filesort and should also enable us to return column
  results in some cases where we couldn't before.

- Changed column bitmap handling in opt_range.cc to be aligned with TABLE
  bitmap, which allowed me to use bitmap functions instead of looping over
  all fields to create some needed bitmaps. (Faster and smaller code)

- Broke up found too long lines

- Moved some variable declaration at start of function for better code
  readability.

- Removed some not used arguments from functions.
  (setup_fields(), mysql_prepare_insert_check_table())

- setup_fields() now takes an enum instead of an int for marking columns
   usage.

- For internal temporary tables, use handler::write_row(),
  handler::delete_row() and handler::update_row() instead of
  handler::ha_xxxx() for faster execution.

- Changed some constants to enum's and define's.

- Using separate column read and write sets allows for easier checking
  of timestamp field was set by statement.

- Remove calls to free_io_cache() as this is now done automaticly in ha_reset()

- Don't build table->normalized_path as this is now identical to table->path
  (after bar's fixes to convert filenames)

- Fixed some missed DBUG_PRINT(.."%lx") to use "0x%lx" to make it easier to
  do comparision with the 'convert-dbug-for-diff' tool.


Things left to do in 5.1:

- We wrongly log failed CREATE TABLE ... SELECT in some cases when using
  row based logging (as shown by testcase binlog_row_mix_innodb_myisam.result)
  Mats has promised to look into this.

- Test that my fix for CREATE TABLE ... SELECT is indeed correct.
  (I added several test cases for this, but in this case it's better that
  someone else also tests this throughly).
  Lars has promosed to do this.
2006-06-04 18:52:22 +03:00
anozdrin@mysql.com
4a43bd1a3a Merge bk-internal.mysql.com:/home/bk/mysql-5.1-new
into  mysql.com:/mnt/raid/MySQL/devel/5.1-rt-wl3158-merged
2006-05-22 14:22:58 +04:00
anozdrin@mysql.com
c1113af15c This is an implementation of two WL items:
- WL#3158: IM: Instance configuration extensions;
  - WL#3159: IM: --bootstrap and --start-default-instance modes

The following new statements have been added:
  - CREATE INSTANCE;
  - DROP INSTANCE;

The behaviour of the following statements have been changed:
  - SET;
  - UNSET;
  - FLUSH INSTANCES;
  - SHOW INSTANCES;
  - SHOW INSTANCE OPTIONS;
2006-05-18 18:57:50 +04:00
monty@mysql.com
3ddc1f9956 Merge mysql.com:/home/my/mysql-5.0
into  mysql.com:/home/my/mysql-5.1
2006-05-04 15:58:30 +03:00
monty@mysql.com
837ba4f399 Fixed memory leak in sql_parse.cc (lex_end() was not called)
This caused sp-vars.test to fail
2006-05-04 15:30:38 +03:00
pem@mysql.com
0e2d20b1cb Merge mysql.com:/extern/mysql/5.1/generic/mysql-5.0-merge
into  mysql.com:/extern/mysql/5.1/generic/mysql-5.1-new
2006-04-25 16:20:49 +02:00
pem@mysql.com
8532fa29f4 Post-push fix for BUG#18344: DROP DATABASE does not drop associated routines
Fixed windows compile error in sql/sp.cc (missing cast to byte*)
2006-04-21 14:30:44 +02:00
pem@mysql.com
9eb230f9bd Fixed BUG#18344: DROP DATABASE does not drop associated routines
We must use the db key length in sp_drop_db_routines (and not the
  number of characters), or long db names will be truncated in the key.
2006-04-18 16:01:01 +02:00
konstantin@mysql.com
08eff11273 Merge mysql.com:/opt/local/work/tmp_merge2
into  mysql.com:/opt/local/work/mysql-5.1-merge
2006-03-30 19:12:10 +04:00
msvensson@shellback.
1d30dfdc00 Remove unused variable 2006-03-28 19:34:44 +02:00
pem@mysql.com
e0a2455f19 Merge mysql.com:/extern/mysql/bk/mysql-5.0-runtime
into  mysql.com:/extern/mysql/5.0/bug17015/mysql-5.0-runtime
2006-03-28 15:08:17 +02:00
pem@mysql.com
e51adff01c Review fix for BUG#17015: Routine name truncation not an error 2006-03-28 15:06:06 +02:00
brian@zim.(none)
e2ce8b2132 Merge zim.(none):/home/brian/mysql/mysql-5.0
into  zim.(none):/home/brian/mysql/mysql-5.1-new
2006-03-09 17:06:04 -08:00
brian@zim.(none)
eefd1207bb This patch does 1) fix my build breakage 2) Complete the removal of all symbols which could clash with another parser. 2006-03-09 16:44:08 -08:00
anozdrin@mysql.com
c1ef46fcc7 Merge mysql.com:/home/alik/Documents/AllProgs/MySQL/devel/5.0-tree
into  mysql.com:/home/alik/Documents/AllProgs/MySQL/devel/5.1-merged
2006-03-09 20:41:21 +03:00
anozdrin@mysql.com
fbb5920399 Implementation of WL#2897: Complete definer support in the stored routines.
The idea is to add DEFINER-clause in CREATE PROCEDURE and CREATE FUNCTION
statements. Almost all support of definer in stored routines had been already
done before this patch.

NOTE: this patch changes behaviour of dumping stored routines in mysqldump.
Before this patch, mysqldump did not dump DEFINER-clause for stored routines
and this was documented behaviour. In order to get full information about stored
routines, one should have dumped mysql.proc table. This patch changes this
behaviour, so that DEFINER-clause is dumped.

Since DEFINER-clause is not supported in CREATE PROCEDURE | FUNCTION statements
before this patch, the clause is covered by additional version-specific comments.
2006-03-02 15:18:49 +03:00
konstantin@mysql.com
a27e32b565 Merge mysql.com:/home/kostja/mysql/mysql-5.0-root
into  mysql.com:/home/kostja/mysql/mysql-5.1-merge
2006-02-22 14:04:24 +03:00
anozdrin@mysql.com
a77cc69e62 Fix for BUG#7787: Stored procedures: improper warning for "grant execute" statement.
The problem was that error flag was not reset.
2006-02-22 13:44:04 +03:00
pem@mysql.com
05826af926 Fixed BUG#17015: Routine name truncation not an error
The name length was checked "the old way", not taking charsets into account,
  when creating a stored routine.
  Fixing this enforces the real limit (64 characters) again, and no truncation
  is possible.
2006-02-16 13:40:37 +01:00
konstantin@mysql.com
e1f807af26 Merge mysql.com:/home/kostja/mysql/mysql-5.0-root
into  mysql.com:/home/kostja/mysql/mysql-5.1-merge
2006-02-09 13:35:59 +03:00
pem@mysql.com
c5abd52a47 Minor fix for BUG#16303 in sp.cc: Simplified code in sp_routine_exists_in_table().
(No change of functionality)
2006-02-02 15:37:29 +01:00
serg@serg.mylan
10373a900f two buffer overflows fixed 2006-01-28 19:21:40 +01:00
pem@mysql.com
5b1fdbec53 Fixed BUG#16303: erroneus stored procedures and functions should be droppable
Use a special lookup function for DROP, which doesn't attempt to parse the
  definition.
2006-01-26 13:29:46 +01:00
anozdrin@mysql.com
b1705ae5c4 Merge BUG#15110 from 5.0 into 5.1.
Merge mysql.com:/home/alik/MySQL/devel/5.0-bug15110
into  mysql.com:/home/alik/MySQL/devel/5.1-bug15110
2006-01-13 19:09:27 +03:00
anozdrin@mysql.com
b04b851ef9 Fix for BUG#15110: mysqldump --triggers: does not include DEFINER clause
There are two main idea of this fix:
  - introduce a common function for server and client to split user value
    (<user name>@<host name>) into user name and host name parts;
  - dump DEFINER clause in correct format in mysqldump.
2006-01-11 02:07:40 +03:00
jimw@mysql.com
96ae7c2e78 Merge mysql.com:/home/jimw/my/mysql-5.0-clean
into  mysql.com:/home/jimw/my/mysql-5.1-clean
2006-01-06 10:42:58 -08:00
monty@mysql.com
b0a5ea01ef Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/my/mysql-5.0
2006-01-06 01:08:48 +02:00
monty@mysql.com
6e22e29de6 Review fixes of new pushed code
- Fixed tests
- Optimized new code
- Fixed some unlikely core dumps
- Better bug fixes for:
  - #14397 - OPTIMIZE TABLE with an open HANDLER causes a crash
  - #14850 (ERROR 1062 when a quering a view using a Group By on a column that can be null
2006-01-06 00:47:49 +02:00
lars@mysql.com
ad126d90e0 WL#1012: All changes as one single changeset.
This includes both code and test cases.
2005-12-22 06:39:02 +01:00
dlenev@mysql.com
5ff3e4ec57 Merge mysql.com:/home/dlenev/src/mysql-5.0-merges
into  mysql.com:/home/dlenev/src/mysql-5.1-merges
2005-12-12 14:59:14 +03:00
anozdrin@mysql.com
5d105fb7e7 Merge mysql.com:/home/alik/MySQL/devel/5.0-wl2984
into  mysql.com:/home/alik/MySQL/devel/5.1-wl2984-merge
2005-12-09 15:14:19 +03:00
dlenev@mysql.com
8d1292185c Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/dlenev/src/mysql-5.0-merges
2005-12-07 20:31:10 +03:00
anozdrin@mysql.com
0ff8f60b45 Patch for WL#2894: Make stored routine variables work
according to the standard.

The idea is to use Field-classes to implement stored routines
variables. Also, we should provide facade to Item-hierarchy
by Item_field class (it is necessary, since SRVs take part
in expressions).

The patch fixes the following bugs:
  - BUG#8702: Stored Procedures: No Error/Warning shown for inappropriate data 
    type matching; 
 
  - BUG#8768: Functions: For any unsigned data type, -ve values can be passed 
    and returned; 
 
  - BUG#8769: Functions: For Int datatypes, out of range values can be passed 
    and returned; 
 
  - BUG#9078: STORED PROCDURE: Decimal digits are not displayed when we use 
    DECIMAL datatype; 
 
  - BUG#9572: Stored procedures: variable type declarations ignored; 
 
  - BUG#12903: upper function does not work inside a function; 
 
  - BUG#13705: parameters to stored procedures are not verified; 
 
  - BUG#13808: ENUM type stored procedure parameter accepts non-enumerated
    data; 
 
  - BUG#13909: Varchar Stored Procedure Parameter always BINARY string (ignores 
    CHARACTER SET); 
 
  - BUG#14161: Stored procedure cannot retrieve bigint unsigned;

  - BUG#14188: BINARY variables have no 0x00 padding;

  - BUG#15148: Stored procedure variables accept non-scalar values;
2005-12-07 17:01:17 +03:00
dlenev@mysql.com
40614adf66 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/dlenev/src/mysql-5.0-bg11555-2
2005-12-07 12:47:25 +03:00
dlenev@mysql.com
06b895c096 Fix for bug #11555 "Stored procedures: current SP tables locking make
impossible view security".

We should not expose names of tables which are explicitly or implicitly (via
routine or trigger) used by view even if we find that they are missing.
So during building of list of prelocked tables for statement we track which
routines (and therefore tables for these routines) are used from views. We
mark elements of LEX::routines set which correspond to routines used in views
by setting Sroutine_hash_entry::belong_to_view member to point to TABLE_LIST
object for topmost view which uses routine. We propagate this mark to all
routines which are used by this routine and which we add to this set. We also
mark tables used by such routine which we add to the list of tables for
prelocking as belonging to this view.
2005-12-07 12:27:17 +03:00
jimw@mysql.com
bc4e6f822b Merge mysql.com:/home/jimw/my/mysql-5.0-clean
into  mysql.com:/home/jimw/my/mysql-5.1-clean
2005-12-06 18:27:39 -08:00
pem@mysql.com
c6fc5d35cc Final review fix of #14233: Crash after tampering with the mysql.proc table.
Changed variable type and added comment in sp.c.
2005-12-06 14:25:12 +01:00
pem@mysql.com
a0ed1d5aba Merge mysql.com:/usr/local/bk/mysql-5.0
into  mysql.com:/usr/home/pem/bug14233/mysql-5.0
2005-12-06 13:34:18 +01:00
pem@mysql.com
eb5bf2ec33 Fixed BUG#14233: Crash after tampering with the mysql.proc table
Post-review version. Some minor review fixes, but also changed the way
  some errors are handled: Don't return specific parse errors; instead
  always use the more general "table corrupt" error (amended accordingly).
2005-11-25 17:09:26 +01:00
monty@mysql.com
4575a662cb Merge mysql.com:/home/my/mysql-5.1
into  mysql.com:/home/my/mysql-5.1-TDC
2005-11-23 22:58:53 +02:00
monty@mysql.com
e42c980967 Table definition cache, part 2
The table opening process now works the following way:
- Create common TABLE_SHARE object
- Read the .frm file and unpack it into the TABLE_SHARE object
- Create a TABLE object based on the information in the TABLE_SHARE
  object and open a handler to the table object

Other noteworthy changes:
- In TABLE_SHARE the most common strings are now LEX_STRING's
- Better error message when table is not found
- Variable table_cache is now renamed 'table_open_cache'
- New variable 'table_definition_cache' that is the number of table defintions that will be cached
- strxnmov() calls are now fixed to avoid overflows
- strxnmov() will now always add one end \0 to result
- engine objects are now created with a TABLE_SHARE object instead of a TABLE object.
- After creating a field object one must call field->init(table) before using it

- For a busy system this change will give you:
 - Less memory usage for table object
 - Faster opening of tables (if it's has been in use or is in table definition cache)
 - Allow you to cache many table definitions objects
 - Faster drop of table
2005-11-23 22:45:02 +02:00
jani@a193-229-222-105.elisa-laajakaista.fi
5273071265 Merge a193-229-222-105.elisa-laajakaista.fi:/home/my/bk/mysql-5.0
into  a193-229-222-105.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-new
2005-11-23 14:57:00 +02:00
bell@sanja.is.com.ua
83d692da88 postmerge fix 2005-11-23 02:49:44 +02:00
bell@sanja.is.com.ua
e6b04edbb1 merge 2005-11-23 01:29:25 +02:00
bell@sanja.is.com.ua
7bd691f11e Recursion support made for SP (BUG#10100). 2005-11-23 01:11:19 +02:00
guilhem@mysql.com
2f95fc2701 Merge mysql.com:/home/mysql_src/mysql-5.0
into  mysql.com:/home/mysql_src/mysql-5.1-merge-of-5.0 (not all files are good,
I'll fix; I'll ask some devs to check their part)
2005-11-18 16:38:01 +01:00
anozdrin@mysql.com
f23f49ed57 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/alik/MySQL/devel/5.0-wl2818
2005-11-10 22:48:00 +03:00
anozdrin@mysql.com
491e4f89f5 WL#2818 (Add creator to the trigger definition for privilege
checks on trigger activation)
2005-11-10 22:25:03 +03:00
guilhem@mysql.com
ff46e54932 WL#2971 "change log-bin-trust-routine-creators=0 to apply only to functions".
Indeed now that stored procedures CALL is not binlogged, but instead the invoked substatements are,
the restrictions applied by log-bin-trust-routine-creators=0 are superfluous for procedures.
They still need to apply to functions where function calls are written to the binlog (for example as "DO myfunc(3)").
We rename the variable to log-bin-trust-function-creators but allow the old name until some future version (and issue a warning if old name is used).
2005-11-10 17:50:51 +01:00
monty@mysql.com
a6f5375cb0 Merge mysql.com:/home/my/mysql-5.0
into  mysql.com:/home/my/mysql-5.1
2005-11-05 01:32:55 +02:00
pem@mysql.com
0657ca2080 Fixed BUG#14233: Crash after tampering with the mysql.proc table
Added error checking for errors when attempting to use stored procedures
  after the mysql.proc table has been dropped, corrupted, or tampered with.
  Test cases were put in a separate file (sp-destruct.test).
2005-10-26 15:34:57 +02:00
jimw@mysql.com
4a893c96e3 Fix use of "%*s" *printf() specifiers that were really meant to be
"%.*s". (Bug #13650)
2005-10-06 17:37:24 -07:00
tomas@poseidon.ndb.mysql.com
620b7bafb0 Merge 2005-10-06 10:54:07 +02:00
bell@sanja.is.com.ua
aec371f910 WL#2787 (part 2, ver 3 (merged)) changed securety context switching 2005-09-15 22:29:07 +03:00
ndbdev@dl145c.mysql.com
dc595c9b1d merge 2005-09-15 07:36:47 +02:00
dlenev@mysql.com
2a96aa110f Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/dlenev/src/mysql-5.0-bg12704-2
2005-09-15 03:57:59 +04:00
dlenev@mysql.com
e231ebe5fb Fix for bug #12704 "Server crashes during trigger execution".
This bug occurs when some trigger for table used by DML statement is created
or changed while statement was waiting in lock_tables(). In this situation
prelocking set which we have calculated becames invalid which can easily lead
to errors and even in some cases to crashes.

With proposed patch we no longer silently reopen tables in lock_tables(),
instead caller of lock_tables() becomes responsible for reopening tables and
recalculation of prelocking set.
2005-09-15 03:56:09 +04:00
msvensson@neptunus.(none)
fb63290635 Merge neptunus.(none):/home/msvensson/mysql/bug10713_new/my50-bug10713_new
into  neptunus.(none):/home/msvensson/mysql/bug10713_new/my51-bug10713_new
2005-09-14 09:43:56 +02:00
monty@mishka.mysql.fi
f348f62cc3 Added option --valgrind-mysqltest to mysql-test-run
Added flag to Field::store(longlong) to specify if value is unsigned.
This fixes bug #12750: Incorrect storage of 9999999999999999999 in DECIMAL(19, 0)
Fixed warning from valgrind in CREATE ... SELECT
Fixed double free of mysql.options if reconnect failed
2005-09-14 01:41:44 +03:00
ndbdev@dl145c.mysql.com
f40c1576b0 Merge 2005-09-06 09:20:15 +02:00
konstantin@mysql.com
a3ddcdf8fb Rename:
- current_arena to stmt_arena: the thread may have more than one
'current' arenas: one for runtime data, and one for the parsed 
tree of a statement. Only one of them is active at any moment.
- set_item_arena -> set_query_arena, because Item_arena was renamed to 
Query_arena a while ago
- set_n_backup_item_arena -> set_n_backup_active_arena;
the active arena is the arena thd->mem_root and thd->free_list
are currently pointing at.
- restore_backup_item_arena -> restore_active_arena (with the same
rationale)
- change_arena_if_needed -> activate_stmt_arena_if_needed; this
method sets thd->stmt_arena active if it's not done yet.
2005-09-02 17:21:19 +04:00
brian@zim.(none)
57403ddc9d Merge zim.(none):/home/brian/mysql/mysql-5.0
into  zim.(none):/home/brian/mysql/mysql-5.1

Resolved to minor issues.
2005-08-30 14:40:02 -07:00
andrey@lmy004.
950a277988 retest the fix for bug #10362 (SHOW PROCEDURE always qualifies name with database)
(already approved)
2005-08-27 12:29:36 +02:00
pappa@c-4a09e253.1238-1-64736c10.cust.bredbandsbolaget.se
02056f8e3a Merge mronstrom@bk-internal.mysql.com:/home/bk/mysql-5.0
into  c-4a09e253.1238-1-64736c10.cust.bredbandsbolaget.se:/home/pappa/mysql-5.1
2005-08-25 13:11:38 -04:00
jimw@mysql.com
2d34276417 Merge mysql.com:/home/jimw/my/mysql-5.0-12318
into  mysql.com:/home/jimw/my/mysql-5.0-clean
2005-08-15 12:39:36 -07:00
timour@mysql.com
354ce1d024 Merge mysql.com:/home/timka/mysql/src/5.0-virgin
into  mysql.com:/home/timka/mysql/src/5.0-2486-merge
2005-08-12 19:27:54 +03:00
timour@mysql.com
a247282aa6 Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".

* Some of the main problems fixed by the patch:
  - in "select *" queries the * expanded correctly according to
    ANSI for arbitrary natural/using joins
  - natural/using joins are correctly transformed into JOIN ... ON
    for any number/nesting of the joins.
  - column references are correctly resolved against natural joins
    of any nesting and combined with arbitrary other joins.

* This patch also contains a fix for name resolution of items
  inside the ON condition of JOIN ... ON - in this case items must
  be resolved only against the JOIN operands. To support such
  'local' name resolution, the patch introduces a stack of
  name resolution contexts used at parse time.

NOTICE:
- This patch is not complete in the sense that
  - there are 2 test cases that still do not pass -
    one in join.test, one in select.test. Both are marked
    with a comment "TODO: WL#2486".
  - it does not include a new test specific for the task
2005-08-12 17:57:19 +03:00
jimw@mysql.com
3a815f45bd Avoid spurious error when restoring INFORMATION_SCHEMA as the current
database after failing to execute a stored procedure in an inaccessible
database. (Bug #12318)
2005-08-11 17:04:16 -07:00
sergefp@mysql.com
9125477df5 Merge mysql.com:/home/psergey/mysql-5.0-bug12228-r4
into mysql.com:/home/psergey/mysql-5.0-bug12228-r5
2005-08-10 21:17:52 +00:00
dlenev@mysql.com
0c38d33507 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/dlenev/src/mysql-5.0-is
2005-08-09 11:43:55 +04:00
sergefp@mysql.com
c6db76b076 Fix for BUG#12228: SP cache code:
* Cleanup SP Cache code, now SP Cache only deletes sp_head objects in 
  sp_cache_flush_obsolete() invalidates all pointers to routines in the cache.
* Use new SP Cache use contract in the code.

There is no test case because it doesn't seem to be possible to cause thread races to end
the same way they end in heavy-load test. This patch removes the crash in heavy test.
2005-08-08 23:23:34 +00:00
dlenev@mysql.com
615baa9f23 Fix for bug #10055 "Using stored function with information_schema causes empty
result set".

To enable full access to contents of I_S tables from stored functions
or statements that use them, we manipulate with thread's open tables
state and ensure that we won't cause deadlock when we open tables by
ignoring flushes and name-locks.
Building of contents of I_S.TABLES no longer requires locking of tables
since we use use handler::info() method with HA_STATUS_AUTO flag instead
of handler::update_auto_increment() for obtaining information about
auto-increment values. But this also means that handlers have to implement
support for HA_STATUS_AUTO flag (particularly InnoDB needs it).
2005-08-08 17:46:06 +04:00
pappa@c-8b0ae253.1238-1-64736c10.cust.bredbandsbolaget.se
69acde961f Merge mronstrom@bk-internal.mysql.com:/home/bk/mysql-5.0
into  c-8b0ae253.1238-1-64736c10.cust.bredbandsbolaget.se:/home/pappa/mysql-5.1
2005-08-05 18:01:34 -04:00
sergefp@mysql.com
31a73da815 Merge spetrunia@bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/psergey/mysql-5.0-sp-no-lock-r7
2005-08-03 10:14:01 +00:00
sergefp@mysql.com
f595847ec0 Manual merge 2005-08-03 03:47:07 +00:00
sergefp@mysql.com
b6a6fe0849 Prelocking-free SPs, post-review fixes:
* Don't activate prelocking mode for evaluating procedure arguments when it is not necessary.
* Code structure simplification and cleanup.
* Cleanup in .test files
2005-08-03 03:37:32 +00:00
jimw@mysql.com
de46ae18c2 Merge mysql.com:/home/jimw/my/mysql-5.0-11602
into  mysql.com:/home/jimw/my/mysql-5.0-clean
2005-08-02 16:50:12 -07:00
sergefp@mysql.com
de02193bdd Added Non-prelocked SP execution: Now a PROCEDURE doesn't enter/leave prelocked mode for
its body, but lets each statement to get/release its own locks. This allows a broader set
of statements to be executed inside PROCEDUREs (but breaks replication)
This patch should fix BUG#8072, BUG#8766, BUG#9563, BUG#11126
2005-07-30 08:19:57 +00:00
monty@mysql.com
b3cbd0048f Cleanups during review of new code
Ensure mysql_close() is called if mysql_set_character_set() fails
2005-07-28 16:10:14 +03:00
jimw@mysql.com
0536bd6679 Increase allowed size of stored procedure bodies to 4GB, and
produce a sensible error when that limit is exceeded. (Bug #11602)
2005-07-26 18:08:49 -07:00
tulin@dl145b.mysql.com
a6c21a0791 merge 2005-07-19 21:56:10 +02:00
dlenev@mysql.com
8a3e723b74 Fix for bugs #5892/6182/8751/8758/10994 (based on Antony's patch)
"Triggers have the wrong namespace"
  "Triggers: duplicate names allowed"
  "Triggers: CREATE TRIGGER does not accept fully qualified names"
  "SHOW TRIGGERS"
2005-07-19 20:06:49 +04:00
mronstrom@mysql.com
67087e2aa7 Patch for push of wl1354 Partitioning 2005-07-18 13:31:02 +02:00
dlenev@mysql.com
8a28d604f5 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/dlenev/src/mysql-5.0-mysqlproc
2005-07-13 15:08:13 +04:00
dlenev@mysql.com
f334ea1fc6 Implementation of Monty's idea: Now we can open mysql.proc table for lookup
of stored routines definitions even if we already have some tables open and
locked. To avoid deadlocks in this case we have to put certain restrictions
on locking of mysql.proc table.

This allows to use stored routines safely under LOCK TABLES without explicitly
mentioning mysql.proc in the list of locked tables. It also fixes bug #11554
"Server crashes on statement indirectly using non-cached function".
2005-07-13 13:48:13 +04:00
pem@mysql.com
6f54e27e5e Merge mysql.com:/usr/local/bk/mysql-5.0
into  mysql.com:/home/pem/work/mysql-5.0
2005-07-11 12:46:42 +02:00
dlenev@mysql.com
4e8c22f296 Manual fixes after merging patch for bug #8406 "Triggers crash if referencing
a table" with main tree.
2005-07-09 23:11:17 +04:00
dlenev@mysql.com
75b8d4fa08 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/dlenev/src/mysql-5.0-bg8406
2005-07-09 22:04:18 +04:00
dlenev@mysql.com
923fe817e0 Enable support of access to tables from triggers. Thus fix bug #8406 "Triggers
crash if referencing a table" and several other related bugs.
Fix for bug #11834 "Re-execution of prepared statement with dropped function
crashes server." which was spotted during work on previous bugs.

Also couple of nice cleanups:
- Replaced two separate hashes for stored routines used by statement with one.
- Now instead of doing one pass through all routines used in statement for
  caching them and then doing another pass for adding their tables to table
  list, we do only one pass during which do both things.
2005-07-09 21:51:59 +04:00
pem@mysql.com
5ce9198f20 Fixed BUG#11365: Stored Procedure: Crash on Procedure operation
Two separate problems. A key buffer was too small in sp.cc for multi-byte
  fields, and the creation and fixing of mysql.proc in the scripts hadn't been
  updated with the correct character sets and collations (like the other
  system tables had).
  Note: No special test case, as the use of utf8 for mysql.proc will make
  any existing crash (if the buffer overrrun wasn't fixed).
2005-07-08 16:33:15 +02:00
bell@sanja.is.com.ua
2941da3971 do not register changes of stack variable 2005-07-03 00:51:02 +03:00
bell@sanja.is.com.ua
d3905f3d0e Name resolution context added (BUG#6443) 2005-07-01 07:05:42 +03:00
pem@mysql.comhem.se
76073d7bf5 Fixed BUG#9529: Stored Procedures: No Warning on truncation of procedure name
during creation.
  Although it returns an error, consistent with the behaviour for other objects.
  (Unclear why we would allow the creation of SPs with truncated names.)
2005-05-31 18:36:32 +02:00
konstantin@mysql.com
2d6a70c42a Preparatory (and the most problematic) patch for Bug#7306
"the server side preparedStatement error for LIMIT placeholder",
which moves all uses of LIMIT clause from PREPARE to OPTIMIZE
and later steps.
After-review fixes.
2005-05-30 20:54:37 +04:00
monty@mysql.com
6cca51f06a Fixed references to uninitialized memory 2005-05-19 04:48:22 +03:00
gbichot@quadita2.mysql.com
b72ae4fe57 Approximative fixes for BUG#2610,2611,9100 i.e. WL#2146 binlogging/replication of routines (stored procs and functions).
Approximative, because it's using our binlogging way (what we call "query"-level) and this is not as good as record-level binlog (5.1) would be. It imposes several
  limitations to routines, and has caveats (which I'll document, and for which the server will try to issue errors but that is not always possible).
  Reason I don't propagate caller info to the binlog as planned is that on master and slave
  users may be different; even with that some caveats would remain.
2005-05-05 14:20:53 +02:00
dlenev@brandersnatch.localdomain
d85bed1121 Fix for bug #9566 "explicit LOCK TABLE and store procedures result in
illegal state".

We should not assume that mysql.proc table does not exist if we are
unable to open it under LOCK TABLES or in prelocked mode (and
remember this fact by setting mysql_proc_table_exists to zero).
2005-04-07 01:40:29 +04:00
monty@mysql.com
5ba3f707f7 Don't use -lsupc++ with gcc 3.3 and below as this gives linking problems when linking staticly
Fix that mysql.proc works with new VARCHAR fields
Give warnings for wrong zero dates
2005-04-04 16:43:25 +03:00
acurtis@pcgem.rdg.cyberkinetica.com
759ad1a13e More portability fixes 2005-03-10 19:42:57 +00:00
acurtis@ltantony.rdg.cyberkinetica.homeunix.net
be3c863ba0 Merge in fix Bug#3788 2005-03-08 22:32:09 +00:00
dlenev@brandersnatch.localdomain
e6a506c397 Fix for yet another memleak caused by SP-locking patch.
Improved handling of situations when we encounter error during
CREATE PROCEDURE (FUNCTION/TRIGGER/...) and bail out of yyparse()
without restoring proper THD::lex.
2005-03-05 16:31:58 +03:00
acurtis@pcgem.rdg.cyberkinetica.com
5e1d2ad68c Bug#3788
Crashes with stored procedure return non-string values
  Also fixes Bug#2773
2005-03-04 21:14:35 +00:00
dlenev@mysql.com
5b16dbf960 Manual merge SP-locking improvements patch with current tree. 2005-03-04 17:46:45 +03:00
dlenev@brandersnatch.localdomain
5a6c7027f0 Better approach for prelocking of tables for stored routines execution
and some SP-related cleanups.

- We don't have separate stage for calculation of list of tables
  to be prelocked and doing implicit LOCK/UNLOCK any more.
  Instead we calculate this list at open_tables() and do implicit
  LOCK in lock_tables() (and UNLOCK in close_thread_tables()).
  Also now we support cases when same table (with same alias) is
  used several times in the same query in SP.

- Cleaned up execution of SP. Moved all common code which handles
  LEX and does preparations before statement execution or complex
  expression evaluation to auxilary sp_lex_keeper class. Now 
  all statements in SP (and corresponding instructions) that
  evaluate expression which can contain subquery have their
  own LEX.
2005-03-04 16:35:28 +03:00
pem@mysql.comhem.se
027c5a6dac Fixed BUG#8762: Stored Procedures: Inconsistent behavior
of DROP PROCEDURE IF EXISTS statement.
2005-03-02 17:25:58 +01:00
pem@mysql.comhem.se
2c26ebe359 WL#2130: Table locking for stored FUNCTIONs
Collect all tables and SPs refered by a statement, and open all tables
with an implicit LOCK TABLES. Do find things refered by triggers and views,
we open them first (and then repeat this until nothing new is found), before
doing the actual lock tables.
2005-02-08 20:52:50 +01:00
monty@mysql.com
d35140a851 First stage of table definition cache
Split TABLE to TABLE and TABLE_SHARE (TABLE_SHARE is still allocated as part of table, will be fixed soon)
Created Field::make_field() and made Field_num::make_field() to call this
Added 'TABLE_SHARE->db' that points to database name; Changed all usage of table_cache_key as database name to use this instead
Changed field->table_name to point to pointer to alias. This allows us to change alias for a table by just updating one pointer.
Renamed TABLE_SHARE->real_name to table_name
Renamed TABLE->table_name to alias
Renamed TABLE_LIST->real_name to table_name
2005-01-06 13:00:13 +02:00
monty@mysql.com
34d5331cee Merge with global tree 2004-12-31 00:50:30 +02:00
monty@mysql.com
d71c030587 After merge fixes 2004-12-31 00:44:00 +02:00
acurtis@pcgem.rdg.cyberkinetica.com
b1e30904d5 WL#925 - Privileges for stored routines
Implement fine-grained control over access to stored procedures
  Privileges are cached (same way as existing table/column privs)
2004-12-23 10:46:24 +00:00
ram@gw.mysql.r18.ru
f7fb35c518 A fix (Bug #6843: Wrong function name crashes MySQL if mysql.proc table is missi 2004-12-16 16:29:47 +04:00
bell@sanja.is.com.ua
69ec6a4592 Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-5.0
into sanja.is.com.ua:/home/bell/mysql/bk/work-join-5.0
2004-11-25 02:27:02 +02:00
bell@sanja.is.com.ua
1e3d8b0839 post-merge fix 2004-11-25 02:23:13 +02:00
pem@mysql.comhem.se
43aefd66fd Fix compiler warnings on some systems. (Unused variables)
Fixed bug in DROP FUNCTION for UDFs.
Note: It still doesn't work properly, but that bug is somewhere else.
2004-11-23 19:19:09 +01:00
bell@sanja.is.com.ua
072d38eb12 merge 2004-11-21 20:08:12 +02:00
bell@sanja.is.com.ua
7210195f1e now my_printf_error is not better then my_error, but my_error call is shorter
used only one implementation of format parser of (printf)
fixed multistatement
2004-11-13 19:35:51 +02:00
bell@sanja.is.com.ua
1555469b64 merge 2004-11-12 15:36:31 +02:00
bell@sanja.is.com.ua
31f7811183 post-review fixes 2004-11-12 14:34:00 +02:00
bell@sanja.is.com.ua
0ef0b030a5 merge 2004-11-11 21:18:10 +02:00
timour@mysql.com
e61b4454da Merge of WL#1972 "Evaluate HAVING before SELECT select-list" 2004-11-11 11:31:58 +02:00
monty@mysql.com
2bba55b57f After merge fixes
Added push_back(void *, MEM_ROOT *) to make some list-handling code easier that needs to be allocated in a different mem-root
(Before one had to change thd->mem_root ; push_back(); restore mem_root.
2004-11-09 03:58:44 +02:00
monty@mysql.com
47bbf768d4 Fixes after merge with 4.1
FOUND is not a reserved keyword anymore
Added Item_field::set_no_const_sub() to be able to mark fields that can't be substituted
Added 'simple_select' method to be able to quickly determinate if a select_result is a normal SELECT
Note that the 5.0 tree is not yet up to date: Sanja will have to fix multi-update-locks for this merge to be complete
2004-11-03 12:39:38 +02:00
timour@mysql.com
09f1c7096c WL#1972 "Evaluate HAVING before SELECT select-list"
- Changed name resolution for GROUP BY so that derived columns do not shadow table columns
  from the FROM clause. As a result GROUP BY now is handled as a true ANSI extentsion.
- Issue a warning when HAVING is resolved into ambiguous columns, and prefer the columns from
  the GROUP BY clause over SELECT columns.
2004-11-02 18:23:15 +02:00
bell@sanja.is.com.ua
dff05eb951 merge 2004-10-28 11:02:48 +03:00
pem@mysql.comhem.se
7944acbbfa Fixed BUG#6022: Stored procedure shutdown problem with self-calling function.
Fixed the pre-caching of functions. It now gives the expected stack overrun
  error for functions recursing too deep.
2004-10-23 13:30:05 +02:00