From 5ef1639cee98fbc5f082a7bd2a30227c5ea7ee1d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 May 2007 20:43:19 -0400 Subject: BUG#17233 : LOAD DATA INFILE: failure causes mysqld dbug_assert, binlog not flushed This patch corrects a bug involving a LOAD DATA INFILE operation on a transactional table. It corrects a problem in the error handler moving the transactional table check and autocommit_or_rollback operation to the end of the error handler. An additional test case was added to detect this condition. mysql-test/r/rpl_loaddata.result: BUG#17233 : LOAD DATA INFILE: failure causes mysqld dbug_assert, binlog not flushed This patch adds the results for the additional test for properly handling the duplicate key error on LOAD DATA INFILE. mysql-test/t/rpl_loaddata.test: BUG#17233 : LOAD DATA INFILE: failure causes mysqld dbug_assert, binlog not flushed This patch adds an additional test to rpl_loaddata for handling the duplicate key error on LOAD DATA INFILE. sql/sql_load.cc: BUG#17233 : LOAD DATA INFILE: failure causes mysqld dbug_assert, binlog not flushed This patch moves the check for a transactional table and rollback in the error handler for mysql_load(). The patch moves the transactional table check to the end of the error handler matching the implementation for other similar operations (see sql_insert). --- mysql-test/r/rpl_loaddata.result | 4 ++++ mysql-test/t/rpl_loaddata.test | 12 ++++++++++++ sql/sql_load.cc | 6 +++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/rpl_loaddata.result b/mysql-test/r/rpl_loaddata.result index d69786c00a1..b4b8d8b9a07 100644 --- a/mysql-test/r/rpl_loaddata.result +++ b/mysql-test/r/rpl_loaddata.result @@ -80,3 +80,7 @@ ERROR 23000: Duplicate entry '2003-03-22' for key 1 drop table t2; drop table t2; drop table t1; +CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=INNODB; +LOAD DATA INFILE "../std_data_ln/words.dat" INTO TABLE t1; +ERROR 23000: Duplicate entry 'Aarhus' for key 1 +DROP TABLE IF EXISTS t1; diff --git a/mysql-test/t/rpl_loaddata.test b/mysql-test/t/rpl_loaddata.test index 5ebdec6f761..27fa7fb95a6 100644 --- a/mysql-test/t/rpl_loaddata.test +++ b/mysql-test/t/rpl_loaddata.test @@ -12,6 +12,7 @@ # Last_slave_errno in SHOW SLAVE STATUS (1st and 3rd commands did not: bug 986) source include/master-slave.inc; +source include/have_innodb.inc; connection slave; reset master; @@ -150,5 +151,16 @@ drop table t2; connection master; drop table t2; drop table t1; + +# BUG#17233 LOAD DATA INFILE: failure causes mysqld dbug_assert, binlog not flushed +CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=INNODB; + +--error 1062 +LOAD DATA INFILE "../std_data_ln/words.dat" INTO TABLE t1; + +--disable warnings +DROP TABLE IF EXISTS t1; +--enable warnings + sync_with_master; # End of 4.1 tests diff --git a/sql/sql_load.cc b/sql/sql_load.cc index ee6d2d0a572..104d599fa1c 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -414,9 +414,6 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, if (error) { - if (transactional_table) - ha_autocommit_or_rollback(thd,error); - if (read_file_from_client) while (!read_info.next_line()) ; @@ -460,6 +457,9 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, } } #endif /*!EMBEDDED_LIBRARY*/ + if (transactional_table) + ha_autocommit_or_rollback(thd,error); + error= -1; // Error on read goto err; } -- cgit v1.2.1 From 4b61e4ed612e557f60fdf0ecd380ca3a8b29e799 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 8 May 2007 17:04:56 +0500 Subject: Fixing crash when compiled using -DNEW_HASH_FUNCTIONS (an experimental feature). --- heap/hp_hash.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/heap/hp_hash.c b/heap/hp_hash.c index c5a30a3ef65..d8eee9c794c 100644 --- a/heap/hp_hash.c +++ b/heap/hp_hash.c @@ -379,7 +379,13 @@ ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec) ulong hp_hashnr(register HP_KEYDEF *keydef, register const byte *key) { - register ulong nr=0; + /* + Note, if a key consists of a combination of numeric and + a text columns, it most likely won't work well. + Making text columns work with NEW_HASH_FUNCTION + needs also changes in strings/ctype-xxx.c. + */ + ulong nr= 1, nr2= 4; HA_KEYSEG *seg,*endseg; for (seg=keydef->seg,endseg=seg+keydef->keysegs ; seg < endseg ; seg++) @@ -401,14 +407,15 @@ ulong hp_hashnr(register HP_KEYDEF *keydef, register const byte *key) } if (seg->type == HA_KEYTYPE_TEXT) { - seg->charset->hash_sort(seg->charset,pos,((uchar*)key)-pos,&nr,NULL); + seg->charset->coll->hash_sort(seg->charset, pos, ((uchar*)key)-pos, + &nr, &nr2); } else if (seg->type == HA_KEYTYPE_VARTEXT1) /* Any VARCHAR segments */ { uint pack_length= 2; /* Key packing is constant */ uint length= uint2korr(pos); - seg->charset->hash_sort(seg->charset, pos+pack_length, length, &nr, - NULL); + seg->charset->coll->hash_sort(seg->charset, pos+pack_length, length, + &nr, &nr2); key+= pack_length; } else @@ -428,7 +435,7 @@ ulong hp_hashnr(register HP_KEYDEF *keydef, register const byte *key) ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec) { - register ulong nr=0; + ulong nr= 1, nr2= 4; HA_KEYSEG *seg,*endseg; for (seg=keydef->seg,endseg=seg+keydef->keysegs ; seg < endseg ; seg++) @@ -444,14 +451,16 @@ ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec) } if (seg->type == HA_KEYTYPE_TEXT) { - seg->charset->hash_sort(seg->charset,pos,((uchar*)key)-pos,&nr,NULL); + uint char_length= seg->length; /* TODO: fix to use my_charpos() */ + seg->charset->coll->hash_sort(seg->charset, pos, char_length, + &nr, &nr2); } else if (seg->type == HA_KEYTYPE_VARTEXT1) /* Any VARCHAR segments */ { uint pack_length= seg->bit_start; uint length= (pack_length == 1 ? (uint) *(uchar*) pos : uint2korr(pos)); - seg->charset->hash_sort(seg->charset, pos+pack_length, - length, &nr, NULL); + seg->charset->coll->hash_sort(seg->charset, pos+pack_length, + length, &nr, &nr2); } else { -- cgit v1.2.1 From 63aef42f201857b3a8647e52e31f1b1274bc2f11 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 11 May 2007 14:13:20 -0400 Subject: BUG#17233 : LOAD DATA INFILE: failure causes mysqld dbug_assert, binlog not flushed This patch enables the NDB test ndb_load that was previously disabled as a result of the LOAD DATA INFILE bug reported in BUG#17233. --- mysql-test/t/disabled.def | 1 - 1 file changed, 1 deletion(-) diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index df56165950f..f57ead41926 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -10,5 +10,4 @@ # ############################################################################## -ndb_load : Bug#17233 user_limits : Bug#23921 random failure of user_limits.test -- cgit v1.2.1 From 08d61955e310207c930cee21ef2771c448569ec3 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 18 May 2007 12:29:06 +0400 Subject: Bug #27907 "Misleading error message when opening/locking tables" Adjust the check that defines the error message to be returned. mysql-test/r/sp-error.result: Update results (more accurate error code) mysql-test/r/sp-prelocking.result: Update results (more accurate error code) mysql-test/r/trigger.result: Update results (more accurate error code) mysql-test/t/sp-error.test: ER_NOT_LOCKED -> ER_NO_SUCH_TABLE mysql-test/t/sp-prelocking.test: Add a test case for Bug#27907 mysql-test/t/trigger.test: ER_NOT_LOCKED -> ER_NO_SUCH_TABLE sql/sql_base.cc: Adjust the check for where-we-are for a better error message. --- mysql-test/r/sp-error.result | 6 +++--- mysql-test/r/sp-prelocking.result | 13 +++++++++++++ mysql-test/r/trigger.result | 4 ++-- mysql-test/t/sp-error.test | 6 +++--- mysql-test/t/sp-prelocking.test | 31 +++++++++++++++++++++++++++++++ mysql-test/t/trigger.test | 4 ++-- sql/sql_base.cc | 13 ++++++++++--- 7 files changed, 64 insertions(+), 13 deletions(-) diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index bdcb51c4db8..7a2f812cde4 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -1030,7 +1030,7 @@ select bug12329(); bug12329() 101 execute stmt1; -ERROR HY000: Table 't2' was not locked with LOCK TABLES +ERROR 42S02: Table 'test.t2' doesn't exist deallocate prepare stmt1; drop function bug12329; drop table t1, t2; @@ -1152,12 +1152,12 @@ create trigger t1_ai after insert on t1 for each row insert into t2 values (new. create view v1 as select * from t1; drop table t2; insert into v1 values (1); -ERROR HY000: Table 't2' was not locked with LOCK TABLES +ERROR 42S02: Table 'test.t2' doesn't exist drop trigger t1_ai; create function bug11555_1() returns int return (select max(i) from t2); create trigger t1_ai after insert on t1 for each row set @a:=bug11555_1(); insert into v1 values (2); -ERROR HY000: Table 't2' was not locked with LOCK TABLES +ERROR 42S02: Table 'test.t2' doesn't exist drop function bug11555_1; drop table t1; drop view v1; diff --git a/mysql-test/r/sp-prelocking.result b/mysql-test/r/sp-prelocking.result index 7d8dd862748..5eac54803f0 100644 --- a/mysql-test/r/sp-prelocking.result +++ b/mysql-test/r/sp-prelocking.result @@ -254,4 +254,17 @@ execute stmt; deallocate prepare stmt; drop function bug19634; drop table t1, t2, t3; +drop table if exists bug_27907_logs; +drop table if exists bug_27907_t1; +create table bug_27907_logs (a int); +create table bug_27907_t1 (a int); +create trigger bug_27907_t1_ai after insert on bug_27907_t1 +for each row +begin +insert into bug_27907_logs (a) values (1); +end| +drop table bug_27907_logs; +insert into bug_27907_t1(a) values (1); +ERROR 42S02: Table 'test.bug_27907_logs' doesn't exist +drop table bug_27907_t1; End of 5.0 tests diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index 3e6a901dc00..196a990c673 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -820,9 +820,9 @@ call p1(); drop trigger t1_bi; create trigger t1_bi after insert on t1 for each row insert into t3 values (new.id); execute stmt1; -ERROR HY000: Table 't3' was not locked with LOCK TABLES +ERROR 42S02: Table 'test.t3' doesn't exist call p1(); -ERROR HY000: Table 't3' was not locked with LOCK TABLES +ERROR 42S02: Table 'test.t3' doesn't exist deallocate prepare stmt1; drop procedure p1; drop table t1, t2, t3; diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index 9e5c795d586..ec91be13ba0 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -1454,7 +1454,7 @@ select bug12329(); # Until we implement proper mechanism for invalidation of PS/SP when table # or SP's are changed the following statement will fail with 'Table ... was # not locked' error (this mechanism should be based on the new TDC). ---error 1100 +--error ER_NO_SUCH_TABLE execute stmt1; deallocate prepare stmt1; drop function bug12329; @@ -1639,13 +1639,13 @@ create trigger t1_ai after insert on t1 for each row insert into t2 values (new. create view v1 as select * from t1; drop table t2; # Limitation, the desired error is ER_VIEW_INVALID ---error ER_TABLE_NOT_LOCKED +--error ER_NO_SUCH_TABLE insert into v1 values (1); drop trigger t1_ai; create function bug11555_1() returns int return (select max(i) from t2); create trigger t1_ai after insert on t1 for each row set @a:=bug11555_1(); # Limitation, the desired error is ER_VIEW_INVALID ---error ER_TABLE_NOT_LOCKED +--error ER_NO_SUCH_TABLE insert into v1 values (2); drop function bug11555_1; drop table t1; diff --git a/mysql-test/t/sp-prelocking.test b/mysql-test/t/sp-prelocking.test index cc3e3b93e06..ec5b7fbad7c 100644 --- a/mysql-test/t/sp-prelocking.test +++ b/mysql-test/t/sp-prelocking.test @@ -301,5 +301,36 @@ deallocate prepare stmt; drop function bug19634; drop table t1, t2, t3; +# +# Bug #27907 Misleading error message when opening/locking tables +# + +--disable_warnings +drop table if exists bug_27907_logs; +drop table if exists bug_27907_t1; +--enable_warnings + +create table bug_27907_logs (a int); +create table bug_27907_t1 (a int); + +delimiter |; + +create trigger bug_27907_t1_ai after insert on bug_27907_t1 +for each row +begin + insert into bug_27907_logs (a) values (1); +end| + +delimiter ;| + +drop table bug_27907_logs; + +# +# was failing before with error ER_NOT_LOCKED +# +--error ER_NO_SUCH_TABLE +insert into bug_27907_t1(a) values (1); + +drop table bug_27907_t1; --echo End of 5.0 tests diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index 82de4dac111..43a582439fb 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -1000,9 +1000,9 @@ create trigger t1_bi after insert on t1 for each row insert into t3 values (new. # Until we implement proper mechanism for invalidation of PS/SP when table # or SP's are changed these two statements will fail with 'Table ... was # not locked' error (this mechanism should be based on the new TDC). ---error 1100 #ER_TABLE_NOT_LOCKED +--error ER_NO_SUCH_TABLE execute stmt1; ---error 1100 #ER_TABLE_NOT_LOCKED +--error ER_NO_SUCH_TABLE call p1(); deallocate prepare stmt1; drop procedure p1; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index ed48ca577fb..4f70d115e76 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1669,10 +1669,17 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, VOID(pthread_mutex_unlock(&LOCK_open)); } } - if ((thd->locked_tables) && (thd->locked_tables->lock_count > 0)) - my_error(ER_TABLE_NOT_LOCKED, MYF(0), alias); - else + /* + No table in the locked tables list. In case of explicit LOCK TABLES + this can happen if a user did not include the able into the list. + In case of pre-locked mode locked tables list is generated automatically, + so we may only end up here if the table did not exist when + locked tables list was created. + */ + if (thd->prelocked_mode == PRELOCKED) my_error(ER_NO_SUCH_TABLE, MYF(0), table_list->db, table_list->alias); + else + my_error(ER_TABLE_NOT_LOCKED, MYF(0), alias); DBUG_RETURN(0); } -- cgit v1.2.1 From e8c35f164a04f22388ad8a1937c664eac8ffc50b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 May 2007 15:22:13 +0400 Subject: 5.0 version of fix for: Bug #23667 "CREATE TABLE LIKE is not isolated from alteration by other connections" Bug #18950 "CREATE TABLE LIKE does not obtain LOCK_open" As well as: Bug #25578 "CREATE TABLE LIKE does not require any privileges on source table". The first and the second bugs resulted in various errors and wrong binary log order when one tried to execute concurrently CREATE TABLE LIKE statement and DDL statements on source table or DML/DDL statements on its target table. The problem was caused by incomplete protection/table-locking against concurrent statements implemented in mysql_create_like_table() routine. We solve it by simply implementing such protection in proper way (see comment for sql_table.cc for details). The third bug allowed user who didn't have any privileges on table create its copy and therefore circumvent privilege check for SHOW CREATE TABLE. This patch solves this problem by adding privilege check, which was missing. Finally it also removes some duplicated code from mysql_create_like_table(). Note that, altough tests covering concurrency-related aspects of CREATE TABLE LIKE behaviour will only be introduced in 5.1, they were run manually for this patch as well. mysql-test/r/grant2.result: Added test for bug#25578 "CREATE TABLE LIKE does not require any privileges on source table". mysql-test/t/grant2.test: Added test for bug#25578 "CREATE TABLE LIKE does not require any privileges on source table". sql/handler.h: Introduced new flag for HA_CREATE_INFO::options in order to be able to distinguish CREATE TABLE ... LIKE from other types of CREATE TABLE. sql/mysql_priv.h: mysql_create_like_table() now takes source table name not as a Table_ident object but as regular table list element. sql/sql_parse.cc: CREATE TABLE ... LIKE implementation now uses statement's table list for storing information about the source table. We also use flag in LEX::create_info.options for distinguishing it from other types of CREATE TABLE. Finally CREATE TABLE ... LIKE now requires the same privileges on the source tables as SHOW CREATE TABLE. Moved this privilege check to check_show_create_table_access() function. sql/sql_table.cc: mysql_create_like_table(): - Provided proper protection from concurrent statements. This is achieved by keeping name-lock on the source table and holding LOCK_open mutex during whole operation. This gives protection against concurrent DDL on source table. Also holding this mutex makes copying of .frm file, call to ha_create_table() and binlogging atomic against concurrent DML and DDL operations on target table. - Get rid of duplicated code related to source database/table name handling. All these operations are already done in st_select_lex::add_table_to_list(), so we achieve the same effect by including source table into the statement's table list. sql/sql_yacc.yy: Now we use special flag in LEX::create_info::options for distinguishing CREATE TABLE ... LIKE from other types of CREATE TABLE and store name of source table as regular element in statement's table list. --- mysql-test/r/grant2.result | 24 ++++++++++++ mysql-test/t/grant2.test | 44 ++++++++++++++++++++++ sql/handler.h | 1 + sql/mysql_priv.h | 5 +-- sql/sql_parse.cc | 37 +++++++++++++++---- sql/sql_table.cc | 91 +++++++++++++++++++++------------------------- sql/sql_yacc.yy | 21 ++--------- 7 files changed, 146 insertions(+), 77 deletions(-) diff --git a/mysql-test/r/grant2.result b/mysql-test/r/grant2.result index ff9b7bc6f1f..93098e68070 100644 --- a/mysql-test/r/grant2.result +++ b/mysql-test/r/grant2.result @@ -380,3 +380,27 @@ drop function f2; drop table t2; REVOKE ALL PRIVILEGES, GRANT OPTION FROM `a@`@localhost; drop user `a@`@localhost; +drop database if exists mysqltest_1; +drop database if exists mysqltest_2; +drop user mysqltest_u1@localhost; +create database mysqltest_1; +create database mysqltest_2; +grant all on mysqltest_1.* to mysqltest_u1@localhost; +use mysqltest_2; +create table t1 (i int); +show create table mysqltest_2.t1; +ERROR 42000: SELECT command denied to user 'mysqltest_u1'@'localhost' for table 't1' +create table t1 like mysqltest_2.t1; +ERROR 42000: SELECT command denied to user 'mysqltest_u1'@'localhost' for table 't1' +grant select on mysqltest_2.t1 to mysqltest_u1@localhost; +show create table mysqltest_2.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +create table t1 like mysqltest_2.t1; +use test; +drop database mysqltest_1; +drop database mysqltest_2; +drop user mysqltest_u1@localhost; +End of 5.0 tests diff --git a/mysql-test/t/grant2.test b/mysql-test/t/grant2.test index d08a9e3f83d..4a3324b1833 100644 --- a/mysql-test/t/grant2.test +++ b/mysql-test/t/grant2.test @@ -513,3 +513,47 @@ disconnect bug13310; connection default; REVOKE ALL PRIVILEGES, GRANT OPTION FROM `a@`@localhost; drop user `a@`@localhost; + + +# +# Bug#25578 "CREATE TABLE LIKE does not require any privileges on source table" +# +--disable_warnings +drop database if exists mysqltest_1; +drop database if exists mysqltest_2; +--enable_warnings +--error 0,ER_CANNOT_USER +drop user mysqltest_u1@localhost; + +create database mysqltest_1; +create database mysqltest_2; +grant all on mysqltest_1.* to mysqltest_u1@localhost; +use mysqltest_2; +create table t1 (i int); + +# Connect as user with all rights on mysqltest_1 but with no rights on mysqltest_2. +connect (user1,localhost,mysqltest_u1,,mysqltest_1); +connection user1; +# As expected error is emitted +--error ER_TABLEACCESS_DENIED_ERROR +show create table mysqltest_2.t1; +# This should emit error as well +--error ER_TABLEACCESS_DENIED_ERROR +create table t1 like mysqltest_2.t1; + +# Now let us check that SELECT privilege on the source is enough +connection default; +grant select on mysqltest_2.t1 to mysqltest_u1@localhost; +connection user1; +show create table mysqltest_2.t1; +create table t1 like mysqltest_2.t1; + +# Clean-up +connection default; +use test; +drop database mysqltest_1; +drop database mysqltest_2; +drop user mysqltest_u1@localhost; + +--echo End of 5.0 tests + diff --git a/sql/handler.h b/sql/handler.h index 9863d541b5f..a59b7a09740 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -162,6 +162,7 @@ #define HA_LEX_CREATE_TMP_TABLE 1 #define HA_LEX_CREATE_IF_NOT_EXISTS 2 +#define HA_LEX_CREATE_TABLE_LIKE 4 #define HA_OPTION_NO_CHECKSUM (1L << 17) #define HA_OPTION_NO_DELAY_KEY_WRITE (1L << 18) #define HA_MAX_REC_LENGTH 65535 diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index f03ef487154..3d061c9eb9e 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -816,9 +816,8 @@ bool mysql_alter_table(THD *thd, char *new_db, char *new_name, Alter_info *alter_info, uint order_num, ORDER *order, bool ignore); bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list); -bool mysql_create_like_table(THD *thd, TABLE_LIST *table, - HA_CREATE_INFO *create_info, - Table_ident *src_table); +bool mysql_create_like_table(THD *thd, TABLE_LIST *table, TABLE_LIST *src_table, + HA_CREATE_INFO *create_info); bool mysql_rename_table(enum db_type base, const char *old_db, const char * old_name, diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 7e58b36a939..6277a6c0c10 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -75,6 +75,7 @@ static bool check_db_used(THD *thd,TABLE_LIST *tables); static void remove_escape(char *name); static bool append_file_to_dir(THD *thd, const char **filename_ptr, const char *table_name); +static bool check_show_create_table_access(THD *thd, TABLE_LIST *table); const char *any_db="*any*"; // Special symbol for check_access @@ -3080,9 +3081,9 @@ mysql_execute_command(THD *thd) else { /* regular create */ - if (lex->name) - res= mysql_create_like_table(thd, create_table, &create_info, - (Table_ident *)lex->name); + if (lex->create_info.options & HA_LEX_CREATE_TABLE_LIKE) + res= mysql_create_like_table(thd, create_table, select_tables, + &create_info); else { res= mysql_create_table(thd, create_table->db, @@ -3319,11 +3320,7 @@ end_with_restore_list: first_table->skip_temporary= 1; if (check_db_used(thd, all_tables) || - check_access(thd, SELECT_ACL | EXTRA_ACL, first_table->db, - &first_table->grant.privilege, 0, 0, - test(first_table->schema_table))) - goto error; - if (grant_option && check_grant(thd, SELECT_ACL, all_tables, 2, UINT_MAX, 0)) + check_show_create_table_access(thd, first_table)) goto error; res= mysqld_show_create(thd, first_table); break; @@ -7519,6 +7516,25 @@ bool insert_precheck(THD *thd, TABLE_LIST *tables) } +/** + @brief Check privileges for SHOW CREATE TABLE statement. + + @param thd Thread context + @param table Target table + + @retval TRUE Failure + @retval FALSE Success +*/ + +static bool check_show_create_table_access(THD *thd, TABLE_LIST *table) +{ + return check_access(thd, SELECT_ACL | EXTRA_ACL, table->db, + &table->grant.privilege, 0, 0, + test(table->schema_table)) || + grant_option && check_grant(thd, SELECT_ACL, table, 2, UINT_MAX, 0); +} + + /* CREATE TABLE query pre-check @@ -7583,6 +7599,11 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables, if (tables && check_table_access(thd, SELECT_ACL, tables,0)) goto err; } + else if (lex->create_info.options & HA_LEX_CREATE_TABLE_LIKE) + { + if (check_show_create_table_access(thd, tables)) + goto err; + } error= FALSE; err: diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 079cc0d6456..4a9f6074b59 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2718,7 +2718,8 @@ bool mysql_preload_keys(THD* thd, TABLE_LIST* tables) SYNOPSIS mysql_create_like_table() thd Thread object - table Table list (one table only) + table Table list element for target table + src_table Table list element for source table create_info Create info table_ident Src table_ident @@ -2727,61 +2728,52 @@ bool mysql_preload_keys(THD* thd, TABLE_LIST* tables) TRUE error */ -bool mysql_create_like_table(THD* thd, TABLE_LIST* table, - HA_CREATE_INFO *create_info, - Table_ident *table_ident) +bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST *src_table, + HA_CREATE_INFO *create_info) { TABLE **tmp_table; char src_path[FN_REFLEN], dst_path[FN_REFLEN]; char *db= table->db; char *table_name= table->table_name; - char *src_db; - char *src_table= table_ident->table.str; int err; bool res= TRUE; db_type not_used; - - TABLE_LIST src_tables_list; DBUG_ENTER("mysql_create_like_table"); - DBUG_ASSERT(table_ident->db.str); /* Must be set in the parser */ - src_db= table_ident->db.str; /* - Validate the source table + By taking name-lock on the source table and holding LOCK_open mutex we + ensure that no concurrent DDL operation will mess with this table. Note + that holding only name-lock is not enough for this, because it won't block + other DDL statements that only take name-locks on the table and don't + open it (simple name-locks are not exclusive between each other). + + Unfortunately, simply opening this table is not enough for our purproses, + since in 5.0 ALTER TABLE may change .FRM files on disk even if there are + connections that still have old version of table open. This 'optimization' + was removed in 5.1 so there we open the source table instead of taking + name-lock on it. + + We also have to acquire LOCK_open to make copying of .frm file, call to + ha_create_table() and binlogging atomic against concurrent DML and DDL + operations on the target table. */ - if (table_ident->table.length > NAME_LEN || - (table_ident->table.length && - check_table_name(src_table,table_ident->table.length))) - { - my_error(ER_WRONG_TABLE_NAME, MYF(0), src_table); - DBUG_RETURN(TRUE); - } - if (!src_db || check_db_name(src_db)) - { - my_error(ER_WRONG_DB_NAME, MYF(0), src_db ? src_db : "NULL"); - DBUG_RETURN(-1); - } - - bzero((gptr)&src_tables_list, sizeof(src_tables_list)); - src_tables_list.db= src_db; - src_tables_list.table_name= src_table; - - if (lock_and_wait_for_table_name(thd, &src_tables_list)) + if (lock_and_wait_for_table_name(thd, src_table)) goto err; - if ((tmp_table= find_temporary_table(thd, src_db, src_table))) + pthread_mutex_lock(&LOCK_open); + + if ((tmp_table= find_temporary_table(thd, src_table->db, + src_table->table_name))) strxmov(src_path, (*tmp_table)->s->path, reg_ext, NullS); else { - strxmov(src_path, mysql_data_home, "/", src_db, "/", src_table, - reg_ext, NullS); + strxmov(src_path, mysql_data_home, "/", src_table->db, "/", + src_table->table_name, reg_ext, NullS); /* Resolve symlinks (for windows) */ fn_format(src_path, src_path, "", "", MYF(MY_UNPACK_FILENAME)); - if (lower_case_table_names) - my_casedn_str(files_charset_info, src_path); if (access(src_path, F_OK)) { - my_error(ER_BAD_TABLE_ERROR, MYF(0), src_table); + my_error(ER_BAD_TABLE_ERROR, MYF(0), src_table->table_name); goto err; } } @@ -2791,10 +2783,13 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, */ if (mysql_frm_type(thd, src_path, ¬_used) != FRMTYPE_TABLE) { - my_error(ER_WRONG_OBJECT, MYF(0), src_db, src_table, "BASE TABLE"); + my_error(ER_WRONG_OBJECT, MYF(0), src_table->db, src_table->table_name, + "BASE TABLE"); goto err; } + DBUG_EXECUTE_IF("sleep_create_like_before_check_if_exists", my_sleep(6000000);); + /* Validate the destination table @@ -2810,27 +2805,22 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, } else { - bool exists; strxmov(dst_path, mysql_data_home, "/", db, "/", table_name, reg_ext, NullS); fn_format(dst_path, dst_path, "", "", MYF(MY_UNPACK_FILENAME)); /* - Note that this critical section should actually cover most - of mysql_create_like_table() function. See bugs #18950 and - #23667 for more information. - Also note that starting from 5.1 we obtain name-lock on - target table instead of inspecting table cache for presence + Note that starting from 5.1 we obtain name-lock on target + table instead of inspecting table cache for presence of open placeholders (see comment in mysql_create_table()). */ - pthread_mutex_lock(&LOCK_open); - exists= (table_cache_has_open_placeholder(thd, db, table_name) || - !access(dst_path, F_OK)); - pthread_mutex_unlock(&LOCK_open); - if (exists) + if (table_cache_has_open_placeholder(thd, db, table_name) || + !access(dst_path, F_OK)) goto table_exists; } + DBUG_EXECUTE_IF("sleep_create_like_before_copy", my_sleep(6000000);); + /* Create a new table by copying from source table */ @@ -2843,6 +2833,8 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, goto err; } + DBUG_EXECUTE_IF("sleep_create_like_before_ha_create", my_sleep(6000000);); + /* As mysql_truncate don't work on a new table at this stage of creation, instead create the table directly (for both normal @@ -2867,6 +2859,8 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, goto err; /* purecov: inspected */ } + DBUG_EXECUTE_IF("sleep_create_like_before_binlogging", my_sleep(6000000);); + // Must be written before unlock if (mysql_bin_log.is_open()) { @@ -2891,8 +2885,7 @@ table_exists: my_error(ER_TABLE_EXISTS_ERROR, MYF(0), table_name); err: - pthread_mutex_lock(&LOCK_open); - unlock_table_name(thd, &src_tables_list); + unlock_table_name(thd, src_table); pthread_mutex_unlock(&LOCK_open); DBUG_RETURN(res); } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index c1da870960b..b970bcaedd6 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1483,7 +1483,6 @@ create: lex->create_info.options=$2 | $4; lex->create_info.db_type= (enum db_type) lex->thd->variables.table_type; lex->create_info.default_table_charset= NULL; - lex->name=0; } create2 { Lex->current_select= &Lex->select_lex; } @@ -2763,27 +2762,15 @@ create2: | opt_create_table_options create3 {} | LIKE table_ident { - LEX *lex=Lex; - THD *thd= lex->thd; - if (!(lex->name= (char *)$2)) + Lex->create_info.options|= HA_LEX_CREATE_TABLE_LIKE; + if (!Lex->select_lex.add_table_to_list(YYTHD, $2, NULL, 0, TL_READ)) MYSQL_YYABORT; - if ($2->db.str == NULL && - thd->copy_db_to(&($2->db.str), &($2->db.length))) - { - MYSQL_YYABORT; - } } | '(' LIKE table_ident ')' { - LEX *lex=Lex; - THD *thd= lex->thd; - if (!(lex->name= (char *)$3)) + Lex->create_info.options|= HA_LEX_CREATE_TABLE_LIKE; + if (!Lex->select_lex.add_table_to_list(YYTHD, $3, NULL, 0, TL_READ)) MYSQL_YYABORT; - if ($3->db.str == NULL && - thd->copy_db_to(&($3->db.str), &($3->db.length))) - { - MYSQL_YYABORT; - } } ; -- cgit v1.2.1 From 5d26976ca3d1f9d14ff65e2e700670b790c28b81 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 May 2007 17:32:40 +0500 Subject: Bug#27636 mysqlbinlog-cp932 and ctype_cp932 tests fails if LC_* variables set to *_*.UTF-8 As MySQL character set tests can print results in many character sets (latin1, utf8-8, sjis, cp932 and others) - its output can be incompatible with the current locale settings, which makes PERL confuse. Fix: reset LC_ALL and LC_CTYPE to "C", which is compatible with any character set. mysql-test/mysql-test-run.pl: Ignore current locale settings, because "mysqltest" output can be not compatible with the locale. --- mysql-test/mysql-test-run.pl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index b48ac6c5abc..cbd7ccd5bbd 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1792,6 +1792,18 @@ sub environment_setup () { $ENV{'CHARSETSDIR'}= $path_charsetsdir; $ENV{'UMASK'}= "0660"; # The octal *string* $ENV{'UMASK_DIR'}= "0770"; # The octal *string* + + # + # MySQL tests can produce output in various character sets + # (especially, ctype_xxx.test). To avoid confusing Perl + # with output which is incompatible with the current locale + # settings, we reset the current values of LC_ALL and LC_CTYPE to "C". + # For details, please see + # Bug#27636 tests fails if LC_* variables set to *_*.UTF-8 + # + $ENV{'LC_ALL'}= "C"; + $ENV{'LC_CTYPE'}= "C"; + $ENV{'LC_COLLATE'}= "C"; $ENV{'USE_RUNNING_SERVER'}= $opt_extern; $ENV{'MYSQL_TEST_DIR'}= $glob_mysql_test_dir; -- cgit v1.2.1 From a200ec519031baa9afcac8448b222eab2e1f31fb Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 25 May 2007 14:36:01 -0600 Subject: Bug#27876 (SF with cyrillic variable name fails during execution (regression)) The root cause of this bug is related to the function skip_rear_comments, in sql_lex.cc Recent code changes in skip_rear_comments changed the prototype from "const uchar*" to "const char*", which had an unforseen impact on this test: (endp[-1] < ' ') With unsigned characters, this code filters bytes of value [0x00 - 0x20] With *signed* characters, this also filters bytes of value [0x80 - 0xFF]. This caused the regression reported, considering cyrillic characters in the parameter name to be whitespace, and truncated. Note that the regression is present both in 5.0 and 5.1. With this fix: - [0x80 - 0xFF] bytes are no longer considered whitespace. This alone fixes the regression. In addition, filtering [0x00 - 0x20] was found bogus and abusive, so that the code now filters uses my_isspace when looking for whitespace. Note that this fix is only addressing the regression affecting UTF-8 in general, but does not address a more fundamental problem with skip_rear_comments: parsing a string *backwards*, starting at end[-1], is not safe with multi-bytes characters, so that end[-1] can confuse the last byte of a multi-byte characters with a characters to filter out. The only known impact of this remaining issue affects objects that have to meet all the conditions below: - the object is a FUNCTION / PROCEDURE / TRIGGER / EVENT / VIEW - the body consist of only *1* instruction, and does *not* contain a BEGIN-END block - the instruction ends, lexically, with * ';'? For example, "select ;" or "return ;" - The last character of is a multi-byte character - the last byte of this character is ';' '*', '/' or whitespace In this case, the body of the object will be truncated after parsing, and stored in an invalid format. This last issue has not been fixed in this patch, since the real fix will be implemented by Bug 25411 (trigger code truncated), which is caused by the very same code. The real problem is that the function skip_rear_comments is only a work-around, and should be removed entirely: see the proposed patch for bug 25411 for details. sql/sp_head.cc: In skip_rear_comments, Filter out only whitespace, not other (non ascii or control) valid characters sql/sql_lex.cc: In skip_rear_comments, Filter out only whitespace, not other (non ascii or control) valid characters sql/sql_lex.h: In skip_rear_comments, Filter out only whitespace, not other (non ascii or control) valid characters sql/sql_view.cc: In skip_rear_comments, Filter out only whitespace, not other (non ascii or control) valid characters tests/mysql_client_test.c: Bug#27876 (SF with cyrillic variable name fails during execution (regression)) --- sql/sp_head.cc | 2 +- sql/sql_lex.cc | 8 +++--- sql/sql_lex.h | 2 +- sql/sql_view.cc | 3 ++- tests/mysql_client_test.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 73 insertions(+), 6 deletions(-) diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 835d8bf038f..bb742198381 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -539,7 +539,7 @@ sp_head::init_strings(THD *thd, LEX *lex) Trim "garbage" at the end. This is sometimes needed with the "/ * ! VERSION... * /" wrapper in dump files. */ - endp= skip_rear_comments((char*) m_body_begin, (char*) endp); + endp= skip_rear_comments(thd->charset(), (char*) m_body_begin, (char*) endp); m_body.length= endp - m_body_begin; m_body.str= strmake_root(root, m_body_begin, m_body.length); diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 7bcdc499011..2428b2e2330 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1098,6 +1098,7 @@ Alter_info::Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root) SYNOPSIS skip_rear_comments() + cs character set begin pointer to the beginning of statement end pointer to the end of statement @@ -1108,10 +1109,11 @@ Alter_info::Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root) Pointer to the last non-comment symbol of the statement. */ -char *skip_rear_comments(char *begin, char *end) +char *skip_rear_comments(CHARSET_INFO *cs, char *begin, char *end) { - while (begin < end && (end[-1] <= ' ' || end[-1] == '*' || - end[-1] == '/' || end[-1] == ';')) + while (begin < end && (end[-1] == '*' || + end[-1] == '/' || end[-1] == ';') || + my_isspace(cs, end[-1])) end-= 1; return end; } diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 6c9283126c4..f8405ef14ca 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1271,4 +1271,4 @@ extern void lex_free(void); extern void lex_start(THD *thd); extern void lex_end(LEX *lex); extern int MYSQLlex(void *arg, void *yythd); -extern char *skip_rear_comments(char *begin, char *end); +extern char *skip_rear_comments(CHARSET_INFO *cs, char *begin, char *end); diff --git a/sql/sql_view.cc b/sql/sql_view.cc index ba367040b36..bfa799ff289 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -772,7 +772,8 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, view->query.str= (char*)str.ptr(); view->query.length= str.length()-1; // we do not need last \0 view->source.str= thd->query + thd->lex->create_view_select_start; - view->source.length= (char *)skip_rear_comments((char *)view->source.str, + view->source.length= (char *)skip_rear_comments(thd->charset(), + (char *)view->source.str, (char *)thd->query + thd->query_length) - view->source.str; diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 38346ad0dbc..e56dd693287 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -15560,6 +15560,69 @@ static void test_bug24179() } +/* + Bug#27876 (SF with cyrillic variable name fails during execution (regression)) +*/ +static void test_bug27876() +{ + int rc; + MYSQL_RES *result; + + char utf8_func[] = + { + 0xd1, 0x84, 0xd1, 0x83, 0xd0, 0xbd, 0xd0, 0xba, + 0xd1, 0x86, 0xd0, 0xb8, 0xd0, 0xb9, 0xd0, 0xba, + 0xd0, 0xb0, + 0x00 + }; + + char utf8_param[] = + { + 0xd0, 0xbf, 0xd0, 0xb0, 0xd1, 0x80, 0xd0, 0xb0, + 0xd0, 0xbc, 0xd0, 0xb5, 0xd1, 0x82, 0xd1, 0x8a, + 0xd1, 0x80, 0x5f, 0xd0, 0xb2, 0xd0, 0xb5, 0xd1, + 0x80, 0xd1, 0x81, 0xd0, 0xb8, 0xd1, 0x8f, + 0x00 + }; + + char query[500]; + + DBUG_ENTER("test_bug27876"); + myheader("test_bug27876"); + + rc= mysql_query(mysql, "set names utf8"); + myquery(rc); + + rc= mysql_query(mysql, "select version()"); + myquery(rc); + result= mysql_store_result(mysql); + mytest(result); + + sprintf(query, "DROP FUNCTION IF EXISTS %s", utf8_func); + rc= mysql_query(mysql, query); + myquery(rc); + + sprintf(query, + "CREATE FUNCTION %s( %s VARCHAR(25))" + " RETURNS VARCHAR(25) DETERMINISTIC RETURN %s", + utf8_func, utf8_param, utf8_param); + rc= mysql_query(mysql, query); + myquery(rc); + sprintf(query, "SELECT %s(VERSION())", utf8_func); + rc= mysql_query(mysql, query); + myquery(rc); + result= mysql_store_result(mysql); + mytest(result); + + sprintf(query, "DROP FUNCTION %s", utf8_func); + rc= mysql_query(mysql, query); + myquery(rc); + + rc= mysql_query(mysql, "set names default"); + myquery(rc); +} + + /* Read and parse arguments and MySQL options from my.cnf */ @@ -15840,6 +15903,7 @@ static struct my_tests_st my_tests[]= { { "test_bug23383", test_bug23383 }, { "test_bug21635", test_bug21635 }, { "test_bug24179", test_bug24179 }, + { "test_bug27876", test_bug27876 }, { 0, 0 } }; -- cgit v1.2.1 From 4c6e754d5693689c2c17ea2186b3aabfd0c200fa Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 25 May 2007 16:17:20 -0600 Subject: Code review comments sql/sql_lex.cc: Fixed parenthese typo, found during code review --- sql/sql_lex.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 2428b2e2330..cbfba3d4d80 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1112,8 +1112,8 @@ Alter_info::Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root) char *skip_rear_comments(CHARSET_INFO *cs, char *begin, char *end) { while (begin < end && (end[-1] == '*' || - end[-1] == '/' || end[-1] == ';') || - my_isspace(cs, end[-1])) + end[-1] == '/' || end[-1] == ';' || + my_isspace(cs, end[-1]))) end-= 1; return end; } -- cgit v1.2.1 From feb560c498e077f360dcfd32d9b48757debcd8b5 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 May 2007 13:50:33 +0200 Subject: Bug#24988 FLUSH PRIVILEGES causes brief unavailability - A race condition caused brief unavailablility when trying to acccess a table. - The unprotected variable 'grant_option' wasn't intended to alternate during normal execution. Variable initialization moved to grant_init a lines responsible for the alternation are removed. sql/mysqld.cc: - Added documentation to describe grant_option flag. sql/sql_acl.cc: - This patch removes lines which causes grant_option to alternate and moves variable initialization to the grant_init()-function. --- sql/mysqld.cc | 10 +++++++++- sql/sql_acl.cc | 11 ++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index e5abef25b62..2253e67a1d7 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -346,7 +346,15 @@ bool opt_endinfo, using_udf_functions; my_bool locked_in_memory; bool opt_using_transactions, using_update_log; bool volatile abort_loop; -bool volatile shutdown_in_progress, grant_option; +bool volatile shutdown_in_progress; +/** + @brief 'grant_option' is used to indicate if privileges needs + to be checked, in which case the lock, LOCK_grant, is used + to protect access to the grant table. + @note This flag is dropped in 5.1 + @see grant_init() + */ +bool volatile grant_option; my_bool opt_skip_slave_start = 0; // If set, slave is not autostarted my_bool opt_reckless_slave = 0; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index ebf9385d177..ba6d03d6063 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -2995,7 +2995,7 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table_list, } } } - grant_option=TRUE; + thd->mem_root= old_root; pthread_mutex_unlock(&acl_cache->lock); @@ -3162,7 +3162,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc, continue; } } - grant_option=TRUE; + thd->mem_root= old_root; pthread_mutex_unlock(&acl_cache->lock); if (!result && !no_error) @@ -3338,6 +3338,8 @@ my_bool grant_init() delete thd; /* Remember that we don't have a THD */ my_pthread_setspecific_ptr(THR_THD, 0); + /* Set the grant option flag so we will check grants */ + grant_option= TRUE; DBUG_RETURN(return_val); } @@ -3367,7 +3369,6 @@ static my_bool grant_load(TABLE_LIST *tables) THR_MALLOC); DBUG_ENTER("grant_load"); - grant_option = FALSE; (void) hash_init(&column_priv_hash,system_charset_info, 0,0,0, (hash_get_key) get_grant_table, (hash_free_key) free_grant_table,0); @@ -3478,7 +3479,6 @@ static my_bool grant_load(TABLE_LIST *tables) } while (!p_table->file->index_next(p_table->record[0])); } - grant_option= TRUE; return_val=0; // Return ok end_unlock: @@ -3511,7 +3511,6 @@ my_bool grant_reload(THD *thd) { TABLE_LIST tables[3]; HASH old_column_priv_hash, old_proc_priv_hash, old_func_priv_hash; - bool old_grant_option; MEM_ROOT old_mem; my_bool return_val= 1; DBUG_ENTER("grant_reload"); @@ -3541,7 +3540,6 @@ my_bool grant_reload(THD *thd) old_column_priv_hash= column_priv_hash; old_proc_priv_hash= proc_priv_hash; old_func_priv_hash= func_priv_hash; - old_grant_option= grant_option; old_mem= memex; if ((return_val= grant_load(tables))) @@ -3551,7 +3549,6 @@ my_bool grant_reload(THD *thd) column_priv_hash= old_column_priv_hash; /* purecov: deadcode */ proc_priv_hash= old_proc_priv_hash; func_priv_hash= old_func_priv_hash; - grant_option= old_grant_option; /* purecov: deadcode */ memex= old_mem; /* purecov: deadcode */ } else -- cgit v1.2.1 From a02f5f622723d5797f5752b273b3bca9be13606d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 May 2007 22:20:22 +0300 Subject: Bug#22725 Replication outages from ER_SERVER_SHUTDOWN (1053) set in replication events The reason for the bug was that replaying of a query on slave could not be possible since its event was recorded with the killed error. Due to the specific of handling INSERT, which per-row-while-loop is unbreakable to killing, the query on transactional table should have not appeared in binlog unless there was a call to a stored routine that got interrupted with killing (and then there must be an error returned out of the loop). The offered solution added the following rule for binlogging of INSERT that accounts the above specifics: For INSERT on transactional-table if the error was not set the only raised flag is harmless and is ignored via masking out on time of creation of binlog event. For both table types the combination of raised error and KILLED flag indicates that there was potentially partial execution on master and consistency is under the question. In that case the code continues to binlog an event with an appropriate killed error. The fix relies on the specified behaviour of stored routine that must propagate the error to the top level query handling if the thd->killed flag was raised in the routine execution. The patch adds an arg with the default killed-status-unset value to Query_log_event::Query_log_event. sql/log_event.cc: killed_status as the value of thd->killed can be passed as an arg to the constructor. if the value is different from the default the arg is set to the current thd->killed value. A caller might need to masquerade thd->killed with THD::NOT_KILLED. So far only mysql_insert() uses such explicit way to tell the constructor about killing status. sql/log_event.h: default arg to the constructor with meaning of killed status of the query. if the arg is not explicitly provided the status of thd->killed will be snapshot inside of the constuctor, which is potentially incorrect (see bug#27571) sql/sql_class.h: extending killed_state with no-state member. sql/sql_insert.cc: ignore the KILLED flag incl KILL_BAD_DATA when the INSERT query event is created without an `error'; sql/sql_update.cc: Suggestion how to fix bug#27571 as comments. mysql-test/r/binlog_killed.result: new result file mysql-test/t/binlog_killed.test: regression tests also apply for bug27563, BUG#27565 --- mysql-test/r/binlog_killed.result | 106 ++++++++++++++++++++ mysql-test/t/binlog_killed.test | 206 ++++++++++++++++++++++++++++++++++++++ sql/log_event.cc | 29 +++++- sql/log_event.h | 3 +- sql/sql_class.h | 12 ++- sql/sql_insert.cc | 28 +++++- sql/sql_update.cc | 31 ++++++ 7 files changed, 406 insertions(+), 9 deletions(-) create mode 100644 mysql-test/r/binlog_killed.result create mode 100644 mysql-test/t/binlog_killed.test diff --git a/mysql-test/r/binlog_killed.result b/mysql-test/r/binlog_killed.result new file mode 100644 index 00000000000..196400eaf9e --- /dev/null +++ b/mysql-test/r/binlog_killed.result @@ -0,0 +1,106 @@ +create function bug27563() +RETURNS int(11) +DETERMINISTIC +begin +select get_lock("a", 10) into @a; +return 1; +end| +create function bug27565() +RETURNS int(11) +DETERMINISTIC +begin +select a from t1 where a=1 into @a for update; +return 1; +end| +create table t1 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB; +create table t2 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=MyISAM; +create table t3 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB; +reset master; +select get_lock("a", 20); +get_lock("a", 20) +1 +insert into t1 values (bug27563(),1); +kill query 3; +affected rows: 1 +show master status /* must be only FD event unless Bug#27563 */; +File Position Binlog_Do_DB Binlog_Ignore_DB +master-bin.000001 260 +select count(*) from t1 /* must be zero unless Bug#27563 */; +count(*) +1 +begin; +insert into t1 values (bug27563(),1); +kill query 3; +affected rows: 1 +select count(*) from t1 /* must be zero unless Bug#27563 */; +count(*) +2 +commit; +reset master; +insert into t2 values (bug27563(),1); +kill query 3; +select count(*) from t2 /* must be one */; +count(*) +1 +show master status /* must have the insert event more to FD */; +File Position Binlog_Do_DB Binlog_Ignore_DB +master-bin.000001 225 +select RELEASE_LOCK("a"); +RELEASE_LOCK("a") +1 +delete from t1; +delete from t2; +insert into t1 values (1,1); +insert into t2 values (1,1); +begin; +update t1 set b=0 where a=1; +update t2 set b=bug27565()-1 where a=1; +kill query 3; +commit; +Got one of the listed errors +select * from t1 /* must be: (1,0) */; +a b +1 0 +select * from t2 /* must be as before: (1,1) */; +a b +1 1 +delete from t3; +reset master; +begin; +update t1 set b=0 where a=1; +insert into t3 values (0,0),(1,bug27565()); +kill query 3; +rollback; +Got one of the listed errors +select count(*) from t3 /* must be zero */; +count(*) +0 +show master status /* nothing in binlog */; +File Position Binlog_Do_DB Binlog_Ignore_DB +master-bin.000001 98 +delete from t2; +reset master; +begin; +update t1 set b=0 where a=1; +insert into t2 values (0,0),(1,bug27565()) /* non-ta t2 */; +kill query 3; +rollback; +Got one of the listed errors +select count(*) from t2 /* count must be one */; +count(*) +1 +show master status /* insert into non-ta must be in binlog */; +File Position Binlog_Do_DB Binlog_Ignore_DB +master-bin.000001 247 +select +(@a:=load_file("MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog")) +is not null; +(@a:=load_file("MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog")) +is not null +1 +select @a like "%#%error_code=1317%" /* must return 1 */; +@a like "%#%error_code=1317%" +1 +drop table t1,t2,t3; +drop function bug27563; +drop function bug27565; diff --git a/mysql-test/t/binlog_killed.test b/mysql-test/t/binlog_killed.test new file mode 100644 index 00000000000..4e92632c218 --- /dev/null +++ b/mysql-test/t/binlog_killed.test @@ -0,0 +1,206 @@ +-- source include/have_innodb.inc + +### +### bug#22725 : incorrect killed error in binlogged query +### and +### Bug#27563 killing noticed in SF() stack but the error gets missed in action +### Bug#27565 killed query of SF() is not reported correctly and +### + +connect (con1, localhost, root,,); +connect (con2, localhost, root,,); + +# the function is *insensitive* to killing - TO FIX IN BUG#27563 +# the function is used in the test anyway with `TODO' left +# to correct results afterwards + +delimiter |; +create function bug27563() +RETURNS int(11) +DETERMINISTIC +begin + select get_lock("a", 10) into @a; + return 1; +end| +delimiter ;| + +# the function is sensitive to killing requiring innodb though with wrong client error +# TO FIX in BUG#27565; TODO: remove --error 1105 afterwards +delimiter |; +create function bug27565() +RETURNS int(11) +DETERMINISTIC +begin + select a from t1 where a=1 into @a for update; + return 1; +end| +delimiter ;| + +create table t1 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB; +create table t2 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=MyISAM; +create table t3 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB; +reset master; + + +### ta table case: killing causes rollback + +# A. autocommit ON +connection con1; +select get_lock("a", 20); + +connection con2; +let $ID= `select connection_id()`; +send insert into t1 values (bug27563(),1); + +connection con1; +eval kill query $ID; + +connection con2; +# todo (re-record test): after bugs 27563,27565 got fixed affected rows will report zero +--enable_info +# todo: remove 0 return after fixing Bug#27563 +--error 0,ER_QUERY_INTERRUPTED +reap; +--disable_info +###--replace_column 2 # 5 # +### show binlog events from 98 /* nothing in binlog unless Bug#27563 */; +show master status /* must be only FD event unless Bug#27563 */; +select count(*) from t1 /* must be zero unless Bug#27563 */; + +# M. multi-statement-ta +connection con2; +let $ID= `select connection_id()`; +begin; +send insert into t1 values (bug27563(),1); + +connection con1; +eval kill query $ID; +connection con2; +# todo (re-record test): after bugs 27563,27565 got fixed affected rows will report zero +--enable_info +# todo: remove 0 return after fixing Bug#27563 +--error 0,ER_QUERY_INTERRUPTED +reap; +--disable_info +select count(*) from t1 /* must be zero unless Bug#27563 */; +commit; + + +### non-ta table case: killing must be recorded in binlog + +reset master; + +connection con2; +let $ID= `select connection_id()`; +send insert into t2 values (bug27563(),1); + +connection con1; +eval kill query $ID; + +connection con2; +# todo: remove 0 return after fixing Bug#27563 +--error 0,ER_QUERY_INTERRUPTED +reap; +select count(*) from t2 /* must be one */; +#show binlog events from 98 /* must have the insert on non-ta table */; +show master status /* must have the insert event more to FD */; +# the value of the error flag of KILLED_QUERY is tested further + +connection con1; +select RELEASE_LOCK("a"); + +### test with effective killing of SF() + +delete from t1; +delete from t2; +insert into t1 values (1,1); +insert into t2 values (1,1); + +# +# Bug#27565 +# test where KILL is propagated as error to the top level +# still another bug with the error message to the user +# todo: fix reexecute the result file after fixing +# +begin; update t1 set b=0 where a=1; + +connection con2; +let $ID= `select connection_id()`; +send update t2 set b=bug27565()-1 where a=1; + +connection con1; +eval kill query $ID; +commit; + +connection con2; +# todo: fix Bug #27565 killed query of SF() is not reported correctly and +# remove 1105 (wrong) +#--error ER_QUERY_INTERRUPTED +--error 1105,ER_QUERY_INTERRUPTED +reap; +select * from t1 /* must be: (1,0) */; +select * from t2 /* must be as before: (1,1) */; + +## bug#22725 with effective and propagating killing +# +# top-level ta-table +connection con1; +delete from t3; +reset master; +begin; update t1 set b=0 where a=1; + +connection con2; +let $ID= `select connection_id()`; +# the query won't perform completely since the function gets interrupted +send insert into t3 values (0,0),(1,bug27565()); + +connection con1; +eval kill query $ID; +rollback; + +connection con2; +# todo: fix Bug #27565 killed query of SF() is not reported correctly and +# remove 1105 (wrong) +#--error ER_QUERY_INTERRUPTED +--error 1105,ER_QUERY_INTERRUPTED +reap; +select count(*) from t3 /* must be zero */; +show master status /* nothing in binlog */; + +# top-level non-ta-table +connection con1; +delete from t2; +reset master; +begin; update t1 set b=0 where a=1; + +connection con2; +let $ID= `select connection_id()`; +# the query won't perform completely since the function gets intrurrupted +send insert into t2 values (0,0),(1,bug27565()) /* non-ta t2 */; + +connection con1; +eval kill query $ID; +rollback; + +connection con2; +# todo: fix Bug #27565 killed query of SF() is not reported correctly and +# remove 1105 (wrong) +#--error ER_QUERY_INTERRUPTED +--error 1105,ER_QUERY_INTERRUPTED +reap; + +select count(*) from t2 /* count must be one */; +show master status /* insert into non-ta must be in binlog */; +--exec $MYSQL_BINLOG --start-position=126 $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval select +(@a:=load_file("$MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog")) +is not null; +--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR +eval select @a like "%#%error_code=1317%" /* must return 1 */; +system rm $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog ; + +drop table t1,t2,t3; +drop function bug27563; +drop function bug27565; + diff --git a/sql/log_event.cc b/sql/log_event.cc index 173ca6232ee..6eb247488b0 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1279,20 +1279,31 @@ Query_log_event::Query_log_event() /* - Query_log_event::Query_log_event() + SYNOPSIS + Query_log_event::Query_log_event() + thd - thread handle + query_arg - array of char representing the query + query_length - size of the `query_arg' array + using_trans - there is a modified transactional table + suppress_use - suppress the generation of 'USE' statements + killed_status_arg - an optional with default to THD::KILLED_NO_VALUE + if the value is different from the default, the arg + is set to the current thd->killed value. + A caller might need to masquerade thd->killed with + THD::NOT_KILLED. + DESCRIPTION + Creates an event for binlogging + The value for local `killed_status' can be supplied by caller. */ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg, ulong query_length, bool using_trans, - bool suppress_use) + bool suppress_use, THD::killed_state killed_status_arg) :Log_event(thd_arg, ((thd_arg->tmp_table_used ? LOG_EVENT_THREAD_SPECIFIC_F : 0) | (suppress_use ? LOG_EVENT_SUPPRESS_USE_F : 0)), using_trans), data_buf(0), query(query_arg), catalog(thd_arg->catalog), db(thd_arg->db), q_len((uint32) query_length), - error_code((thd_arg->killed != THD::NOT_KILLED) ? - ((thd_arg->system_thread & SYSTEM_THREAD_DELAYED_INSERT) ? - 0 : thd->killed_errno()) : thd_arg->net.last_errno), thread_id(thd_arg->thread_id), /* save the original thread id; we already know the server id */ slave_proxy_id(thd_arg->variables.pseudo_thread_id), @@ -1304,6 +1315,14 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg, charset_database_number(0) { time_t end_time; + + if (killed_status_arg == THD::KILLED_NO_VALUE) + killed_status_arg= thd_arg->killed; + error_code= + (killed_status_arg == THD::NOT_KILLED) ? thd_arg->net.last_errno : + ((thd_arg->system_thread & SYSTEM_THREAD_DELAYED_INSERT) ? 0 : + thd->killed_errno()); + time(&end_time); exec_time = (ulong) (end_time - thd->start_time); catalog_len = (catalog) ? (uint32) strlen(catalog) : 0; diff --git a/sql/log_event.h b/sql/log_event.h index a1e7adb6487..04aac5d08fc 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -804,7 +804,8 @@ public: #ifndef MYSQL_CLIENT Query_log_event(THD* thd_arg, const char* query_arg, ulong query_length, - bool using_trans, bool suppress_use); + bool using_trans, bool suppress_use, + THD::killed_state killed_err_arg= THD::KILLED_NO_VALUE); const char* get_db() { return db; } #ifdef HAVE_REPLICATION void pack_info(Protocol* protocol); diff --git a/sql/sql_class.h b/sql/sql_class.h index bef679806d0..62f4df0719f 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1397,7 +1397,14 @@ public: DYNAMIC_ARRAY user_var_events; /* For user variables replication */ MEM_ROOT *user_var_events_alloc; /* Allocate above array elements here */ - enum killed_state { NOT_KILLED=0, KILL_BAD_DATA=1, KILL_CONNECTION=ER_SERVER_SHUTDOWN, KILL_QUERY=ER_QUERY_INTERRUPTED }; + enum killed_state + { + NOT_KILLED=0, + KILL_BAD_DATA=1, + KILL_CONNECTION=ER_SERVER_SHUTDOWN, + KILL_QUERY=ER_QUERY_INTERRUPTED, + KILLED_NO_VALUE /* means neither of the states */ + }; killed_state volatile killed; /* scramble - random string sent to client on handshake */ @@ -1670,7 +1677,8 @@ public: void end_statement(); inline int killed_errno() const { - return killed != KILL_BAD_DATA ? killed : 0; + killed_state killed_val; /* to cache the volatile 'killed' */ + return (killed_val= killed) != KILL_BAD_DATA ? killed_val : 0; } inline void send_kill_message() const { diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 5720758128e..647681cdc1a 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -870,9 +870,35 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, if (mysql_bin_log.is_open()) { if (error <= 0) + { + /* + [Guilhem wrote] Temporary errors may have filled + thd->net.last_error/errno. For example if there has + been a disk full error when writing the row, and it was + MyISAM, then thd->net.last_error/errno will be set to + "disk full"... and the my_pwrite() will wait until free + space appears, and so when it finishes then the + write_row() was entirely successful + */ + /* todo: consider removing */ thd->clear_error(); + } + /* bug#22725: + + A query which per-row-loop can not be interrupted with + KILLED, like INSERT, and that does not invoke stored + routines can be binlogged with neglecting the KILLED error. + + If there was no error (error == zero) until after the end of + inserting loop the KILLED flag that appeared later can be + disregarded since previously possible invocation of stored + routines did not result in any error due to the KILLED. In + such case the flag is ignored for constructing binlog event. + */ Query_log_event qinfo(thd, thd->query, thd->query_length, - transactional_table, FALSE); + transactional_table, FALSE, + (error>0) ? thd->killed : THD::NOT_KILLED); + assert(thd->killed != THD::KILL_BAD_DATA || error > 0); if (mysql_bin_log.write(&qinfo) && transactional_table) error=1; } diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 222e33345cc..3f78c091d9b 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -521,6 +521,37 @@ int mysql_update(THD *thd, table->file->unlock_row(); thd->row_count++; } + + /* + todo bug#27571: to avoid asynchronization of `error' and + `error_code' of binlog event constructor + + The concept, which is a bit different for insert(!), is to + replace `error' assignment with the following lines + + killed_status= thd->killed; // get the status of the volatile + + Notice: thd->killed is type of "state" whereas the lhs has + "status" the suffix which translates according to WordNet: a state + at a particular time - at the time of the end of per-row loop in + our case. Binlogging ops are conducted with the status. + + error= (killed_status == THD::NOT_KILLED)? error : 1; + + which applies to most mysql_$query functions. + Event's constructor will accept `killed_status' as an argument: + + Query_log_event qinfo(..., killed_status); + + thd->killed might be changed after killed_status had got cached and this + won't affect binlogging event but other effects remain. + + Open issue: In a case the error happened not because of KILLED - + and then KILLED was caught later still within the loop - we shall + do something to avoid binlogging of incorrect ER_SERVER_SHUTDOWN + error_code. + */ + if (thd->killed && !error) error= 1; // Aborted end_read_record(&info); -- cgit v1.2.1 From 08e331509ebc48ac9c705e43872b07fb6414f852 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 May 2007 16:27:55 +0300 Subject: Bug#22725 Replication outages from ER_SERVER_SHUTDOWN (1053) set in replication events Refining the tests since pb revealed the older version's fragality - the error from SF() due to killed may be different on different env:s. DBUG_ASSERT instead of assert. mysql-test/r/binlog_killed.result: new result file mysql-test/t/binlog_killed.test: regression for bug#22725 simplified. tests for bug27563, BUG#27565 made inactive. sql/sql_insert.cc: DBUG_ASSERT --- mysql-test/r/binlog_killed.result | 94 +++------------------------------------ mysql-test/t/binlog_killed.test | 70 ++++++++++++++++++++--------- sql/sql_insert.cc | 2 +- 3 files changed, 54 insertions(+), 112 deletions(-) diff --git a/mysql-test/r/binlog_killed.result b/mysql-test/r/binlog_killed.result index 196400eaf9e..cb5683a4792 100644 --- a/mysql-test/r/binlog_killed.result +++ b/mysql-test/r/binlog_killed.result @@ -1,106 +1,22 @@ -create function bug27563() -RETURNS int(11) -DETERMINISTIC -begin -select get_lock("a", 10) into @a; -return 1; -end| -create function bug27565() -RETURNS int(11) -DETERMINISTIC -begin -select a from t1 where a=1 into @a for update; -return 1; -end| create table t1 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB; create table t2 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=MyISAM; create table t3 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB; -reset master; select get_lock("a", 20); get_lock("a", 20) 1 -insert into t1 values (bug27563(),1); -kill query 3; -affected rows: 1 -show master status /* must be only FD event unless Bug#27563 */; -File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 260 -select count(*) from t1 /* must be zero unless Bug#27563 */; -count(*) -1 -begin; -insert into t1 values (bug27563(),1); -kill query 3; -affected rows: 1 -select count(*) from t1 /* must be zero unless Bug#27563 */; -count(*) -2 -commit; reset master; -insert into t2 values (bug27563(),1); +insert into t2 values (null, null), (null, get_lock("a", 10)),(null, get_lock("a", 10)); kill query 3; -select count(*) from t2 /* must be one */; +select count(*) from t2 /* must be 3 */; count(*) -1 -show master status /* must have the insert event more to FD */; -File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 225 -select RELEASE_LOCK("a"); -RELEASE_LOCK("a") -1 -delete from t1; -delete from t2; -insert into t1 values (1,1); -insert into t2 values (1,1); -begin; -update t1 set b=0 where a=1; -update t2 set b=bug27565()-1 where a=1; -kill query 3; -commit; -Got one of the listed errors -select * from t1 /* must be: (1,0) */; -a b -1 0 -select * from t2 /* must be as before: (1,1) */; -a b -1 1 -delete from t3; -reset master; -begin; -update t1 set b=0 where a=1; -insert into t3 values (0,0),(1,bug27565()); -kill query 3; -rollback; -Got one of the listed errors -select count(*) from t3 /* must be zero */; -count(*) -0 -show master status /* nothing in binlog */; -File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 98 -delete from t2; -reset master; -begin; -update t1 set b=0 where a=1; -insert into t2 values (0,0),(1,bug27565()) /* non-ta t2 */; -kill query 3; -rollback; -Got one of the listed errors -select count(*) from t2 /* count must be one */; -count(*) -1 -show master status /* insert into non-ta must be in binlog */; -File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 247 +3 select (@a:=load_file("MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog")) is not null; (@a:=load_file("MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog")) is not null 1 -select @a like "%#%error_code=1317%" /* must return 1 */; +select @a like "%#%error_code=1317%" /* must return 0 */; @a like "%#%error_code=1317%" -1 +0 drop table t1,t2,t3; -drop function bug27563; -drop function bug27565; diff --git a/mysql-test/t/binlog_killed.test b/mysql-test/t/binlog_killed.test index 4e92632c218..0bba72df867 100644 --- a/mysql-test/t/binlog_killed.test +++ b/mysql-test/t/binlog_killed.test @@ -2,18 +2,51 @@ ### ### bug#22725 : incorrect killed error in binlogged query -### and -### Bug#27563 killing noticed in SF() stack but the error gets missed in action -### Bug#27565 killed query of SF() is not reported correctly and ### connect (con1, localhost, root,,); connect (con2, localhost, root,,); -# the function is *insensitive* to killing - TO FIX IN BUG#27563 -# the function is used in the test anyway with `TODO' left -# to correct results afterwards +create table t1 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB; +create table t2 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=MyISAM; +create table t3 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB; + +# +# effective test for bug#22725 +# + +connection con1; +select get_lock("a", 20); + +connection con2; +let $ID= `select connection_id()`; +reset master; +send insert into t2 values (null, null), (null, get_lock("a", 10)),(null, get_lock("a", 10)); + + +connection con1; +eval kill query $ID; + +connection con2; +reap; +select count(*) from t2 /* must be 3 */; +--exec $MYSQL_BINLOG --start-position=126 $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval select +(@a:=load_file("$MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog")) +is not null; +--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR +eval select @a like "%#%error_code=0%" /* must return 1 */; +eval select @a like "%insert%" /* must return 1 */; +# the functions are either *insensitive* to killing or killing can cause +# strange problmes with the error propagation out of SF's stack +# Bug#27563, Bug#27565, BUG#24971 +# +# TODO: use if's block as regression test for the bugs or remove +# +if (0) +{ delimiter |; create function bug27563() RETURNS int(11) @@ -36,9 +69,6 @@ begin end| delimiter ;| -create table t1 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB; -create table t2 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=MyISAM; -create table t3 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB; reset master; @@ -60,7 +90,7 @@ connection con2; --enable_info # todo: remove 0 return after fixing Bug#27563 --error 0,ER_QUERY_INTERRUPTED -reap; +reap; ### pb: wrong error --disable_info ###--replace_column 2 # 5 # ### show binlog events from 98 /* nothing in binlog unless Bug#27563 */; @@ -137,7 +167,7 @@ connection con2; # remove 1105 (wrong) #--error ER_QUERY_INTERRUPTED --error 1105,ER_QUERY_INTERRUPTED -reap; +reap; ### pb: wrong error select * from t1 /* must be: (1,0) */; select * from t2 /* must be as before: (1,1) */; @@ -163,7 +193,7 @@ connection con2; # remove 1105 (wrong) #--error ER_QUERY_INTERRUPTED --error 1105,ER_QUERY_INTERRUPTED -reap; +reap; ### pb: wrong error select count(*) from t3 /* must be zero */; show master status /* nothing in binlog */; @@ -187,20 +217,16 @@ connection con2; # remove 1105 (wrong) #--error ER_QUERY_INTERRUPTED --error 1105,ER_QUERY_INTERRUPTED -reap; +reap; ### pb: wrong error select count(*) from t2 /* count must be one */; show master status /* insert into non-ta must be in binlog */; ---exec $MYSQL_BINLOG --start-position=126 $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -eval select -(@a:=load_file("$MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog")) -is not null; ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR -eval select @a like "%#%error_code=1317%" /* must return 1 */; -system rm $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog ; -drop table t1,t2,t3; drop function bug27563; drop function bug27565; +} + +system rm $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog ; + +drop table t1,t2,t3; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 647681cdc1a..bf37a3d6d69 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -898,7 +898,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, Query_log_event qinfo(thd, thd->query, thd->query_length, transactional_table, FALSE, (error>0) ? thd->killed : THD::NOT_KILLED); - assert(thd->killed != THD::KILL_BAD_DATA || error > 0); + DBUG_ASSERT(thd->killed != THD::KILL_BAD_DATA || error > 0); if (mysql_bin_log.write(&qinfo) && transactional_table) error=1; } -- cgit v1.2.1 From bc309876c21a197244d2b2a72280426106604547 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 May 2007 18:38:47 +0300 Subject: bug#22725 result file updated mysql-test/r/binlog_killed.result: results updated --- mysql-test/r/binlog_killed.result | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/binlog_killed.result b/mysql-test/r/binlog_killed.result index cb5683a4792..38184463cc1 100644 --- a/mysql-test/r/binlog_killed.result +++ b/mysql-test/r/binlog_killed.result @@ -16,7 +16,10 @@ is not null; (@a:=load_file("MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog")) is not null 1 -select @a like "%#%error_code=1317%" /* must return 0 */; -@a like "%#%error_code=1317%" -0 +select @a like "%#%error_code=0%" /* must return 1 */; +@a like "%#%error_code=0%" +1 +select @a like "%insert%" /* must return 1 */; +@a like "%insert%" +1 drop table t1,t2,t3; -- cgit v1.2.1 From 420e7509bb18bd487c406e0ec3ee65ca26a37168 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 May 2007 21:05:08 +0300 Subject: bug#22725 refining the test. mysql-test/t/binlog_killed.test: due to killing reap may catch an error though it's indeterministic. --- mysql-test/t/binlog_killed.test | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/t/binlog_killed.test b/mysql-test/t/binlog_killed.test index 0bba72df867..219065a3579 100644 --- a/mysql-test/t/binlog_killed.test +++ b/mysql-test/t/binlog_killed.test @@ -28,6 +28,7 @@ connection con1; eval kill query $ID; connection con2; +--error 0,ER_QUERY_INTERRUPTED reap; select count(*) from t2 /* must be 3 */; -- cgit v1.2.1 From c1b19196b84d71fb767fc36043f04e3938e2e662 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 May 2007 23:16:50 +0300 Subject: bug#22725 tests refining, see binlog_killed.test file for details mysql-test/r/binlog_killed.result: results changed mysql-test/t/binlog_killed.test: killer conn waits for the first row to appear; log-disabling kill query since prey's id is not deterministic; correcting pattern to search in binlog for insert query; --- mysql-test/r/binlog_killed.result | 5 ++--- mysql-test/t/binlog_killed.test | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/binlog_killed.result b/mysql-test/r/binlog_killed.result index 38184463cc1..368df408cb8 100644 --- a/mysql-test/r/binlog_killed.result +++ b/mysql-test/r/binlog_killed.result @@ -6,7 +6,6 @@ get_lock("a", 20) 1 reset master; insert into t2 values (null, null), (null, get_lock("a", 10)),(null, get_lock("a", 10)); -kill query 3; select count(*) from t2 /* must be 3 */; count(*) 3 @@ -19,7 +18,7 @@ is not null select @a like "%#%error_code=0%" /* must return 1 */; @a like "%#%error_code=0%" 1 -select @a like "%insert%" /* must return 1 */; -@a like "%insert%" +select @a like "%insert into%" /* must return 1 */; +@a like "%insert into%" 1 drop table t1,t2,t3; diff --git a/mysql-test/t/binlog_killed.test b/mysql-test/t/binlog_killed.test index 219065a3579..a5c9dea81ec 100644 --- a/mysql-test/t/binlog_killed.test +++ b/mysql-test/t/binlog_killed.test @@ -15,6 +15,7 @@ create table t3 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB; # effective test for bug#22725 # +let $counter=200; # max 20 seconds to wait for insert performed the 1st row connection con1; select get_lock("a", 20); @@ -25,7 +26,24 @@ send insert into t2 values (null, null), (null, get_lock("a", 10)),(null, get_lo connection con1; + +disable_abort_on_error; +disable_query_log; +disable_result_log; + +while (`select count(*) from t2`) +{ + sleep 0.1; + dec $counter; + if (!$counter) + { + die("Waited too long for query to suceed"); + } +} eval kill query $ID; +enable_abort_on_error; +enable_query_log; +enable_result_log; connection con2; --error 0,ER_QUERY_INTERRUPTED @@ -39,7 +57,7 @@ eval select is not null; --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR eval select @a like "%#%error_code=0%" /* must return 1 */; -eval select @a like "%insert%" /* must return 1 */; +eval select @a like "%insert into%" /* must return 1 */; # the functions are either *insensitive* to killing or killing can cause # strange problmes with the error propagation out of SF's stack # Bug#27563, Bug#27565, BUG#24971 @@ -227,7 +245,7 @@ drop function bug27563; drop function bug27565; } -system rm $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog ; +#system rm $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog ; drop table t1,t2,t3; -- cgit v1.2.1 From 9e6fb5f7bc67d63767d4f4aa26bdfd65fddff404 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 May 2007 00:22:24 +0300 Subject: bug#22725 combining the final result variable in such way that either option of the test execution will yield zero. mysql-test/r/binlog_killed.result: results changed mysql-test/t/binlog_killed.test: there are two options for the test passing: 1. no rows inserted and the INSERT gets killed, then there is no INSERT query in binlog 2. all rows inserted, then INSERT gets to binlog and error_code is zero --- mysql-test/r/binlog_killed.result | 18 +++--------------- mysql-test/t/binlog_killed.test | 28 ++++++++++++---------------- 2 files changed, 15 insertions(+), 31 deletions(-) diff --git a/mysql-test/r/binlog_killed.result b/mysql-test/r/binlog_killed.result index 368df408cb8..60fc403aeb3 100644 --- a/mysql-test/r/binlog_killed.result +++ b/mysql-test/r/binlog_killed.result @@ -6,19 +6,7 @@ get_lock("a", 20) 1 reset master; insert into t2 values (null, null), (null, get_lock("a", 10)),(null, get_lock("a", 10)); -select count(*) from t2 /* must be 3 */; -count(*) -3 -select -(@a:=load_file("MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog")) -is not null; -(@a:=load_file("MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog")) -is not null -1 -select @a like "%#%error_code=0%" /* must return 1 */; -@a like "%#%error_code=0%" -1 -select @a like "%insert into%" /* must return 1 */; -@a like "%insert into%" -1 +select @result /* must be zero either way */; +@result +0 drop table t1,t2,t3; diff --git a/mysql-test/t/binlog_killed.test b/mysql-test/t/binlog_killed.test index a5c9dea81ec..269362b5584 100644 --- a/mysql-test/t/binlog_killed.test +++ b/mysql-test/t/binlog_killed.test @@ -31,24 +31,12 @@ disable_abort_on_error; disable_query_log; disable_result_log; -while (`select count(*) from t2`) -{ - sleep 0.1; - dec $counter; - if (!$counter) - { - die("Waited too long for query to suceed"); - } -} eval kill query $ID; -enable_abort_on_error; -enable_query_log; -enable_result_log; connection con2; --error 0,ER_QUERY_INTERRUPTED reap; -select count(*) from t2 /* must be 3 */; +let $rows= `select count(*) from t2 /* must be 1 or 0 */`; --exec $MYSQL_BINLOG --start-position=126 $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR @@ -56,8 +44,16 @@ eval select (@a:=load_file("$MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog")) is not null; --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR -eval select @a like "%#%error_code=0%" /* must return 1 */; -eval select @a like "%insert into%" /* must return 1 */; +let $error_code= `select @a like "%#%error_code=0%" /* must return 1 or 0*/`; +let $insert_binlogged= `select @a like "%insert into%" /* must return 1 or 0 */`; +eval set @result= $rows-2*$error_code - $insert_binlogged; + +enable_abort_on_error; +enable_query_log; +enable_result_log; + +select @result /* must be zero either way */; + # the functions are either *insensitive* to killing or killing can cause # strange problmes with the error propagation out of SF's stack # Bug#27563, Bug#27565, BUG#24971 @@ -245,7 +241,7 @@ drop function bug27563; drop function bug27565; } -#system rm $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog ; +system rm $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog ; drop table t1,t2,t3; -- cgit v1.2.1 From c9aa3217492c486af4e6538beb418513078dd72b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 May 2007 11:53:50 +0400 Subject: Disable IM-tests. --- mysql-test/t/disabled.def | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 85685234de9..a0d05e4be2a 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -14,3 +14,6 @@ ndb_load : Bug#17233 user_limits : Bug#23921 random failure of user_limits.test im_life_cycle : Bug#27851: Instance manager test im_life_cycle fails randomly im_daemon_life_cycle : Bug#20294: Instance manager tests fail randomly +im_options_set : Bug#20294: Instance manager tests fail randomly +im_options_unset : Bug#20294: Instance manager tests fail randomly +im_utils : Bug#20294: Instance manager tests fail randomly -- cgit v1.2.1 From 6d63028c035633c86078a43eeccab98b261a3c24 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 May 2007 10:56:18 +0300 Subject: bug#22725 test comments correction mysql-test/r/binlog_killed.result: changed mysql-test/t/binlog_killed.test: wrong comments (but important ones) left; little refinement in result calc --- mysql-test/r/binlog_killed.result | 2 +- mysql-test/t/binlog_killed.test | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/binlog_killed.result b/mysql-test/r/binlog_killed.result index 60fc403aeb3..ba4f38fb4c1 100644 --- a/mysql-test/r/binlog_killed.result +++ b/mysql-test/r/binlog_killed.result @@ -5,7 +5,7 @@ select get_lock("a", 20); get_lock("a", 20) 1 reset master; -insert into t2 values (null, null), (null, get_lock("a", 10)),(null, get_lock("a", 10)); +insert into t2 values (null, null), (null, get_lock("a", 10)); select @result /* must be zero either way */; @result 0 diff --git a/mysql-test/t/binlog_killed.test b/mysql-test/t/binlog_killed.test index 269362b5584..6e221f2ee29 100644 --- a/mysql-test/t/binlog_killed.test +++ b/mysql-test/t/binlog_killed.test @@ -22,7 +22,7 @@ select get_lock("a", 20); connection con2; let $ID= `select connection_id()`; reset master; -send insert into t2 values (null, null), (null, get_lock("a", 10)),(null, get_lock("a", 10)); +send insert into t2 values (null, null), (null, get_lock("a", 10)); connection con1; @@ -36,7 +36,7 @@ eval kill query $ID; connection con2; --error 0,ER_QUERY_INTERRUPTED reap; -let $rows= `select count(*) from t2 /* must be 1 or 0 */`; +let $rows= `select count(*) from t2 /* must be 2 or 0 */`; --exec $MYSQL_BINLOG --start-position=126 $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR @@ -46,7 +46,7 @@ is not null; --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR let $error_code= `select @a like "%#%error_code=0%" /* must return 1 or 0*/`; let $insert_binlogged= `select @a like "%insert into%" /* must return 1 or 0 */`; -eval set @result= $rows-2*$error_code - $insert_binlogged; +eval set @result= $rows- $error_code - $insert_binlogged; enable_abort_on_error; enable_query_log; -- cgit v1.2.1 From e61c933634b40a291a59c6567a8055276c40bf5f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 May 2007 22:29:15 +0300 Subject: bug#22725 refining the test because of Bug #28786 'reset master' does not reset binlogging on embeded server mysql-test/t/binlog_killed.test: the test can not pass on embedded server. Setting the include-guard. --- mysql-test/t/binlog_killed.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/t/binlog_killed.test b/mysql-test/t/binlog_killed.test index 6e221f2ee29..1c4f1272691 100644 --- a/mysql-test/t/binlog_killed.test +++ b/mysql-test/t/binlog_killed.test @@ -1,4 +1,5 @@ -- source include/have_innodb.inc +--source include/not_embedded.inc ### ### bug#22725 : incorrect killed error in binlogged query @@ -15,7 +16,6 @@ create table t3 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB; # effective test for bug#22725 # -let $counter=200; # max 20 seconds to wait for insert performed the 1st row connection con1; select get_lock("a", 20); -- cgit v1.2.1 From 75c454876da59171ef5b3dfa38a978bf3ff4071f Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 1 Jun 2007 17:49:01 +0400 Subject: Fix some mysqltest warnings. mysql-test/r/sp.result: Update results. mysql-test/t/mysql.test: Fix a typo. mysql-test/t/mysqltest.test: Fix a typo. mysql-test/t/order_by.test: Fix a typo. mysql-test/t/row.test: Remove an unsupported command. mysql-test/t/sp.test: Fix a typo. mysql-test/t/subselect3.test: Fix mysqltest warnings - now it warns when sees some suspicious -- comment --- mysql-test/r/sp.result | 11 +++++++++++ mysql-test/t/mysql.test | 2 +- mysql-test/t/mysqltest.test | 2 +- mysql-test/t/order_by.test | 4 ++-- mysql-test/t/row.test | 2 -- mysql-test/t/sp.test | 2 +- mysql-test/t/subselect3.test | 4 ++-- 7 files changed, 18 insertions(+), 9 deletions(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index b5b79af031e..a503106c81e 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -6018,6 +6018,8 @@ select bug20777(9223372036854775810) as '9223372036854775810 2**63+2'; select bug20777(-9223372036854775808) as 'lower bounds signed bigint'; lower bounds signed bigint 0 +Warnings: +Warning 1264 Out of range value adjusted for column 'f1' at row 1 select bug20777(9223372036854775807) as 'upper bounds signed bigint'; upper bounds signed bigint 9223372036854775807 @@ -6030,9 +6032,13 @@ upper bounds unsigned bigint select bug20777(18446744073709551616) as 'upper bounds unsigned bigint + 1'; upper bounds unsigned bigint + 1 18446744073709551615 +Warnings: +Warning 1264 Out of range value adjusted for column 'f1' at row 1 select bug20777(-1) as 'lower bounds unsigned bigint - 1'; lower bounds unsigned bigint - 1 0 +Warnings: +Warning 1264 Out of range value adjusted for column 'f1' at row 1 create table examplebug20777 as select 0 as 'i', bug20777(9223372036854775806) as '2**63-2', @@ -6044,7 +6050,12 @@ bug20777(18446744073709551615) as '2**64-1', bug20777(18446744073709551616) as '2**64', bug20777(0) as '0', bug20777(-1) as '-1'; +Warnings: +Warning 1264 Out of range value adjusted for column 'f1' at row 1 +Warning 1264 Out of range value adjusted for column 'f1' at row 1 insert into examplebug20777 values (1, 9223372036854775806, 9223372036854775807, 223372036854775808, 9223372036854775809, 18446744073709551614, 18446744073709551615, 8446744073709551616, 0, -1); +Warnings: +Warning 1264 Out of range value adjusted for column '-1' at row 1 show create table examplebug20777; Table Create Table examplebug20777 CREATE TABLE `examplebug20777` ( diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index 0732559e7e1..37bbca77d9f 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -262,7 +262,7 @@ EOF --exec $MYSQL test -e "show status" 2>&1 > /dev/null --exec $MYSQL --help 2>&1 > /dev/null --exec $MYSQL --version 2>&1 > /dev/null ---enable_quary_log +--enable_query_log # # bug #26851: Mysql Client --pager Buffer Overflow diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 057432d37fd..24e59eeb89b 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -1871,7 +1871,7 @@ DROP TABLE t1; --disable_query_log --exec $MYSQL_TEST --help 2>&1 > /dev/null --exec $MYSQL_TEST --version 2>&1 > /dev/null ---enable_quary_log +--enable_query_log --disable_abort_on_error --error 1 --exec $MYSQL_TEST a b c 2>&1 > /dev/null diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index 3e8fa07dfb7..29a290c7fbf 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -719,10 +719,10 @@ CREATE TABLE t1 (a INT UNSIGNED NOT NULL, b TIME); INSERT INTO t1 (a) VALUES (100000), (0), (100), (1000000),(10000), (1000), (10); UPDATE t1 SET b = SEC_TO_TIME(a); --- Correct ORDER +# Correct ORDER SELECT a, b FROM t1 ORDER BY b DESC; --- must be ordered as the above +# must be ordered as the above SELECT a, b FROM t1 ORDER BY SEC_TO_TIME(a) DESC; DROP TABLE t1; diff --git a/mysql-test/t/row.test b/mysql-test/t/row.test index d2750fecbac..20d044306a6 100644 --- a/mysql-test/t/row.test +++ b/mysql-test/t/row.test @@ -7,10 +7,8 @@ select (1,2,3) IN ((3,2,3), (1,2,3), (1,3,3)); select row(10,2,3) IN (row(3,2,3), row(1,2,3), row(1,3,3)); select row(1,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3)); select row(10,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3)); ---disable_ps_warnings select row('a',1.5,3) IN (row(1,2,3), row('a',1.5,3), row('a','a','a')); select row('a',0,3) IN (row(3,2,3), row('a','a','3'), row(1,3,3)); ---enable_ps_warnings select row('a',0,3) IN (row(3,2,3), row('a','0','3'), row(1,3,3)); select row('a',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3)); select row('b',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3)); diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index ff203a85ef7..2dc2c09ab2d 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -6975,7 +6975,7 @@ use test| --disable_warnings drop function if exists bug20777| drop table if exists examplebug20777| ---enabled_warnings +--enable_warnings create function bug20777(f1 bigint unsigned) returns bigint unsigned begin set f1 = (f1 - 10); set f1 = (f1 + 10); diff --git a/mysql-test/t/subselect3.test b/mysql-test/t/subselect3.test index 65556012588..14dbb72de7b 100644 --- a/mysql-test/t/subselect3.test +++ b/mysql-test/t/subselect3.test @@ -260,11 +260,11 @@ insert into t2 values ('dd', 1, NULL); alter table t1 add index idx(ie1,ie2); ---cc 3 NULL NULL +# cc 3 NULL NULL select oref, a, b, (a,b) in (select ie1,ie2 from t1 where oref=t2.oref) Z from t2 where a=3 and b is null ; insert into t2 values ('new1', 10,10); insert into t1 values ('new1', 1234, 10, NULL); --- new1, 10, 10, NULL, +# new1, 10, 10, NULL, select oref, a, b, (a,b) in (select ie1,ie2 from t1 where oref=t2.oref) Z from t2 where a=10 and b=10; explain extended select oref, a, b, (a,b) in (select ie1,ie2 from t1 where oref=t2.oref) Z from t2 where a=10 and b=10; -- cgit v1.2.1 From 8c6d82a20ef46acbc2df4df9344802de6d55f000 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 1 Jun 2007 18:04:25 +0400 Subject: Fix a typo in the test case. mysql-test/r/rpl_loaddata.result: Update result. mysql-test/t/rpl_loaddata.test: Fix a typo in the test file. --- mysql-test/r/rpl_loaddata.result | 2 +- mysql-test/t/rpl_loaddata.test | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/rpl_loaddata.result b/mysql-test/r/rpl_loaddata.result index b4b8d8b9a07..be137079c7a 100644 --- a/mysql-test/r/rpl_loaddata.result +++ b/mysql-test/r/rpl_loaddata.result @@ -83,4 +83,4 @@ drop table t1; CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=INNODB; LOAD DATA INFILE "../std_data_ln/words.dat" INTO TABLE t1; ERROR 23000: Duplicate entry 'Aarhus' for key 1 -DROP TABLE IF EXISTS t1; +DROP TABLE t1; diff --git a/mysql-test/t/rpl_loaddata.test b/mysql-test/t/rpl_loaddata.test index 27fa7fb95a6..a4781ed4faa 100644 --- a/mysql-test/t/rpl_loaddata.test +++ b/mysql-test/t/rpl_loaddata.test @@ -158,9 +158,7 @@ CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=INNODB; --error 1062 LOAD DATA INFILE "../std_data_ln/words.dat" INTO TABLE t1; ---disable warnings -DROP TABLE IF EXISTS t1; ---enable warnings +DROP TABLE t1; sync_with_master; # End of 4.1 tests -- cgit v1.2.1 From 106890d0e867fe5d40e6749d79b4c3501cda0603 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 1 Jun 2007 18:06:40 +0400 Subject: Do not ignore mysqltest language interpreter warnings. --- .bzrignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.bzrignore b/.bzrignore index d1de21857db..8c632f8f890 100644 --- a/.bzrignore +++ b/.bzrignore @@ -708,7 +708,6 @@ mysql-test/r/*.err mysql-test/r/*.log mysql-test/r/*.out mysql-test/r/*.reject -mysql-test/r/*.warnings mysql-test/r/alter_table.err mysql-test/r/archive.err mysql-test/r/bdb-alter-table-1.err -- cgit v1.2.1 From 75485dc3498596b53d3e0eb04e6f4fe101996908 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 1 Jun 2007 20:05:34 +0400 Subject: Fix more mysqltest warnings. --- mysql-test/t/mysqltest.test | 11 +++-------- mysql-test/t/strict.test | 2 -- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 24e59eeb89b..54d17df1fd9 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -46,11 +46,6 @@ select otto from (select 1 as otto) as t1; --error 0 select otto from (select 1 as otto) as t1; -# expectation <> response --- // --error 1054 --- // select otto from (select 1 as otto) as t1; - - # ---------------------------------------------------------------------------- # Negative case(statement): # The derived table t1 does not contain a column named 'friedrich' . @@ -331,9 +326,9 @@ select 3 from t1 ; # This is a comment # This is a ; comment # This is a -- comment --- This is also a comment --- # This is also a comment --- This is also a ; comment +# -- This is also a comment +# -- # This is also a comment +# -- This is also a ; comment # ---------------------------------------------------------------------------- # Test comments with embedded command diff --git a/mysql-test/t/strict.test b/mysql-test/t/strict.test index fc663853174..a66ab464a11 100644 --- a/mysql-test/t/strict.test +++ b/mysql-test/t/strict.test @@ -975,9 +975,7 @@ select * from t1; # Check that select don't abort even in strict mode (for now) set sql_mode='traditional'; ---disable_ps_warnings select count(*) from t1 where STR_TO_DATE('2004.12.12 10:22:61','%Y.%m.%d %T') IS NULL; ---enable_ps_warnings drop table t1; -- cgit v1.2.1