mysql-test/r/sp.result:
test commented until bug#11394 fix
test for bug#10136
mysql-test/t/sp.test:
test commented until bug#11394 fix
bug10136
sql/sp_head.cc:
fixed items cleunup for SP
into mysql.com:/home/pem/work/mysql-5.0
mysql-test/r/sp.result:
Auto merged
mysql-test/t/sp.test:
Auto merged
sql/item_func.cc:
Auto merged
sql/sp_head.cc:
Auto merged
sql/sp_rcontext.cc:
Auto merged
Fixed valgrind complaints. This fixes the memory leak problems for
procedured, and partially for functions. There's still a leak involving
results from functions that turned out to be too involved, so it will be
fixed separately.
mysql-test/r/sp.result:
Fixed some minor mistake (spotted while debugging).
mysql-test/t/sp.test:
Fixed some minor mistake (spotted while debugging).
sql/item_func.cc:
Moved Item_func_sp::cleanup() from item_func.h to ease debugging,
and made a debug output come out right.
sql/item_func.h:
Moved Item_func_sp::cleanup() to item_func.cc to ease debugging.
sql/sp_head.cc:
Fixed valgrind problems with the previous memory leak fix (unit cleanup and
putting result field in a differen mem_root), and removed prealloc flag from
init_alloc_root() calls.
sql/sp_rcontext.cc:
New mem_root pointer used for return fields from functions.
sql/sp_rcontext.h:
New mem_root pointer used for return fields from functions.
Added a test case for bug #6866.
sql_select.cc:
Fixed bug #6866.
Bug was due to the fact that on_expr was not backed up
for the second execution of the stored procedure.
sql/sql_select.cc:
Fixed bug #6866.
Bug was due to the fact that on_expr was not backed up
for the second execution of the stored procedure.
mysql-test/r/sp.result:
Added a test case for bug #6866.
mysql-test/t/sp.test:
Added a test case for bug #6866.
Have to catch errors from SELECT when opening a cursor.
mysql-test/r/sp.result:
New test case for BUG#10961.
mysql-test/t/sp.test:
New test case for BUG#10961.
sql/protocol.h:
Init data in Protocol_cursor constructor, for error cases.
sql/sp_head.cc:
Catch "hidden" errors during SELECT when opening a cursor.
results.
Actually a problem when converting decimal to int for user variables.
mysql-test/r/sp.result:
New test case for BUG#9559.
mysql-test/t/sp.test:
New test case for BUG#9559.
sql/item_func.cc:
Don't set the unsigned flag when converting decimal user var to int.
some optimisation of IF/NOT IF ptomised to Pem
mysql-test/r/sp.result:
test for bug#5963
mysql-test/t/sp.test:
test for bug#5963
sql/item.cc:
new method which return reference on Item for SP variables support
sql/item.h:
comment fixed
method added
sql/sp_head.cc:
preparation of item made separate function
we do not need new constant Item to check IF/IF NOT
support of passing correct address of item for fix_fields method
sql/sp_rcontext.cc:
support of Item address passing to fix_fields
sql/sp_rcontext.h:
support of correct address passing to fix_fields
sql/sql_class.cc:
support of correct item address passing to fix_field
mysql-test/r/sp.result:
Correct the result file for the changed test.
mysql-test/t/sp.test:
1) Correct the "fib" stored procedure and its initial data to be mathematical correct: fib(0) = 0
2) Do a small run of "fib" first, that is not likely to hit a memory limit (see entry 9937 in the bug DB).
BitKeeper/etc/logging_ok:
Logging to logging@openlogging.org accepted
mysql-test/r/case.result:
test result fixed
mysql-test/r/create.result:
test result fixed
mysql-test/r/distinct.result:
test result fixed
mysql-test/r/func_group.result:
test result fixed
mysql-test/r/func_op.result:
test result fixed
mysql-test/r/group_by.result:
test result fixed
mysql-test/r/metadata.result:
test result fixed
mysql-test/r/olap.result:
test result fixed
mysql-test/r/ps_2myisam.result:
test result fixed
mysql-test/r/ps_3innodb.result:
test result fixed
mysql-test/r/ps_4heap.result:
test result fixed
mysql-test/r/ps_5merge.result:
test result fixed
mysql-test/r/ps_6bdb.result:
test result fixed
mysql-test/r/ps_7ndb.result:
test result fixed
mysql-test/r/select.result:
test result fixed
mysql-test/r/sp.result:
test result fixed
mysql-test/r/type_decimal.result:
test result fixed
mysql-test/r/type_newdecimal.result:
test result fixed
mysql-test/r/union.result:
test result fixed
mysql-test/r/variables.result:
test result fixed
mysql-test/t/func_group.test:
test modified
mysql-test/t/olap.test:
test modified
mysql-test/t/type_decimal.test:
test modified
a stored procedure" (version 2).
To handle updates and inserts into view in SP properly we should set
lock types for tables of the view's main select when we are opening
view for prelocking purproses.
mysql-test/r/sp.result:
Added test case for bug #9841 "Unexpected read lock when trying to update
a view in a stored procedure"
mysql-test/t/sp.test:
Added test case for bug #9841 "Unexpected read lock when trying to update
a view in a stored procedure"
sql/sql_view.cc:
mysql_make_view():
To handle updates and inserts into view in SP properly we should set
lock types for tables of the view's main select when we are opening
view for prelocking purproses.
Also it is more correct to use LEX::select_lex::get_table_list()
instead of 'view_tables' variable for obtaining list of those
tables.
The bug appears to have already been fixed. (Bug #7293)
mysql-test/r/sp.result:
Add results for new test
mysql-test/t/sp.test:
Add regression test for bug 7293
mysql-test/r/sp.result:
New test case for BUG#9004.
Also updated some other results, since formerly "invisible" (but correct)
warnings now are visible.
mysql-test/t/sp.test:
New test case for BUG#9004.
sql/sql_error.cc:
Don't reset warnings while executing a stored routine.
sql/sql_parse.cc:
Don't reset warnings while executing a stored routine.
Bug partially fixed by 9775/9102 work on SP function return.
mysql-test/r/sp.result:
Bug#8861
Test for bug
mysql-test/t/sp.test:
Bug#8861
Test for bug
sql/protocol.cc:
Bug#8861
Requires change in assertion
Fix bug and implement return type casting.
mysql-test/r/sp.result:
Bug#9775
Test for bug + feature
Fix previous tests
mysql-test/t/sp.test:
Bug#9775
Test for bug + feature
Fix previous tests
sql/item_func.cc:
Bug#9775
new method Item_func_sp::execute(Field **)
some optimizations.
sql/item_func.h:
Bug#9775
results for Item_func_sp pass through a Field of the return type.
new method Item_func_sp::execute(Field **)
sql/sp_head.cc:
Bug#9775
missing initialiation for type_lengths in sp_head::create_typelib()
Bug in the optimizer caused an infinite loop for weird code.
mysql-test/r/sp.result:
New test case for BUG#6898.
mysql-test/t/sp.test:
New test case for BUG#6898.
sql/sp_head.cc:
Detect self referencing jumps in the optimizer.
bugfix 9102 corrected the crashing, this corrects the result.
mysql-test/r/sp.result:
Bug#7648
New test for bug
mysql-test/t/sp.test:
Bug#7648
New test for bug
sql/item_func.h:
Bug#7648
Cannot cheat in Item_func_sp::val_int()
Initialization of fields for sp return type was not complete.
mysql-test/r/sp.result:
Bug#9102
Test for bug
mysql-test/t/sp.test:
Bug#9102
Test for bug
sql/mysql_priv.h:
Bug#9102
new function: sp_prepare_create_field()
sql/sp_head.cc:
Strip spaces and do charset conversion for sp function typelibs
sql/sql_table.cc:
Bug#9102
new function - sp_prepare_create_field()
prepares create_field in similar way to mysql_prepare_table()
sql/sql_yacc.yy:
Bug#9102
... actually, it was a query cache problem. (It shouldn't cache such queries)
mysql-test/r/sp.result:
Added testcase for BUG#9902.
mysql-test/t/sp.test:
Added testcase for BUG#9902.
sql/sql_yacc.yy:
Don't cache queries which are calling stored functions.
overwrites IN variable
and added error checking of variables for [IN]OUT parameters while
rewriting the out parameter handling.
mysql-test/r/sp-error.result:
New test case for non-variable argument for [IN]OUT parameters.
(And changed to qualified names in some other error messages.)
mysql-test/r/sp.result:
New test case for BUG#9598.
mysql-test/t/sp-error.test:
New test case for non-variable argument for [IN]OUT parameters.
mysql-test/t/sp.test:
New test case for BUG#9598.
sql/item.h:
Need to distinguish between SP local variable items and other items,
for error checking and [IN]OUT parameter handling.
sql/share/errmsg.txt:
New error message for non-variable arguments for [IN]OUT parameters in stored procedures.
sql/sp_head.cc:
Rewrote the [IN]OUT parameter handling in procedure invokation, to make
it work properly when using user variables in sub-calls.
Also added error checking for non-variable arguments for such parameters
(and changed to qualified names for wrong number of arg. errors).
sql/sp_rcontext.cc:
No need to keep track on the out index for an [IN]OUT parameter any more.
sql/sp_rcontext.h:
No need to keep track on the out index for an [IN]OUT parameter any more.
causes system crash.
mysql-test/r/sp.result:
Added test case for BUG#9674.
mysql-test/t/sp.test:
Added test case for BUG#9674.
sql/item.cc:
Returning a pointer to a local variable is not a good idea.
Better to use parameter which is there for exactly this purpose.
mysql-test/r/sp.result:
Added test case for BUG#6129.
mysql-test/t/sp.test:
Added test case for BUG#6129.
sql/sp_pcontext.h:
Only need one handler counter.
sql/sql_yacc.yy:
Count handlers correctly.
mysql-test/r/sp.result:
Added testcase for BUG#6129: Check that sql_mode is really set in mysql.proc.
mysql-test/t/sp.test:
Added testcase for BUG#6129: Check that sql_mode is really set in mysql.proc.
mysql-test/r/sp.result:
Added test case for BUG#7185.
mysql-test/t/sp.test:
Added test case for BUG#7185.
sql/sql_yacc.yy:
Allow non-reserved words as stored procedure names.
and BUG#9074: STORED PROC: The scope of every handler declared is not properly applied
mysql-test/r/sp.result:
New test cases for BUG#6900 and BUG#9074 (duplicates).
mysql-test/t/sp.test:
New test cases for BUG#6900 and BUG#9074 (duplicates).
sql/sp_rcontext.cc:
Corrected logic for finding condition handlers - pick the innermost one.
state" to sp-error.test.
According to Per-Erik all SP related tests which should result in error
should go into sp-error.test and not in sp.test, because we want to be
able to run sp.test using normal client.
mysql-test/r/sp-error.result:
Moved test for bug #9566 "explicit LOCK TABLE and store procedures result in illegal
state" to sp-error.test.
mysql-test/r/sp.result:
Moved test for bug #9566 "explicit LOCK TABLE and store procedures result in illegal
state" to sp-error.test.
mysql-test/t/sp-error.test:
Moved test for bug #9566 "explicit LOCK TABLE and store procedures result in illegal
state" to sp-error.test.
mysql-test/t/sp.test:
Moved test for bug #9566 "explicit LOCK TABLE and store procedures result in illegal
state" to sp-error.test.
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).
mysql-test/r/sp.result:
Added test for bug #9566 "explicit LOCK TABLE and store procedures result in illegal
state"
mysql-test/t/sp.test:
Added test for bug #9566 "explicit LOCK TABLE and store procedures result in illegal
state"
sql/sp.cc:
db_find_routine_aux():
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 since this
condition may be transient.
mysql-test/r/create.result:
Auto merged
mysql-test/r/ctype_latin1_de.result:
Auto merged
mysql-test/r/grant.result:
Auto merged
mysql-test/r/grant2.result:
Auto merged
mysql-test/r/limit.result:
Auto merged
mysql-test/r/order_by.result:
Auto merged
mysql-test/r/rpl000001.result:
Auto merged
mysql-test/r/sp.result:
Auto merged
mysql-test/r/strict.result:
Auto merged
mysql-test/r/type_blob.result:
Auto merged
mysql-test/r/type_ranges.result:
Auto merged
mysql-test/r/warnings.result:
Auto merged
mysql-test/t/ctype_latin1_de.test:
Auto merged
mysql-test/t/limit.test:
Auto merged
mysql-test/t/order_by.test:
Auto merged
mysql-test/t/show_check.test:
Auto merged
mysql-test/t/sp.test:
Auto merged
mysql-test/t/type_blob.test:
Auto merged
mysql-test/t/type_ranges.test:
Auto merged
sql/item.cc:
Auto merged
sql/item.h:
Auto merged
sql/sql_insert.cc:
Auto merged
mysql-test/t/strict.test:
SCCS merged
Sedond attempt: Simply disallow CHECK in SPs, since it can't work.
mysql-test/r/sp-error.result:
New test cast for BUG#6600
mysql-test/r/sp.result:
Removed old test case for BUG#6600
mysql-test/t/sp-error.test:
New test cast for BUG#6600
mysql-test/t/sp.test:
Removed old test case for BUG#6600
sql/share/errmsg.txt:
Made the SP bad statement error message more general.
sql/sp_head.cc:
CHECK is not possible in stored procedures.
sql/sql_parse.cc:
Undid attempt to fix CHECK in stored procedures, it didn't work.
sql/sql_yacc.yy:
CHECK is not possible in stored procedures.
(And updated error messages for LOCK/UNLOCK.)
BitKeeper/etc/logging_ok:
auto-union
mysql-test/r/information_schema.result:
Auto merged
mysql-test/r/ndb_autodiscover.result:
Auto merged
mysql-test/r/ps_1general.result:
Auto merged
mysql-test/r/show_check.result:
Auto merged
mysql-test/r/sp.result:
Auto merged
mysql-test/r/view.result:
Auto merged
scripts/fill_func_tables.sh:
Auto merged
scripts/mysql_create_system_tables.sh:
Auto merged
scripts/mysql_fix_privilege_tables.sh:
Auto merged
scripts/mysql_fix_privilege_tables.sql:
Auto merged
sql/field.cc:
Auto merged
sql/handler.cc:
Auto merged
sql/item_sum.cc:
Auto merged
sql/item_sum.h:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_table.cc:
Auto merged
sql/table.cc:
Auto merged
mysql-test/r/sp.result:
New test case for BUG#6600.
mysql-test/t/sp.test:
New test case for BUG#6600.
sql/sp_head.cc:
Added yet another multiple result set statement to the list.
sql/sql_parse.cc:
Have to invalidate SP caches in CHECK TABLE, or it will produce very
strange results when called in SPs.
transactional test removed
sp_trans.test, sp_trans.result:
new file
mysql-test/r/sp.result:
transactional test removed
mysql-test/t/sp.test:
transactional test removed
into pcgem.rdg.cyberkinetica.com:/var/db/bk/work-acurtis/bug3788.4
mysql-test/r/sp.result:
Auto merged
mysql-test/t/sp.test:
Auto merged
sql/sql_parse.cc:
Auto merged
mysql-test/r/information_schema.result:
Auto merged
mysql-test/t/sp.test:
Auto merged
sql/item.cc:
Auto merged
sql/item_func.cc:
Auto merged
sql/item_func.h:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/sp.cc:
Auto merged
sql/sp_head.cc:
Auto merged
sql/sp_head.h:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_table.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
mysql-test/r/sp.result:
Merge
BitKeeper/etc/logging_ok:
Logging to logging@openlogging.org accepted
mysql-test/r/sp.result:
fixing results for new test
mysql-test/t/sp.test:
making a new test with autocommit set to 0 and 1.
Second CALL is in autocommit mode to prove that the relevant bug
(bug #8550) is fixed.
mysql-test/r/sp.result:
New test case for BUG#8937.
mysql-test/t/sp.test:
New test case for BUG#8937.
sql/item_sum.h:
Added val_int() method for Item_sum_avg for forced int types (in SPs for instance),
otherwise Item_sum_sum::val_int() is used.
mysql-test/r/sp.result:
Reorganized tests (all bugs at the end now) and made some tests adopt to the file's style.
mysql-test/t/sp.test:
Reorganized tests (all bugs at the end now) and made some tests adopt to the file's style.
stored procedure, it is converted to DELETE.
mysql-test/r/sp.result:
A result for the test case for bug #8850
mysql-test/t/sp.test:
A test case for the bug #8850
sql/sql_delete.cc:
A fix for bug #8850, plus adding a missing call to mysql_init_select(),
which caused mem_root corruption.
sql/sql_parse.cc:
A fix for the bug #8850
BitKeeper/etc/ignore:
Added acinclude.m4 to the ignore list
Crashes with stored procedure return non-string values
Also fixes Bug#2773
mysql-test/r/information_schema.result:
Bug#3788
Fix results for bugfix
mysql-test/r/sp.result:
Bug#3788
Tests for Bug
Fix results for bugfix
mysql-test/t/sp.test:
Bug#3788
New tests for bug
sql/item.cc:
Fix unrelated crash in view test with --ps-protocol.
sql/item_func.cc:
Bug#3788
Alter how SP function result types are handled.
sql/item_func.h:
Bug#3788
Alter how SP function result types are handled.
sql/mysql_priv.h:
Bug#3788
Prototypes for new global functions
sql/sp.cc:
Bug#3788
Alter how function return type is reported
sql/sp_head.cc:
Bug#3788
Change how function return types are stored for SPs
sql/sp_head.h:
Bug#3788
Change how function return types are stored for SPs
sql/sql_parse.cc:
Bug#3788
Split out field construction into its own function
sql/sql_table.cc:
Bug#3788
Split out field preparation code into its own function
sql/sql_yacc.yy:
Bug#3788
Change how function return types are stored for SPs
sql/unireg.cc:
Bug#3788
Add assertion check
mysql-test/r/mysqldump.result:
Auto merged
mysql-test/r/sp.result:
Auto merged
mysql-test/t/mysqldump.test:
Auto merged
mysql-test/t/sp.test:
Auto merged
sql/item_func.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/sp.cc:
Auto merged
sql/sp_rcontext.cc:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_class.h:
Auto merged
sql/sql_lex.cc:
Auto merged
sql/sql_lex.h:
Auto merged
sql/sql_prepare.cc:
Auto merged
sql/sql_update.cc:
Auto merged
sql/sql_view.cc:
Auto merged
sql/table.h:
Auto merged
sql/sp_head.cc:
Manual merge.
sql/sql_class.cc:
Manual merge.
sql/sql_parse.cc:
Manual merge.
sql/sql_yacc.yy:
Manual merge.
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.
mysql-test/r/lock.result:
Replaced wrong error code with the correct one after fixing bug in
SP-locking.
mysql-test/r/mysqldump.result:
Added dropping of view which is used in test to its beginning.
mysql-test/r/sp.result:
Added tests for improved SP-locking.
Temporarily disabled tests for SHOW PROCEDURE STATUS and alike
(Until Monty will allow to open mysql.proc under LOCK TABLES without
mentioning it in lock list).
Replaced wrong results of test for bug #5240 with correct results after
fixing bug in handling of cursors.
mysql-test/t/lock.test:
Replaced wrong error code with the correct one after fixing bug in
SP-locking.
mysql-test/t/mysqldump.test:
Added dropping of view which is used in test to its beginning.
mysql-test/t/sp.test:
Added tests for improved SP-locking.
Temporarily disabled tests for SHOW PROCEDURE STATUS and alike
(Until Monty will allow to open mysql.proc under LOCK TABLES without
mentioning it in lock list).
Removed test for bug #1654 since we already test exactly this function
in one of SP-locking tests.
Removed comment about cursor's wrong behavior in test for bug #5240
after fixing bug which was its cause.
sql/item_func.cc:
Removed comment which is no longer true.
sql/mysql_priv.h:
Changed open_tables() signature.
Now its 2nd parameter is in/out since it can add elements to table list.
sql/sp.cc:
sp_find_procedure():
Added one more parameter which enforces cache only lookup.
sp_merge_hash():
Now uses its return value to indicate that first of two hashes changed
as result of merge.
sp_cache_routines():
This function caches all stored routines used in query now.
sql/sp.h:
- sp_find_procedure() now has one more parameter which enforces cache only
lookup.
- sp_merge_hash() now uses its return value to indicate that first of two
hashes changed as result of merge.
- sp_cache_routines() caches all stored routines now. So it does not need
third argument any more.
sql/sp_head.cc:
sp_head::sp_head():
Added initialization of new m_spfuns and m_spprocs members.
sp_head::execute():
Let us save/restore part of thread context which can be damaged by
execution of instructions.
sp_head::execute_function()/execute_procedure():
Now it is responsibility of caller to close tables used in
subqueries which are passed as routine parameters.
sp_head::restore_lex():
Let us accumulate information about routines used by this one
in new m_spfuns, m_spprocs hashes.
sp_lex_keeper::reset_lex_and_exec_core()
Main method of new auxilary sp_lex_keeper class to which instructions
delegate responsibility for handling LEX and preparations before
executing statement or calculating complex expression.
Since all instructions which calculate complex expression or execute
command now use sp_lex_keeper they have to implement
sp_instr::exec_core() method. Most of instruction specific logic
has moved from sp_instr::execute() to this new method.
Removed sp_instr_set_user_var class which is no longer used, because
nowdays we allow execution of statements in stored functions and
triggers.
sp_merge_table_list() became sp_head::merge_table_list() method. It
also treats sp_head::m_sptabs as multi-set of tables now.
sp_hash_to_table_list() became sp_head::add_used_tables_to_table_list().
It takes into account that sp_head::m_sptabs is multi-set and allocates
object into persistent arena of PS.
Removed sp_merge_table_hash(), sp_open_and_lock_tables(),
sp_unlock_tables(), sp_merge_routine_tables() methods since they are not
used by new prelocking mechanism.
Added sp_add_sp_tables_to_table_list() which serves for adding tables needed
by routines used in query to the query table list for prelocking.
sql/sp_head.h:
class sp_head:
- Added m_spfuns, m_spprocs members for storing names of routines used
by this routine.
- Added add_used_tables_to_table_list() method which allows to add
tables needed by this routine to query's table list.
- Converted sp_merge_table_list() to sp_head::merge_table_list() method.
- Changed semantics of THD::m_sptabs. Now it is multi-set which contains
only tables which are used by this routine and not routines that are
called from this one.
Removed sp_merge_routine_tables(), sp_merge_table_hash(),
sp_open_and_lock_tables(), sp_unlock_tables() calls since they are not
used for our prelocking list calculation.
Added auxilary sp_lex_keeper class to which instructions delegate
responsibility for handling LEX and preparations before executing
statement or calculating complex expression. This class uses
new sp_instr::exec_core() method which is responsible for executing
instruction's core function after all preparations were made.
All instructions which hold and calculate complex expression now have
their own LEX (by aggregating sp_lex_keeper instance). sp_instr_stmt
now uses sp_lex_keeper too.
Removed sp_instr_set_user_var class which is no longer used, because
nowdays we allow execution of statements in stored functions and
triggers.
sql/sp_rcontext.cc:
Now sp_cursor holds pointer to sp_lex_keeper instead of LEX.
sql/sp_rcontext.h:
Now sp_cursor holds pointer to sp_lex_keeper instead of LEX.
sql/sql_acl.cc:
acl_init(), grant_init():
Now we use simple_open_n_lock_tables() instead of explicit
calls to open_tables() and mysql_lock_tables().
sql/sql_base.cc:
Implemented support for execution of statements in "prelocked" mode.
When we have statement which uses stored routines explicitly or
implicitly (via views or triggers) we have to open and lock all tables
for these routines at the same time as tables for the main statement.
In fact we have to do implicit LOCK TABLES at the begining of such
statement and implict UNLOCK TABLES at its end. We call such mode
"prelocked".
When open_tables() is called for the statement tables which are needed
for execution of routines used by it are added to its tables list
(this process also caches all routines used). Implicit use of routines
is discovered when we open view or table with trigger and apropriate
tables are added to the table list at this moment. Statement which has
such extra tables in its list (well actually any that uses functions)
is marked as requiring prelocked mode for its execution.
When lock_tables() sees such statement it will issue implicit LOCK TABLES
for this extended table list instead of doing usual locking, it will also
set THD::prelocked_mode to indicate that we are in prelocked mode.
When open_tables()/lock_tables() are called for statement of stored
routine (substatement), they notice that we are running in prelocked mode
and use one of prelocked tables from those that are not used by upper
levels of execution.
close_thread_tables() for substatement won't really close tables used
but will mark them as free for reuse instead.
Finally when close_thread_tables() is called for the main statement it
really unlocks and closes all tables used.
Everything will work even if one uses such statement under real LOCK
TABLES (we are simply not doing implicit LOCK/UNLOCK in this case).
sql/sql_class.cc:
Added initialization of THD::prelocked_mode member.
sql/sql_class.h:
- Added prelocked_mode_type enum and THD::prelocked_mode member
which are used for indication whenever "prelocked mode" is on
(i.e. that statement uses stored routines and is executed under
implicit LOCK TABLES).
- Removed THD::shortcut_make_view which is no longer needed.
We use TABLE_LIST::prelocking_placeholder for the same purprose
now.
sql/sql_handler.cc:
Changed open_tables() invocation.
Now its 2nd parameter is in/out since it can add elements to table list.
sql/sql_lex.cc:
lex_start():
Added initialization of LEX::query_tables_own_last.
Unused LEX::sptabs member was removed.
st_lex::unlink_first_table()/link_first_table_back():
We should update LEX::query_tables_last properly if table list
contains(ed) only one element.
sql/sql_lex.h:
LEX:
- Removed sptabs member since it is no longer used.
- Added query_tables_own_last member, which if non-0 indicates that
statement requires prelocking (implicit LOCK TABLES) for its execution
and points to last own element in query table list. If it is zero
then this query does not need prelocking.
- Added requires_prelocking(), mark_as_requiring_prelocking(),
first_not_own_table() inline methods to incapsulate and simplify
usage of this new member.
sql/sql_parse.cc:
dispatch_command():
To properly leave prelocked mode when needed we should call
close_thread_tables() even if there are no open tables.
mysql_execute_command():
- Removed part of function which were responsible for doing implicit
LOCK TABLES before statement execution if statement used stored
routines (and doing UNLOCK TABLES at the end).
Now we do all this in open_tables()/lock_tables()/close_thread_tables()
instead.
- It is also sensible to reset errors before execution of statement
which uses routines.
- SQLCOM_DO, SQLCOM_SET_OPTION, SQLCOM_CALL
We should always try to open tables because even if statement has empty
table list, it can call routines using tables, which should be preopened
before statement execution.
- SQLCOM_CALL
We should not look up routine called in mysql.proc, since it should be
already cached by this moment by open_tables() call.
- SQLCOM_LOCK_TABLES
it is better to use simple_open_n_lock_tables() since we want to avoid
materialization of derived tables for this command.
sql/sql_prepare.cc:
mysql_test_update():
Changed open_tables() invocations. Now its 2nd parameter is in/out
since it can add elements to table list.
check_prepared_statement():
Since now we cache all routines used by statement in open_tables() we
don't need to do it explicitly.
mysql_stmt_prepare():
Now we should call close_thread_tables() when THD::lex points to the
LEX of statement which opened tables.
reset_stmt_for_execute():
Commented why we are resetting all tables in table list.
sql/sql_trigger.h:
Table_triggers_list::process_triggers():
We should surpress sending of ok packet when we are calling trigger's
routine, since now we allow statements in them.
sql/sql_update.cc:
Changed open_tables() invocations.
Now its 2nd parameter is in/out since it can add elements to table list.
sql/sql_view.cc:
mysql_make_view():
- Removed handling of routines used in view. Instead we add tables which
are needed for their execution to statement's table list in
open_tables().
- Now we use TABLE_LIST::prelocking_placeholder instead of
THD::shortcut_make_view for indicating that view is opened
only to discover which tables and routines it uses (this happens
when we build extended table list for prelocking). Also now we try
to avoid to modify main LEX in this case (except of its table list).
- Corrected small error we added tables to the table list of the main
LEX without updating its query_tables_last member properly.
sql/sql_yacc.yy:
Now each expression which is used in SP statements and can contain
subquery has its own LEX. This LEX is stored in corresponding sp_instr
object and used along with Item tree for expression calculation.
We don't need sp_instr_set_user_var() anymore since now we allow
execution of statements in stored functions and triggers.
sql/table.h:
Added TABLE_LIST::prelocking_placeholder member for distinguishing
elements of table list which does not belong to the statement itself
and added there only for prelocking (as they are to be used by routines
called by this statement).
sql/tztime.cc:
my_tz_init():
Now we use more simplier simple_open_n_lock_tables() call instead of
open_tables()/lock_tables() pair.
and bug#8849 "problem with insert statement with table alias's":
make equality propagation work in stored procedures and prepared
statements.
Equality propagation can change AND/OR structure of ON expressions,
so the fix is to provide each execution of PS/SP with it's own
copy of AND/OR tree. We have been doing that already for WHERE clauses,
now ON clauses are also copied.
mysql-test/r/ps.result:
Bug#8115: test results fixed.
mysql-test/r/sp.result:
Bug#8849: test results fixed.
mysql-test/t/ps.test:
A test case for Bug#8115 "Server Crash with prepared statement".
mysql-test/t/sp.test:
A test case for Bug#8849 "problem with insert statement with table
alias's".
sql/item_cmpfunc.cc:
Comment a parse tree transformation.
sql/item_cmpfunc.h:
Comment how Item_equal works with PS/SP.
sql/mysql_priv.h:
Add declaration for init_stmt_after_parse.
sql/sp_head.cc:
Call init_stmt_after_parse in restore_lex(), which is used to
grab TABLE_LIST and SELECT_LEX list of a parsed substatement of
stored procedure. This is a necessary post-init step which
must be done for any statement which can be executed many times.
sql/sql_prepare.cc:
Implement init_stmt_after_parse() which prepares AND/OR
structure of all ON expressions and WHERE clauses of a statement
for copying.
sql/sql_select.cc:
Implementation of equality propagation inspected with regard to
prepared statements and stored procedures. We now restore
AND/OR structure of every ON expression in addition to AND/OR
structure of WHERE clauses when reexecuting a PS/SP.
sql/table.h:
Add declaration for TABLE::prep_on_expr.
of DROP PROCEDURE IF EXISTS statement.
mysql-test/r/sp.result:
New test case for BUG#8757
mysql-test/t/sp.test:
New test case for BUG#8757
sql/sp.cc:
Don't zap lex->found_semicolon. (For compound statements)
mysql-test/r/sp.result:
New test case for BUG#8757.
mysql-test/t/sp.test:
New test case for BUG#8757.
sql/sp_pcontext.cc:
Return the correct scope offset to cursors during parsing.