Make mysqltest to use --ps-protocol more
use prepared statements for everything that server supports
with the exception of CALL (for now).
Fix discovered test failures and bugs.
tests:
* PROCESSLIST shows Execute state, not Query
* SHOW STATUS increments status variables more than in text protocol
* multi-statements should be avoided (see tests with a wrong delimiter)
* performance_schema events have different names in --ps-protocol
* --enable_prepare_warnings
mysqltest.cc:
* make sure run_query_stmt() doesn't crash if there's
no active connection (in wait_until_connected_again.inc)
* prepare all statements that server supports
protocol.h
* Protocol_discard::send_result_set_metadata() should not send
anything to the client.
sql_acl.cc:
* extract the functionality of getting the user for SHOW GRANTS
from check_show_access(), so that mysql_test_show_grants() could
generate the correct column names in the prepare step
sql_class.cc:
* result->prepare() can fail, don't ignore its return value
* use correct number of decimals for EXPLAIN columns
sql_parse.cc:
* discard profiling for SHOW PROFILE. In text protocol it's done in
prepare_schema_table(), but in --ps it is called on prepare only,
so nothing was discarding profiling during execute.
* move the permission checking code for SHOW CREATE VIEW to
mysqld_show_create_get_fields(), so that it would be called during
prepare step too.
* only set sel_result when it was created here and needs to be
destroyed in the same block. Avoid destroying lex->result.
* use the correct number of tables in check_show_access(). Saying
"as many as possible" doesn't work when first_not_own_table isn't
set yet.
sql_prepare.cc:
* use correct user name for SHOW GRANTS columns
* don't ignore verbose flag for SHOW SLAVE STATUS
* support preparing REVOKE ALL and ROLLBACK TO SAVEPOINT
* don't ignore errors from thd->prepare_explain_fields()
* use select_send result for sending ANALYZE and EXPLAIN, but don't
overwrite lex->result, because it might be needed to issue execute-time
errors (select_dumpvar - too many rows)
sql_show.cc:
* check grants for SHOW CREATE VIEW here, not in mysql_execute_command
sql_view.cc:
* use the correct function to check privileges. Old code was doing
check_access() for thd->security_ctx, which is invoker's sctx,
not definer's sctx. Hide various view related errors from the invoker.
sql_yacc.yy:
* initialize lex->select_lex for LOAD, otherwise it'll contain garbage
data that happen to fail tests with views in --ps (but not otherwise).
When CREATE TABLE wasn't given ENGINE=... it would determine
the default ENGINE at parse-time rather than at execution
time, leading to incorrect behaviour (namely, later changes
to the default engine being ignore) when calling CREATE TABLE
from a stored procedure.
We now defer working out the default engine till execution of
CREATE TABLE.
mysql-test/r/sp_trans.result:
results!
mysql-test/t/sp_trans.test:
Show that CREATE TABLE (called from store routine) heeds
any changes after CREATE SP / parse-time. Show that explicitly
requesting an ENGINE still works.
sql/sql_parse.cc:
If no ENGINE=... was given at parse-time, determine default
engine at execution time of CREATE TABLE.
sql/sql_yacc.yy:
If CREATE TABLE is not given ENGINE=..., don't bother
figuring out the default engine during parsing; we'll
do it at execution time instead to be aware of the
latest updates.
Bug#54678: InnoDB, TRUNCATE, ALTER, I_S SELECT, crash or deadlock
- Incompatible change: truncate no longer resorts to a row by
row delete if the storage engine does not support the truncate
method. Consequently, the count of affected rows does not, in
any case, reflect the actual number of rows.
- Incompatible change: it is no longer possible to truncate a
table that participates as a parent in a foreign key constraint,
unless it is a self-referencing constraint (both parent and child
are in the same table). To work around this incompatible change
and still be able to truncate such tables, disable foreign checks
with SET foreign_key_checks=0 before truncate. Alternatively, if
foreign key checks are necessary, please use a DELETE statement
without a WHERE condition.
Problem description:
The problem was that for storage engines that do not support
truncate table via a external drop and recreate, such as InnoDB
which implements truncate via a internal drop and recreate, the
delete_all_rows method could be invoked with a shared metadata
lock, causing problems if the engine needed exclusive access
to some internal metadata. This problem originated with the
fact that there is no truncate specific handler method, which
ended up leading to a abuse of the delete_all_rows method that
is primarily used for delete operations without a condition.
Solution:
The solution is to introduce a truncate handler method that is
invoked when the engine does not support truncation via a table
drop and recreate. This method is invoked under a exclusive
metadata lock, so that there is only a single instance of the
table when the method is invoked.
Also, the method is not invoked and a error is thrown if
the table is a parent in a non-self-referencing foreign key
relationship. This was necessary to avoid inconsistency as
some integrity checks are bypassed. This is inline with the
fact that truncate is primarily a DDL operation that was
designed to quickly remove all data from a table.
mysql-test/suite/innodb/t/innodb-truncate.test:
Add test cases for truncate and foreign key checks.
Also test that InnoDB resets auto-increment on truncate.
mysql-test/suite/innodb/t/innodb.test:
FK is not necessary, test is related to auto-increment.
Update error number, truncate is no longer invoked if
table is parent in a FK relationship.
mysql-test/suite/innodb/t/innodb_mysql.test:
Update error number, truncate is no longer invoked if
table is parent in a FK relationship.
Use delete instead of truncate, test is used to check
the interaction of FKs, triggers and delete.
mysql-test/suite/parts/inc/partition_check.inc:
Fix typo.
mysql-test/suite/sys_vars/t/foreign_key_checks_func.test:
Update error number, truncate is no longer invoked if
table is parent in a FK relationship.
mysql-test/t/mdl_sync.test:
Modify test case to reflect and ensure that truncate takes
a exclusive metadata lock.
mysql-test/t/trigger-trans.test:
Update error number, truncate is no longer invoked if
table is parent in a FK relationship.
sql/ha_partition.cc:
Reorganize the various truncate methods. delete_all_rows is now
passed directly to the underlying engines, so as truncate. The
code responsible for truncating individual partitions is moved
to ha_partition::truncate_partition, which is invoked when a
ALTER TABLE t1 TRUNCATE PARTITION p statement is executed.
Since the partition truncate no longer can be invoked via
delete, the bitmap operations are not necessary anymore. The
explicit reset of the auto-increment value is also removed
as the underlying engines are now responsible for reseting
the value.
sql/handler.cc:
Wire up the handler truncate method.
sql/handler.h:
Introduce and document the truncate handler method. It assumes
certain use cases of delete_all_rows.
Add method to retrieve the list of foreign keys referencing a
table. Method is used to avoid truncating tables that are
parent in a foreign key relationship.
sql/share/errmsg-utf8.txt:
Add error message for truncate and FK.
sql/sql_lex.h:
Introduce a flag so that the partition engine can detect when
a partition is being truncated. Used to give a special error.
sql/sql_parse.cc:
Function mysql_truncate_table no longer exists.
sql/sql_partition_admin.cc:
Implement the TRUNCATE PARTITION statement.
sql/sql_truncate.cc:
Change the truncate table implementation to use the new truncate
handler method and to not rely on row-by-row delete anymore.
The truncate handler method is always invoked with a exclusive
metadata lock. Also, it is no longer possible to truncate a
table that is parent in some non-self-referencing foreign key.
storage/archive/ha_archive.cc:
Rename method as the description indicates that in the future
this could be a truncate operation.
storage/blackhole/ha_blackhole.cc:
Implement truncate as no operation for the blackhole engine in
order to remain compatible with older releases.
storage/federated/ha_federated.cc:
Introduce truncate method that invokes delete_all_rows.
This is required to support partition truncate as this
form of truncate does not implement the drop and recreate
protocol.
storage/heap/ha_heap.cc:
Introduce truncate method that invokes delete_all_rows.
This is required to support partition truncate as this
form of truncate does not implement the drop and recreate
protocol.
storage/ibmdb2i/ha_ibmdb2i.cc:
Introduce truncate method that invokes delete_all_rows.
This is required to support partition truncate as this
form of truncate does not implement the drop and recreate
protocol.
storage/innobase/handler/ha_innodb.cc:
Rename delete_all_rows to truncate. InnoDB now does truncate
under a exclusive metadata lock.
Introduce and reorganize methods used to retrieve the list
of foreign keys referenced by a or referencing a table.
storage/myisammrg/ha_myisammrg.cc:
Introduce truncate method that invokes delete_all_rows.
This is required in order to remain compatible with earlier
releases where truncate would resort to a row-by-row delete.
******
This patch fixes the following bugs:
- Bug#5889: Exit handler for a warning doesn't hide the warning in
trigger
- Bug#9857: Stored procedures: handler for sqlwarning ignored
- Bug#23032: Handlers declared in a SP do not handle warnings generated
in sub-SP
- Bug#36185: Incorrect precedence for warning and exception handlers
The problem was in the way warnings/errors during stored routine execution
were handled. Prior to this patch the logic was as follows:
- when a warning/an error happens: if we're executing a stored routine,
and there is a handler for that warning/error, remember the handler,
ignore the warning/error and continue execution.
- after a stored routine instruction is executed: check for a remembered
handler and activate one (if any).
This logic caused several problems:
- if one instruction generates several warnings (errors) it's impossible
to choose the right handler -- a handler for the first generated
condition was chosen and remembered for activation.
- mess with handling conditions in scopes different from the current one.
- not putting generated warnings/errors into Warning Info (Diagnostic
Area) is against The Standard.
The patch changes the logic as follows:
- Diagnostic Area is cleared on the beginning of each statement that
either is able to generate warnings, or is able to work with tables.
- at the end of a stored routine instruction, Diagnostic Area is left
intact.
- Diagnostic Area is checked after each stored routine instruction. If
an instruction generates several condition, it's now possible to take a
look at all of them and determine an appropriate handler.
mysql-test/r/signal.result:
Update result file:
1. handled conditions are not cleared any more;
2. reflect changes in signal.test
mysql-test/r/signal_demo3.result:
Update result file: handled conditions are not cleared any more.
Due to playing with max_error_count, resulting warning lists
have changed.
mysql-test/r/sp-big.result:
Update result file: handled conditions are not cleared any more.
mysql-test/r/sp-bugs.result:
Update result file: handled conditions are not cleared any more.
mysql-test/r/sp-code.result:
Update result file:
1. handled conditions are not cleared any more.
2. add result for a new test case in sp-code.test.
mysql-test/r/sp-error.result:
Update result file:
1. handled conditions are not cleared any more.
2. add result for a new test case in sp-error.test.
mysql-test/r/sp.result:
Update result file: handled conditions are not cleared any more.
mysql-test/r/sp_trans.result:
Update result file: handled conditions are not cleared any more.
mysql-test/r/strict.result:
Update result file: handled conditions are not cleared any more.
mysql-test/r/view.result:
Update result file: handled conditions are not cleared any more.
mysql-test/suite/funcs_1/r/innodb_storedproc_02.result:
Update result file: handled conditions are not cleared any more.
mysql-test/suite/funcs_1/r/memory_storedproc_02.result:
Update result file: handled conditions are not cleared any more.
mysql-test/suite/funcs_1/r/myisam_storedproc_02.result:
Update result file: handled conditions are not cleared any more.
mysql-test/suite/funcs_1/r/storedproc.result:
Update result file: handled conditions are not cleared any more.
mysql-test/suite/rpl/r/rpl_row_sp005.result:
Update result file: handled conditions are not cleared any more.
mysql-test/suite/rpl/r/rpl_row_sp006_InnoDB.result:
Update result file: handled conditions are not cleared any more.
mysql-test/suite/rpl/r/rpl_row_trig003.result:
Update result file: handled conditions are not cleared any more.
mysql-test/t/signal.test:
Make a test case more readable in the result file.
mysql-test/t/sp-code.test:
Add a test case for Bug#23032 checking that
No Data takes precedence on Warning.
mysql-test/t/sp-error.test:
Adding test cases for:
- Bug#23032
- Bug#36185
- Bug#5889
- Bug#9857
mysql-test/t/sp.test:
Fixing test case to reflect behavioral changes made by the patch.
sql/sp_head.cc:
Reset the per-statement warning count before executing
a stored procedure instruction.
Move to a separate function code which checks the
completion status of the executed statement and searches
for a handler.
Remove redundant code now that search for a handler is
done after execution, errors are always pushed.
sql/sp_pcontext.h:
Remove unused code.
sql/sp_rcontext.cc:
- Polish sp_rcontext::find_handler(): use sp_rcontext::m_hfound instead
of an extra local variable;
- Remove sp_rcontext::handle_condition();
- Introduce sp_rcontext::activate_handler(), which prepares
previously found handler for execution.
- Move sp_rcontext::enter_handler() code into activate_handler(),
because enter_handler() is used only from there;
- Cleanups;
- Introduce DBUG_EXECUTE_IF() for a test case in sp-code.test
sql/sp_rcontext.h:
- Remove unused code
- Cleanups
sql/sql_class.cc:
Merge THD::raise_condition_no_handler() into THD::raise_condition().
After the patch raise_condition_no_handler() was called
in raise_condition() only.
sql/sql_class.h:
Remove raise_condition_no_handler().
sql/sql_error.cc:
Remove Warning_info::reserve_space() -- handled conditions are not
cleared any more, so there is no need for RESIGNAL to re-push them.
sql/sql_error.h:
Remove Warning_info::reserve_space().
sql/sql_signal.cc:
Handled conditions are not cleared any more,
so there is no need for RESIGNAL to re-push them.
removed in MySQL 6.0
CREATE TABLE... TYPE= returns the warning "The syntax
'TYPE=storage_engine' is deprecated and will be removed in
MySQL 6.0. Please use 'ENGINE=storage_engine' instead"
This syntax is deprecated already from version 5.4.4, so
the message has been changed.
In addition, the deprecation macro was changed to reflect
the ServerPT decision not to include version number in the
warning message.
A number of test result files have been changed as a
consequence of the change in the deprecation macro.
Text conflict in mysql-test/collections/default.experimental
Text conflict in mysql-test/r/show_check.result
Text conflict in mysql-test/r/sp-code.result
Text conflict in mysql-test/suite/binlog/r/binlog_tmp_table.result
Text conflict in mysql-test/suite/rpl/t/disabled.def
Text conflict in mysql-test/t/show_check.test
Text conflict in mysys/my_delete.c
Text conflict in sql/item.h
Text conflict in sql/item_cmpfunc.h
Text conflict in sql/log.cc
Text conflict in sql/mysqld.cc
Text conflict in sql/repl_failsafe.cc
Text conflict in sql/slave.cc
Text conflict in sql/sql_parse.cc
Text conflict in sql/sql_table.cc
Text conflict in sql/sql_yacc.yy
Text conflict in storage/myisam/ha_myisam.cc
Corrected results for
stm_auto_increment_bug33029.reject 2009-12-01
20:01:49.000000000 +0300
<andrei> @@ -42,9 +42,6 @@
<andrei> RETURN i;
<andrei> END//
<andrei> CALL p1();
<andrei> -Warnings:
<andrei> -Note 1592 Statement may not be safe to log in statement
format.
<andrei> -Note 1592 Statement may not be safe to log in statement
format.
There should be indeed no Note present because there is in fact autoincrement
top-level query in sp() that triggers inserting in yet another auto-inc table.
(todo: alert DaoGang to improve the test).
Unable to reproduce crash with current version of the 5.5.0 codebase.
Test case for MyISAM/InnoDB based on the bug rapport added to
sp_trans.test.
Backport of revno: 2617.65.9.
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
mysql-test/r/backup.result:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
mysql-test/r/events_bugs.result:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
mysql-test/r/events_trans.result:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
mysql-test/r/ndb_dd_basic.result:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
mysql-test/r/ndb_dd_ddl.result:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
mysql-test/r/ndb_gis.result:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
mysql-test/r/ndb_row_format.result:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
mysql-test/r/rpl_extraCol_innodb.result:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
mysql-test/r/rpl_extraCol_myisam.result:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
mysql-test/r/rpl_incident.result:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
mysql-test/r/rpl_ndb_extraCol.result:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
mysql-test/r/rpl_row_tabledefs_2myisam.result:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
mysql-test/r/rpl_row_tabledefs_3innodb.result:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
mysql-test/r/rpl_sp.result:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
mysql-test/r/select.result:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
mysql-test/r/show_check.result:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
mysql-test/r/sp.result:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
mysql-test/r/sp_gis.result:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
mysql-test/r/sp_trans.result:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
mysql-test/r/type_timestamp.result:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
mysql-test/r/warnings.result:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
mysql-test/r/xml.result:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
mysql-test/t/grant.test:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
mysql-test/t/partition_grant.test:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
sql/mysql_priv.h:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
sql/share/errmsg.txt:
Fix some error messages so that all error codes are equivalent in 5.0 and 5.1
Post-commit issues fixed
* Test results for other tests fixed due to added error #s
* Memory allocation/free issues found with running with valgrind
* Fix to mysql-test-run shell script to run federated_server test (installs
mysql.servers table properly)
mysql-test/r/1st.result:
WL #3031
New result for 1st test
mysql-test/r/backup.result:
WL #3031
Error codes differ due to addition of error codes for federated server errors (2)
so all test results with hard-coded error #s will be off by two. New results generated.
mysql-test/r/connect.result:
WL #3031
Error codes differ due to addition of error codes for federated server errors (2)
so all test results with hard-coded error #s will be off by two. New results generated.
mysql-test/r/information_schema.result:
WL #3031
Error codes differ due to addition of error codes for federated server errors (2)
so all test results with hard-coded error #s will be off by two. New results generated.
mysql-test/r/mysql.result:
WL #3031
Error codes differ due to addition of error codes for federated server errors (2)
so all test results with hard-coded error #s will be off by two. New results generated.
mysql-test/r/mysqlcheck.result:
WL #3031
Error codes differ due to addition of error codes for federated server errors (2)
so all test results with hard-coded error #s will be off by two. New results generated.
mysql-test/r/ndb_dd_basic.result:
WL #3031
Error codes differ due to addition of error codes for federated server errors (2)
so all test results with hard-coded error #s will be off by two. New results generated.
mysql-test/r/ndb_dd_ddl.result:
WL #3031
Error codes differ due to addition of error codes for federated server errors (2)
so all test results with hard-coded error #s will be off by two. New results generated.
mysql-test/r/select.result:
WL #3031
Error codes differ due to addition of error codes for federated server errors (2)
so all test results with hard-coded error #s will be off by two. New results generated.
mysql-test/r/show_check.result:
WL #3031
Error codes differ due to addition of error codes for federated server errors (2)
so all test results with hard-coded error #s will be off by two. New results generated.
mysql-test/r/sp.result:
WL #3031
Error codes differ due to addition of error codes for federated server errors (2)
so all test results with hard-coded error #s will be off by two. New results generated.
mysql-test/r/sp_gis.result:
WL #3031
Error codes differ due to addition of error codes for federated server errors (2)
so all test results with hard-coded error #s will be off by two. New results generated.
mysql-test/r/sp_trans.result:
WL #3031
Error codes differ due to addition of error codes for federated server errors (2)
so all test results with hard-coded error #s will be off by two. New results generated.
mysql-test/r/system_mysql_db.result:
WL #3031
Error codes differ due to addition of error codes for federated server errors (2)
so all test results with hard-coded error #s will be off by two. New results generated.
mysql-test/r/type_timestamp.result:
WL #3031
Error codes differ due to addition of error codes for federated server errors (2)
so all test results with hard-coded error #s will be off by two. New results generated.
mysql-test/r/warnings.result:
WL #3031
Error codes differ due to addition of error codes for federated server errors (2)
so all test results with hard-coded error #s will be off by two. New results generated.
mysql-test/r/xml.result:
WL #3031
Error codes differ due to addition of error codes for federated server errors (2)
so all test results with hard-coded error #s will be off by two. New results generated.
scripts/mysql_create_system_tables.sh:
WL #3031
Fixed old mysql-test-run.sh script to work with new mysql.servers table as reported
by Cisco
sql/sql_yacc.yy:
WL# 3031
OPTIONS/options must be usable as table or column name.
storage/federated/ha_federated.cc:
WL# 3031
* Fixed allocation and free issues (warnings found with --valgrind)
* Fixed cast issues
* Made sure port was set accordingly
into neptunus.(none):/home/msvensson/mysql/bug10656/my51-bug10656
mysql-test/r/sp.result:
Auto merged
mysql-test/r/sp_trans.result:
Auto merged
mysql-test/t/sp.test:
Auto merged
-Add test case
Move testcase that needs innodb from sp.test => sp_trans.test
mysql-test/r/sp.result:
Move test cases tyhat requires innodb to sp_trans.test
mysql-test/r/sp_trans.result:
Move test cases tyhat requires innodb to sp_trans.test
Add test case for bug#10656
mysql-test/t/sp.test:
Move test cases tyhat requires innodb to sp_trans.test
mysql-test/t/sp_trans.test:
Add test case for bug#10656
Move test cases that require innodb to sp_trans.test
into mysql.com:/home/mydev/mysql-5.1-wl1563-msg
mysql-test/r/create_select_tmp.result:
Auto merged
mysql-test/r/heap_hash.result:
Auto merged
mysql-test/r/innodb.result:
Auto merged
mysql-test/r/join_outer.result:
Auto merged
mysql-test/r/myisam.result:
Auto merged
mysql-test/r/ndb_index_unique.result:
Auto merged
mysql-test/r/rpl_loaddata.result:
Auto merged
mysql-test/r/sp-error.result:
Auto merged
mysql-test/r/sp.result:
Auto merged
mysql-test/r/sp_trans.result:
Auto merged
mysql-test/r/type_bit.result:
Auto merged
mysql-test/r/type_varchar.result:
Auto merged
sql/handler.cc:
Auto merged
sql/share/errmsg.txt:
Auto merged
mysql-test/r/heap.result:
WL#1563 - Modify MySQL to support fast CREATE/DROP INDEX
Manual merge
mysql-test/r/rpl_err_ignoredtable.result:
WL#1563 - Modify MySQL to support fast CREATE/DROP INDEX
Manual merge
mysql-test/r/rpl_insert_id.result:
WL#1563 - Modify MySQL to support fast CREATE/DROP INDEX
Manual merge
Lowered the parameter to 10, and also renamed non-standard table names to t3.
mysql-test/r/sp.result:
Updated results.
mysql-test/r/sp_trans.result:
Updated results.
mysql-test/t/sp.test:
Renamed fac, primes and fib tables to t3.
Lowered fib() test parameter to 10 (20 hit the stack overrun check on some machines).
mysql-test/t/sp_trans.test:
Added drop of t3 for safety. (Might be left from sp.test after certain test failures.)
Don't set thd->is_fatal_error in sql_update for duplicate key errors.
mysql-test/r/sp.result:
New test case for BUG#13729.
mysql-test/r/sp_trans.result:
New test case for BUG#14840.
mysql-test/t/sp.test:
New test case for BUG#13729.
mysql-test/t/sp_trans.test:
New test case for BUG#14840.
sql/sql_update.cc:
Don't set thd->is_fatal_error if it's a duplicate key error.
handling of savepoints in stored routines.
Fixed ha_rollback_to_savepoint()/ha_savepoint()/ha_release_savepoint()
functions to properly handle savepoints inside of stored functions and
triggers.
Also now when we invoke stored function or trigger we create new savepoint
level. We destroy it at the end of function/trigger execution and return back
to old savepoint level.
mysql-test/r/sp_trans.result:
Added test for bug #13825 "Triggers: crash if release savepoint" and for
general handling of savepoints in stored routines.
mysql-test/t/sp_trans.test:
Added test for bug #13825 "Triggers: crash if release savepoint" and for
general handling of savepoints in stored routines.
sql/ha_innodb.cc:
innobase_savepoint():
Replaced check which always failed due to similar check in caller
with assertion.
sql/handler.cc:
ha_rollback_to_savepoint()/ha_savepoint()/ha_release_savepoint():
Changed functions to properly support handling of savepoints
inside of stored functions and triggers.
sql/sql_class.cc:
THD::reset_sub_statement_state()/restore_sub_statement_state():
When we invoke stored function or trigger we should create new savepoint
level. We should destroy it at the end of function/trigger execution and
return back to old savepoint level. To support this behavior we should
save and reset list of current savepoints on entering function and restore
old list when we leave it.
sql/sql_class.h:
Sub_statement_state:
When we invoke stored function or trigger we should create new savepoint
level. We should destroy it at the end of function/trigger execution and
return back to old savepoint level. To support this behavior added "savepoint"
member which is used to save/restore list of current savepoints on
entering/leaving function.
sql/sql_parse.cc:
mysql_execute_command():
Changed processing of SQLCOM_SAVEPOINT so now it is not ignored when
we are in autocommit mode and savepoint is set inside of stored
function or trigger.
mysql-test/r/innodb.result:
Minor fixes
mysql-test/r/rpl_ddl.result:
Merge fixes
mysql-test/r/sp_trans.result:
TRUNCATE now makes implicit commit
mysql-test/t/sp_trans.test:
No error since we have inplicit commit
We should not allow explicit or implicit transaction commits inside
of stored functions or triggers (so in autocommit mode we should not
do commits after execution of sub-statement).
Also since we don't support nested statement transactions in 5.0,
we shouldn't commit or rollback stmt transactions while we are inside
stored functions or triggers. This should be fixed in later (>=5.1)
releases.
mysql-test/r/sp_trans.result:
Added test for bug #10015 "Crash in InnoDB if stored routines are used"
and for general transaction handling inside of functions.
mysql-test/t/sp_trans.test:
Added test for bug #10015 "Crash in InnoDB if stored routines are used"
and for general transaction handling inside of functions.
sql/handler.cc:
ha_trans_commit()/ha_trans_rollback():
Since we don't support nested statement transactions in 5.0,
we can't commit or rollback stmt transactions while we are inside
stored functions or triggers. So we simply do nothing now.
This should be fixed in later ( >= 5.1) releases.
sql/item_func.cc:
Item_func_sp::execute():
Set THD::transaction.in_sub_stmt flag to TRUE during stored function
execution to prevent commits and rollbacks for statement level
transactions, since doing them will ruin such transaction for
stateemtn which calls this function.
sql/share/errmsg.txt:
Added error message which says that statements doing explicit or implicit
commits are disallowed in triggers and stored functions.
sql/sql_base.cc:
close_thread_tables():
Clarified comment about committing of statement transactions in
prelocked mode.
sql/sql_class.h:
THD::transaction:
Added in_sub_stmt method which indicates that we are executing
statements from trigger or stored function now, and thus
statement transaction belongs to statement which invoked this
routine and we should not commit or rollback it while executing
these sub-statements.
sql/sql_parse.cc:
end_active_trans()/begin_trans()/end_trans():
We should not commit or rollback global (non-stmt) transaction
if we are executing stored function or trigger. These checks will
catch situation when we are trying to do commit or rollback in stored
procedure which is called from function or trigger.
sql/sql_trigger.h:
Table_triggers_list::process_triggers():
Set THD::transaction.in_sub_stmt flag to TRUE during trigger
execution to prevent commits and rollbacks for statement level
transactions, since doing them will ruin such transaction for
stateemtn which invokes this trigger.
sql/sql_yacc.yy:
Prohibited usage of statements which do explicit or implicit commit or
rollback inside of stored functions and triggers.
and removed a have_innodb.inc inclusion which was left by mistake
in an earlier change.
mysql-test/r/sp_trans.result:
Changed procedure name and delimiter setting to follow the style of the other SP test files.
mysql-test/t/sp-error.test:
Added comment with hint for bug test case style.
mysql-test/t/sp-threads.test:
Added comments, with hint for bug test case style.
mysql-test/t/sp.test:
Removed have_innodb.inc inclusion.
Added comments about different SP test files, table usage and
hint for bug test case style.
mysql-test/t/sp_trans.test:
Changed procedure name and delimiter setting to follow the style of the other SP test files.
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