The idea of the patch is to separate statement processing logic,
such as parsing, validation of the parsed tree, execution and cleanup,
from global query processing logic, such as logging, resetting
priorities of a thread, resetting stored procedure cache, resetting
thread count of errors and warnings.
This makes PREPARE and EXECUTE behave similarly to the rest of SQL
statements and allows their use in stored procedures.
This patch contains a change in behaviour:
until recently for each SQL prepared statement command, 2 queries
were written to the general log, e.g.
[Query] prepare stmt from @stmt_text;
[Prepare] select * from t1 <-- contents of @stmt_text
The chagne was necessary to prevent [Prepare] commands from being written
to the general log when executing a stored procedure with Dynamic SQL.
We should consider whether the old behavior is preferrable and probably
restore it.
This patch refixes Bug#7115, Bug#10975 (partially), Bug#10605 (various bugs
in Dynamic SQL reported before it was disabled).
mysql-test/r/not_embedded_server.result:
Since we don't want to log Dynamic SQL in stored procedures,
now the general log gets only one log entry per SQL statement.
mysql-test/r/sp-error.result:
- remove obsolete tests
- a better error message for the case when a stored procedure that
returns a result set is called from a function
mysql-test/r/trigger.result:
- a better error message for the case when a stored procedure that
returns a result set is called from a trigger
mysql-test/t/sp-error.test:
- a better error message for the case when a stored procedure that
returns a result set is called from a function.
- move the comment to its place (end of file).
mysql-test/t/trigger.test:
- a better error message for the case when a stored procedure that
returns a result set is called from a trigger
sql/item_func.cc:
- we need to pass sql_command explicitly to get_var_with_binlog, because
when creating a query for SQL prepared statement thd->lex->sql_command
points at SQLCOM_EXECUTE, which is not listed in the list of update
queries.
sql/log_event.h:
- remove an extra copy of the previous sentence
sql/mysql_priv.h:
- fix declarations of sql_prepare.cc API
sql/share/errmsg.txt:
- a new error message, when one attempts to execute a prepared statement
which is currently being executed (this can happen only in Dynamic SQL
at the moment).
sql/sp_head.cc:
- extend sp_multi_results_command to return different flags for a
command (and rename it)
- add support for SQLCOM_PREPARE,SQLCOM_EXECUTE, SQLCOM_DEALLOCATE
to sp_get_flags_for_command
- replace multiple boolean sp_head members with uint m_flags
- a fix for a crash when user variables are used in a stored procedure
and binlog is on. A temporary fix for Bug#12637 "SP crashes the server
if it has update query with user var & binlog is enabled", which actually
stands for stored functions: now instead of a crash we break
replication if a user variable is used in a stored function which
is executed in prelocked mode.
sql/sp_head.h:
- replace multiple boolean flags of sp_head with uint m_flags;
- add flag CONTAINS_DYNAMIC_SQL
- use this flag to error if a stored procedure with Dynamic SQL is
called from a function or trigger.
sql/sql_class.cc:
- Statement_map::insert should not delete a statement if it exists,
now it's done externally to be able to handle the case when the
statement being deleted is in use.
- remove extra code (free_list is already reset in free_items)
sql/sql_lex.cc:
- add lex->stmt_prepare_mode; we can't rely on thd->command any more,
because we don't reset it any more (Dynamic SQL requirement is that
PS are as little intrusive as possible).
sql/sql_lex.h:
- declare bool LEX::stmt_prepare_mode
sql/sql_parse.cc:
- move prepared statement code to sql_prepare.cc
- change declarations (refactored code)
- better error message when one attempts to use Dynamic SQL or a
stored procedure that returns a result set in a function or trigger.
sql/sql_prepare.cc:
- major refactoring to ensure PREPARE/EXECUTE commands do not reset global THD
state and allow their use in stored procedures.
- add Prepared_statement::flags and use it to ensure no recursive execution
of a prepared statement is possible
- better comments
sql/sql_yacc.yy:
- enable PREPARE/EXECUTE/DEALLOCATE in stored procedures
- produce an error message on attempt to use PREPARE/EXECUTE/DEALLOCATE
in a stored function or trigger
mysql-test/r/sp-dynamic.result:
- sp-dynamic.test results
mysql-test/t/sp-dynamic.test:
- a new test for PREPARE/EXECUTE/DEALLOCATE in stored procedures.
into mysql.com:/home/jimw/my/mysql-5.0-clean
mysql-test/t/variables.test:
Auto merged
sql/set_var.cc:
Auto merged
mysql-test/r/variables.result:
Resolve conflict
scripts/mysqld_multi.sh:
Resolve conflict
mysql-test/r/mysqltest.result:
Update test results
mysql-test/t/mysqltest.test:
Send output from failed command to /dev/null in order to avoid recording the output from different shells
into mysql.com:/usr/home/bar/mysql-4.1.b12363
mysql-test/t/variables.test:
Auto merged
sql/set_var.cc:
Auto merged
mysql-test/r/variables.result:
SCCS merged
into mysql.com:/home/dlenev/src/mysql-5.0-merges
mysql-test/lib/mtr_process.pl:
Auto merged
mysql-test/lib/mtr_report.pl:
Auto merged
mysql-test/lib/mtr_timer.pl:
Auto merged
mysql-test/mysql-test-run.pl:
Auto merged
sql/examples/ha_archive.cc:
Auto merged
into sanja.is.com.ua:/home/bell/mysql/bk/work-bug3-5.0
BitKeeper/etc/config:
Auto merged
mysql-test/r/view.result:
Auto merged
mysql-test/t/view.test:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_delete.cc:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_update.cc:
Auto merged
sql/sql_view.cc:
Auto merged
sql/table.h:
Auto merged
into neptunus.(none):/home/msvensson/mysql/bug11316/my41-bug11316
mysql-test/mysql-test-run.pl:
Auto merged
mysql-test/t/create.test:
Auto merged
mysql-test/t/create_select_tmp.test:
Auto merged
mysql-test/t/drop.test:
Auto merged
mysql-test/t/flush.test:
Auto merged
mysql-test/t/handler.test:
Auto merged
mysql-test/t/innodb-deadlock.test:
Auto merged
mysql-test/t/innodb-lock.test:
Auto merged
mysql-test/t/innodb.test:
Auto merged
mysql-test/t/ndb_autodiscover2.test:
Auto merged
mysql-test/t/rpl000001.test:
Auto merged
mysql-test/t/rpl_EE_error.test:
Auto merged
mysql-test/t/rpl_change_master.test:
Auto merged
mysql-test/t/rpl_deadlock.test:
Auto merged
mysql-test/t/rpl_drop.test:
Auto merged
mysql-test/t/rpl_drop_temp.test:
Auto merged
mysql-test/t/rpl_error_ignored_table.test:
Auto merged
mysql-test/t/rpl_flush_log_loop.test:
Auto merged
mysql-test/t/rpl_insert_id.test:
Auto merged
mysql-test/t/rpl_loaddata.test:
Auto merged
mysql-test/t/rpl_rotate_logs.test:
Auto merged
mysql-test/t/rpl_until.test:
Auto merged
client/mysqltest.c:
Manual merge
mysql-test/t/mysqltest.test:
Manual merge
into neptunus.(none):/home/msvensson/mysql/bug11316/my50-bug11316
mysql-test/mysql-test-run.pl:
Auto merged
mysql-test/mysql-test-run.sh:
Auto merged
mysql-test/r/mysqltest.result:
Auto merged
mysql-test/r/type_newdecimal.result:
Auto merged
mysql-test/t/create.test:
Auto merged
mysql-test/t/create_select_tmp.test:
Auto merged
mysql-test/t/drop.test:
Auto merged
mysql-test/t/flush.test:
Auto merged
mysql-test/t/handler.test:
Auto merged
mysql-test/t/innodb-deadlock.test:
Auto merged
mysql-test/t/innodb-lock.test:
Auto merged
mysql-test/t/innodb.test:
Auto merged
mysql-test/t/kill.test:
Auto merged
mysql-test/t/ndb_autodiscover2.test:
Auto merged
mysql-test/t/rpl000001.test:
Auto merged
mysql-test/t/rpl_EE_error.test:
Auto merged
mysql-test/t/rpl_change_master.test:
Auto merged
mysql-test/t/rpl_deadlock.test:
Auto merged
mysql-test/t/rpl_drop.test:
Auto merged
mysql-test/t/rpl_drop_temp.test:
Auto merged
mysql-test/t/rpl_error_ignored_table.test:
Auto merged
mysql-test/t/rpl_flush_log_loop.test:
Auto merged
mysql-test/t/rpl_insert_id.test:
Auto merged
mysql-test/t/rpl_loaddata.test:
Auto merged
mysql-test/t/rpl_rotate_logs.test:
Auto merged
mysql-test/t/rpl_sp.test:
Auto merged
mysql-test/t/rpl_until.test:
Auto merged
mysql-test/t/strict.test:
Auto merged
mysql-test/t/type_newdecimal.test:
Auto merged
client/mysqltest.c:
Merge with --parsing-disabled
mysql-test/t/mysqltest.test:
Manual merge
client/mysqltest.c:
Fixes after merge
mysql-test/r/type_newdecimal.result:
Update results after correction of testcase
mysql-test/t/flush_read_lock_kill.test:
Found extra delimiter
mysql-test/t/kill.test:
Found extra delimiter
mysql-test/t/rpl_loaddata.test:
Found extra delimiter
mysql-test/t/rpl_sp.test:
Found extra delimiter
mysql-test/t/strict.test:
Convert "!$1292" to "--error 1292"
mysql-test/t/type_newdecimal.test:
Missing ;
into mysql.com:/home/dlenev/src/mysql-4.1-bg12423
sql/mysqld.cc:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
mysql-test/r/grant2.result:
Manual merge.
mysql-test/t/grant2.test:
Manual merge.
multi-threaded environment".
To avoid deadlocks between several simultaneously run account management
commands (particularly between FLUSH PRIVILEGES/SET PASSWORD and GRANT
commands) we should always take table and internal locks during their
execution in the same order. In other words we should first open and lock
privilege tables and only then obtain acl_cache::lock/LOCK_grant locks.
mysql-test/r/grant2.result:
Added test for bug #12423 "Deadlock when doing FLUSH PRIVILEGES and GRANT in
multi-threaded environment".
mysql-test/t/grant2.test:
Added test for bug #12423 "Deadlock when doing FLUSH PRIVILEGES and GRANT in
multi-threaded environment".
sql/mysqld.cc:
acl_init/grant_init() are now used only at server start up so they always
allocate temporary THD object and don't need argument for passing pointer
to it.
sql/sql_acl.cc:
To avoid deadlocks between several simultaneously run account management
commands (particularly between FLUSH PRIVILEGES/SET PASSWORD and GRANT
commands) we should always take table and internal locks during their
execution in the same order. In other words we should first open and lock
privilege tables and only then obtain acl_cache::lock/LOCK_grant locks.
Changed acl_reload()/grant_reload() and change_password()/update_user_table()
in such way that they obey this principle. Now in acl_reload()/grant_reload()/
change_password() we open and lock privilege tables, then obtain internal
locks and then call acl_load()/grant_load()/update_user_table() functions to
do actual loading or updating.
sql/sql_acl.h:
acl_init/grant_init() are now used only at server start up so they always
allocate temporary THD object and don't need argument for passing pointer
to it. acl_reload()/grant_reload() now are able to report about their
success or failure through return value.
sql/sql_parse.cc:
If reload_acl_and_cache() is called from SIGHUP handler we have to
allocate temporary THD for execution of acl_reload()/grant_reload().
mysql-test/r/ndb_index_ordered.result:
fix ha_ndb crash on ordered index on nullable varchar
mysql-test/t/ndb_index_ordered.test:
fix ha_ndb crash on ordered index on nullable varchar
sql/ha_ndbcluster.cc:
fix ha_ndb crash on ordered index on nullable varchar
into neptunus.(none):/home/msvensson/mysql/bug11316/my50-bug11316
mysql-test/mysql-test-run.pl:
Auto merged
mysql-test/mysql-test-run.sh:
Auto merged
mysql-test/r/rpl_flush_log_loop.result:
Auto merged
mysql-test/t/create.test:
Auto merged
mysql-test/t/drop.test:
Auto merged
mysql-test/t/innodb.test:
Auto merged
mysql-test/t/rpl000001.test:
Auto merged
mysql-test/t/rpl_EE_error.test:
Auto merged
mysql-test/t/rpl_deadlock.test:
Auto merged
mysql-test/t/rpl_drop_temp.test:
Auto merged
mysql-test/t/rpl_error_ignored_table.test:
Auto merged
mysql-test/t/rpl_flush_log_loop.test:
Auto merged
mysql-test/t/rpl_loaddata.test:
Auto merged
mysql-test/t/rpl_rotate_logs.test:
Auto merged
client/mysqltest.c:
Manual merge
mysql-test/r/mysqltest.result:
Manual merge
mysql-test/t/flush.test:
Manual merge
mysql-test/t/mysqltest.test:
Manual merge
mysql-test/t/rpl_change_master.test:
Manual merge
mysql-test/t/rpl_until.test:
Manual merge
client/mysqltest.c:
Fix function var_copy to make it possible to assign one variable to another.
ex: let $1=$2
mysql-test/r/mysqltest.result:
Update test result
mysql-test/t/mysqltest.test:
Add test cases for variable to variable assignment
- Move clearing of expected errors
client/mysqltest.c:
Move clear of expected errors to the query loop so that the expected error is reset even when the query is retrieved from the q_lines cache.
mysql-test/r/mysqltest.result:
Update test results
mysql-test/t/mysqltest.test:
Add test for bug#12471
into mysql.com:/home/jimw/my/mysql-5.0-clean
configure.in:
Auto merged
include/my_global.h:
Auto merged
myisam/mi_extra.c:
Auto merged
mysql-test/r/lowercase_table.result:
Auto merged
mysql-test/t/lowercase_table.test:
Auto merged
mysys/my_access.c:
Auto merged
BitKeeper/deleted/.del-extra.c~706f29d72beb2565:
Auto merged
sql/examples/ha_tina.cc:
Resolve conflict
on Windows. (Bug #12325)
mysql-test/r/lowercase_table.result:
Update results
mysql-test/t/lowercase_table.test:
Move test to new windows.test, since it is Windows-specific
mysys/my_access.c:
Check that we've matched the whole forbidden name.
mysql-test/include/windows.inc:
New BitKeeper file ``mysql-test/include/windows.inc''
mysql-test/r/windows.result:
New BitKeeper file ``mysql-test/r/windows.result''
mysql-test/t/windows.test:
New BitKeeper file ``mysql-test/t/windows.test''
into mysql.com:/home/jimw/my/mysql-5.0-clean
mysql-test/r/func_gconcat.result:
Auto merged
mysql-test/t/func_gconcat.test:
Auto merged
mysql-test/t/system_mysql_db_fix.test:
Auto merged
ndb/src/kernel/blocks/backup/BackupInit.cpp:
Auto merged
ndb/src/kernel/blocks/dbacc/Dbacc.hpp:
Auto merged
ndb/src/kernel/blocks/dbacc/DbaccInit.cpp:
Auto merged
ndb/src/kernel/blocks/dbacc/DbaccMain.cpp:
Auto merged
ndb/src/kernel/blocks/dbdict/Dbdict.cpp:
Auto merged
ndb/src/kernel/blocks/dbdict/Dbdict.hpp:
Auto merged
ndb/src/kernel/blocks/dbdih/DbdihMain.cpp:
Auto merged
ndb/src/kernel/blocks/dblqh/Dblqh.hpp:
Auto merged
ndb/src/kernel/blocks/dblqh/DblqhInit.cpp:
Auto merged
ndb/src/kernel/blocks/dblqh/DblqhMain.cpp:
Auto merged
ndb/src/kernel/blocks/dbtup/Dbtup.hpp:
Auto merged
ndb/src/kernel/blocks/dbtup/DbtupGen.cpp:
Auto merged
ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp:
Auto merged
ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp:
Auto merged
ndb/src/kernel/vm/SimulatedBlock.cpp:
Auto merged
ndb/src/kernel/vm/SimulatedBlock.hpp:
Auto merged
ndb/src/mgmclient/CommandInterpreter.cpp:
Auto merged
ndb/src/mgmsrv/ConfigInfo.cpp:
Auto merged
sql/item_sum.cc:
Auto merged
sql/sql_table.cc:
Auto merged
tests/mysql_client_test.c:
Auto merged
ndb/src/ndbapi/ndberror.c:
Resolve conflicts
sql/ha_innodb.cc:
Resolve conflicts
sql/item_strfunc.cc:
Resolve conflicts
After merge fix for bug #12537
sql/item.cc:
After merge fix for bug #12537
sql/sql_select.cc:
After merge fix for bug #12537
mysql-test/r/create.result:
After merge fix for bug #12537
mysql-test/t/create.test:
After merge fix for bug #12537
Use !<err_no> instead
client/mysqltest.c:
Remove syntax !$<err_no> to set an expected error code
mysql-test/r/mysqltest.result:
Update test result
mysql-test/t/mysqltest.test:
Uncomment tests for the deprecated syntax
rpl_replicate_do.result:
New test case
sql_parse.cc:
All SET statements should be executed by slave thd
rpl_replicate_do.test:
New test case
mysql-test/t/rpl_replicate_do.test:
Added test
sql/sql_parse.cc:
All SET commands should be executed by slave thd
mysql-test/r/rpl_replicate_do.result:
New test case
- Add stricter checking of syntax in mysqltest
client/mysqltest.c:
Stricter checking of syntax in mysqltest.
mysql-test/r/mysqltest.result:
Update test results
mysql-test/t/create.test:
Remove extra ;
mysql-test/t/create_select_tmp.test:
Remove extra ;
mysql-test/t/drop.test:
Remove extra ;
mysql-test/t/flush.test:
Remove extra ;
mysql-test/t/handler.test:
Remove extra ;
mysql-test/t/innodb.test:
Remove extra ;
mysql-test/t/mysqltest.test:
Add more tests for replace, replace_columns, comments with commands and sync_with_master
mysql-test/t/rpl000001.test:
Remove extra ;
mysql-test/t/rpl_EE_error.test:
Remove extra ;
mysql-test/t/rpl_drop.test:
Remove extra ;
mysql-test/t/rpl_error_ignored_table.test:
Remove extra ;
mysql-test/t/rpl_loaddata.test:
Remove extra ;
Item_func_group_concat::fix_fields() set maybe_null flag to 0, and set it to
1 only if some of it's arguments may be null. When used in subquery in tmp
table created field which can't be null. When no data retireved result field
have to be set to null and error mentioned in bug report occurs. Also this
bug can occur if selecting from not null field in empty table.
Function group_concat now marked maybe_null from the very beginning not only
if some of it's argument may be null.
sql/item_sum.cc:
Fix bug #12861 client hang with group_concat insubquery FROM DUAL.
mysql-test/r/func_gconcat.result:
Test case for bug #12861 client hang with group_concat insubquery FROM DUAL.
mysql-test/t/func_gconcat.test:
Test case for bug #12861 client hang with group_concat insubquery FROM DUAL.
into mysql.com:/usr/home/ram/work/mysql-5.0
sql/ha_blackhole.cc:
Auto merged
sql/mysqld.cc:
Auto merged
sql/set_var.cc:
Auto merged
mysql-test/r/variables.result:
merging
mysql-test/t/variables.test:
merging
view.
For Item_func_strcmp print() was not defined and for this class was called
print_op of it's parent class. Because of this strcmp() was printed wrongly
and this results int creation of broken view.
Added function Item_func_strcmp::print() which correctly prints strcmp()
function.
sql/item_cmpfunc.h:
Fix bug #12489 wrongly printed strcmp() function results in creation of broken view.
mysql-test/r/view.result:
Test case for bug #12489 wrongly printed strcmp() function results in creation of broken view.
mysql-test/t/view.test:
Test case for bug #12489 wrongly printed strcmp() function results in creation of broken view.
mysql-test/r/archive.result:
Updated result file
mysql-test/t/archive.test:
Test fix. The INSERT DELAYED test must always come last.
sql/examples/ha_archive.h:
Bad merge.
Item::tmp_table_field_from_field_type() and create_tmp_field_from_item()
was converting string field to blob depending on byte-wise length instead of
character length, which results in converting valid varchar string with
length == 86 to longtext.
Made that functions above take into account max width of character when
converting string fields to blobs.
sql/item.cc:
Fix bug #12537 UNION produces longtext instead of varchar
Item::tmp_table_field_from_field_type() now taking into account max char width when creating tmp field for string fields.
sql/sql_select.cc:
Fix bug #12537 UNION produces longtext instead of varchar
create_tmp_field_from_item()now taking into account max char width when creating tmp field for string fields.
mysql-test/r/create.result:
Test case for bug #12537 UNION produces longtext instead of varchar
mysql-test/t/create.test:
Test case for bug #12537 UNION produces longtext instead of varchar
character_set_results is nullable, but value_ptr returns string "NULL"
set_var.cc:
Create Item_null instead of Item_string for NULL values
variables.result, variables.test:
adding test case
sql/set_var.cc:
Bug#12363
character_set_results is nullable, but value_ptr returns string "NULL"
Create Item_null instead of Item_string for NULL values
mysql-test/t/variables.test:
fixing tests accordingly
mysql-test/r/variables.result:
fixing tests accordingly
into mysql.com:/home/mydev/mysql-5.0-5000
mysql-test/r/innodb.result:
Auto merged
mysql-test/t/innodb.test:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_delete.cc:
After merge fix.