From 83aade738787f991122b3dcf519789eba7becb93 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 11 Jul 2006 15:54:52 +0400 Subject: [PATCH 1/7] Fix Bug#15205 "Select from CSV table without the datafile causes crash" mysql-test/r/csv.result: update result file mysql-test/t/csv.test: add a test for the bug sql/examples/ha_tina.cc: move open() call before my_hash_insert, so that we don't insert invalid share to the hash. To avoid other possible problems also add hash_delete(), so that the share is removed from hash before it is freed. --- mysql-test/r/csv.result | 10 ++++++++++ mysql-test/t/csv.test | 24 ++++++++++++++++++++++++ sql/examples/ha_tina.cc | 13 ++++++++----- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/csv.result b/mysql-test/r/csv.result index 3c87c1f4b92..f3e91a663b8 100644 --- a/mysql-test/r/csv.result +++ b/mysql-test/r/csv.result @@ -5000,3 +5000,13 @@ insert t1 values (1),(2),(3),(4),(5); truncate table t1; affected rows: 0 drop table t1; +create table bug15205 (val int(11) default null) engine=csv; +create table bug15205_2 (val int(11) default null) engine=csv; +select * from bug15205; +ERROR HY000: Got error 1 from storage engine +select * from bug15205_2; +val +select * from bug15205; +val +drop table bug15205; +drop table bug15205_2; diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test index a028f6ced6d..8bd48b7da2c 100644 --- a/mysql-test/t/csv.test +++ b/mysql-test/t/csv.test @@ -1384,3 +1384,27 @@ truncate table t1; -- truncate --disable_info drop table t1; +# +# Bug #15205 Select from CSV table without the datafile causes crash +# +# NOTE: the bug is not deterministic + +# The crash happens because the necessary cleanup after an error wasn't +# performed. Namely, the table share, inserted in the hash during table +# open, was not deleted from hash. At the same time the share was freed +# when an error was encountered. Thus, subsequent access to the hash +# resulted in scanning through deleted memory and we were geting a crash. +# that's why we need two tables in the bugtest + +create table bug15205 (val int(11) default null) engine=csv; +create table bug15205_2 (val int(11) default null) engine=csv; +--exec rm $MYSQLTEST_VARDIR/master-data/test/bug15205.CSV +# system error (can't open the datafile) +--error ER_GET_ERRNO +select * from bug15205; +select * from bug15205_2; +--exec touch $MYSQLTEST_VARDIR/master-data/test/bug15205.CSV +select * from bug15205; +drop table bug15205; +drop table bug15205_2; + diff --git a/sql/examples/ha_tina.cc b/sql/examples/ha_tina.cc index 8ae82f97d0b..ebddfc244b8 100644 --- a/sql/examples/ha_tina.cc +++ b/sql/examples/ha_tina.cc @@ -184,16 +184,18 @@ static TINA_SHARE *get_share(const char *table_name, TABLE *table) share->table_name_length=length; share->table_name=tmp_name; strmov(share->table_name,table_name); - fn_format(data_file_name, table_name, "", ".CSV",MY_REPLACE_EXT|MY_UNPACK_FILENAME); + fn_format(data_file_name, table_name, "", ".CSV", + MY_REPLACE_EXT | MY_UNPACK_FILENAME); + + if ((share->data_file= my_open(data_file_name, O_RDWR|O_APPEND, + MYF(0))) == -1) + goto error; + if (my_hash_insert(&tina_open_tables, (byte*) share)) goto error; thr_lock_init(&share->lock); pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST); - if ((share->data_file= my_open(data_file_name, O_RDWR|O_APPEND, - MYF(0))) == -1) - goto error2; - /* We only use share->data_file for writing, so we scan to the end to append */ if (my_seek(share->data_file, 0, SEEK_END, MYF(0)) == MY_FILEPOS_ERROR) goto error2; @@ -212,6 +214,7 @@ error3: error2: thr_lock_delete(&share->lock); pthread_mutex_destroy(&share->mutex); + hash_delete(&tina_open_tables, (byte*) share); error: pthread_mutex_unlock(&tina_mutex); my_free((gptr) share, MYF(0)); From 5768d57013eefa5f744963996a73c1ab5a15e388 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Aug 2006 16:57:46 +0400 Subject: [PATCH 2/7] Fix for BUG#21247: im_instance_conf.imtest fails on trees with test-1 in their name. The problem was that IM-tests contained grep-statements with too wide patterns. The fix is to make these patterns more restrictive. Only IM-tests have been fixed, no code has been touched. mysql-test/t/im_instance_conf.imtest: Use more restrictive pattern. mysql-test/t/im_options.imtest: Use more restrictive pattern. --- mysql-test/t/im_instance_conf.imtest | 54 ++++++++++++++-------------- mysql-test/t/im_options.imtest | 48 ++++++++++++------------- 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/mysql-test/t/im_instance_conf.imtest b/mysql-test/t/im_instance_conf.imtest index 3d254b16ca5..abd22c1ba9d 100644 --- a/mysql-test/t/im_instance_conf.imtest +++ b/mysql-test/t/im_instance_conf.imtest @@ -37,7 +37,7 @@ # Check that the configuration file contains only instances that we expect. --echo -------------------------------------------------------------------- ---exec grep server_id $MYSQLTEST_VARDIR/im.cnf; +--exec grep '^server_id\>' $MYSQLTEST_VARDIR/im.cnf; --echo -------------------------------------------------------------------- # Check that mysqld1 is reported as running. @@ -79,7 +79,7 @@ CREATE INSTANCE mysqld3 SHOW INSTANCES; --echo -------------------------------------------------------------------- ---exec grep server_id $MYSQLTEST_VARDIR/im.cnf ; +--exec grep '^server_id\>' $MYSQLTEST_VARDIR/im.cnf; --echo -------------------------------------------------------------------- # Check that CREATE INSTANCE fails for existing instance. Let's all three @@ -101,7 +101,7 @@ CREATE INSTANCE mysqld3; # - without values; --echo -------------------------------------------------------------------- ---exec grep nonguarded $MYSQLTEST_VARDIR/im.cnf; +--exec grep '^nonguarded\>' $MYSQLTEST_VARDIR/im.cnf; --echo -------------------------------------------------------------------- CREATE INSTANCE mysqld4 @@ -112,15 +112,15 @@ CREATE INSTANCE mysqld4 SHOW INSTANCES; --echo -------------------------------------------------------------------- ---exec grep nonguarded $MYSQLTEST_VARDIR/im.cnf; +--exec grep '^nonguarded\>' $MYSQLTEST_VARDIR/im.cnf; --echo -------------------------------------------------------------------- # - with value; --echo -------------------------------------------------------------------- ---exec grep test-A $MYSQLTEST_VARDIR/im.cnf || true; +--exec grep '^test-A\>' $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- ---exec grep test-B $MYSQLTEST_VARDIR/im.cnf || true; +--exec grep '^test-B\>' $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- CREATE INSTANCE mysqld5 @@ -132,9 +132,9 @@ CREATE INSTANCE mysqld5 SHOW INSTANCES; --echo -------------------------------------------------------------------- ---exec grep test-A $MYSQLTEST_VARDIR/im.cnf; +--exec grep '^test-A\>' $MYSQLTEST_VARDIR/im.cnf; --echo -------------------------------------------------------------------- ---exec grep test-B $MYSQLTEST_VARDIR/im.cnf; +--exec grep '^test-B\>' $MYSQLTEST_VARDIR/im.cnf; --echo -------------------------------------------------------------------- # Check that CREATE INSTANCE parses options and handles grammar errors @@ -144,7 +144,7 @@ SHOW INSTANCES; # - check handling of extra spaces; --echo -------------------------------------------------------------------- ---exec grep test-C $MYSQLTEST_VARDIR/im.cnf || true; +--exec grep '^test-C\>' $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- CREATE INSTANCE mysqld6 @@ -156,17 +156,17 @@ CREATE INSTANCE mysqld6 SHOW INSTANCES; --echo -------------------------------------------------------------------- ---exec grep test-C1 $MYSQLTEST_VARDIR/im.cnf; +--exec grep '^test-C1\>' $MYSQLTEST_VARDIR/im.cnf; --echo -------------------------------------------------------------------- ---exec grep test-C2 $MYSQLTEST_VARDIR/im.cnf; +--exec grep '^test-C2\>' $MYSQLTEST_VARDIR/im.cnf; --echo -------------------------------------------------------------------- # - check handling of grammar error; --echo -------------------------------------------------------------------- ---exec grep test-D $MYSQLTEST_VARDIR/im.cnf || true; +--exec grep '^test-D\>' $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- ---exec grep test-E $MYSQLTEST_VARDIR/im.cnf || true; +--exec grep '^test-E\>' $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- --error ER_SYNTAX_ERROR @@ -182,21 +182,21 @@ CREATE INSTANCE mysqld8 test-F = ; SHOW INSTANCES; --echo -------------------------------------------------------------------- ---exec grep test-D $MYSQLTEST_VARDIR/im.cnf || true; +--exec grep '^test-D\>' $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- ---exec grep test-E $MYSQLTEST_VARDIR/im.cnf || true; +--exec grep '^test-E\>' $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- # - check parsing of string option values --echo -------------------------------------------------------------------- ---exec grep test-1 $MYSQLTEST_VARDIR/im.cnf || true; +--exec grep '^test-1\>' $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- ---exec grep test-2 $MYSQLTEST_VARDIR/im.cnf || true; +--exec grep '^test-2\>' $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- ---exec grep test-3 $MYSQLTEST_VARDIR/im.cnf || true; +--exec grep '^test-3\>' $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- ---exec grep test-4 $MYSQLTEST_VARDIR/im.cnf || true; +--exec grep '^test-4\>' $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- CREATE INSTANCE mysqld9 @@ -233,21 +233,21 @@ CREATE INSTANCE mysqld13 test-bad=' \ '; SHOW INSTANCES; --echo -------------------------------------------------------------------- ---exec grep test-1 $MYSQLTEST_VARDIR/im.cnf; +--exec grep '^test-1\>' $MYSQLTEST_VARDIR/im.cnf; --echo -------------------------------------------------------------------- ---exec grep test-2 $MYSQLTEST_VARDIR/im.cnf; +--exec grep '^test-2\>' $MYSQLTEST_VARDIR/im.cnf; --echo -------------------------------------------------------------------- ---exec grep test-3 $MYSQLTEST_VARDIR/im.cnf; +--exec grep '^test-3\>' $MYSQLTEST_VARDIR/im.cnf; --echo -------------------------------------------------------------------- ---exec grep test-4 $MYSQLTEST_VARDIR/im.cnf; +--exec grep '^test-4\>' $MYSQLTEST_VARDIR/im.cnf; --echo -------------------------------------------------------------------- ---exec grep test-5 $MYSQLTEST_VARDIR/im.cnf; +--exec grep '^test-5\>' $MYSQLTEST_VARDIR/im.cnf; --echo -------------------------------------------------------------------- ---exec grep test-6 $MYSQLTEST_VARDIR/im.cnf; +--exec grep '^test-6\>' $MYSQLTEST_VARDIR/im.cnf; --echo -------------------------------------------------------------------- ---exec grep test-7 $MYSQLTEST_VARDIR/im.cnf; +--exec grep '^test-7\>' $MYSQLTEST_VARDIR/im.cnf; --echo -------------------------------------------------------------------- ---exec grep test-bad $MYSQLTEST_VARDIR/im.cnf || true; +--exec grep '^test-bad\>' $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- diff --git a/mysql-test/t/im_options.imtest b/mysql-test/t/im_options.imtest index 55bd29c9ee1..fbead0b290c 100644 --- a/mysql-test/t/im_options.imtest +++ b/mysql-test/t/im_options.imtest @@ -43,7 +43,7 @@ # - check the configuration file; --echo -------------------------------------------------------------------- ---exec grep server_id $MYSQLTEST_VARDIR/im.cnf ; +--exec grep '^server_id\>' $MYSQLTEST_VARDIR/im.cnf ; --echo -------------------------------------------------------------------- # - check the running instances. @@ -133,25 +133,25 @@ UNSET mysqld2.server_id = 11; SET mysqld2.aaa, mysqld3.bbb, mysqld2.ccc = 0010, mysqld3.ddd = 0020; --echo -------------------------------------------------------------------- ---exec grep aaa $MYSQLTEST_VARDIR/im.cnf ; +--exec grep '^aaa\>' $MYSQLTEST_VARDIR/im.cnf ; --echo -------------------------------------------------------------------- ---exec grep bbb $MYSQLTEST_VARDIR/im.cnf ; +--exec grep '^bbb\>' $MYSQLTEST_VARDIR/im.cnf ; --echo -------------------------------------------------------------------- ---exec grep ccc $MYSQLTEST_VARDIR/im.cnf ; +--exec grep '^ccc\>' $MYSQLTEST_VARDIR/im.cnf ; --echo -------------------------------------------------------------------- ---exec grep ddd $MYSQLTEST_VARDIR/im.cnf ; +--exec grep '^ddd\>' $MYSQLTEST_VARDIR/im.cnf ; --echo -------------------------------------------------------------------- UNSET mysqld2.aaa, mysqld3.bbb, mysqld2.ccc, mysqld3.ddd; --echo -------------------------------------------------------------------- ---exec grep aaa $MYSQLTEST_VARDIR/im.cnf || true; +--exec grep '^aaa\>' $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- ---exec grep bbb $MYSQLTEST_VARDIR/im.cnf || true; +--exec grep '^bbb\>' $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- ---exec grep ccc $MYSQLTEST_VARDIR/im.cnf || true; +--exec grep '^ccc\>' $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- ---exec grep ddd $MYSQLTEST_VARDIR/im.cnf || true; +--exec grep '^ddd\>' $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- # - check that if some instance name is invalid or the active is active, @@ -161,22 +161,22 @@ UNSET mysqld2.aaa, mysqld3.bbb, mysqld2.ccc, mysqld3.ddd; SET mysqld2.aaa, mysqld3.bbb, mysqld.ccc = 0010; --echo -------------------------------------------------------------------- ---exec grep aaa $MYSQLTEST_VARDIR/im.cnf || true; +--exec grep '^aaa\>' $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- ---exec grep bbb $MYSQLTEST_VARDIR/im.cnf || true; +--exec grep '^bbb\>' $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- ---exec grep ccc $MYSQLTEST_VARDIR/im.cnf || true; +--exec grep '^ccc\>' $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- --error 3015 # ER_INSTANCE_IS_ACTIVE SET mysqld2.aaa, mysqld3.bbb, mysqld1.ccc = 0010; --echo -------------------------------------------------------------------- ---exec grep aaa $MYSQLTEST_VARDIR/im.cnf || true; +--exec grep '^aaa\>' $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- ---exec grep bbb $MYSQLTEST_VARDIR/im.cnf || true; +--exec grep '^bbb\>' $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- ---exec grep ccc $MYSQLTEST_VARDIR/im.cnf || true; +--exec grep '^ccc\>' $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- # - check that if some instance name is invalid or the active is active, @@ -186,14 +186,14 @@ SET mysqld2.aaa, mysqld3.bbb, mysqld1.ccc = 0010; UNSET mysqld2.server_id, mysqld3.server_id, mysqld.ccc; --echo -------------------------------------------------------------------- ---exec grep server_id $MYSQLTEST_VARDIR/im.cnf; +--exec grep '^server_id\>' $MYSQLTEST_VARDIR/im.cnf; --echo -------------------------------------------------------------------- --error 3015 # ER_INSTANCE_IS_ACTIVE UNSET mysqld2.server_id, mysqld3.server_id, mysqld1.ccc; --echo -------------------------------------------------------------------- ---exec grep server_id $MYSQLTEST_VARDIR/im.cnf; +--exec grep '^server_id\>' $MYSQLTEST_VARDIR/im.cnf; --echo -------------------------------------------------------------------- DROP INSTANCE mysqld3; @@ -207,21 +207,21 @@ SET mysqld2 . server_id = 222 ; SET mysqld2 . server_id = 222 , mysqld2 . aaa , mysqld2 . bbb ; --echo -------------------------------------------------------------------- ---exec grep server_id $MYSQLTEST_VARDIR/im.cnf ; +--exec grep '^server_id\>' $MYSQLTEST_VARDIR/im.cnf ; --echo -------------------------------------------------------------------- ---exec grep aaa $MYSQLTEST_VARDIR/im.cnf ; +--exec grep '^aaa\>' $MYSQLTEST_VARDIR/im.cnf ; --echo -------------------------------------------------------------------- ---exec grep bbb $MYSQLTEST_VARDIR/im.cnf ; +--exec grep '^bbb\>' $MYSQLTEST_VARDIR/im.cnf ; --echo -------------------------------------------------------------------- UNSET mysqld2 . aaa , mysqld2 . bbb ; --echo -------------------------------------------------------------------- ---exec grep server_id $MYSQLTEST_VARDIR/im.cnf ; +--exec grep '^server_id\>' $MYSQLTEST_VARDIR/im.cnf ; --echo -------------------------------------------------------------------- ---exec grep aaa $MYSQLTEST_VARDIR/im.cnf || true; +--exec grep '^aaa\>' $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- ---exec grep bbb $MYSQLTEST_VARDIR/im.cnf || true; +--exec grep '^bbb\>' $MYSQLTEST_VARDIR/im.cnf || true; --echo -------------------------------------------------------------------- ########################################################################### @@ -235,7 +235,7 @@ UNSET mysqld2 . aaa , mysqld2 . bbb ; # server_id=SERVER_ID for mysqld2); --echo -------------------------------------------------------------------- ---exec grep server_id $MYSQLTEST_VARDIR/im.cnf ; +--exec grep '^server_id\>' $MYSQLTEST_VARDIR/im.cnf ; --echo -------------------------------------------------------------------- # - (for mysqld1) check that the running instance has not been affected: From 728a924c66d90aa78d49a36a20b578b41e9bd4d4 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 17 Aug 2006 18:13:45 +0200 Subject: [PATCH 3/7] Cleanup patch. There is an existing macros for initializing LEX_STRINGs with constant strings -> C_STRING_WITH_LEN. Change existing code to use it. (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN sql/handler.cc: There is an existing macros for initializing LEX_STRINGs with constant strings -> C_STRING_WITH_LEN. Change existing code to use it. (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN sql/item.cc: There is an existing macros for initializing LEX_STRINGs with constant strings -> C_STRING_WITH_LEN. Change existing code to use it. (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN sql/mysql_priv.h: There is an existing macros for initializing LEX_STRINGs with constant strings -> C_STRING_WITH_LEN. Change existing code to use it. (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN sql/sql_acl.cc: There is an existing macros for initializing LEX_STRINGs with constant strings -> C_STRING_WITH_LEN. Change existing code to use it. (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN sql/sql_error.cc: There is an existing macros for initializing LEX_STRINGs with constant strings -> C_STRING_WITH_LEN. Change existing code to use it. (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN sql/sql_error.h: There is an existing macros for initializing LEX_STRINGs with constant strings -> C_STRING_WITH_LEN. Change existing code to use it. (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN sql/sql_lex.h: There is an existing macros for initializing LEX_STRINGs with constant strings -> C_STRING_WITH_LEN. Change existing code to use it. (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN sql/sql_parse.cc: There is an existing macros for initializing LEX_STRINGs with constant strings -> C_STRING_WITH_LEN. Change existing code to use it. (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN sql/sql_partition.cc: There is an existing macros for initializing LEX_STRINGs with constant strings -> C_STRING_WITH_LEN. Change existing code to use it. (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN sql/sql_plugin.cc: There is an existing macros for initializing LEX_STRINGs with constant strings -> C_STRING_WITH_LEN. Change existing code to use it. (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN sql/sql_show.cc: There is an existing macros for initializing LEX_STRINGs with constant strings -> C_STRING_WITH_LEN. Change existing code to use it. (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN sql/sql_trigger.cc: There is an existing macros for initializing LEX_STRINGs with constant strings -> C_STRING_WITH_LEN. Change existing code to use it. (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN sql/sql_view.cc: There is an existing macros for initializing LEX_STRINGs with constant strings -> C_STRING_WITH_LEN. Change existing code to use it. (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN sql/tztime.cc: There is an existing macros for initializing LEX_STRINGs with constant strings -> C_STRING_WITH_LEN. Change existing code to use it. (char *) STRING_WITH_LEN -> C_STRING_WITH_LEN --- sql/handler.cc | 10 ++-- sql/item.cc | 2 +- sql/mysql_priv.h | 2 +- sql/sql_acl.cc | 126 +++++++++++++++++++++---------------------- sql/sql_error.cc | 10 ++-- sql/sql_error.h | 2 +- sql/sql_lex.h | 10 ++-- sql/sql_parse.cc | 70 ++++++++++++------------ sql/sql_partition.cc | 12 ++--- sql/sql_plugin.cc | 6 +-- sql/sql_show.cc | 10 ++-- sql/sql_trigger.cc | 24 ++++----- sql/sql_view.cc | 26 ++++----- sql/tztime.cc | 10 ++-- 14 files changed, 160 insertions(+), 160 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index fbccfe7fa46..e1fb8e07a05 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -72,11 +72,11 @@ ulong savepoint_alloc_size= 0; static const LEX_STRING sys_table_aliases[]= { - {(char*)STRING_WITH_LEN("INNOBASE")}, {(char*)STRING_WITH_LEN("INNODB")}, - {(char*)STRING_WITH_LEN("NDB")}, {(char*)STRING_WITH_LEN("NDBCLUSTER")}, - {(char*)STRING_WITH_LEN("BDB")}, {(char*)STRING_WITH_LEN("BERKELEYDB")}, - {(char*)STRING_WITH_LEN("HEAP")}, {(char*)STRING_WITH_LEN("MEMORY")}, - {(char*)STRING_WITH_LEN("MERGE")}, {(char*)STRING_WITH_LEN("MRG_MYISAM")}, + { C_STRING_WITH_LEN("INNOBASE") }, { C_STRING_WITH_LEN("INNODB") }, + { C_STRING_WITH_LEN("NDB") }, { C_STRING_WITH_LEN("NDBCLUSTER") }, + { C_STRING_WITH_LEN("BDB") }, { C_STRING_WITH_LEN("BERKELEYDB") }, + { C_STRING_WITH_LEN("HEAP") }, { C_STRING_WITH_LEN("MEMORY") }, + { C_STRING_WITH_LEN("MERGE") }, { C_STRING_WITH_LEN("MRG_MYISAM")}, {NullS, 0} }; diff --git a/sql/item.cc b/sql/item.cc index 1afe25b1990..4d6dc8ae754 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1004,7 +1004,7 @@ bool Item_splocal::set_value(THD *thd, sp_rcontext *ctx, Item **it) *****************************************************************************/ Item_case_expr::Item_case_expr(int case_expr_id) - :Item_sp_variable((char *) STRING_WITH_LEN("case_expr")), + :Item_sp_variable( C_STRING_WITH_LEN("case_expr")), m_case_expr_id(case_expr_id) { } diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index a9ecbb23a27..651b0405842 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1479,7 +1479,7 @@ extern char *mysql_data_home,server_version[SERVER_VERSION_LENGTH], def_ft_boolean_syntax[sizeof(ft_boolean_syntax)]; #define mysql_tmpdir (my_tmpdir(&mysql_tmpdir_list)) extern MY_TMPDIR mysql_tmpdir_list; -extern LEX_STRING command_name[]; +extern const LEX_STRING command_name[]; extern const char *first_keyword, *my_localhost, *delayed_user, *binary_keyword; extern const char **errmesg; /* Error messages */ extern const char *myisam_recover_options_str; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 966d0f88ca3..402cfc4de60 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -36,114 +36,114 @@ time_t mysql_db_table_last_check= 0L; TABLE_FIELD_W_TYPE mysql_db_table_fields[MYSQL_DB_FIELD_COUNT] = { { - {(char *) STRING_WITH_LEN("Host")}, - {(char *) STRING_WITH_LEN("char(60)")}, + { C_STRING_WITH_LEN("Host") }, + { C_STRING_WITH_LEN("char(60)") }, {NULL, 0} }, { - {(char *) STRING_WITH_LEN("Db")}, - {(char *) STRING_WITH_LEN("char(64)")}, + { C_STRING_WITH_LEN("Db") }, + { C_STRING_WITH_LEN("char(64)") }, {NULL, 0} }, { - {(char *) STRING_WITH_LEN("User")}, - {(char *) STRING_WITH_LEN("char(16)")}, + { C_STRING_WITH_LEN("User") }, + { C_STRING_WITH_LEN("char(16)") }, {NULL, 0} }, { - {(char *) STRING_WITH_LEN("Select_priv")}, - {(char *) STRING_WITH_LEN("enum('N','Y')")}, - {(char *) STRING_WITH_LEN("utf8")} + { C_STRING_WITH_LEN("Select_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } }, { - {(char *) STRING_WITH_LEN("Insert_priv")}, - {(char *) STRING_WITH_LEN("enum('N','Y')")}, - {(char *) STRING_WITH_LEN("utf8")} + { C_STRING_WITH_LEN("Insert_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } }, { - {(char *) STRING_WITH_LEN("Update_priv")}, - {(char *) STRING_WITH_LEN("enum('N','Y')")}, - {(char *) STRING_WITH_LEN("utf8")} + { C_STRING_WITH_LEN("Update_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } }, { - {(char *) STRING_WITH_LEN("Delete_priv")}, - {(char *) STRING_WITH_LEN("enum('N','Y')")}, - {(char *) STRING_WITH_LEN("utf8")} + { C_STRING_WITH_LEN("Delete_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } }, { - {(char *) STRING_WITH_LEN("Create_priv")}, - {(char *) STRING_WITH_LEN("enum('N','Y')")}, - {(char *) STRING_WITH_LEN("utf8")} + { C_STRING_WITH_LEN("Create_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } }, { - {(char *) STRING_WITH_LEN("Drop_priv")}, - {(char *) STRING_WITH_LEN("enum('N','Y')")}, - {(char *) STRING_WITH_LEN("utf8")} + { C_STRING_WITH_LEN("Drop_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } }, { - {(char *) STRING_WITH_LEN("Grant_priv")}, - {(char *) STRING_WITH_LEN("enum('N','Y')")}, - {(char *) STRING_WITH_LEN("utf8")} + { C_STRING_WITH_LEN("Grant_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } }, { - {(char *) STRING_WITH_LEN("References_priv")}, - {(char *) STRING_WITH_LEN("enum('N','Y')")}, - {(char *) STRING_WITH_LEN("utf8")} + { C_STRING_WITH_LEN("References_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } }, { - {(char *) STRING_WITH_LEN("Index_priv")}, - {(char *) STRING_WITH_LEN("enum('N','Y')")}, - {(char *) STRING_WITH_LEN("utf8")} + { C_STRING_WITH_LEN("Index_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } }, { - {(char *) STRING_WITH_LEN("Alter_priv")}, - {(char *) STRING_WITH_LEN("enum('N','Y')")}, - {(char *) STRING_WITH_LEN("utf8")} + { C_STRING_WITH_LEN("Alter_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } }, { - {(char *) STRING_WITH_LEN("Create_tmp_table_priv")}, - {(char *) STRING_WITH_LEN("enum('N','Y')")}, - {(char *) STRING_WITH_LEN("utf8")} + { C_STRING_WITH_LEN("Create_tmp_table_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } }, { - {(char *) STRING_WITH_LEN("Lock_tables_priv")}, - {(char *) STRING_WITH_LEN("enum('N','Y')")}, - {(char *) STRING_WITH_LEN("utf8")} + { C_STRING_WITH_LEN("Lock_tables_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } }, { - {(char *) STRING_WITH_LEN("Create_view_priv")}, - {(char *) STRING_WITH_LEN("enum('N','Y')")}, - {(char *) STRING_WITH_LEN("utf8")} + { C_STRING_WITH_LEN("Create_view_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } }, { - {(char *) STRING_WITH_LEN("Show_view_priv")}, - {(char *) STRING_WITH_LEN("enum('N','Y')")}, - {(char *) STRING_WITH_LEN("utf8")} + { C_STRING_WITH_LEN("Show_view_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } }, { - {(char *) STRING_WITH_LEN("Create_routine_priv")}, - {(char *) STRING_WITH_LEN("enum('N','Y')")}, - {(char *) STRING_WITH_LEN("utf8")} + { C_STRING_WITH_LEN("Create_routine_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } }, { - {(char *) STRING_WITH_LEN("Alter_routine_priv")}, - {(char *) STRING_WITH_LEN("enum('N','Y')")}, - {(char *) STRING_WITH_LEN("utf8")} + { C_STRING_WITH_LEN("Alter_routine_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } }, { - {(char *) STRING_WITH_LEN("Execute_priv")}, - {(char *) STRING_WITH_LEN("enum('N','Y')")}, - {(char *) STRING_WITH_LEN("utf8")} + { C_STRING_WITH_LEN("Execute_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } }, { - {(char *) STRING_WITH_LEN("Event_priv")}, - {(char *) STRING_WITH_LEN("enum('N','Y')")}, - {(char *) STRING_WITH_LEN("utf8")} + { C_STRING_WITH_LEN("Event_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } }, { - {(char *) STRING_WITH_LEN("Trigger_priv")}, - {(char *) STRING_WITH_LEN("enum('N','Y')")}, - {(char *) STRING_WITH_LEN("utf8")} + { C_STRING_WITH_LEN("Trigger_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } } }; diff --git a/sql/sql_error.cc b/sql/sql_error.cc index 58763881ecf..9a9a9784df3 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -212,12 +212,12 @@ void push_warning_printf(THD *thd, MYSQL_ERROR::enum_warning_level level, TRUE Error sending data to client */ -LEX_STRING warning_level_names[]= +const LEX_STRING warning_level_names[]= { - {(char*) STRING_WITH_LEN("Note")}, - {(char*) STRING_WITH_LEN("Warning")}, - {(char*) STRING_WITH_LEN("Error")}, - {(char*) STRING_WITH_LEN("?")} + { C_STRING_WITH_LEN("Note") }, + { C_STRING_WITH_LEN("Warning") }, + { C_STRING_WITH_LEN("Error") }, + { C_STRING_WITH_LEN("?") } }; bool mysqld_show_warnings(THD *thd, ulong levels_to_show) diff --git a/sql/sql_error.h b/sql/sql_error.h index b5cac24d894..f4a7b14ba1a 100644 --- a/sql/sql_error.h +++ b/sql/sql_error.h @@ -41,4 +41,4 @@ void push_warning_printf(THD *thd, MYSQL_ERROR::enum_warning_level level, void mysql_reset_errors(THD *thd, bool force); bool mysqld_show_warnings(THD *thd, ulong levels_to_show); -extern LEX_STRING warning_level_names[]; +extern const LEX_STRING warning_level_names[]; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 55dc6cb55a4..5c0a88542b8 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -149,11 +149,11 @@ enum enum_sp_data_access const LEX_STRING sp_data_access_name[]= { - { (char*) STRING_WITH_LEN("") }, - { (char*) STRING_WITH_LEN("CONTAINS SQL") }, - { (char*) STRING_WITH_LEN("NO SQL") }, - { (char*) STRING_WITH_LEN("READS SQL DATA") }, - { (char*) STRING_WITH_LEN("MODIFIES SQL DATA") } + { C_STRING_WITH_LEN("") }, + { C_STRING_WITH_LEN("CONTAINS SQL") }, + { C_STRING_WITH_LEN("NO SQL") }, + { C_STRING_WITH_LEN("READS SQL DATA") }, + { C_STRING_WITH_LEN("MODIFIES SQL DATA") } }; #define DERIVED_SUBQUERY 1 diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 1af80f2c4b0..b5154d60ed2 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -72,38 +72,38 @@ static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables); const char *any_db="*any*"; // Special symbol for check_access -LEX_STRING command_name[]={ - (char *)STRING_WITH_LEN("Sleep"), - (char *)STRING_WITH_LEN("Quit"), - (char *)STRING_WITH_LEN("Init DB"), - (char *)STRING_WITH_LEN("Query"), - (char *)STRING_WITH_LEN("Field List"), - (char *)STRING_WITH_LEN("Create DB"), - (char *)STRING_WITH_LEN("Drop DB"), - (char *)STRING_WITH_LEN("Refresh"), - (char *)STRING_WITH_LEN("Shutdown"), - (char *)STRING_WITH_LEN("Statistics"), - (char *)STRING_WITH_LEN("Processlist"), - (char *)STRING_WITH_LEN("Connect"), - (char *)STRING_WITH_LEN("Kill"), - (char *)STRING_WITH_LEN("Debug"), - (char *)STRING_WITH_LEN("Ping"), - (char *)STRING_WITH_LEN("Time"), - (char *)STRING_WITH_LEN("Delayed insert"), - (char *)STRING_WITH_LEN("Change user"), - (char *)STRING_WITH_LEN("Binlog Dump"), - (char *)STRING_WITH_LEN("Table Dump"), - (char *)STRING_WITH_LEN("Connect Out"), - (char *)STRING_WITH_LEN("Register Slave"), - (char *)STRING_WITH_LEN("Prepare"), - (char *)STRING_WITH_LEN("Execute"), - (char *)STRING_WITH_LEN("Long Data"), - (char *)STRING_WITH_LEN("Close stmt"), - (char *)STRING_WITH_LEN("Reset stmt"), - (char *)STRING_WITH_LEN("Set option"), - (char *)STRING_WITH_LEN("Fetch"), - (char *)STRING_WITH_LEN("Daemon"), - (char *)STRING_WITH_LEN("Error") // Last command number +const LEX_STRING command_name[]={ + C_STRING_WITH_LEN("Sleep"), + C_STRING_WITH_LEN("Quit"), + C_STRING_WITH_LEN("Init DB"), + C_STRING_WITH_LEN("Query"), + C_STRING_WITH_LEN("Field List"), + C_STRING_WITH_LEN("Create DB"), + C_STRING_WITH_LEN("Drop DB"), + C_STRING_WITH_LEN("Refresh"), + C_STRING_WITH_LEN("Shutdown"), + C_STRING_WITH_LEN("Statistics"), + C_STRING_WITH_LEN("Processlist"), + C_STRING_WITH_LEN("Connect"), + C_STRING_WITH_LEN("Kill"), + C_STRING_WITH_LEN("Debug"), + C_STRING_WITH_LEN("Ping"), + C_STRING_WITH_LEN("Time"), + C_STRING_WITH_LEN("Delayed insert"), + C_STRING_WITH_LEN("Change user"), + C_STRING_WITH_LEN("Binlog Dump"), + C_STRING_WITH_LEN("Table Dump"), + C_STRING_WITH_LEN("Connect Out"), + C_STRING_WITH_LEN("Register Slave"), + C_STRING_WITH_LEN("Prepare"), + C_STRING_WITH_LEN("Execute"), + C_STRING_WITH_LEN("Long Data"), + C_STRING_WITH_LEN("Close stmt"), + C_STRING_WITH_LEN("Reset stmt"), + C_STRING_WITH_LEN("Set option"), + C_STRING_WITH_LEN("Fetch"), + C_STRING_WITH_LEN("Daemon"), + C_STRING_WITH_LEN("Error") // Last command number }; const char *xa_state_names[]={ @@ -4940,9 +4940,9 @@ end_with_restore_list: { String buff; const LEX_STRING command[3]= - {{(char *)STRING_WITH_LEN("CREATE ")}, - {(char *)STRING_WITH_LEN("ALTER ")}, - {(char *)STRING_WITH_LEN("CREATE OR REPLACE ")}}; + {{ C_STRING_WITH_LEN("CREATE ") }, + { C_STRING_WITH_LEN("ALTER ") }, + { C_STRING_WITH_LEN("CREATE OR REPLACE ") }}; thd->clear_error(); buff.append(command[thd->lex->create_view_mode].str, diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 73091c0994e..69a345bf2a4 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -46,12 +46,12 @@ */ const LEX_STRING partition_keywords[]= { - { (char *) STRING_WITH_LEN("HASH") }, - { (char *) STRING_WITH_LEN("RANGE") }, - { (char *) STRING_WITH_LEN("LIST") }, - { (char *) STRING_WITH_LEN("KEY") }, - { (char *) STRING_WITH_LEN("MAXVALUE") }, - { (char *) STRING_WITH_LEN("LINEAR ") } + { C_STRING_WITH_LEN("HASH") }, + { C_STRING_WITH_LEN("RANGE") }, + { C_STRING_WITH_LEN("LIST") }, + { C_STRING_WITH_LEN("KEY") }, + { C_STRING_WITH_LEN("MAXVALUE") }, + { C_STRING_WITH_LEN("LINEAR ") } }; static const char *part_str= "PARTITION"; static const char *sub_str= "SUB"; diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index f7205470abd..8dc00908fc5 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -25,9 +25,9 @@ char *opt_plugin_dir_ptr; char opt_plugin_dir[FN_REFLEN]; const LEX_STRING plugin_type_names[MYSQL_MAX_PLUGIN_TYPE_NUM]= { - { (char *)STRING_WITH_LEN("UDF") }, - { (char *)STRING_WITH_LEN("STORAGE ENGINE") }, - { (char *)STRING_WITH_LEN("FTPARSER") } + { C_STRING_WITH_LEN("UDF") }, + { C_STRING_WITH_LEN("STORAGE ENGINE") }, + { C_STRING_WITH_LEN("FTPARSER") } }; plugin_type_init plugin_type_initialize[MYSQL_MAX_PLUGIN_TYPE_NUM]= diff --git a/sql/sql_show.cc b/sql/sql_show.cc index bf09f516499..530315b507b 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2159,7 +2159,7 @@ LEX_STRING *make_lex_string(THD *thd, LEX_STRING *lex_str, /* INFORMATION_SCHEMA name */ -LEX_STRING information_schema_name= {(char*)"information_schema", 18}; +LEX_STRING information_schema_name= { C_STRING_WITH_LEN("information_schema")}; /* This is only used internally, but we need it here as a forward reference */ extern ST_SCHEMA_TABLE schema_tables[]; @@ -3189,10 +3189,10 @@ static my_bool iter_schema_engines(THD *thd, st_plugin_int *plugin, if (!(wild && wild[0] && wild_case_compare(scs, plugin->name.str,wild))) { - LEX_STRING state[2]= {{(char*) STRING_WITH_LEN("ENABLED")}, - {(char*) STRING_WITH_LEN("DISABLED")}}; - LEX_STRING yesno[2]= {{(char*) STRING_WITH_LEN("NO")}, - {(char*) STRING_WITH_LEN("YES")}}; + LEX_STRING state[2]= {{ C_STRING_WITH_LEN("ENABLED") }, + { C_STRING_WITH_LEN("DISABLED") }}; + LEX_STRING yesno[2]= {{ C_STRING_WITH_LEN("NO") }, + { C_STRING_WITH_LEN("YES") }}; LEX_STRING *tmp; restore_record(table, s->default_values); diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 1837372c6c4..e990b7bc86d 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -22,7 +22,7 @@ #include "parse_file.h" static const LEX_STRING triggers_file_type= - {(char *) STRING_WITH_LEN("TRIGGERS")}; + { C_STRING_WITH_LEN("TRIGGERS") }; const char * const triggers_file_ext= ".TRG"; @@ -35,17 +35,17 @@ const char * const triggers_file_ext= ".TRG"; static File_option triggers_file_parameters[]= { { - {(char *) STRING_WITH_LEN("triggers") }, + { C_STRING_WITH_LEN("triggers") }, offsetof(class Table_triggers_list, definitions_list), FILE_OPTIONS_STRLIST }, { - {(char *) STRING_WITH_LEN("sql_modes") }, + { C_STRING_WITH_LEN("sql_modes") }, offsetof(class Table_triggers_list, definition_modes_list), FILE_OPTIONS_ULLLIST }, { - {(char *) STRING_WITH_LEN("definers") }, + { C_STRING_WITH_LEN("definers") }, offsetof(class Table_triggers_list, definers_list), FILE_OPTIONS_STRLIST }, @@ -54,7 +54,7 @@ static File_option triggers_file_parameters[]= File_option sql_modes_parameters= { - {(char*) STRING_WITH_LEN("sql_modes") }, + { C_STRING_WITH_LEN("sql_modes") }, offsetof(class Table_triggers_list, definition_modes_list), FILE_OPTIONS_ULLLIST }; @@ -78,14 +78,14 @@ struct st_trigname }; static const LEX_STRING trigname_file_type= - {(char *) STRING_WITH_LEN("TRIGGERNAME")}; + { C_STRING_WITH_LEN("TRIGGERNAME") }; const char * const trigname_file_ext= ".TRN"; static File_option trigname_file_parameters[]= { { - {(char *) STRING_WITH_LEN("trigger_table")}, + { C_STRING_WITH_LEN("trigger_table")}, offsetof(struct st_trigname, trigger_table), FILE_OPTIONS_ESTRING }, @@ -95,15 +95,15 @@ static File_option trigname_file_parameters[]= const LEX_STRING trg_action_time_type_names[]= { - { (char *) STRING_WITH_LEN("BEFORE") }, - { (char *) STRING_WITH_LEN("AFTER") } + { C_STRING_WITH_LEN("BEFORE") }, + { C_STRING_WITH_LEN("AFTER") } }; const LEX_STRING trg_event_type_names[]= { - { (char *) STRING_WITH_LEN("INSERT") }, - { (char *) STRING_WITH_LEN("UPDATE") }, - { (char *) STRING_WITH_LEN("DELETE") } + { C_STRING_WITH_LEN("INSERT") }, + { C_STRING_WITH_LEN("UPDATE") }, + { C_STRING_WITH_LEN("DELETE") } }; diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 09a199b2738..66258fca945 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -25,7 +25,7 @@ #define MD5_BUFF_LENGTH 33 -const LEX_STRING view_type= { (char*) STRING_WITH_LEN("VIEW") }; +const LEX_STRING view_type= { C_STRING_WITH_LEN("VIEW") }; static int mysql_register_view(THD *thd, TABLE_LIST *view, enum_view_create_mode mode); @@ -579,40 +579,40 @@ static const int num_view_backups= 3; parse() */ static File_option view_parameters[]= -{{{(char*) STRING_WITH_LEN("query")}, +{{{ C_STRING_WITH_LEN("query")}, offsetof(TABLE_LIST, query), FILE_OPTIONS_ESTRING}, - {{(char*) STRING_WITH_LEN("md5")}, + {{ C_STRING_WITH_LEN("md5")}, offsetof(TABLE_LIST, md5), FILE_OPTIONS_STRING}, - {{(char*) STRING_WITH_LEN("updatable")}, + {{ C_STRING_WITH_LEN("updatable")}, offsetof(TABLE_LIST, updatable_view), FILE_OPTIONS_ULONGLONG}, - {{(char*) STRING_WITH_LEN("algorithm")}, + {{ C_STRING_WITH_LEN("algorithm")}, offsetof(TABLE_LIST, algorithm), FILE_OPTIONS_ULONGLONG}, - {{(char*) STRING_WITH_LEN("definer_user")}, + {{ C_STRING_WITH_LEN("definer_user")}, offsetof(TABLE_LIST, definer.user), FILE_OPTIONS_STRING}, - {{(char*) STRING_WITH_LEN("definer_host")}, + {{ C_STRING_WITH_LEN("definer_host")}, offsetof(TABLE_LIST, definer.host), FILE_OPTIONS_STRING}, - {{(char*) STRING_WITH_LEN("suid")}, + {{ C_STRING_WITH_LEN("suid")}, offsetof(TABLE_LIST, view_suid), FILE_OPTIONS_ULONGLONG}, - {{(char*) STRING_WITH_LEN("with_check_option")}, + {{ C_STRING_WITH_LEN("with_check_option")}, offsetof(TABLE_LIST, with_check), FILE_OPTIONS_ULONGLONG}, - {{(char*) STRING_WITH_LEN("revision")}, + {{ C_STRING_WITH_LEN("revision")}, offsetof(TABLE_LIST, revision), FILE_OPTIONS_REV}, - {{(char*) STRING_WITH_LEN("timestamp")}, + {{ C_STRING_WITH_LEN("timestamp")}, offsetof(TABLE_LIST, timestamp), FILE_OPTIONS_TIMESTAMP}, - {{(char*)STRING_WITH_LEN("create-version")}, + {{ C_STRING_WITH_LEN("create-version")}, offsetof(TABLE_LIST, file_version), FILE_OPTIONS_ULONGLONG}, - {{(char*) STRING_WITH_LEN("source")}, + {{ C_STRING_WITH_LEN("source")}, offsetof(TABLE_LIST, source), FILE_OPTIONS_ESTRING}, {{NullS, 0}, 0, diff --git a/sql/tztime.cc b/sql/tztime.cc index 4f6542bd043..a1bcf25bb51 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -1389,15 +1389,15 @@ static bool time_zone_tables_exist= 1; static const LEX_STRING tz_tables_names[MY_TZ_TABLES_COUNT]= { - {(char *) STRING_WITH_LEN("time_zone_name")}, - {(char *) STRING_WITH_LEN("time_zone")}, - {(char *) STRING_WITH_LEN("time_zone_transition_type")}, - {(char *) STRING_WITH_LEN("time_zone_transition")} + { C_STRING_WITH_LEN("time_zone_name")}, + { C_STRING_WITH_LEN("time_zone")}, + { C_STRING_WITH_LEN("time_zone_transition_type")}, + { C_STRING_WITH_LEN("time_zone_transition")} }; /* Name of database to which those tables belong. */ -static const LEX_STRING tz_tables_db_name= {(char *) STRING_WITH_LEN("mysql")}; +static const LEX_STRING tz_tables_db_name= { C_STRING_WITH_LEN("mysql")}; class Tz_names_entry: public Sql_alloc From 8daf4e8373b9fc3def33e2146445cd1600cbc084 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 21 Aug 2006 12:18:59 +0400 Subject: [PATCH 4/7] Fix for bug#21216 "Simultaneous DROP TABLE and SHOW OPEN TABLES causes server to crash". Crash caused by assertion failure happened when one ran SHOW OPEN TABLES while concurrently doing DROP TABLE (or RENAME TABLE, CREATE TABLE LIKE or any other command that takes name-lock) in other connection. For non-debug version of server problem exposed itself as wrong output of SHOW OPEN TABLES statement (it was missing name-locked tables). Finally in 5.1 both debug and non-debug versions simply crashed in this situation due to NULL-pointer dereference. This problem was caused by the fact that table placeholders which were added to table cache in order to obtain name-lock had TABLE_SHARE::table_name set to 0. Therefore they broke assumption that this member is non-0 for all tables in table cache which was checked by assert in list_open_tables() (in 5.1 this function simply relies on it). The fix simply sets this member for such placeholders to appropriate value making this assumption true again. This patch also includes test for similar bug 12212 "Crash that happens during removing of database name from cache" reappeared in 5.1 as bug 19403. mysql-test/r/drop.result: Added test for bug#21216 "Simultaneous DROP TABLE and SHOW OPEN TABLES causes server to crash" and bug#12212/19403 "Crash that happens during removing of database name from cache". mysql-test/t/drop.test: Added test for bug#21216 "Simultaneous DROP TABLE and SHOW OPEN TABLES causes server to crash" and bug#12212/19403 "Crash that happens during removing of database name from cache". sql/lock.cc: lock_table_name(): Our code assumes that TABLE_SHARE::table_name for objects in table cache is non-NULL (for example look at assertion in list_open_tables()). This was not true for table placeholders that were added to table cache for name-locking. So let us set this member for such placeholders. --- mysql-test/r/drop.result | 13 +++++++++++++ mysql-test/t/drop.test | 41 ++++++++++++++++++++++++++++++++++++++++ sql/lock.cc | 7 +++++-- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/drop.result b/mysql-test/r/drop.result index 979e5d48871..d122dabc4ec 100644 --- a/mysql-test/r/drop.result +++ b/mysql-test/r/drop.result @@ -72,3 +72,16 @@ show tables; Tables_in_test t1 drop table t1; +drop database if exists mysqltest; +drop table if exists t1; +create table t1 (i int); +lock tables t1 read; +create database mysqltest; + drop table t1; +show open tables; + drop database mysqltest; +select 1; +1 +1 +unlock tables; +End of 5.0 tests diff --git a/mysql-test/t/drop.test b/mysql-test/t/drop.test index 7cd943d46da..a1451773e90 100644 --- a/mysql-test/t/drop.test +++ b/mysql-test/t/drop.test @@ -81,3 +81,44 @@ show tables; drop table t1; # End of 4.1 tests + + +# +# Test for bug#21216 "Simultaneous DROP TABLE and SHOW OPEN TABLES causes +# server to crash". Crash (caused by failed assertion in 5.0 or by null +# pointer dereference in 5.1) happened when one ran SHOW OPEN TABLES +# while concurrently doing DROP TABLE (or RENAME TABLE, CREATE TABLE LIKE +# or any other command that takes name-lock) in other connection. +# +# Also includes test for similar bug#12212 "Crash that happens during +# removing of database name from cache" reappeared in 5.1 as bug#19403 +# In its case crash happened when one concurrently executed DROP DATABASE +# and one of name-locking command. +# +--disable_warnings +drop database if exists mysqltest; +drop table if exists t1; +--enable_warnings +create table t1 (i int); +lock tables t1 read; +create database mysqltest; +connect (addconroot1, localhost, root,,); +--send drop table t1 +connect (addconroot2, localhost, root,,); +# Server should not crash in any of the following statements +--disable_result_log +show open tables; +--enable_result_log +--send drop database mysqltest +connection default; +select 1; +unlock tables; +connection addconroot1; +--reap +connection addconroot2; +--reap +disconnect addconroot1; +disconnect addconroot2; +connection default; + +--echo End of 5.0 tests diff --git a/sql/lock.cc b/sql/lock.cc index 97a080c5634..90ddcc957a2 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -854,6 +854,7 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list) TABLE *table; char key[MAX_DBKEY_LENGTH]; char *db= table_list->db; + int table_in_key_offset; uint key_length; HASH_SEARCH_STATE state; DBUG_ENTER("lock_table_name"); @@ -861,8 +862,9 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list) safe_mutex_assert_owner(&LOCK_open); - key_length=(uint) (strmov(strmov(key,db)+1,table_list->table_name) - -key)+ 1; + table_in_key_offset= strmov(key, db) - key + 1; + key_length= (uint)(strmov(key + table_in_key_offset, table_list->table_name) + - key) + 1; /* Only insert the table if we haven't insert it already */ @@ -883,6 +885,7 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list) table->s= &table->share_not_to_be_used; memcpy((table->s->table_cache_key= (char*) (table+1)), key, key_length); table->s->db= table->s->table_cache_key; + table->s->table_name= table->s->table_cache_key + table_in_key_offset; table->s->key_length=key_length; table->in_use=thd; table->locked_by_name=1; From 992aceaf71fec15cef86d31550e1f7428bbbb8e9 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 21 Aug 2006 19:02:11 +0400 Subject: [PATCH 5/7] Fix for bug#19403/12212 "Crash that happens during removing of database name from cache" and #21216 "Simultaneous DROP TABLE and SHOW OPEN TABLES causes server to crash". Crash happened when one ran DROP DATABASE or SHOW OPEN TABLES statements while concurrently doing DROP TABLE (or RENAME TABLE, CREATE TABLE LIKE or any other command that takes name-lock) in other connection. This problem was caused by the fact that table placeholders which were added to table cache in order to obtain name-lock on table had TABLE_SHARE::db and table_name set to 0. Therefore they broke assumption that these members are non-0 for all tables in table cache on which some of our code relies. The fix sets these members for such placeholders to appropriate value making this assumption true again. As attempt to avoid such problems in future we introduce auxiliary TABLE_SHARE::set_table_cache_key() methods which should be used when one wants to set TABLE_SHARE::table_cache_key and which ensure that TABLE_SHARE::table_name/db are set properly. Test cases for these bugs were added to 5.0 test-suite (with 5.0-specific fix for bug #21216). sql/lock.cc: Our code assumes that TABLE_SHARE::table_name/db for objects in table cache is set properly (and is non-NULL). For example look in list_open_tables() and remove_db_from_cache(). This was not true for table placeholders that were added to table cache for name-locking. Changed lock_table_name() to preserve this assumption (now it uses TABLE_SHARE::set_table_cache_key() to set all three table_cache_key/db/table_name members at once). Also now we use my_multi_malloc() to allocate memory for TABLE and TABLE_SHARE objects instead of using my_malloc() + summing sizes as it automatically provides proper alignment for memory allocated. sql/sql_base.cc: Now we use TABLE_SHARE::set_table_cache_key() auxiliary methods to set TABLE_SHARE::table_cache_key/db/table_name members at once. We also use multi_alloc_root() instead of alloc_root() for allocating memory for several objects as it is less error prone. Finally, we also got rid of unused code in reopen_name_locked_table(). sql/sql_select.cc: Got rid of redundant code. TABLE_SHARE::db/table_cache_key are both set to empty string by the call to init_tmp_table_share() routine. sql/table.cc: Now alloc_table_share() uses auxiliary TABLE_SHARE::set_table_cache_key() method to properly set TABLE_SHARE::table_cache_key/db/table_name members. Also now we use multi_alloc_root() instead of alloc_root() for allocating memory for several objects as it is more clear/less error-prone. sql/table.h: Added comment about importance of apropriate setting of TABLE_SHARE::table_name/db/table_cache_key for tables in table cache. Introduced two auxiliary TABLE_SHARE::set_table_cache_key() methods which allow to set these three members at once. --- sql/lock.cc | 21 ++++++++------- sql/sql_base.cc | 41 ++++++++---------------------- sql/sql_select.cc | 2 -- sql/table.cc | 20 ++++++--------- sql/table.h | 65 ++++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 95 insertions(+), 54 deletions(-) diff --git a/sql/lock.cc b/sql/lock.cc index 8e75ea42f7d..06f538a2a03 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -874,6 +874,8 @@ end: int lock_table_name(THD *thd, TABLE_LIST *table_list, bool check_in_use) { TABLE *table; + TABLE_SHARE *share; + char *key_buff; char key[MAX_DBKEY_LENGTH]; char *db= table_list->db; uint key_length; @@ -903,17 +905,18 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list, bool check_in_use) } /* Create a table entry with the right key and with an old refresh version - Note that we must use my_malloc() here as this is freed by the table - cache + Note that we must use my_multi_malloc() here as this is freed by the + table cache */ - if (!(table= (TABLE*) my_malloc(sizeof(*table)+ sizeof(TABLE_SHARE)+ - key_length, MYF(MY_WME | MY_ZEROFILL)))) + if (!my_multi_malloc(MYF(MY_WME | MY_ZEROFILL), + &table, sizeof(*table), + &share, sizeof(*share), + &key_buff, key_length, + NULL)) DBUG_RETURN(-1); - table->s= (TABLE_SHARE*) (table+1); - memcpy((table->s->table_cache_key.str= (char*) (table->s+1)), key, - key_length); - table->s->table_cache_key.length= key_length; - table->s->tmp_table= INTERNAL_TMP_TABLE; // for intern_close_table + table->s= share; + share->set_table_cache_key(key_buff, key, key_length); + share->tmp_table= INTERNAL_TMP_TABLE; // for intern_close_table table->in_use= thd; table->locked_by_name=1; table_list->table=table; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 1c733e3c12d..32a622c7401 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -634,6 +634,7 @@ TABLE_SHARE *get_cached_table_share(const char *db, const char *table_name) static void close_handle_and_leave_table_as_lock(TABLE *table) { TABLE_SHARE *share, *old_share= table->s; + char *key_buff; MEM_ROOT *mem_root= &table->mem_root; DBUG_ENTER("close_handle_and_leave_table_as_lock"); @@ -642,20 +643,14 @@ static void close_handle_and_leave_table_as_lock(TABLE *table) This has to be done to ensure that the table share is removed from the table defintion cache as soon as the last instance is removed */ - if ((share= (TABLE_SHARE*) alloc_root(mem_root, sizeof(*share)))) + if (multi_alloc_root(mem_root, + &share, sizeof(*share), + &key_buff, old_share->table_cache_key.length, + NULL)) { bzero((char*) share, sizeof(*share)); - share->db.str= memdup_root(mem_root, old_share->db.str, - old_share->db.length+1); - share->db.length= old_share->db.length; - share->table_name.str= memdup_root(mem_root, - old_share->table_name.str, - old_share->table_name.length+1); - share->table_name.length= old_share->table_name.length; - share->table_cache_key.str= memdup_root(mem_root, - old_share->table_cache_key.str, - old_share->table_cache_key.length); - share->table_cache_key.length= old_share->table_cache_key.length; + share->set_table_cache_key(key_buff, old_share->table_cache_key.str, + old_share->table_cache_key.length); share->tmp_table= INTERNAL_TMP_TABLE; // for intern_close_table() } @@ -1603,28 +1598,18 @@ bool rename_temporary_table(THD* thd, TABLE *table, const char *db, const char *table_name) { char *key; + uint key_length; TABLE_SHARE *share= table->s; TABLE_LIST table_list; - uint db_length, table_length; DBUG_ENTER("rename_temporary_table"); - if (!(key=(char*) alloc_root(&share->mem_root, - (uint) (db_length= strlen(db))+ - (uint) (table_length= strlen(table_name))+6+4))) + if (!(key=(char*) alloc_root(&share->mem_root, MAX_DBKEY_LENGTH))) DBUG_RETURN(1); /* purecov: inspected */ table_list.db= (char*) db; table_list.table_name= (char*) table_name; - share->db.str= share->table_cache_key.str= key; - share->db.length= db_length; - share->table_cache_key.length= create_table_def_key(thd, key, - &table_list, 1); - /* - Here we use the fact that table_name is stored as the second component - in the 'key' (after db_name), where components are separated with \0 - */ - share->table_name.str= key+db_length+1; - share->table_name.length= table_length; + key_length= create_table_def_key(thd, key, &table_list, 1); + share->set_table_cache_key(key, key_length); DBUG_RETURN(0); } @@ -1749,10 +1734,7 @@ bool reopen_name_locked_table(THD* thd, TABLE_LIST* table_list) { TABLE *table= table_list->table; TABLE_SHARE *share; - char *db= table_list->db; char *table_name= table_list->table_name; - char key[MAX_DBKEY_LENGTH]; - uint key_length; TABLE orig_table; DBUG_ENTER("reopen_name_locked_table"); @@ -1762,7 +1744,6 @@ bool reopen_name_locked_table(THD* thd, TABLE_LIST* table_list) DBUG_RETURN(TRUE); orig_table= *table; - key_length=(uint) (strmov(strmov(key,db)+1,table_name)-key)+1; if (open_unireg_entry(thd, table, table_list, table_name, table->s->table_cache_key.str, diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 7eda55c6a3f..a882f0b066d 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8645,8 +8645,6 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, share->primary_key= MAX_KEY; // Indicate no primary key share->keys_for_keyread.init(); share->keys_in_use.init(); - /* For easier error reporting */ - share->table_cache_key= share->db; /* Calculate which type of fields we will store in the temporary table */ diff --git a/sql/table.cc b/sql/table.cc index f0a864287b0..179cfb2be14 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -93,6 +93,7 @@ TABLE_SHARE *alloc_table_share(TABLE_LIST *table_list, char *key, { MEM_ROOT mem_root; TABLE_SHARE *share; + char *key_buff, *path_buff; char path[FN_REFLEN]; uint path_length; DBUG_ENTER("alloc_table_share"); @@ -103,22 +104,17 @@ TABLE_SHARE *alloc_table_share(TABLE_LIST *table_list, char *key, table_list->db, table_list->table_name, "", 0); init_sql_alloc(&mem_root, TABLE_ALLOC_BLOCK_SIZE, 0); - if ((share= (TABLE_SHARE*) alloc_root(&mem_root, - sizeof(*share) + key_length + - path_length +1))) + if (multi_alloc_root(&mem_root, + &share, sizeof(*share), + &key_buff, key_length, + &path_buff, path_length + 1, + NULL)) { bzero((char*) share, sizeof(*share)); - share->table_cache_key.str= (char*) (share+1); - share->table_cache_key.length= key_length; - memcpy(share->table_cache_key.str, key, key_length); - /* Use the fact the key is db/0/table_name/0 */ - share->db.str= share->table_cache_key.str; - share->db.length= strlen(share->db.str); - share->table_name.str= share->db.str + share->db.length + 1; - share->table_name.length= strlen(share->table_name.str); + share->set_table_cache_key(key_buff, key, key_length); - share->path.str= share->table_cache_key.str+ key_length; + share->path.str= path_buff; share->path.length= path_length; strmov(share->path.str, path); share->normalized_path.str= share->path.str; diff --git a/sql/table.h b/sql/table.h index 7675c27823b..c13a23468ae 100644 --- a/sql/table.h +++ b/sql/table.h @@ -138,7 +138,16 @@ typedef struct st_table_share CHARSET_INFO *table_charset; /* Default charset of string fields */ MY_BITMAP all_set; - /* A pair "database_name\0table_name\0", widely used as simply a db name */ + /* + Key which is used for looking-up table in table cache and in the list + of thread's temporary tables. Has the form of: + "database_name\0table_name\0" + optional part for temporary tables. + + Note that all three 'table_cache_key', 'db' and 'table_name' members + must be set (and be non-zero) for tables in table cache. They also + should correspond to each other. + To ensure this one can use set_table_cache() methods. + */ LEX_STRING table_cache_key; LEX_STRING db; /* Pointer to db */ LEX_STRING table_name; /* Table name (for open) */ @@ -223,6 +232,60 @@ typedef struct st_table_share uint part_state_len; handlerton *default_part_db_type; #endif + + + /* + Set share's table cache key and update its db and table name appropriately. + + SYNOPSIS + set_table_cache_key() + key_buff Buffer with already built table cache key to be + referenced from share. + key_length Key length. + + NOTES + Since 'key_buff' buffer will be referenced from share it should has same + life-time as share itself. + This method automatically ensures that TABLE_SHARE::table_name/db have + appropriate values by using table cache key as their source. + */ + + void set_table_cache_key(char *key_buff, uint key_length) + { + table_cache_key.str= key_buff; + table_cache_key.length= key_length; + /* + Let us use the fact that the key is "db/0/table_name/0" + optional + part for temporary tables. + */ + db.str= table_cache_key.str; + db.length= strlen(db.str); + table_name.str= db.str + db.length + 1; + table_name.length= strlen(table_name.str); + } + + + /* + Set share's table cache key and update its db and table name appropriately. + + SYNOPSIS + set_table_cache_key() + key_buff Buffer to be used as storage for table cache key + (should be at least key_length bytes). + key Value for table cache key. + key_length Key length. + + NOTE + Since 'key_buff' buffer will be used as storage for table cache key + it should has same life-time as share itself. + */ + + void set_table_cache_key(char *key_buff, const char *key, uint key_length) + { + memcpy(key_buff, key, key_length); + set_table_cache_key(key_buff, key_length); + } + } TABLE_SHARE; From 7a37eeae62b63f90f630ad0f6618d27d72c2f54b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 Aug 2006 15:50:06 +0200 Subject: [PATCH 6/7] Fix for bug #20665 All commands supported in Stored Procedures should work in Prepared Statements. Post-review changeset. Problem: There are some commands which are avaiable to be executed in SP but cannot be prepared. This patch fixes this and makes it possible prepare these statements. Changes: The commands later are made available in PS. RESET has been forbidden in SF/Trigger. Solution: All current server commands where checked and those missing (see later) we added. Tests for all of the commands with repeated executions were added - testing with SP, SF and PS. SHOW BINLOG EVENTS SHOW (MASTER | SLAVE) STATUS SHOW (MASTER | BINARY) LOGS SHOW (PROCEDURE | FUNCTION) CODE (parsable only in debug builds) SHOW CREATE (PROCEDURE | FUNCTION | EVENT | TABLE | VIEW) SHOW (AUTHORS | CONTRIBUTORS | WARNINGS | ERRORS) CHANGE MASTER RESET (MASTER | SLAVE | QUERY CACHE) SLAVE (START | STOP) CHECKSUM (TABLE | TABLES) INSTALL PLUGIN UNINSTALL PLUGIN CACHE INDEX LOAD INDEX INTO CACHE GRANT REVOKE KILL (CREATE | RENAME | DROP) DATABASE (CREATE | RENAME | DROP) USER FLUSH (TABLE | TABLES | TABLES WITH READ LOCK | HOSTS | PRIVILEGES | LOGS | STATUS | MASTER | SLAVE | DES_KEY_FILE | USER_RESOURCES) mysql-test/r/ps.result: update result mysql-test/r/ps_1general.result: update result mysql-test/r/ps_grant.result: update result mysql-test/r/sp-dynamic.result: update result mysql-test/t/ps.test: Add more statements, probably all currently missing which are possible in a SP but not preparable. Every statement is tested in a SP, in a SF and attempted to prepare. mysql-test/t/ps_1general.test: - Enable some of the statements, which are already possible in SP. - 1295 -> ER_UNSUPPORTED_PS mysql-test/t/ps_grant.test: Enable statements already possible in SP. sql/sp_head.cc: - Reorder to keep some alphabet order. - Add missing SHOW_SCHEDULER_STATUS. sql/sql_prepare.cc: Add possibility to prepare statements, which are already allowed in SP. --- mysql-test/r/ps.result | 882 ++++++++++++++++++++++++++++++++ mysql-test/r/ps_1general.result | 12 - mysql-test/r/ps_grant.result | 3 - mysql-test/r/sp-dynamic.result | 4 +- mysql-test/t/ps.test | 871 +++++++++++++++++++++++++++++++ mysql-test/t/ps_1general.test | 24 +- mysql-test/t/ps_grant.test | 3 - sql/sp_head.cc | 15 +- sql/sql_prepare.cc | 33 ++ 9 files changed, 1804 insertions(+), 43 deletions(-) diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index b2f5cec896f..5188900579e 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -1277,3 +1277,885 @@ ERROR 3D000: No database selected create temporary table t1 (i int); ERROR 3D000: No database selected use test; +create procedure proc_1() reset query cache; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +create function func_1() returns int begin reset query cache; return 1; end| +select func_1(), func_1(), func_1() from dual; +ERROR 0A000: FLUSH is not allowed in stored function or trigger +drop function func_1; +prepare abc from "reset query cache"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +create procedure proc_1() reset master; +drop procedure proc_1; +create function func_1() returns int begin reset master; return 1; end| +select func_1(), func_1(), func_1() from dual; +ERROR 0A000: FLUSH is not allowed in stored function or trigger +drop function func_1; +prepare abc from "reset master"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +create procedure proc_1() reset slave; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +create function func_1() returns int begin reset slave; return 1; end| +select func_1(), func_1(), func_1() from dual; +ERROR 0A000: FLUSH is not allowed in stored function or trigger +drop function func_1; +prepare abc from "reset slave"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +create procedure proc_1(a integer) kill a; +call proc_1(0); +ERROR HY000: Unknown thread id: 0 +call proc_1(0); +ERROR HY000: Unknown thread id: 0 +call proc_1(0); +ERROR HY000: Unknown thread id: 0 +drop procedure proc_1; +create function func_1() returns int begin kill 0; return 1; end| +select func_1() from dual; +ERROR HY000: Unknown thread id: 0 +select func_1() from dual; +ERROR HY000: Unknown thread id: 0 +select func_1() from dual; +ERROR HY000: Unknown thread id: 0 +drop function func_1; +prepare abc from "kill 0"; +execute abc; +ERROR HY000: Unknown thread id: 0 +execute abc; +ERROR HY000: Unknown thread id: 0 +execute abc; +ERROR HY000: Unknown thread id: 0 +deallocate prepare abc; +create procedure proc_1() flush hosts; +call proc_1(); +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +create function func_1() returns int begin flush hosts; return 1; end| +ERROR 0A000: FLUSH is not allowed in stored function or trigger +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "flush hosts"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +create procedure proc_1() flush privileges; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +create function func_1() returns int begin flush privileges; return 1; end| +ERROR 0A000: FLUSH is not allowed in stored function or trigger +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "flush privileges"; +deallocate prepare abc; +create procedure proc_1() flush tables with read lock; +call proc_1(); +unlock tables; +call proc_1(); +unlock tables; +call proc_1(); +unlock tables; +drop procedure proc_1; +create function func_1() returns int begin flush tables with read lock; return 1; end| +ERROR 0A000: FLUSH is not allowed in stored function or trigger +prepare abc from "flush tables with read lock"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +unlock tables; +create procedure proc_1() flush tables; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +create function func_1() returns int begin flush tables; return 1; end| +ERROR 0A000: FLUSH is not allowed in stored function or trigger +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "flush tables"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +create procedure proc_1() flush tables; +flush tables; +show open tables from mysql; +Database Table In_use Name_locked +mysql general_log 1 0 +select Host, User from mysql.user limit 0; +Host User +select Host, Db from mysql.host limit 0; +Host Db +show open tables from mysql; +Database Table In_use Name_locked +mysql user 0 0 +mysql general_log 1 0 +mysql host 0 0 +call proc_1(); +show open tables from mysql; +Database Table In_use Name_locked +mysql general_log 1 0 +select Host, User from mysql.user limit 0; +Host User +select Host, Db from mysql.host limit 0; +Host Db +show open tables from mysql; +Database Table In_use Name_locked +mysql user 0 0 +mysql general_log 1 0 +mysql host 0 0 +call proc_1(); +show open tables from mysql; +Database Table In_use Name_locked +mysql general_log 1 0 +select Host, User from mysql.user limit 0; +Host User +select Host, Db from mysql.host limit 0; +Host Db +show open tables from mysql; +Database Table In_use Name_locked +mysql user 0 0 +mysql general_log 1 0 +mysql host 0 0 +call proc_1(); +show open tables from mysql; +Database Table In_use Name_locked +mysql general_log 1 0 +select Host, User from mysql.user limit 0; +Host User +select Host, Db from mysql.host limit 0; +Host Db +show open tables from mysql; +Database Table In_use Name_locked +mysql user 0 0 +mysql general_log 1 0 +mysql host 0 0 +flush tables; +drop procedure proc_1; +create function func_1() returns int begin flush tables; return 1; end| +ERROR 0A000: FLUSH is not allowed in stored function or trigger +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +flush tables; +select Host, User from mysql.user limit 0; +Host User +select Host, Db from mysql.host limit 0; +Host Db +show open tables from mysql; +Database Table In_use Name_locked +mysql user 0 0 +mysql general_log 1 0 +mysql host 0 0 +prepare abc from "flush tables"; +execute abc; +show open tables from mysql; +Database Table In_use Name_locked +mysql general_log 1 0 +select Host, User from mysql.user limit 0; +Host User +select Host, Db from mysql.host limit 0; +Host Db +show open tables from mysql; +Database Table In_use Name_locked +mysql user 0 0 +mysql general_log 1 0 +mysql host 0 0 +execute abc; +show open tables from mysql; +Database Table In_use Name_locked +mysql general_log 1 0 +select Host, User from mysql.user limit 0; +Host User +select Host, Db from mysql.host limit 0; +Host Db +show open tables from mysql; +Database Table In_use Name_locked +mysql user 0 0 +mysql general_log 1 0 +mysql host 0 0 +execute abc; +show open tables from mysql; +Database Table In_use Name_locked +mysql general_log 1 0 +select Host, User from mysql.user limit 0; +Host User +select Host, Db from mysql.host limit 0; +Host Db +show open tables from mysql; +Database Table In_use Name_locked +mysql user 0 0 +mysql general_log 1 0 +mysql host 0 0 +flush tables; +deallocate prepare abc; +create procedure proc_1() flush logs; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +create function func_1() returns int begin flush logs; return 1; end| +ERROR 0A000: FLUSH is not allowed in stored function or trigger +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "flush logs"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +create procedure proc_1() flush status; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +create function func_1() returns int begin flush status; return 1; end| +ERROR 0A000: FLUSH is not allowed in stored function or trigger +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "flush status"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +create procedure proc_1() flush slave; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +create function func_1() returns int begin flush slave; return 1; end| +ERROR 0A000: FLUSH is not allowed in stored function or trigger +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "flush slave"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +create procedure proc_1() flush master; +drop procedure proc_1; +create function func_1() returns int begin flush master; return 1; end| +ERROR 0A000: FLUSH is not allowed in stored function or trigger +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "flush master"; +deallocate prepare abc; +create procedure proc_1() flush des_key_file; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +create function func_1() returns int begin flush des_key_file; return 1; end| +ERROR 0A000: FLUSH is not allowed in stored function or trigger +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "flush des_key_file"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +create procedure proc_1() flush user_resources; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +create function func_1() returns int begin flush user_resources; return 1; end| +ERROR 0A000: FLUSH is not allowed in stored function or trigger +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "flush user_resources"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +create procedure proc_1() start slave; +drop procedure proc_1; +create function func_1() returns int begin start slave; return 1; end| +drop function func_1; +prepare abc from "start slave"; +deallocate prepare abc; +create procedure proc_1() stop slave; +drop procedure proc_1; +create function func_1() returns int begin stop slave; return 1; end| +drop function func_1; +prepare abc from "stop slave"; +deallocate prepare abc; +create procedure proc_1() show binlog events; +drop procedure proc_1; +create function func_1() returns int begin show binlog events; return 1; end| +ERROR 0A000: Not allowed to return a result set from a function +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "show binlog events"; +deallocate prepare abc; +create procedure proc_1() show slave status; +drop procedure proc_1; +create function func_1() returns int begin show slave status; return 1; end| +ERROR 0A000: Not allowed to return a result set from a function +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "show slave status"; +deallocate prepare abc; +create procedure proc_1() show master status; +drop procedure proc_1; +create function func_1() returns int begin show master status; return 1; end| +ERROR 0A000: Not allowed to return a result set from a function +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "show master status"; +deallocate prepare abc; +create procedure proc_1() show master logs; +drop procedure proc_1; +create function func_1() returns int begin show master logs; return 1; end| +ERROR 0A000: Not allowed to return a result set from a function +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "show master logs"; +deallocate prepare abc; +create procedure proc_1() show events; +call proc_1(); +Db Name Definer Type Execute at Interval value Interval field Starts Ends Status +call proc_1(); +Db Name Definer Type Execute at Interval value Interval field Starts Ends Status +call proc_1(); +Db Name Definer Type Execute at Interval value Interval field Starts Ends Status +drop procedure proc_1; +create function func_1() returns int begin show events; return 1; end| +ERROR 0A000: Not allowed to return a result set from a function +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "show events"; +execute abc; +Db Name Definer Type Execute at Interval value Interval field Starts Ends Status +execute abc; +Db Name Definer Type Execute at Interval value Interval field Starts Ends Status +execute abc; +Db Name Definer Type Execute at Interval value Interval field Starts Ends Status +deallocate prepare abc; +create procedure proc_1() show scheduler status; +drop procedure proc_1; +create function func_1() returns int begin show scheduler status; return 1; end| +ERROR 0A000: Not allowed to return a result set from a function +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "show scheduler status"; +ERROR HY000: This command is not supported in the prepared statement protocol yet +deallocate prepare abc; +ERROR HY000: Unknown prepared statement handler (abc) given to DEALLOCATE PREPARE +drop procedure if exists a; +create procedure a() select 42; +create procedure proc_1(a char(2)) show create procedure a; +call proc_1("bb"); +Procedure sql_mode Create Procedure +a CREATE DEFINER=`root`@`localhost` PROCEDURE `a`() +select 42 +call proc_1("bb"); +Procedure sql_mode Create Procedure +a CREATE DEFINER=`root`@`localhost` PROCEDURE `a`() +select 42 +call proc_1("bb"); +Procedure sql_mode Create Procedure +a CREATE DEFINER=`root`@`localhost` PROCEDURE `a`() +select 42 +drop procedure proc_1; +create function func_1() returns int begin show create procedure a; return 1; end| +ERROR 0A000: Not allowed to return a result set from a function +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "show create procedure a"; +execute abc; +Procedure sql_mode Create Procedure +a CREATE DEFINER=`root`@`localhost` PROCEDURE `a`() +select 42 +execute abc; +Procedure sql_mode Create Procedure +a CREATE DEFINER=`root`@`localhost` PROCEDURE `a`() +select 42 +execute abc; +Procedure sql_mode Create Procedure +a CREATE DEFINER=`root`@`localhost` PROCEDURE `a`() +select 42 +deallocate prepare abc; +drop procedure a; +drop function if exists a; +create function a() returns int return 42+13; +create procedure proc_1(a char(2)) show create function a; +call proc_1("bb"); +Function sql_mode Create Function +a CREATE DEFINER=`root`@`localhost` FUNCTION `a`() RETURNS int(11) +return 42+13 +call proc_1("bb"); +Function sql_mode Create Function +a CREATE DEFINER=`root`@`localhost` FUNCTION `a`() RETURNS int(11) +return 42+13 +call proc_1("bb"); +Function sql_mode Create Function +a CREATE DEFINER=`root`@`localhost` FUNCTION `a`() RETURNS int(11) +return 42+13 +drop procedure proc_1; +create function func_1() returns int begin show create function a; return 1; end| +ERROR 0A000: Not allowed to return a result set from a function +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "show create function a"; +execute abc; +Function sql_mode Create Function +a CREATE DEFINER=`root`@`localhost` FUNCTION `a`() RETURNS int(11) +return 42+13 +execute abc; +Function sql_mode Create Function +a CREATE DEFINER=`root`@`localhost` FUNCTION `a`() RETURNS int(11) +return 42+13 +execute abc; +Function sql_mode Create Function +a CREATE DEFINER=`root`@`localhost` FUNCTION `a`() RETURNS int(11) +return 42+13 +deallocate prepare abc; +drop function a; +drop table if exists tab1; +create table tab1(a int, b char(1), primary key(a,b)); +create procedure proc_1() show create table tab1; +call proc_1(); +Table Create Table +tab1 CREATE TABLE `tab1` ( + `a` int(11) NOT NULL DEFAULT '0', + `b` char(1) NOT NULL DEFAULT '', + PRIMARY KEY (`a`,`b`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +call proc_1(); +Table Create Table +tab1 CREATE TABLE `tab1` ( + `a` int(11) NOT NULL DEFAULT '0', + `b` char(1) NOT NULL DEFAULT '', + PRIMARY KEY (`a`,`b`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +call proc_1(); +Table Create Table +tab1 CREATE TABLE `tab1` ( + `a` int(11) NOT NULL DEFAULT '0', + `b` char(1) NOT NULL DEFAULT '', + PRIMARY KEY (`a`,`b`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop procedure proc_1; +create function func_1() returns int begin show create table tab1; return 1; end| +ERROR 0A000: Not allowed to return a result set from a function +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "show create table tab1"; +execute abc; +Table Create Table +tab1 CREATE TABLE `tab1` ( + `a` int(11) NOT NULL DEFAULT '0', + `b` char(1) NOT NULL DEFAULT '', + PRIMARY KEY (`a`,`b`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +execute abc; +Table Create Table +tab1 CREATE TABLE `tab1` ( + `a` int(11) NOT NULL DEFAULT '0', + `b` char(1) NOT NULL DEFAULT '', + PRIMARY KEY (`a`,`b`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +execute abc; +Table Create Table +tab1 CREATE TABLE `tab1` ( + `a` int(11) NOT NULL DEFAULT '0', + `b` char(1) NOT NULL DEFAULT '', + PRIMARY KEY (`a`,`b`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +deallocate prepare abc; +drop table tab1; +drop view if exists v1; +drop table if exists t1; +create table t1(a int, b char(5)); +insert into t1 values (1, "one"), (1, "edno"), (2, "two"), (2, "dve"); +create view v1 as +(select a, count(*) from t1 group by a) +union all +(select b, count(*) from t1 group by b); +create procedure proc_1() show create view v1; +call proc_1(); +View Create View +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select `t1`.`a` AS `a`,count(0) AS `count(*)` from `t1` group by `t1`.`a`) union all (select `t1`.`b` AS `b`,count(0) AS `count(*)` from `t1` group by `t1`.`b`) +call proc_1(); +View Create View +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select `t1`.`a` AS `a`,count(0) AS `count(*)` from `t1` group by `t1`.`a`) union all (select `t1`.`b` AS `b`,count(0) AS `count(*)` from `t1` group by `t1`.`b`) +call proc_1(); +View Create View +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select `t1`.`a` AS `a`,count(0) AS `count(*)` from `t1` group by `t1`.`a`) union all (select `t1`.`b` AS `b`,count(0) AS `count(*)` from `t1` group by `t1`.`b`) +drop procedure proc_1; +create function func_1() returns int begin show create view v1; return 1; end| +ERROR 0A000: Not allowed to return a result set from a function +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "show create view v1"; +execute abc; +View Create View +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select `t1`.`a` AS `a`,count(0) AS `count(*)` from `t1` group by `t1`.`a`) union all (select `t1`.`b` AS `b`,count(0) AS `count(*)` from `t1` group by `t1`.`b`) +execute abc; +View Create View +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select `t1`.`a` AS `a`,count(0) AS `count(*)` from `t1` group by `t1`.`a`) union all (select `t1`.`b` AS `b`,count(0) AS `count(*)` from `t1` group by `t1`.`b`) +execute abc; +View Create View +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select `t1`.`a` AS `a`,count(0) AS `count(*)` from `t1` group by `t1`.`a`) union all (select `t1`.`b` AS `b`,count(0) AS `count(*)` from `t1` group by `t1`.`b`) +deallocate prepare abc; +drop view v1; +drop table t1; +create procedure proc_1() install plugin my_plug soname '/root/some_plugin.so'; +call proc_1(); +ERROR HY000: No paths allowed for shared library +call proc_1(); +ERROR HY000: No paths allowed for shared library +call proc_1(); +ERROR HY000: No paths allowed for shared library +drop procedure proc_1; +create procedure proc_1() install plugin my_plug soname 'some_plugin.so'; +call proc_1(); +ERROR HY000: Can't open shared library '/work/mysql-5.1-runtime/mysql-test/lib/mysql/some_plugin.so' (errno: 0 cannot open shared object file: No such file or directory) +call proc_1(); +ERROR HY000: Can't open shared library '/work/mysql-5.1-runtime/mysql-test/lib/mysql/some_plugin.so' (errno: 22 cannot open shared object file: No such file or directory) +call proc_1(); +ERROR HY000: Can't open shared library '/work/mysql-5.1-runtime/mysql-test/lib/mysql/some_plugin.so' (errno: 22 cannot open shared object file: No such file or directory) +drop procedure proc_1; +create function func_1() returns int begin install plugin my_plug soname '/tmp/plugin'; return 1; end| +ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger. +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "install plugin my_plug soname '/root/some_plugin.so'"; +execute abc; +ERROR HY000: No paths allowed for shared library +execute abc; +ERROR HY000: No paths allowed for shared library +deallocate prepare abc; +prepare abc from "install plugin my_plug soname 'some_plugin.so'"; +deallocate prepare abc; +create procedure proc_1() uninstall plugin my_plug; +call proc_1(); +ERROR 42000: PLUGIN my_plug does not exist +call proc_1(); +ERROR 42000: PLUGIN my_plug does not exist +call proc_1(); +ERROR 42000: PLUGIN my_plug does not exist +drop procedure proc_1; +create function func_1() returns int begin uninstall plugin my_plug; return 1; end| +ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger. +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "uninstall plugin my_plug"; +execute abc; +ERROR 42000: PLUGIN my_plug does not exist +execute abc; +ERROR 42000: PLUGIN my_plug does not exist +execute abc; +ERROR 42000: PLUGIN my_plug does not exist +deallocate prepare abc; +drop database if exists mysqltest_xyz; +create procedure proc_1() create database mysqltest_xyz; +call proc_1(); +drop database if exists mysqltest_xyz; +call proc_1(); +call proc_1(); +ERROR HY000: Can't create database 'mysqltest_xyz'; database exists +drop database if exists mysqltest_xyz; +call proc_1(); +drop database if exists mysqltest_xyz; +drop procedure proc_1; +create function func_1() returns int begin create database mysqltest_xyz; return 1; end| +ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger. +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "create database mysqltest_xyz"; +execute abc; +drop database if exists mysqltest_xyz; +execute abc; +execute abc; +ERROR HY000: Can't create database 'mysqltest_xyz'; database exists +drop database if exists mysqltest_xyz; +execute abc; +drop database if exists mysqltest_xyz; +deallocate prepare abc; +drop table if exists t1; +create table t1 (a int, b char(5)); +insert into t1 values (1, "one"), (2, "two"), (3, "three"); +create procedure proc_1() checksum table xyz; +call proc_1(); +Table Checksum +test.xyz NULL +Warnings: +Error 1146 Table 'test.xyz' doesn't exist +call proc_1(); +Table Checksum +test.xyz NULL +Warnings: +Error 1146 Table 'test.xyz' doesn't exist +call proc_1(); +Table Checksum +test.xyz NULL +Warnings: +Error 1146 Table 'test.xyz' doesn't exist +drop procedure proc_1; +create function func_1() returns int begin checksum table t1; return 1; end| +ERROR 0A000: Not allowed to return a result set from a function +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "checksum table t1"; +execute abc; +Table Checksum +test.t1 645809265 +execute abc; +Table Checksum +test.t1 645809265 +execute abc; +Table Checksum +test.t1 645809265 +deallocate prepare abc; +create procedure proc_1() create user pstest_xyz@localhost; +call proc_1(); +drop user pstest_xyz@localhost; +call proc_1(); +call proc_1(); +ERROR HY000: Operation CREATE USER failed for 'pstest_xyz'@'localhost' +drop user pstest_xyz@localhost; +call proc_1(); +drop user pstest_xyz@localhost; +drop procedure proc_1; +create function func_1() returns int begin create user pstest_xyz@localhost; return 1; end| +ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger. +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "create user pstest_xyz@localhost"; +execute abc; +drop user pstest_xyz@localhost; +execute abc; +execute abc; +ERROR HY000: Operation CREATE USER failed for 'pstest_xyz'@'localhost' +drop user pstest_xyz@localhost; +execute abc; +drop user pstest_xyz@localhost; +deallocate prepare abc; +drop event if exists xyz; +create function func_1() returns int begin create event xyz on schedule at now() do select 123; return 1; end| +ERROR 0A000: Not allowed to return a result set from a function +select func_1(), func_1(), func_1() from dual; +ERROR 42000: FUNCTION test.func_1 does not exist +drop function func_1; +ERROR 42000: FUNCTION test.func_1 does not exist +prepare abc from "create event xyz on schedule at now() do select 123"; +ERROR HY000: This command is not supported in the prepared statement protocol yet +deallocate prepare abc; +ERROR HY000: Unknown prepared statement handler (abc) given to DEALLOCATE PREPARE +drop event if exists xyz; +create event xyz on schedule every 5 minute disable do select 123; +create procedure proc_1() alter event xyz comment 'xyz'; +call proc_1(); +drop event xyz; +create event xyz on schedule every 5 minute disable do select 123; +call proc_1(); +drop event xyz; +create event xyz on schedule every 5 minute disable do select 123; +call proc_1(); +drop event xyz; +drop procedure proc_1; +create function func_1() returns int begin alter event xyz comment 'xyz'; return 1; end| +ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger. +prepare abc from "alter event xyz comment 'xyz'"; +ERROR HY000: This command is not supported in the prepared statement protocol yet +deallocate prepare abc; +ERROR HY000: Unknown prepared statement handler (abc) given to DEALLOCATE PREPARE +drop event if exists xyz; +create event xyz on schedule every 5 minute disable do select 123; +create procedure proc_1() drop event xyz; +call proc_1(); +create event xyz on schedule every 5 minute disable do select 123; +call proc_1(); +call proc_1(); +ERROR HY000: Unknown event 'xyz' +drop procedure proc_1; +create function func_1() returns int begin drop event xyz; return 1; end| +ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger. +prepare abc from "drop event xyz"; +ERROR HY000: This command is not supported in the prepared statement protocol yet +deallocate prepare abc; +ERROR HY000: Unknown prepared statement handler (abc) given to DEALLOCATE PREPARE +drop table if exists t1; +create table t1 (a int, b char(5)) engine=myisam; +insert into t1 values (1, "one"), (2, "two"), (3, "three"); +SET GLOBAL new_cache.key_buffer_size=128*1024; +create procedure proc_1() cache index t1 in new_cache; +call proc_1(); +Table Op Msg_type Msg_text +test.t1 assign_to_keycache status OK +call proc_1(); +Table Op Msg_type Msg_text +test.t1 assign_to_keycache status OK +call proc_1(); +Table Op Msg_type Msg_text +test.t1 assign_to_keycache status OK +drop procedure proc_1; +SET GLOBAL second_cache.key_buffer_size=128*1024; +prepare abc from "cache index t1 in second_cache"; +execute abc; +Table Op Msg_type Msg_text +test.t1 assign_to_keycache status OK +execute abc; +Table Op Msg_type Msg_text +test.t1 assign_to_keycache status OK +execute abc; +Table Op Msg_type Msg_text +test.t1 assign_to_keycache status OK +deallocate prepare abc; +drop table t1; +drop table if exists t1; +drop table if exists t2; +create table t1 (a int, b char(5)) engine=myisam; +insert into t1 values (1, "one"), (2, "two"), (3, "three"); +create table t2 (a int, b char(5)) engine=myisam; +insert into t2 values (1, "one"), (2, "two"), (3, "three"); +create procedure proc_1() load index into cache t1 ignore leaves; +call proc_1(); +Table Op Msg_type Msg_text +test.t1 preload_keys status OK +call proc_1(); +Table Op Msg_type Msg_text +test.t1 preload_keys status OK +call proc_1(); +Table Op Msg_type Msg_text +test.t1 preload_keys status OK +drop procedure proc_1; +create function func_1() returns int begin load index into cache t1 ignore leaves; return 1; end| +ERROR 0A000: Not allowed to return a result set from a function +prepare abc from "load index into cache t2 ignore leaves"; +execute abc; +Table Op Msg_type Msg_text +test.t2 preload_keys status OK +execute abc; +Table Op Msg_type Msg_text +test.t2 preload_keys status OK +execute abc; +Table Op Msg_type Msg_text +test.t2 preload_keys status OK +deallocate prepare abc; +drop table t1, t2; +create procedure proc_1() show errors; +call proc_1(); +Level Code Message +call proc_1(); +Level Code Message +call proc_1(); +Level Code Message +drop procedure proc_1; +create function func_1() returns int begin show errors; return 1; end| +ERROR 0A000: Not allowed to return a result set from a function +prepare abc from "show errors"; +deallocate prepare abc; +drop table if exists t1; +drop table if exists t2; +create procedure proc_1() show warnings; +drop table if exists t1; +Warnings: +Note 1051 Unknown table 't1' +call proc_1(); +Level Code Message +drop table if exists t2; +Warnings: +Note 1051 Unknown table 't2' +call proc_1(); +Level Code Message +drop table if exists t1, t2; +Warnings: +Note 1051 Unknown table 't1' +Note 1051 Unknown table 't2' +call proc_1(); +Level Code Message +drop procedure proc_1; +create function func_1() returns int begin show warnings; return 1; end| +ERROR 0A000: Not allowed to return a result set from a function +prepare abc from "show warnings"; +drop table if exists t1; +Warnings: +Note 1051 Unknown table 't1' +execute abc; +Level Code Message +Note 1051 Unknown table 't1' +drop table if exists t2; +Warnings: +Note 1051 Unknown table 't2' +execute abc; +Level Code Message +Note 1051 Unknown table 't2' +drop table if exists t1, t2; +Warnings: +Note 1051 Unknown table 't1' +Note 1051 Unknown table 't2' +execute abc; +Level Code Message +Note 1051 Unknown table 't1' +Note 1051 Unknown table 't2' +deallocate prepare abc; diff --git a/mysql-test/r/ps_1general.result b/mysql-test/r/ps_1general.result index c94df7f5c2a..67959920248 100644 --- a/mysql-test/r/ps_1general.result +++ b/mysql-test/r/ps_1general.result @@ -308,17 +308,11 @@ prepare stmt4 from ' show engine bdb logs '; execute stmt4; prepare stmt4 from ' show grants for user '; prepare stmt4 from ' show create table t2 '; -ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt4 from ' show master status '; -ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt4 from ' show master logs '; -ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt4 from ' show slave status '; -ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt4 from ' show warnings limit 20 '; -ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt4 from ' show errors limit 20 '; -ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt4 from ' show storage engines '; execute stmt4; drop table if exists t5; @@ -387,10 +381,8 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp prepare stmt4 from ' use test ' ; ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt3 from ' create database mysqltest '; -ERROR HY000: This command is not supported in the prepared statement protocol yet create database mysqltest ; prepare stmt3 from ' drop database mysqltest '; -ERROR HY000: This command is not supported in the prepared statement protocol yet drop database mysqltest ; prepare stmt3 from ' describe t2 '; execute stmt3; @@ -412,7 +404,6 @@ execute stmt1 ; prepare stmt1 from ' optimize table t1 ' ; prepare stmt1 from ' analyze table t1 ' ; prepare stmt1 from ' checksum table t1 ' ; -ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt1 from ' repair table t1 ' ; prepare stmt1 from ' restore table t1 from ''data.txt'' ' ; ERROR HY000: This command is not supported in the prepared statement protocol yet @@ -440,11 +431,8 @@ execute stmt5; 1 SET sql_mode=""; prepare stmt1 from ' flush local privileges ' ; -ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt1 from ' reset query cache ' ; -ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt1 from ' KILL 0 '; -ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt1 from ' explain select a from t1 order by b '; execute stmt1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr diff --git a/mysql-test/r/ps_grant.result b/mysql-test/r/ps_grant.result index fdc1f97bb4c..8b16123ccea 100644 --- a/mysql-test/r/ps_grant.result +++ b/mysql-test/r/ps_grant.result @@ -78,13 +78,10 @@ ERROR 42000: There is no such grant defined for user 'second_user' on host 'loca drop database mysqltest; prepare stmt3 from ' grant all on test.t1 to drop_user@localhost identified by ''looser'' '; -ERROR HY000: This command is not supported in the prepared statement protocol yet grant all on test.t1 to drop_user@localhost identified by 'looser' ; prepare stmt3 from ' revoke all privileges on test.t1 from drop_user@localhost '; -ERROR HY000: This command is not supported in the prepared statement protocol yet revoke all privileges on test.t1 from drop_user@localhost ; prepare stmt3 from ' drop user drop_user@localhost '; -ERROR HY000: This command is not supported in the prepared statement protocol yet drop user drop_user@localhost; diff --git a/mysql-test/r/sp-dynamic.result b/mysql-test/r/sp-dynamic.result index d9d5706cded..f1c7e6076e5 100644 --- a/mysql-test/r/sp-dynamic.result +++ b/mysql-test/r/sp-dynamic.result @@ -284,11 +284,11 @@ call p1()| select * from t1| id stmt_text status 1 select 1 supported -2 flush tables not supported +2 flush tables supported 3 handler t1 open as ha not supported 4 analyze table t1 supported 5 check table t1 not supported -6 checksum table t1 not supported +6 checksum table t1 supported 7 check table t1 not supported 8 optimize table t1 supported 9 repair table t1 supported diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index aa7b6ebf266..94d6fb3af55 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -1330,3 +1330,874 @@ create temporary table t1 (i int); # use test; # End of 5.0 tests + + +# +# Bug #20665: All commands supported in Stored Procedures should work in +# Prepared Statements +# +create procedure proc_1() reset query cache; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +delimiter |; +create function func_1() returns int begin reset query cache; return 1; end| +delimiter ;| +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +select func_1(), func_1(), func_1() from dual; +drop function func_1; +prepare abc from "reset query cache"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; + + +create procedure proc_1() reset master; +drop procedure proc_1; +delimiter |; +create function func_1() returns int begin reset master; return 1; end| +delimiter ;| +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +select func_1(), func_1(), func_1() from dual; +drop function func_1; +prepare abc from "reset master"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; + + +create procedure proc_1() reset slave; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +delimiter |; +create function func_1() returns int begin reset slave; return 1; end| +delimiter ;| +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +select func_1(), func_1(), func_1() from dual; +drop function func_1; +prepare abc from "reset slave"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; + + +create procedure proc_1(a integer) kill a; +--error ER_NO_SUCH_THREAD +call proc_1(0); +--error ER_NO_SUCH_THREAD +call proc_1(0); +--error ER_NO_SUCH_THREAD +call proc_1(0); +drop procedure proc_1; +delimiter |; +create function func_1() returns int begin kill 0; return 1; end| +delimiter ;| +--error ER_NO_SUCH_THREAD +select func_1() from dual; +--error ER_NO_SUCH_THREAD +select func_1() from dual; +--error ER_NO_SUCH_THREAD +select func_1() from dual; +drop function func_1; +prepare abc from "kill 0"; +--error ER_NO_SUCH_THREAD +execute abc; +--error ER_NO_SUCH_THREAD +execute abc; +--error ER_NO_SUCH_THREAD +execute abc; +deallocate prepare abc; + + +create procedure proc_1() flush hosts; +call proc_1(); +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin flush hosts; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "flush hosts"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; + + +create procedure proc_1() flush privileges; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin flush privileges; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "flush privileges"; +deallocate prepare abc; + + +create procedure proc_1() flush tables with read lock; +call proc_1(); +unlock tables; +call proc_1(); +unlock tables; +call proc_1(); +unlock tables; +drop procedure proc_1; +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin flush tables with read lock; return 1; end| +delimiter ;| +prepare abc from "flush tables with read lock"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +unlock tables; + + +create procedure proc_1() flush tables; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin flush tables; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "flush tables"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; + + +create procedure proc_1() flush tables; +flush tables; +show open tables from mysql; +select Host, User from mysql.user limit 0; +select Host, Db from mysql.host limit 0; +show open tables from mysql; +call proc_1(); +show open tables from mysql; +select Host, User from mysql.user limit 0; +select Host, Db from mysql.host limit 0; +show open tables from mysql; +call proc_1(); +show open tables from mysql; +select Host, User from mysql.user limit 0; +select Host, Db from mysql.host limit 0; +show open tables from mysql; +call proc_1(); +show open tables from mysql; +select Host, User from mysql.user limit 0; +select Host, Db from mysql.host limit 0; +show open tables from mysql; +flush tables; +drop procedure proc_1; +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin flush tables; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +flush tables; +select Host, User from mysql.user limit 0; +select Host, Db from mysql.host limit 0; +show open tables from mysql; +prepare abc from "flush tables"; +execute abc; +show open tables from mysql; +select Host, User from mysql.user limit 0; +select Host, Db from mysql.host limit 0; +show open tables from mysql; +execute abc; +show open tables from mysql; +select Host, User from mysql.user limit 0; +select Host, Db from mysql.host limit 0; +show open tables from mysql; +execute abc; +show open tables from mysql; +select Host, User from mysql.user limit 0; +select Host, Db from mysql.host limit 0; +show open tables from mysql; +flush tables; +deallocate prepare abc; + + +create procedure proc_1() flush logs; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin flush logs; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "flush logs"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; + + +create procedure proc_1() flush status; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin flush status; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "flush status"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; + + +create procedure proc_1() flush slave; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin flush slave; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "flush slave"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; + + +create procedure proc_1() flush master; +drop procedure proc_1; +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin flush master; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "flush master"; +deallocate prepare abc; + + +create procedure proc_1() flush des_key_file; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin flush des_key_file; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "flush des_key_file"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; + + +create procedure proc_1() flush user_resources; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin flush user_resources; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "flush user_resources"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; + + +create procedure proc_1() start slave; +drop procedure proc_1; +delimiter |; +create function func_1() returns int begin start slave; return 1; end| +delimiter ;| +drop function func_1; +prepare abc from "start slave"; +deallocate prepare abc; + + +create procedure proc_1() stop slave; +drop procedure proc_1; +delimiter |; +create function func_1() returns int begin stop slave; return 1; end| +delimiter ;| +drop function func_1; +prepare abc from "stop slave"; +deallocate prepare abc; + + +create procedure proc_1() show binlog events; +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin show binlog events; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "show binlog events"; +deallocate prepare abc; + + +create procedure proc_1() show slave status; +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin show slave status; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "show slave status"; +deallocate prepare abc; + + +create procedure proc_1() show master status; +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin show master status; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "show master status"; +deallocate prepare abc; + + +create procedure proc_1() show master logs; +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin show master logs; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "show master logs"; +deallocate prepare abc; + + +create procedure proc_1() show events; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin show events; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "show events"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; + + +create procedure proc_1() show scheduler status; +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin show scheduler status; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +--error ER_UNSUPPORTED_PS +prepare abc from "show scheduler status"; +--error ER_UNKNOWN_STMT_HANDLER +deallocate prepare abc; + + +--disable_warnings +drop procedure if exists a; +--enable_warnings +create procedure a() select 42; +create procedure proc_1(a char(2)) show create procedure a; +call proc_1("bb"); +call proc_1("bb"); +call proc_1("bb"); +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin show create procedure a; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "show create procedure a"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +drop procedure a; + + +--disable_warnings +drop function if exists a; +--enable_warnings +create function a() returns int return 42+13; +create procedure proc_1(a char(2)) show create function a; +call proc_1("bb"); +call proc_1("bb"); +call proc_1("bb"); +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin show create function a; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "show create function a"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +drop function a; + + +--disable_warnings +drop table if exists tab1; +--enable_warnings +create table tab1(a int, b char(1), primary key(a,b)); +create procedure proc_1() show create table tab1; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin show create table tab1; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "show create table tab1"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +drop table tab1; + + +--disable_warnings +drop view if exists v1; +drop table if exists t1; +--enable_warnings +create table t1(a int, b char(5)); +insert into t1 values (1, "one"), (1, "edno"), (2, "two"), (2, "dve"); +create view v1 as + (select a, count(*) from t1 group by a) + union all + (select b, count(*) from t1 group by b); +create procedure proc_1() show create view v1; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin show create view v1; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "show create view v1"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +drop view v1; +drop table t1; + + +create procedure proc_1() install plugin my_plug soname '/root/some_plugin.so'; +--error ER_UDF_NO_PATHS +call proc_1(); +--error ER_UDF_NO_PATHS +call proc_1(); +--error ER_UDF_NO_PATHS +call proc_1(); +drop procedure proc_1; +create procedure proc_1() install plugin my_plug soname 'some_plugin.so'; +--error ER_CANT_OPEN_LIBRARY +call proc_1(); +--error ER_CANT_OPEN_LIBRARY +call proc_1(); +--error ER_CANT_OPEN_LIBRARY +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin install plugin my_plug soname '/tmp/plugin'; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "install plugin my_plug soname '/root/some_plugin.so'"; +--error ER_UDF_NO_PATHS +execute abc; +--error ER_UDF_NO_PATHS +execute abc; +deallocate prepare abc; +prepare abc from "install plugin my_plug soname 'some_plugin.so'"; +deallocate prepare abc; + + +create procedure proc_1() uninstall plugin my_plug; +--error ER_SP_DOES_NOT_EXIST +call proc_1(); +--error ER_SP_DOES_NOT_EXIST +call proc_1(); +--error ER_SP_DOES_NOT_EXIST +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin uninstall plugin my_plug; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "uninstall plugin my_plug"; +--error ER_SP_DOES_NOT_EXIST +execute abc; +--error ER_SP_DOES_NOT_EXIST +execute abc; +--error ER_SP_DOES_NOT_EXIST +execute abc; +deallocate prepare abc; + + +--disable_warnings +drop database if exists mysqltest_xyz; +--enable_warnings +create procedure proc_1() create database mysqltest_xyz; +call proc_1(); +drop database if exists mysqltest_xyz; +call proc_1(); +--error ER_DB_CREATE_EXISTS +call proc_1(); +drop database if exists mysqltest_xyz; +call proc_1(); +drop database if exists mysqltest_xyz; +drop procedure proc_1; +delimiter |; +--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin create database mysqltest_xyz; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "create database mysqltest_xyz"; +execute abc; +drop database if exists mysqltest_xyz; +execute abc; +--error ER_DB_CREATE_EXISTS +execute abc; +drop database if exists mysqltest_xyz; +execute abc; +drop database if exists mysqltest_xyz; +deallocate prepare abc; + + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int, b char(5)); +insert into t1 values (1, "one"), (2, "two"), (3, "three"); +create procedure proc_1() checksum table xyz; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin checksum table t1; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "checksum table t1"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; + + +create procedure proc_1() create user pstest_xyz@localhost; +call proc_1(); +drop user pstest_xyz@localhost; +call proc_1(); +--error ER_CANNOT_USER +call proc_1(); +drop user pstest_xyz@localhost; +call proc_1(); +drop user pstest_xyz@localhost; +drop procedure proc_1; +delimiter |; +--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin create user pstest_xyz@localhost; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "create user pstest_xyz@localhost"; +execute abc; +drop user pstest_xyz@localhost; +execute abc; +--error ER_CANNOT_USER +execute abc; +drop user pstest_xyz@localhost; +execute abc; +drop user pstest_xyz@localhost; +deallocate prepare abc; + + +--disable_warnings +drop event if exists xyz; +--enable_warnings +#create procedure proc_1() create event xyz on schedule every 5 minute disable do select 123; +#call proc_1(); +#drop event xyz; +#call proc_1(); +#--error ER_EVENT_ALREADY_EXISTS +#call proc_1(); +#drop event xyz; +#call proc_1(); +#drop event xyz; +#drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin create event xyz on schedule at now() do select 123; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +--error ER_UNSUPPORTED_PS +prepare abc from "create event xyz on schedule at now() do select 123"; +--error ER_UNKNOWN_STMT_HANDLER +deallocate prepare abc; + + +--disable_warnings +drop event if exists xyz; +create event xyz on schedule every 5 minute disable do select 123; +--enable_warnings +create procedure proc_1() alter event xyz comment 'xyz'; +call proc_1(); +drop event xyz; +create event xyz on schedule every 5 minute disable do select 123; +call proc_1(); +drop event xyz; +create event xyz on schedule every 5 minute disable do select 123; +call proc_1(); +drop event xyz; +drop procedure proc_1; +delimiter |; +--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin alter event xyz comment 'xyz'; return 1; end| +delimiter ;| +--error ER_UNSUPPORTED_PS +prepare abc from "alter event xyz comment 'xyz'"; +--error ER_UNKNOWN_STMT_HANDLER +deallocate prepare abc; + + +--disable_warnings +drop event if exists xyz; +create event xyz on schedule every 5 minute disable do select 123; +--enable_warnings +create procedure proc_1() drop event xyz; +call proc_1(); +create event xyz on schedule every 5 minute disable do select 123; +call proc_1(); +--error ER_EVENT_DOES_NOT_EXIST +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin drop event xyz; return 1; end| +delimiter ;| +--error ER_UNSUPPORTED_PS +prepare abc from "drop event xyz"; +--error ER_UNKNOWN_STMT_HANDLER +deallocate prepare abc; + + +--disable_warnings +drop table if exists t1; +create table t1 (a int, b char(5)) engine=myisam; +insert into t1 values (1, "one"), (2, "two"), (3, "three"); +--enable_warnings +SET GLOBAL new_cache.key_buffer_size=128*1024; +create procedure proc_1() cache index t1 in new_cache; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +SET GLOBAL second_cache.key_buffer_size=128*1024; +prepare abc from "cache index t1 in second_cache"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +drop table t1; + +--disable_warnings +drop table if exists t1; +drop table if exists t2; +create table t1 (a int, b char(5)) engine=myisam; +insert into t1 values (1, "one"), (2, "two"), (3, "three"); +create table t2 (a int, b char(5)) engine=myisam; +insert into t2 values (1, "one"), (2, "two"), (3, "three"); +--enable_warnings +create procedure proc_1() load index into cache t1 ignore leaves; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin load index into cache t1 ignore leaves; return 1; end| +delimiter ;| +prepare abc from "load index into cache t2 ignore leaves"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +drop table t1, t2; + +# +# Bug #21422: GRANT/REVOKE possible inside stored function, probably in a trigger +# This is disabled for now till it is resolved in 5.0 +# + +#create procedure proc_1() grant all on *.* to abc@host; +#drop procedure proc_1; +#delimiter |; +#--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +#create function func_1() returns int begin grant all on *.* to abc@host; return 1; end| +#delimiter ;| +#prepare abc from "grant all on *.* to abc@host"; +# +#create procedure proc_1() revoke all on *.* from abc@host; +#drop procedure proc_1; +#delimiter |;#--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +#create function func_1() returns int begin revoke all on *.* from abc@host; return 1; end| +#delimiter ;| +#prepare abc from "revoke all on *.* from abc@host"; + +create procedure proc_1() show errors; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin show errors; return 1; end| +delimiter ;| +prepare abc from "show errors"; +deallocate prepare abc; + +--disable_warnings +drop table if exists t1; +drop table if exists t2; +--enable_warnings +create procedure proc_1() show warnings; +drop table if exists t1; +call proc_1(); +drop table if exists t2; +call proc_1(); +drop table if exists t1, t2; +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin show warnings; return 1; end| +delimiter ;| +prepare abc from "show warnings"; +drop table if exists t1; +execute abc; +drop table if exists t2; +execute abc; +drop table if exists t1, t2; +execute abc; +deallocate prepare abc; + diff --git a/mysql-test/t/ps_1general.test b/mysql-test/t/ps_1general.test index c15bc1633a6..c0b81796731 100644 --- a/mysql-test/t/ps_1general.test +++ b/mysql-test/t/ps_1general.test @@ -330,17 +330,11 @@ prepare stmt4 from ' show engine bdb logs '; execute stmt4; --enable_result_log prepare stmt4 from ' show grants for user '; ---error 1295 prepare stmt4 from ' show create table t2 '; ---error 1295 prepare stmt4 from ' show master status '; ---error 1295 prepare stmt4 from ' show master logs '; ---error 1295 prepare stmt4 from ' show slave status '; ---error 1295 prepare stmt4 from ' show warnings limit 20 '; ---error 1295 prepare stmt4 from ' show errors limit 20 '; prepare stmt4 from ' show storage engines '; # The output depends upon the precise order in which @@ -427,14 +421,12 @@ prepare stmt1 from ' execute stmt2 ' ; prepare stmt1 from ' deallocate prepare never_prepared ' ; ## switch the database connection ---error 1295 +--error ER_UNSUPPORTED_PS prepare stmt4 from ' use test ' ; ## create/drop database ---error 1295 prepare stmt3 from ' create database mysqltest '; create database mysqltest ; ---error 1295 prepare stmt3 from ' drop database mysqltest '; drop database mysqltest ; @@ -446,12 +438,12 @@ drop table t2 ; --error 1146 execute stmt3; ## lock/unlock ---error 1295 +--error ER_UNSUPPORTED_PS prepare stmt3 from ' lock tables t1 read ' ; ---error 1295 +--error ER_UNSUPPORTED_PS prepare stmt3 from ' unlock tables ' ; ## Load/Unload table contents ---error 1295 +--error ER_UNSUPPORTED_PS prepare stmt1 from ' load data infile ''data.txt'' into table t1 fields terminated by ''\t'' '; prepare stmt1 from ' select * into outfile ''data.txt'' from t1 '; @@ -459,13 +451,12 @@ execute stmt1 ; ## prepare stmt1 from ' optimize table t1 ' ; prepare stmt1 from ' analyze table t1 ' ; ---error 1295 prepare stmt1 from ' checksum table t1 ' ; prepare stmt1 from ' repair table t1 ' ; ---error 1295 +--error ER_UNSUPPORTED_PS prepare stmt1 from ' restore table t1 from ''data.txt'' ' ; ## handler ---error 1295 +--error ER_UNSUPPORTED_PS prepare stmt1 from ' handler t1 open '; @@ -491,11 +482,8 @@ SET sql_mode=ansi; execute stmt5; SET sql_mode=""; ---error 1295 prepare stmt1 from ' flush local privileges ' ; ---error 1295 prepare stmt1 from ' reset query cache ' ; ---error 1295 prepare stmt1 from ' KILL 0 '; ## simple explain diff --git a/mysql-test/t/ps_grant.test b/mysql-test/t/ps_grant.test index 81c842de459..4c48b4d151f 100644 --- a/mysql-test/t/ps_grant.test +++ b/mysql-test/t/ps_grant.test @@ -117,15 +117,12 @@ drop database mysqltest; # # grant/revoke + drop user # ---error 1295 prepare stmt3 from ' grant all on test.t1 to drop_user@localhost identified by ''looser'' '; grant all on test.t1 to drop_user@localhost identified by 'looser' ; ---error 1295 prepare stmt3 from ' revoke all privileges on test.t1 from drop_user@localhost '; revoke all privileges on test.t1 from drop_user@localhost ; ---error 1295 prepare stmt3 from ' drop user drop_user@localhost '; drop user drop_user@localhost; diff --git a/sql/sp_head.cc b/sql/sp_head.cc index b88ff13cd7a..475419631f7 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -161,17 +161,20 @@ sp_get_flags_for_command(LEX *lex) } /* fallthrough */ case SQLCOM_ANALYZE: + case SQLCOM_BACKUP_TABLE: case SQLCOM_OPTIMIZE: case SQLCOM_PRELOAD_KEYS: case SQLCOM_ASSIGN_TO_KEYCACHE: case SQLCOM_CHECKSUM: case SQLCOM_CHECK: case SQLCOM_HA_READ: + case SQLCOM_SHOW_AUTHORS: case SQLCOM_SHOW_BINLOGS: case SQLCOM_SHOW_BINLOG_EVENTS: case SQLCOM_SHOW_CHARSETS: case SQLCOM_SHOW_COLLATIONS: case SQLCOM_SHOW_COLUMN_TYPES: + case SQLCOM_SHOW_CONTRIBUTORS: case SQLCOM_SHOW_CREATE: case SQLCOM_SHOW_CREATE_DB: case SQLCOM_SHOW_CREATE_FUNC: @@ -180,16 +183,20 @@ sp_get_flags_for_command(LEX *lex) case SQLCOM_SHOW_DATABASES: case SQLCOM_SHOW_ERRORS: case SQLCOM_SHOW_FIELDS: + case SQLCOM_SHOW_FUNC_CODE: case SQLCOM_SHOW_GRANTS: case SQLCOM_SHOW_ENGINE_STATUS: case SQLCOM_SHOW_ENGINE_LOGS: case SQLCOM_SHOW_ENGINE_MUTEX: + case SQLCOM_SHOW_EVENTS: case SQLCOM_SHOW_KEYS: case SQLCOM_SHOW_MASTER_STAT: case SQLCOM_SHOW_NEW_MASTER: case SQLCOM_SHOW_OPEN_TABLES: case SQLCOM_SHOW_PRIVILEGES: case SQLCOM_SHOW_PROCESSLIST: + case SQLCOM_SHOW_PROC_CODE: + case SQLCOM_SHOW_SCHEDULER_STATUS: case SQLCOM_SHOW_SLAVE_HOSTS: case SQLCOM_SHOW_SLAVE_STAT: case SQLCOM_SHOW_STATUS: @@ -199,12 +206,7 @@ sp_get_flags_for_command(LEX *lex) case SQLCOM_SHOW_TABLES: case SQLCOM_SHOW_VARIABLES: case SQLCOM_SHOW_WARNS: - case SQLCOM_SHOW_PROC_CODE: - case SQLCOM_SHOW_FUNC_CODE: - case SQLCOM_SHOW_AUTHORS: - case SQLCOM_SHOW_CONTRIBUTORS: case SQLCOM_REPAIR: - case SQLCOM_BACKUP_TABLE: case SQLCOM_RESTORE_TABLE: flags= sp_head::MULTI_RESULTS; break; @@ -262,6 +264,9 @@ sp_get_flags_for_command(LEX *lex) case SQLCOM_CREATE_EVENT: case SQLCOM_ALTER_EVENT: case SQLCOM_DROP_EVENT: + case SQLCOM_FLUSH: + case SQLCOM_INSTALL_PLUGIN: + case SQLCOM_UNINSTALL_PLUGIN: flags= sp_head::HAS_COMMIT_OR_ROLLBACK; break; default: diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 16508516df7..337f1cc2492 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1740,6 +1740,20 @@ static bool check_prepared_statement(Prepared_statement *stmt, case SQLCOM_SHOW_ENGINE_MUTEX: case SQLCOM_SHOW_CREATE_DB: case SQLCOM_SHOW_GRANTS: + case SQLCOM_SHOW_BINLOG_EVENTS: + case SQLCOM_SHOW_MASTER_STAT: + case SQLCOM_SHOW_SLAVE_STAT: + case SQLCOM_SHOW_CREATE_PROC: + case SQLCOM_SHOW_CREATE_FUNC: + case SQLCOM_SHOW_CREATE_EVENT: + case SQLCOM_SHOW_CREATE: + case SQLCOM_SHOW_PROC_CODE: + case SQLCOM_SHOW_FUNC_CODE: + case SQLCOM_SHOW_AUTHORS: + case SQLCOM_SHOW_CONTRIBUTORS: + case SQLCOM_SHOW_WARNS: + case SQLCOM_SHOW_ERRORS: + case SQLCOM_SHOW_BINLOGS: case SQLCOM_DROP_TABLE: case SQLCOM_RENAME_TABLE: case SQLCOM_ALTER_TABLE: @@ -1754,6 +1768,25 @@ static bool check_prepared_statement(Prepared_statement *stmt, case SQLCOM_REPAIR: case SQLCOM_ANALYZE: case SQLCOM_OPTIMIZE: + case SQLCOM_CHANGE_MASTER: + case SQLCOM_RESET: + case SQLCOM_FLUSH: + case SQLCOM_SLAVE_START: + case SQLCOM_SLAVE_STOP: + case SQLCOM_INSTALL_PLUGIN: + case SQLCOM_UNINSTALL_PLUGIN: + case SQLCOM_CREATE_DB: + case SQLCOM_DROP_DB: + case SQLCOM_RENAME_DB: + case SQLCOM_CHECKSUM: + case SQLCOM_CREATE_USER: + case SQLCOM_RENAME_USER: + case SQLCOM_DROP_USER: + case SQLCOM_ASSIGN_TO_KEYCACHE: + case SQLCOM_PRELOAD_KEYS: + case SQLCOM_GRANT: + case SQLCOM_REVOKE: + case SQLCOM_KILL: break; default: From 8eeac5a7272840bc42698028fca4845e003cecca Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 24 Aug 2006 16:17:42 +0400 Subject: [PATCH 7/7] after merge fix --- mysql-test/t/csv.test | 2 +- storage/csv/ha_tina.cc | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test index a042f163635..9815da4fb55 100644 --- a/mysql-test/t/csv.test +++ b/mysql-test/t/csv.test @@ -1575,7 +1575,7 @@ create table bug15205 (val int(11) default null) engine=csv; create table bug15205_2 (val int(11) default null) engine=csv; --exec rm $MYSQLTEST_VARDIR/master-data/test/bug15205.CSV # system error (can't open the datafile) ---error ER_GET_ERRNO +--error 13 select * from bug15205; select * from bug15205_2; --exec touch $MYSQLTEST_VARDIR/master-data/test/bug15205.CSV diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index bec236becd0..5d18ed99a9a 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -229,6 +229,11 @@ static TINA_SHARE *get_share(const char *table_name, TABLE *table) MY_REPLACE_EXT|MY_UNPACK_FILENAME); fn_format(meta_file_name, table_name, "", CSM_EXT, MY_REPLACE_EXT|MY_UNPACK_FILENAME); + + if (my_stat(share->data_file_name, &file_stat, MYF(MY_WME)) == NULL) + goto error; + share->saved_data_file_length= file_stat.st_size; + if (my_hash_insert(&tina_open_tables, (byte*) share)) goto error; thr_lock_init(&share->lock); @@ -250,10 +255,6 @@ static TINA_SHARE *get_share(const char *table_name, TABLE *table) */ if (read_meta_file(share->meta_file, &share->rows_recorded)) share->crashed= TRUE; - - if (my_stat(share->data_file_name, &file_stat, MYF(MY_WME)) == NULL) - goto error2; - share->saved_data_file_length= file_stat.st_size; } share->use_count++; pthread_mutex_unlock(&tina_mutex);