From 2bbcd7301ad458afa17dbd64515950f5b6f75bf0 Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Sun, 15 Jun 2008 18:01:07 +0500 Subject: [PATCH 001/137] Bug #35934 mysql_upgrade calls mysqlcheck with insufficient parameters. Parameters added to the mysqlcheck call to fix table/database names. --- client/mysql_upgrade.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 6c5ca039a41..088115ec3ac 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -652,6 +652,8 @@ static int run_mysqlcheck_upgrade(void) "--check-upgrade", "--all-databases", "--auto-repair", + "--fix-db-names", + "--fix-table-names", NULL); } From deaa2c3059e9283cf2b60e35d7dbf91b772d9b62 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Wed, 12 Nov 2008 13:36:53 +0100 Subject: [PATCH 002/137] Bug#38784: Mysql server crash if table is altered with partition changes. Occurred with EXTRA_DEBUG on windows. Problem was insufficient length of a local variable that stored path names. Solution was to use the correct length. --- CMakeLists.txt | 4 ++++ sql/sql_partition.cc | 22 +++++++++++----------- win/configure.js | 1 + 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7107a112f19..2f6e1236542 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,6 +98,10 @@ IF(CYBOZU) ADD_DEFINITIONS(-DCYBOZU) ENDIF(CYBOZU) +IF(EXTRA_DEBUG) + ADD_DEFINITIONS(-D EXTRA_DEBUG) +ENDIF(EXTRA_DEBUG) + # in some places we use DBUG_OFF SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDBUG_OFF") SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDBUG_OFF") diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 5ed64ea8fd5..8eabded623c 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -5304,8 +5304,8 @@ static bool write_log_changed_partitions(ALTER_PARTITION_PARAM_TYPE *lpt, DDL_LOG_ENTRY ddl_log_entry; partition_info *part_info= lpt->part_info; DDL_LOG_MEMORY_ENTRY *log_entry; - char tmp_path[FN_LEN]; - char normal_path[FN_LEN]; + char tmp_path[FN_REFLEN]; + char normal_path[FN_REFLEN]; List_iterator part_it(part_info->partitions); uint temp_partitions= part_info->temp_partitions.elements; uint no_elements= part_info->partitions.elements; @@ -5516,7 +5516,7 @@ static bool write_log_drop_shadow_frm(ALTER_PARTITION_PARAM_TYPE *lpt) partition_info *part_info= lpt->part_info; DDL_LOG_MEMORY_ENTRY *log_entry; DDL_LOG_MEMORY_ENTRY *exec_log_entry= NULL; - char shadow_path[FN_LEN]; + char shadow_path[FN_REFLEN]; DBUG_ENTER("write_log_drop_shadow_frm"); build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt); @@ -5559,8 +5559,8 @@ static bool write_log_rename_frm(ALTER_PARTITION_PARAM_TYPE *lpt) partition_info *part_info= lpt->part_info; DDL_LOG_MEMORY_ENTRY *log_entry; DDL_LOG_MEMORY_ENTRY *exec_log_entry= part_info->exec_log_entry; - char path[FN_LEN]; - char shadow_path[FN_LEN]; + char path[FN_REFLEN]; + char shadow_path[FN_REFLEN]; DDL_LOG_MEMORY_ENTRY *old_first_log_entry= part_info->first_log_entry; DBUG_ENTER("write_log_rename_frm"); @@ -5610,8 +5610,8 @@ static bool write_log_drop_partition(ALTER_PARTITION_PARAM_TYPE *lpt) partition_info *part_info= lpt->part_info; DDL_LOG_MEMORY_ENTRY *log_entry; DDL_LOG_MEMORY_ENTRY *exec_log_entry= part_info->exec_log_entry; - char tmp_path[FN_LEN]; - char path[FN_LEN]; + char tmp_path[FN_REFLEN]; + char path[FN_REFLEN]; uint next_entry= 0; DDL_LOG_MEMORY_ENTRY *old_first_log_entry= part_info->first_log_entry; DBUG_ENTER("write_log_drop_partition"); @@ -5669,8 +5669,8 @@ static bool write_log_add_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt) partition_info *part_info= lpt->part_info; DDL_LOG_MEMORY_ENTRY *log_entry; DDL_LOG_MEMORY_ENTRY *exec_log_entry= NULL; - char tmp_path[FN_LEN]; - char path[FN_LEN]; + char tmp_path[FN_REFLEN]; + char path[FN_REFLEN]; uint next_entry= 0; DBUG_ENTER("write_log_add_change_partition"); @@ -5723,8 +5723,8 @@ static bool write_log_final_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt) partition_info *part_info= lpt->part_info; DDL_LOG_MEMORY_ENTRY *log_entry; DDL_LOG_MEMORY_ENTRY *exec_log_entry= part_info->exec_log_entry; - char path[FN_LEN]; - char shadow_path[FN_LEN]; + char path[FN_REFLEN]; + char shadow_path[FN_REFLEN]; DDL_LOG_MEMORY_ENTRY *old_first_log_entry= part_info->first_log_entry; uint next_entry= 0; DBUG_ENTER("write_log_final_change_partition"); diff --git a/win/configure.js b/win/configure.js index c86ec0cf47c..ac51b15b9f0 100644 --- a/win/configure.js +++ b/win/configure.js @@ -48,6 +48,7 @@ try case "__NT__": case "CYBOZU": case "EMBED_MANIFESTS": + case "EXTRA_DEBUG": case "WITH_EMBEDDED_SERVER": configfile.WriteLine("SET (" + args.Item(i) + " TRUE)"); break; From af2e74f8cbbe23552648a7acae197e5a15048706 Mon Sep 17 00:00:00 2001 From: V Narayanan Date: Tue, 18 Nov 2008 11:31:03 +0530 Subject: [PATCH 003/137] Bug#39616: Missing quotes from .CSV crashes server When a CSV file contained comma separated elements that were not enclosed in quotes, it was causing the mysql server to crash. The old algorithm that parsed the content of a row in mysql 5.0 was assuming that the values of the fields in a .CSV file will be enclosed in quotes and will be separated by commas. This was causing the old algorithm to fail when the content of the file resembled the following 3,"sans quotes" The CSV engine that is part of mysql 5.0 was expecting the above to be "3","sans quotes" The above is just one example of where the engine was failing for what would be recognized as a valid .CSV file content otherwise. The proposed fix changes the old algorithm being used to parse rows from the .CSV file to handle two separate cases 1) When the current field of the row is enclosed in quotes 2) When the current field of the row is not enclosed in quotes --- mysql-test/r/csv.result | 15 ++++++ mysql-test/t/csv.test | 43 +++++++++++++++++ sql/examples/ha_tina.cc | 103 +++++++++++++++++++++++++++++++--------- 3 files changed, 139 insertions(+), 22 deletions(-) diff --git a/mysql-test/r/csv.result b/mysql-test/r/csv.result index dca4e349c8a..ac1aee6cc9a 100644 --- a/mysql-test/r/csv.result +++ b/mysql-test/r/csv.result @@ -5071,4 +5071,19 @@ select * from t1; a foo drop table t1; +create table bug39616_1(id int NOT NULL, d varchar(50) NOT NULL) ENGINE=csv; +select * from bug39616_1; +id d +1 integer sans quotes +1 string sans quotes +1 string end quotes" +1 quotes"in between" strings +1 Integer with quote and string with no quote +1 escape sequence + " \ \a within quotes +drop table bug39616_1; +create table bug39616_1(id int NOT NULL, d varchar(50) NOT NULL) ENGINE=csv; +select * from bug39616_1; +id d +drop table bug39616_1; End of 5.0 tests diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test index db5cb92c3e6..72d61fc7781 100644 --- a/mysql-test/t/csv.test +++ b/mysql-test/t/csv.test @@ -1460,4 +1460,47 @@ insert into t1 values(); select * from t1; drop table t1; +# +# Bug #39616 Missing quotes from .CSV crashes server +# +# Editing the .CSV file and leaving out quotes from around an integer field +# crashes the server. +# + +# +# Test for the integers and strings enclosed in quotes, not enclosed in quotes, +# \X characters. +# +create table bug39616_1(id int NOT NULL, d varchar(50) NOT NULL) ENGINE=csv; + +--remove_file $MYSQLTEST_VARDIR/master-data/test/bug39616_1.CSV +--write_file $MYSQLTEST_VARDIR/master-data/test/bug39616_1.CSV +1,"integer sans quotes" +1,string sans quotes +1,string end quotes" +1,quotes"in between" strings +"1",Integer with quote and string with no quote +1,"escape sequence \n \" \\ \r \a within quotes" +EOF + +select * from bug39616_1; + +drop table bug39616_1; + +# +# Test for he case when a field begins with a quote, but does not end in a +# quote. +# Note: This results in an empty set. +# +create table bug39616_1(id int NOT NULL, d varchar(50) NOT NULL) ENGINE=csv; + +--remove_file $MYSQLTEST_VARDIR/master-data/test/bug39616_1.CSV +--write_file $MYSQLTEST_VARDIR/master-data/test/bug39616_1.CSV +1,"string only at the beginning quotes +EOF + +select * from bug39616_1; + +drop table bug39616_1; + --echo End of 5.0 tests diff --git a/sql/examples/ha_tina.cc b/sql/examples/ha_tina.cc index 0b57fe86e62..aaaa3b8ffb4 100644 --- a/sql/examples/ha_tina.cc +++ b/sql/examples/ha_tina.cc @@ -416,37 +416,96 @@ int ha_tina::find_current_row(byte *buf) if ((end_ptr= find_eoln(share->mapped_file, current_position, share->file_stat.st_size)) == 0) DBUG_RETURN(HA_ERR_END_OF_FILE); + /* + Parse the line obtained using the following algorithm + + BEGIN + 1) Store the EOL (end of line) for the current row + 2) Until all the fields in the current query have not been + filled + 2.1) If the current character begins with a quote + 2.1.1) Until EOL has not been reached + a) If end of current field is reached, move + to next field and jump to step 2.3 + b) If current character begins with \\ handle + \\n, \\r, \\, \\" + c) else append the current character into the buffer + before checking that EOL has not been reached. + 2.2) If the current character does not begin with a quote + 2.2.1) Until EOL has not been reached + a) If the end of field has been reached move to the + next field and jump to step 2.3 + b) append the current character into the buffer + 2.3) Store the current field value and jump to 2) + TERMINATE + */ + for (Field **field=table->field ; *field ; field++) { buffer.length(0); - mapped_ptr++; // Increment past the first quote - for(;mapped_ptr != end_ptr; mapped_ptr++) + /* Handle the case where the first character begins with a quote */ + if (*mapped_ptr == '"') { - //Need to convert line feeds! - if (*mapped_ptr == '"' && - (((mapped_ptr[1] == ',') && (mapped_ptr[2] == '"')) || (mapped_ptr == end_ptr -1 ))) + /* Increment past the first quote */ + mapped_ptr++; + /* Loop through the row to extract the values for the current field */ + for(; mapped_ptr != end_ptr; mapped_ptr++) { - mapped_ptr += 2; // Move past the , and the " - break; - } - if (*mapped_ptr == '\\' && mapped_ptr != (end_ptr - 1)) - { - mapped_ptr++; - if (*mapped_ptr == 'r') - buffer.append('\r'); - else if (*mapped_ptr == 'n' ) - buffer.append('\n'); - else if ((*mapped_ptr == '\\') || (*mapped_ptr == '"')) - buffer.append(*mapped_ptr); - else /* This could only happed with an externally created file */ + /* check for end of the current field */ + if (*mapped_ptr == '"' && + (mapped_ptr[1] == ',' || mapped_ptr == end_ptr -1 )) { - buffer.append('\\'); + /* Move past the , and the " */ + mapped_ptr += 2; + break; + } + if (*mapped_ptr == '\\' && mapped_ptr != (end_ptr - 1)) + { + mapped_ptr++; + if (*mapped_ptr == 'r') + buffer.append('\r'); + else if (*mapped_ptr == 'n' ) + buffer.append('\n'); + else if ((*mapped_ptr == '\\') || (*mapped_ptr == '"')) + buffer.append(*mapped_ptr); + else /* This could only happed with an externally created file */ + { + buffer.append('\\'); + buffer.append(*mapped_ptr); + } + } + else + { + /* + If no last quote was found, but the end of row has been reached + it implies that there has been error. + */ + if (mapped_ptr == end_ptr -1) + DBUG_RETURN(HA_ERR_END_OF_FILE); + /* Store current character in the buffer for the field */ buffer.append(*mapped_ptr); } - } - else - buffer.append(*mapped_ptr); + } } + else + { + /* Handle the case where the current row does not start with quotes */ + + /* Loop through the row to extract the values for the current field */ + for (; mapped_ptr != end_ptr; mapped_ptr++) + { + /* check for end of current field */ + if (*mapped_ptr == ',') + { + /* Increment past the current comma */ + mapped_ptr++; + break; + } + /* store the current character in the buffer for the field */ + buffer.append(*mapped_ptr); + } + } + /* Store the field value from the buffer */ (*field)->store(buffer.ptr(), buffer.length(), buffer.charset()); } next_position= (end_ptr - share->mapped_file)+1; From d1e5808d7ed09b23a9b3b1720e43541efb66a08c Mon Sep 17 00:00:00 2001 From: "Tatiana A. Nurnberg" Date: Thu, 20 Nov 2008 15:39:39 +0100 Subject: [PATCH 004/137] Bug#39591: Crash if table comment is longer than 62 characters It was possible to crash a mysqld build with EXTRA_DEBUG using CREATE TABLE ... COMMENT with a specially-crafted UTF-8 string. This CS removes the check that caused it since it no longer applies in current servers anyway, and adds comments instead to avoid future confusion. --- mysql-test/r/strict.result | 7 +++++++ mysql-test/t/strict.test | 9 +++++++++ sql/unireg.cc | 26 ++++++++++++++++++-------- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result index 34869862a63..c31b5ea2189 100644 --- a/mysql-test/r/strict.result +++ b/mysql-test/r/strict.result @@ -1348,6 +1348,13 @@ t1 CREATE TABLE `t1` ( `i` int(11) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='123456789*123456789*123456789*123456789*123456789*123456789*' drop table t1; +CREATE TABLE t3 (f1 INT) COMMENT 'כקבהחןכקבהחןכקבהחןכקבהחןכקבהחןכקבהחןכקבהחןכקבהחןכקבהחןכקבהחן'; +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `f1` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='כקבהחןכקבהחןכקבהחןכקבהחןכקבהחןכקבהחןכקבהחןכקבהחןכקבהחןכקבהחן' +DROP TABLE t3; set sql_mode= 'traditional'; create table t1(col1 tinyint, col2 tinyint unsigned, col3 smallint, col4 smallint unsigned, diff --git a/mysql-test/t/strict.test b/mysql-test/t/strict.test index 2b71bf1093c..f66c2913ac9 100644 --- a/mysql-test/t/strict.test +++ b/mysql-test/t/strict.test @@ -1199,6 +1199,15 @@ comment '123456789*123456789*123456789*123456789*123456789*123456789*'; show create table t1; drop table t1; +# +# Bug #39591: Crash if table comment is longer than 62 characters +# + +#60 chars, 120 (+1) bytes (UTF-8 with 2-byte chars) +CREATE TABLE t3 (f1 INT) COMMENT 'כקבהחןכקבהחןכקבהחןכקבהחןכקבהחןכקבהחןכקבהחןכקבהחןכקבהחןכקבהחן'; +SHOW CREATE TABLE t3; +DROP TABLE t3; + # # Bug #26359: Strings becoming truncated and converted to numbers under STRICT mode # diff --git a/sql/unireg.cc b/sql/unireg.cc index b581ad4655a..f20d3e8cc6b 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -143,6 +143,24 @@ bool mysql_create_frm(THD *thd, my_string file_name, (create_info->min_rows == 1) && (keys == 0)); int2store(fileinfo+28,key_info_length); + /* + This gives us the byte-position of the character at + (character-position, not byte-position) TABLE_COMMENT_MAXLEN. + The trick here is that character-positions start at 0, so the last + character in a maximum-allowed length string would be at char-pos + MAXLEN-1; charpos MAXLEN will be the position of the terminator. + Consequently, bytepos(charpos(MAXLEN)) should be equal to + comment[length] (which should also be the terminator, or at least + the first byte after the payload in the strict sense). If this is + not so (bytepos(charpos(MAXLEN)) comes /before/ the end of the + string), the string is too long. + + For additional credit, realise that UTF-8 has 1-3 bytes before 6.0, + and 1-4 bytes in 6.0 (6.0 also has UTF-32). This means that the + inlined COMMENT supposedly does not exceed 60 character plus + terminator, vulgo, 181 bytes. + */ + tmp_len= system_charset_info->cset->charpos(system_charset_info, create_info->comment.str, create_info->comment.str + @@ -165,14 +183,6 @@ bool mysql_create_frm(THD *thd, my_string file_name, strmake((char*) forminfo+47, create_info->comment.str ? create_info->comment.str : "", create_info->comment.length); forminfo[46]=(uchar) create_info->comment.length; -#ifdef EXTRA_DEBUG - /* - EXTRA_DEBUG causes strmake() to initialize its buffer behind the - payload with a magic value to detect wrong buffer-sizes. We - explicitly zero that segment again. - */ - memset((char*) forminfo+47 + forminfo[46], 0, 61 - forminfo[46]); -#endif if (my_pwrite(file,(byte*) fileinfo,64,0L,MYF_RW) || my_pwrite(file,(byte*) keybuff,key_info_length, (ulong) uint2korr(fileinfo+6),MYF_RW)) From 85d4cbae24d0a6d86911a1845d0c3fe24f48c36e Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Fri, 28 Nov 2008 18:17:13 +0400 Subject: [PATCH 005/137] BUG#37245 - Full text search problem Certain boolean mode queries with truncation operator did not return matching records and calculate relevancy incorrectly. --- myisam/ft_boolean_search.c | 38 ++++++++++++++++++++++++++++++------ mysql-test/r/fulltext.result | 9 +++++++++ mysql-test/t/fulltext.test | 9 +++++++++ 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c index 57de75ee4be..255c51fd33a 100644 --- a/myisam/ft_boolean_search.c +++ b/myisam/ft_boolean_search.c @@ -122,11 +122,11 @@ static int FTB_WORD_cmp(my_off_t *v, FTB_WORD *a, FTB_WORD *b) static int FTB_WORD_cmp_list(CHARSET_INFO *cs, FTB_WORD **a, FTB_WORD **b) { - /* ORDER BY word DESC, ndepth DESC */ - int i= mi_compare_text(cs, (uchar*) (*b)->word+1,(*b)->len-1, - (uchar*) (*a)->word+1,(*a)->len-1,0,0); + /* ORDER BY word, ndepth */ + int i= mi_compare_text(cs, (uchar*) (*a)->word + 1, (*a)->len - 1, + (uchar*) (*b)->word + 1, (*b)->len - 1, 0, 0); if (!i) - i=CMP_NUM((*b)->ndepth,(*a)->ndepth); + i= CMP_NUM((*a)->ndepth, (*b)->ndepth); return i; } @@ -674,23 +674,49 @@ float ft_boolean_find_relevance(FT_INFO *ftb, byte *record, uint length) (byte *) end, &word, TRUE)) { int a, b, c; + /* + Find right-most element in the array of query words matching this + word from a document. + */ for (a=0, b=ftb->queue.elements, c=(a+b)/2; b-a>1; c=(a+b)/2) { ftbw=ftb->list[c]; if (mi_compare_text(ftb->charset, (uchar*) word.pos, word.len, (uchar*) ftbw->word+1, ftbw->len-1, - (my_bool) (ftbw->flags&FTB_FLAG_TRUNC),0) >0) + (my_bool) (ftbw->flags & FTB_FLAG_TRUNC), 0) < 0) b=c; else a=c; } + /* + If there were no words with truncation operator, we iterate to the + beginning of an array until array element is equal to the word from + a document. This is done mainly because the same word may be + mentioned twice (or more) in the query. + + In case query has words with truncation operator we must iterate + to the beginning of the array. There may be non-matching query words + between matching word with truncation operator and the right-most + matching element. E.g., if we're looking for 'aaa15' in an array of + 'aaa1* aaa14 aaa15 aaa16'. + + Worse of that there still may be match even if the binary search + above didn't find matching element. E.g., if we're looking for + 'aaa15' in an array of 'aaa1* aaa14 aaa16'. The binary search will + stop at 'aaa16'. + */ for (; c>=0; c--) { ftbw=ftb->list[c]; if (mi_compare_text(ftb->charset, (uchar*) word.pos, word.len, (uchar*) ftbw->word+1,ftbw->len-1, (my_bool) (ftbw->flags&FTB_FLAG_TRUNC),0)) - break; + { + if (ftb->with_scan & FTB_FLAG_TRUNC) + continue; + else + break; + } if (ftbw->docid[1] == docid) continue; ftbw->docid[1]=docid; diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index e73f8af405c..6821691c9d0 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -497,3 +497,12 @@ WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref b b 5 const 4 Using where DROP TABLE t1; +CREATE TABLE t1(a CHAR(10)); +INSERT INTO t1 VALUES('aaa15'); +SELECT MATCH(a) AGAINST('aaa1* aaa14 aaa16' IN BOOLEAN MODE) FROM t1; +MATCH(a) AGAINST('aaa1* aaa14 aaa16' IN BOOLEAN MODE) +1 +SELECT MATCH(a) AGAINST('aaa1* aaa14 aaa15 aaa16' IN BOOLEAN MODE) FROM t1; +MATCH(a) AGAINST('aaa1* aaa14 aaa15 aaa16' IN BOOLEAN MODE) +2 +DROP TABLE t1; diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index fa087d89efb..77d84c730d9 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -423,3 +423,12 @@ EXPLAIN SELECT * FROM t1 FORCE INDEX(b) WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1; DROP TABLE t1; + +# +# BUG#37245 - Full text search problem +# +CREATE TABLE t1(a CHAR(10)); +INSERT INTO t1 VALUES('aaa15'); +SELECT MATCH(a) AGAINST('aaa1* aaa14 aaa16' IN BOOLEAN MODE) FROM t1; +SELECT MATCH(a) AGAINST('aaa1* aaa14 aaa15 aaa16' IN BOOLEAN MODE) FROM t1; +DROP TABLE t1; From 674f88380ce50bcbbdbfbc47d39208385534aeb8 Mon Sep 17 00:00:00 2001 From: Matthias Leich Date: Fri, 28 Nov 2008 16:45:34 +0100 Subject: [PATCH 006/137] - Fix for Bug#40179 Test main.query_cache failing randomly on Pushbuild, test weakness - disable the test suffering from Bug#41098 Query Cache returns wrong result with concurrent insert - additional improvements Details: - Move the test for the historic bug Bug 28249 Query Cache returns wrong result with concurrent insert / certain lock into its own testscript query_cache_28249.test. - query_cache.test: - replace error numbers with error names - remove trailing spaces, replace tabs with spaces - reset of @@global.log_bin_trust_function_creators to its original value at the end of the test - query_cache_28249.test: - replace sleep 5 with poll routine - avoid random differences caused by concurrent_inserts effects - improved comments and formatting --- mysql-test/r/query_cache.result | 38 +------- mysql-test/r/query_cache_28249.result | 62 +++++++++++++ mysql-test/t/disabled.def | 1 + mysql-test/t/query_cache.test | 102 ++++----------------- mysql-test/t/query_cache_28249.test | 124 ++++++++++++++++++++++++++ 5 files changed, 206 insertions(+), 121 deletions(-) create mode 100644 mysql-test/r/query_cache_28249.result create mode 100644 mysql-test/t/query_cache_28249.test diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index 34c86d6c8c6..3c8ff8faddc 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -1116,12 +1116,13 @@ create procedure `p1`() begin select a, f1() from t1; end// +SET @log_bin_trust_function_creators = @@global.log_bin_trust_function_creators; SET GLOBAL log_bin_trust_function_creators = 1; call p1()// a f1() 1 2 2 2 -SET GLOBAL log_bin_trust_function_creators = 0; +SET GLOBAL log_bin_trust_function_creators = @log_bin_trust_function_creators; drop procedure p1// drop function f1// drop table t1// @@ -1615,41 +1616,6 @@ id DROP PROCEDURE proc29856; DROP TABLE t1; SET GLOBAL query_cache_size= default; -Bug#28249 Query Cache returns wrong result with concurrent insert/ certain lock -set GLOBAL query_cache_type=1; -set GLOBAL query_cache_limit=10000; -set GLOBAL query_cache_min_res_unit=0; -set GLOBAL query_cache_size= 100000; -flush tables; -drop table if exists t1, t2; -create table t1 (a int); -create table t2 (a int); -insert into t1 values (1),(2),(3); -Locking table T2 with a write lock. -lock table t2 write; -Select blocked by write lock. -select *, (select count(*) from t2) from t1;; -Sleeing is ok, because selecting should be done very fast. -Inserting into table T1. -insert into t1 values (4); -Unlocking the tables. -unlock tables; -Collecting result from previously blocked select. -Next select should contain 4 rows, as the insert is long finished. -select *, (select count(*) from t2) from t1; -a (select count(*) from t2) -1 0 -2 0 -3 0 -4 0 -reset query cache; -select *, (select count(*) from t2) from t1; -a (select count(*) from t2) -1 0 -2 0 -3 0 -4 0 -drop table t1,t2; # # Bug#25132 disabled query cache: Qcache_free_blocks = 1 # diff --git a/mysql-test/r/query_cache_28249.result b/mysql-test/r/query_cache_28249.result new file mode 100644 index 00000000000..aed84911032 --- /dev/null +++ b/mysql-test/r/query_cache_28249.result @@ -0,0 +1,62 @@ +SET @query_cache_type= @@global.query_cache_type; +SET @query_cache_limit= @@global.query_cache_limit; +SET @query_cache_min_res_unit= @@global.query_cache_min_res_unit; +SET @query_cache_size= @@global.query_cache_size; +# Bug#28249 Query Cache returns wrong result with concurrent insert/ certain lock +# Establish connections user1,user2,user3 (user=root) +# Switch to connection user1 +SET GLOBAL query_cache_type=1; +SET GLOBAL query_cache_limit=10000; +SET GLOBAL query_cache_min_res_unit=0; +SET GLOBAL query_cache_size= 100000; +FLUSH TABLES; +DROP TABLE IF EXISTS t1, t2; +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +INSERT INTO t1 VALUES (1),(2),(3); +# Switch to connection user2 +LOCK TABLE t2 WRITE; +# Switch to connection user1 +# "send" the next select, "reap" the result later. +# The select will be blocked by the write lock on the t1. +SELECT *, (SELECT COUNT(*) FROM t2) FROM t1; +# Switch to connection user3 +# Poll till the select of connection user1 is blocked by the write lock on t1. +SELECT user,command,state,info FROM information_schema.processlist +WHERE state = 'Locked' + AND info = 'SELECT *, (SELECT COUNT(*) FROM t2) FROM t1'; +user command state info +root Query Locked SELECT *, (SELECT COUNT(*) FROM t2) FROM t1 +INSERT INTO t1 VALUES (4); +# Switch to connection user2 +UNLOCK TABLES; +# Switch to connection user1 +# Collecting ("reap") the result from the previously blocked select. +# The printing of the result (varies between 3 and 4 rows) set has to be suppressed. +# Switch to connection user3 +# The next select enforces that effects of "concurrent_inserts" like the +# record with a = 4 is missing in result sets can no more happen. +SELECT 1 FROM t1 WHERE a = 4; +1 +1 +# Switch to connection user1 +# The next result set must contain 4 rows. +SELECT *, (SELECT COUNT(*) FROM t2) FROM t1; +a (SELECT COUNT(*) FROM t2) +1 0 +2 0 +3 0 +4 0 +RESET QUERY CACHE; +SELECT *, (SELECT COUNT(*) FROM t2) FROM t1; +a (SELECT COUNT(*) FROM t2) +1 0 +2 0 +3 0 +4 0 +DROP TABLE t1,t2; +# Switch to connection default + close connections user1,user2,user3 +SET GLOBAL query_cache_type= @query_cache_type; +SET GLOBAL query_cache_limit= @query_cache_limit; +SET GLOBAL query_cache_min_res_unit= @query_cache_min_res_unit; +SET GLOBAL query_cache_size= @query_cache_size; diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index c01bb4b9e44..748c80548d9 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -12,3 +12,4 @@ federated_transactions : Bug#29523 Transactions do not work log_tables.test : Bug #37798: main.log_tables fails randomly on powermacg5 and windows slow_query_log_func.test : Bug #37962: *_func tests containing sleeps/race conditions +query_cache_28249 : Bug#41098 Query Cache returns wrong result with concurrent insert diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test index 88287e53b34..296914c985b 100644 --- a/mysql-test/t/query_cache.test +++ b/mysql-test/t/query_cache.test @@ -300,7 +300,7 @@ select * from t1; select * from t1; show status like "Qcache_queries_in_cache"; insert delayed into t1 values (4); ---sleep 5 # Wait for insert delayed to be executed. +--sleep 5 # Wait for insert delayed to be executed. select a from t1; show status like "Qcache_queries_in_cache"; drop table t1; @@ -410,10 +410,10 @@ create table t1(id int auto_increment primary key); insert into t1 values (NULL), (NULL), (NULL); select * from t1 where id=2; alter table t1 rename to t2; --- error 1146 +--error ER_NO_SUCH_TABLE select * from t1 where id=2; drop table t2; --- error 1146 +--error ER_NO_SUCH_TABLE select * from t1 where id=2; # @@ -435,7 +435,7 @@ create table t1 (a int); insert into t1 values (1),(2),(3); show status like "Qcache_queries_in_cache"; select * from t1 into outfile "query_cache.out.file"; ---error 1086 +--error ER_FILE_EXISTS_ERROR select * from t1 into outfile "query_cache.out.file"; select * from t1 limit 1 into dumpfile "query_cache.dump.file"; show status like "Qcache_queries_in_cache"; @@ -537,7 +537,7 @@ drop table t1; # If at least one of the above variables has changed, # the cached query can't be reused. In the below test # absolutely the same query is used several times, -# SELECT should fetch different results for every instance. +# SELECT should fetch different results for every instance. # No hits should be produced. # New cache entry should appear for every SELECT. # @@ -554,21 +554,21 @@ show status like "Qcache_queries_in_cache"; # Change collation_connection and run the same query again # set collation_connection=koi8r_bin; -SELECT a,'',''='' FROM t1; +SELECT a,'',''='' FROM t1; show status like "Qcache_hits"; show status like "Qcache_queries_in_cache"; # # Now change character_set_client and run the same query again # set character_set_client=cp1251; -SELECT a,'',''='' FROM t1; +SELECT a,'',''='' FROM t1; show status like "Qcache_hits"; show status like "Qcache_queries_in_cache"; # # And finally change character_set_results and run the same query again # set character_set_results=cp1251; -SELECT a,'',''='' FROM t1; +SELECT a,'',''='' FROM t1; show status like "Qcache_hits"; show status like "Qcache_queries_in_cache"; SET NAMES default; @@ -602,12 +602,12 @@ insert into t1 set c = repeat('x',24); insert into t1 set c = concat(repeat('x',24),'x'); insert into t1 set c = concat(repeat('x',24),'w'); insert into t1 set c = concat(repeat('x',24),'y'); -set max_sort_length=200; +set max_sort_length=200; select c from t1 order by c, id; reset query cache; set max_sort_length=20; select c from t1 order by c, id; -set max_sort_length=200; +set max_sort_length=200; select c from t1 order by c, id; set max_sort_length=default; # sql_mode @@ -801,9 +801,10 @@ create procedure `p1`() begin select a, f1() from t1; end// +SET @log_bin_trust_function_creators = @@global.log_bin_trust_function_creators; SET GLOBAL log_bin_trust_function_creators = 1; call p1()// -SET GLOBAL log_bin_trust_function_creators = 0; +SET GLOBAL log_bin_trust_function_creators = @log_bin_trust_function_creators; drop procedure p1// drop function f1// @@ -1016,7 +1017,7 @@ set GLOBAL query_cache_size= default; # -# Bug #28897 UUID() returns non-unique values when query cache is enabled +# Bug#28897 UUID() returns non-unique values when query cache is enabled # set GLOBAL query_cache_size=1000000; @@ -1025,7 +1026,7 @@ create table t1 (a char); insert into t1 values ('c'); let $q1= `select UUID(), a from t1`; -let $q2= `select UUID(), a from t1`; +let $q2= `select UUID(), a from t1`; # disabling the logging of the query because the UUIDs are different each run. --disable_query_log @@ -1046,7 +1047,7 @@ create table t1 (a char); insert into t1 values ('c'); let $q1= `select RAND() from t1 union select sql_cache 1 from t1;`; -let $q2= `select RAND() from t1 union select sql_cache 1 from t1;`; +let $q2= `select RAND() from t1 union select sql_cache 1 from t1;`; # disabling the logging of the query because the times are different each run. --disable_query_log @@ -1181,75 +1182,6 @@ DROP PROCEDURE proc29856; DROP TABLE t1; SET GLOBAL query_cache_size= default; -# -# Bug #28249 Query Cache returns wrong result with concurrent insert / certain lock -# ---echo Bug#28249 Query Cache returns wrong result with concurrent insert/ certain lock -connect (user1,localhost,root,,test,,); -connect (user2,localhost,root,,test,,); -connect (user3,localhost,root,,test,,); - -connection user1; - -set GLOBAL query_cache_type=1; -set GLOBAL query_cache_limit=10000; -set GLOBAL query_cache_min_res_unit=0; -set GLOBAL query_cache_size= 100000; - -flush tables; ---disable_warnings -drop table if exists t1, t2; ---enable_warnings -create table t1 (a int); -create table t2 (a int); -insert into t1 values (1),(2),(3); -connection user2; ---echo Locking table T2 with a write lock. -lock table t2 write; - -connection user1; ---echo Select blocked by write lock. ---send select *, (select count(*) from t2) from t1; ---echo Sleeing is ok, because selecting should be done very fast. -sleep 5; - -connection user3; ---echo Inserting into table T1. -insert into t1 values (4); - -connection user2; ---echo Unlocking the tables. -unlock tables; - -connection user1; ---echo Collecting result from previously blocked select. -# -# Since the lock ordering rule in thr_multi_lock depends on -# pointer values, from execution to execution we might have -# different lock order, and therefore, sometimes lock t1 and block -# on t2, and sometimes block on t2 right away. In the second case, -# the following insert succeeds, and only then this select can -# proceed, and we actually test nothing, as the very first select -# returns 4 rows right away. -# It's fine to have a test case that covers the problematic area -# at least once in a while. -# We, however, need to disable the result log here to make the -# test repeatable. ---disable_result_log ---reap ---enable_result_log ---echo Next select should contain 4 rows, as the insert is long finished. -select *, (select count(*) from t2) from t1; -reset query cache; -select *, (select count(*) from t2) from t1; - -drop table t1,t2; - -connection default; -disconnect user1; -disconnect user2; -disconnect user3; - # --echo # --echo # Bug#25132 disabled query cache: Qcache_free_blocks = 1 @@ -1260,7 +1192,7 @@ set global query_cache_type=0; show status like 'Qcache_free_blocks'; --echo Restore default values. -# Bug #28211 RENAME DATABASE and query cache don't play nicely together +# Bug#28211 RENAME DATABASE and query cache don't play nicely together # # TODO: enable these tests when RENAME DATABASE is implemented. # --disable_warnings @@ -1278,7 +1210,7 @@ show status like 'Qcache_free_blocks'; # show status like 'Qcache_queries_in_cache'; # drop database db2; # set global query_cache_size=default; -# +# # --disable_warnings # drop database if exists db1; # drop database if exists db3; diff --git a/mysql-test/t/query_cache_28249.test b/mysql-test/t/query_cache_28249.test new file mode 100644 index 00000000000..021c13cb54a --- /dev/null +++ b/mysql-test/t/query_cache_28249.test @@ -0,0 +1,124 @@ +### t/query_cache_28249.test ### +# +# Test for +# Bug #28249 Query Cache returns wrong result with concurrent insert / certain lock +# +# Last modification: +# 2008-11-27 mleich - Move this test out of query_cache.test +# - Fix Bug#40179 Test main.query_cache failing randomly on Pushbuild, +# test weakness +# - Minor improvements (comments,formatting etc.) +# + +--source include/have_query_cache.inc + +SET @query_cache_type= @@global.query_cache_type; +SET @query_cache_limit= @@global.query_cache_limit; +SET @query_cache_min_res_unit= @@global.query_cache_min_res_unit; +SET @query_cache_size= @@global.query_cache_size; + +--echo # Bug#28249 Query Cache returns wrong result with concurrent insert/ certain lock +--echo # Establish connections user1,user2,user3 (user=root) +connect (user1,localhost,root,,test,,); +connect (user2,localhost,root,,test,,); +connect (user3,localhost,root,,test,,); + +--echo # Switch to connection user1 +connection user1; + +SET GLOBAL query_cache_type=1; +SET GLOBAL query_cache_limit=10000; +SET GLOBAL query_cache_min_res_unit=0; +SET GLOBAL query_cache_size= 100000; + +FLUSH TABLES; +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +INSERT INTO t1 VALUES (1),(2),(3); + +--echo # Switch to connection user2 +connection user2; +LOCK TABLE t2 WRITE; + +--echo # Switch to connection user1 +connection user1; +--echo # "send" the next select, "reap" the result later. +--echo # The select will be blocked by the write lock on the t1. +let $select_for_qc = +SELECT *, (SELECT COUNT(*) FROM t2) FROM t1; +send; +eval $select_for_qc; + +--echo # Switch to connection user3 +connection user3; +# Typical information_schema.processlist content sufficient sleep time +# ID USER COMMAND TIME STATE INFO +# .... +# 2 root Query 5 Locked SELECT *, (SELECT COUNT(*) FROM t2) FROM t1 +# .... +# XXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +# The values marked with 'X' must be reached. +--echo # Poll till the select of connection user1 is blocked by the write lock on t1. +let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist +WHERE state = 'Locked' + AND info = '$select_for_qc'; +--source include/wait_condition.inc +eval +SELECT user,command,state,info FROM information_schema.processlist +WHERE state = 'Locked' + AND info = '$select_for_qc'; +INSERT INTO t1 VALUES (4); + +--echo # Switch to connection user2 +connection user2; +UNLOCK TABLES; + +--echo # Switch to connection user1 +connection user1; +# +# Since the lock ordering rule in thr_multi_lock depends on +# pointer values, from execution to execution we might have +# different lock order, and therefore, sometimes lock t1 and block +# on t2, and sometimes block on t2 right away. In the second case, +# the following insert succeeds, and only then this select can +# proceed, and we actually test nothing, as the very first select +# returns 4 rows right away. +# It's fine to have a test case that covers the problematic area +# at least once in a while. +--echo # Collecting ("reap") the result from the previously blocked select. +--echo # The printing of the result (varies between 3 and 4 rows) set has to be suppressed. +--disable_result_log +--reap +--enable_result_log + +--echo # Switch to connection user3 +connection user3; +--echo # The next select enforces that effects of "concurrent_inserts" like the +--echo # record with a = 4 is missing in result sets can no more happen. +SELECT 1 FROM t1 WHERE a = 4; + +--echo # Switch to connection user1 +connection user1; +--echo # The next result set must contain 4 rows. +# If not, we have a regression of Bug#28249 +eval $select_for_qc; +RESET QUERY CACHE; +eval $select_for_qc; + +DROP TABLE t1,t2; + +--echo # Switch to connection default + close connections user1,user2,user3 +connection default; +disconnect user1; +disconnect user2; +disconnect user3; + +SET GLOBAL query_cache_type= @query_cache_type; +SET GLOBAL query_cache_limit= @query_cache_limit; +SET GLOBAL query_cache_min_res_unit= @query_cache_min_res_unit; +SET GLOBAL query_cache_size= @query_cache_size; + + From f486bfbbdb8eeaca11428c7822472150f11185cc Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Sat, 29 Nov 2008 15:36:17 +0200 Subject: [PATCH 007/137] Bug #37742: HA_EXTRA_KEYREAD flag is set when key contains only prefix of requested column When the storage engine uses secondary keys clustered with the primary key MySQL was adding the primary key parts to each secondary key. In doing so it was not checking whether the index was on full columns and this resulted in the secondary keys being added to the list of covering keys even if they have partial columns. Fixed by not adding a primary key part to the list of columns that can be used for index read of the secondary keys when the primary key part is a partial key part. --- mysql-test/r/innodb_mysql.result | 84 ++++++++++++++++++++++++++++++++ mysql-test/t/innodb_mysql.test | 36 ++++++++++++++ sql/table.cc | 4 +- 3 files changed, 123 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index 2c14b1f2385..a348c63ec81 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -1677,3 +1677,87 @@ select @@session.sql_log_bin, @@session.binlog_format, @@session.tx_isolation; CREATE TABLE t1 ( a INT ) ENGINE=InnoDB; INSERT INTO t1 VALUES(1); DROP TABLE t1; +CREATE TABLE foo (a int, b int, c char(10), +PRIMARY KEY (c(3)), +KEY b (b) +) engine=innodb; +CREATE TABLE foo2 (a int, b int, c char(10), +PRIMARY KEY (c), +KEY b (b) +) engine=innodb; +CREATE TABLE bar (a int, b int, c char(10), +PRIMARY KEY (c(3)), +KEY b (b) +) engine=myisam; +INSERT INTO foo VALUES +(1,2,'abcdefghij'), (2,3,''), (3,4,'klmnopqrst'), +(4,5,'uvwxyz'), (5,6,'meotnsyglt'), (4,5,'asfdewe'); +INSERT INTO bar SELECT * FROM foo; +INSERT INTO foo2 SELECT * FROM foo; +EXPLAIN SELECT c FROM bar WHERE b>2;; +id 1 +select_type SIMPLE +table bar +type ALL +possible_keys b +key NULL +key_len NULL +ref NULL +rows 6 +Extra Using where +EXPLAIN SELECT c FROM foo WHERE b>2;; +id 1 +select_type SIMPLE +table foo +type ALL +possible_keys b +key NULL +key_len NULL +ref NULL +rows 6 +Extra Using where +EXPLAIN SELECT c FROM foo2 WHERE b>2;; +id 1 +select_type SIMPLE +table foo2 +type range +possible_keys b +key b +key_len 5 +ref NULL +rows 3 +Extra Using where; Using index +EXPLAIN SELECT c FROM bar WHERE c>2;; +id 1 +select_type SIMPLE +table bar +type ALL +possible_keys PRIMARY +key NULL +key_len NULL +ref NULL +rows 6 +Extra Using where +EXPLAIN SELECT c FROM foo WHERE c>2;; +id 1 +select_type SIMPLE +table foo +type ALL +possible_keys PRIMARY +key NULL +key_len NULL +ref NULL +rows 6 +Extra Using where +EXPLAIN SELECT c FROM foo2 WHERE c>2;; +id 1 +select_type SIMPLE +table foo2 +type index +possible_keys PRIMARY +key b +key_len 5 +ref NULL +rows 6 +Extra Using where; Using index +DROP TABLE foo, bar, foo2; diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test index ed8de208474..06ebb079a1b 100644 --- a/mysql-test/t/innodb_mysql.test +++ b/mysql-test/t/innodb_mysql.test @@ -43,3 +43,39 @@ CREATE TABLE t1 ( a INT ) ENGINE=InnoDB; INSERT INTO t1 VALUES(1); DROP TABLE t1; +# +# Bug #37742: HA_EXTRA_KEYREAD flag is set when key contains only prefix of +# requested column +# + +CREATE TABLE foo (a int, b int, c char(10), + PRIMARY KEY (c(3)), + KEY b (b) +) engine=innodb; + +CREATE TABLE foo2 (a int, b int, c char(10), + PRIMARY KEY (c), + KEY b (b) +) engine=innodb; + +CREATE TABLE bar (a int, b int, c char(10), + PRIMARY KEY (c(3)), + KEY b (b) +) engine=myisam; + +INSERT INTO foo VALUES + (1,2,'abcdefghij'), (2,3,''), (3,4,'klmnopqrst'), + (4,5,'uvwxyz'), (5,6,'meotnsyglt'), (4,5,'asfdewe'); + +INSERT INTO bar SELECT * FROM foo; +INSERT INTO foo2 SELECT * FROM foo; + +--query_vertical EXPLAIN SELECT c FROM bar WHERE b>2; +--query_vertical EXPLAIN SELECT c FROM foo WHERE b>2; +--query_vertical EXPLAIN SELECT c FROM foo2 WHERE b>2; + +--query_vertical EXPLAIN SELECT c FROM bar WHERE c>2; +--query_vertical EXPLAIN SELECT c FROM foo WHERE c>2; +--query_vertical EXPLAIN SELECT c FROM foo2 WHERE c>2; + +DROP TABLE foo, bar, foo2; diff --git a/sql/table.cc b/sql/table.cc index 89714e4e47e..1de47a48513 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1416,7 +1416,9 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, */ if (ha_option & HA_PRIMARY_KEY_IN_READ_INDEX) { - field->part_of_key= share->keys_in_use; + if (field->key_length() == key_part->length && + !(field->flags & BLOB_FLAG)) + field->part_of_key= share->keys_in_use; if (field->part_of_sortkey.is_set(key)) field->part_of_sortkey= share->keys_in_use; } From f1b5eadf5b0f16d970daaf0a4cb2f87e603a5de0 Mon Sep 17 00:00:00 2001 From: Horst Hunger Date: Mon, 1 Dec 2008 09:32:07 +0100 Subject: [PATCH 008/137] Fix for Bug#36875: Problem was, that there some warnings has been written containing values, which were determined by the server depending on the os. The solution is to disable warnings in general. The check of the values only have been done for Linux and Windows. Now, the check has been changed to the check of ranges (not more concrete values) being near by the expected (set) values. --- .../sys_vars/inc/sort_buffer_size_basic.inc | 88 ++++++------- .../r/sort_buffer_size_basic_32.result | 121 +++++------------- .../r/sort_buffer_size_basic_64.result | 117 +++++------------ 3 files changed, 110 insertions(+), 216 deletions(-) diff --git a/mysql-test/suite/sys_vars/inc/sort_buffer_size_basic.inc b/mysql-test/suite/sys_vars/inc/sort_buffer_size_basic.inc index 4dbae7c8847..10acf709386 100644 --- a/mysql-test/suite/sys_vars/inc/sort_buffer_size_basic.inc +++ b/mysql-test/suite/sys_vars/inc/sort_buffer_size_basic.inc @@ -17,9 +17,12 @@ # * Valid & Invalid values # # * Scope & Access method # # * Data Integrity # +# Modified: Horst Hunger, 2008-11-28 # +# disabled warnings as they contain the values of this variable, # +# modified the check of the value only checking a range. # # # -# Reference: http://dev.mysql.com/doc/refman/5.1/en/ # -# server-system-variables.html # +# Reference: # +# http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html # # # ############################################################################### @@ -29,7 +32,7 @@ ###################################################################### -# START OF sort_buffer_size TESTS # +# START OF sort_buffer_size TESTS # ###################################################################### @@ -37,65 +40,63 @@ # Save initial value # ############################################################# -# due to difference when running on Windows (bug filed) +# due to differences when running on Windows (bug filed) --source include/not_windows.inc -SET @start_global_value = @@global.sort_buffer_size; -SELECT @start_global_value; -SET @start_session_value = @@session.sort_buffer_size; -SELECT @start_session_value; +--disable_warnings +SET @start_global_value = @@global.sort_buffer_size; +SET @start_session_value = @@session.sort_buffer_size; --echo '#--------------------FN_DYNVARS_151_01-------------------------#' ###################################################################### -# Display the DEFAULT value of sort_buffer_size # +# Display the DEFAULT value of sort_buffer_size # ###################################################################### SET @@global.sort_buffer_size = 1000; SET @@global.sort_buffer_size = DEFAULT; -SELECT @@global.sort_buffer_size= 2097144 OR @@global.sort_buffer_size= 2097116; +SELECT @@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000; SET @@session.sort_buffer_size = 2000; SET @@session.sort_buffer_size = DEFAULT; -SELECT @@session.sort_buffer_size= 2097144 OR @@session.sort_buffer_size= 2097116; +SELECT @@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000; --echo '#--------------------FN_DYNVARS_151_02-------------------------#' ###################################################################### -# Check the DEFAULT value of sort_buffer_size # +# Check the DEFAULT value of sort_buffer_size # ###################################################################### SET @@global.sort_buffer_size = DEFAULT; -SELECT @@global.sort_buffer_size = 2097144 OR @@global.sort_buffer_size= 2097116; +SELECT @@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000; SET @@session.sort_buffer_size = DEFAULT; -SELECT @@session.sort_buffer_size = 2097144 OR @@session.sort_buffer_size= 2097116; +SELECT @@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000; --echo '#--------------------FN_DYNVARS_151_03-------------------------#' ################################################################################ -# Change the value of sort_buffer_size to a valid value for GLOBAL Scope # +# Change the value of sort_buffer_size to a valid value for GLOBAL Scope # ################################################################################ SET @@global.sort_buffer_size = 32776; -SELECT @@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804; +SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; SET @@global.sort_buffer_size = 32777; -SELECT @@global.sort_buffer_size= 32777 OR @@global.sort_buffer_size= 32804; +SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; SET @@global.sort_buffer_size = 4294967295; SELECT @@global.sort_buffer_size; SET @@global.sort_buffer_size = 4294967294; SELECT @@global.sort_buffer_size; ---echo 'Bug# 34877: Invalid Values are showing in variable on assigning valid values.'; --echo '#--------------------FN_DYNVARS_151_04-------------------------#' ################################################################################### -# Change the value of sort_buffer_size to a valid value for SESSION Scope # +# Change the value of sort_buffer_size to a valid value for SESSION Scope # ################################################################################### SET @@session.sort_buffer_size = 32776; -SELECT @@session.sort_buffer_size= 32776 OR @@session.sort_buffer_size= 32804; +SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000; SET @@session.sort_buffer_size = 32777; -SELECT @@session.sort_buffer_size= 32777 OR @@session.sort_buffer_size= 32804; +SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000; SET @@session.sort_buffer_size = 4294967295; SELECT @@session.sort_buffer_size; SET @@session.sort_buffer_size = 4294967294; @@ -104,13 +105,13 @@ SELECT @@session.sort_buffer_size; --echo '#------------------FN_DYNVARS_151_05-----------------------#' ################################################################## -# Change the value of sort_buffer_size to an invalid value # +# Change the value of sort_buffer_size to an invalid value # ################################################################## SET @@global.sort_buffer_size = 32775; -SELECT @@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804; +SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; SET @@global.sort_buffer_size = -1024; -SELECT @@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804; +SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; SET @@global.sort_buffer_size = 4294967296; SELECT @@global.sort_buffer_size; --Error ER_PARSE_ERROR @@ -121,19 +122,16 @@ SET @@global.sort_buffer_size = test; SELECT @@global.sort_buffer_size; SET @@session.sort_buffer_size = 32775; -SELECT @@session.sort_buffer_size= 32776 OR @@session.sort_buffer_size= 32804; +SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000; SET @@session.sort_buffer_size = -2; -SELECT @@session.sort_buffer_size= 32776 OR @@session.sort_buffer_size= 32804; +SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000; --Error ER_PARSE_ERROR SET @@session.sort_buffer_size = 65530.34.; SET @@session.sort_buffer_size = 4294967296; SELECT @@session.sort_buffer_size; ---echo 'Bug # 34837: Errors are not coming on assigning invalid values to variable'; --Error ER_WRONG_TYPE_FOR_VAR SET @@session.sort_buffer_size = test; -SELECT @@session.sort_buffer_size; - --echo '#------------------FN_DYNVARS_151_06-----------------------#' #################################################################### @@ -141,14 +139,16 @@ SELECT @@session.sort_buffer_size; #################################################################### -SELECT @@global.sort_buffer_size = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='sort_buffer_size'; +SELECT @@global.sort_buffer_size = VARIABLE_VALUE FROM + INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='sort_buffer_size'; --echo '#------------------FN_DYNVARS_151_07-----------------------#' #################################################################### # Check if the value in SESSION Table matches value in variable # #################################################################### -SELECT @@session.sort_buffer_size = VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='sort_buffer_size'; +SELECT @@session.sort_buffer_size = VARIABLE_VALUE FROM + INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='sort_buffer_size'; --echo '#------------------FN_DYNVARS_151_08-----------------------#' @@ -157,25 +157,22 @@ SELECT @@session.sort_buffer_size = VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSI #################################################################### SET @@global.sort_buffer_size = TRUE; -SELECT @@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804; +SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; SET @@global.sort_buffer_size = FALSE; -SELECT @@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804; -echo 'Bug: Errors should be displayed on assigning TRUE/FALSE to variable'; - +SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; --echo '#---------------------FN_DYNVARS_151_09----------------------#' #################################################################################### -# Check if accessing variable with and without GLOBAL point to same variable # +# Check if accessing variable with and without GLOBAL point to same variable # #################################################################################### SET @@global.sort_buffer_size = 9000; SELECT @@sort_buffer_size = @@global.sort_buffer_size; - --echo '#---------------------FN_DYNVARS_151_10----------------------#' -######################################################################################################## -# Check if accessing variable with SESSION,LOCAL and without SCOPE points to same session variable # -######################################################################################################## +################################################################################################### +# Check if accessing variable with SESSION,LOCAL and without SCOPE points to same session variable# +################################################################################################### SET @@sort_buffer_size = 9000; SELECT @@sort_buffer_size = @@local.sort_buffer_size; @@ -184,12 +181,11 @@ SELECT @@local.sort_buffer_size = @@session.sort_buffer_size; --echo '#---------------------FN_DYNVARS_151_11----------------------#' ################################################################################### -# Check if sort_buffer_size can be accessed with and without @@ sign # +# Check if sort_buffer_size can be accessed with and without @@ sign # ################################################################################### SET sort_buffer_size = 9100; -SELECT @sort_buffer_size= 32776 OR @@sort_buffer_size= 32804; -SELECT @@sort_buffer_size; +SELECT @@sort_buffer_size >= 32776 AND @@sort_buffer_size < 33000; --Error ER_UNKNOWN_TABLE SELECT local.sort_buffer_size; --Error ER_UNKNOWN_TABLE @@ -203,11 +199,11 @@ SELECT sort_buffer_size = @@session.sort_buffer_size; #################################### SET @@global.sort_buffer_size = @start_global_value; -SELECT @@global.sort_buffer_size; SET @@session.sort_buffer_size = @start_session_value; -SELECT @@session.sort_buffer_size; +--enable_warnings ############################################################# -# END OF sort_buffer_size TESTS # +# END OF sort_buffer_size TESTS # ############################################################# + diff --git a/mysql-test/suite/sys_vars/r/sort_buffer_size_basic_32.result b/mysql-test/suite/sys_vars/r/sort_buffer_size_basic_32.result index 09a1fe59046..353ea9dee8c 100644 --- a/mysql-test/suite/sys_vars/r/sort_buffer_size_basic_32.result +++ b/mysql-test/suite/sys_vars/r/sort_buffer_size_basic_32.result @@ -1,47 +1,33 @@ SET @start_global_value = @@global.sort_buffer_size; -SELECT @start_global_value; -@start_global_value -262144 SET @start_session_value = @@session.sort_buffer_size; -SELECT @start_session_value; -@start_session_value -262144 '#--------------------FN_DYNVARS_151_01-------------------------#' SET @@global.sort_buffer_size = 1000; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '1000' SET @@global.sort_buffer_size = DEFAULT; -SELECT @@global.sort_buffer_size= 2097144 OR @@global.sort_buffer_size= 2097116; -@@global.sort_buffer_size= 2097144 OR @@global.sort_buffer_size= 2097116 +SELECT @@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000; +@@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000 1 SET @@session.sort_buffer_size = 2000; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '2000' SET @@session.sort_buffer_size = DEFAULT; -SELECT @@session.sort_buffer_size= 2097144 OR @@session.sort_buffer_size= 2097116; -@@session.sort_buffer_size= 2097144 OR @@session.sort_buffer_size= 2097116 +SELECT @@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000; +@@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000 1 '#--------------------FN_DYNVARS_151_02-------------------------#' SET @@global.sort_buffer_size = DEFAULT; -SELECT @@global.sort_buffer_size = 2097144 OR @@global.sort_buffer_size= 2097116; -@@global.sort_buffer_size = 2097144 OR @@global.sort_buffer_size= 2097116 +SELECT @@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000; +@@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000 1 SET @@session.sort_buffer_size = DEFAULT; -SELECT @@session.sort_buffer_size = 2097144 OR @@session.sort_buffer_size= 2097116; -@@session.sort_buffer_size = 2097144 OR @@session.sort_buffer_size= 2097116 +SELECT @@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000; +@@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000 1 '#--------------------FN_DYNVARS_151_03-------------------------#' SET @@global.sort_buffer_size = 32776; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '32776' -SELECT @@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804; -@@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804 +SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; +@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000 1 SET @@global.sort_buffer_size = 32777; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '32777' -SELECT @@global.sort_buffer_size= 32777 OR @@global.sort_buffer_size= 32804; -@@global.sort_buffer_size= 32777 OR @@global.sort_buffer_size= 32804 +SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; +@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000 1 SET @@global.sort_buffer_size = 4294967295; SELECT @@global.sort_buffer_size; @@ -51,19 +37,14 @@ SET @@global.sort_buffer_size = 4294967294; SELECT @@global.sort_buffer_size; @@global.sort_buffer_size 4294967294 -'Bug# 34877: Invalid Values are showing in variable on assigning valid values.'; '#--------------------FN_DYNVARS_151_04-------------------------#' SET @@session.sort_buffer_size = 32776; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '32776' -SELECT @@session.sort_buffer_size= 32776 OR @@session.sort_buffer_size= 32804; -@@session.sort_buffer_size= 32776 OR @@session.sort_buffer_size= 32804 +SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000; +@@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000 1 SET @@session.sort_buffer_size = 32777; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '32777' -SELECT @@session.sort_buffer_size= 32777 OR @@session.sort_buffer_size= 32804; -@@session.sort_buffer_size= 32777 OR @@session.sort_buffer_size= 32804 +SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000; +@@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000 1 SET @@session.sort_buffer_size = 4294967295; SELECT @@session.sort_buffer_size; @@ -75,20 +56,14 @@ SELECT @@session.sort_buffer_size; 4294967294 '#------------------FN_DYNVARS_151_05-----------------------#' SET @@global.sort_buffer_size = 32775; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '32775' -SELECT @@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804; -@@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804 +SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; +@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000 1 SET @@global.sort_buffer_size = -1024; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '0' -SELECT @@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804; -@@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804 +SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; +@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000 1 SET @@global.sort_buffer_size = 4294967296; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '4294967296' SELECT @@global.sort_buffer_size; @@global.sort_buffer_size 4294967295 @@ -103,64 +78,47 @@ SELECT @@global.sort_buffer_size; @@global.sort_buffer_size 4294967295 SET @@session.sort_buffer_size = 32775; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '32775' -SELECT @@session.sort_buffer_size= 32776 OR @@session.sort_buffer_size= 32804; -@@session.sort_buffer_size= 32776 OR @@session.sort_buffer_size= 32804 +SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000; +@@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000 1 SET @@session.sort_buffer_size = -2; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '0' -SELECT @@session.sort_buffer_size= 32776 OR @@session.sort_buffer_size= 32804; -@@session.sort_buffer_size= 32776 OR @@session.sort_buffer_size= 32804 +SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000; +@@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000 1 SET @@session.sort_buffer_size = 65530.34.; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1 SET @@session.sort_buffer_size = 4294967296; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '4294967296' SELECT @@session.sort_buffer_size; @@session.sort_buffer_size 4294967295 -'Bug # 34837: Errors are not coming on assigning invalid values to variable'; SET @@session.sort_buffer_size = test; ERROR 42000: Incorrect argument type to variable 'sort_buffer_size' -SELECT @@session.sort_buffer_size; -@@session.sort_buffer_size -4294967295 '#------------------FN_DYNVARS_151_06-----------------------#' -SELECT @@global.sort_buffer_size = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='sort_buffer_size'; +SELECT @@global.sort_buffer_size = VARIABLE_VALUE FROM +INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='sort_buffer_size'; @@global.sort_buffer_size = VARIABLE_VALUE 1 '#------------------FN_DYNVARS_151_07-----------------------#' -SELECT @@session.sort_buffer_size = VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='sort_buffer_size'; +SELECT @@session.sort_buffer_size = VARIABLE_VALUE FROM +INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='sort_buffer_size'; @@session.sort_buffer_size = VARIABLE_VALUE 1 '#------------------FN_DYNVARS_151_08-----------------------#' SET @@global.sort_buffer_size = TRUE; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '1' -SELECT @@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804; -@@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804 +SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; +@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000 1 SET @@global.sort_buffer_size = FALSE; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '0' -SELECT @@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804; -@@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804 +SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; +@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000 1 -'Bug: Errors should be displayed on assigning TRUE/FALSE to variable' '#---------------------FN_DYNVARS_151_09----------------------#' SET @@global.sort_buffer_size = 9000; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '9000' SELECT @@sort_buffer_size = @@global.sort_buffer_size; @@sort_buffer_size = @@global.sort_buffer_size 0 '#---------------------FN_DYNVARS_151_10----------------------#' SET @@sort_buffer_size = 9000; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '9000' SELECT @@sort_buffer_size = @@local.sort_buffer_size; @@sort_buffer_size = @@local.sort_buffer_size 1 @@ -169,14 +127,9 @@ SELECT @@local.sort_buffer_size = @@session.sort_buffer_size; 1 '#---------------------FN_DYNVARS_151_11----------------------#' SET sort_buffer_size = 9100; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '9100' -SELECT @sort_buffer_size= 32776 OR @@sort_buffer_size= 32804; -@sort_buffer_size= 32776 OR @@sort_buffer_size= 32804 +SELECT @@sort_buffer_size >= 32776 AND @@sort_buffer_size < 33000; +@@sort_buffer_size >= 32776 AND @@sort_buffer_size < 33000 1 -SELECT @@sort_buffer_size; -@@sort_buffer_size -32804 SELECT local.sort_buffer_size; ERROR 42S02: Unknown table 'local' in field list SELECT session.sort_buffer_size; @@ -184,10 +137,4 @@ ERROR 42S02: Unknown table 'session' in field list SELECT sort_buffer_size = @@session.sort_buffer_size; ERROR 42S22: Unknown column 'sort_buffer_size' in 'field list' SET @@global.sort_buffer_size = @start_global_value; -SELECT @@global.sort_buffer_size; -@@global.sort_buffer_size -262144 SET @@session.sort_buffer_size = @start_session_value; -SELECT @@session.sort_buffer_size; -@@session.sort_buffer_size -262144 diff --git a/mysql-test/suite/sys_vars/r/sort_buffer_size_basic_64.result b/mysql-test/suite/sys_vars/r/sort_buffer_size_basic_64.result index e9bd14abc67..3708f88f889 100644 --- a/mysql-test/suite/sys_vars/r/sort_buffer_size_basic_64.result +++ b/mysql-test/suite/sys_vars/r/sort_buffer_size_basic_64.result @@ -1,47 +1,33 @@ SET @start_global_value = @@global.sort_buffer_size; -SELECT @start_global_value; -@start_global_value -262144 SET @start_session_value = @@session.sort_buffer_size; -SELECT @start_session_value; -@start_session_value -262144 '#--------------------FN_DYNVARS_151_01-------------------------#' SET @@global.sort_buffer_size = 1000; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '1000' SET @@global.sort_buffer_size = DEFAULT; -SELECT @@global.sort_buffer_size= 2097144 OR @@global.sort_buffer_size= 2097116; -@@global.sort_buffer_size= 2097144 OR @@global.sort_buffer_size= 2097116 +SELECT @@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000; +@@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000 1 SET @@session.sort_buffer_size = 2000; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '2000' SET @@session.sort_buffer_size = DEFAULT; -SELECT @@session.sort_buffer_size= 2097144 OR @@session.sort_buffer_size= 2097116; -@@session.sort_buffer_size= 2097144 OR @@session.sort_buffer_size= 2097116 +SELECT @@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000; +@@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000 1 '#--------------------FN_DYNVARS_151_02-------------------------#' SET @@global.sort_buffer_size = DEFAULT; -SELECT @@global.sort_buffer_size = 2097144 OR @@global.sort_buffer_size= 2097116; -@@global.sort_buffer_size = 2097144 OR @@global.sort_buffer_size= 2097116 +SELECT @@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000; +@@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000 1 SET @@session.sort_buffer_size = DEFAULT; -SELECT @@session.sort_buffer_size = 2097144 OR @@session.sort_buffer_size= 2097116; -@@session.sort_buffer_size = 2097144 OR @@session.sort_buffer_size= 2097116 +SELECT @@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000; +@@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000 1 '#--------------------FN_DYNVARS_151_03-------------------------#' SET @@global.sort_buffer_size = 32776; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '32776' -SELECT @@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804; -@@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804 +SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; +@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000 1 SET @@global.sort_buffer_size = 32777; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '32777' -SELECT @@global.sort_buffer_size= 32777 OR @@global.sort_buffer_size= 32804; -@@global.sort_buffer_size= 32777 OR @@global.sort_buffer_size= 32804 +SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; +@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000 1 SET @@global.sort_buffer_size = 4294967295; SELECT @@global.sort_buffer_size; @@ -51,19 +37,14 @@ SET @@global.sort_buffer_size = 4294967294; SELECT @@global.sort_buffer_size; @@global.sort_buffer_size 4294967294 -'Bug# 34877: Invalid Values are showing in variable on assigning valid values.'; '#--------------------FN_DYNVARS_151_04-------------------------#' SET @@session.sort_buffer_size = 32776; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '32776' -SELECT @@session.sort_buffer_size= 32776 OR @@session.sort_buffer_size= 32804; -@@session.sort_buffer_size= 32776 OR @@session.sort_buffer_size= 32804 +SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000; +@@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000 1 SET @@session.sort_buffer_size = 32777; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '32777' -SELECT @@session.sort_buffer_size= 32777 OR @@session.sort_buffer_size= 32804; -@@session.sort_buffer_size= 32777 OR @@session.sort_buffer_size= 32804 +SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000; +@@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000 1 SET @@session.sort_buffer_size = 4294967295; SELECT @@session.sort_buffer_size; @@ -75,16 +56,12 @@ SELECT @@session.sort_buffer_size; 4294967294 '#------------------FN_DYNVARS_151_05-----------------------#' SET @@global.sort_buffer_size = 32775; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '32775' -SELECT @@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804; -@@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804 +SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; +@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000 1 SET @@global.sort_buffer_size = -1024; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '0' -SELECT @@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804; -@@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804 +SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; +@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000 1 SET @@global.sort_buffer_size = 4294967296; SELECT @@global.sort_buffer_size; @@ -101,16 +78,12 @@ SELECT @@global.sort_buffer_size; @@global.sort_buffer_size 4294967296 SET @@session.sort_buffer_size = 32775; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '32775' -SELECT @@session.sort_buffer_size= 32776 OR @@session.sort_buffer_size= 32804; -@@session.sort_buffer_size= 32776 OR @@session.sort_buffer_size= 32804 +SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000; +@@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000 1 SET @@session.sort_buffer_size = -2; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '0' -SELECT @@session.sort_buffer_size= 32776 OR @@session.sort_buffer_size= 32804; -@@session.sort_buffer_size= 32776 OR @@session.sort_buffer_size= 32804 +SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000; +@@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000 1 SET @@session.sort_buffer_size = 65530.34.; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1 @@ -118,45 +91,34 @@ SET @@session.sort_buffer_size = 4294967296; SELECT @@session.sort_buffer_size; @@session.sort_buffer_size 4294967296 -'Bug # 34837: Errors are not coming on assigning invalid values to variable'; SET @@session.sort_buffer_size = test; ERROR 42000: Incorrect argument type to variable 'sort_buffer_size' -SELECT @@session.sort_buffer_size; -@@session.sort_buffer_size -4294967296 '#------------------FN_DYNVARS_151_06-----------------------#' -SELECT @@global.sort_buffer_size = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='sort_buffer_size'; +SELECT @@global.sort_buffer_size = VARIABLE_VALUE FROM +INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='sort_buffer_size'; @@global.sort_buffer_size = VARIABLE_VALUE 1 '#------------------FN_DYNVARS_151_07-----------------------#' -SELECT @@session.sort_buffer_size = VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='sort_buffer_size'; +SELECT @@session.sort_buffer_size = VARIABLE_VALUE FROM +INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='sort_buffer_size'; @@session.sort_buffer_size = VARIABLE_VALUE 1 '#------------------FN_DYNVARS_151_08-----------------------#' SET @@global.sort_buffer_size = TRUE; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '1' -SELECT @@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804; -@@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804 +SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; +@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000 1 SET @@global.sort_buffer_size = FALSE; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '0' -SELECT @@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804; -@@global.sort_buffer_size= 32776 OR @@global.sort_buffer_size= 32804 +SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; +@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000 1 -'Bug: Errors should be displayed on assigning TRUE/FALSE to variable' '#---------------------FN_DYNVARS_151_09----------------------#' SET @@global.sort_buffer_size = 9000; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '9000' SELECT @@sort_buffer_size = @@global.sort_buffer_size; @@sort_buffer_size = @@global.sort_buffer_size 0 '#---------------------FN_DYNVARS_151_10----------------------#' SET @@sort_buffer_size = 9000; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '9000' SELECT @@sort_buffer_size = @@local.sort_buffer_size; @@sort_buffer_size = @@local.sort_buffer_size 1 @@ -165,14 +127,9 @@ SELECT @@local.sort_buffer_size = @@session.sort_buffer_size; 1 '#---------------------FN_DYNVARS_151_11----------------------#' SET sort_buffer_size = 9100; -Warnings: -Warning 1292 Truncated incorrect sort_buffer_size value: '9100' -SELECT @sort_buffer_size= 32776 OR @@sort_buffer_size= 32804; -@sort_buffer_size= 32776 OR @@sort_buffer_size= 32804 +SELECT @@sort_buffer_size >= 32776 AND @@sort_buffer_size < 33000; +@@sort_buffer_size >= 32776 AND @@sort_buffer_size < 33000 1 -SELECT @@sort_buffer_size; -@@sort_buffer_size -32804 SELECT local.sort_buffer_size; ERROR 42S02: Unknown table 'local' in field list SELECT session.sort_buffer_size; @@ -180,10 +137,4 @@ ERROR 42S02: Unknown table 'session' in field list SELECT sort_buffer_size = @@session.sort_buffer_size; ERROR 42S22: Unknown column 'sort_buffer_size' in 'field list' SET @@global.sort_buffer_size = @start_global_value; -SELECT @@global.sort_buffer_size; -@@global.sort_buffer_size -262144 SET @@session.sort_buffer_size = @start_session_value; -SELECT @@session.sort_buffer_size; -@@session.sort_buffer_size -262144 From 1feb81bf336e41325934ec263d2dc79e10e8f6ca Mon Sep 17 00:00:00 2001 From: Horst Hunger Date: Tue, 2 Dec 2008 11:05:56 +0100 Subject: [PATCH 009/137] Fix for Bug#36876: The minimum value differs depending on the OS and mysqld build, so that the test fail spradically. The check of this value has been changed from check of concrete values to the check of a range that is near by the expected value. --- mysql-test/include/linux_sys_vars.inc | 1 - mysql-test/include/windows_sys_vars.inc | 1 - .../sys_vars/inc/key_buffer_size_basic.inc | 54 ++++++++---------- .../r/key_buffer_size_basic_32.result | 55 ++++++++----------- .../r/key_buffer_size_basic_64.result | 55 ++++++++----------- 5 files changed, 68 insertions(+), 98 deletions(-) diff --git a/mysql-test/include/linux_sys_vars.inc b/mysql-test/include/linux_sys_vars.inc index 4401a1e057a..85d7c6df7dc 100644 --- a/mysql-test/include/linux_sys_vars.inc +++ b/mysql-test/include/linux_sys_vars.inc @@ -9,7 +9,6 @@ SET @min_flush_time = 0; #SET @max_flush_time = 0; SET @default_key_buffer_size = 131072; -SET @min_key_buffer_size = 36; #SET @default_join_buffer_size = 131072; #SET @min_join_buffer_size = 8200; diff --git a/mysql-test/include/windows_sys_vars.inc b/mysql-test/include/windows_sys_vars.inc index 90ff86fefd1..1d51ddb52f9 100644 --- a/mysql-test/include/windows_sys_vars.inc +++ b/mysql-test/include/windows_sys_vars.inc @@ -9,7 +9,6 @@ SET @min_flush_time = 0; #SET @max_flush_time = 0; SET @default_key_buffer_size= 131072; -SET @min_key_buffer_size= 8; #SET @default_join_buffer_size = 131072; #SET @min_join_buffer_size = 8200; diff --git a/mysql-test/suite/sys_vars/inc/key_buffer_size_basic.inc b/mysql-test/suite/sys_vars/inc/key_buffer_size_basic.inc index 996a9e712f9..a8fa50a6a23 100644 --- a/mysql-test/suite/sys_vars/inc/key_buffer_size_basic.inc +++ b/mysql-test/suite/sys_vars/inc/key_buffer_size_basic.inc @@ -17,14 +17,14 @@ # * Valid & Invalid values # # * Scope & Access method # # * Data Integrity # +# Modified: Horst Hunger 2008-11-27 # +# Due to OS depending values the check has been changed # +# from concrete values to ranges. # # # -# Reference: http://dev.mysql.com/doc/refman/5.1/en/ # -# server-system-variables.html # +# Reference: # +# http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html # # # ############################################################################### -# Changes: # -# 2008-03-06 hhunger Got "lost connections with 5.1.24 # -######################################################################## --source include/load_sysvars.inc @@ -38,8 +38,6 @@ ######################################################################## SET @start_value = @@global.key_buffer_size; -SELECT @start_value; - --echo '#--------------------FN_DYNVARS_055_01------------------------#' ######################################################################## @@ -49,9 +47,7 @@ SELECT @start_value; SET @@global.key_buffer_size = 99; --Error ER_NO_DEFAULT SET @@global.key_buffer_size = DEFAULT; ---echo 'Bug# 34878: This variable has default value according to documentation'; -SELECT @@global.key_buffer_size = @min_key_buffer_size; - +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; --echo '#---------------------FN_DYNVARS_055_02-------------------------#' ############################################### @@ -66,26 +62,25 @@ SELECT @@global.key_buffer_size = @start_value; # Change the value of key_buffer_size to a valid value # ######################################################################## -SET @@global.key_buffer_size = @min_key_buffer_size; -SELECT @@global.key_buffer_size= @min_key_buffer_size; +SET @@global.key_buffer_size = 8 ; +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; --disable_warnings -#Due to "lost connection" +#Due to increasing the runtime significantly and allocating the buffer instantly. #SET @@global.key_buffer_size = 4294967295; --enable_warnings #SELECT @@global.key_buffer_size; SET @@global.key_buffer_size = 1800; -SELECT @@global.key_buffer_size = @min_key_buffer_size; +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; SET @@global.key_buffer_size = 65535; SELECT @@global.key_buffer_size; -echo 'Bug # 34837: Errors are not coming on assigning invalid values to variable'; - --echo '#--------------------FN_DYNVARS_055_04-------------------------#' ########################################################################### # Change the value of key_buffer_size to invalid value # ########################################################################### -# Due to "lost connection" +# Due to increasing the runtime significantly and allocating the buffer instantly +# with a size of 18446744073709551615 bytes with 32bit exec. #SET @@global.key_buffer_size = -1; #SELECT @@global.key_buffer_size; #SET @@global.key_buffer_size = 100000000000; @@ -96,16 +91,14 @@ SELECT @@global.key_buffer_size; #SET @@global.key_buffer_size = -1024; #SELECT @@global.key_buffer_size; SET @@global.key_buffer_size = 4; -SELECT @@global.key_buffer_size = @min_key_buffer_size; ---echo 'Bug # 34837: Errors are not coming on assigning invalid values to variable'; +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; --Error ER_WRONG_TYPE_FOR_VAR SET @@global.key_buffer_size = ON; -SELECT @@global.key_buffer_size = @min_key_buffer_size; +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; --Error ER_WRONG_TYPE_FOR_VAR SET @@global.key_buffer_size = 'test'; -SELECT @@global.key_buffer_size = @min_key_buffer_size; - +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; --echo '#-------------------FN_DYNVARS_055_05----------------------------#' ########################################################################### @@ -114,8 +107,7 @@ SELECT @@global.key_buffer_size = @min_key_buffer_size; --Error ER_GLOBAL_VARIABLE SET @@session.key_buffer_size = 0; -SELECT @@key_buffer_size = @min_key_buffer_size; - +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; --echo '#----------------------FN_DYNVARS_055_06------------------------#' ############################################################################## @@ -130,17 +122,15 @@ SELECT @@key_buffer_size = VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='key_buffer_size'; - --echo '#---------------------FN_DYNVARS_055_07----------------------#' ################################################################### # Check if TRUE and FALSE values can be used on variable # ################################################################### SET @@global.key_buffer_size = TRUE; -SELECT @@global.key_buffer_size = @min_key_buffer_size; +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; SET @@global.key_buffer_size = FALSE; -SELECT @@global.key_buffer_size = @min_key_buffer_size; - +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; --echo '#---------------------FN_DYNVARS_055_08----------------------#' ##################################################################### @@ -150,7 +140,7 @@ SELECT @@global.key_buffer_size = @min_key_buffer_size; # due to differences in contents of the warnings --disable_warnings -SET @@global.key_buffer_size = @min_key_buffer_size; +SET @@global.key_buffer_size = 8 ; SELECT @@key_buffer_size = @@global.key_buffer_size; --enable_warnings @@ -160,8 +150,8 @@ SELECT @@key_buffer_size = @@global.key_buffer_size; ########################################################################## --Error ER_GLOBAL_VARIABLE -SET key_buffer_size = @min_key_buffer_size; -SELECT @@key_buffer_size = @min_key_buffer_size; +SET key_buffer_size = 8 ; +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; --Error ER_PARSE_ERROR SET local.key_buffer_size = 10; --Error ER_UNKNOWN_TABLE @@ -179,9 +169,9 @@ SELECT key_buffer_size = @@session.key_buffer_size; ############################## SET @@global.key_buffer_size = @start_value; -SELECT @@global.key_buffer_size; --enable_warnings ####################################################################### # END OF key_buffer_size TESTS # ####################################################################### + diff --git a/mysql-test/suite/sys_vars/r/key_buffer_size_basic_32.result b/mysql-test/suite/sys_vars/r/key_buffer_size_basic_32.result index 981988a1d4d..51c4f841205 100644 --- a/mysql-test/suite/sys_vars/r/key_buffer_size_basic_32.result +++ b/mysql-test/suite/sys_vars/r/key_buffer_size_basic_32.result @@ -1,14 +1,10 @@ SET @start_value = @@global.key_buffer_size; -SELECT @start_value; -@start_value -1048576 '#--------------------FN_DYNVARS_055_01------------------------#' SET @@global.key_buffer_size = 99; SET @@global.key_buffer_size = DEFAULT; ERROR 42000: Variable 'key_buffer_size' doesn't have a default value -'Bug# 34878: This variable has default value according to documentation'; -SELECT @@global.key_buffer_size = @min_key_buffer_size; -@@global.key_buffer_size = @min_key_buffer_size +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; +@@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36 1 '#---------------------FN_DYNVARS_055_02-------------------------#' SET @@global.key_buffer_size = @start_value; @@ -16,21 +12,20 @@ SELECT @@global.key_buffer_size = @start_value; @@global.key_buffer_size = @start_value 1 '#--------------------FN_DYNVARS_055_03------------------------#' -SET @@global.key_buffer_size = @min_key_buffer_size; -SELECT @@global.key_buffer_size= @min_key_buffer_size; -@@global.key_buffer_size= @min_key_buffer_size +SET @@global.key_buffer_size = 8 ; +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; +@@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36 1 SET @@global.key_buffer_size = 1800; Warnings: Warning 1292 Truncated incorrect key_buffer_size value: '1800' -SELECT @@global.key_buffer_size = @min_key_buffer_size; -@@global.key_buffer_size = @min_key_buffer_size +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; +@@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36 1 SET @@global.key_buffer_size = 65535; SELECT @@global.key_buffer_size; @@global.key_buffer_size 61440 -'Bug # 34837: Errors are not coming on assigning invalid values to variable' '#--------------------FN_DYNVARS_055_04-------------------------#' SET @@global.key_buffer_size = 10000.01; ERROR 42000: Incorrect argument type to variable 'key_buffer_size' @@ -40,25 +35,24 @@ SELECT @@global.key_buffer_size; SET @@global.key_buffer_size = 4; Warnings: Warning 1292 Truncated incorrect key_buffer_size value: '4' -SELECT @@global.key_buffer_size = @min_key_buffer_size; -@@global.key_buffer_size = @min_key_buffer_size +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; +@@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36 1 -'Bug # 34837: Errors are not coming on assigning invalid values to variable'; SET @@global.key_buffer_size = ON; ERROR 42000: Incorrect argument type to variable 'key_buffer_size' -SELECT @@global.key_buffer_size = @min_key_buffer_size; -@@global.key_buffer_size = @min_key_buffer_size +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; +@@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36 1 SET @@global.key_buffer_size = 'test'; ERROR 42000: Incorrect argument type to variable 'key_buffer_size' -SELECT @@global.key_buffer_size = @min_key_buffer_size; -@@global.key_buffer_size = @min_key_buffer_size +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; +@@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36 1 '#-------------------FN_DYNVARS_055_05----------------------------#' SET @@session.key_buffer_size = 0; ERROR HY000: Variable 'key_buffer_size' is a GLOBAL variable and should be set with SET GLOBAL -SELECT @@key_buffer_size = @min_key_buffer_size; -@@key_buffer_size = @min_key_buffer_size +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; +@@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36 1 '#----------------------FN_DYNVARS_055_06------------------------#' SELECT @@global.key_buffer_size = VARIABLE_VALUE @@ -75,25 +69,25 @@ WHERE VARIABLE_NAME='key_buffer_size'; SET @@global.key_buffer_size = TRUE; Warnings: Warning 1292 Truncated incorrect key_buffer_size value: '1' -SELECT @@global.key_buffer_size = @min_key_buffer_size; -@@global.key_buffer_size = @min_key_buffer_size +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; +@@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36 1 SET @@global.key_buffer_size = FALSE; Warnings: Warning 1438 Cannot drop default keycache -SELECT @@global.key_buffer_size = @min_key_buffer_size; -@@global.key_buffer_size = @min_key_buffer_size +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; +@@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36 1 '#---------------------FN_DYNVARS_055_08----------------------#' -SET @@global.key_buffer_size = @min_key_buffer_size; +SET @@global.key_buffer_size = 8 ; SELECT @@key_buffer_size = @@global.key_buffer_size; @@key_buffer_size = @@global.key_buffer_size 1 '#---------------------FN_DYNVARS_055_09----------------------#' -SET key_buffer_size = @min_key_buffer_size; +SET key_buffer_size = 8 ; ERROR HY000: Variable 'key_buffer_size' is a GLOBAL variable and should be set with SET GLOBAL -SELECT @@key_buffer_size = @min_key_buffer_size; -@@key_buffer_size = @min_key_buffer_size +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; +@@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36 1 SET local.key_buffer_size = 10; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key_buffer_size = 10' at line 1 @@ -106,6 +100,3 @@ ERROR 42S02: Unknown table 'global' in field list SELECT key_buffer_size = @@session.key_buffer_size; ERROR 42S22: Unknown column 'key_buffer_size' in 'field list' SET @@global.key_buffer_size = @start_value; -SELECT @@global.key_buffer_size; -@@global.key_buffer_size -1048576 diff --git a/mysql-test/suite/sys_vars/r/key_buffer_size_basic_64.result b/mysql-test/suite/sys_vars/r/key_buffer_size_basic_64.result index 981988a1d4d..51c4f841205 100644 --- a/mysql-test/suite/sys_vars/r/key_buffer_size_basic_64.result +++ b/mysql-test/suite/sys_vars/r/key_buffer_size_basic_64.result @@ -1,14 +1,10 @@ SET @start_value = @@global.key_buffer_size; -SELECT @start_value; -@start_value -1048576 '#--------------------FN_DYNVARS_055_01------------------------#' SET @@global.key_buffer_size = 99; SET @@global.key_buffer_size = DEFAULT; ERROR 42000: Variable 'key_buffer_size' doesn't have a default value -'Bug# 34878: This variable has default value according to documentation'; -SELECT @@global.key_buffer_size = @min_key_buffer_size; -@@global.key_buffer_size = @min_key_buffer_size +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; +@@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36 1 '#---------------------FN_DYNVARS_055_02-------------------------#' SET @@global.key_buffer_size = @start_value; @@ -16,21 +12,20 @@ SELECT @@global.key_buffer_size = @start_value; @@global.key_buffer_size = @start_value 1 '#--------------------FN_DYNVARS_055_03------------------------#' -SET @@global.key_buffer_size = @min_key_buffer_size; -SELECT @@global.key_buffer_size= @min_key_buffer_size; -@@global.key_buffer_size= @min_key_buffer_size +SET @@global.key_buffer_size = 8 ; +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; +@@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36 1 SET @@global.key_buffer_size = 1800; Warnings: Warning 1292 Truncated incorrect key_buffer_size value: '1800' -SELECT @@global.key_buffer_size = @min_key_buffer_size; -@@global.key_buffer_size = @min_key_buffer_size +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; +@@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36 1 SET @@global.key_buffer_size = 65535; SELECT @@global.key_buffer_size; @@global.key_buffer_size 61440 -'Bug # 34837: Errors are not coming on assigning invalid values to variable' '#--------------------FN_DYNVARS_055_04-------------------------#' SET @@global.key_buffer_size = 10000.01; ERROR 42000: Incorrect argument type to variable 'key_buffer_size' @@ -40,25 +35,24 @@ SELECT @@global.key_buffer_size; SET @@global.key_buffer_size = 4; Warnings: Warning 1292 Truncated incorrect key_buffer_size value: '4' -SELECT @@global.key_buffer_size = @min_key_buffer_size; -@@global.key_buffer_size = @min_key_buffer_size +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; +@@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36 1 -'Bug # 34837: Errors are not coming on assigning invalid values to variable'; SET @@global.key_buffer_size = ON; ERROR 42000: Incorrect argument type to variable 'key_buffer_size' -SELECT @@global.key_buffer_size = @min_key_buffer_size; -@@global.key_buffer_size = @min_key_buffer_size +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; +@@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36 1 SET @@global.key_buffer_size = 'test'; ERROR 42000: Incorrect argument type to variable 'key_buffer_size' -SELECT @@global.key_buffer_size = @min_key_buffer_size; -@@global.key_buffer_size = @min_key_buffer_size +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; +@@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36 1 '#-------------------FN_DYNVARS_055_05----------------------------#' SET @@session.key_buffer_size = 0; ERROR HY000: Variable 'key_buffer_size' is a GLOBAL variable and should be set with SET GLOBAL -SELECT @@key_buffer_size = @min_key_buffer_size; -@@key_buffer_size = @min_key_buffer_size +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; +@@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36 1 '#----------------------FN_DYNVARS_055_06------------------------#' SELECT @@global.key_buffer_size = VARIABLE_VALUE @@ -75,25 +69,25 @@ WHERE VARIABLE_NAME='key_buffer_size'; SET @@global.key_buffer_size = TRUE; Warnings: Warning 1292 Truncated incorrect key_buffer_size value: '1' -SELECT @@global.key_buffer_size = @min_key_buffer_size; -@@global.key_buffer_size = @min_key_buffer_size +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; +@@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36 1 SET @@global.key_buffer_size = FALSE; Warnings: Warning 1438 Cannot drop default keycache -SELECT @@global.key_buffer_size = @min_key_buffer_size; -@@global.key_buffer_size = @min_key_buffer_size +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; +@@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36 1 '#---------------------FN_DYNVARS_055_08----------------------#' -SET @@global.key_buffer_size = @min_key_buffer_size; +SET @@global.key_buffer_size = 8 ; SELECT @@key_buffer_size = @@global.key_buffer_size; @@key_buffer_size = @@global.key_buffer_size 1 '#---------------------FN_DYNVARS_055_09----------------------#' -SET key_buffer_size = @min_key_buffer_size; +SET key_buffer_size = 8 ; ERROR HY000: Variable 'key_buffer_size' is a GLOBAL variable and should be set with SET GLOBAL -SELECT @@key_buffer_size = @min_key_buffer_size; -@@key_buffer_size = @min_key_buffer_size +SELECT @@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36; +@@global.key_buffer_size >= 8 AND @@global.key_buffer_size <= 36 1 SET local.key_buffer_size = 10; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key_buffer_size = 10' at line 1 @@ -106,6 +100,3 @@ ERROR 42S02: Unknown table 'global' in field list SELECT key_buffer_size = @@session.key_buffer_size; ERROR 42S22: Unknown column 'key_buffer_size' in 'field list' SET @@global.key_buffer_size = @start_value; -SELECT @@global.key_buffer_size; -@@global.key_buffer_size -1048576 From 8f39d2584ba0ba33998461aa93a714f8cadf498d Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Tue, 2 Dec 2008 11:18:01 +0100 Subject: [PATCH 010/137] Bug#40389: REORGANIZE PARTITION crashes when only using one partition The non documented command 'ALTER PARTITION t REORGANIZE PARTITION' (without any partitions!) which only make sense for nativly partitioned engines, such as NDB, crashes the server if there was no change of number of partitions. The problem was wrong usage of fast_end_partition function, which led to usage of a non initialized variable. --- mysql-test/r/partition_mgm.result | 7 +++++++ mysql-test/t/partition_mgm.test | 11 +++++++++++ sql/partition_info.cc | 1 + sql/sql_partition.cc | 5 ++--- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/partition_mgm.result b/mysql-test/r/partition_mgm.result index 9ef220028b3..eeb9be949a0 100644 --- a/mysql-test/r/partition_mgm.result +++ b/mysql-test/r/partition_mgm.result @@ -1,4 +1,11 @@ DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a INT PRIMARY KEY) +ENGINE MYISAM +PARTITION BY HASH (a) +PARTITIONS 1; +INSERT INTO t1 VALUES (1),(2),(3),(4),(5); +ALTER TABLE t1 REORGANIZE PARTITION; +DROP TABLE t1; create table t1 (a int) partition by range (a) subpartition by key (a) diff --git a/mysql-test/t/partition_mgm.test b/mysql-test/t/partition_mgm.test index 68da4a5b390..1f53989b4d4 100644 --- a/mysql-test/t/partition_mgm.test +++ b/mysql-test/t/partition_mgm.test @@ -3,6 +3,17 @@ DROP TABLE IF EXISTS t1; --enable_warnings +# +# Bug 40389: REORGANIZE PARTITION crashes when only using one partition +# +CREATE TABLE t1 (a INT PRIMARY KEY) +ENGINE MYISAM +PARTITION BY HASH (a) +PARTITIONS 1; +INSERT INTO t1 VALUES (1),(2),(3),(4),(5); +ALTER TABLE t1 REORGANIZE PARTITION; +DROP TABLE t1; + # # Bug 21143: mysqld hang when error in number of subparts in # REORGANIZE command diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 02f2c9b0ab1..e2027d3571e 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -867,6 +867,7 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type, if (part_type != HASH_PARTITION || !list_of_part_fields) { + DBUG_ASSERT(part_expr); err= part_expr->walk(&Item::check_partition_func_processor, 0, NULL); if (!err && is_sub_partitioned() && !list_of_subpart_fields) diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index da80a2125e9..6fb803ce4ff 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -4228,9 +4228,8 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, after the change as before. Thus we can reply ok immediately without any changes at all. */ - DBUG_RETURN(fast_end_partition(thd, ULL(0), ULL(0), - table, NULL, - TRUE, NULL, FALSE)); + *fast_alter_partition= TRUE; + DBUG_RETURN(FALSE); } else if (new_part_no > curr_part_no) { From 7cb0aa4ccf216932c58ef701a0e126d1692fe146 Mon Sep 17 00:00:00 2001 From: Horst Hunger Date: Tue, 2 Dec 2008 12:34:52 +0100 Subject: [PATCH 011/137] Fix for Bug#37810: The "show status" may be received by the server in a startup state, where it only can reject the statement, so that the client then react with 2013. So, adding 2013 to the list of errors may help, as the "show status" will be repeated then. --- mysql-test/include/wait_until_connected_again.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/include/wait_until_connected_again.inc b/mysql-test/include/wait_until_connected_again.inc index dc96f646cb3..2d8356cb0f5 100644 --- a/mysql-test/include/wait_until_connected_again.inc +++ b/mysql-test/include/wait_until_connected_again.inc @@ -6,7 +6,7 @@ let $counter= 500; while ($mysql_errno) { - --error 0,2002,2006 + --error 0,2002,2006,2013 show status; dec $counter; From 40889f9ea6643620509f6978316a40d209b92b18 Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Tue, 2 Dec 2008 19:32:07 +0200 Subject: [PATCH 012/137] Bug #40221 Replication failure on RBR + UPDATE the primary key A transaction could result in having an extra event after a query that errored e.g because of a dup key. Such a query is rolled back in innodb, as specified, but has not been in binlog. It appeares that the binlog engine did not always register for a query (statement) because the previous query had not reset at its statement commit time. Because of that fact there was no roll-back to the trx_data->before_stmt_pos position and a the pending event of the errorred query could become flushed to the binlog file. Fixed with deploying the reset of trx_data->before_stmt_pos at the end of the query processing. --- .../suite/binlog/r/binlog_innodb_row.result | 22 ++++++++++++++++ .../suite/binlog/t/binlog_innodb_row.test | 26 +++++++++++++++++++ sql/log.cc | 18 +++++++++---- 3 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 mysql-test/suite/binlog/r/binlog_innodb_row.result create mode 100644 mysql-test/suite/binlog/t/binlog_innodb_row.test diff --git a/mysql-test/suite/binlog/r/binlog_innodb_row.result b/mysql-test/suite/binlog/r/binlog_innodb_row.result new file mode 100644 index 00000000000..47ddcbd00f6 --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_innodb_row.result @@ -0,0 +1,22 @@ +CREATE TABLE t1 (pk int auto_increment primary key) ENGINE=innodb; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`pk`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +reset master; +begin; +insert into t1 values (1),(2); +*** the following UPDATE query wont generate any updates for the binlog *** +update t1 set pk = 3 where pk < 3; +ERROR 23000: Duplicate entry '3' for key 'PRIMARY' +commit; +*** Results of the test: the binlog must have only Write_rows events not any Update_rows *** +show binlog events from ; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Xid # # COMMIT /* XID */ +drop table t1; diff --git a/mysql-test/suite/binlog/t/binlog_innodb_row.test b/mysql-test/suite/binlog/t/binlog_innodb_row.test new file mode 100644 index 00000000000..7f42f5b95cb --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_innodb_row.test @@ -0,0 +1,26 @@ +# +# Tests of innodb/binlog with the row binlog format +# +source include/have_innodb.inc; +source include/have_log_bin.inc; +source include/have_binlog_format_row.inc; + +# +# Bug #40221 Replication failure on RBR + UPDATE the primary key +# + +CREATE TABLE t1 (pk int auto_increment primary key) ENGINE=innodb; +show create table t1; +reset master; + +begin; +insert into t1 values (1),(2); +--echo *** the following UPDATE query wont generate any updates for the binlog *** +--error ER_DUP_ENTRY +update t1 set pk = 3 where pk < 3; +commit; + +--echo *** Results of the test: the binlog must have only Write_rows events not any Update_rows *** +source include/show_binlog_events.inc; + +drop table t1; diff --git a/sql/log.cc b/sql/log.cc index fb8669a5731..8169ff08590 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -207,6 +207,7 @@ public: truncate(0); before_stmt_pos= MY_OFF_T_UNDEF; trans_log.end_of_file= max_binlog_cache_size; + DBUG_ASSERT(empty()); } Rows_log_event *pending() const @@ -1377,8 +1378,6 @@ binlog_end_trans(THD *thd, binlog_trx_data *trx_data, FLAGSTR(thd->options, OPTION_NOT_AUTOCOMMIT), FLAGSTR(thd->options, OPTION_BEGIN))); - thd->binlog_flush_pending_rows_event(TRUE); - /* NULL denotes ROLLBACK with nothing to replicate: i.e., rollback of only transactional tables. If the transaction contain changes to @@ -1387,6 +1386,7 @@ binlog_end_trans(THD *thd, binlog_trx_data *trx_data, */ if (end_ev != NULL) { + thd->binlog_flush_pending_rows_event(TRUE); /* Doing a commit or a rollback including non-transactional tables, i.e., ending a transaction where we might write the transaction @@ -1435,6 +1435,7 @@ binlog_end_trans(THD *thd, binlog_trx_data *trx_data, mysql_bin_log.update_table_map_version(); } + DBUG_ASSERT(thd->binlog_get_pending_rows_event() == NULL); DBUG_RETURN(error); } @@ -1466,6 +1467,7 @@ static int binlog_prepare(handlerton *hton, THD *thd, bool all) */ static int binlog_commit(handlerton *hton, THD *thd, bool all) { + int error= 0; DBUG_ENTER("binlog_commit"); binlog_trx_data *const trx_data= (binlog_trx_data*) thd_get_ha_data(thd, binlog_hton); @@ -1552,10 +1554,14 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all) { Query_log_event qev(thd, STRING_WITH_LEN("COMMIT"), TRUE, FALSE); qev.error_code= 0; // see comment in MYSQL_LOG::write(THD, IO_CACHE) - int error= binlog_end_trans(thd, trx_data, &qev, all); - DBUG_RETURN(error); + error= binlog_end_trans(thd, trx_data, &qev, all); + goto end; } - DBUG_RETURN(0); + +end: + if (!all) + trx_data->before_stmt_pos = MY_OFF_T_UNDEF; // part of the stmt commit + DBUG_RETURN(error); } /** @@ -1615,6 +1621,8 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all) */ error= binlog_end_trans(thd, trx_data, 0, all); } + if (!all) + trx_data->before_stmt_pos = MY_OFF_T_UNDEF; // part of the stmt rollback DBUG_RETURN(error); } From 66a7f5e93c8eab29e0b1316dd1056885eb88fcf4 Mon Sep 17 00:00:00 2001 From: Horst Hunger Date: Wed, 3 Dec 2008 10:39:31 +0100 Subject: [PATCH 013/137] temporary fix for Bug#37780: A short analysis of the test shows that it needs a replacement of the sleeps and as "In most cases, it might take some time for the thread to die, because the kill flag is checked only at specific intervals" (user manual) to carfully check that and insert waiting for that event. --- mysql-test/t/disabled.def | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index c01bb4b9e44..0ba5e353474 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -10,5 +10,6 @@ # ############################################################################## federated_transactions : Bug#29523 Transactions do not work -log_tables.test : Bug #37798: main.log_tables fails randomly on powermacg5 and windows -slow_query_log_func.test : Bug #37962: *_func tests containing sleeps/race conditions +log_tables : Bug #37798: main.log_tables fails randomly on powermacg5 and windows +slow_query_log_func : Bug #37962: *_func tests containing sleeps/race conditions +kill : Bug#37780 2008-12-03 HHunger need some changes to be robust enoiugh for pushbuild. From 3562e9e2dbb2eb51a74f1fbd317c5777593ed32c Mon Sep 17 00:00:00 2001 From: Horst Hunger Date: Wed, 3 Dec 2008 16:43:53 +0100 Subject: [PATCH 014/137] (No) fix for Bug#36878: The test has been taken out fo main and put into "sys_vars", but the opportunity to check the test has been take to improve it. --- .../sys_vars/inc/tmp_table_size_basic.inc | 30 ++----------------- .../sys_vars/r/tmp_table_size_basic_32.result | 6 ---- .../sys_vars/r/tmp_table_size_basic_64.result | 6 ---- 3 files changed, 3 insertions(+), 39 deletions(-) diff --git a/mysql-test/suite/sys_vars/inc/tmp_table_size_basic.inc b/mysql-test/suite/sys_vars/inc/tmp_table_size_basic.inc index 7f69bcd1f8c..d29ef6da094 100644 --- a/mysql-test/suite/sys_vars/inc/tmp_table_size_basic.inc +++ b/mysql-test/suite/sys_vars/inc/tmp_table_size_basic.inc @@ -18,8 +18,8 @@ # * Scope & Access method # # * Data Integrity # # # -# Reference: http://dev.mysql.com/doc/refman/5.1/en/ # -# server-system-variables.html#option_mysqld_tmp_table_size # +# Reference: # +# http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html # # # ############################################################################### @@ -29,7 +29,6 @@ # START OF tmp_table_size TESTS # ############################################################## - ############################################################# # Save initial value # ############################################################# @@ -39,8 +38,6 @@ SELECT @start_global_value; SET @start_session_value = @@session.tmp_table_size; SELECT @start_session_value; ---echo 'Bug# 34876: This variable has invalid default value as compared to documentation'; - --echo '#--------------------FN_DYNVARS_005_01-------------------------#' ############################################################## # Display the DEFAULT value of tmp_table_size # @@ -50,16 +47,13 @@ SET @@global.tmp_table_size = 100; SET @@global.tmp_table_size = DEFAULT; SELECT @@global.tmp_table_size; ---echo 'Bug# 34876: This variable has invalid default value as compared to documentation'; SET @@session.tmp_table_size = 200; SET @@session.tmp_table_size = DEFAULT; SELECT @@session.tmp_table_size; ---echo 'Bug# 34876: This variable has invalid default value as compared to documentation'; - --echo '#--------------------FN_DYNVARS_005_02-------------------------#' ######################################################################## -# Check the DEFAULT value of tmp_table_size # +# Check the DEFAULT value of tmp_table_size # ######################################################################## SET @@global.tmp_table_size = DEFAULT; @@ -68,8 +62,6 @@ SELECT @@global.tmp_table_size = 33554432; SET @@session.tmp_table_size = DEFAULT; SELECT @@session.tmp_table_size = 33554432; ---echo 'Bug# 34876: This variable has invalid default value as compared to documentation'; - --echo '#--------------------FN_DYNVARS_005_03-------------------------#' ######################################################################## # Change the value of tmp_table_size to a valid value for GLOBAL Scope # @@ -111,24 +103,17 @@ SELECT @@global.tmp_table_size; SET @@global.tmp_table_size = 1000; SELECT @@global.tmp_table_size; ---echo 'Bug # 34837: Errors are not coming on assigning invalid values to variable'; - - -- Error ER_WRONG_TYPE_FOR_VAR SET @@global.tmp_table_size = ON; - -- Error ER_WRONG_TYPE_FOR_VAR SET @@global.tmp_table_size = OFF; - SET @@global.tmp_table_size = True; SELECT @@global.tmp_table_size; SET @@global.tmp_table_size = False; SELECT @@global.tmp_table_size; ---echo 'Bug:Error should be shown that variable is numeric and can not assigned boolean value'; - -- Error ER_WRONG_TYPE_FOR_VAR SET @@global.tmp_table_size = 65530.34; @@ -136,11 +121,9 @@ SET @@global.tmp_table_size = 65530.34; -- Error ER_WRONG_TYPE_FOR_VAR SET @@global.tmp_table_size ="Test"; - -- Error ER_WRONG_TYPE_FOR_VAR SET @@session.tmp_table_size = ON; - -- Error ER_WRONG_TYPE_FOR_VAR SET @@session.tmp_table_size = OFF; @@ -156,13 +139,11 @@ SET @@session.tmp_table_size = "Test"; SET @@session.tmp_table_size = 12345678901; SELECT @@session.tmp_table_size; - --echo '#------------------FN_DYNVARS_005_06-----------------------#' #################################################################### # Check if the value in GLOBAL Table matches value in variable # #################################################################### - SELECT @@global.tmp_table_size = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='tmp_table_size'; @@ -176,9 +157,6 @@ SELECT @@session.tmp_table_size = VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='tmp_table_size'; - - - --echo '#---------------------FN_DYNVARS_001_09----------------------#' ######################################################################## # Check if global and session variables are independent of each other # @@ -216,7 +194,6 @@ SELECT global.tmp_table_size; --Error ER_BAD_FIELD_ERROR SELECT tmp_table_size = @@session.tmp_table_size; - #################################### # Restore initial value # #################################### @@ -226,7 +203,6 @@ SELECT @@global.tmp_table_size; SET @@session.tmp_table_size = @start_session_value; SELECT @@session.tmp_table_size; - ################################################### # END OF tmp_table_size TESTS # ################################################### diff --git a/mysql-test/suite/sys_vars/r/tmp_table_size_basic_32.result b/mysql-test/suite/sys_vars/r/tmp_table_size_basic_32.result index aeafd95ed55..ba3fd5420c6 100644 --- a/mysql-test/suite/sys_vars/r/tmp_table_size_basic_32.result +++ b/mysql-test/suite/sys_vars/r/tmp_table_size_basic_32.result @@ -6,7 +6,6 @@ SET @start_session_value = @@session.tmp_table_size; SELECT @start_session_value; @start_session_value 16777216 -'Bug# 34876: This variable has invalid default value as compared to documentation'; '#--------------------FN_DYNVARS_005_01-------------------------#' SET @@global.tmp_table_size = 100; Warnings: @@ -15,7 +14,6 @@ SET @@global.tmp_table_size = DEFAULT; SELECT @@global.tmp_table_size; @@global.tmp_table_size 16777216 -'Bug# 34876: This variable has invalid default value as compared to documentation'; SET @@session.tmp_table_size = 200; Warnings: Warning 1292 Truncated incorrect tmp_table_size value: '200' @@ -23,7 +21,6 @@ SET @@session.tmp_table_size = DEFAULT; SELECT @@session.tmp_table_size; @@session.tmp_table_size 16777216 -'Bug# 34876: This variable has invalid default value as compared to documentation'; '#--------------------FN_DYNVARS_005_02-------------------------#' SET @@global.tmp_table_size = DEFAULT; SELECT @@global.tmp_table_size = 33554432; @@ -33,7 +30,6 @@ SET @@session.tmp_table_size = DEFAULT; SELECT @@session.tmp_table_size = 33554432; @@session.tmp_table_size = 33554432 0 -'Bug# 34876: This variable has invalid default value as compared to documentation'; '#--------------------FN_DYNVARS_005_03-------------------------#' SET @@global.tmp_table_size = 1024; SELECT @@global.tmp_table_size; @@ -79,7 +75,6 @@ Warning 1292 Truncated incorrect tmp_table_size value: '1000' SELECT @@global.tmp_table_size; @@global.tmp_table_size 1024 -'Bug # 34837: Errors are not coming on assigning invalid values to variable'; SET @@global.tmp_table_size = ON; ERROR 42000: Incorrect argument type to variable 'tmp_table_size' SET @@global.tmp_table_size = OFF; @@ -96,7 +91,6 @@ Warning 1292 Truncated incorrect tmp_table_size value: '0' SELECT @@global.tmp_table_size; @@global.tmp_table_size 1024 -'Bug:Error should be shown that variable is numeric and can not assigned boolean value'; SET @@global.tmp_table_size = 65530.34; ERROR 42000: Incorrect argument type to variable 'tmp_table_size' SET @@global.tmp_table_size ="Test"; diff --git a/mysql-test/suite/sys_vars/r/tmp_table_size_basic_64.result b/mysql-test/suite/sys_vars/r/tmp_table_size_basic_64.result index 837b90fc143..73ebaecf5f0 100644 --- a/mysql-test/suite/sys_vars/r/tmp_table_size_basic_64.result +++ b/mysql-test/suite/sys_vars/r/tmp_table_size_basic_64.result @@ -6,7 +6,6 @@ SET @start_session_value = @@session.tmp_table_size; SELECT @start_session_value; @start_session_value 16777216 -'Bug# 34876: This variable has invalid default value as compared to documentation'; '#--------------------FN_DYNVARS_005_01-------------------------#' SET @@global.tmp_table_size = 100; Warnings: @@ -15,7 +14,6 @@ SET @@global.tmp_table_size = DEFAULT; SELECT @@global.tmp_table_size; @@global.tmp_table_size 16777216 -'Bug# 34876: This variable has invalid default value as compared to documentation'; SET @@session.tmp_table_size = 200; Warnings: Warning 1292 Truncated incorrect tmp_table_size value: '200' @@ -23,7 +21,6 @@ SET @@session.tmp_table_size = DEFAULT; SELECT @@session.tmp_table_size; @@session.tmp_table_size 16777216 -'Bug# 34876: This variable has invalid default value as compared to documentation'; '#--------------------FN_DYNVARS_005_02-------------------------#' SET @@global.tmp_table_size = DEFAULT; SELECT @@global.tmp_table_size = 33554432; @@ -33,7 +30,6 @@ SET @@session.tmp_table_size = DEFAULT; SELECT @@session.tmp_table_size = 33554432; @@session.tmp_table_size = 33554432 0 -'Bug# 34876: This variable has invalid default value as compared to documentation'; '#--------------------FN_DYNVARS_005_03-------------------------#' SET @@global.tmp_table_size = 1024; SELECT @@global.tmp_table_size; @@ -79,7 +75,6 @@ Warning 1292 Truncated incorrect tmp_table_size value: '1000' SELECT @@global.tmp_table_size; @@global.tmp_table_size 1024 -'Bug # 34837: Errors are not coming on assigning invalid values to variable'; SET @@global.tmp_table_size = ON; ERROR 42000: Incorrect argument type to variable 'tmp_table_size' SET @@global.tmp_table_size = OFF; @@ -96,7 +91,6 @@ Warning 1292 Truncated incorrect tmp_table_size value: '0' SELECT @@global.tmp_table_size; @@global.tmp_table_size 1024 -'Bug:Error should be shown that variable is numeric and can not assigned boolean value'; SET @@global.tmp_table_size = 65530.34; ERROR 42000: Incorrect argument type to variable 'tmp_table_size' SET @@global.tmp_table_size ="Test"; From 5f7869a22a4068ae052680630a6d062208ec27a6 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 3 Dec 2008 19:15:39 +0300 Subject: [PATCH 015/137] Fix for bug #27483: Casting 'scientific notation type' to 'unsigned bigint' fails on windows. Visual Studio does not take into account some x86 hardware limitations which leads to incorrect results when converting large DOUBLE values to BIGINT UNSIGNED ones. Fixed by adding a workaround for double->ulonglong conversion on Windows. --- include/config-win.h | 9 +++++++++ include/my_global.h | 3 +++ mysql-test/r/type_float.result | 13 +++++++++++++ mysql-test/t/type_float.test | 17 +++++++++++++++++ 4 files changed, 42 insertions(+) diff --git a/include/config-win.h b/include/config-win.h index 2628095a181..eba699159c7 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -245,6 +245,15 @@ inline double ulonglong2double(ulonglong value) #define my_off_t2double(A) ulonglong2double(A) #endif /* _WIN64 */ +inline ulonglong double2ulonglong(double d) +{ + double t= d - (double) 0x8000000000000000ULL; + + if (t >= 0) + return ((ulonglong) t) + 0x8000000000000000ULL; + return (ulonglong) d; +} + #if SIZEOF_OFF_T > 4 #define lseek(A,B,C) _lseeki64((A),(longlong) (B),(C)) #define tell(A) _telli64(A) diff --git a/include/my_global.h b/include/my_global.h index e474b620d27..845ae042a42 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -713,6 +713,9 @@ typedef SOCKET_SIZE_TYPE size_socket; #define ulonglong2double(A) ((double) (ulonglong) (A)) #define my_off_t2double(A) ((double) (my_off_t) (A)) #endif +#ifndef double2ulonglong +#define double2ulonglong(A) ((ulonglong) (double) (A)) +#endif #endif #ifndef offsetof diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result index f1075604ca9..e7f17bd75a7 100644 --- a/mysql-test/r/type_float.result +++ b/mysql-test/r/type_float.result @@ -392,4 +392,17 @@ f1 + 0e0 1.0000000150475e+30 -1.0000000150475e+30 drop table t1; +create table t1(d double, u bigint unsigned); +insert into t1(d) values (9.2233720368547777e+18), +(9.223372036854779e18), +(9.22337203685479e18), +(1.84e19); +update t1 set u = d; +select * from t1; +d u +9.22337203685478e+18 9223372036854775808 +9.22337203685478e+18 9223372036854779904 +9.22337203685479e+18 9223372036854790144 +1.84e+19 18400000000000000000 +drop table t1; End of 5.0 tests diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test index 9aa8c00d24a..b23755b44fb 100644 --- a/mysql-test/t/type_float.test +++ b/mysql-test/t/type_float.test @@ -252,4 +252,21 @@ insert into t1 values (2e30), (-2e30); select f1 + 0e0 from t1; drop table t1; +# +# Bug #27483: Casting 'scientific notation type' to 'unsigned bigint' fails on +# windows. +# + +create table t1(d double, u bigint unsigned); + +insert into t1(d) values (9.2233720368547777e+18), + (9.223372036854779e18), + (9.22337203685479e18), + (1.84e19); + +update t1 set u = d; +select * from t1; + +drop table t1; + --echo End of 5.0 tests From 82757fdfc02f8fbe8d5fdfae0cd67aa60fa9863c Mon Sep 17 00:00:00 2001 From: Mats Kindahl Date: Wed, 3 Dec 2008 20:55:49 +0100 Subject: [PATCH 016/137] Bug #40116: Uncommited changes are replicated and stay on slave after rollback on master When starting a transaction with a statement containing changes to both transactional tables and non-transactional tables, the statement is considered as non-transactional and is therefore written directly to the binary log. This behaviour was present in 5.0, and has propagated to 5.1. If a trigger containing a change of a non-transactional table is added to a transactional table, any changes to the transactional table is "tainted" as non-transactional. This patch solves the problem by removing the existing "hack" that allows non-transactional statements appearing first in a transaction to be written directly to the binary log. Instead, anything inside a transaction is treaded as part of the transaction and not written to the binary log until the transaction is committed. --- .../r/binlog_row_mix_innodb_myisam.result | 24 ++--- .../suite/rpl/r/rpl_row_create_table.result | 95 ++++++++++++------- mysql-test/suite/rpl/r/rpl_slave_skip.result | 1 + mysql-test/suite/rpl/r/rpl_trigger.result | 26 +++++ .../suite/rpl/t/rpl_row_create_table.test | 28 ++++-- mysql-test/suite/rpl/t/rpl_slave_skip.test | 1 + mysql-test/suite/rpl/t/rpl_trigger.test | 42 ++++++-- sql/log.cc | 61 +----------- 8 files changed, 152 insertions(+), 126 deletions(-) diff --git a/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result b/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result index 7106480663f..0b33d71b6f1 100644 --- a/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result +++ b/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result @@ -133,10 +133,6 @@ master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # use `test`; BEGIN -master-bin.000001 # Table_map # # table_id: # (test.t2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT insert into t1 values(11); commit; show binlog events from ; @@ -148,8 +144,6 @@ master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT -master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ @@ -278,10 +272,6 @@ master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # use `test`; BEGIN -master-bin.000001 # Table_map # # table_id: # (test.t2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT master-bin.000001 # Query # # use `test`; drop table t1,t2 master-bin.000001 # Query # # use `test`; create table t0 (n int) master-bin.000001 # Query # # use `test`; BEGIN @@ -382,7 +372,7 @@ master-bin.000001 # Query # # use `test`; DROP TABLE if exists t2 master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # use `test`; ROLLBACK master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS t2 master-bin.000001 # Query # # use `test`; CREATE TABLE t2 (a int, b int, primary key (a)) engine=innodb master-bin.000001 # Query # # use `test`; BEGIN @@ -395,12 +385,16 @@ master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map # # table_id: # (test.t2) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Query # # use `test`; COMMIT master-bin.000001 # Query # # use `test`; DROP TABLE t2 master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # use `test`; ROLLBACK master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F @@ -408,11 +402,7 @@ master-bin.000001 # Query # # use `test`; COMMIT master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT -master-bin.000001 # Query # # use `test`; BEGIN -master-bin.000001 # Table_map # # table_id: # (test.t1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # use `test`; ROLLBACK master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Query # # use `test`; TRUNCATE table t2 master-bin.000001 # Query # # use `test`; COMMIT diff --git a/mysql-test/suite/rpl/r/rpl_row_create_table.result b/mysql-test/suite/rpl/r/rpl_row_create_table.result index ad659c37b7f..5d6587a5fce 100644 --- a/mysql-test/suite/rpl/r/rpl_row_create_table.result +++ b/mysql-test/suite/rpl/r/rpl_row_create_table.result @@ -4,34 +4,39 @@ reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; +**** Resetting master and slave **** +STOP SLAVE; +RESET SLAVE; +RESET MASTER; +START SLAVE; CREATE TABLE t1 (a INT, b INT); CREATE TABLE t2 (a INT, b INT) ENGINE=Merge; CREATE TABLE t3 (a INT, b INT) CHARSET=utf8; CREATE TABLE t4 (a INT, b INT) ENGINE=Merge CHARSET=utf8; -SHOW BINLOG EVENTS FROM 216; +SHOW BINLOG EVENTS FROM 106; Log_name # -Pos 216 +Pos 106 Event_type Query Server_id # -End_log_pos 309 +End_log_pos 199 Info use `test`; CREATE TABLE t1 (a INT, b INT) Log_name # -Pos 309 +Pos 199 Event_type Query Server_id # -End_log_pos 415 +End_log_pos 305 Info use `test`; CREATE TABLE t2 (a INT, b INT) ENGINE=Merge Log_name # -Pos 415 +Pos 305 Event_type Query Server_id # -End_log_pos 521 +End_log_pos 411 Info use `test`; CREATE TABLE t3 (a INT, b INT) CHARSET=utf8 Log_name # -Pos 521 +Pos 411 Event_type Query Server_id # -End_log_pos 640 +End_log_pos 530 Info use `test`; CREATE TABLE t4 (a INT, b INT) ENGINE=Merge CHARSET=utf8 **** On Master **** SHOW CREATE TABLE t1; @@ -125,9 +130,14 @@ NULL 3 6 NULL 4 2 NULL 5 10 NULL 6 12 +**** Resetting master and slave **** +STOP SLAVE; +RESET SLAVE; +RESET MASTER; +START SLAVE; CREATE TABLE t7 (UNIQUE(b)) SELECT a,b FROM tt3; ERROR 23000: Duplicate entry '2' for key 'b' -SHOW BINLOG EVENTS FROM 1374; +SHOW BINLOG EVENTS FROM 106; Log_name Pos Event_type Server_id End_log_pos Info CREATE TABLE t7 (a INT, b INT UNIQUE); INSERT INTO t7 SELECT a,b FROM tt3; @@ -137,18 +147,23 @@ a b 1 2 2 4 3 6 -SHOW BINLOG EVENTS FROM 1374; +SHOW BINLOG EVENTS FROM 106; Log_name Pos Event_type Server_id End_log_pos Info -# 1374 Query # 1474 use `test`; CREATE TABLE t7 (a INT, b INT UNIQUE) -# 1474 Query # 1542 use `test`; BEGIN -# 1542 Table_map # 1584 table_id: # (test.t7) -# 1584 Write_rows # 1640 table_id: # flags: STMT_END_F -# 1640 Query # 1711 use `test`; ROLLBACK +# 106 Query # 206 use `test`; CREATE TABLE t7 (a INT, b INT UNIQUE) +# 206 Query # 274 use `test`; BEGIN +# 274 Table_map # 316 table_id: # (test.t7) +# 316 Write_rows # 372 table_id: # flags: STMT_END_F +# 372 Query # 443 use `test`; ROLLBACK SELECT * FROM t7 ORDER BY a,b; a b 1 2 2 4 3 6 +**** Resetting master and slave **** +STOP SLAVE; +RESET SLAVE; +RESET MASTER; +START SLAVE; CREATE TEMPORARY TABLE tt4 (a INT, b INT); INSERT INTO tt4 VALUES (4,8), (5,10), (6,12); BEGIN; @@ -156,12 +171,12 @@ INSERT INTO t7 SELECT a,b FROM tt4; ROLLBACK; Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back -SHOW BINLOG EVENTS FROM 1711; +SHOW BINLOG EVENTS FROM 106; Log_name Pos Event_type Server_id End_log_pos Info -# 1711 Query # 1779 use `test`; BEGIN -# 1779 Table_map # 1821 table_id: # (test.t7) -# 1821 Write_rows # 1877 table_id: # flags: STMT_END_F -# 1877 Query # 1946 use `test`; COMMIT +# 106 Query # 174 use `test`; BEGIN +# 174 Table_map # 216 table_id: # (test.t7) +# 216 Write_rows # 272 table_id: # flags: STMT_END_F +# 272 Query # 343 use `test`; ROLLBACK SELECT * FROM t7 ORDER BY a,b; a b 1 2 @@ -178,6 +193,11 @@ a b 4 8 5 10 6 12 +**** Resetting master and slave **** +STOP SLAVE; +RESET SLAVE; +RESET MASTER; +START SLAVE; CREATE TABLE t8 LIKE t4; CREATE TABLE t9 LIKE tt4; CREATE TEMPORARY TABLE tt5 LIKE t4; @@ -196,10 +216,10 @@ Create Table CREATE TABLE `t9` ( `a` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -SHOW BINLOG EVENTS FROM 1946; +SHOW BINLOG EVENTS FROM 106; Log_name Pos Event_type Server_id End_log_pos Info -# 1946 Query # 2032 use `test`; CREATE TABLE t8 LIKE t4 -# 2032 Query # 2171 use `test`; CREATE TABLE `t9` ( +# 106 Query # 192 use `test`; CREATE TABLE t8 LIKE t4 +# 192 Query # 331 use `test`; CREATE TABLE `t9` ( `a` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL ) @@ -276,9 +296,8 @@ a 1 2 3 -SHOW BINLOG EVENTS; +SHOW BINLOG EVENTS FROM 106; Log_name Pos Event_type Server_id End_log_pos Info -# 4 Format_desc # 106 Server ver: #, Binlog ver: # # 106 Query # 192 use `test`; CREATE TABLE t1 (a INT) # 192 Query # 260 use `test`; BEGIN # 260 Table_map # 301 table_id: # (test.t1) @@ -308,7 +327,7 @@ Log_name Pos Event_type Server_id End_log_pos Info # 1329 Query # 1397 use `test`; BEGIN # 1397 Table_map # 1438 table_id: # (test.t1) # 1438 Write_rows # 1482 table_id: # flags: STMT_END_F -# 1482 Query # 1551 use `test`; COMMIT +# 1482 Query # 1553 use `test`; ROLLBACK SHOW TABLES; Tables_in_test t1 @@ -371,9 +390,8 @@ a 4 6 9 -SHOW BINLOG EVENTS; +SHOW BINLOG EVENTS FROM 106; Log_name Pos Event_type Server_id End_log_pos Info -# 4 Format_desc # 106 Server ver: #, Binlog ver: # # 106 Query # 192 use `test`; CREATE TABLE t1 (a INT) # 192 Query # 260 use `test`; BEGIN # 260 Table_map # 301 table_id: # (test.t1) @@ -394,6 +412,11 @@ a 6 9 TRUNCATE TABLE t2; +**** Resetting master and slave **** +STOP SLAVE; +RESET SLAVE; +RESET MASTER; +START SLAVE; BEGIN; INSERT INTO t2 SELECT a*a FROM t1; CREATE TEMPORARY TABLE tt2 @@ -406,14 +429,14 @@ Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back SELECT * FROM t2 ORDER BY a; a -SHOW BINLOG EVENTS FROM 949; +SHOW BINLOG EVENTS FROM 106; Log_name Pos Event_type Server_id End_log_pos Info -# 949 Query # 1017 use `test`; BEGIN -# 1017 Table_map # 1058 table_id: # (test.t2) -# 1058 Write_rows # 1102 table_id: # flags: STMT_END_F -# 1102 Table_map # 1143 table_id: # (test.t2) -# 1143 Write_rows # 1182 table_id: # flags: STMT_END_F -# 1182 Query # 1253 use `test`; ROLLBACK +# 106 Query # 174 use `test`; BEGIN +# 174 Table_map # 215 table_id: # (test.t2) +# 215 Write_rows # 259 table_id: # flags: STMT_END_F +# 259 Table_map # 300 table_id: # (test.t2) +# 300 Write_rows # 339 table_id: # flags: STMT_END_F +# 339 Query # 410 use `test`; ROLLBACK SELECT * FROM t2 ORDER BY a; a DROP TABLE t1,t2; diff --git a/mysql-test/suite/rpl/r/rpl_slave_skip.result b/mysql-test/suite/rpl/r/rpl_slave_skip.result index bb03c3b6cca..9784d6372d2 100644 --- a/mysql-test/suite/rpl/r/rpl_slave_skip.result +++ b/mysql-test/suite/rpl/r/rpl_slave_skip.result @@ -174,6 +174,7 @@ DROP TRIGGER tr2; INSERT INTO t1 VALUES (3,'master/slave'); INSERT INTO t2 VALUES (3,'master/slave'); INSERT INTO t3 VALUES (3,'master/slave'); +COMMIT; SELECT * FROM t1 ORDER BY a; a b 2 master only diff --git a/mysql-test/suite/rpl/r/rpl_trigger.result b/mysql-test/suite/rpl/r/rpl_trigger.result index 68c82ed037f..5cc75013bf7 100644 --- a/mysql-test/suite/rpl/r/rpl_trigger.result +++ b/mysql-test/suite/rpl/r/rpl_trigger.result @@ -975,3 +975,29 @@ a b 2 b 3 c drop table t1; +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +create table t1 ( f int ) engine = innodb; +create table log ( r int ) engine = myisam; +create trigger tr +after insert on t1 +for each row insert into log values ( new.f ); +set autocommit = 0; +insert into t1 values ( 1 ); +select * from t1; +f +1 +select * from t1; +f +rollback; +Warnings: +Warning 1196 Some non-transactional changed tables couldn't be rolled back +select * from t1; +f +select * from t1; +f +drop table t1, log; diff --git a/mysql-test/suite/rpl/t/rpl_row_create_table.test b/mysql-test/suite/rpl/t/rpl_row_create_table.test index 3fb5aa8e1f2..d74eb873270 100644 --- a/mysql-test/suite/rpl/t/rpl_row_create_table.test +++ b/mysql-test/suite/rpl/t/rpl_row_create_table.test @@ -29,6 +29,8 @@ SET GLOBAL storage_engine=memory; START SLAVE; --enable_query_log +--source include/reset_master_and_slave.inc + connection master; CREATE TABLE t1 (a INT, b INT); CREATE TABLE t2 (a INT, b INT) ENGINE=Merge; @@ -36,7 +38,7 @@ CREATE TABLE t3 (a INT, b INT) CHARSET=utf8; CREATE TABLE t4 (a INT, b INT) ENGINE=Merge CHARSET=utf8; --replace_column 1 # 4 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ ---query_vertical SHOW BINLOG EVENTS FROM 216 +--query_vertical SHOW BINLOG EVENTS FROM 106 --echo **** On Master **** --query_vertical SHOW CREATE TABLE t1 --query_vertical SHOW CREATE TABLE t2 @@ -65,6 +67,8 @@ SELECT * FROM t5 ORDER BY a,b,c; --query_vertical SHOW CREATE TABLE t6 SELECT * FROM t6 ORDER BY a,b,c; +--source include/reset_master_and_slave.inc + connection master; # Test for erroneous constructions --error ER_DUP_ENTRY @@ -72,7 +76,7 @@ CREATE TABLE t7 (UNIQUE(b)) SELECT a,b FROM tt3; # Shouldn't be written to the binary log --replace_column 1 # 4 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ -SHOW BINLOG EVENTS FROM 1374; +SHOW BINLOG EVENTS FROM 106; # Test that INSERT-SELECT works the same way as for SBR. CREATE TABLE t7 (a INT, b INT UNIQUE); @@ -82,10 +86,12 @@ SELECT * FROM t7 ORDER BY a,b; # Should be written to the binary log --replace_column 1 # 4 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ -SHOW BINLOG EVENTS FROM 1374; +SHOW BINLOG EVENTS FROM 106; sync_slave_with_master; SELECT * FROM t7 ORDER BY a,b; +--source include/reset_master_and_slave.inc + connection master; CREATE TEMPORARY TABLE tt4 (a INT, b INT); INSERT INTO tt4 VALUES (4,8), (5,10), (6,12); @@ -94,11 +100,13 @@ INSERT INTO t7 SELECT a,b FROM tt4; ROLLBACK; --replace_column 1 # 4 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ -SHOW BINLOG EVENTS FROM 1711; +SHOW BINLOG EVENTS FROM 106; SELECT * FROM t7 ORDER BY a,b; sync_slave_with_master; SELECT * FROM t7 ORDER BY a,b; +--source include/reset_master_and_slave.inc + connection master; CREATE TABLE t8 LIKE t4; CREATE TABLE t9 LIKE tt4; @@ -110,7 +118,7 @@ CREATE TEMPORARY TABLE tt7 SELECT 1; --query_vertical SHOW CREATE TABLE t9 --replace_column 1 # 4 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ -SHOW BINLOG EVENTS FROM 1946; +SHOW BINLOG EVENTS FROM 106; sync_slave_with_master; --echo **** On Slave **** --query_vertical SHOW CREATE TABLE t8 @@ -162,7 +170,7 @@ SELECT * FROM t3 ORDER BY a; SELECT * FROM t4 ORDER BY a; --replace_column 1 # 4 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/ -SHOW BINLOG EVENTS; +SHOW BINLOG EVENTS FROM 106; sync_slave_with_master; SHOW TABLES; SELECT TABLE_NAME,ENGINE @@ -208,13 +216,17 @@ COMMIT; SELECT * FROM t2 ORDER BY a; --replace_column 1 # 4 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/ -SHOW BINLOG EVENTS; +SHOW BINLOG EVENTS FROM 106; sync_slave_with_master; SELECT * FROM t2 ORDER BY a; connection master; TRUNCATE TABLE t2; +sync_slave_with_master; +--source include/reset_master_and_slave.inc + +connection master; BEGIN; INSERT INTO t2 SELECT a*a FROM t1; CREATE TEMPORARY TABLE tt2 @@ -227,7 +239,7 @@ ROLLBACK; SELECT * FROM t2 ORDER BY a; --replace_column 1 # 4 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/ -SHOW BINLOG EVENTS FROM 949; +SHOW BINLOG EVENTS FROM 106; sync_slave_with_master; SELECT * FROM t2 ORDER BY a; diff --git a/mysql-test/suite/rpl/t/rpl_slave_skip.test b/mysql-test/suite/rpl/t/rpl_slave_skip.test index 8a5b1ae0ae4..da25e5631c0 100644 --- a/mysql-test/suite/rpl/t/rpl_slave_skip.test +++ b/mysql-test/suite/rpl/t/rpl_slave_skip.test @@ -121,6 +121,7 @@ DROP TRIGGER tr2; INSERT INTO t1 VALUES (3,'master/slave'); INSERT INTO t2 VALUES (3,'master/slave'); INSERT INTO t3 VALUES (3,'master/slave'); +COMMIT; SELECT * FROM t1 ORDER BY a; SELECT * FROM t2 ORDER BY a; diff --git a/mysql-test/suite/rpl/t/rpl_trigger.test b/mysql-test/suite/rpl/t/rpl_trigger.test index 911110d17dc..8e911178dcc 100644 --- a/mysql-test/suite/rpl/t/rpl_trigger.test +++ b/mysql-test/suite/rpl/t/rpl_trigger.test @@ -467,20 +467,46 @@ drop trigger if exists t1_bi; insert into t1 values (3, "c"); select * from t1; - -save_master_pos; -connection slave; -sync_with_master; - +sync_slave_with_master; select * from t1; connection master; drop table t1; +sync_slave_with_master; + +# +# Bug#40116: Uncommited changes are replicated and stay on slave after +# rollback on master +# + +source include/master-slave-reset.inc; +source include/have_innodb.inc; + +connection master; +create table t1 ( f int ) engine = innodb; +create table log ( r int ) engine = myisam; +create trigger tr + after insert on t1 + for each row insert into log values ( new.f ); + +set autocommit = 0; +insert into t1 values ( 1 ); + +select * from t1; +sync_slave_with_master; +select * from t1; + +connection master; +rollback; +select * from t1; +sync_slave_with_master; +select * from t1; + +connection master; +drop table t1, log; +sync_slave_with_master; # # End of tests # -save_master_pos; -connection slave; -sync_with_master; diff --git a/sql/log.cc b/sql/log.cc index fb8669a5731..3ebf2a7c03e 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1478,60 +1478,11 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all) } /* - Decision table for committing a transaction. The top part, the - *conditions* represent different cases that can occur, and hte - bottom part, the *actions*, represent what should be done in that - particular case. + We commit the transaction if: - Real transaction 'all' was true + - We are not in a transaction and committing a statement, or - Statement in cache There were at least one statement in the - transaction cache - - In transaction We are inside a transaction - - Stmt modified non-trans The statement being committed modified a - non-transactional table - - All modified non-trans Some statement before this one in the - transaction modified a non-transactional - table - - - ============================= = = = = = = = = = = = = = = = = - Real transaction N N N N N N N N N N N N N N N N - Statement in cache N N N N N N N N Y Y Y Y Y Y Y Y - In transaction N N N N Y Y Y Y N N N N Y Y Y Y - Stmt modified non-trans N N Y Y N N Y Y N N Y Y N N Y Y - All modified non-trans N Y N Y N Y N Y N Y N Y N Y N Y - - Action: (C)ommit/(A)ccumulate C C - C A C - C - - - - A A - A - ============================= = = = = = = = = = = = = = = = = - - - ============================= = = = = = = = = = = = = = = = = - Real transaction Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y - Statement in cache N N N N N N N N Y Y Y Y Y Y Y Y - In transaction N N N N Y Y Y Y N N N N Y Y Y Y - Stmt modified non-trans N N Y Y N N Y Y N N Y Y N N Y Y - All modified non-trans N Y N Y N Y N Y N Y N Y N Y N Y - - (C)ommit/(A)ccumulate/(-) - - - - C C - C - - - - C C - C - ============================= = = = = = = = = = = = = = = = = - - In other words, we commit the transaction if and only if both of - the following are true: - - We are not in a transaction and committing a statement - - - We are in a transaction and one (or more) of the following are - true: - - - A full transaction is committed - - OR - - - A non-transactional statement is committed and there is - no statement cached + - We are in a transaction and a full transaction is committed Otherwise, we accumulate the statement */ @@ -1544,11 +1495,7 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all) YESNO(in_transaction), YESNO(thd->transaction.all.modified_non_trans_table), YESNO(thd->transaction.stmt.modified_non_trans_table))); - if (in_transaction && - (all || - (!trx_data->at_least_one_stmt && - thd->transaction.stmt.modified_non_trans_table)) || - !in_transaction && !all) + if (!in_transaction || all) { Query_log_event qev(thd, STRING_WITH_LEN("COMMIT"), TRUE, FALSE); qev.error_code= 0; // see comment in MYSQL_LOG::write(THD, IO_CACHE) From 5726574b0c11b90047e326f8b36350c82485519f Mon Sep 17 00:00:00 2001 From: Luis Soares Date: Thu, 4 Dec 2008 01:01:03 +0000 Subject: [PATCH 017/137] BUG#38826 Race in MYSQL_LOG::purge_logs is impossible to debug in production BUG#39325 Server crash inside MYSQL_LOG::purge_first_log halts replicaiton The patch reverses the order of the purging and updating events for log and relay-log.info/index files respectively. This solves the problem of having holes caused by crashes happening between updating info/index files and purging logs. NOTE: This is a combined patch for BUG#38826 and BUG#39325. This patch is based on bugteam tree and takes into account reviewers suggestions. --- mysql-test/r/binlog_index.result | 1 + sql/log.cc | 212 +++++++++++++++++++------------ sql/sql_class.h | 7 + 3 files changed, 141 insertions(+), 79 deletions(-) diff --git a/mysql-test/r/binlog_index.result b/mysql-test/r/binlog_index.result index 82fc26092f4..b307b97e460 100644 --- a/mysql-test/r/binlog_index.result +++ b/mysql-test/r/binlog_index.result @@ -21,6 +21,7 @@ flush logs; *** must be a warning master-bin.000001 was not found *** Warnings: Warning 1477 Being purged log MYSQLTEST_VARDIR/log/master-bin.000001 was not found +Warning 1477 Being purged log MYSQLTEST_VARDIR/log/master-bin.000001 was not found *** must show one record, of the active binlog, left in the index file after PURGE *** show binary logs; Log_name File_size diff --git a/sql/log.cc b/sql/log.cc index 5a1cfe46686..477cb21b2f3 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -417,6 +417,7 @@ MYSQL_LOG::MYSQL_LOG() index_file_name[0] = 0; bzero((char*) &log_file,sizeof(log_file)); bzero((char*) &index_file, sizeof(index_file)); + bzero((char*) &purge_temp, sizeof(purge_temp)); } /* this is called only once */ @@ -1059,10 +1060,10 @@ err: IMPLEMENTATION - Protects index file with LOCK_index + - Read the next file name from the index file and store in rli->linfo - Delete relevant relay log files - Copy all file names after these ones to the front of the index file - If the OS has truncate, truncate the file, else fill it with \n' - - Read the next file name from the index file and store in rli->linfo RETURN VALUES 0 ok @@ -1076,6 +1077,7 @@ err: int MYSQL_LOG::purge_first_log(struct st_relay_log_info* rli, bool included) { int error; + char *to_purge_if_included= NULL; DBUG_ENTER("purge_first_log"); DBUG_ASSERT(is_open()); @@ -1083,36 +1085,20 @@ int MYSQL_LOG::purge_first_log(struct st_relay_log_info* rli, bool included) DBUG_ASSERT(!strcmp(rli->linfo.log_file_name,rli->event_relay_log_name)); pthread_mutex_lock(&LOCK_index); - pthread_mutex_lock(&rli->log_space_lock); - rli->relay_log.purge_logs(rli->group_relay_log_name, included, - 0, 0, &rli->log_space_total); - // Tell the I/O thread to take the relay_log_space_limit into account - rli->ignore_log_space_limit= 0; - pthread_mutex_unlock(&rli->log_space_lock); + to_purge_if_included= my_strdup(rli->group_relay_log_name, MYF(0)); - /* - Ok to broadcast after the critical region as there is no risk of - the mutex being destroyed by this thread later - this helps save - context switches - */ - pthread_cond_broadcast(&rli->log_space_cond); - /* Read the next log file name from the index file and pass it back to - the caller - If included is true, we want the first relay log; - otherwise we want the one after event_relay_log_name. + the caller. */ - if ((included && (error=find_log_pos(&rli->linfo, NullS, 0))) || - (!included && - ((error=find_log_pos(&rli->linfo, rli->event_relay_log_name, 0)) || - (error=find_next_log(&rli->linfo, 0))))) + if((error=find_log_pos(&rli->linfo, rli->event_relay_log_name, 0)) || + (error=find_next_log(&rli->linfo, 0))) { char buff[22]; sql_print_error("next log error: %d offset: %s log: %s included: %d", error, llstr(rli->linfo.index_file_offset,buff), - rli->group_relay_log_name, + rli->event_relay_log_name, included); goto err; } @@ -1140,7 +1126,42 @@ int MYSQL_LOG::purge_first_log(struct st_relay_log_info* rli, bool included) /* Store where we are in the new file for the execution thread */ flush_relay_log_info(rli); + DBUG_EXECUTE_IF("crash_before_purge_logs", abort();); + + pthread_mutex_lock(&rli->log_space_lock); + rli->relay_log.purge_logs(to_purge_if_included, included, + 0, 0, &rli->log_space_total); + // Tell the I/O thread to take the relay_log_space_limit into account + rli->ignore_log_space_limit= 0; + pthread_mutex_unlock(&rli->log_space_lock); + + /* + Ok to broadcast after the critical region as there is no risk of + the mutex being destroyed by this thread later - this helps save + context switches + */ + pthread_cond_broadcast(&rli->log_space_cond); + + /* + * Need to update the log pos because purge logs has been called + * after fetching initially the log pos at the begining of the method. + */ + if(error=find_log_pos(&rli->linfo, rli->event_relay_log_name, 0)) + { + char buff[22]; + sql_print_error("next log error: %d offset: %s log: %s included: %d", + error, + llstr(rli->linfo.index_file_offset,buff), + rli->group_relay_log_name, + included); + goto err; + } + + /* If included was passed, rli->linfo should be the first entry. */ + DBUG_ASSERT(!included || rli->linfo.index_file_start_offset == 0); + err: + my_free(to_purge_if_included, MYF(0)); pthread_mutex_unlock(&LOCK_index); DBUG_RETURN(error); } @@ -1199,8 +1220,36 @@ int MYSQL_LOG::purge_logs(const char *to_log, if (need_mutex) pthread_mutex_lock(&LOCK_index); - if ((error=find_log_pos(&log_info, to_log, 0 /*no mutex*/))) + if ((error=find_log_pos(&log_info, to_log, 0 /*no mutex*/))) + { + sql_print_error("MYSQL_LOG::purge_logs was called with file %s not " + "listed in the index.", to_log); goto err; + } + + /* + For crash recovery reasons the index needs to be updated before + any files are deleted. Move files to be deleted into a temp file + to be processed after the index is updated. + */ + if (!my_b_inited(&purge_temp)) + { + if (error=open_cached_file(&purge_temp, mysql_tmpdir, TEMP_PREFIX, + DISK_BUFFER_SIZE, MYF(MY_WME))) + { + sql_print_error("MYSQL_LOG::purge_logs failed to open purge_temp"); + goto err; + } + } + else + { + if (error=reinit_io_cache(&purge_temp, WRITE_CACHE, 0, 0, 1)) + { + sql_print_error("MYSQL_LOG::purge_logs failed to reinit purge_temp " + "for write"); + goto err; + } + } /* File name exists in index file; delete until we find this file @@ -1211,6 +1260,59 @@ int MYSQL_LOG::purge_logs(const char *to_log, while ((strcmp(to_log,log_info.log_file_name) || (exit_loop=included)) && !log_in_use(log_info.log_file_name)) { + if ((error=my_b_write(&purge_temp, (byte*)log_info.log_file_name, + strlen(log_info.log_file_name))) || + (error=my_b_write(&purge_temp, (byte*)"\n", 1))) + { + sql_print_error("MYSQL_LOG::purge_logs failed to copy %s to purge_temp", + log_info.log_file_name); + goto err; + } + + if (find_next_log(&log_info, 0) || exit_loop) + break; + } + + /* We know how many files to delete. Update index file. */ + if (error=update_log_index(&log_info, need_update_threads)) + { + sql_print_error("MSYQL_LOG::purge_logs failed to update the index file"); + goto err; + } + + DBUG_EXECUTE_IF("crash_after_update_index", abort();); + + /* Switch purge_temp for read. */ + if (error=reinit_io_cache(&purge_temp, READ_CACHE, 0, 0, 0)) + { + sql_print_error("MSYQL_LOG::purge_logs failed to reinit purge_temp " + "for read"); + goto err; + } + + /* Read each entry from purge_temp and delete the file. */ + for (;;) + { + uint length; + + if ((length=my_b_gets(&purge_temp, log_info.log_file_name, + FN_REFLEN)) <= 1) + { + if (purge_temp.error) + { + error= purge_temp.error; + sql_print_error("MSYQL_LOG::purge_logs error %d reading from " + "purge_temp", error); + goto err; + } + + /* Reached EOF */ + break; + } + + /* Get rid of the trailing '\n' */ + log_info.log_file_name[length-1]= 0; + MY_STAT s; if (!my_stat(log_info.log_file_name, &s, MYF(0))) { @@ -1304,15 +1406,7 @@ int MYSQL_LOG::purge_logs(const char *to_log, } } } - if (find_next_log(&log_info, 0) || exit_loop) - break; } - - /* - If we get killed -9 here, the sysadmin would have to edit - the log index file after restart - otherwise, this should be safe - */ - error= update_log_index(&log_info, need_update_threads); err: if (need_mutex) @@ -1326,7 +1420,6 @@ err: SYNOPSIS purge_logs_before_date() - thd Thread pointer before_date Delete all log files before given date. NOTES @@ -1343,6 +1436,7 @@ err: int MYSQL_LOG::purge_logs_before_date(time_t purge_time) { int error; + char to_log[FN_REFLEN]; LOG_INFO log_info; MY_STAT stat_area; THD *thd= current_thd; @@ -1350,12 +1444,8 @@ int MYSQL_LOG::purge_logs_before_date(time_t purge_time) DBUG_ENTER("purge_logs_before_date"); pthread_mutex_lock(&LOCK_index); + to_log[0]= 0; - /* - Delete until we find curren file - or a file that is used or a file - that is older than purge_time. - */ if ((error=find_log_pos(&log_info, NullS, 0 /*no mutex*/))) goto err; @@ -1405,54 +1495,18 @@ int MYSQL_LOG::purge_logs_before_date(time_t purge_time) } else { - if (stat_area.st_mtime >= purge_time) + if (stat_area.st_mtime < purge_time) + strmake(to_log, + log_info.log_file_name, + sizeof(log_info.log_file_name)); + else break; - if (my_delete(log_info.log_file_name, MYF(0))) - { - if (my_errno == ENOENT) - { - /* It's not fatal even if we can't delete a log file */ - if (thd) - { - push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, - ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE), - log_info.log_file_name); - } - sql_print_information("Failed to delete file '%s'", - log_info.log_file_name); - my_errno= 0; - } - else - { - if (thd) - { - push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, - ER_BINLOG_PURGE_FATAL_ERR, - "a problem with deleting %s; " - "consider examining correspondence " - "of your binlog index file " - "to the actual binlog files", - log_info.log_file_name); - } - else - { - sql_print_information("Failed to delete log file '%s'", - log_info.log_file_name); - } - error= LOG_INFO_FATAL; - goto err; - } - } } if (find_next_log(&log_info, 0)) break; } - /* - If we get killed -9 here, the sysadmin would have to edit - the log index file after restart - otherwise, this should be safe - */ - error= update_log_index(&log_info, 1); + error= (to_log[0] ? purge_logs(to_log, 1, 0, 1, (ulonglong *) 0) : 0); err: pthread_mutex_unlock(&LOCK_index); diff --git a/sql/sql_class.h b/sql/sql_class.h index c8d42d44df7..cc7ef7809d4 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -205,6 +205,13 @@ class MYSQL_LOG: public TC_LOG time_t last_time,query_start; IO_CACHE log_file; IO_CACHE index_file; + /* + purge_temp is a temp file used in purge_logs so that the index file + can be updated before deleting files from disk, yielding better crash + recovery. It is created on demand the first time purge_logs is called + and then reused for subsequent calls. It is cleaned up in cleanup(). + */ + IO_CACHE purge_temp; char *name; char time_buff[20],db[NAME_LEN+1]; char log_file_name[FN_REFLEN],index_file_name[FN_REFLEN]; From 4a3b1575e31c234b983b33719fc46265b966abe0 Mon Sep 17 00:00:00 2001 From: Patrick Crews Date: Wed, 3 Dec 2008 21:44:07 -0500 Subject: [PATCH 018/137] Bug#40177: Test funcs_1.storedproc failing on Pushbuild Altered param_check to disable warnings on system-sensitive operations and added some notes / possible TODO Re-recorded.result file to account for change --- mysql-test/suite/funcs_1/r/storedproc.result | 1212 ----------------- .../suite/funcs_1/storedproc/param_check.inc | 19 +- 2 files changed, 18 insertions(+), 1213 deletions(-) diff --git a/mysql-test/suite/funcs_1/r/storedproc.result b/mysql-test/suite/funcs_1/r/storedproc.result index 38fa933e13f..0c414df0c57 100644 --- a/mysql-test/suite/funcs_1/r/storedproc.result +++ b/mysql-test/suite/funcs_1/r/storedproc.result @@ -191,2427 +191,1215 @@ ERROR 22007: Illegal double '1.7976931348623157493578e+308' value found during p UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+100; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+100, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+100); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+99; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+99, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+99); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+98; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+98, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+98); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+97; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+97, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+97); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+96; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+96, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+96); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+95; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+95, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+95); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+94; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+94, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+94); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+93; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+93, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+93); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+92; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+92, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+92); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+91; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+91, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+91); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+90; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+90, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+90); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+89; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+89, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+89); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+88; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+88, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+88); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+87; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+87, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+87); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+86; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+86, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+86); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+85; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+85, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+85); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+84; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+84, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+84); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+83; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+83, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+83); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+82; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+82, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+82); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+81; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+81, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+81); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+80; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+80, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+80); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+79; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+79, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+79); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+78; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+78, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+78); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+77; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+77, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+77); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+76; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+76, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+76); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+75; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+75, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+75); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+74; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+74, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+74); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+73; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+73, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+73); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+72; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+72, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+72); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+71; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+71, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+71); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+70; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+70, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+70); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+69; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+69, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+69); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+68; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+68, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+68); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+67; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+67, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+67); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+66; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+66, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+66); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+65; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+65, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+65); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+64; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+64, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+64); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+63; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+63, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+63); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+62; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+62, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+62); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+61; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+61, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+61); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+60; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+60, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+60); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+59; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+59, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+59); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+58; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+58, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+58); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+57; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+57, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+57); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+56; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+56, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+56); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+55; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+55, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+55); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+54; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+54, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+54); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+53; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+53, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+53); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+52; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+52, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+52); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+51; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+51, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+51); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+50; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+50, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+50); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+49; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+49, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+49); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+48; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+48, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+48); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+47; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+47, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+47); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+46; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+46, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+46); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+45; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+45, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+45); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+44; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+44, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+44); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+43; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+43, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+43); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+42; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+42, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+42); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+41; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+41, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+41); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+40; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+40, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+40); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+39; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+39, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+39); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+38; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+38, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+38); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+37; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+37, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+37); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+36; -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+36, @v1_proc); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+36); -Warnings: -Warning 1264 Out of range value for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+35; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+35, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+35); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+34; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+34, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+34); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+33; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+33, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+33); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+32; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+32, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+32); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+31; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+31, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+31); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+30; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+30, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+30); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+29; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+29, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+29); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+28; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+28, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+28); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+27; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+27, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+27); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+26; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+26, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+26); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+25; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+25, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+25); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+24; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+24, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+24); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+23; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+23, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+23); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+22; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+22, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+22); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+21; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+21, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+21); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+20; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+20, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+20); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+19; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+19, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+19); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+18; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+18, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+18); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+17; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+17, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+17); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+16; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+16, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+16); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+15; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+15, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+15); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+14; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+14, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+14); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+13; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+13, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+13); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+12; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+12, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+12); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+11; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+11, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+11); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+10; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+10, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+10); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+9; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+9, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+9); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+8; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+8, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+8); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+7; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+7, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+7); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+6; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+6, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+6); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+5; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+5, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+5); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+4; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+4, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+4); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+3; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+3, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+3); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+2; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+2, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+2); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+1; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+1, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+1); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e+0; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e+0, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e+0); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-100; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-100, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-100); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-99; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-99, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-99); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-98; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-98, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-98); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-97; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-97, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-97); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-96; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-96, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-96); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-95; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-95, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-95); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-94; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-94, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-94); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-93; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-93, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-93); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-92; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-92, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-92); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-91; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-91, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-91); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-90; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-90, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-90); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-89; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-89, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-89); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-88; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-88, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-88); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-87; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-87, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-87); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-86; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-86, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-86); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-85; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-85, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-85); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-84; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-84, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-84); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-83; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-83, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-83); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-82; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-82, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-82); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-81; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-81, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-81); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-80; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-80, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-80); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-79; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-79, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-79); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-78; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-78, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-78); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-77; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-77, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-77); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-76; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-76, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-76); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-75; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-75, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-75); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-74; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-74, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-74); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-73; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-73, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-73); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-72; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-72, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-72); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-71; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-71, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-71); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-70; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-70, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-70); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-69; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-69, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-69); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-68; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-68, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-68); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-67; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-67, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-67); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-66; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-66, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-66); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-65; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-65, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-65); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-64; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-64, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-64); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-63; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-63, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-63); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-62; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-62, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-62); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-61; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-61, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-61); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-60; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-60, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-60); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-59; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-59, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-59); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-58; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-58, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-58); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-57; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-57, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-57); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-56; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-56, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-56); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-55; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-55, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-55); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-54; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-54, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-54); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-53; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-53, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-53); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-52; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-52, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-52); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-51; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-51, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-51); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-50; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-50, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-50); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-49; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-49, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-49); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-48; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-48, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-48); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-47; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-47, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-47); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-46; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-46, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-46); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-45; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-45, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-45); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-44; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-44, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-44); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-43; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-43, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-43); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-42; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-42, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-42); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-41; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-41, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-41); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-40; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-40, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-40); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-39; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-39, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-39); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-38; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-38, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-38); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-37; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-37, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-37); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-36; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-36, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-36); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-35; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-35, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-35); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-34; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-34, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-34); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-33; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-33, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-33); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-32; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-32, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-32); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-31; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-31, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-31); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-30; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-30, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-30); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-29; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-29, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-29); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-28; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-28, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-28); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-27; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-27, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-27); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-26; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-26, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-26); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-25; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-25, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-25); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-24; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-24, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-24); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-23; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-23, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-23); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-22; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-22, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-22); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-21; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-21, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-21); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-20; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-20, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-20); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-19; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-19, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-19); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-18; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-18, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-18); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-17; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-17, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-17); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-16; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-16, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-16); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-15; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-15, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-15); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-14; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-14, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-14); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-13; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-13, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-13); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-12; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-12, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-12); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-11; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-11, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-11); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-10; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-10, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-10); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-9; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-9, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-9); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-8; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-8, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-8); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-7; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-7, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-7); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-6; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-6, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-6); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-5; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-5, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-5); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-4; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-4, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-4); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-3; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-3, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-3); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-2; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-2, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-2); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-1; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-1, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-1); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 UPDATE t1_aux SET f1 = NULL; SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; UPDATE t1_aux SET f1 = 0.1234567890987654321e-0; -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SELECT f1 INTO @v1_tab FROM t1_aux; CALL sproc_1(0.1234567890987654321e-0, @v1_proc); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 SET @v1_func = func_1(0.1234567890987654321e-0); -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 DROP PROCEDURE sproc_1; DROP FUNCTION func_1; DROP TABLE t1_aux; diff --git a/mysql-test/suite/funcs_1/storedproc/param_check.inc b/mysql-test/suite/funcs_1/storedproc/param_check.inc index f6c0b30ab8b..203187f92b1 100644 --- a/mysql-test/suite/funcs_1/storedproc/param_check.inc +++ b/mysql-test/suite/funcs_1/storedproc/param_check.inc @@ -16,15 +16,32 @@ # Created: # 2008-08-27 mleich # - +# Modified: +# 2008-11-17 pcrews +# added --disable / --enable_warning statements to minimize differences +# between platforms (Bug#40177 Test funcs_1.storedproc failing on Pushbuild) +# +# TODO: (After 5.1 GA) +# 1) Examine reordering statements in this file to minimize the number of +# --disable / --enable_warning statements. Unsure if performance gains +# warrant the working time +# 2) We could probably add a comparison of the # of warnings before the +# assignment of @v1_proc and @v1_func to the # of warnings after assignment +# The difference of these values should be zero +# Refer to Bug#40177 - http://bugs.mysql.com/bug.php?id=40177 for notes as well + eval UPDATE t1_aux SET f1 = NULL; # Enforce that all user variables have the same data type and initial value. SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; +--disable_warnings eval UPDATE t1_aux SET f1 = $test_value; +--enable_warnings SELECT f1 INTO @v1_tab FROM t1_aux; +--disable_warnings eval CALL sproc_1($test_value, @v1_proc); eval SET @v1_func = func_1($test_value); +--enable_warnings if (`SELECT @v1_tab <> @v1_proc OR @v1_tab <> @v2_proc OR @v1_tab <> @v1_func`) { From 2405e47df065e731cd9a35d57d97802810497650 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Thu, 4 Dec 2008 10:47:25 +0100 Subject: [PATCH 019/137] Bug#40515: Query on a partitioned table does not return 'lock wait timeout exceeded' Problem was a bug in the implementation of scan in partitioning which masked the error code from the partition's handler. Fixed by returning the value from the underlying handler. --- mysql-test/suite/parts/r/partition_special_innodb.result | 5 +++++ mysql-test/suite/parts/t/partition_special_innodb.test | 2 ++ sql/ha_partition.cc | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/parts/r/partition_special_innodb.result b/mysql-test/suite/parts/r/partition_special_innodb.result index 5eab78de8c2..8869f6d450c 100644 --- a/mysql-test/suite/parts/r/partition_special_innodb.result +++ b/mysql-test/suite/parts/r/partition_special_innodb.result @@ -213,5 +213,10 @@ START TRANSACTION; INSERT INTO t1 VALUES (NULL, 'first row t2'); SET autocommit=OFF; ALTER TABLE t1 AUTO_INCREMENT = 10; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction INSERT INTO t1 VALUES (NULL, 'second row t2'); +SELECT a,b FROM t1 ORDER BY a; +a b +1 first row t2 +2 second row t2 DROP TABLE t1; diff --git a/mysql-test/suite/parts/t/partition_special_innodb.test b/mysql-test/suite/parts/t/partition_special_innodb.test index b9fc8bdcd56..eac19f6d588 100644 --- a/mysql-test/suite/parts/t/partition_special_innodb.test +++ b/mysql-test/suite/parts/t/partition_special_innodb.test @@ -68,10 +68,12 @@ INSERT INTO t1 VALUES (NULL, 'first row t2'); --connection con2 SET autocommit=OFF; +--error ER_LOCK_WAIT_TIMEOUT ALTER TABLE t1 AUTO_INCREMENT = 10; --connection con1 INSERT INTO t1 VALUES (NULL, 'second row t2'); +SELECT a,b FROM t1 ORDER BY a; --disconnect con2 --disconnect con1 --connection default diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 0c96b06381c..852f437b213 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -3431,7 +3431,7 @@ int ha_partition::rnd_next(uchar *buf) while (TRUE) { - int result= file->rnd_next(buf); + result= file->rnd_next(buf); if (!result) { m_last_part= part_id; From cea55f3dc68953050dacd5366a7003e2ab29cdcf Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Thu, 4 Dec 2008 18:36:45 +0200 Subject: [PATCH 020/137] Bug #33420 Test 'rpl_packet' fails randomly with changed "Exec_Master_Log_Pos" Bug #41173 rpl_packet fails sporadically on pushbuild: query 'DROP TABLE t1' failed The both issues appeared to be a race between the SQL thread executing CREATE table t1 and the IO thread that is expected to stop at the consequent big size event. The two events need serialization which is implemented. The early bug required back-porting a part fixes for bug#38350 exclusively for 5.0 version. --- mysql-test/r/rpl_packet.result | 40 +++++----------------------------- mysql-test/t/rpl_packet.test | 22 ++++++++++++++----- 2 files changed, 21 insertions(+), 41 deletions(-) diff --git a/mysql-test/r/rpl_packet.result b/mysql-test/r/rpl_packet.result index 88c63994fff..f84ce18810e 100644 --- a/mysql-test/r/rpl_packet.result +++ b/mysql-test/r/rpl_packet.result @@ -23,39 +23,9 @@ SET @@global.max_allowed_packet=4096; SET @@global.net_buffer_length=4096; STOP SLAVE; START SLAVE; -CREATE TABLe `t1` (`f1` LONGTEXT) ENGINE=MyISAM; +CREATE TABLE `t1` (`f1` LONGTEXT) ENGINE=MyISAM; INSERT INTO `t1`(`f1`) VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2048'); -show slave status; -Slave_IO_State # -Master_Host 127.0.0.1 -Master_User root -Master_Port MASTER_MYPORT -Connect_Retry 1 -Master_Log_File master-bin.000001 -Read_Master_Log_Pos 2138 -Relay_Log_File # -Relay_Log_Pos # -Relay_Master_Log_File master-bin.000001 -Slave_IO_Running No -Slave_SQL_Running # -Replicate_Do_DB -Replicate_Ignore_DB -Replicate_Do_Table -Replicate_Ignore_Table -Replicate_Wild_Do_Table -Replicate_Wild_Ignore_Table -Last_Errno 0 -Last_Error -Skip_Counter 0 -Exec_Master_Log_Pos 2138 -Relay_Log_Space # -Until_Condition None -Until_Log_File -Until_Log_Pos 0 -Master_SSL_Allowed No -Master_SSL_CA_File -Master_SSL_CA_Path -Master_SSL_Cert -Master_SSL_Cipher -Master_SSL_Key -Seconds_Behind_Master # +Slave_IO_Running = No (expect No) +==== clean up ==== +DROP TABLE t1; +DROP TABLE t1; diff --git a/mysql-test/t/rpl_packet.test b/mysql-test/t/rpl_packet.test index a3efdf24bce..f7066c93b30 100644 --- a/mysql-test/t/rpl_packet.test +++ b/mysql-test/t/rpl_packet.test @@ -73,16 +73,26 @@ disconnect master; connect (master, localhost, root); connection master; -CREATE TABLe `t1` (`f1` LONGTEXT) ENGINE=MyISAM; +CREATE TABLE `t1` (`f1` LONGTEXT) ENGINE=MyISAM; + +sync_slave_with_master; + +connection master; INSERT INTO `t1`(`f1`) VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2048'); # The slave I/O thread must stop after trying to read the above event connection slave; ---source include/wait_for_slave_io_to_stop.inc ---replace_result $MASTER_MYPORT MASTER_MYPORT -# import is only the 11th column Slave_IO_Running ---replace_column 1 # 8 # 9 # 12 # 23 # 33 # -query_vertical show slave status; +--source include/wait_for_slave_io_to_stop.inc +let $slave_io_running= query_get_value(SHOW SLAVE STATUS, Slave_IO_Running, 1); +--echo Slave_IO_Running = $slave_io_running (expect No) + + +--echo ==== clean up ==== +connection master; +DROP TABLE t1; +# slave is stopped +connection slave; +DROP TABLE t1; # End of tests From 4e9695acca35c7188d12427044ce461157d6f213 Mon Sep 17 00:00:00 2001 From: Mats Kindahl Date: Fri, 5 Dec 2008 10:23:27 +0100 Subject: [PATCH 021/137] Bug #40116: Uncommited changes are replicated and stay on slave after rollback on master Making test slightly more generic and robust. --- mysql-test/suite/rpl/r/rpl_trigger.result | 11 ++--------- mysql-test/suite/rpl/t/rpl_trigger.test | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_trigger.result b/mysql-test/suite/rpl/r/rpl_trigger.result index 5cc75013bf7..b68af8f4afe 100644 --- a/mysql-test/suite/rpl/r/rpl_trigger.result +++ b/mysql-test/suite/rpl/r/rpl_trigger.result @@ -988,16 +988,9 @@ after insert on t1 for each row insert into log values ( new.f ); set autocommit = 0; insert into t1 values ( 1 ); -select * from t1; -f -1 -select * from t1; -f rollback; Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back -select * from t1; -f -select * from t1; -f +Comparing tables master:test.t1 and slave:test.t1 +Comparing tables master:test.log and slave:test.log drop table t1, log; diff --git a/mysql-test/suite/rpl/t/rpl_trigger.test b/mysql-test/suite/rpl/t/rpl_trigger.test index 8e911178dcc..d63eafe56a7 100644 --- a/mysql-test/suite/rpl/t/rpl_trigger.test +++ b/mysql-test/suite/rpl/t/rpl_trigger.test @@ -480,8 +480,11 @@ sync_slave_with_master; # rollback on master # +connection master; source include/master-slave-reset.inc; source include/have_innodb.inc; +connection slave; +source include/have_innodb.inc; connection master; create table t1 ( f int ) engine = innodb; @@ -492,16 +495,15 @@ create trigger tr set autocommit = 0; insert into t1 values ( 1 ); - -select * from t1; -sync_slave_with_master; -select * from t1; - -connection master; rollback; -select * from t1; -sync_slave_with_master; -select * from t1; + +let $diff_table_1=master:test.t1; +let $diff_table_2=slave:test.t1; +--source include/diff_tables.inc + +let $diff_table_1=master:test.log; +let $diff_table_2=slave:test.log; +--source include/diff_tables.inc connection master; drop table t1, log; From 33cf11b4285c83f0ba90178fb9fe8c039d0de129 Mon Sep 17 00:00:00 2001 From: Patrick Crews Date: Fri, 5 Dec 2008 08:21:03 -0500 Subject: [PATCH 022/137] Bug#41258: mysql-test-run does not copy subdirectories of std_data on Windows (5.0 only) Altered how we copy data from mysql-test/std_data on Windows to match what we are doing in 5.1 and 6.0 --- mysql-test/mysql-test-run.pl | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 268dd3fbd16..70637034b6e 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -2380,13 +2380,7 @@ sub setup_vardir() { { # on windows, copy all files from std_data into var/std_data_ln mkpath("$opt_vardir/std_data_ln"); - opendir(DIR, "$glob_mysql_test_dir/std_data") - or mtr_error("Can't find the std_data directory: $!"); - for(readdir(DIR)) { - next if -d "$glob_mysql_test_dir/std_data/$_"; - copy("$glob_mysql_test_dir/std_data/$_", "$opt_vardir/std_data_ln/$_"); - } - closedir(DIR); + mtr_copy_dir("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data_ln"); } # Remove old log files From 3677288f6f058894abf02cc16baf18ce763c1683 Mon Sep 17 00:00:00 2001 From: Horst Hunger Date: Fri, 5 Dec 2008 16:43:13 +0100 Subject: [PATCH 023/137] Fix for Bug#36878 after review by Matthias: Only one line in the result files of 32 bit and 64 bit platforms differed and made problems on 64 bit machine with 32 bit mysqld. The removal of the separation into 32 bit and 64 bit versions of that test fixes also this problem. --- ..._32.result => tmp_table_size_basic.result} | 48 ++--- .../sys_vars/r/tmp_table_size_basic_64.result | 166 ------------------ .../tmp_table_size_basic.test} | 95 +++++----- .../sys_vars/t/tmp_table_size_basic_32.test | 9 - .../sys_vars/t/tmp_table_size_basic_64.test | 9 - 5 files changed, 60 insertions(+), 267 deletions(-) rename mysql-test/suite/sys_vars/r/{tmp_table_size_basic_32.result => tmp_table_size_basic.result} (83%) delete mode 100644 mysql-test/suite/sys_vars/r/tmp_table_size_basic_64.result rename mysql-test/suite/sys_vars/{inc/tmp_table_size_basic.inc => t/tmp_table_size_basic.test} (81%) delete mode 100644 mysql-test/suite/sys_vars/t/tmp_table_size_basic_32.test delete mode 100644 mysql-test/suite/sys_vars/t/tmp_table_size_basic_64.test diff --git a/mysql-test/suite/sys_vars/r/tmp_table_size_basic_32.result b/mysql-test/suite/sys_vars/r/tmp_table_size_basic.result similarity index 83% rename from mysql-test/suite/sys_vars/r/tmp_table_size_basic_32.result rename to mysql-test/suite/sys_vars/r/tmp_table_size_basic.result index ba3fd5420c6..3b4099d30ae 100644 --- a/mysql-test/suite/sys_vars/r/tmp_table_size_basic_32.result +++ b/mysql-test/suite/sys_vars/r/tmp_table_size_basic.result @@ -1,35 +1,21 @@ SET @start_global_value = @@global.tmp_table_size; -SELECT @start_global_value; -@start_global_value -16777216 SET @start_session_value = @@session.tmp_table_size; -SELECT @start_session_value; -@start_session_value -16777216 '#--------------------FN_DYNVARS_005_01-------------------------#' SET @@global.tmp_table_size = 100; Warnings: Warning 1292 Truncated incorrect tmp_table_size value: '100' SET @@global.tmp_table_size = DEFAULT; -SELECT @@global.tmp_table_size; -@@global.tmp_table_size -16777216 SET @@session.tmp_table_size = 200; Warnings: Warning 1292 Truncated incorrect tmp_table_size value: '200' SET @@session.tmp_table_size = DEFAULT; -SELECT @@session.tmp_table_size; -@@session.tmp_table_size -16777216 '#--------------------FN_DYNVARS_005_02-------------------------#' -SET @@global.tmp_table_size = DEFAULT; -SELECT @@global.tmp_table_size = 33554432; -@@global.tmp_table_size = 33554432 -0 -SET @@session.tmp_table_size = DEFAULT; -SELECT @@session.tmp_table_size = 33554432; -@@session.tmp_table_size = 33554432 -0 +SELECT @@global.tmp_table_size >= 16777216; +@@global.tmp_table_size >= 16777216 +1 +SELECT @@session.tmp_table_size >= 16777216; +@@session.tmp_table_size >= 16777216 +1 '#--------------------FN_DYNVARS_005_03-------------------------#' SET @@global.tmp_table_size = 1024; SELECT @@global.tmp_table_size; @@ -48,7 +34,7 @@ SET @@session.tmp_table_size = 1024; SELECT @@session.tmp_table_size; @@session.tmp_table_size 1024 -SET @@session.tmp_table_size =4294967295; +SET @@session.tmp_table_size = 4294967295; SELECT @@session.tmp_table_size; @@session.tmp_table_size 4294967295 @@ -114,18 +100,18 @@ SELECT @@session.tmp_table_size; SET @@session.tmp_table_size = "Test"; ERROR 42000: Incorrect argument type to variable 'tmp_table_size' SET @@session.tmp_table_size = 12345678901; -SELECT @@session.tmp_table_size; -@@session.tmp_table_size -4294967295 +SELECT @@session.tmp_table_size IN (12345678901,4294967295); +@@session.tmp_table_size IN (12345678901,4294967295) +1 '#------------------FN_DYNVARS_005_06-----------------------#' -SELECT @@global.tmp_table_size = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES +SELECT @@global.tmp_table_size = VARIABLE_VALUE +FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='tmp_table_size'; @@global.tmp_table_size = VARIABLE_VALUE 1 '#------------------FN_DYNVARS_005_07-----------------------#' -SELECT @@session.tmp_table_size = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.SESSION_VARIABLES +SELECT @@session.tmp_table_size = VARIABLE_VALUE +FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='tmp_table_size'; @@session.tmp_table_size = VARIABLE_VALUE 1 @@ -157,10 +143,4 @@ ERROR 42S02: Unknown table 'global' in field list SELECT tmp_table_size = @@session.tmp_table_size; ERROR 42S22: Unknown column 'tmp_table_size' in 'field list' SET @@global.tmp_table_size = @start_global_value; -SELECT @@global.tmp_table_size; -@@global.tmp_table_size -16777216 SET @@session.tmp_table_size = @start_session_value; -SELECT @@session.tmp_table_size; -@@session.tmp_table_size -16777216 diff --git a/mysql-test/suite/sys_vars/r/tmp_table_size_basic_64.result b/mysql-test/suite/sys_vars/r/tmp_table_size_basic_64.result deleted file mode 100644 index 73ebaecf5f0..00000000000 --- a/mysql-test/suite/sys_vars/r/tmp_table_size_basic_64.result +++ /dev/null @@ -1,166 +0,0 @@ -SET @start_global_value = @@global.tmp_table_size; -SELECT @start_global_value; -@start_global_value -16777216 -SET @start_session_value = @@session.tmp_table_size; -SELECT @start_session_value; -@start_session_value -16777216 -'#--------------------FN_DYNVARS_005_01-------------------------#' -SET @@global.tmp_table_size = 100; -Warnings: -Warning 1292 Truncated incorrect tmp_table_size value: '100' -SET @@global.tmp_table_size = DEFAULT; -SELECT @@global.tmp_table_size; -@@global.tmp_table_size -16777216 -SET @@session.tmp_table_size = 200; -Warnings: -Warning 1292 Truncated incorrect tmp_table_size value: '200' -SET @@session.tmp_table_size = DEFAULT; -SELECT @@session.tmp_table_size; -@@session.tmp_table_size -16777216 -'#--------------------FN_DYNVARS_005_02-------------------------#' -SET @@global.tmp_table_size = DEFAULT; -SELECT @@global.tmp_table_size = 33554432; -@@global.tmp_table_size = 33554432 -0 -SET @@session.tmp_table_size = DEFAULT; -SELECT @@session.tmp_table_size = 33554432; -@@session.tmp_table_size = 33554432 -0 -'#--------------------FN_DYNVARS_005_03-------------------------#' -SET @@global.tmp_table_size = 1024; -SELECT @@global.tmp_table_size; -@@global.tmp_table_size -1024 -SET @@global.tmp_table_size = 60020; -SELECT @@global.tmp_table_size; -@@global.tmp_table_size -60020 -SET @@global.tmp_table_size = 4294967295; -SELECT @@global.tmp_table_size; -@@global.tmp_table_size -4294967295 -'#--------------------FN_DYNVARS_005_04-------------------------#' -SET @@session.tmp_table_size = 1024; -SELECT @@session.tmp_table_size; -@@session.tmp_table_size -1024 -SET @@session.tmp_table_size =4294967295; -SELECT @@session.tmp_table_size; -@@session.tmp_table_size -4294967295 -SET @@session.tmp_table_size = 65535; -SELECT @@session.tmp_table_size; -@@session.tmp_table_size -65535 -'#------------------FN_DYNVARS_005_05-----------------------#' -SET @@global.tmp_table_size = 0; -Warnings: -Warning 1292 Truncated incorrect tmp_table_size value: '0' -SELECT @@global.tmp_table_size; -@@global.tmp_table_size -1024 -SET @@global.tmp_table_size = -1024; -Warnings: -Warning 1292 Truncated incorrect tmp_table_size value: '0' -SELECT @@global.tmp_table_size; -@@global.tmp_table_size -1024 -SET @@global.tmp_table_size = 1000; -Warnings: -Warning 1292 Truncated incorrect tmp_table_size value: '1000' -SELECT @@global.tmp_table_size; -@@global.tmp_table_size -1024 -SET @@global.tmp_table_size = ON; -ERROR 42000: Incorrect argument type to variable 'tmp_table_size' -SET @@global.tmp_table_size = OFF; -ERROR 42000: Incorrect argument type to variable 'tmp_table_size' -SET @@global.tmp_table_size = True; -Warnings: -Warning 1292 Truncated incorrect tmp_table_size value: '1' -SELECT @@global.tmp_table_size; -@@global.tmp_table_size -1024 -SET @@global.tmp_table_size = False; -Warnings: -Warning 1292 Truncated incorrect tmp_table_size value: '0' -SELECT @@global.tmp_table_size; -@@global.tmp_table_size -1024 -SET @@global.tmp_table_size = 65530.34; -ERROR 42000: Incorrect argument type to variable 'tmp_table_size' -SET @@global.tmp_table_size ="Test"; -ERROR 42000: Incorrect argument type to variable 'tmp_table_size' -SET @@session.tmp_table_size = ON; -ERROR 42000: Incorrect argument type to variable 'tmp_table_size' -SET @@session.tmp_table_size = OFF; -ERROR 42000: Incorrect argument type to variable 'tmp_table_size' -SET @@session.tmp_table_size = True; -Warnings: -Warning 1292 Truncated incorrect tmp_table_size value: '1' -SELECT @@session.tmp_table_size; -@@session.tmp_table_size -1024 -SET @@session.tmp_table_size = False; -Warnings: -Warning 1292 Truncated incorrect tmp_table_size value: '0' -SELECT @@session.tmp_table_size; -@@session.tmp_table_size -1024 -SET @@session.tmp_table_size = "Test"; -ERROR 42000: Incorrect argument type to variable 'tmp_table_size' -SET @@session.tmp_table_size = 12345678901; -SELECT @@session.tmp_table_size; -@@session.tmp_table_size -12345678901 -'#------------------FN_DYNVARS_005_06-----------------------#' -SELECT @@global.tmp_table_size = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES -WHERE VARIABLE_NAME='tmp_table_size'; -@@global.tmp_table_size = VARIABLE_VALUE -1 -'#------------------FN_DYNVARS_005_07-----------------------#' -SELECT @@session.tmp_table_size = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.SESSION_VARIABLES -WHERE VARIABLE_NAME='tmp_table_size'; -@@session.tmp_table_size = VARIABLE_VALUE -1 -'#---------------------FN_DYNVARS_001_09----------------------#' -SET @@global.tmp_table_size = 1024; -SET @@tmp_table_size = 4294967295; -SELECT @@tmp_table_size = @@global.tmp_table_size; -@@tmp_table_size = @@global.tmp_table_size -0 -'#---------------------FN_DYNVARS_001_10----------------------#' -SET @@tmp_table_size = 100; -Warnings: -Warning 1292 Truncated incorrect tmp_table_size value: '100' -SELECT @@tmp_table_size = @@local.tmp_table_size; -@@tmp_table_size = @@local.tmp_table_size -1 -SELECT @@local.tmp_table_size = @@session.tmp_table_size; -@@local.tmp_table_size = @@session.tmp_table_size -1 -'#---------------------FN_DYNVARS_001_11----------------------#' -SET tmp_table_size = 1027; -SELECT @@tmp_table_size; -@@tmp_table_size -1027 -SELECT local.tmp_table_size; -ERROR 42S02: Unknown table 'local' in field list -SELECT global.tmp_table_size; -ERROR 42S02: Unknown table 'global' in field list -SELECT tmp_table_size = @@session.tmp_table_size; -ERROR 42S22: Unknown column 'tmp_table_size' in 'field list' -SET @@global.tmp_table_size = @start_global_value; -SELECT @@global.tmp_table_size; -@@global.tmp_table_size -16777216 -SET @@session.tmp_table_size = @start_session_value; -SELECT @@session.tmp_table_size; -@@session.tmp_table_size -16777216 diff --git a/mysql-test/suite/sys_vars/inc/tmp_table_size_basic.inc b/mysql-test/suite/sys_vars/t/tmp_table_size_basic.test similarity index 81% rename from mysql-test/suite/sys_vars/inc/tmp_table_size_basic.inc rename to mysql-test/suite/sys_vars/t/tmp_table_size_basic.test index d29ef6da094..c2ff51d50ca 100644 --- a/mysql-test/suite/sys_vars/inc/tmp_table_size_basic.inc +++ b/mysql-test/suite/sys_vars/t/tmp_table_size_basic.test @@ -1,27 +1,29 @@ -############## mysql-test\t\tmp_table_size_basic.test ######################### -# # -# Variable Name: tmp_table_size # -# Scope: GLOBAL | SESSION # -# Access Type: Dynamic # -# Data Type: numeric # -# Default Value: 33554432 # -# Range: 1024-4294967295 # -# # -# # -# Creation Date: 2008-02-13 # -# Author: Salman # -# # -# Description: Test Cases of Dynamic System Variable tmp_table_size # -# that checks the behavior of this variable in the following ways# -# * Default Value # -# * Valid & Invalid values # -# * Scope & Access method # -# * Data Integrity # -# # -# Reference: # -# http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html # -# # -############################################################################### +########################### tmp_table_size_basic.test ########################## +# # +# Variable Name: tmp_table_size # +# Scope: GLOBAL | SESSION # +# Access Type: Dynamic # +# Data Type: numeric # +# Default Value: system dependend # +# Range: 1024-system dependend # +# # +# # +# Creation Date: 2008-02-13 # +# Author: Salman # +# # +# Description: Test Cases of Dynamic System Variable tmp_table_size # +# that checks the behavior of this variable in the following ways # +# * Default Value # +# * Valid & Invalid values # +# * Scope & Access method # +# * Data Integrity # +# Modified: 2008-12-04 HHunger # +# removed the differences between 64 and 32 bit platforms # +# # +# Reference: # +# http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html # +# # +################################################################################ --source include/load_sysvars.inc @@ -34,9 +36,7 @@ ############################################################# SET @start_global_value = @@global.tmp_table_size; -SELECT @start_global_value; SET @start_session_value = @@session.tmp_table_size; -SELECT @start_session_value; --echo '#--------------------FN_DYNVARS_005_01-------------------------#' ############################################################## @@ -45,22 +45,19 @@ SELECT @start_session_value; SET @@global.tmp_table_size = 100; SET @@global.tmp_table_size = DEFAULT; -SELECT @@global.tmp_table_size; SET @@session.tmp_table_size = 200; SET @@session.tmp_table_size = DEFAULT; -SELECT @@session.tmp_table_size; --echo '#--------------------FN_DYNVARS_005_02-------------------------#' ######################################################################## # Check the DEFAULT value of tmp_table_size # ######################################################################## +# The DEFAULT value is system dependend. +# Therefore we have only a plausibility check here +SELECT @@global.tmp_table_size >= 16777216; -SET @@global.tmp_table_size = DEFAULT; -SELECT @@global.tmp_table_size = 33554432; - -SET @@session.tmp_table_size = DEFAULT; -SELECT @@session.tmp_table_size = 33554432; +SELECT @@session.tmp_table_size >= 16777216; --echo '#--------------------FN_DYNVARS_005_03-------------------------#' ######################################################################## @@ -79,11 +76,11 @@ SELECT @@global.tmp_table_size; ######################################################################### # Change the value of tmp_table_size to a valid value for SESSION Scope # ######################################################################### - + SET @@session.tmp_table_size = 1024; SELECT @@session.tmp_table_size; -SET @@session.tmp_table_size =4294967295; +SET @@session.tmp_table_size = 4294967295; SELECT @@session.tmp_table_size; SET @@session.tmp_table_size = 65535; SELECT @@session.tmp_table_size; @@ -103,10 +100,10 @@ SELECT @@global.tmp_table_size; SET @@global.tmp_table_size = 1000; SELECT @@global.tmp_table_size; --- Error ER_WRONG_TYPE_FOR_VAR +--Error ER_WRONG_TYPE_FOR_VAR SET @@global.tmp_table_size = ON; --- Error ER_WRONG_TYPE_FOR_VAR +--Error ER_WRONG_TYPE_FOR_VAR SET @@global.tmp_table_size = OFF; SET @@global.tmp_table_size = True; @@ -115,16 +112,16 @@ SELECT @@global.tmp_table_size; SET @@global.tmp_table_size = False; SELECT @@global.tmp_table_size; --- Error ER_WRONG_TYPE_FOR_VAR +--Error ER_WRONG_TYPE_FOR_VAR SET @@global.tmp_table_size = 65530.34; --- Error ER_WRONG_TYPE_FOR_VAR +--Error ER_WRONG_TYPE_FOR_VAR SET @@global.tmp_table_size ="Test"; --- Error ER_WRONG_TYPE_FOR_VAR +--Error ER_WRONG_TYPE_FOR_VAR SET @@session.tmp_table_size = ON; --- Error ER_WRONG_TYPE_FOR_VAR +--Error ER_WRONG_TYPE_FOR_VAR SET @@session.tmp_table_size = OFF; SET @@session.tmp_table_size = True; @@ -133,19 +130,21 @@ SELECT @@session.tmp_table_size; SET @@session.tmp_table_size = False; SELECT @@session.tmp_table_size; --- Error ER_WRONG_TYPE_FOR_VAR +--Error ER_WRONG_TYPE_FOR_VAR SET @@session.tmp_table_size = "Test"; SET @@session.tmp_table_size = 12345678901; -SELECT @@session.tmp_table_size; + +# With a 64 bit mysqld:12345678901,with a 32 bit mysqld: 4294967295 +SELECT @@session.tmp_table_size IN (12345678901,4294967295); --echo '#------------------FN_DYNVARS_005_06-----------------------#' #################################################################### # Check if the value in GLOBAL Table matches value in variable # #################################################################### -SELECT @@global.tmp_table_size = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES +SELECT @@global.tmp_table_size = VARIABLE_VALUE +FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='tmp_table_size'; --echo '#------------------FN_DYNVARS_005_07-----------------------#' @@ -153,8 +152,8 @@ WHERE VARIABLE_NAME='tmp_table_size'; # Check if the value in SESSION Table matches value in variable # #################################################################### -SELECT @@session.tmp_table_size = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.SESSION_VARIABLES +SELECT @@session.tmp_table_size = VARIABLE_VALUE +FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='tmp_table_size'; --echo '#---------------------FN_DYNVARS_001_09----------------------#' @@ -199,9 +198,7 @@ SELECT tmp_table_size = @@session.tmp_table_size; #################################### SET @@global.tmp_table_size = @start_global_value; -SELECT @@global.tmp_table_size; SET @@session.tmp_table_size = @start_session_value; -SELECT @@session.tmp_table_size; ################################################### # END OF tmp_table_size TESTS # diff --git a/mysql-test/suite/sys_vars/t/tmp_table_size_basic_32.test b/mysql-test/suite/sys_vars/t/tmp_table_size_basic_32.test deleted file mode 100644 index c772b5c896c..00000000000 --- a/mysql-test/suite/sys_vars/t/tmp_table_size_basic_32.test +++ /dev/null @@ -1,9 +0,0 @@ -################################################################################ -# Created by Horst Hunger 2008-05-07 # -# # -# Wrapper for 32 bit machines # -################################################################################ - ---source include/have_32bit.inc ---source suite/sys_vars/inc/tmp_table_size_basic.inc - diff --git a/mysql-test/suite/sys_vars/t/tmp_table_size_basic_64.test b/mysql-test/suite/sys_vars/t/tmp_table_size_basic_64.test deleted file mode 100644 index 46b3f65be9a..00000000000 --- a/mysql-test/suite/sys_vars/t/tmp_table_size_basic_64.test +++ /dev/null @@ -1,9 +0,0 @@ -################################################################################ -# Created by Horst Hunger 2008-05-07 # -# # -# Wrapper for 64 bit machines # -################################################################################ - ---source include/have_64bit.inc ---source suite/sys_vars/inc/tmp_table_size_basic.inc - From 0fc3483b7a260ffa156ed0ac84cd95a96fce2851 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Fri, 5 Dec 2008 19:20:05 +0100 Subject: [PATCH 024/137] Bug#39750 -cannot create temp file on Windows. The problem appears often in conjuction with temp files, when temp-pool is used, so that names of temp files are not unique. The reason is that rapid deletiion and creation of fiiles with the same name on Windows is not guaranteed to succeed. File disappears from the file system only when the last handle to it is closed. If for example a virus scanner, a backup or indexing application opens the temp file just before MySQL deletes it, the file will enter "delete pending" state. In this state,it is not possible to open the file , or create a file with the same name (CreateFile returns ERROR_ACCESS_DENED, posix open returns EACESS) Fix (rather a cheap workarounf) is not to use temp-pool when working with temporary files- this will make filenames unique. With this patch , temp- pool setting will be ignored on anything but Linux(the option only made sense for Linux since its invention anyway). --- sql/mysqld.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 7ff2b9e7dff..32e0dd1542c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -227,6 +227,12 @@ extern "C" int gethostname(char *name, int namelen); extern "C" sig_handler handle_segfault(int sig); +#if defined(__linux__) +#define ENABLE_TEMP_POOL 1 +#else +#define ENABLE_TEMP_TOOL 0 +#endif + /* Constants */ const char *show_comp_option_name[]= {"YES", "NO", "DISABLED"}; @@ -3398,8 +3404,13 @@ static int init_common_variables(const char *conf_file_name, int argc, sys_var_slow_log_path.value= my_strdup(s, MYF(0)); sys_var_slow_log_path.value_length= strlen(s); +#if (ENABLE_TEMP_POOL) if (use_temp_pool && bitmap_init(&temp_pool,0,1024,1)) return 1; +#else + use_temp_pool= 0; +#endif + if (my_database_names_init()) return 1; @@ -6297,9 +6308,14 @@ log and this option does nothing anymore.", (uchar**) &opt_tc_heuristic_recover, (uchar**) &opt_tc_heuristic_recover, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"temp-pool", OPT_TEMP_POOL, +#if (ENABLE_TEMP_POOL) "Using this option will cause most temporary files created to use a small set of names, rather than a unique name for each new file.", +#else + "This option is ignored on this OS.", +#endif (uchar**) &use_temp_pool, (uchar**) &use_temp_pool, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, + {"timed_mutexes", OPT_TIMED_MUTEXES, "Specify whether to time mutexes (only InnoDB mutexes are currently supported)", (uchar**) &timed_mutexes, (uchar**) &timed_mutexes, 0, GET_BOOL, NO_ARG, 0, From b16ba9aa332735d87c5b3de2ae77b38b098cd55e Mon Sep 17 00:00:00 2001 From: Matthias Leich Date: Mon, 8 Dec 2008 15:36:42 +0100 Subject: [PATCH 025/137] Fix for Bug#40904 20 tests in 5.1 are disabled in a bad manner - remove totally wrong (syntax) entries from disabled.def - remove entries belonging to deleted tests from disabled.def - correct the comments (correct the bug mentioned) of entries in disabled.def - remove never completed tests which were accidently pushed --- mysql-test/suite/funcs_2/t/disabled.def | 8 +- mysql-test/suite/ndb/t/disabled.def | 3 +- .../suite/parts/r/partition_bit_ndb.result | 126 ------ mysql-test/suite/parts/t/disabled.def | 5 - .../suite/parts/t/partition_bit_ndb.test | 60 --- .../suite/parts/t/partition_sessions.test | 391 ------------------ .../suite/parts/t/partition_value_innodb.test | 12 +- .../suite/parts/t/partition_value_myisam.test | 12 +- .../suite/parts/t/partition_value_ndb.test | 12 +- mysql-test/suite/rpl_ndb/t/disabled.def | 4 +- mysql-test/t/disabled.def | 3 +- 11 files changed, 35 insertions(+), 601 deletions(-) delete mode 100644 mysql-test/suite/parts/r/partition_bit_ndb.result delete mode 100644 mysql-test/suite/parts/t/partition_bit_ndb.test delete mode 100644 mysql-test/suite/parts/t/partition_sessions.test diff --git a/mysql-test/suite/funcs_2/t/disabled.def b/mysql-test/suite/funcs_2/t/disabled.def index c903662e052..da6230bd7ed 100644 --- a/mysql-test/suite/funcs_2/t/disabled.def +++ b/mysql-test/suite/funcs_2/t/disabled.def @@ -1,6 +1,6 @@ # Disabled by hhunger (2008-03-03) due to WL4204 -innodb_charset : Due to bug#20447 -myisam_charset : Due to bug#20477 -memory_charset : Due to bug#20447 -ndb_charset : Due to bug#20447 +innodb_charset : Bug#20447 Problem with prefix keys with contractions and expansions +myisam_charset : Bug#20447 Problem with prefix keys with contractions and expansions +memory_charset : Bug#20447 Problem with prefix keys with contractions and expansions +ndb_charset : Bug#20447 Problem with prefix keys with contractions and expansions diff --git a/mysql-test/suite/ndb/t/disabled.def b/mysql-test/suite/ndb/t/disabled.def index c638c7b4774..0fc9a5d3ad6 100644 --- a/mysql-test/suite/ndb/t/disabled.def +++ b/mysql-test/suite/ndb/t/disabled.def @@ -9,8 +9,7 @@ # Do not use any TAB characters for whitespace. # ############################################################################## -partition_03ndb : BUG#16385 2006-03-24 mikael Partitions: crash when updating a range partitioned NDB table -ndb_partition_error2 : HF is not sure if the test can work as internded on all the platforms +ndb_partition_error2 : Bug#40989 ndb_partition_error2 needs maintenance # the below testcase have been reworked to avoid the bug, test contains comment, keep bug open diff --git a/mysql-test/suite/parts/r/partition_bit_ndb.result b/mysql-test/suite/parts/r/partition_bit_ndb.result deleted file mode 100644 index add3ed394ad..00000000000 --- a/mysql-test/suite/parts/r/partition_bit_ndb.result +++ /dev/null @@ -1,126 +0,0 @@ -SET @max_row = 20; -create table t1 (a bit(65), primary key (a)) partition by key (a); -ERROR 42000: Display width out of range for column 'a' (max = 64) -create table t1 (a bit(0), primary key (a)) partition by key (a); -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` bit(1) NOT NULL DEFAULT '\0', - PRIMARY KEY (`a`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (a) */ -drop table t1; -create table t1 (a bit(0), primary key (a)) partition by key (a) ( -partition pa1 DATA DIRECTORY = -'/tmp' INDEX DIRECTORY = -'/tmp', -partition pa2 DATA DIRECTORY = -'/tmp' INDEX DIRECTORY = -'/tmp'); -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` bit(1) NOT NULL DEFAULT '\0', - PRIMARY KEY (`a`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='/tmp/' INDEX DIRECTORY='/tmp/' -/*!50100 PARTITION BY KEY (a) -(PARTITION pa1 DATA DIRECTORY = '/tmp' INDEX DIRECTORY = '/tmp' ENGINE = MyISAM, - PARTITION pa2 DATA DIRECTORY = '/tmp' INDEX DIRECTORY = '/tmp' ENGINE = MyISAM) */ -drop table t1; -create table t1 (a bit(64), primary key (a)) partition by key (a); -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` bit(64) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0', - PRIMARY KEY (`a`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (a) */ -insert into t1 values -(b'1111111111111111111111111111111111111111111111111111111111111111'), -(b'1000000000000000000000000000000000000000000000000000000000000000'), -(b'0000000000000000000000000000000000000000000000000000000000000001'), -(b'1010101010101010101010101010101010101010101010101010101010101010'), -(b'0101010101010101010101010101010101010101010101010101010101010101'); -select hex(a) from t1; -hex(a) -1 -5555555555555555 -8000000000000000 -AAAAAAAAAAAAAAAA -FFFFFFFFFFFFFFFF -drop table t1; -create table t1 (a bit(64), primary key (a)) partition by key (a)( -partition pa1 DATA DIRECTORY = -'/tmp' INDEX DIRECTORY = -'/tmp' max_rows=20 min_rows=2, -partition pa2 DATA DIRECTORY = -'/tmp' INDEX DIRECTORY = -'/tmp' max_rows=30 min_rows=3, -partition pa3 DATA DIRECTORY = -'/tmp' INDEX DIRECTORY = -'/tmp' max_rows=30 min_rows=4, -partition pa4 DATA DIRECTORY = -'/tmp' INDEX DIRECTORY = -'/tmp' max_rows=40 min_rows=2); -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` bit(64) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0', - PRIMARY KEY (`a`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='/tmp/' INDEX DIRECTORY='/tmp/' -/*!50100 PARTITION BY KEY (a) -(PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 DATA DIRECTORY = '/tmp' INDEX DIRECTORY = '/tmp' ENGINE = MyISAM, - PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 DATA DIRECTORY = '/tmp' INDEX DIRECTORY = '/tmp' ENGINE = MyISAM, - PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 DATA DIRECTORY = '/tmp' INDEX DIRECTORY = '/tmp' ENGINE = MyISAM, - PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 DATA DIRECTORY = '/tmp' INDEX DIRECTORY = '/tmp' ENGINE = MyISAM) */ -insert into t1 values -(b'1111111111111111111111111111111111111111111111111111111111111111'), -(b'1000000000000000000000000000000000000000000000000000000000000000'), -(b'0000000000000000000000000000000000000000000000000000000000000001'), -(b'1010101010101010101010101010101010101010101010101010101010101010'), -(b'0101010101010101010101010101010101010101010101010101010101010101'); -select hex(a) from t1; -hex(a) -1 -5555555555555555 -8000000000000000 -AAAAAAAAAAAAAAAA -FFFFFFFFFFFFFFFF -drop table t1; -create table t1 (a bit, primary key (a)) partition by key (a); -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` bit(1) NOT NULL DEFAULT '\0', - PRIMARY KEY (`a`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (a) */ -insert into t1 values (b'0'), (b'1'); -select hex(a) from t1; -hex(a) -0 -1 -alter table t1 drop primary key; -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` bit(1) NOT NULL DEFAULT '\0' -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (a) */ -select hex(a) from t1; -hex(a) -0 -1 -alter table t1 add primary key (a); -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` bit(1) NOT NULL DEFAULT '\0', - PRIMARY KEY (`a`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY KEY (a) */ -select hex(a) from t1; -hex(a) -0 -1 -drop table t1; diff --git a/mysql-test/suite/parts/t/disabled.def b/mysql-test/suite/parts/t/disabled.def index b9cd3462635..518a3c90422 100644 --- a/mysql-test/suite/parts/t/disabled.def +++ b/mysql-test/suite/parts/t/disabled.def @@ -1,8 +1,3 @@ partition_basic_ndb : Bug#19899 Crashing the server # http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-limitations-syntax.html -partition_bit_ndb : NDB does not support bit column in index -partition_sessions : needs system_3_init.inc partition_syntax_ndb : Bug#36735 Not supported -partition_value_innodb : Bug#30581 partition_value tests use disallowed CAST() function -partition_value_myisam : Bug#30581 partition_value tests use disallowed CAST() function -partition_value_ndb : Bug#30581 partition_value tests use disallowed CAST() function diff --git a/mysql-test/suite/parts/t/partition_bit_ndb.test b/mysql-test/suite/parts/t/partition_bit_ndb.test deleted file mode 100644 index 227d3d53401..00000000000 --- a/mysql-test/suite/parts/t/partition_bit_ndb.test +++ /dev/null @@ -1,60 +0,0 @@ -################################################################################ -# t/partition_bit_ndb.test # -# # -# Purpose: # -# Tests around bit type # -# NDB branch # -# # -#------------------------------------------------------------------------------# -# Original Author: HH # -# Original Date: 2006-08-01 # -# Change Author: # -# Change Date: # -# Change: # -################################################################################ - -# -# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! -# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN -# THE SOURCED FILES ONLY. -# -# Please read the README at the end of inc/partition.pre before changing -# any of the variables. -# - -#------------------------------------------------------------------------------# -# General not engine specific settings and requirements - -##### Options, for debugging support ##### -let $debug= 0; -let $with_partitioning= 1; - -##### Option, for displaying files ##### -let $ls= 1; - -##### Number of rows for the INSERT/UPDATE/DELETE/SELECT experiments ##### -# on partioned tables -SET @max_row = 20; - -# The server must support partitioning. ---source include/have_partition.inc - -#------------------------------------------------------------------------------# -# Engine specific settings and requirements - -##### Storage engine to be tested ---source include/have_ndb.inc -let $engine= 'NDB'; -connection default; - -# range, list and hash partitioning in ndb requires new_mode ---disable_query_log -set new=on; ---enable_query_log -##### Assign a big number smaller than the maximum value for partitions ##### -# and smaller than the maximum value of SIGNED INTEGER -let $MAX_VALUE= (2147483646); - -#------------------------------------------------------------------------------# -# Execute the tests to be applied to all storage engines ---source suite/parts/inc/partition_bit.inc diff --git a/mysql-test/suite/parts/t/partition_sessions.test b/mysql-test/suite/parts/t/partition_sessions.test deleted file mode 100644 index 3d59292bee5..00000000000 --- a/mysql-test/suite/parts/t/partition_sessions.test +++ /dev/null @@ -1,391 +0,0 @@ - -#-------------------------------------------------- -# Initialize system_3 test variables -#-------------------------------------------------- - ---source suite/system_3/include/system_3_init.inc - -let $NUM_VAL=`SELECT @NUM_VAL`; -let $LOAD_LINES=`SELECT @LOAD_LINES`; -let $LOG_UPPER=`SELECT @LOG_UPPER`; -let $LOG_LOWER=`SELECT @LOG_LOWER`; -#let $ENG1=`SELECT @ENG1`; -let $ENG2=`SELECT @ENG2`; -let $ENG_LOG=`SELECT @ENG_LOG`; -let $CLIENT_HOST=`SELECT @CLIENT_HOST`; -let $ENG=innodb; -let $ENG1=innodb; -#--------------------------------------------------------- -# Column list with definition for all tables to be checked -#--------------------------------------------------------- - -let $column_list= f1 int, -f2 char (15), -f3 decimal (5,3), -f4 datetime; - -let $col_access_list = f1,f2,f3,f4 ; -let $col_new_list = new.f1,new.f2,new.f3 new.f4 ; - -#--------------------------------------------------- -# Setting the parameters to use during testing -#--------------------------------------------------- -# Set number of variations of the f1 variable (used to segment the rows -# being updated/deleted by a user at a time. The higher the number, the -# more smaller segments used with each query. ---replace_result $NUM_VAL NUM_VAL -eval set @f1_nums=$NUM_VAL; - -# The following sets the number controls the size of the log table. -# Once a size of '@threshold' is reached, the first rows are removed -# sunch that the table is down to '@shrink_to' lines ---replace_result $LOG_LOWER LOG_LOWER -eval set @shrink_to=$LOG_LOWER; ---replace_result $LOG_UPPER LOG_UPPER -eval set @threshold=$LOG_UPPER; - -#--------------------------------------------------- -# Creating the database tables and loading the data -#--------------------------------------------------- - ---disable_warnings -drop database if exists systest1; ---enable_warnings - -create database systest1; - ---disable_abort_on_error ---replace_result $CLIENT_HOST CLIENT_HOST -eval create user systuser@'$CLIENT_HOST'; ---enable_abort_on_error ---replace_result $CLIENT_HOST CLIENT_HOST -eval set password for systuser@'$CLIENT_HOST' = password('systpass'); ---replace_result $CLIENT_HOST CLIENT_HOST -eval grant ALL on systest1.* to systuser@'$CLIENT_HOST'; -use systest1; ---replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK -connect (systuser,localhost,systuser,systpass,systest1,$MASTER_MYPORT,$MASTER_MYSOCK); - -create table tb1_master ( - f1 int, - f2 char(15), - f3 decimal (5,3), - f4 datetime -); - -#--replace_result $ENG_LOG ENG_LOG -eval create table tb1_logs ( - i1 int NOT NULL auto_increment, primary key (i1), - dt1 datetime NOT NULL, - entry_dsc char(100), - f4 int -) engine=$ENG_LOG -; -#PARTITION BY HASH (i1) PARTITIONS 8; - -if ($debug) -{ -SHOW CREATE TABLE tb1_logs; -} - -#--replace_result $ENG_LOG ENG_LOG -eval create table ddl_logs ( - i1 int NOT NULL auto_increment, primary key (i1), - dt1 datetime NOT NULL, - entry_dsc char(100), - errno int -) engine=$ENG_LOG; -#PARTITION BY HASH (i1) PARTITIONS 8; - -if ($debug) -{ -SHOW CREATE TABLE tb1_logs; -} -create table test_stat ( - dt1 datetime, - table_name char(20), - row_count int, - start_row int, - end_row int -); - -#---------------------------------------------------------------------- -# tb3_eng1: key partitioning -#---------------------------------------------------------------------- - -#--replace_result $ENG1 ENG1 -eval create table tb3_eng1 ( - i1 int NOT NULL auto_increment, primary key (i1), - $column_list -) engine=$ENG1 -PARTITION BY KEY (i1) PARTITIONS 4 -(PARTITION part1, -PARTITION part2, -PARTITION part3, -PARTITION part4); - -#--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR -eval load data local infile '$MYSQL_TEST_DIR/suite/system_3/data/tb1.txt' - into table tb3_eng1 ($col_access_list); - -if ($WITH_TRIGGERS) -{ -delimiter //; - -Create trigger tb3_eng1_ins after insert on tb3_eng1 for each row -BEGIN - insert into tb1_logs (dt1, entry_dsc, f4) - values (now(), concat('Insert row ', new.f1,' ', - new.f2, ' ', new.f3, ' (tb3_eng1)'), new.f1); -END// - -Create trigger tb3_eng1_upd after update on tb3_eng1 for each row -BEGIN - insert into tb1_logs (dt1, entry_dsc, f4) - values (now(), concat('Update row ', old.f1,' ', old.f2, '->', - new.f2, ' ', old.f3, '->', new.f3, ' (tb3_eng1)'), new.f1); -END// - -Create trigger tb3_eng1_del after delete on tb3_eng1 for each row -BEGIN - insert into tb1_logs (dt1, entry_dsc, f4) - values (now(), concat('Delete row ', old.f1,' ', old.f2, ' ', - old.f3, ' (tb3_eng1)'), old.f1); -END// - -delimiter ;// -} -delimiter //; - -# This functions returns a random integer number -# between zero and 'num' -#----------------------------------------------- -create function int_rand(num int) returns int -BEGIN - return round(num*rand()+0.5); -END// - -# This function returns a string in the length 'len' of -# random letters (ascii range of 65-122) -#------------------------------------------------------ -create function str_rand (len int) returns char(12) -BEGIN - declare tmp_letter char(1); - declare tmp_word char(12); - declare word_str char(12) default ''; - wl_loop: WHILE len DO - set tmp_letter=char(round(57*rand()+65)); - set tmp_word=concat(word_str,tmp_letter); - set word_str=tmp_word; - set len=len-1; - END WHILE wl_loop; - return word_str; -END// - - -# This procedure scans 'tb1_master' table for rows where f1='num_pr' -# and for each row inserts a row in 'tb3_eng1' -#------------------------------------------------------------------ -eval create procedure ins_tb3_eng1 (num_pr int, str_pr char(15)) -BEGIN - declare done int default 0; - declare v3 decimal(5,3); - declare cur1 cursor for - select f3 from tb1_master where f1=num_pr; - declare continue handler for sqlstate '01000' set done = 1; - declare continue handler for sqlstate '02000' set done = 1; - open cur1; - fetch cur1 into v3; - wl_loop: WHILE NOT done DO - insert into tb3_eng1 ($col_access_list) values - (int_rand(@f1_nums), concat('I:',str_pr,'-',num_pr), v3, now()); - fetch cur1 into v3; - END WHILE wl_loop; - close cur1; -END// - - -# This procedure does selects from the 'tb1_logs' and inserts the -# count into the table -#------------------------------------------------------------------ -create procedure slct_tb1_logs () -BEGIN - declare done int default 0; - declare v4 int; - declare v_count int default 0; - declare str_val char(15) default ELT(int_rand(3), - 'Insert', 'Update', 'Delete'); - declare cur1 cursor for - select f4 from tb1_logs where entry_dsc like concat('%',str_val,'%'); - declare continue handler for sqlstate '01000' set done = 1; - declare continue handler for sqlstate '02000' set done = 1; - open cur1; - fetch cur1 into v4; - wl_loop: WHILE NOT done DO - set v_count=v_count+1; - fetch cur1 into v4; - END WHILE wl_loop; - close cur1; - insert into tb1_logs (dt1, entry_dsc, f4) - values (now(), concat('Number of \'', str_val, '\' rows is: ', - v_count, ' (tb1_log)'),0); -END// - -delimiter ;// - ---disable_abort_on_error -insert into systest1.tb3_eng1 values (NULL,50,'init_val',12.345,'2005-01-01 00:00:00'); -insert into systest1.tb3_eng1 values (NULL,70,'init_val',12.345,'2005-01-01 00:00:00'); ---enable_abort_on_error - -connection default;0. ---disable_abort_on_error ---replace_result $CLIENT_HOST CLIENT_HOST -eval create user syst1user@'$CLIENT_HOST'; ---enable_abort_on_error ---replace_result $CLIENT_HOST CLIENT_HOST -eval set password for syst1user@'$CLIENT_HOST' = password('systpass'); ---replace_result $CLIENT_HOST CLIENT_HOST -eval grant ALL on systest1.* to syst1user@'$CLIENT_HOST'; -use systest1; ---replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK -connect (syst1user,localhost,syst1user,systpass,systest1,$MASTER_MYPORT,$MASTER_MYSOCK); - ---source suite/system_3/include/system_3_init.inc -use systest1; -let $NUM_VAL=`SELECT @NUM_VAL`; -eval SET @f1_nums=$NUM_VAL; -SET @tmp_num=int_rand(@f1_nums); -SET @tmp_word=str_rand(4); - -# DEBUG select @tmp_num, @tmp_word; - -# Insert rows replacing the deleted rows using a strored procedure -# that reads the rows from a master table -CALL ins_tb3_eng1 (@tmp_num, @tmp_word); - -connection syst1user; ---source suite/system_3/include/system_3_init.inc -use systest1; -let $NUM_VAL=`SELECT @NUM_VAL`; -eval SET @f1_nums=$NUM_VAL; -SET @tmp_num=int_rand(@f1_nums); -SET @tmp_word=str_rand(4); - -# DEBUG select @tmp_num, @tmp_word; - -# Insert rows replacing the deleted rows using a strored procedure -# that reads the rows from a master table -CALL ins_tb3_eng1 (@tmp_num, @tmp_word); - -connection systuser; ---source suite/system_3/include/system_3_init.inc -use systest1; -call slct_tb1_logs(); - -connection syst1user; ---source suite/system_3/include/system_3_init.inc -use systest1; -let $NUM_VAL=`SELECT @NUM_VAL`; -eval set @f1_nums=$NUM_VAL; -set @tmp_num=int_rand(@f1_nums); -set @tmp_word=str_rand(4); - -select @tmp_num, @tmp_word; - -# Update all rows in the table where f1 is one less the random number -update tb3_eng1 - set f2=concat('U:',@tmp_word,'-',@tmp_num), f3=f3+1 - where f1=@tmp_num-1; - -connection systuser; ---source suite/system_3/include/system_3_init.inc -use systest1; -let $NUM_VAL=`SELECT @NUM_VAL`; -eval set @f1_nums=$NUM_VAL; -set @tmp_num=int_rand(@f1_nums); -set @tmp_word=str_rand(4); - -select @tmp_num, @tmp_word; - -# Update all rows in the table where f1 is one less the random number -update tb3_eng1 - set f2=concat('U:',@tmp_word,'-',@tmp_num), f3=f3+1 - where f1=@tmp_num-1; - -connection syst1user; ---source suite/system_3/include/system_3_init.inc -use systest1; -call slct_tb1_logs(); - -connection systuser; ---source suite/system_3/include/system_3_init.inc -use systest1; -let $NUM_VAL=`SELECT @NUM_VAL`; -eval set @f1_nums=$NUM_VAL; -set @tmp_num=int_rand(@f1_nums); -set @tmp_word=str_rand(4); - -select @tmp_num, @tmp_word; - -# Update all rows in the table where f1 is one less the random number -update tb3_eng1 - set f2=concat('U:',@tmp_word,'-',@tmp_num), f3=f3+1 - where f1=@tmp_num-1; - - -connection syst1user; ---source suite/system_3/include/system_3_init.inc -use systest1; -#--replace_result $NUM_VAL -let $NUM_VAL=`SELECT @NUM_VAL`; -eval set @f1_nums=$NUM_VAL; -set @tmp_num=int_rand(@f1_nums); -select @tmp_num; - -# DEBUG select @tmp_num, @tmp_word; - -# Delete all rows from the table where f1 is equal to the above number -delete from tb3_eng1 where f1=@tmp_num; - -connection systuser; ---source suite/system_3/include/system_3_init.inc -use systest1; -select * from tb3_eng1 where f1>40; - - -connection syst1user; ---source suite/system_3/include/system_3_init.inc -use systest1; -let $NUM_VAL=`SELECT @NUM_VAL`; -eval set @f1_nums=$NUM_VAL; -set @tmp_num=int_rand(@f1_nums); -select @tmp_num; - -# DEBUG select @tmp_num, @tmp_word; - -# Delete all rows from the table where f1 is equal to the above number -delete from tb3_eng1 where f1=@tmp_num; - -connection systuser; ---source suite/system_3/include/system_3_init.inc -use systest1; -select * from tb3_eng1 where f1>40; - -connection syst1user; ---source suite/system_3/include/system_3_init.inc -use systest1; -let $NUM_VAL=`SELECT @NUM_VAL`; -eval set @f1_nums=$NUM_VAL; -set @tmp_num=int_rand(@f1_nums); -select @tmp_num; - -select @tmp_num, @tmp_word; - -# Delete all rows from the table where f1 is equal to the above number -delete from tb3_eng1 where f1=@tmp_num; - -connection systuser; ---source suite/system_3/include/system_3_init.inc -use systest1; -select * from tb3_eng1 where f1>40; diff --git a/mysql-test/suite/parts/t/partition_value_innodb.test b/mysql-test/suite/parts/t/partition_value_innodb.test index 9d59533a54e..fe47f533107 100644 --- a/mysql-test/suite/parts/t/partition_value_innodb.test +++ b/mysql-test/suite/parts/t/partition_value_innodb.test @@ -8,9 +8,9 @@ #------------------------------------------------------------------------------# # Original Author: mleich # # Original Date: 2006-04-11 # -# Change Author: # -# Change Date: # -# Change: # +# Change Author: mleich # +# Change Date: 2008-12-08 # +# Change: Remove test from disabled.def + change test that it gets skipped # ################################################################################ # @@ -22,6 +22,12 @@ # any of the variables. # +# +# CAST() within the partitioning function si no more supported, but we get +# this functionality probably soon again. Therefor we do not delete this test. +--skip # CAST() in partitioning function is currently not supported. + + #------------------------------------------------------------------------------# # General not engine specific settings and requirements diff --git a/mysql-test/suite/parts/t/partition_value_myisam.test b/mysql-test/suite/parts/t/partition_value_myisam.test index d6020669509..026ad57f0b2 100644 --- a/mysql-test/suite/parts/t/partition_value_myisam.test +++ b/mysql-test/suite/parts/t/partition_value_myisam.test @@ -8,9 +8,9 @@ #------------------------------------------------------------------------------# # Original Author: mleich # # Original Date: 2006-04-11 # -# Change Author: # -# Change Date: # -# Change: # +# Change Author: mleich # +# Change Date: 2008-12-08 # +# Change: Remove test from disabled.def + change test that it gets skipped # ################################################################################ # @@ -22,6 +22,12 @@ # any of the variables. # +# +# CAST() within the partitioning function si no more supported, but we get +# this functionality probably soon again. Therefor we do not delete this test. +--skip # CAST() in partitioning function is currently not supported. + + #------------------------------------------------------------------------------# # General not engine specific settings and requirements diff --git a/mysql-test/suite/parts/t/partition_value_ndb.test b/mysql-test/suite/parts/t/partition_value_ndb.test index 2f948b95727..80b4ba6fb64 100644 --- a/mysql-test/suite/parts/t/partition_value_ndb.test +++ b/mysql-test/suite/parts/t/partition_value_ndb.test @@ -8,9 +8,9 @@ #------------------------------------------------------------------------------# # Original Author: mleich # # Original Date: 2006-04-11 # -# Change Author: # -# Change Date: # -# Change: # +# Change Author: mleich # +# Change Date: 2008-12-08 # +# Change: Remove test from disabled.def + change test that it gets skipped # ################################################################################ # @@ -22,6 +22,12 @@ # any of the variables. # +# +# CAST() within the partitioning function si no more supported, but we get +# this functionality probably soon again. Therefor we do not delete this test. +--skip # CAST() in partitioning function is currently not supported. + + #------------------------------------------------------------------------------# # General not engine specific settings and requirements diff --git a/mysql-test/suite/rpl_ndb/t/disabled.def b/mysql-test/suite/rpl_ndb/t/disabled.def index ebc99feeac6..694f7098980 100644 --- a/mysql-test/suite/rpl_ndb/t/disabled.def +++ b/mysql-test/suite/rpl_ndb/t/disabled.def @@ -10,7 +10,7 @@ # ############################################################################## -rpl_ndb_circular : Bug#33849 COMMIT event missing in cluster circular replication. -rpl_ndb_circular_simplex : Bug#33849 COMMIT event missing in cluster circular replication. +rpl_ndb_circular : Bug#41183 rpl_ndb_circular, rpl_ndb_circular_simplex need maintenance, crash +rpl_ndb_circular_simplex : Bug#41183 rpl_ndb_circular, rpl_ndb_circular_simplex need maintenance, crash # the below testcase have been reworked to avoid the bug, test contains comment, keep bug open diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 5de0a435ba5..e2a4d0ba33d 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -10,6 +10,5 @@ # ############################################################################## federated_transactions : Bug#29523 Transactions do not work -log_tables.test : Bug #37798: main.log_tables fails randomly on powermacg5 and windows -slow_query_log_func.test : Bug #37962: *_func tests containing sleeps/race conditions +slow_query_log_func : Bug #37962: *_func tests containing sleeps/race conditions wait_timeout_func : Bug #41225 joro wait_timeout_func fails From ca25988f6e3342ddb368e004d19ad488d6c62643 Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Mon, 8 Dec 2008 17:07:08 +0200 Subject: [PATCH 026/137] Bug #40221 Replication failure on RBR + UPDATE the primary key Extending bug#40221 regression test: 1. include INSERT 2. convert prim key + autoinc to unique. --- .../suite/binlog/r/binlog_innodb_row.result | 27 ++++++++++++------- .../suite/binlog/t/binlog_innodb_row.test | 24 ++++++++++++++--- 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/mysql-test/suite/binlog/r/binlog_innodb_row.result b/mysql-test/suite/binlog/r/binlog_innodb_row.result index 47ddcbd00f6..fab79c4bc2f 100644 --- a/mysql-test/suite/binlog/r/binlog_innodb_row.result +++ b/mysql-test/suite/binlog/r/binlog_innodb_row.result @@ -1,16 +1,10 @@ -CREATE TABLE t1 (pk int auto_increment primary key) ENGINE=innodb; -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `pk` int(11) NOT NULL AUTO_INCREMENT, - PRIMARY KEY (`pk`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 +CREATE TABLE t1 (i int unique) ENGINE=innodb; reset master; begin; insert into t1 values (1),(2); *** the following UPDATE query wont generate any updates for the binlog *** -update t1 set pk = 3 where pk < 3; -ERROR 23000: Duplicate entry '3' for key 'PRIMARY' +update t1 set i = 3 where i < 3; +ERROR 23000: Duplicate entry '3' for key 'i' commit; *** Results of the test: the binlog must have only Write_rows events not any Update_rows *** show binlog events from ; @@ -19,4 +13,19 @@ master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ +delete from t1; +reset master; +begin; +insert into t1 values (1),(2); +*** the following UPDATE query wont generate any updates for the binlog *** +insert into t1 values (3),(4),(1),(2); +ERROR 23000: Duplicate entry '1' for key 'i' +commit; +*** Results of the test: the binlog must have only one Write_rows event not two *** +show binlog events from ; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Xid # # COMMIT /* XID */ drop table t1; diff --git a/mysql-test/suite/binlog/t/binlog_innodb_row.test b/mysql-test/suite/binlog/t/binlog_innodb_row.test index 7f42f5b95cb..aaba98e3284 100644 --- a/mysql-test/suite/binlog/t/binlog_innodb_row.test +++ b/mysql-test/suite/binlog/t/binlog_innodb_row.test @@ -9,18 +9,34 @@ source include/have_binlog_format_row.inc; # Bug #40221 Replication failure on RBR + UPDATE the primary key # -CREATE TABLE t1 (pk int auto_increment primary key) ENGINE=innodb; -show create table t1; +CREATE TABLE t1 (i int unique) ENGINE=innodb; +reset master; + +# part 1: update can cause the dup key + +begin; +insert into t1 values (1),(2); +--echo *** the following UPDATE query wont generate any updates for the binlog *** +--error ER_DUP_ENTRY +update t1 set i = 3 where i < 3; +commit; + +--echo *** Results of the test: the binlog must have only Write_rows events not any Update_rows *** +source include/show_binlog_events.inc; + +# part 2: insert can cause the dup key + +delete from t1; reset master; begin; insert into t1 values (1),(2); --echo *** the following UPDATE query wont generate any updates for the binlog *** --error ER_DUP_ENTRY -update t1 set pk = 3 where pk < 3; +insert into t1 values (3),(4),(1),(2); commit; ---echo *** Results of the test: the binlog must have only Write_rows events not any Update_rows *** +--echo *** Results of the test: the binlog must have only one Write_rows event not two *** source include/show_binlog_events.inc; drop table t1; From a8dd8f699551e083683b961123b317984455930c Mon Sep 17 00:00:00 2001 From: Chad MILLER Date: Mon, 8 Dec 2008 12:45:48 -0500 Subject: [PATCH 027/137] Replace C++ comment in a header file. Thanks, Alik! --- extra/yassl/include/openssl/ssl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extra/yassl/include/openssl/ssl.h b/extra/yassl/include/openssl/ssl.h index de09f1ebe4b..05b34a0dc45 100644 --- a/extra/yassl/include/openssl/ssl.h +++ b/extra/yassl/include/openssl/ssl.h @@ -203,8 +203,8 @@ SSL_CTX* SSL_CTX_new(SSL_METHOD*); SSL* SSL_new(SSL_CTX*); int SSL_set_fd (SSL*, YASSL_SOCKET_T); YASSL_SOCKET_T SSL_get_fd(const SSL*); -int SSL_connect(SSL*); // if you get an error from connect - // see note at top of REAMDE +int SSL_connect(SSL*); /* if you get an error from connect + see note at top of REAMDE */ int SSL_write(SSL*, const void*, int); int SSL_read(SSL*, void*, int); int SSL_accept(SSL*); From e6edcee80d8360e7f2eab469f9ed92410d82dc1c Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Mon, 8 Dec 2008 21:40:25 +0200 Subject: [PATCH 028/137] Bug #33420 Test 'rpl_packet' fails randomly with changed "Exec_Master_Log_Pos" binlog_row_mix_innodb_myisam resutls are corrected. The last operations prior the dup error is TRUNCATE table t2; Therefore after --error ER_DUP_ENTRY INSERT INTO t2 select * from t1; table t2 must be empty, and that is what the updated results confirm. --- mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result | 2 -- 1 file changed, 2 deletions(-) diff --git a/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result b/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result index 0b33d71b6f1..dcad7e022b7 100644 --- a/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result +++ b/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result @@ -385,8 +385,6 @@ master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map # # table_id: # (test.t2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Query # # use `test`; COMMIT master-bin.000001 # Query # # use `test`; DROP TABLE t2 master-bin.000001 # Query # # use `test`; BEGIN From b7139581325fe41ed584dfa653a2a66d211d4d67 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Tue, 9 Dec 2008 11:05:36 +0300 Subject: [PATCH 029/137] Fixed type_float failures in --ps-protocol mode introduced by the test case for bug #27483. The reason for the failures was bug #21205 (fixed in 6.0 by dtoa, but still present in 5.0/5.1). --- mysql-test/r/type_float.result | 12 ++++++------ mysql-test/t/type_float.test | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result index e7f17bd75a7..d86c515062a 100644 --- a/mysql-test/r/type_float.result +++ b/mysql-test/r/type_float.result @@ -398,11 +398,11 @@ insert into t1(d) values (9.2233720368547777e+18), (9.22337203685479e18), (1.84e19); update t1 set u = d; -select * from t1; -d u -9.22337203685478e+18 9223372036854775808 -9.22337203685478e+18 9223372036854779904 -9.22337203685479e+18 9223372036854790144 -1.84e+19 18400000000000000000 +select u from t1; +u +9223372036854775808 +9223372036854779904 +9223372036854790144 +18400000000000000000 drop table t1; End of 5.0 tests diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test index b23755b44fb..3ceef129912 100644 --- a/mysql-test/t/type_float.test +++ b/mysql-test/t/type_float.test @@ -265,7 +265,7 @@ insert into t1(d) values (9.2233720368547777e+18), (1.84e19); update t1 set u = d; -select * from t1; +select u from t1; drop table t1; From 315f6539876c50b16f3f122a66cf959050e7d2d5 Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Tue, 9 Dec 2008 12:30:49 +0400 Subject: [PATCH 030/137] Bug#35934 mysql_upgrade calls mysqlcheck with insufficient parameters modifying the original fix. As it turned out --fix-db-names option of the mysqlcheck suppress the --check_upgrade option, so we have to call the mysqlcheck twice from the mysql_upgrade. per-file comments: client/mysql_upgrade.c Bug#35934 mysql_upgrade calls mysqlcheck with insufficient parameters --- client/mysql_upgrade.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index e1fc4caf720..190bb2383e9 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -616,6 +616,18 @@ static int run_mysqlcheck_upgrade(void) "--check-upgrade", "--all-databases", "--auto-repair", + NULL); +} + + +static int run_mysqlcheck_fixnames(void) +{ + verbose("Running 'mysqlcheck'..."); + return run_tool(mysqlcheck_path, + NULL, /* Send output from mysqlcheck directly to screen */ + "--no-defaults", + ds_args.str, + "--all-databases", "--fix-db-names", "--fix-table-names", NULL); @@ -784,7 +796,8 @@ int main(int argc, char **argv) /* Run "mysqlcheck" and "mysql_fix_privilege_tables.sql" */ - if (run_mysqlcheck_upgrade() || + if (run_mysqlcheck_fixnames() || + run_mysqlcheck_upgrade() || run_sql_fix_privilege_tables()) { /* From b3012d08673df1e7685c227067b619b4ccaa52ac Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Tue, 9 Dec 2008 13:04:28 +0400 Subject: [PATCH 031/137] Bug#40949 Debug version of MySQL server crashes when run OPTIMIZE on compressed table. reset diagnostics area state after error message is sent --- mysql-test/r/myisampack.result | 22 ++++++++++++++++++++++ mysql-test/t/myisampack.test | 25 +++++++++++++++++++++++++ sql/sql_table.cc | 1 + 3 files changed, 48 insertions(+) diff --git a/mysql-test/r/myisampack.result b/mysql-test/r/myisampack.result index 5f39d318234..14b6283bf8f 100644 --- a/mysql-test/r/myisampack.result +++ b/mysql-test/r/myisampack.result @@ -27,3 +27,25 @@ CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK DROP TABLE t1; +drop table if exists t1; +create table t1(f1 int, f2 varchar(255)); +insert into t1 values(1, 'foo'), (2, 'bar'); +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +flush tables; +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize error Table 'test.t1' is read only +Warnings: +Error 1036 Table 't1' is read only +drop table t1; diff --git a/mysql-test/t/myisampack.test b/mysql-test/t/myisampack.test index 6598af6318a..99767f81033 100644 --- a/mysql-test/t/myisampack.test +++ b/mysql-test/t/myisampack.test @@ -31,3 +31,28 @@ FLUSH TABLES; --exec $MYISAMCHK -s --unpack $MYSQLTEST_VARDIR/master-data/test/t1 CHECK TABLE t1 EXTENDED; DROP TABLE t1; + +# +# Bug#40949 Debug version of MySQL server crashes when run OPTIMIZE on compressed table. +# +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1(f1 int, f2 varchar(255)); +insert into t1 values(1, 'foo'), (2, 'bar'); +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +flush tables; +--exec $MYISAMPACK $MYSQLTEST_VARDIR/master-data/test/t1 +optimize table t1; +drop table t1; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index ec35616bc89..16d420441d1 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4319,6 +4319,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, table->table=0; // For query cache if (protocol->write()) goto err; + thd->main_da.reset_diagnostics_area(); continue; /* purecov: end */ } From eb46763654e3f432d2e654681e9c079cbc3d4af0 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Tue, 9 Dec 2008 13:53:23 +0400 Subject: [PATCH 032/137] Bug#35796 SHOW CREATE TABLE and default value for BIT field show default value for BIT field in printable format --- mysql-test/r/type_bit.result | 15 +++++++++++++++ mysql-test/t/type_bit.test | 15 +++++++++++++++ sql/item.cc | 3 +++ sql/sql_show.cc | 18 +++++++++++++++--- 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/type_bit.result b/mysql-test/r/type_bit.result index 68c0e1635a3..2a83d9b4c62 100644 --- a/mysql-test/r/type_bit.result +++ b/mysql-test/r/type_bit.result @@ -708,4 +708,19 @@ HEX(b1) HEX(b2) i2 1 0 100 1 0 200 DROP TABLE t1, t2; +CREATE TABLE IF NOT EXISTS t1 ( +f1 bit(2) NOT NULL default b'10', +f2 bit(14) NOT NULL default b'11110000111100' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` bit(2) NOT NULL default b'10', + `f2` bit(14) NOT NULL default b'11110000111100' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci +DROP TABLE t1; +CREATE TABLE IF NOT EXISTS t1 ( +f1 bit(2) NOT NULL default b'' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; +ERROR 42000: Invalid default value for 'f1' End of 5.0 tests diff --git a/mysql-test/t/type_bit.test b/mysql-test/t/type_bit.test index 6a6b29deda4..81dca17f112 100644 --- a/mysql-test/t/type_bit.test +++ b/mysql-test/t/type_bit.test @@ -352,4 +352,19 @@ SELECT HEX(b1), HEX(b2), i2 FROM t2 DROP TABLE t1, t2; +# +# Bug #35796 SHOW CREATE TABLE and default value for BIT field +# +CREATE TABLE IF NOT EXISTS t1 ( +f1 bit(2) NOT NULL default b'10', +f2 bit(14) NOT NULL default b'11110000111100' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +--error ER_INVALID_DEFAULT +CREATE TABLE IF NOT EXISTS t1 ( +f1 bit(2) NOT NULL default b'' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; + --echo End of 5.0 tests diff --git a/sql/item.cc b/sql/item.cc index 182f4abdfe6..243c22bb7e6 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4950,6 +4950,9 @@ int Item_hex_string::save_in_field(Field *field, bool no_conversions) ulonglong nr; uint32 length= str_value.length(); + if (!length) + return 1; + if (length > 8) { nr= field->flags & UNSIGNED_FLAG ? ULONGLONG_MAX : LONGLONG_MAX; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 4e3d209f674..59082e0a295 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -798,7 +798,7 @@ static bool get_field_default_value(THD *thd, TABLE *table, { bool has_default; bool has_now_default; - + enum enum_field_types field_type= field->type(); /* We are using CURRENT_TIMESTAMP instead of NOW because it is more standard @@ -806,7 +806,7 @@ static bool get_field_default_value(THD *thd, TABLE *table, has_now_default= table->timestamp_field == field && field->unireg_check != Field::TIMESTAMP_UN_FIELD; - has_default= (field->type() != FIELD_TYPE_BLOB && + has_default= (field_type != FIELD_TYPE_BLOB && !(field->flags & NO_DEFAULT_VALUE_FLAG) && field->unireg_check != Field::NEXT_NUMBER && !((thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40)) @@ -821,7 +821,19 @@ static bool get_field_default_value(THD *thd, TABLE *table, { // Not null by default char tmp[MAX_FIELD_WIDTH]; String type(tmp, sizeof(tmp), field->charset()); - field->val_str(&type); + if (field_type == MYSQL_TYPE_BIT) + { + longlong dec= field->val_int(); + char *ptr= longlong2str(dec, tmp + 2, 2); + uint32 length= (uint32) (ptr - tmp); + tmp[0]= 'b'; + tmp[1]= '\''; + tmp[length]= '\''; + type.length(length + 1); + quoted= 0; + } + else + field->val_str(&type); if (type.length()) { String def_val; From 0661c210d3813a73d678f7e9d8347762b8a984a5 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Tue, 9 Dec 2008 14:00:43 +0400 Subject: [PATCH 033/137] bug#35558 Wrong server metadata blows up the client the problem: FORMAT func max_length value was calculated incorrectly the fix: correct calculation of max_length --- mysql-test/r/func_str.result | 12 +++++++++--- mysql-test/t/func_str.test | 10 ++++++++++ sql/item_strfunc.h | 5 +++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index d0809eca65b..c121c8937d7 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -717,8 +717,6 @@ insert(_latin2'abcd',2,3,_latin2'ef'), replace(_latin2'abcd',_latin2'b',_latin2'B'), encode('abcd','ab') ; -Warnings: -Warning 1265 Data truncated for column 'format(130,10)' at row 1 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -727,7 +725,7 @@ t1 CREATE TABLE `t1` ( `conv(130,16,10)` varchar(64) default NULL, `hex(130)` varchar(6) NOT NULL default '', `char(130)` varbinary(4) NOT NULL default '', - `format(130,10)` varchar(4) NOT NULL default '', + `format(130,10)` varchar(16) NOT NULL default '', `left(_latin2'a',1)` varchar(1) character set latin2 NOT NULL default '', `right(_latin2'a',1)` varchar(1) character set latin2 NOT NULL default '', `lcase(_latin2'a')` varchar(1) character set latin2 NOT NULL default '', @@ -2175,4 +2173,12 @@ SELECT HEX(c1) from v1; HEX(c1) 414243 DROP VIEW v1; +create table t1(a float); +insert into t1 values (1.33); +select format(a, 2) from t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def format(a, 2) 253 20 4 Y 0 2 8 +format(a, 2) +1.33 +drop table t1; End of 5.0 tests diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 1ca2bbfaf4c..8298a50c277 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -1149,4 +1149,14 @@ CREATE VIEW v1 AS SELECT CHAR(0x414243) as c1; SELECT HEX(c1) from v1; DROP VIEW v1; +# +# Bug #35558 Wrong server metadata blows up the client +# +create table t1(a float); +insert into t1 values (1.33); +--enable_metadata +select format(a, 2) from t1; +--disable_metadata +drop table t1; + --echo End of 5.0 tests diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 3648438a69b..23ac20a4017 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -516,8 +516,9 @@ public: { collation.set(default_charset()); uint char_length= args[0]->max_length/args[0]->collation.collation->mbmaxlen; - max_length= ((char_length + (char_length-args[0]->decimals)/3) * - collation.collation->mbmaxlen); + uint max_sep_count= char_length/3 + (decimals ? 1 : 0) + /*sign*/1; + max_length= (char_length + max_sep_count + decimals) * + collation.collation->mbmaxlen; } const char *func_name() const { return "format"; } void print(String *); From 66fa3c09a3827fcbf8c082de50fe7a606be03f69 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Tue, 9 Dec 2008 13:19:46 +0300 Subject: [PATCH 034/137] Added a missing bit from the original patch for bug #27483 which was lost when re-applying the patch manually to another tree. --- sql/field.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/field.cc b/sql/field.cc index 8188b51d4d1..f8ab4b852ec 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3473,7 +3473,7 @@ int Field_longlong::store(double nr) error= 1; } else - res=(longlong) (ulonglong) nr; + res=(longlong) double2ulonglong(nr); } else { From bc2095c19e037699bca80bad21e94e7adb75b6e5 Mon Sep 17 00:00:00 2001 From: Leonard Zhou Date: Tue, 9 Dec 2008 18:52:10 +0800 Subject: [PATCH 035/137] BUG#27477 Remove tmp-directory on MTR start --- mysql-test/mysql-test-run.pl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index b342421ca2e..20a0b639e84 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -2386,6 +2386,9 @@ sub remove_stale_vardir () { mtr_verbose("Removing $opt_vardir/"); mtr_rmtree("$opt_vardir/"); } + # Remove the "tmp" dir + mtr_verbose("Removing $opt_tmpdir/"); + mtr_rmtree("$opt_tmpdir/"); } # From d2b5e0bb940dbcf4dae0000a745cab58a351408e Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Tue, 9 Dec 2008 16:38:52 +0400 Subject: [PATCH 036/137] Bug#31291 ALTER TABLE CONVERT TO CHARACTER SET does not change some data types added ability for TINY[MEDIUM] text fields to be converted to greater subtype during alter if necessary(altered charset) --- mysql-test/r/alter_table.result | 16 ++++++++++++++++ mysql-test/t/alter_table.test | 13 +++++++++++++ sql/sql_table.cc | 4 +++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index 95c652055ec..d81086682f1 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -915,3 +915,19 @@ check table t1; Table Op Msg_type Msg_text test.t1 check status OK drop table t1; +create table t1 (a tinytext character set latin1); +alter table t1 convert to character set utf8; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` text +) ENGINE=MyISAM DEFAULT CHARSET=utf8 +drop table t1; +create table t1 (a mediumtext character set latin1); +alter table t1 convert to character set utf8; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` longtext +) ENGINE=MyISAM DEFAULT CHARSET=utf8 +drop table t1; diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index bcca122f9f8..18481291bba 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -696,3 +696,16 @@ unlock tables; select * from t1; check table t1; drop table t1; + + +# +# Bug#31291 ALTER TABLE CONVERT TO CHARACTER SET does not change some data types +# +create table t1 (a tinytext character set latin1); +alter table t1 convert to character set utf8; +show create table t1; +drop table t1; +create table t1 (a mediumtext character set latin1); +alter table t1 convert to character set utf8; +show create table t1; +drop table t1; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 8baeca9ccf7..eefe2a5596e 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1535,7 +1535,9 @@ static bool prepare_blob_field(THD *thd, create_field *sql_field) if ((sql_field->flags & BLOB_FLAG) && sql_field->length) { - if (sql_field->sql_type == FIELD_TYPE_BLOB) + if (sql_field->sql_type == FIELD_TYPE_BLOB || + sql_field->sql_type == FIELD_TYPE_TINY_BLOB || + sql_field->sql_type == FIELD_TYPE_MEDIUM_BLOB) { /* The user has given a length to the blob column */ sql_field->sql_type= get_blob_type_from_length(sql_field->length); From c5c64a30d44f720ff3c9a6bfcdbf11a0bcc70797 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Tue, 9 Dec 2008 16:59:47 +0400 Subject: [PATCH 037/137] Bug#31399 Wrong query result when doing join buffering over BIT fields if table has bit fields then uneven bits(if exist) are stored into null bits place. So we need to copy null bits in case of uneven bit field presence. --- mysql-test/r/type_bit.result | 26 ++++++++++++++++++++++++++ mysql-test/t/type_bit.test | 30 ++++++++++++++++++++++++++++++ sql/sql_select.cc | 8 ++++++-- 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/type_bit.result b/mysql-test/r/type_bit.result index 2a83d9b4c62..63dec0297d0 100644 --- a/mysql-test/r/type_bit.result +++ b/mysql-test/r/type_bit.result @@ -723,4 +723,30 @@ CREATE TABLE IF NOT EXISTS t1 ( f1 bit(2) NOT NULL default b'' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; ERROR 42000: Invalid default value for 'f1' +create table t1bit7 (a1 bit(7) not null) engine=MyISAM; +create table t2bit7 (b1 bit(7)) engine=MyISAM; +insert into t1bit7 values (b'1100000'); +insert into t1bit7 values (b'1100001'); +insert into t1bit7 values (b'1100010'); +insert into t2bit7 values (b'1100001'); +insert into t2bit7 values (b'1100010'); +insert into t2bit7 values (b'1100110'); +select bin(a1) from t1bit7, t2bit7 where t1bit7.a1=t2bit7.b1; +bin(a1) +1100001 +1100010 +drop table t1bit7, t2bit7; +create table t1bit7 (a1 bit(15) not null) engine=MyISAM; +create table t2bit7 (b1 bit(15)) engine=MyISAM; +insert into t1bit7 values (b'110000011111111'); +insert into t1bit7 values (b'110000111111111'); +insert into t1bit7 values (b'110001011111111'); +insert into t2bit7 values (b'110000111111111'); +insert into t2bit7 values (b'110001011111111'); +insert into t2bit7 values (b'110011011111111'); +select bin(a1) from t1bit7, t2bit7 where t1bit7.a1=t2bit7.b1; +bin(a1) +110000111111111 +110001011111111 +drop table t1bit7, t2bit7; End of 5.0 tests diff --git a/mysql-test/t/type_bit.test b/mysql-test/t/type_bit.test index 81dca17f112..bdc678688f1 100644 --- a/mysql-test/t/type_bit.test +++ b/mysql-test/t/type_bit.test @@ -367,4 +367,34 @@ CREATE TABLE IF NOT EXISTS t1 ( f1 bit(2) NOT NULL default b'' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; + +# +# Bug#31399 Wrong query result when doing join buffering over BIT fields +# +create table t1bit7 (a1 bit(7) not null) engine=MyISAM; +create table t2bit7 (b1 bit(7)) engine=MyISAM; + +insert into t1bit7 values (b'1100000'); +insert into t1bit7 values (b'1100001'); +insert into t1bit7 values (b'1100010'); +insert into t2bit7 values (b'1100001'); +insert into t2bit7 values (b'1100010'); +insert into t2bit7 values (b'1100110'); + +select bin(a1) from t1bit7, t2bit7 where t1bit7.a1=t2bit7.b1; +drop table t1bit7, t2bit7; + +create table t1bit7 (a1 bit(15) not null) engine=MyISAM; +create table t2bit7 (b1 bit(15)) engine=MyISAM; + +insert into t1bit7 values (b'110000011111111'); +insert into t1bit7 values (b'110000111111111'); +insert into t1bit7 values (b'110001011111111'); +insert into t2bit7 values (b'110000111111111'); +insert into t2bit7 values (b'110001011111111'); +insert into t2bit7 values (b'110011011111111'); + +select bin(a1) from t1bit7, t2bit7 where t1bit7.a1=t2bit7.b1; +drop table t1bit7, t2bit7; + --echo End of 5.0 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 2ac33c4e07f..b080fff8725 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -13233,6 +13233,7 @@ join_init_cache(THD *thd,JOIN_TAB *tables,uint table_count) length=0; for (i=0 ; i < table_count ; i++) { + bool have_bit_fields= FALSE; uint null_fields=0,used_fields; Field **f_ptr,*field; @@ -13247,13 +13248,16 @@ join_init_cache(THD *thd,JOIN_TAB *tables,uint table_count) length+=field->fill_cache_field(copy); if (copy->blob_field) (*blob_ptr++)=copy; - if (field->maybe_null()) + if (field->real_maybe_null()) null_fields++; + if (field->type() == MYSQL_TYPE_BIT && + ((Field_bit*)field)->bit_len) + have_bit_fields= TRUE; copy++; } } /* Copy null bits from table */ - if (null_fields && tables[i].table->s->null_fields) + if (null_fields || have_bit_fields) { /* must copy null bits */ copy->str=(char*) tables[i].table->null_flags; copy->length= tables[i].table->s->null_bytes; From 9ff609116d5888863a269bdc09a2336c4aa3a816 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Tue, 9 Dec 2008 19:31:22 +0400 Subject: [PATCH 038/137] updated test results --- .../suite/parts/r/partition_bit_innodb.result | 18 +++++++++--------- .../suite/parts/r/partition_bit_myisam.result | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/mysql-test/suite/parts/r/partition_bit_innodb.result b/mysql-test/suite/parts/r/partition_bit_innodb.result index 2ea66592679..a9ae917f13d 100644 --- a/mysql-test/suite/parts/r/partition_bit_innodb.result +++ b/mysql-test/suite/parts/r/partition_bit_innodb.result @@ -6,7 +6,7 @@ create table t1 (a bit(0), primary key (a)) engine='INNODB' partition by key (a) show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` bit(1) NOT NULL DEFAULT '\0', + `a` bit(1) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) */ @@ -18,7 +18,7 @@ partition pa2); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` bit(1) NOT NULL DEFAULT '\0', + `a` bit(1) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) @@ -30,7 +30,7 @@ partition by key (a) partitions 2; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` bit(64) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0', + `a` bit(64) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) @@ -58,7 +58,7 @@ partition pa4 max_rows=40 min_rows=2); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` bit(64) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0', + `a` bit(64) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) @@ -88,7 +88,7 @@ partition by key (a) partitions 4; show create table t2; Table Create Table t2 CREATE TABLE `t2` ( - `a` bit(1) NOT NULL DEFAULT '\0', + `a` bit(1) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) @@ -102,7 +102,7 @@ alter table t2 drop primary key; show create table t2; Table Create Table t2 CREATE TABLE `t2` ( - `a` bit(1) NOT NULL DEFAULT '\0' + `a` bit(1) NOT NULL DEFAULT b'0' ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) PARTITIONS 4 */ @@ -114,7 +114,7 @@ alter table t2 add primary key (a); show create table t2; Table Create Table t2 CREATE TABLE `t2` ( - `a` bit(1) NOT NULL DEFAULT '\0', + `a` bit(1) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) @@ -133,7 +133,7 @@ partition pa4 values less than (256)); show create table t3; Table Create Table t3 CREATE TABLE `t3` ( - `a` bit(8) NOT NULL DEFAULT '\0', + `a` bit(8) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) @@ -416,7 +416,7 @@ partition pa3 values in (17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32)); show create table t4; Table Create Table t4 CREATE TABLE `t4` ( - `a` bit(8) NOT NULL DEFAULT '\0', + `a` bit(8) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) diff --git a/mysql-test/suite/parts/r/partition_bit_myisam.result b/mysql-test/suite/parts/r/partition_bit_myisam.result index c1f067d80d1..680845c9971 100644 --- a/mysql-test/suite/parts/r/partition_bit_myisam.result +++ b/mysql-test/suite/parts/r/partition_bit_myisam.result @@ -6,7 +6,7 @@ create table t1 (a bit(0), primary key (a)) engine='MyISAM' partition by key (a) show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` bit(1) NOT NULL DEFAULT '\0', + `a` bit(1) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) */ @@ -18,7 +18,7 @@ partition pa2); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` bit(1) NOT NULL DEFAULT '\0', + `a` bit(1) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) @@ -30,7 +30,7 @@ partition by key (a) partitions 2; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` bit(64) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0', + `a` bit(64) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) @@ -58,7 +58,7 @@ partition pa4 max_rows=40 min_rows=2); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` bit(64) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0', + `a` bit(64) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) @@ -88,7 +88,7 @@ partition by key (a) partitions 4; show create table t2; Table Create Table t2 CREATE TABLE `t2` ( - `a` bit(1) NOT NULL DEFAULT '\0', + `a` bit(1) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) @@ -102,7 +102,7 @@ alter table t2 drop primary key; show create table t2; Table Create Table t2 CREATE TABLE `t2` ( - `a` bit(1) NOT NULL DEFAULT '\0' + `a` bit(1) NOT NULL DEFAULT b'0' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) PARTITIONS 4 */ @@ -114,7 +114,7 @@ alter table t2 add primary key (a); show create table t2; Table Create Table t2 CREATE TABLE `t2` ( - `a` bit(1) NOT NULL DEFAULT '\0', + `a` bit(1) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) @@ -133,7 +133,7 @@ partition pa4 values less than (256)); show create table t3; Table Create Table t3 CREATE TABLE `t3` ( - `a` bit(8) NOT NULL DEFAULT '\0', + `a` bit(8) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) @@ -416,7 +416,7 @@ partition pa3 values in (17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32)); show create table t4; Table Create Table t4 CREATE TABLE `t4` ( - `a` bit(8) NOT NULL DEFAULT '\0', + `a` bit(8) NOT NULL DEFAULT b'0', PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) From 71296ae2e2c3b6f87ad392aa3f45b9c53a41b2f2 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Tue, 9 Dec 2008 19:46:03 +0200 Subject: [PATCH 039/137] Bug #37936: ASSERT_COLUMN_MARKED_FOR_WRITE in Field_datetime::store , Field_varstring::store The code that temporary saved the bitmaps of the read set and the write set so that it can set it to all columns for debug purposes was not expecting that the table->read_set and table->write_set can be the same. And was always saving both in sequence. As a result the original value was never restored. Fixed by saving & restoring the original value only once if the two sets are the same (in a special set of functions). --- mysql-test/r/select.result | 26 ++++++++++++++++++++++++++ mysql-test/t/select.test | 33 +++++++++++++++++++++++++++++++++ sql/item_cmpfunc.cc | 18 ++++++------------ sql/opt_range.cc | 26 +++++++++++--------------- sql/table.h | 30 ++++++++++++++++++++++++++++++ 5 files changed, 106 insertions(+), 27 deletions(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 4b2464af688..313bc9b9630 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -4358,3 +4358,29 @@ a 4 5 DROP TABLE t1; +CREATE TABLE A (date_key date); +CREATE TABLE C ( +pk int, +int_nokey int, +int_key int, +date_key date NOT NULL, +date_nokey date, +varchar_key varchar(1) +); +INSERT INTO C VALUES +(1,1,1,'0000-00-00',NULL,NULL), +(1,1,1,'0000-00-00',NULL,NULL); +SELECT 1 FROM C WHERE pk > ANY (SELECT 1 FROM C); +1 +SELECT COUNT(DISTINCT 1) FROM C +WHERE date_key = (SELECT 1 FROM A WHERE C.date_key IS NULL) GROUP BY pk; +COUNT(DISTINCT 1) +SELECT date_nokey FROM C +WHERE int_key IN (SELECT 1 FROM A) +HAVING date_nokey = '10:41:7' +ORDER BY date_key; +date_nokey +Warnings: +Warning 1292 Incorrect date value: '10:41:7' for column 'date_nokey' at row 1 +DROP TABLE A,C; +End of 5.1 tests diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 30abb797e83..020f94699f9 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -3701,3 +3701,36 @@ SELECT a FROM t1 ORDER BY a LIMIT 2; SELECT a FROM t1 ORDER BY a LIMIT 2,4294967296; SELECT a FROM t1 ORDER BY a LIMIT 2,4294967297; DROP TABLE t1; + +# +# Bug #37936: ASSERT_COLUMN_MARKED_FOR_WRITE in Field_datetime::store , +# Field_varstring::store +# + +CREATE TABLE A (date_key date); + +CREATE TABLE C ( + pk int, + int_nokey int, + int_key int, + date_key date NOT NULL, + date_nokey date, + varchar_key varchar(1) +); + +INSERT INTO C VALUES +(1,1,1,'0000-00-00',NULL,NULL), +(1,1,1,'0000-00-00',NULL,NULL); + +SELECT 1 FROM C WHERE pk > ANY (SELECT 1 FROM C); + +SELECT COUNT(DISTINCT 1) FROM C + WHERE date_key = (SELECT 1 FROM A WHERE C.date_key IS NULL) GROUP BY pk; +SELECT date_nokey FROM C + WHERE int_key IN (SELECT 1 FROM A) + HAVING date_nokey = '10:41:7' + ORDER BY date_key; + +DROP TABLE A,C; + +--echo End of 5.1 tests diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index cefa479fea6..564632fbb9b 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -394,19 +394,16 @@ static bool convert_constant_item(THD *thd, Item_field *field_item, TABLE *table= field->table; ulong orig_sql_mode= thd->variables.sql_mode; enum_check_fields orig_count_cuted_fields= thd->count_cuted_fields; - my_bitmap_map *old_write_map; - my_bitmap_map *old_read_map; + my_bitmap_map *old_maps[2]; ulonglong orig_field_val; /* original field value if valid */ - LINT_INIT(old_write_map); - LINT_INIT(old_read_map); + LINT_INIT(old_maps[0]); + LINT_INIT(old_maps[1]); LINT_INIT(orig_field_val); if (table) - { - old_write_map= dbug_tmp_use_all_columns(table, table->write_set); - old_read_map= dbug_tmp_use_all_columns(table, table->read_set); - } + dbug_tmp_use_all_columns(table, old_maps, + table->read_set, table->write_set); /* For comparison purposes allow invalid dates like 2000-01-32 */ thd->variables.sql_mode= (orig_sql_mode & ~MODE_NO_ZERO_DATE) | MODE_INVALID_DATES; @@ -437,10 +434,7 @@ static bool convert_constant_item(THD *thd, Item_field *field_item, thd->variables.sql_mode= orig_sql_mode; thd->count_cuted_fields= orig_count_cuted_fields; if (table) - { - dbug_tmp_restore_column_map(table->write_set, old_write_map); - dbug_tmp_restore_column_map(table->read_set, old_read_map); - } + dbug_tmp_restore_column_maps(table->read_set, table->write_set, old_maps); } return result; } diff --git a/sql/opt_range.cc b/sql/opt_range.cc index bafc368e415..7d9709909c3 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2668,7 +2668,7 @@ bool prune_partitions(THD *thd, TABLE *table, Item *pprune_cond) PART_PRUNE_PARAM prune_param; MEM_ROOT alloc; RANGE_OPT_PARAM *range_par= &prune_param.range_param; - my_bitmap_map *old_read_set, *old_write_set; + my_bitmap_map *old_sets[2]; prune_param.part_info= part_info; init_sql_alloc(&alloc, thd->variables.range_alloc_block_size, 0); @@ -2682,8 +2682,8 @@ bool prune_partitions(THD *thd, TABLE *table, Item *pprune_cond) DBUG_RETURN(FALSE); } - old_write_set= dbug_tmp_use_all_columns(table, table->write_set); - old_read_set= dbug_tmp_use_all_columns(table, table->read_set); + dbug_tmp_use_all_columns(table, old_sets, + table->read_set, table->write_set); range_par->thd= thd; range_par->table= table; /* range_par->cond doesn't need initialization */ @@ -2773,8 +2773,7 @@ all_used: retval= FALSE; // some partitions are used mark_all_partitions_as_used(prune_param.part_info); end: - dbug_tmp_restore_column_map(table->write_set, old_write_set); - dbug_tmp_restore_column_map(table->read_set, old_read_set); + dbug_tmp_restore_column_maps(table->read_set, table->write_set, old_sets); thd->no_errors=0; thd->mem_root= range_par->old_root; free_root(&alloc,MYF(0)); // Return memory & allocator @@ -11145,9 +11144,9 @@ print_key(KEY_PART *key_part, const uchar *key, uint used_length) String tmp(buff,sizeof(buff),&my_charset_bin); uint store_length; TABLE *table= key_part->field->table; - my_bitmap_map *old_write_set, *old_read_set; - old_write_set= dbug_tmp_use_all_columns(table, table->write_set); - old_read_set= dbug_tmp_use_all_columns(table, table->read_set); + my_bitmap_map *old_sets[2]; + + dbug_tmp_use_all_columns(table, old_sets, table->read_set, table->write_set); for (; key < key_end; key+=store_length, key_part++) { @@ -11173,8 +11172,7 @@ print_key(KEY_PART *key_part, const uchar *key, uint used_length) if (key+store_length < key_end) fputc('/',DBUG_FILE); } - dbug_tmp_restore_column_map(table->write_set, old_write_set); - dbug_tmp_restore_column_map(table->read_set, old_read_set); + dbug_tmp_restore_column_maps(table->read_set, table->write_set, old_sets); } @@ -11182,18 +11180,16 @@ static void print_quick(QUICK_SELECT_I *quick, const key_map *needed_reg) { char buf[MAX_KEY/8+1]; TABLE *table; - my_bitmap_map *old_read_map, *old_write_map; + my_bitmap_map *old_sets[2]; DBUG_ENTER("print_quick"); if (!quick) DBUG_VOID_RETURN; DBUG_LOCK_FILE; table= quick->head; - old_read_map= dbug_tmp_use_all_columns(table, table->read_set); - old_write_map= dbug_tmp_use_all_columns(table, table->write_set); + dbug_tmp_use_all_columns(table, old_sets, table->read_set, table->write_set); quick->dbug_dump(0, TRUE); - dbug_tmp_restore_column_map(table->read_set, old_read_map); - dbug_tmp_restore_column_map(table->write_set, old_write_map); + dbug_tmp_restore_column_maps(table->read_set, table->write_set, old_sets); fprintf(DBUG_FILE,"other_keys: 0x%s:\n", needed_reg->print(buf)); diff --git a/sql/table.h b/sql/table.h index ccd6b60664e..a89434b23ed 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1692,5 +1692,35 @@ static inline void dbug_tmp_restore_column_map(MY_BITMAP *bitmap, #endif } + +/* + Variant of the above : handle both read and write sets. + Provide for the possiblity of the read set being the same as the write set +*/ +static inline void dbug_tmp_use_all_columns(TABLE *table, + my_bitmap_map **save, + MY_BITMAP *read_set, + MY_BITMAP *write_set) +{ +#ifndef DBUG_OFF + save[0]= read_set->bitmap; + save[1]= write_set->bitmap; + (void) tmp_use_all_columns(table, read_set); + (void) tmp_use_all_columns(table, write_set); +#endif +} + + +static inline void dbug_tmp_restore_column_maps(MY_BITMAP *read_set, + MY_BITMAP *write_set, + my_bitmap_map **old) +{ +#ifndef DBUG_OFF + tmp_restore_column_map(read_set, old[0]); + tmp_restore_column_map(write_set, old[1]); +#endif +} + + size_t max_row_length(TABLE *table, const uchar *data); From d506265f2ccbaea41f268aa58f0272273537e443 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Tue, 9 Dec 2008 20:35:02 +0200 Subject: [PATCH 040/137] backported the fix for bug #34773 to 5.0 --- mysql-test/r/explain.result | 48 +++++++++++++++++++++++++++++++++++++ mysql-test/t/explain.test | 29 ++++++++++++++++++++++ sql/item.cc | 4 ++-- sql/item_sum.cc | 37 +++++++++++++++++++++++++--- sql/item_sum.h | 25 +++++++++++++------ sql/opt_range.cc | 2 +- sql/opt_sum.cc | 6 ++--- sql/sql_select.cc | 16 ++++++------- 8 files changed, 143 insertions(+), 24 deletions(-) diff --git a/mysql-test/r/explain.result b/mysql-test/r/explain.result index a4c8432d2a4..3aa189f4a9d 100644 --- a/mysql-test/r/explain.result +++ b/mysql-test/r/explain.result @@ -107,3 +107,51 @@ X X X X X X X X X X X X X X X X X X Range checked for each record (index map: 0xFFFFFFFFFF) DROP TABLE t2; DROP TABLE t1; +CREATE TABLE t1(a INT); +CREATE TABLE t2(a INT); +INSERT INTO t1 VALUES (1),(2); +INSERT INTO t2 VALUES (1),(2); +EXPLAIN EXTENDED SELECT 1 +FROM (SELECT COUNT(DISTINCT t1.a) FROM t1,t2 GROUP BY t1.a) AS s1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY ALL NULL NULL NULL NULL 2 +2 DERIVED t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort +2 DERIVED t2 ALL NULL NULL NULL NULL 2 +Warnings: +Note 1003 select 1 AS `1` from (select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT t1.a)` from `test`.`t1` join `test`.`t2` group by `test`.`t1`.`a`) `s1` +EXPLAIN EXTENDED SELECT 1 +FROM (SELECT COUNT(DISTINCT t1.a) FROM t1,t2 GROUP BY t1.a) AS s1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY ALL NULL NULL NULL NULL 2 +2 DERIVED t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort +2 DERIVED t2 ALL NULL NULL NULL NULL 2 +Warnings: +Note 1003 select 1 AS `1` from (select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT t1.a)` from `test`.`t1` join `test`.`t2` group by `test`.`t1`.`a`) `s1` +prepare s1 from +'EXPLAIN EXTENDED SELECT 1 + FROM (SELECT COUNT(DISTINCT t1.a) FROM t1,t2 GROUP BY t1.a) AS s1'; +execute s1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY ALL NULL NULL NULL NULL 2 +2 DERIVED t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort +2 DERIVED t2 ALL NULL NULL NULL NULL 2 +Warnings: +Note 1003 select 1 AS `1` from (select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT t1.a)` from `test`.`t1` join `test`.`t2` group by `test`.`t1`.`a`) `s1` +prepare s1 from +'EXPLAIN EXTENDED SELECT 1 + FROM (SELECT COUNT(DISTINCT t1.a) FROM t1,t2 GROUP BY t1.a) AS s1'; +execute s1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY ALL NULL NULL NULL NULL 2 +2 DERIVED t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort +2 DERIVED t2 ALL NULL NULL NULL NULL 2 +Warnings: +Note 1003 select 1 AS `1` from (select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT t1.a)` from `test`.`t1` join `test`.`t2` group by `test`.`t1`.`a`) `s1` +execute s1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY ALL NULL NULL NULL NULL 2 +2 DERIVED t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort +2 DERIVED t2 ALL NULL NULL NULL NULL 2 +Warnings: +Note 1003 select 1 AS `1` from (select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT t1.a)` from `test`.`t1` join `test`.`t2` group by `test`.`t1`.`a`) `s1` +DROP TABLE t1,t2; diff --git a/mysql-test/t/explain.test b/mysql-test/t/explain.test index c9ae8aceaf6..0247aca82df 100644 --- a/mysql-test/t/explain.test +++ b/mysql-test/t/explain.test @@ -94,4 +94,33 @@ EXPLAIN SELECT 1 FROM DROP TABLE t2; DROP TABLE t1; +# +# Bug #34773: query with explain extended and derived table / other table +# crashes server +# + +CREATE TABLE t1(a INT); +CREATE TABLE t2(a INT); +INSERT INTO t1 VALUES (1),(2); +INSERT INTO t2 VALUES (1),(2); + +EXPLAIN EXTENDED SELECT 1 + FROM (SELECT COUNT(DISTINCT t1.a) FROM t1,t2 GROUP BY t1.a) AS s1; + +EXPLAIN EXTENDED SELECT 1 + FROM (SELECT COUNT(DISTINCT t1.a) FROM t1,t2 GROUP BY t1.a) AS s1; + +prepare s1 from +'EXPLAIN EXTENDED SELECT 1 + FROM (SELECT COUNT(DISTINCT t1.a) FROM t1,t2 GROUP BY t1.a) AS s1'; +execute s1; + +prepare s1 from +'EXPLAIN EXTENDED SELECT 1 + FROM (SELECT COUNT(DISTINCT t1.a) FROM t1,t2 GROUP BY t1.a) AS s1'; +execute s1; +execute s1; + +DROP TABLE t1,t2; + # End of 5.0 tests. diff --git a/sql/item.cc b/sql/item.cc index 243c22bb7e6..2a89c86cd88 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -6795,7 +6795,7 @@ enum_field_types Item_type_holder::get_real_type(Item *item) */ Item_sum *item_sum= (Item_sum *) item; if (item_sum->keep_field_type()) - return get_real_type(item_sum->args[0]); + return get_real_type(item_sum->get_arg(0)); break; } case FUNC_ITEM: @@ -7059,7 +7059,7 @@ void Item_type_holder::get_full_info(Item *item) if (item->type() == Item::SUM_FUNC_ITEM && (((Item_sum*)item)->sum_func() == Item_sum::MAX_FUNC || ((Item_sum*)item)->sum_func() == Item_sum::MIN_FUNC)) - item = ((Item_sum*)item)->args[0]; + item = ((Item_sum*)item)->get_arg(0); /* We can have enum/set type after merging only if we have one enum|set field (or MIN|MAX(enum|set field)) and number of NULL fields diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 91320d6b56b..d33d92a5238 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -370,6 +370,10 @@ Item_sum::Item_sum(List &list) :arg_count(list.elements), args[i++]= item; } } + if (!(orig_args= (Item **) sql_alloc(sizeof(Item *) * arg_count))) + { + args= NULL; + } mark_as_sum_func(); list.empty(); // Fields are used } @@ -380,18 +384,28 @@ Item_sum::Item_sum(List &list) :arg_count(list.elements), */ Item_sum::Item_sum(THD *thd, Item_sum *item): - Item_result_field(thd, item), arg_count(item->arg_count), + Item_result_field(thd, item), aggr_sel(item->aggr_sel), nest_level(item->nest_level), aggr_level(item->aggr_level), - quick_group(item->quick_group), used_tables_cache(item->used_tables_cache), + quick_group(item->quick_group), + arg_count(item->arg_count), orig_args(NULL), + used_tables_cache(item->used_tables_cache), forced_const(item->forced_const) { if (arg_count <= 2) + { args=tmp_args; + orig_args=tmp_orig_args; + } else + { if (!(args= (Item**) thd->alloc(sizeof(Item*)*arg_count))) return; + if (!(orig_args= (Item**) thd->alloc(sizeof(Item*)*arg_count))) + return; + } memcpy(args, item->args, sizeof(Item*)*arg_count); + memcpy(orig_args, item->orig_args, sizeof(Item*)*arg_count); } @@ -426,12 +440,13 @@ void Item_sum::make_field(Send_field *tmp_field) void Item_sum::print(String *str) { + Item **pargs= orig_args; str->append(func_name()); for (uint i=0 ; i < arg_count ; i++) { if (i) str->append(','); - args[i]->print(str); + pargs[i]->print(str); } str->append(')'); } @@ -532,6 +547,13 @@ void Item_sum::update_used_tables () } +Item *Item_sum::set_arg(int i, THD *thd, Item *new_val) +{ + thd->change_item_tree(args + i, new_val); + return new_val; +} + + String * Item_sum_num::val_str(String *str) { @@ -583,6 +605,7 @@ Item_sum_num::fix_fields(THD *thd, Item **ref) if (check_sum_func(thd, ref)) return TRUE; + memcpy (orig_args, args, sizeof (Item *) * arg_count); fixed= 1; return FALSE; } @@ -670,6 +693,7 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref) if (check_sum_func(thd, ref)) return TRUE; + orig_args[0]= args[0]; fixed= 1; return FALSE; } @@ -3107,6 +3131,12 @@ Item_func_group_concat(Name_resolution_context *context_arg, sizeof(ORDER*)*arg_count_order))) return; + if (!(orig_args= (Item **) sql_alloc(sizeof(Item *) * arg_count))) + { + args= NULL; + return; + } + order= (ORDER**)(args + arg_count); /* fill args items of show and sort */ @@ -3334,6 +3364,7 @@ Item_func_group_concat::fix_fields(THD *thd, Item **ref) if (check_sum_func(thd, ref)) return TRUE; + memcpy (orig_args, args, sizeof (Item *) * arg_count); fixed= 1; return FALSE; } diff --git a/sql/item_sum.h b/sql/item_sum.h index d39fc96e254..51a1eff9bbf 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -228,10 +228,8 @@ public: VARIANCE_FUNC, SUM_BIT_FUNC, UDF_SUM_FUNC, GROUP_CONCAT_FUNC }; - Item **args, *tmp_args[2]; Item **ref_by; /* pointer to a ref to the object used to register it */ Item_sum *next; /* next in the circular chain of registered objects */ - uint arg_count; Item_sum *in_sum_func; /* embedding set function if any */ st_select_lex * aggr_sel; /* select where the function is aggregated */ int8 nest_level; /* number of the nesting level of the set function */ @@ -248,24 +246,32 @@ public: List outer_fields; protected: + uint arg_count; + Item **args, *tmp_args[2]; + /* + Copy of the arguments list to hold the original set of arguments. + Used in EXPLAIN EXTENDED instead of the current argument list because + the current argument list can be altered by usage of temporary tables. + */ + Item **orig_args, *tmp_orig_args[2]; table_map used_tables_cache; bool forced_const; public: void mark_as_sum_func(); - Item_sum() :arg_count(0), quick_group(1), forced_const(FALSE) + Item_sum() :quick_group(1), arg_count(0), forced_const(FALSE) { mark_as_sum_func(); } - Item_sum(Item *a) :args(tmp_args), arg_count(1), quick_group(1), - forced_const(FALSE) + Item_sum(Item *a) :quick_group(1), arg_count(1), args(tmp_args), + orig_args(tmp_orig_args), forced_const(FALSE) { args[0]=a; mark_as_sum_func(); } - Item_sum( Item *a, Item *b ) :args(tmp_args), arg_count(2), quick_group(1), - forced_const(FALSE) + Item_sum( Item *a, Item *b ) :quick_group(1), arg_count(2), args(tmp_args), + orig_args(tmp_orig_args), forced_const(FALSE) { args[0]=a; args[1]=b; mark_as_sum_func(); @@ -374,6 +380,10 @@ public: bool register_sum_func(THD *thd, Item **ref); st_select_lex *depended_from() { return (nest_level == aggr_level ? 0 : aggr_sel); } + + Item *get_arg(int i) { return args[i]; } + Item *set_arg(int i, THD *thd, Item *new_val); + uint get_arg_count() { return arg_count; } }; @@ -981,6 +991,7 @@ public: if (udf.fix_fields(thd, this, this->arg_count, this->args)) return TRUE; + memcpy (orig_args, args, sizeof (Item *) * arg_count); return check_sum_func(thd, ref); } enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; } diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 204ebdb6f33..7d9b1179d87 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -7735,7 +7735,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree) DBUG_RETURN(NULL); /* The argument of MIN/MAX. */ - Item *expr= min_max_item->args[0]->real_item(); + Item *expr= min_max_item->get_arg(0)->real_item(); if (expr->type() == Item::FIELD_ITEM) /* Is it an attribute? */ { if (! min_max_arg_item) diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index 3fc62d05ae5..39db1344588 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -160,7 +160,7 @@ int opt_sum_query(TABLE_LIST *tables, List &all_fields,COND *conds) to the number of rows in the tables if this number is exact and there are no outer joins. */ - if (!conds && !((Item_sum_count*) item)->args[0]->maybe_null && + if (!conds && !((Item_sum_count*) item)->get_arg(0)->maybe_null && !outer_tables && is_exact_count) { ((Item_sum_count*) item)->make_const(count); @@ -176,7 +176,7 @@ int opt_sum_query(TABLE_LIST *tables, List &all_fields,COND *conds) parts of the key is found in the COND, then we can use indexes to find the key. */ - Item *expr=item_sum->args[0]; + Item *expr=item_sum->get_arg(0); if (expr->real_item()->type() == Item::FIELD_ITEM) { byte key_buff[MAX_KEY_LENGTH]; @@ -319,7 +319,7 @@ int opt_sum_query(TABLE_LIST *tables, List &all_fields,COND *conds) parts of the key is found in the COND, then we can use indexes to find the key. */ - Item *expr=item_sum->args[0]; + Item *expr=item_sum->get_arg(0); if (expr->real_item()->type() == Item::FIELD_ITEM) { byte key_buff[MAX_KEY_LENGTH]; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b080fff8725..48276170caf 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -9444,11 +9444,11 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, } if (type == Item::SUM_FUNC_ITEM && !group && !save_sum_fields) { /* Can't calc group yet */ - ((Item_sum*) item)->result_field=0; - for (i=0 ; i < ((Item_sum*) item)->arg_count ; i++) + Item_sum *sum_item= (Item_sum *) item; + sum_item->result_field=0; + for (i=0 ; i < sum_item->get_arg_count() ; i++) { - Item **argp= ((Item_sum*) item)->args + i; - Item *arg= *argp; + Item *arg= sum_item->get_arg(i); if (!arg->const_item()) { uint field_index= (uint) (reg_field - table->field); @@ -9478,7 +9478,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, string_total_length+= new_field->pack_length(); } thd->mem_root= mem_root_save; - thd->change_item_tree(argp, new Item_field(new_field)); + arg= sum_item->set_arg(i, thd, new Item_field(new_field)); thd->mem_root= &table->mem_root; if (!(new_field->flags & NOT_NULL_FLAG)) { @@ -9487,7 +9487,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, new_field->maybe_null() is still false, it will be changed below. But we have to setup Item_field correctly */ - (*argp)->maybe_null=1; + arg->maybe_null=1; } new_field->query_id= thd->query_id; } @@ -13922,9 +13922,9 @@ count_field_types(SELECT_LEX *select_lex, TMP_TABLE_PARAM *param, param->quick_group=0; // UDF SUM function param->sum_func_count++; - for (uint i=0 ; i < sum_item->arg_count ; i++) + for (uint i=0 ; i < sum_item->get_arg_count() ; i++) { - if (sum_item->args[0]->real_item()->type() == Item::FIELD_ITEM) + if (sum_item->get_arg(i)->real_item()->type() == Item::FIELD_ITEM) param->field_count++; else param->func_count++; From f5a850109afea58f5b04af3d4b3703466a5a122c Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 10 Dec 2008 13:05:57 +0400 Subject: [PATCH 041/137] Bug#38227 EXTRACTVALUE doesn't work with DTD declarations Problem: XML syntax parser allowed to use quoted strings as attribute names, and tried to put them into parser state stack instead of identifiers. After that parser failed, if quoted string contained some slash characters. Fix: - Disallowing quoted strings in regular tags. - Allowing quoted string in DOCTYPE declararion, but don't push it into parse state stack (just skip it). --- mysql-test/r/xml.result | 24 ++++++++++++++++++++++++ mysql-test/t/xml.test | 25 +++++++++++++++++++++++++ strings/xml.c | 13 +++++++++++-- 3 files changed, 60 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/xml.result b/mysql-test/r/xml.result index 56c884343e3..41c0d6bee21 100644 --- a/mysql-test/r/xml.result +++ b/mysql-test/r/xml.result @@ -1029,4 +1029,28 @@ SELECT 1 FROM t1 ORDER BY(UPDATEXML(a, '1', '1')); 1 1 DROP TABLE t1; +SET @xml= +' + + + Title - document with document declaration + + Hi, Im a webpage with document a declaration +'; +SELECT ExtractValue(@xml, 'html/head/title'); +ExtractValue(@xml, 'html/head/title') + Title - document with document declaration +SELECT ExtractValue(@xml, 'html/body'); +ExtractValue(@xml, 'html/body') + Hi, Im a webpage with document a declaration +SELECT ExtractValue('CharData', '/xml'); +ExtractValue('CharData', '/xml') +NULL +Warnings: +Warning 1525 Incorrect XML value: 'parse error at line 1 pos 11: STRING unexpected ('>' wanted)' +SELECT ExtractValue('CharData', '/xml'); +ExtractValue('CharData', '/xml') +NULL +Warnings: +Warning 1525 Incorrect XML value: 'parse error at line 1 pos 17: STRING unexpected ('>' wanted)' End of 5.1 tests diff --git a/mysql-test/t/xml.test b/mysql-test/t/xml.test index 5ca9c7afd76..d840e14ba5f 100644 --- a/mysql-test/t/xml.test +++ b/mysql-test/t/xml.test @@ -551,4 +551,29 @@ INSERT INTO t1 VALUES (0), (0); SELECT 1 FROM t1 ORDER BY(UPDATEXML(a, '1', '1')); DROP TABLE t1; +# +# BUG#38227 EXTRACTVALUE doesn't work with DTD declarations +# +# Check that quoted strings work fine in DOCTYPE declaration. +# + +SET @xml= +' + + + Title - document with document declaration + + Hi, Im a webpage with document a declaration +'; + +SELECT ExtractValue(@xml, 'html/head/title'); +SELECT ExtractValue(@xml, 'html/body'); + +# These two documents will fail. +# Quoted strings are not allowed in regular tags +# +SELECT ExtractValue('CharData', '/xml'); +SELECT ExtractValue('CharData', '/xml'); + + --echo End of 5.1 tests diff --git a/strings/xml.c b/strings/xml.c index 5c62a8e8603..1b697ec6b26 100644 --- a/strings/xml.c +++ b/strings/xml.c @@ -328,7 +328,7 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, size_t len) } while ((MY_XML_IDENT == (lex=my_xml_scan(p,&a))) || - (MY_XML_STRING == lex)) + ((MY_XML_STRING == lex && exclam))) { MY_XML_ATTR b; if (MY_XML_EQ == (lex=my_xml_scan(p,&b))) @@ -349,13 +349,22 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, size_t len) return MY_XML_ERROR; } } - else if ((MY_XML_STRING == lex) || (MY_XML_IDENT == lex)) + else if (MY_XML_IDENT == lex) { p->current_node_type= MY_XML_NODE_ATTR; if ((MY_XML_OK != my_xml_enter(p,a.beg,(size_t) (a.end-a.beg))) || (MY_XML_OK != my_xml_leave(p,a.beg,(size_t) (a.end-a.beg)))) return MY_XML_ERROR; } + else if ((MY_XML_STRING == lex) && exclam) + { + /* + We are in , e.g. + + + Just skip "SystemLiteral" and "PublicidLiteral" + */ + } else break; } From 33bac53782bda23d4ff9a063c049e06c22bd3c4f Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 10 Dec 2008 16:07:32 +0300 Subject: [PATCH 042/137] Fix for a test failure on Solaris/x86/gcc introduced by the patch for bug #27483. Removed values with more than 15 significant digits from the test case. Results of reading/printing such values using system library functions depend on implementation and thus are not portable. --- mysql-test/r/type_float.result | 6 +----- mysql-test/t/type_float.test | 4 +--- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result index d86c515062a..8caabbff047 100644 --- a/mysql-test/r/type_float.result +++ b/mysql-test/r/type_float.result @@ -393,15 +393,11 @@ f1 + 0e0 -1.0000000150475e+30 drop table t1; create table t1(d double, u bigint unsigned); -insert into t1(d) values (9.2233720368547777e+18), -(9.223372036854779e18), -(9.22337203685479e18), +insert into t1(d) values (9.22337203685479e18), (1.84e19); update t1 set u = d; select u from t1; u -9223372036854775808 -9223372036854779904 9223372036854790144 18400000000000000000 drop table t1; diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test index 3ceef129912..53bcf44061d 100644 --- a/mysql-test/t/type_float.test +++ b/mysql-test/t/type_float.test @@ -259,9 +259,7 @@ drop table t1; create table t1(d double, u bigint unsigned); -insert into t1(d) values (9.2233720368547777e+18), - (9.223372036854779e18), - (9.22337203685479e18), +insert into t1(d) values (9.22337203685479e18), (1.84e19); update t1 set u = d; From 2b64acde8bbf5148fb288895a114f1832e909937 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Wed, 10 Dec 2008 18:13:11 +0400 Subject: [PATCH 043/137] Bug#37956 memory leak and / or crash with geometry and prepared statements! Bug#37671 crash on prepared statement + cursor + geometry + too many open files! if mysql_execute_command() returns error then free materialized_cursor object. is_rnd_inited is added to satisfy rnd_end() assertion (handler may be uninitialized in some cases) --- sql/sql_cursor.cc | 18 +++++++++---- sql/sql_select.cc | 7 +++-- tests/mysql_client_test.c | 54 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 7 deletions(-) diff --git a/sql/sql_cursor.cc b/sql/sql_cursor.cc index 16567765ba6..83c60814cf3 100644 --- a/sql/sql_cursor.cc +++ b/sql/sql_cursor.cc @@ -85,6 +85,7 @@ class Materialized_cursor: public Server_side_cursor List item_list; ulong fetch_limit; ulong fetch_count; + bool is_rnd_inited; public: Materialized_cursor(select_result *result, TABLE *table); @@ -191,7 +192,11 @@ int mysql_open_cursor(THD *thd, uint flags, select_result *result, such command is SHOW VARIABLES or SHOW STATUS. */ if (rc) + { + if (result_materialize->materialized_cursor) + delete result_materialize->materialized_cursor; goto err_open; + } if (sensitive_cursor->is_open()) { @@ -532,7 +537,8 @@ Materialized_cursor::Materialized_cursor(select_result *result_arg, :Server_side_cursor(&table_arg->mem_root, result_arg), table(table_arg), fetch_limit(0), - fetch_count(0) + fetch_count(0), + is_rnd_inited(0) { fake_unit.init_query(); fake_unit.thd= table->in_use; @@ -589,11 +595,12 @@ int Materialized_cursor::open(JOIN *join __attribute__((unused))) THD *thd= fake_unit.thd; int rc; Query_arena backup_arena; - thd->set_n_backup_active_arena(this, &backup_arena); /* Create a list of fields and start sequential scan */ - rc= (result->prepare(item_list, &fake_unit) || - table->file->ha_rnd_init(TRUE)); + rc= result->prepare(item_list, &fake_unit); + if (!rc && !(rc= table->file->ha_rnd_init(TRUE))) + is_rnd_inited= 1; + thd->restore_active_arena(this, &backup_arena); if (rc == 0) { @@ -673,7 +680,8 @@ void Materialized_cursor::close() { /* Free item_list items */ free_items(); - (void) table->file->ha_rnd_end(); + if (is_rnd_inited) + (void) table->file->ha_rnd_end(); /* We need to grab table->mem_root to prevent free_tmp_table from freeing: the cursor object was allocated in this memory. diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 48276170caf..d2c469f99da 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1599,8 +1599,11 @@ JOIN::exec() (zero_result_cause?zero_result_cause:"No tables used")); else { - result->send_fields(*columns_list, - Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF); + if (result->send_fields(*columns_list, + Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) + { + DBUG_VOID_RETURN; + } /* We have to test for 'conds' here as the WHERE may not be constant even if we don't have any tables for prepared statements or if diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index ee3a053f8bd..ea4d363bdac 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -15899,6 +15899,59 @@ static void test_bug28934() } +/** + Bug#37956 memory leak and / or crash with geometry and prepared statements! +*/ + +static void test_bug37956(void) +{ + const char *query="select point(?,?)"; + MYSQL_STMT *stmt=NULL; + unsigned int val=0; + MYSQL_BIND bind_param[2]; + unsigned char buff[2]= { 134, 211 }; + DBUG_ENTER("test_bug37956"); + myheader("test_bug37956"); + + stmt= mysql_simple_prepare(mysql, query); + check_stmt(stmt); + + val=1; + mysql_stmt_attr_set(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, (void *)&val); + val=CURSOR_TYPE_READ_ONLY; + mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void *)&val); + val=0; + mysql_stmt_attr_set(stmt, STMT_ATTR_PREFETCH_ROWS, (void *)&val); + + memset(bind_param, 0, sizeof(bind_param)); + bind_param[0].buffer_type=MYSQL_TYPE_TINY; + bind_param[0].buffer= (void *)buff; + bind_param[0].is_null=NULL; + bind_param[0].error=NULL; + bind_param[0].is_unsigned=1; + bind_param[1].buffer_type=MYSQL_TYPE_TINY; + bind_param[1].buffer= (void *)(buff+1); + bind_param[1].is_null=NULL; + bind_param[1].error=NULL; + bind_param[1].is_unsigned=1; + + if (mysql_stmt_bind_param(stmt, bind_param)) + { + mysql_stmt_close(stmt); + DIE_UNLESS(0); + } + + if (mysql_stmt_execute(stmt)) + { + mysql_stmt_close(stmt); + DBUG_VOID_RETURN; + } + /* Should never reach here: execution returns an error. */ + mysql_stmt_close(stmt); + DIE_UNLESS(0); + DBUG_VOID_RETURN; +} + /* Bug#27592 (stack overrun when storing datetime value using prepared statements) */ @@ -16595,6 +16648,7 @@ static struct my_tests_st my_tests[]= { { "test_bug32265", test_bug32265 }, { "test_bug38486", test_bug38486 }, { "test_bug40365", test_bug40365 }, + { "test_bug37956", test_bug37956 }, { 0, 0 } }; From 5fdd9c99c246c27f92f85e9919dea2ed537d460d Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Wed, 10 Dec 2008 18:38:27 +0400 Subject: [PATCH 044/137] Bug#35275 INFORMATION_SCHEMA.TABLES.CREATE_OPTIONS omits KEY_BLOCK_SIZE Added KEY_BLOCK_SIZE option to I_S.TABLES.CREATE_OPTIONS field --- mysql-test/r/information_schema.result | 5 +++++ mysql-test/t/information_schema.test | 7 +++++++ sql/sql_show.cc | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 85af461eb14..4fd0bdde063 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1707,4 +1707,9 @@ where a.VARIABLE_NAME = b.VARIABLE_NAME; a.VARIABLE_VALUE - b.VARIABLE_VALUE 2 drop table t0; +CREATE TABLE t1(a INT) KEY_BLOCK_SIZE=1; +SELECT CREATE_OPTIONS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1'; +CREATE_OPTIONS +KEY_BLOCK_SIZE=1 +DROP TABLE t1; End of 5.1 tests. diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index bcb22c44076..3dbdf76c220 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1383,4 +1383,11 @@ select a.VARIABLE_VALUE - b.VARIABLE_VALUE from t0 b, information_schema.global_ where a.VARIABLE_NAME = b.VARIABLE_NAME; drop table t0; +# +# Bug#35275 INFORMATION_SCHEMA.TABLES.CREATE_OPTIONS omits KEY_BLOCK_SIZE +# +CREATE TABLE t1(a INT) KEY_BLOCK_SIZE=1; +SELECT CREATE_OPTIONS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1'; +DROP TABLE t1; + --echo End of 5.1 tests. diff --git a/sql/sql_show.cc b/sql/sql_show.cc index a506429fb97..3fd06aba672 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -3589,6 +3589,11 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, (share->transactional == HA_CHOICE_YES ? "1" : "0"), NullS); } + if (share->key_block_size) + { + ptr= strmov(ptr, " KEY_BLOCK_SIZE="); + ptr= longlong10_to_str(share->key_block_size, ptr, 10); + } #ifdef WITH_PARTITION_STORAGE_ENGINE if (is_partitioned) ptr= strmov(ptr, " partitioned"); From c0301ac03e568742a67426ea405ec7a87910343e Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Wed, 10 Dec 2008 19:29:22 +0100 Subject: [PATCH 045/137] post push fix for test case for bug#39084. --- mysql-test/t/partition_innodb_stmt.test | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/t/partition_innodb_stmt.test b/mysql-test/t/partition_innodb_stmt.test index 2ed5baee0ac..d6181ce068e 100644 --- a/mysql-test/t/partition_innodb_stmt.test +++ b/mysql-test/t/partition_innodb_stmt.test @@ -1,3 +1,4 @@ +--source include/have_partition.inc --source include/have_binlog_format_statement.inc --source include/have_innodb.inc From 87ea5307d0750d33aec28bf7613a5b80c5c0dac2 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Thu, 11 Dec 2008 12:57:59 +0400 Subject: [PATCH 046/137] disable bug37956 test if geometry package is not enabled --- tests/mysql_client_test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index ea4d363bdac..79d188c252c 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -15899,6 +15899,7 @@ static void test_bug28934() } +#ifdef HAVE_SPATIAL /** Bug#37956 memory leak and / or crash with geometry and prepared statements! */ @@ -15951,6 +15952,7 @@ static void test_bug37956(void) DIE_UNLESS(0); DBUG_VOID_RETURN; } +#endif /* Bug#27592 (stack overrun when storing datetime value using prepared statements) @@ -16648,7 +16650,9 @@ static struct my_tests_st my_tests[]= { { "test_bug32265", test_bug32265 }, { "test_bug38486", test_bug38486 }, { "test_bug40365", test_bug40365 }, +#ifdef HAVE_SPATIAL { "test_bug37956", test_bug37956 }, +#endif { 0, 0 } }; From e419c5d349997835644f1b438e90a4af61694a62 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Thu, 11 Dec 2008 14:37:18 +0400 Subject: [PATCH 047/137] fix for pushbuild failure on 64 linux --- tests/mysql_client_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 79d188c252c..50f03a1a086 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -15908,7 +15908,7 @@ static void test_bug37956(void) { const char *query="select point(?,?)"; MYSQL_STMT *stmt=NULL; - unsigned int val=0; + ulong val=0; MYSQL_BIND bind_param[2]; unsigned char buff[2]= { 134, 211 }; DBUG_ENTER("test_bug37956"); From e0f4556db759aaad0046396eb6ea63c8df5b45c4 Mon Sep 17 00:00:00 2001 From: Luis Soares Date: Thu, 11 Dec 2008 11:06:50 +0000 Subject: [PATCH 048/137] Fix PB warnings for parenthesis and valgrind leak report. BUG#38826 --- sql/log.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index 477cb21b2f3..c411f7c8238 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1146,7 +1146,7 @@ int MYSQL_LOG::purge_first_log(struct st_relay_log_info* rli, bool included) * Need to update the log pos because purge logs has been called * after fetching initially the log pos at the begining of the method. */ - if(error=find_log_pos(&rli->linfo, rli->event_relay_log_name, 0)) + if((error=find_log_pos(&rli->linfo, rli->event_relay_log_name, 0))) { char buff[22]; sql_print_error("next log error: %d offset: %s log: %s included: %d", @@ -1234,8 +1234,8 @@ int MYSQL_LOG::purge_logs(const char *to_log, */ if (!my_b_inited(&purge_temp)) { - if (error=open_cached_file(&purge_temp, mysql_tmpdir, TEMP_PREFIX, - DISK_BUFFER_SIZE, MYF(MY_WME))) + if ((error=open_cached_file(&purge_temp, mysql_tmpdir, TEMP_PREFIX, + DISK_BUFFER_SIZE, MYF(MY_WME)))) { sql_print_error("MYSQL_LOG::purge_logs failed to open purge_temp"); goto err; @@ -1243,7 +1243,7 @@ int MYSQL_LOG::purge_logs(const char *to_log, } else { - if (error=reinit_io_cache(&purge_temp, WRITE_CACHE, 0, 0, 1)) + if ((error=reinit_io_cache(&purge_temp, WRITE_CACHE, 0, 0, 1))) { sql_print_error("MYSQL_LOG::purge_logs failed to reinit purge_temp " "for write"); @@ -1274,7 +1274,7 @@ int MYSQL_LOG::purge_logs(const char *to_log, } /* We know how many files to delete. Update index file. */ - if (error=update_log_index(&log_info, need_update_threads)) + if ((error=update_log_index(&log_info, need_update_threads))) { sql_print_error("MSYQL_LOG::purge_logs failed to update the index file"); goto err; @@ -1283,7 +1283,7 @@ int MYSQL_LOG::purge_logs(const char *to_log, DBUG_EXECUTE_IF("crash_after_update_index", abort();); /* Switch purge_temp for read. */ - if (error=reinit_io_cache(&purge_temp, READ_CACHE, 0, 0, 0)) + if ((error=reinit_io_cache(&purge_temp, READ_CACHE, 0, 0, 0))) { sql_print_error("MSYQL_LOG::purge_logs failed to reinit purge_temp " "for read"); @@ -1409,6 +1409,7 @@ int MYSQL_LOG::purge_logs(const char *to_log, } err: + close_cached_file(&purge_temp); if (need_mutex) pthread_mutex_unlock(&LOCK_index); DBUG_RETURN(error); From cf9126a034cd69b1271519b130d2218fd4d08a5a Mon Sep 17 00:00:00 2001 From: Chad MILLER Date: Thu, 11 Dec 2008 12:26:03 -0500 Subject: [PATCH 049/137] Bug#33812: mysql client incorrectly parsing DELIMITER Fix parsing of mysql client commands, especially in relation to single-line comments when --comments was specified. This is a little tricky, because we need to allow single-line comments in the middle of statements, but we don't want to allow client commands in the middle of statements. So in comment-preservation mode, we go ahead and send single-line comments to the server immediately when we encounter them on their own. This is still slightly flawed, in that it does not handle a single-line comment with leading spaces, followed by a client-side command when --comment has been enabled. But this isn't a new problem, and it is quite an edge condition. Fixing it would require a more extensive overall of how the mysql client parses commands. --- client/mysql.cc | 49 ++++++++++++++------------------------- mysql-test/r/mysql.result | 6 +++++ mysql-test/t/mysql.test | 19 +++++++++++++++ 3 files changed, 42 insertions(+), 32 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 9b14f9fb3ef..20f87d5cdcd 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1998,7 +1998,7 @@ static bool add_line(String &buffer,char *line,char *in_string, { if (!preserve_comments) { - // Skip spaces at the beggining of a statement + // Skip spaces at the beginning of a statement if (my_isspace(charset_info,inchar) && (out == line) && buffer.is_empty()) continue; @@ -2081,37 +2081,6 @@ static bool add_line(String &buffer,char *line,char *in_string, continue; } } - else if (!*ml_comment && !*in_string && - (end_of_line - pos) >= 10 && - !my_strnncoll(charset_info, (uchar*) pos, 10, - (const uchar*) "delimiter ", 10)) - { - // Flush previously accepted characters - if (out != line) - { - buffer.append(line, (uint32) (out - line)); - out= line; - } - - // Flush possible comments in the buffer - if (!buffer.is_empty()) - { - if (com_go(&buffer, 0) > 0) // < 0 is not fatal - DBUG_RETURN(1); - buffer.length(0); - } - - /* - Delimiter wants the get rest of the given line as argument to - allow one to change ';' to ';;' and back - */ - buffer.append(pos); - if (com_delimiter(&buffer, pos) > 0) - DBUG_RETURN(1); - - buffer.length(0); - break; - } else if (!*ml_comment && !*in_string && is_prefix(pos, delimiter)) { // Found a statement. Continue parsing after the delimiter @@ -2174,8 +2143,24 @@ static bool add_line(String &buffer,char *line,char *in_string, // comment to end of line if (preserve_comments) + { + bool started_with_nothing= !buffer.length(); + buffer.append(pos); + /* + A single-line comment by itself gets sent immediately so that + client commands (delimiter, status, etc) will be interpreted on + the next line. + */ + if (started_with_nothing) + { + if (com_go(&buffer, 0) > 0) // < 0 is not fatal + DBUG_RETURN(1); + buffer.length(0); + } + } + break; } else if (!*in_string && inchar == '/' && *(pos+1) == '*' && diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index eded1a3fc3b..95bdcab6ba1 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -180,4 +180,10 @@ ERROR at line 1: DELIMITER cannot contain a backslash character 1 This is a file starting with UTF8 BOM 0xEFBBBF This is a file starting with UTF8 BOM 0xEFBBBF +delimiter +1 +2 +2 +2 +2 End of 5.0 tests diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index 182b292c817..76941af893a 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -290,4 +290,23 @@ EOF --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug29323.sql 2>&1 remove_file $MYSQLTEST_VARDIR/tmp/bug29323.sql; +# +# Bug #33812: mysql client incorrectly parsing DELIMITER +# +# The space and ; after delimiter are important +--exec $MYSQL -e "select 1 delimiter ;" + +# +# Bug #38158: mysql client regression, can't read dump files +# +--write_file $MYSQLTEST_VARDIR/tmp/bug38158.sql +-- Testing +-- +delimiter || +select 2 || +EOF +--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug38158.sql 2>&1 +--exec $MYSQL -c < $MYSQLTEST_VARDIR/tmp/bug38158.sql 2>&1 +remove_file $MYSQLTEST_VARDIR/tmp/bug38158.sql; + --echo End of 5.0 tests From ce8ad64dd2ac2f28557020f5de07c56cc21ecaac Mon Sep 17 00:00:00 2001 From: Gleb Shchepa Date: Fri, 12 Dec 2008 00:57:32 +0400 Subject: [PATCH 050/137] Bug #40761: Assert on sum function on IF(..., CAST(longtext AS UNSIGNED), signed_val) (was: LEFT JOIN on inline view crashes server) Select from a LONGTEXT column wrapped with an expression like "IF(..., CAST(longtext_column AS UNSIGNED), smth_signed)" failed an assertion or crashed the server. IFNULL function was affected too. LONGTEXT column item has a maximum length of 32^2-1 bytes, at the same time this is a maximum possible length of any MySQL item. CAST(longtext_column AS UNSIGNED) returns some unsigned numeric result of length 32^2-1, so the result of IF/IFNULL function of this number and some other signed number will have text length of (32^2-1)+1=32^2 (one byte for the minus sign) - there is integer overflow, and the length is equal to zero. That caused assert/crash. The bug has been fixed by the same solution as in the CASE function implementation. --- mysql-test/r/func_if.result | 9 +++++++ mysql-test/t/func_if.test | 13 ++++++++++ sql/item_cmpfunc.cc | 50 ++++++++++++++++--------------------- sql/item_cmpfunc.h | 1 - sql/item_func.cc | 10 ++++++++ sql/item_func.h | 2 ++ 6 files changed, 56 insertions(+), 29 deletions(-) diff --git a/mysql-test/r/func_if.result b/mysql-test/r/func_if.result index 7ffc957e285..16d6b435dc7 100644 --- a/mysql-test/r/func_if.result +++ b/mysql-test/r/func_if.result @@ -176,4 +176,13 @@ IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((R DROP TABLE t1; +CREATE TABLE t1 (c LONGTEXT); +INSERT INTO t1 VALUES(1), (2), (3), (4), ('12345678901234567890'); +SELECT * FROM (SELECT MAX(IF(1, CAST(c AS UNSIGNED), 0)) FROM t1) AS te; +MAX(IF(1, CAST(c AS UNSIGNED), 0)) +12345678901234567890 +SELECT * FROM (SELECT MAX(IFNULL(CAST(c AS UNSIGNED), 0)) FROM t1) AS te; +MAX(IFNULL(CAST(c AS UNSIGNED), 0)) +12345678901234567890 +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/func_if.test b/mysql-test/t/func_if.test index 8da10f36cbe..68728d6697e 100644 --- a/mysql-test/t/func_if.test +++ b/mysql-test/t/func_if.test @@ -150,4 +150,17 @@ FROM t1; DROP TABLE t1; +# +# Bug #40761: Assert on sum func on IF(..., CAST(longtext AS UNSIGNED), signed) +# (was: LEFT JOIN on inline view crashes server) +# + +CREATE TABLE t1 (c LONGTEXT); +INSERT INTO t1 VALUES(1), (2), (3), (4), ('12345678901234567890'); + +SELECT * FROM (SELECT MAX(IF(1, CAST(c AS UNSIGNED), 0)) FROM t1) AS te; +SELECT * FROM (SELECT MAX(IFNULL(CAST(c AS UNSIGNED), 0)) FROM t1) AS te; + +DROP TABLE t1; + --echo End of 5.0 tests diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 3b1d18b4252..759e912cc82 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2069,21 +2069,23 @@ Item_func_ifnull::fix_length_and_dec() { agg_result_type(&hybrid_type, args, 2); maybe_null=args[1]->maybe_null; - decimals= max(args[0]->decimals, args[1]->decimals); - unsigned_flag= args[0]->unsigned_flag && args[1]->unsigned_flag; if (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT) { - int len0= args[0]->max_length - args[0]->decimals - - (args[0]->unsigned_flag ? 0 : 1); - - int len1= args[1]->max_length - args[1]->decimals - - (args[1]->unsigned_flag ? 0 : 1); - - max_length= max(len0, len1) + decimals + (unsigned_flag ? 0 : 1); + max_length= 0; + decimals= 0; + unsigned_flag= TRUE; + agg_num_lengths(args[0]); + agg_num_lengths(args[1]); + max_length= my_decimal_precision_to_length(max_length + decimals, decimals, + unsigned_flag); } else + { max_length= max(args[0]->max_length, args[1]->max_length); + decimals= max(args[0]->decimals, args[1]->decimals); + unsigned_flag=args[0]->unsigned_flag && args[1]->unsigned_flag; + } switch (hybrid_type) { case STRING_RESULT: @@ -2238,8 +2240,6 @@ void Item_func_if::fix_length_and_dec() { maybe_null=args[1]->maybe_null || args[2]->maybe_null; - decimals= max(args[1]->decimals, args[2]->decimals); - unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag; enum Item_result arg1_type=args[1]->result_type(); enum Item_result arg2_type=args[2]->result_type(); @@ -2276,16 +2276,20 @@ Item_func_if::fix_length_and_dec() if ((cached_result_type == DECIMAL_RESULT ) || (cached_result_type == INT_RESULT)) { - int len1= args[1]->max_length - args[1]->decimals - - (args[1]->unsigned_flag ? 0 : 1); - - int len2= args[2]->max_length - args[2]->decimals - - (args[2]->unsigned_flag ? 0 : 1); - - max_length=max(len1, len2) + decimals + (unsigned_flag ? 0 : 1); + max_length= 0; + decimals= 0; + unsigned_flag= TRUE; + agg_num_lengths(args[1]); + agg_num_lengths(args[2]); + max_length= my_decimal_precision_to_length(max_length + decimals, decimals, + unsigned_flag); } else + { max_length= max(args[1]->max_length, args[2]->max_length); + decimals= max(args[1]->decimals, args[2]->decimals); + unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag; + } } @@ -2633,16 +2637,6 @@ void Item_func_case::agg_str_lengths(Item* arg) } -void Item_func_case::agg_num_lengths(Item *arg) -{ - uint len= my_decimal_length_to_precision(arg->max_length, arg->decimals, - arg->unsigned_flag) - arg->decimals; - set_if_bigger(max_length, len); - set_if_bigger(decimals, arg->decimals); - unsigned_flag= unsigned_flag && arg->unsigned_flag; -} - - void Item_func_case::fix_length_and_dec() { Item **agg; diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index db831c7030c..6ecbfba140f 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -759,7 +759,6 @@ public: Item *find_item(String *str); CHARSET_INFO *compare_collation() { return cmp_collation.collation; } void agg_str_lengths(Item *arg); - void agg_num_lengths(Item *arg); }; diff --git a/sql/item_func.cc b/sql/item_func.cc index c0d08d9b213..c650b0ae933 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -5668,3 +5668,13 @@ void Item_func_sp::update_used_tables() const_item_cache= FALSE; } } + + +void Item_func::agg_num_lengths(Item *arg) +{ + uint len= my_decimal_length_to_precision(arg->max_length, arg->decimals, + arg->unsigned_flag) - arg->decimals; + set_if_bigger(max_length, len); + set_if_bigger(decimals, arg->decimals); + unsigned_flag= unsigned_flag && arg->unsigned_flag; +} diff --git a/sql/item_func.h b/sql/item_func.h index 6dcf32cba07..d4da0b7a853 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -193,6 +193,8 @@ public: void * arg, traverse_order order); bool is_expensive_processor(byte *arg); virtual bool is_expensive() { return 0; } +protected: + void agg_num_lengths(Item *arg); }; From 03f9b2cea60842e8b8e7e7e65bfdf96ca7e3fef8 Mon Sep 17 00:00:00 2001 From: Gleb Shchepa Date: Fri, 12 Dec 2008 14:59:10 +0400 Subject: [PATCH 051/137] rollback of bug #40761 fix --- mysql-test/r/func_if.result | 9 ------- mysql-test/t/func_if.test | 13 ---------- sql/item_cmpfunc.cc | 50 +++++++++++++++++++++---------------- sql/item_cmpfunc.h | 1 + sql/item_func.cc | 10 -------- sql/item_func.h | 2 -- 6 files changed, 29 insertions(+), 56 deletions(-) diff --git a/mysql-test/r/func_if.result b/mysql-test/r/func_if.result index 16d6b435dc7..7ffc957e285 100644 --- a/mysql-test/r/func_if.result +++ b/mysql-test/r/func_if.result @@ -176,13 +176,4 @@ IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((R DROP TABLE t1; -CREATE TABLE t1 (c LONGTEXT); -INSERT INTO t1 VALUES(1), (2), (3), (4), ('12345678901234567890'); -SELECT * FROM (SELECT MAX(IF(1, CAST(c AS UNSIGNED), 0)) FROM t1) AS te; -MAX(IF(1, CAST(c AS UNSIGNED), 0)) -12345678901234567890 -SELECT * FROM (SELECT MAX(IFNULL(CAST(c AS UNSIGNED), 0)) FROM t1) AS te; -MAX(IFNULL(CAST(c AS UNSIGNED), 0)) -12345678901234567890 -DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/func_if.test b/mysql-test/t/func_if.test index 68728d6697e..8da10f36cbe 100644 --- a/mysql-test/t/func_if.test +++ b/mysql-test/t/func_if.test @@ -150,17 +150,4 @@ FROM t1; DROP TABLE t1; -# -# Bug #40761: Assert on sum func on IF(..., CAST(longtext AS UNSIGNED), signed) -# (was: LEFT JOIN on inline view crashes server) -# - -CREATE TABLE t1 (c LONGTEXT); -INSERT INTO t1 VALUES(1), (2), (3), (4), ('12345678901234567890'); - -SELECT * FROM (SELECT MAX(IF(1, CAST(c AS UNSIGNED), 0)) FROM t1) AS te; -SELECT * FROM (SELECT MAX(IFNULL(CAST(c AS UNSIGNED), 0)) FROM t1) AS te; - -DROP TABLE t1; - --echo End of 5.0 tests diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 759e912cc82..3b1d18b4252 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2069,23 +2069,21 @@ Item_func_ifnull::fix_length_and_dec() { agg_result_type(&hybrid_type, args, 2); maybe_null=args[1]->maybe_null; + decimals= max(args[0]->decimals, args[1]->decimals); + unsigned_flag= args[0]->unsigned_flag && args[1]->unsigned_flag; if (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT) { - max_length= 0; - decimals= 0; - unsigned_flag= TRUE; - agg_num_lengths(args[0]); - agg_num_lengths(args[1]); - max_length= my_decimal_precision_to_length(max_length + decimals, decimals, - unsigned_flag); + int len0= args[0]->max_length - args[0]->decimals + - (args[0]->unsigned_flag ? 0 : 1); + + int len1= args[1]->max_length - args[1]->decimals + - (args[1]->unsigned_flag ? 0 : 1); + + max_length= max(len0, len1) + decimals + (unsigned_flag ? 0 : 1); } else - { max_length= max(args[0]->max_length, args[1]->max_length); - decimals= max(args[0]->decimals, args[1]->decimals); - unsigned_flag=args[0]->unsigned_flag && args[1]->unsigned_flag; - } switch (hybrid_type) { case STRING_RESULT: @@ -2240,6 +2238,8 @@ void Item_func_if::fix_length_and_dec() { maybe_null=args[1]->maybe_null || args[2]->maybe_null; + decimals= max(args[1]->decimals, args[2]->decimals); + unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag; enum Item_result arg1_type=args[1]->result_type(); enum Item_result arg2_type=args[2]->result_type(); @@ -2276,20 +2276,16 @@ Item_func_if::fix_length_and_dec() if ((cached_result_type == DECIMAL_RESULT ) || (cached_result_type == INT_RESULT)) { - max_length= 0; - decimals= 0; - unsigned_flag= TRUE; - agg_num_lengths(args[1]); - agg_num_lengths(args[2]); - max_length= my_decimal_precision_to_length(max_length + decimals, decimals, - unsigned_flag); + int len1= args[1]->max_length - args[1]->decimals + - (args[1]->unsigned_flag ? 0 : 1); + + int len2= args[2]->max_length - args[2]->decimals + - (args[2]->unsigned_flag ? 0 : 1); + + max_length=max(len1, len2) + decimals + (unsigned_flag ? 0 : 1); } else - { max_length= max(args[1]->max_length, args[2]->max_length); - decimals= max(args[1]->decimals, args[2]->decimals); - unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag; - } } @@ -2637,6 +2633,16 @@ void Item_func_case::agg_str_lengths(Item* arg) } +void Item_func_case::agg_num_lengths(Item *arg) +{ + uint len= my_decimal_length_to_precision(arg->max_length, arg->decimals, + arg->unsigned_flag) - arg->decimals; + set_if_bigger(max_length, len); + set_if_bigger(decimals, arg->decimals); + unsigned_flag= unsigned_flag && arg->unsigned_flag; +} + + void Item_func_case::fix_length_and_dec() { Item **agg; diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 6ecbfba140f..db831c7030c 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -759,6 +759,7 @@ public: Item *find_item(String *str); CHARSET_INFO *compare_collation() { return cmp_collation.collation; } void agg_str_lengths(Item *arg); + void agg_num_lengths(Item *arg); }; diff --git a/sql/item_func.cc b/sql/item_func.cc index c650b0ae933..c0d08d9b213 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -5668,13 +5668,3 @@ void Item_func_sp::update_used_tables() const_item_cache= FALSE; } } - - -void Item_func::agg_num_lengths(Item *arg) -{ - uint len= my_decimal_length_to_precision(arg->max_length, arg->decimals, - arg->unsigned_flag) - arg->decimals; - set_if_bigger(max_length, len); - set_if_bigger(decimals, arg->decimals); - unsigned_flag= unsigned_flag && arg->unsigned_flag; -} diff --git a/sql/item_func.h b/sql/item_func.h index d4da0b7a853..6dcf32cba07 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -193,8 +193,6 @@ public: void * arg, traverse_order order); bool is_expensive_processor(byte *arg); virtual bool is_expensive() { return 0; } -protected: - void agg_num_lengths(Item *arg); }; From 2b761ffde93fe951eb884c796d8f8232e78723f0 Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Fri, 12 Dec 2008 14:52:20 +0200 Subject: [PATCH 052/137] Bug #41383 Test commit1_innodb fails with binlog-format=row The test explicitly warned on existence of a bug in its 27th part. The expected values of prepare and commit counters changed, corrected, by fixes to bug#40221. Notice, that binlog does not have to register for a statement with the statement binlog-format because the statement rollback does not need to do anything in that mode. It's not so with the ROW format which was bug#40221 concern. Fixed with correcting the expected values of the mentioned counters and explained that with comments in the test. --- mysql-test/include/commit.inc | 7 +++++-- mysql-test/r/commit_1innodb.result | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/mysql-test/include/commit.inc b/mysql-test/include/commit.inc index 98f9c93b25a..48b0eac12e5 100644 --- a/mysql-test/include/commit.inc +++ b/mysql-test/include/commit.inc @@ -671,8 +671,11 @@ call p_verify_status_increment(2, 2, 2, 2); savepoint a; call p_verify_status_increment(0, 0, 0, 0); insert t1 set a=4; ---echo # Sic: a bug. Binlog did not register itself this time. -call p_verify_status_increment(1, 0, 1, 0); +--echo # Binlog does not register itself this time for other than the 1st +--echo # statement of the transaction with MIXED/STATEMENT binlog_format. +--echo # It needs registering with the ROW format. Therefore 1,0,2,2 are +--echo # the correct arguments to this test after bug#40221 fixed. +call p_verify_status_increment(1, 0, 2, 2); release savepoint a; rollback; call p_verify_status_increment(0, 0, 0, 0); diff --git a/mysql-test/r/commit_1innodb.result b/mysql-test/r/commit_1innodb.result index a2c1eb9a82e..766b920f630 100644 --- a/mysql-test/r/commit_1innodb.result +++ b/mysql-test/r/commit_1innodb.result @@ -770,8 +770,11 @@ call p_verify_status_increment(0, 0, 0, 0); SUCCESS insert t1 set a=4; -# Sic: a bug. Binlog did not register itself this time. -call p_verify_status_increment(1, 0, 1, 0); +# Binlog does not register itself this time for other than the 1st +# statement of the transaction with MIXED/STATEMENT binlog_format. +# It needs registering with the ROW format. Therefore 1,0,2,2 are +# the correct arguments to this test after bug#40221 fixed. +call p_verify_status_increment(1, 0, 2, 2); SUCCESS release savepoint a; From c1bf0475cf23777a5a5c25e0b4ece4dfc3e4e398 Mon Sep 17 00:00:00 2001 From: Gleb Shchepa Date: Fri, 12 Dec 2008 17:16:25 +0400 Subject: [PATCH 053/137] Bug #40761: Assert on sum function on IF(..., CAST(longtext AS UNSIGNED), signed_val) (was: LEFT JOIN on inline view crashes server) Select from a LONGTEXT column wrapped with an expression like "IF(..., CAST(longtext_column AS UNSIGNED), smth_signed)" failed an assertion or crashed the server. IFNULL function was affected too. LONGTEXT column item has a maximum length of 32^2-1 bytes, at the same time this is a maximum possible length of any MySQL item. CAST(longtext_column AS UNSIGNED) returns some unsigned numeric result of length 32^2-1, so the result of IF/IFNULL function of this number and some other signed number will have text length of (32^2-1)+1=32^2 (one byte for the minus sign) - there is integer overflow, and the length is equal to zero. That caused assert/crash. CAST AS UNSIGNED function has been modified to limit maximal length of resulting number to 67 (maximal length of DECIMAL and two characters for minus sign and dot). --- mysql-test/r/func_if.result | 9 +++++++++ mysql-test/t/func_if.test | 14 ++++++++++++++ sql/item_func.h | 5 ++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_if.result b/mysql-test/r/func_if.result index 7ffc957e285..16d6b435dc7 100644 --- a/mysql-test/r/func_if.result +++ b/mysql-test/r/func_if.result @@ -176,4 +176,13 @@ IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((R DROP TABLE t1; +CREATE TABLE t1 (c LONGTEXT); +INSERT INTO t1 VALUES(1), (2), (3), (4), ('12345678901234567890'); +SELECT * FROM (SELECT MAX(IF(1, CAST(c AS UNSIGNED), 0)) FROM t1) AS te; +MAX(IF(1, CAST(c AS UNSIGNED), 0)) +12345678901234567890 +SELECT * FROM (SELECT MAX(IFNULL(CAST(c AS UNSIGNED), 0)) FROM t1) AS te; +MAX(IFNULL(CAST(c AS UNSIGNED), 0)) +12345678901234567890 +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/func_if.test b/mysql-test/t/func_if.test index 8da10f36cbe..4efea8e195e 100644 --- a/mysql-test/t/func_if.test +++ b/mysql-test/t/func_if.test @@ -150,4 +150,18 @@ FROM t1; DROP TABLE t1; +# +# Bug #40761: Assert on sum func on IF(..., CAST(longtext AS UNSIGNED), signed) +# (was: LEFT JOIN on inline view crashes server) +# + +CREATE TABLE t1 (c LONGTEXT); +INSERT INTO t1 VALUES(1), (2), (3), (4), ('12345678901234567890'); + +SELECT * FROM (SELECT MAX(IF(1, CAST(c AS UNSIGNED), 0)) FROM t1) AS te; +SELECT * FROM (SELECT MAX(IFNULL(CAST(c AS UNSIGNED), 0)) FROM t1) AS te; + +DROP TABLE t1; + + --echo End of 5.0 tests diff --git a/sql/item_func.h b/sql/item_func.h index 6dcf32cba07..89c841abb75 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -351,7 +351,10 @@ public: Item_func_unsigned(Item *a) :Item_func_signed(a) {} const char *func_name() const { return "cast_as_unsigned"; } void fix_length_and_dec() - { max_length=args[0]->max_length; unsigned_flag=1; } + { + max_length= min(args[0]->max_length, DECIMAL_MAX_PRECISION + 2); + unsigned_flag=1; + } longlong val_int(); void print(String *str); }; From d083ceabe840e9049ae340ddedb7343ad38b1589 Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Fri, 12 Dec 2008 21:15:56 +0200 Subject: [PATCH 054/137] Bug #41003 log_bin_trust_function_creators_func test explicitly warns on a bug in it The test 1. did not verify that CREATE FUNCTION shall fails in a case of active binlog and @@log_bin_trust_function_creators is zero if there is no DETERMINISTIC qualifier and super user privilege; 2. contained an explit warning on that CREATE FUNCTION actually succeeded whereas it was supposed to fail; 3. did not demand the bin-log be set ON even though it has contained the opt file explictily setting the name for the binlog file. Fixed 1-3 with modifying the test accordingly. --- ...og_bin_trust_function_creators_func.result | 25 +++++++++++---- ...in_trust_function_creators_func-master.opt | 1 - .../log_bin_trust_function_creators_func.test | 32 ++++++++++++++++--- 3 files changed, 47 insertions(+), 11 deletions(-) delete mode 100644 mysql-test/t/log_bin_trust_function_creators_func-master.opt diff --git a/mysql-test/r/log_bin_trust_function_creators_func.result b/mysql-test/r/log_bin_trust_function_creators_func.result index e109b53a8e7..50de0466a0d 100644 --- a/mysql-test/r/log_bin_trust_function_creators_func.result +++ b/mysql-test/r/log_bin_trust_function_creators_func.result @@ -10,10 +10,7 @@ create table t2 (a INT); SELECT @@log_bin_trust_function_creators; @@log_bin_trust_function_creators 0 -SELECT @@sql_log_bin; -@@sql_log_bin -1 -## Creating new function f1 ## +## Creating new function f1 fails because no DETERMINISTIC ### CREATE FUNCTION f1(a INT) RETURNS INT BEGIN IF (a < 3) THEN @@ -21,8 +18,24 @@ INSERT INTO t2 VALUES (a); END IF; RETURN 1; END| -'Bug: Create Function should give error here because non-super user'; -'is creating function here'; +ERROR HY000: This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable) +## Creating new function f1 fails because non-super user ## +CREATE FUNCTION f1(a INT) RETURNS INT DETERMINISTIC +BEGIN +IF (a < 3) THEN +INSERT INTO t2 VALUES (a); +END IF; +RETURN 1; +END| +ERROR HY000: You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable) +## Creating new function f1 succeeds ## +CREATE FUNCTION f1(a INT) RETURNS INT DETERMINISTIC +BEGIN +IF (a < 3) THEN +INSERT INTO t2 VALUES (a); +END IF; +RETURN 1; +END| ## Creating new table t1 ## CREATE TABLE t1 (a INT); ## Inserting some records in t1 ## diff --git a/mysql-test/t/log_bin_trust_function_creators_func-master.opt b/mysql-test/t/log_bin_trust_function_creators_func-master.opt deleted file mode 100644 index 2dd562ea1aa..00000000000 --- a/mysql-test/t/log_bin_trust_function_creators_func-master.opt +++ /dev/null @@ -1 +0,0 @@ ---log-bin=test.log diff --git a/mysql-test/t/log_bin_trust_function_creators_func.test b/mysql-test/t/log_bin_trust_function_creators_func.test index db91128b225..38207babc03 100644 --- a/mysql-test/t/log_bin_trust_function_creators_func.test +++ b/mysql-test/t/log_bin_trust_function_creators_func.test @@ -20,6 +20,8 @@ # # ############################################################################### +source include/have_log_bin.inc; + --disable_warnings drop table if exists t1; --enable_warnings @@ -45,10 +47,10 @@ connect (test_con1,localhost,tt,,); connection test_con1; SELECT @@log_bin_trust_function_creators; -SELECT @@sql_log_bin; ---echo ## Creating new function f1 ## +--echo ## Creating new function f1 fails because no DETERMINISTIC ### delimiter |; +--error ER_BINLOG_UNSAFE_ROUTINE CREATE FUNCTION f1(a INT) RETURNS INT BEGIN IF (a < 3) THEN @@ -58,8 +60,30 @@ BEGIN END| delimiter ;| ---echo 'Bug: Create Function should give error here because non-super user'; ---echo 'is creating function here'; +--echo ## Creating new function f1 fails because non-super user ## +delimiter |; +--error ER_BINLOG_CREATE_ROUTINE_NEED_SUPER +CREATE FUNCTION f1(a INT) RETURNS INT DETERMINISTIC +BEGIN + IF (a < 3) THEN + INSERT INTO t2 VALUES (a); + END IF; + RETURN 1; +END| +delimiter ;| + +connection default; + +--echo ## Creating new function f1 succeeds ## +delimiter |; +CREATE FUNCTION f1(a INT) RETURNS INT DETERMINISTIC +BEGIN + IF (a < 3) THEN + INSERT INTO t2 VALUES (a); + END IF; + RETURN 1; +END| +delimiter ;| --echo ## Creating new table t1 ## CREATE TABLE t1 (a INT); From ae75d95370ca3d73a9329091fd56abcab8ff5dc3 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Fri, 12 Dec 2008 15:48:26 -0700 Subject: [PATCH 055/137] Apply the rest of innodb-5.0-ss2475. This fixes Bug#36819, "ut_usectime does not handle errors from gettimeofday". r2475 | vasil | 2008-05-22 19:35:30 +0300 (Thu, 22 May 2008) | 13 lines Fix by retrying gettimeofday() several times if it fails in ut_usectime(). If it fails on all calls then return error to the caller to be handled at higher level. Update the variable innodb_row_lock_time_max in SHOW STATUS output only if ut_usectime() was successful. --- innobase/btr/btr0cur.c | 2 +- innobase/include/ut0ut.h | 8 ++++++-- innobase/srv/srv0srv.c | 21 +++++++++++++++------ innobase/ut/ut0ut.c | 36 +++++++++++++++++++++++++++++++----- 4 files changed, 53 insertions(+), 14 deletions(-) diff --git a/innobase/btr/btr0cur.c b/innobase/btr/btr0cur.c index d51a090be75..509b2ba3119 100644 --- a/innobase/btr/btr0cur.c +++ b/innobase/btr/btr0cur.c @@ -52,7 +52,7 @@ can be released by page reorganize, then it is reorganized */ #define BTR_CUR_PAGE_REORGANIZE_LIMIT (UNIV_PAGE_SIZE / 32) -/* When estimating number of different kay values in an index sample +/* When estimating number of different key values in an index, sample this many index pages */ #define BTR_KEY_VAL_ESTIMATE_N_PAGES 8 diff --git a/innobase/include/ut0ut.h b/innobase/include/ut0ut.h index 8938957cd12..b1c1602fd30 100644 --- a/innobase/include/ut0ut.h +++ b/innobase/include/ut0ut.h @@ -139,11 +139,15 @@ ib_time_t ut_time(void); /*=========*/ /************************************************************** -Returns system time. */ +Returns system time. +Upon successful completion, the value 0 is returned; otherwise the +value -1 is returned and the global variable errno is set to indicate the +error. */ -void +int ut_usectime( /*========*/ + /* out: 0 on success, -1 otherwise */ ulint* sec, /* out: seconds since the Epoch */ ulint* ms); /* out: microseconds since the Epoch+*sec */ /************************************************************** diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c index 431138400b6..6b755ae9816 100644 --- a/innobase/srv/srv0srv.c +++ b/innobase/srv/srv0srv.c @@ -1372,7 +1372,7 @@ srv_table_reserve_slot_for_mysql(void) /******************************************************************* Puts a MySQL OS thread to wait for a lock to be released. If an error -occurs during the wait trx->error_state associated with thr is +occurs during the wait, then trx->error_state associated with thr is != DB_SUCCESS when we return. DB_LOCK_WAIT_TIMEOUT and DB_DEADLOCK are possible errors. DB_DEADLOCK is returned if selective deadlock resolution chose this transaction as a victim. */ @@ -1442,8 +1442,11 @@ srv_suspend_mysql_thread( srv_n_lock_wait_count++; srv_n_lock_wait_current_count++; - ut_usectime(&sec, &ms); - start_time = (ib_longlong)sec * 1000000 + ms; + if (ut_usectime(&sec, &ms) == -1) { + start_time = -1; + } else { + start_time = (ib_longlong)sec * 1000000 + ms; + } } /* Wake the lock timeout monitor thread, if it is suspended */ @@ -1497,14 +1500,20 @@ srv_suspend_mysql_thread( wait_time = ut_difftime(ut_time(), slot->suspend_time); if (thr->lock_state == QUE_THR_LOCK_ROW) { - ut_usectime(&sec, &ms); - finish_time = (ib_longlong)sec * 1000000 + ms; + if (ut_usectime(&sec, &ms) == -1) { + finish_time = -1; + } else { + finish_time = (ib_longlong)sec * 1000000 + ms; + } diff_time = (ulint) (finish_time - start_time); srv_n_lock_wait_current_count--; srv_n_lock_wait_time = srv_n_lock_wait_time + diff_time; - if (diff_time > srv_n_lock_max_wait_time) { + if (diff_time > srv_n_lock_max_wait_time && + /* only update the variable if we successfully + retrieved the start and finish times. See Bug#36819. */ + start_time != -1 && finish_time != -1) { srv_n_lock_max_wait_time = diff_time; } } diff --git a/innobase/ut/ut0ut.c b/innobase/ut/ut0ut.c index feb03269d91..b93838a1885 100644 --- a/innobase/ut/ut0ut.c +++ b/innobase/ut/ut0ut.c @@ -123,19 +123,45 @@ ut_time(void) } /************************************************************** -Returns system time. */ +Returns system time. +Upon successful completion, the value 0 is returned; otherwise the +value -1 is returned and the global variable errno is set to indicate the +error. */ -void +int ut_usectime( /*========*/ + /* out: 0 on success, -1 otherwise */ ulint* sec, /* out: seconds since the Epoch */ ulint* ms) /* out: microseconds since the Epoch+*sec */ { struct timeval tv; + int ret; + int errno_gettimeofday; + int i; - ut_gettimeofday(&tv, NULL); - *sec = (ulint) tv.tv_sec; - *ms = (ulint) tv.tv_usec; + for (i = 0; i < 10; i++) { + + ret = ut_gettimeofday(&tv, NULL); + + if (ret == -1) { + errno_gettimeofday = errno; + ut_print_timestamp(stderr); + fprintf(stderr, " InnoDB: gettimeofday(): %s\n", + strerror(errno_gettimeofday)); + os_thread_sleep(100000); /* 0.1 sec */ + errno = errno_gettimeofday; + } else { + break; + } + } + + if (ret != -1) { + *sec = (ulint) tv.tv_sec; + *ms = (ulint) tv.tv_usec; + } + + return(ret); } /************************************************************** From 7886d63c62cce1b3a852eb68f747514661c3385f Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Fri, 12 Dec 2008 17:40:31 -0700 Subject: [PATCH 056/137] Apply 3 patches from innodb-5.0-ss2637. This fixes Bug#36149: Read buffer overflow in srv0start.c found during "make test" Per-revision comments: r2484 | vasil | 2008-05-28 15:32:48 +0300 (Wed, 28 May 2008) | 9 lines Fix Bug#36149 Read buffer overflow in srv0start.c found during "make test" Use strncmp(3) instead of memcmp(3) to avoid reading past end of the string if it is empty (*str == '\0'). This bug is _not_ a buffer overflow. Discussed with: Sunny (via IM) r2538 | inaam | 2008-07-15 21:24:02 +0300 (Tue, 15 Jul 2008) | 15 lines Fix of issue# 4 Fixed a timing hole where a thread dropping an index can free the in-memory index struct while another thread is still using that structure to remove entries from adaptive hash index belonging to one of the pages that belongs to the index being dropped. The fix is to have a reference counter in the index struct and to wait for this counter to drop to zero beforing freeing the struct. Reviewed by: Heikki r2544 | inaam | 2008-07-22 18:58:11 +0300 (Tue, 22 Jul 2008) | 8 lines Removed UNIV_INLINE qualifier from btr_search_info_get_ref_count(). Otherwise compilation failed on non-debug builds. Pointed by: Vasil --- innobase/btr/btr0sea.c | 40 ++++++++++++++++++++++++++++++++ innobase/dict/dict0dict.c | 47 ++++++++++++++++++++++++++++++++++++++ innobase/include/btr0sea.h | 21 +++++++++++++++-- innobase/srv/srv0start.c | 8 +++---- 4 files changed, 110 insertions(+), 6 deletions(-) diff --git a/innobase/btr/btr0sea.c b/innobase/btr/btr0sea.c index ed746bcf12c..3c202c5a3bf 100644 --- a/innobase/btr/btr0sea.c +++ b/innobase/btr/btr0sea.c @@ -162,6 +162,8 @@ btr_search_info_create( info->last_search = NULL; info->n_direction = 0; + + info->ref_count = 0; info->root_guess = NULL; info->hash_analysis = 0; @@ -183,6 +185,31 @@ btr_search_info_create( return(info); } +/********************************************************************* +Returns the value of ref_count. The value is protected by +btr_search_latch. */ +ulint +btr_search_info_get_ref_count( +/*==========================*/ + /* out: ref_count value. */ + btr_search_t* info) /* in: search info. */ +{ + ulint ret; + + ut_ad(info); + +#ifdef UNIV_SYNC_DEBUG + ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED)); + ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); +#endif /* UNIV_SYNC_DEBUG */ + + rw_lock_s_lock(&btr_search_latch); + ret = info->ref_count; + rw_lock_s_unlock(&btr_search_latch); + + return(ret); +} + /************************************************************************* Updates the search info of an index about hash successes. NOTE that info is NOT protected by any semaphore, to save CPU time! Do not assume its fields @@ -1019,8 +1046,12 @@ next_rec: ha_remove_all_nodes_to_page(table, folds[i], page); } + ut_a(index->search_info->ref_count > 0); + index->search_info->ref_count--; + block->is_hashed = FALSE; block->index = NULL; + cleanup: if (UNIV_UNLIKELY(block->n_pointers)) { /* Corruption */ @@ -1241,6 +1272,15 @@ btr_search_build_page_hash_index( goto exit_func; } + /* This counter is decremented every time we drop page + hash index entries and is incremented here. Since we can + rebuild hash index for a page that is already hashed, we + have to take care not to increment the counter in that + case. */ + if (!block->is_hashed) { + index->search_info->ref_count++; + } + block->is_hashed = TRUE; block->n_hash_helps = 0; diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index b8d9f362b06..b0d95597153 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -1556,6 +1556,8 @@ dict_index_remove_from_cache( dict_field_t* field; ulint size; ulint i; + ulint retries = 0; + btr_search_t* info; ut_ad(table && index); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); @@ -1564,6 +1566,51 @@ dict_index_remove_from_cache( ut_ad(mutex_own(&(dict_sys->mutex))); #endif /* UNIV_SYNC_DEBUG */ + /* We always create search info whether or not adaptive + hash index is enabled or not. */ + info = index->search_info; + ut_ad(info); + + /* We are not allowed to free the in-memory index struct + dict_index_t until all entries in the adaptive hash index + that point to any of the page belonging to his b-tree index + are dropped. This is so because dropping of these entries + require access to dict_index_t struct. To avoid such scenario + We keep a count of number of such pages in the search_info and + only free the dict_index_t struct when this count drops to + zero. */ + + for (;;) { + ulint ref_count = btr_search_info_get_ref_count(info); + if (ref_count == 0) { + break; + } + + /* Sleep for 10ms before trying again. */ + os_thread_sleep(10000); + ++retries; + + if (retries % 500 == 0) { + /* No luck after 5 seconds of wait. */ + fprintf(stderr, "InnoDB: Error: Waited for" + " %lu secs for hash index" + " ref_count (%lu) to drop" + " to 0.\n" + "index: \"%s\"" + " table: \"%s\"\n", + retries/100, + ref_count, + index->name, + table->name); + } + + /* To avoid a hang here we commit suicide if the + ref_count doesn't drop to zero in 600 seconds. */ + if (retries >= 60000) { + ut_error; + } + } + ut_ad(UT_LIST_GET_LEN((index->tree)->tree_indexes) == 1); dict_tree_free(index->tree); diff --git a/innobase/include/btr0sea.h b/innobase/include/btr0sea.h index 78e88a24083..370132af60d 100644 --- a/innobase/include/btr0sea.h +++ b/innobase/include/btr0sea.h @@ -40,6 +40,14 @@ btr_search_info_create( /*===================*/ /* out, own: search info struct */ mem_heap_t* heap); /* in: heap where created */ +/********************************************************************* +Returns the value of ref_count. The value is protected by +btr_search_latch. */ +ulint +btr_search_info_get_ref_count( +/*==========================*/ + /* out: ref_count value. */ + btr_search_t* info); /* in: search info. */ /************************************************************************* Updates the search info. */ UNIV_INLINE @@ -144,6 +152,13 @@ btr_search_validate(void); struct btr_search_struct{ ulint magic_n; /* magic number */ + ulint ref_count; /* Number of blocks in this index tree + that have search index built + i.e. block->index points to this index. + Protected by btr_search_latch except + when during initialization in + btr_search_info_create(). */ + /* The following 4 fields are currently not used: */ rec_t* last_search; /* pointer to the lower limit record of the previous search; NULL if not known */ @@ -154,8 +169,10 @@ struct btr_search_struct{ or BTR_SEA_SAME_PAGE */ dulint modify_clock; /* value of modify clock at the time last_search was stored */ - /*----------------------*/ - /* The following 4 fields are not protected by any latch: */ + + /* The following fields are not protected by any latch. + Unfortunately, this means that they must be aligned to + the machine word, i.e., they cannot be turned into bit-fields. */ page_t* root_guess; /* the root page frame when it was last time fetched, or NULL */ ulint hash_analysis; /* when this exceeds a certain value, the diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c index 5f8707a661c..d380eb14710 100644 --- a/innobase/srv/srv0start.c +++ b/innobase/srv/srv0start.c @@ -180,11 +180,11 @@ srv_parse_data_file_paths_and_sizes( str++; } - if (0 == memcmp(str, ":autoextend", (sizeof ":autoextend") - 1)) { + if (0 == strncmp(str, ":autoextend", (sizeof ":autoextend") - 1)) { str += (sizeof ":autoextend") - 1; - if (0 == memcmp(str, ":max:", (sizeof ":max:") - 1)) { + if (0 == strncmp(str, ":max:", (sizeof ":max:") - 1)) { str += (sizeof ":max:") - 1; @@ -288,13 +288,13 @@ srv_parse_data_file_paths_and_sizes( (*data_file_names)[i] = path; (*data_file_sizes)[i] = size; - if (0 == memcmp(str, ":autoextend", (sizeof ":autoextend") - 1)) { + if (0 == strncmp(str, ":autoextend", (sizeof ":autoextend") - 1)) { *is_auto_extending = TRUE; str += (sizeof ":autoextend") - 1; - if (0 == memcmp(str, ":max:", (sizeof ":max:") - 1)) { + if (0 == strncmp(str, ":max:", (sizeof ":max:") - 1)) { str += (sizeof ":max:") - 1; From 776fb66ad5bb0873f3336841a39ed41c86a2ed2d Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Fri, 12 Dec 2008 17:42:34 -0700 Subject: [PATCH 057/137] r2629 | inaam | 2008-09-16 18:46:00 +0300 (Tue, 16 Sep 2008) | 9 lines branches/5.0 bug#39483 InnoDB hang on adaptive hash because of out of order ::open() call by MySQL Under some conditions MySQL calls ::open with search_latch leading to a deadlock as we try to acquire dict_sys->mutex inside ::open breaking the latching order. The fix is to release search_latch. Reviewed by: Heikki --- sql/ha_innodb.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 1c0f8a6e9b3..83e2d025f18 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -2158,6 +2158,14 @@ ha_innobase::open( UT_NOT_USED(test_if_locked); thd = current_thd; + + /* Under some cases MySQL seems to call this function while + holding btr_search_latch. This breaks the latching order as + we acquire dict_sys->mutex below and leads to a deadlock. */ + if (thd != NULL) { + innobase_release_temporary_latches(thd); + } + normalize_table_name(norm_name, name); user_thd = NULL; From 46c19805381f3e44dbc87b5f9fe27501d8f72c6c Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 11:24:16 -0700 Subject: [PATCH 058/137] Completing snapshot innodb-5.1-ss2438, part 1. Fixes Bug #35537: Innodb doesn't increment handler_update and handler_delete Detailed revision comments: r2388 | vasil | 2008-03-27 14:02:34 +0200 (Thu, 27 Mar 2008) | 7 lines branches/5.1: Swap the order in which mysql_thd, mysql_query_str and *mysql_query_str are checked for non-NULL. Suggested by: Marko r2421 | calvin | 2008-04-24 15:32:30 +0300 (Thu, 24 Apr 2008) | 6 lines branches/5.1: Fix bug#35537 - Innodb doesn't increment handler_update and handler_delete Add the calls to ha_statistic_increment() in ha_innobase::delete_row() and ha_innobase::update_row(). --- mysql-test/r/innodb.result | 8 +++++++ mysql-test/t/innodb.test | 31 +++++++++++++++++++++++++++ storage/innobase/handler/ha_innodb.cc | 4 ++++ storage/innobase/row/row0sel.c | 4 ++-- 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index 5f8c59b9a0c..7806262f052 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -3295,3 +3295,11 @@ info: Records: 5 Duplicates: 0 Warnings: 0 TRUNCATE TABLE t1; affected rows: 0 DROP TABLE t1; +Variable_name Value +Handler_update 0 +Variable_name Value +Handler_delete 0 +Variable_name Value +Handler_update 1 +Variable_name Value +Handler_delete 1 diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index 339be87419a..eaff5867dc3 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -2475,6 +2475,7 @@ SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2'; DROP TABLE t2; DROP TABLE t1; # End 34920 test +# # Bug #29507 TRUNCATE shows to many rows effected # CONNECTION default; @@ -2491,6 +2492,36 @@ TRUNCATE TABLE t1; --disable_info DROP TABLE t1; # +# Bug#35537 Innodb doesn't increment handler_update and handler_delete. +# +-- disable_query_log +-- disable_result_log + +CONNECT (c1,localhost,root,,); + +DROP TABLE IF EXISTS bug35537; +CREATE TABLE bug35537 ( + c1 int +) ENGINE=InnoDB; + +INSERT INTO bug35537 VALUES (1); + +-- enable_result_log + +SHOW SESSION STATUS LIKE 'Handler_update%'; +SHOW SESSION STATUS LIKE 'Handler_delete%'; + +UPDATE bug35537 SET c1 = 2 WHERE c1 = 1; +DELETE FROM bug35537 WHERE c1 = 2; + +SHOW SESSION STATUS LIKE 'Handler_update%'; +SHOW SESSION STATUS LIKE 'Handler_delete%'; + +DROP TABLE bug35537; + +DISCONNECT c1; +CONNECTION default; + ####################################################################### # # # Please, DO NOT TOUCH this file as well as the innodb.result file. # diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 887acacbd1f..cd2b121cbf4 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -3755,6 +3755,8 @@ ha_innobase::update_row( ut_a(prebuilt->trx == trx); + ha_statistic_increment(&SSV::ha_update_count); + if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE) table->timestamp_field->set_time(); @@ -3844,6 +3846,8 @@ ha_innobase::delete_row( ut_a(prebuilt->trx == trx); + ha_statistic_increment(&SSV::ha_delete_count); + /* Only if the table has an AUTOINC column */ if (table->found_next_number_field && record == table->record[0]) { ulonglong dummy = 0; diff --git a/storage/innobase/row/row0sel.c b/storage/innobase/row/row0sel.c index 6ff135e4f5a..c6a93d4e0d5 100644 --- a/storage/innobase/row/row0sel.c +++ b/storage/innobase/row/row0sel.c @@ -3577,9 +3577,9 @@ shortcut_fails_too_big_rec: if (trx->isolation_level <= TRX_ISO_READ_COMMITTED && prebuilt->select_lock_type != LOCK_NONE + && trx->mysql_thd != NULL && trx->mysql_query_str != NULL - && *trx->mysql_query_str != NULL - && trx->mysql_thd != NULL) { + && *trx->mysql_query_str != NULL) { /* Scan the MySQL query string; check if SELECT is the first word there */ From 01710fb472aa8de1ed6ec891cf766aa4b571241c Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 11:26:53 -0700 Subject: [PATCH 059/137] Completing snapshot innodb-5.1-ss2438, part 2. Fixes Bug #36169: create innodb compressed table with too large row size crashed Revision comments: r2422 | vasil | 2008-04-24 16:00:30 +0300 (Thu, 24 Apr 2008) | 11 lines branches/5.1: Fix Bug#36169 create innodb compressed table with too large row size crashed Sometimes it is possible that row_drop_table_for_mysql(index->table_name, trx, FALSE); is invoked in row_create_index_for_mysql() when the index object is freed so copy the table name to a safe place beforehand and use the copy. Approved by: Sunny --- storage/innobase/row/row0mysql.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c index d5ef12d0af2..f5228618a04 100644 --- a/storage/innobase/row/row0mysql.c +++ b/storage/innobase/row/row0mysql.c @@ -1963,6 +1963,7 @@ row_create_index_for_mysql( ulint err; ulint i, j; ulint len; + char* table_name; #ifdef UNIV_SYNC_DEBUG ut_ad(rw_lock_own(&dict_operation_lock, RW_LOCK_EX)); @@ -1972,6 +1973,11 @@ row_create_index_for_mysql( trx->op_info = "creating index"; + /* Copy the table name because we may want to drop the + table later, after the index object is freed (inside + que_run_threads()) and thus index->table_name is not available. */ + table_name = mem_strdup(index->table_name); + trx_start_if_not_started(trx); /* Check that the same column does not appear twice in the index. @@ -2044,13 +2050,15 @@ error_handling: trx_general_rollback_for_mysql(trx, FALSE, NULL); - row_drop_table_for_mysql(index->table_name, trx, FALSE); + row_drop_table_for_mysql(table_name, trx, FALSE); trx->error_state = DB_SUCCESS; } trx->op_info = ""; + mem_free(table_name); + return((int) err); } From 4e7bc33e0b8964c51c91b667baef87a4884b10f5 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 11:54:01 -0700 Subject: [PATCH 060/137] Completing snapshot innodb-5.1-ss2438, part 3. Changes to plug.in structure, some INNODB_CFLAGS improvements for better maintenance, and some comments and whitespace changes. Detailed revision comments: r2433 | vasil | 2008-04-30 12:02:35 +0300 (Wed, 30 Apr 2008) | 5 lines branches/5.1: Add vim modeline to hint it that plug.in is a config file so it can be colorized. r2429 | vasil | 2008-04-30 11:19:06 +0300 (Wed, 30 Apr 2008) | 10 lines branches/5.1: * Use INNODB_CFLAGS insead of cluttering CFLAGS with InnoDB specific flags. CFLAGS are used to compile every file in the MySQL source tree. * Add INNODB_DYNAMIC_CFLAGS to the flags of the dynamic plugin and use -prefer-non-pic to make the dynamic plugin faster on i386. Approved by: Sunny r2430 | vasil | 2008-04-30 11:48:35 +0300 (Wed, 30 Apr 2008) | 8 lines branches/5.1: Use CFLAGS instead of INNODB_CFLAGS to avoid having incompatible flags inserted in CFLAGS and INNODB_CFLAGS and to avoid compiling mysql and innodb with different flags. Discussed with: Sunny r2431 | vasil | 2008-04-30 11:54:49 +0300 (Wed, 30 Apr 2008) | 4 lines branches/5.1: Fix r2430, it should be CFLAGS="$CFLAGS ..." not CFLAGS="..." r2432 | vasil | 2008-04-30 11:58:38 +0300 (Wed, 30 Apr 2008) | 4 lines branches/5.1: Non-functional change: use tabs for indentation in plug.in. r2436 | vasil | 2008-04-30 19:15:46 +0300 (Wed, 30 Apr 2008) | 7 lines branches/5.1: Non-functional white space change in Makefile.am: Use tabs for indentation and be consistent about spaces around the equal sign. --- storage/innobase/Makefile.am | 38 +++++++++++++++---------------- storage/innobase/plug.in | 43 ++++++++++++++++++++---------------- 2 files changed, 43 insertions(+), 38 deletions(-) diff --git a/storage/innobase/Makefile.am b/storage/innobase/Makefile.am index b5e5c5375dc..7410bf7e591 100644 --- a/storage/innobase/Makefile.am +++ b/storage/innobase/Makefile.am @@ -15,21 +15,21 @@ # Process this file with automake to create Makefile.in -MYSQLDATAdir = $(localstatedir) -MYSQLSHAREdir = $(pkgdatadir) -MYSQLBASEdir= $(prefix) -MYSQLLIBdir= $(pkglibdir) -pkgplugindir = $(pkglibdir)/plugin -INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \ +MYSQLDATAdir= $(localstatedir) +MYSQLSHAREdir= $(pkgdatadir) +MYSQLBASEdir= $(prefix) +MYSQLLIBdir= $(pkglibdir) +pkgplugindir= $(pkglibdir)/plugin +INCLUDES= -I$(top_srcdir)/include -I$(top_builddir)/include \ -I$(top_srcdir)/regex \ -I$(top_srcdir)/storage/innobase/include \ -I$(top_srcdir)/sql \ - -I$(srcdir) + -I$(srcdir) -DEFS = @DEFS@ +DEFS= @DEFS@ -noinst_HEADERS = include/btr0btr.h include/btr0btr.ic \ +noinst_HEADERS= include/btr0btr.h include/btr0btr.ic \ include/btr0cur.h include/btr0cur.ic \ include/btr0pcur.h include/btr0pcur.ic \ include/btr0sea.h include/btr0sea.ic \ @@ -121,9 +121,9 @@ noinst_HEADERS = include/btr0btr.h include/btr0btr.ic \ include/ut0list.ic include/ut0wqueue.h \ include/ha_prototypes.h handler/ha_innodb.h -EXTRA_LIBRARIES = libinnobase.a -noinst_LIBRARIES = @plugin_innobase_static_target@ -libinnobase_a_SOURCES = btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c \ +EXTRA_LIBRARIES= libinnobase.a +noinst_LIBRARIES= @plugin_innobase_static_target@ +libinnobase_a_SOURCES= btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c \ btr/btr0sea.c buf/buf0buf.c buf/buf0flu.c \ buf/buf0lru.c buf/buf0rea.c data/data0data.c \ data/data0type.c dict/dict0boot.c \ @@ -156,17 +156,17 @@ libinnobase_a_SOURCES = btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c \ handler/ha_innodb.cc libinnobase_a_CXXFLAGS= $(AM_CFLAGS) -libinnobase_a_CFLAGS = $(AM_CFLAGS) +libinnobase_a_CFLAGS= $(AM_CFLAGS) -EXTRA_LTLIBRARIES = ha_innodb.la +EXTRA_LTLIBRARIES= ha_innodb.la pkgplugin_LTLIBRARIES= @plugin_innobase_shared_target@ -ha_innodb_la_LDFLAGS = -module -rpath $(pkgplugindir) -ha_innodb_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN -ha_innodb_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN -ha_innodb_la_SOURCES = $(libinnobase_a_SOURCES) +ha_innodb_la_LDFLAGS= -module -rpath $(pkgplugindir) +ha_innodb_la_CXXFLAGS= $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS) +ha_innodb_la_CFLAGS= $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS) +ha_innodb_la_SOURCES= $(libinnobase_a_SOURCES) -EXTRA_DIST = CMakeLists.txt plug.in \ +EXTRA_DIST= CMakeLists.txt plug.in \ pars/make_bison.sh pars/make_flex.sh \ pars/pars0grm.y pars/pars0lex.l diff --git a/storage/innobase/plug.in b/storage/innobase/plug.in index b252d471fba..f7d2abed751 100644 --- a/storage/innobase/plug.in +++ b/storage/innobase/plug.in @@ -15,25 +15,30 @@ MYSQL_PLUGIN_ACTIONS(innobase, [ AC_CHECK_FUNCS(localtime_r) AC_C_BIGENDIAN case "$target_os" in - lin*) - CFLAGS="$CFLAGS -DUNIV_LINUX";; - hpux10*) - CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX -DUNIV_HPUX10";; - hp*) - CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX";; - aix*) - CFLAGS="$CFLAGS -DUNIV_AIX";; - irix*) - CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE";; - osf*) - CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE";; - *solaris*|*SunOS*) - CFLAGS="$CFLAGS -DUNIV_SOLARIS";; - sysv5uw7*) - # Problem when linking on SCO - CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE";; - openbsd*) - CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE";; + lin*) + CFLAGS="$CFLAGS -DUNIV_LINUX";; + hpux10*) + CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX -DUNIV_HPUX10";; + hp*) + CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX";; + aix*) + CFLAGS="$CFLAGS -DUNIV_AIX";; + irix*|osf*|sysv5uw7*|openbsd*) + CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE";; + *solaris*|*SunOS*) + CFLAGS="$CFLAGS -DUNIV_SOLARIS";; esac + INNODB_DYNAMIC_CFLAGS="-DMYSQL_DYNAMIC_PLUGIN" + case "$target_cpu" in + x86_64) + # The AMD64 ABI forbids absolute addresses in shared libraries + ;; + *86) + # Use absolute addresses on IA-32 + INNODB_DYNAMIC_CFLAGS="$INNODB_DYNAMIC_CFLAGS -prefer-non-pic" + ;; + esac + AC_SUBST(INNODB_DYNAMIC_CFLAGS) ]) +# vim: set ft=config: From 63a5c5708e7b3c072584f76fc48589b1b48f705e Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 12:15:12 -0700 Subject: [PATCH 061/137] Complete applying InnoDB snapshot innodb-5.1-ss2479. Fixes Bug #11894: innodb_file_per_table crashes w/ Windows .sym symbolic link hack Detailed revision comments: r2466 | calvin | 2008-05-20 01:37:14 +0300 (Tue, 20 May 2008) | 12 lines branches/5.1: Fix Bug#11894 innodb_file_per_table crashes w/ Windows .sym symbolic link hack The crash was due to un-handled error 3 (path not found). In the case of file per table, change the call to os_file_handle_error_no_exit() from os_file_handle_error(). Also, checks for full path pattern during table create (Windows only), which is used in symbolic link and temp table creation. Approved by: Heikki --- storage/innobase/handler/ha_innodb.cc | 23 +++++++++++++++++++ storage/innobase/os/os0file.c | 32 ++++++++++++++++++++++----- 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index cd2b121cbf4..4b7c5b1246a 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -4990,6 +4990,29 @@ ha_innobase::create( DBUG_ENTER("ha_innobase::create"); DBUG_ASSERT(thd != NULL); + DBUG_ASSERT(create_info != NULL); + +#ifdef __WIN__ + /* Names passed in from server are in two formats: + 1. /: for normal table creation + 2. full path: for temp table creation, or sym link + + When srv_file_per_table is on, check for full path pattern, i.e. + X:\dir\..., X is a driver letter, or + \\dir1\dir2\..., UNC path + returns error if it is in full path format, but not creating a temp. + table. Currently InnoDB does not support symbolic link on Windows. */ + + if (srv_file_per_table + && (!create_info->options & HA_LEX_CREATE_TMP_TABLE)) { + + if ((name[1] == ':') + || (name[0] == '\\' && name[1] == '\\')) { + sql_print_error("Cannot create table %s\n", name); + DBUG_RETURN(HA_ERR_GENERIC); + } + } +#endif if (form->s->fields > 1000) { /* The limit probably should be REC_MAX_N_FIELDS - 3 = 1020, diff --git a/storage/innobase/os/os0file.c b/storage/innobase/os/os0file.c index 9adb9ddac50..8fd959512c1 100644 --- a/storage/innobase/os/os0file.c +++ b/storage/innobase/os/os0file.c @@ -1267,9 +1267,19 @@ try_again: if (file == INVALID_HANDLE_VALUE) { *success = FALSE; - retry = os_file_handle_error(name, - create_mode == OS_FILE_CREATE ? - "create" : "open"); + /* When srv_file_per_table is on, file creation failure may not + be critical to the whole instance. Do not crash the server in + case of unknown errors. */ + if (srv_file_per_table) { + retry = os_file_handle_error_no_exit(name, + create_mode == OS_FILE_CREATE ? + "create" : "open"); + } else { + retry = os_file_handle_error(name, + create_mode == OS_FILE_CREATE ? + "create" : "open"); + } + if (retry) { goto try_again; } @@ -1344,9 +1354,19 @@ try_again: if (file == -1) { *success = FALSE; - retry = os_file_handle_error(name, - create_mode == OS_FILE_CREATE ? - "create" : "open"); + /* When srv_file_per_table is on, file creation failure may not + be critical to the whole instance. Do not crash the server in + case of unknown errors. */ + if (srv_file_per_table) { + retry = os_file_handle_error_no_exit(name, + create_mode == OS_FILE_CREATE ? + "create" : "open"); + } else { + retry = os_file_handle_error(name, + create_mode == OS_FILE_CREATE ? + "create" : "open"); + } + if (retry) { goto try_again; } else { From 8b88249b0aa5423bc6e3a32299902dbd087af6e8 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 12:18:59 -0700 Subject: [PATCH 062/137] Complete application of InnoDB snapshot innodb-5.1-ss2485, part 1. Fixes Bug #36819: ut_usectime does not handle errors from gettimeofday Detailed revision comments: r2480 | vasil | 2008-05-27 11:40:07 +0300 (Tue, 27 May 2008) | 11 lines branches/5.1: Fix Bug#36819 ut_usectime does not handle errors from gettimeofday by retrying gettimeofday() several times if it fails in ut_usectime(). If it fails on all calls then return error to the caller to be handled at higher level. Update the variable innodb_row_lock_time_max in SHOW STATUS output only if ut_usectime() was successful. --- storage/innobase/include/ut0ut.h | 8 +++++-- storage/innobase/srv/srv0srv.c | 19 ++++++++++++----- storage/innobase/ut/ut0ut.c | 36 +++++++++++++++++++++++++++----- 3 files changed, 51 insertions(+), 12 deletions(-) diff --git a/storage/innobase/include/ut0ut.h b/storage/innobase/include/ut0ut.h index a60ce73c35a..8ad1782b178 100644 --- a/storage/innobase/include/ut0ut.h +++ b/storage/innobase/include/ut0ut.h @@ -145,11 +145,15 @@ ib_time_t ut_time(void); /*=========*/ /************************************************************** -Returns system time. */ +Returns system time. +Upon successful completion, the value 0 is returned; otherwise the +value -1 is returned and the global variable errno is set to indicate the +error. */ -void +int ut_usectime( /*========*/ + /* out: 0 on success, -1 otherwise */ ulint* sec, /* out: seconds since the Epoch */ ulint* ms); /* out: microseconds since the Epoch+*sec */ /************************************************************** diff --git a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c index 773b5d583e0..e8b7bd4cee2 100644 --- a/storage/innobase/srv/srv0srv.c +++ b/storage/innobase/srv/srv0srv.c @@ -1453,8 +1453,11 @@ srv_suspend_mysql_thread( srv_n_lock_wait_count++; srv_n_lock_wait_current_count++; - ut_usectime(&sec, &ms); - start_time = (ib_longlong)sec * 1000000 + ms; + if (ut_usectime(&sec, &ms) == -1) { + start_time = -1; + } else { + start_time = (ib_longlong)sec * 1000000 + ms; + } } /* Wake the lock timeout monitor thread, if it is suspended */ @@ -1508,14 +1511,20 @@ srv_suspend_mysql_thread( wait_time = ut_difftime(ut_time(), slot->suspend_time); if (thr->lock_state == QUE_THR_LOCK_ROW) { - ut_usectime(&sec, &ms); - finish_time = (ib_longlong)sec * 1000000 + ms; + if (ut_usectime(&sec, &ms) == -1) { + finish_time = -1; + } else { + finish_time = (ib_longlong)sec * 1000000 + ms; + } diff_time = (ulint) (finish_time - start_time); srv_n_lock_wait_current_count--; srv_n_lock_wait_time = srv_n_lock_wait_time + diff_time; - if (diff_time > srv_n_lock_max_wait_time) { + if (diff_time > srv_n_lock_max_wait_time && + /* only update the variable if we successfully + retrieved the start and finish times. See Bug#36819. */ + start_time != -1 && finish_time != -1) { srv_n_lock_max_wait_time = diff_time; } } diff --git a/storage/innobase/ut/ut0ut.c b/storage/innobase/ut/ut0ut.c index 1ca278cd633..6b5bcef1830 100644 --- a/storage/innobase/ut/ut0ut.c +++ b/storage/innobase/ut/ut0ut.c @@ -112,19 +112,45 @@ ut_time(void) } /************************************************************** -Returns system time. */ +Returns system time. +Upon successful completion, the value 0 is returned; otherwise the +value -1 is returned and the global variable errno is set to indicate the +error. */ -void +int ut_usectime( /*========*/ + /* out: 0 on success, -1 otherwise */ ulint* sec, /* out: seconds since the Epoch */ ulint* ms) /* out: microseconds since the Epoch+*sec */ { struct timeval tv; + int ret; + int errno_gettimeofday; + int i; - ut_gettimeofday(&tv, NULL); - *sec = (ulint) tv.tv_sec; - *ms = (ulint) tv.tv_usec; + for (i = 0; i < 10; i++) { + + ret = ut_gettimeofday(&tv, NULL); + + if (ret == -1) { + errno_gettimeofday = errno; + ut_print_timestamp(stderr); + fprintf(stderr, " InnoDB: gettimeofday(): %s\n", + strerror(errno_gettimeofday)); + os_thread_sleep(100000); /* 0.1 sec */ + errno = errno_gettimeofday; + } else { + break; + } + } + + if (ret != -1) { + *sec = (ulint) tv.tv_sec; + *ms = (ulint) tv.tv_usec; + } + + return(ret); } /************************************************************** From 85b06b4ea9caa9f5e74369a605b4f58a5a9d63d1 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 12:21:24 -0700 Subject: [PATCH 063/137] Complete application of InnoDB snapshot innodb-5.1-ss2485, part 2. Fixes Bug #36149: Read buffer overflow in srv0start.c found during "make test" Detailed revision comments: r2485 | vasil | 2008-05-28 16:01:14 +0300 (Wed, 28 May 2008) | 9 lines branches/5.1: Fix Bug#36149 Read buffer overflow in srv0start.c found during "make test" Use strncmp(3) instead of memcmp(3) to avoid reading past end of the string if it is empty (*str == '\0'). This bug is _not_ a buffer overflow. Discussed with: Sunny (via IM) --- storage/innobase/srv/srv0start.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/storage/innobase/srv/srv0start.c b/storage/innobase/srv/srv0start.c index 979d882307a..ea88039f3dd 100644 --- a/storage/innobase/srv/srv0start.c +++ b/storage/innobase/srv/srv0start.c @@ -202,13 +202,13 @@ srv_parse_data_file_paths_and_sizes( str = srv_parse_megabytes(str, &size); - if (0 == memcmp(str, ":autoextend", - (sizeof ":autoextend") - 1)) { + if (0 == strncmp(str, ":autoextend", + (sizeof ":autoextend") - 1)) { str += (sizeof ":autoextend") - 1; - if (0 == memcmp(str, ":max:", - (sizeof ":max:") - 1)) { + if (0 == strncmp(str, ":max:", + (sizeof ":max:") - 1)) { str += (sizeof ":max:") - 1; @@ -290,14 +290,15 @@ srv_parse_data_file_paths_and_sizes( (*data_file_names)[i] = path; (*data_file_sizes)[i] = size; - if (0 == memcmp(str, ":autoextend", - (sizeof ":autoextend") - 1)) { + if (0 == strncmp(str, ":autoextend", + (sizeof ":autoextend") - 1)) { *is_auto_extending = TRUE; str += (sizeof ":autoextend") - 1; - if (0 == memcmp(str, ":max:", (sizeof ":max:") - 1)) { + if (0 == strncmp(str, ":max:", + (sizeof ":max:") - 1)) { str += (sizeof ":max:") - 1; From 980ec41fe70e11e5263dfe148b8e82d350d07c2b Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 12:25:33 -0700 Subject: [PATCH 064/137] Complete application of InnoDB snapshot innodb-5.1-ss2545. Fix race condition which could result in freeing a struct that is still in use by another thread. Detailed revision comments: r2537 | inaam | 2008-07-15 20:46:03 +0300 (Tue, 15 Jul 2008) | 12 lines branches/5.1 issue# 4 Fixed a timing hole where a thread dropping an index can free the in-memory index struct while another thread is still using that structure to remove entries from adaptive hash index belonging to one of the pages that belongs to the index being dropped. The fix is to have a reference counter in the index struct and to wait for this counter to drop to zero beforing freeing the struct. Reviewed by: Heikki r2543 | inaam | 2008-07-22 18:57:43 +0300 (Tue, 22 Jul 2008) | 7 lines branches/5.1: Removed UNIV_INLINE qualifier from btr_search_info_get_ref_count(). Otherwise compilation failed on non-debug builds. Pointed by: Vasil --- storage/innobase/btr/btr0sea.c | 39 +++++++++++++++++++++++++ storage/innobase/dict/dict0dict.c | 47 ++++++++++++++++++++++++++++++ storage/innobase/include/btr0sea.h | 15 ++++++++++ 3 files changed, 101 insertions(+) diff --git a/storage/innobase/btr/btr0sea.c b/storage/innobase/btr/btr0sea.c index 2fe3606a390..3482e16497a 100644 --- a/storage/innobase/btr/btr0sea.c +++ b/storage/innobase/btr/btr0sea.c @@ -161,6 +161,7 @@ btr_search_info_create( info->magic_n = BTR_SEARCH_MAGIC_N; #endif /* UNIV_DEBUG */ + info->ref_count = 0; info->root_guess = NULL; info->hash_analysis = 0; @@ -184,6 +185,31 @@ btr_search_info_create( return(info); } +/********************************************************************* +Returns the value of ref_count. The value is protected by +btr_search_latch. */ +ulint +btr_search_info_get_ref_count( +/*==========================*/ + /* out: ref_count value. */ + btr_search_t* info) /* in: search info. */ +{ + ulint ret; + + ut_ad(info); + +#ifdef UNIV_SYNC_DEBUG + ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED)); + ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); +#endif /* UNIV_SYNC_DEBUG */ + + rw_lock_s_lock(&btr_search_latch); + ret = info->ref_count; + rw_lock_s_unlock(&btr_search_latch); + + return(ret); +} + /************************************************************************* Updates the search info of an index about hash successes. NOTE that info is NOT protected by any semaphore, to save CPU time! Do not assume its fields @@ -1022,8 +1048,12 @@ next_rec: ha_remove_all_nodes_to_page(table, folds[i], page); } + ut_a(index->search_info->ref_count > 0); + index->search_info->ref_count--; + block->is_hashed = FALSE; block->index = NULL; + cleanup: if (UNIV_UNLIKELY(block->n_pointers)) { /* Corruption */ @@ -1244,6 +1274,15 @@ btr_search_build_page_hash_index( goto exit_func; } + /* This counter is decremented every time we drop page + hash index entries and is incremented here. Since we can + rebuild hash index for a page that is already hashed, we + have to take care not to increment the counter in that + case. */ + if (!block->is_hashed) { + index->search_info->ref_count++; + } + block->is_hashed = TRUE; block->n_hash_helps = 0; diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c index 5eaa44b4615..7bc700c4268 100644 --- a/storage/innobase/dict/dict0dict.c +++ b/storage/innobase/dict/dict0dict.c @@ -1394,12 +1394,59 @@ dict_index_remove_from_cache( dict_index_t* index) /* in, own: index */ { ulint size; + ulint retries = 0; + btr_search_t* info; ut_ad(table && index); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); ut_ad(mutex_own(&(dict_sys->mutex))); + /* We always create search info whether or not adaptive + hash index is enabled or not. */ + info = index->search_info; + ut_ad(info); + + /* We are not allowed to free the in-memory index struct + dict_index_t until all entries in the adaptive hash index + that point to any of the page belonging to his b-tree index + are dropped. This is so because dropping of these entries + require access to dict_index_t struct. To avoid such scenario + We keep a count of number of such pages in the search_info and + only free the dict_index_t struct when this count drops to + zero. */ + + for (;;) { + ulint ref_count = btr_search_info_get_ref_count(info); + if (ref_count == 0) { + break; + } + + /* Sleep for 10ms before trying again. */ + os_thread_sleep(10000); + ++retries; + + if (retries % 500 == 0) { + /* No luck after 5 seconds of wait. */ + fprintf(stderr, "InnoDB: Error: Waited for" + " %lu secs for hash index" + " ref_count (%lu) to drop" + " to 0.\n" + "index: \"%s\"" + " table: \"%s\"\n", + retries/100, + ref_count, + index->name, + table->name); + } + + /* To avoid a hang here we commit suicide if the + ref_count doesn't drop to zero in 600 seconds. */ + if (retries >= 60000) { + ut_error; + } + } + rw_lock_free(&index->lock); /* Remove the index from the list of indexes of the table */ diff --git a/storage/innobase/include/btr0sea.h b/storage/innobase/include/btr0sea.h index 281587ad060..6d1c2bb86d3 100644 --- a/storage/innobase/include/btr0sea.h +++ b/storage/innobase/include/btr0sea.h @@ -40,6 +40,14 @@ btr_search_info_create( /*===================*/ /* out, own: search info struct */ mem_heap_t* heap); /* in: heap where created */ +/********************************************************************* +Returns the value of ref_count. The value is protected by +btr_search_latch. */ +ulint +btr_search_info_get_ref_count( +/*==========================*/ + /* out: ref_count value. */ + btr_search_t* info); /* in: search info. */ /************************************************************************* Updates the search info. */ UNIV_INLINE @@ -137,6 +145,13 @@ btr_search_validate(void); /* The search info struct in an index */ struct btr_search_struct{ + ulint ref_count; /* Number of blocks in this index tree + that have search index built + i.e. block->index points to this index. + Protected by btr_search_latch except + when during initialization in + btr_search_info_create(). */ + /* The following fields are not protected by any latch. Unfortunately, this means that they must be aligned to the machine word, i.e., they cannot be turned into bit-fields. */ From 8b0a676eb45e7c65156594d8791724ca9bd1a653 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 12:28:19 -0700 Subject: [PATCH 065/137] Apply InnoDB snapshot innodb-5.1-ss2637, part 1. Fixes Bug #37885: row_search_for_mysql may gap lock unnecessarily with SQL comments in query Detailed revision comments: r2603 | marko | 2008-08-21 16:25:05 +0300 (Thu, 21 Aug 2008) | 10 lines branches/5.1: Identify SELECT statements by thd_sql_command() == SQLCOM_SELECT instead of parsing the query string. This fixes MySQL Bug #37885 without us having to implement lexical analysis of SQL comments in yet another place. thd_is_select(): A new predicate. row_search_for_mysql(): Use thd_is_select(). Approved by Heikki. --- storage/innobase/handler/ha_innodb.cc | 12 ++++++++++++ storage/innobase/include/ha_prototypes.h | 9 +++++++++ storage/innobase/row/row0sel.c | 17 +++++------------ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 4b7c5b1246a..8a8d9698ac1 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -507,6 +507,18 @@ thd_has_edited_nontrans_tables( return((ibool) thd_non_transactional_update((THD*) thd)); } +/********************************************************************** +Returns true if the thread is executing a SELECT statement. */ +extern "C" +ibool +thd_is_select( +/*==========*/ + /* out: true if thd is executing SELECT */ + const void* thd) /* in: thread handle (THD*) */ +{ + return(thd_sql_command((const THD*) thd) == SQLCOM_SELECT); +} + /************************************************************************ Obtain the InnoDB transaction of a MySQL thread. */ inline diff --git a/storage/innobase/include/ha_prototypes.h b/storage/innobase/include/ha_prototypes.h index ef0722321af..6bfc43579b3 100644 --- a/storage/innobase/include/ha_prototypes.h +++ b/storage/innobase/include/ha_prototypes.h @@ -63,5 +63,14 @@ thd_has_edited_nontrans_tables( been edited */ void* thd); /* in: thread handle (THD*) */ +/********************************************************************** +Returns true if the thread is executing a SELECT statement. */ + +ibool +thd_is_select( +/*==========*/ + /* out: true if thd is executing SELECT */ + const void* thd); /* in: thread handle (THD*) */ + #endif #endif diff --git a/storage/innobase/row/row0sel.c b/storage/innobase/row/row0sel.c index c6a93d4e0d5..79f107ce77d 100644 --- a/storage/innobase/row/row0sel.c +++ b/storage/innobase/row/row0sel.c @@ -32,6 +32,7 @@ Created 12/19/1997 Heikki Tuuri #include "row0mysql.h" #include "read0read.h" #include "buf0lru.h" +#include "ha_prototypes.h" /* Maximum number of rows to prefetch; MySQL interface has another parameter */ #define SEL_MAX_N_PREFETCH 16 @@ -3578,19 +3579,11 @@ shortcut_fails_too_big_rec: if (trx->isolation_level <= TRX_ISO_READ_COMMITTED && prebuilt->select_lock_type != LOCK_NONE && trx->mysql_thd != NULL - && trx->mysql_query_str != NULL - && *trx->mysql_query_str != NULL) { + && thd_is_select(trx->mysql_thd)) { + /* It is a plain locking SELECT and the isolation + level is low: do not lock gaps */ - /* Scan the MySQL query string; check if SELECT is the first - word there */ - - if (dict_str_starts_with_keyword( - trx->mysql_thd, *trx->mysql_query_str, "SELECT")) { - /* It is a plain locking SELECT and the isolation - level is low: do not lock gaps */ - - set_also_gap_locks = FALSE; - } + set_also_gap_locks = FALSE; } /* Note that if the search mode was GE or G, then the cursor From fef8e27a79f7edbbfcfde2130fbe8fc290de6361 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 12:29:59 -0700 Subject: [PATCH 066/137] Apply InnoDB snapshot innodb-5.1-ss2637, part 2. Fixes Bug #38839: auto increment does not work properly with InnoDB after update Detailed revision comments: r2609 | sunny | 2008-08-24 01:19:05 +0300 (Sun, 24 Aug 2008) | 12 lines branches/5.1: Fix for MySQL Bug#38839. Reset the statement level last value field in prebuilt. This field tracks the last value in an autoincrement interval. We use this value to check whether we need to update a table's AUTOINC counter, if the value written to a table is less than this value then we avoid updating the table's AUTOINC value in order to reduce mutex contention. If it's not reset (e.g., after a DELETE statement) then there is the possibility of missing updates to the table's AUTOINC counter resulting in a subsequent duplicate row error message under certain conditions (see the test case for details). Bug #38839 - auto increment does not work properly with InnoDB after update --- mysql-test/r/innodb-autoinc.result | 27 +++++++++++++++++++++++++++ mysql-test/t/innodb-autoinc.test | 21 +++++++++++++++++++++ storage/innobase/handler/ha_innodb.cc | 23 +++++++++++++++++------ 3 files changed, 65 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/innodb-autoinc.result b/mysql-test/r/innodb-autoinc.result index e000f910772..70cdc67f77e 100644 --- a/mysql-test/r/innodb-autoinc.result +++ b/mysql-test/r/innodb-autoinc.result @@ -169,3 +169,30 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`c1`) ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1 DROP TABLE t1; +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE t1 (c1 INT AUTO_INCREMENT, c2 INT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL, 1); +DELETE FROM t1 WHERE c1 = 1; +INSERT INTO t1 VALUES (2,1); +INSERT INTO t1 VALUES (NULL,8); +SELECT * FROM t1; +c1 c2 +2 1 +3 8 +DROP TABLE t1; +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE t1 (c1 INT AUTO_INCREMENT, c2 INT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL, 1); +DELETE FROM t1 WHERE c1 = 1; +INSERT INTO t1 VALUES (2,1), (NULL, 8); +INSERT INTO t1 VALUES (NULL,9); +SELECT * FROM t1; +c1 c2 +2 1 +3 8 +5 9 +DROP TABLE t1; diff --git a/mysql-test/t/innodb-autoinc.test b/mysql-test/t/innodb-autoinc.test index aa464e42627..1c97364199b 100644 --- a/mysql-test/t/innodb-autoinc.test +++ b/mysql-test/t/innodb-autoinc.test @@ -139,3 +139,24 @@ SELECT c1 FROM t1; SHOW CREATE TABLE t1; DROP TABLE t1; +# +# Bug 38839 +# Reset the last value generated at end of statement +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 INT AUTO_INCREMENT, c2 INT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL, 1); +DELETE FROM t1 WHERE c1 = 1; +INSERT INTO t1 VALUES (2,1); +INSERT INTO t1 VALUES (NULL,8); +SELECT * FROM t1; +DROP TABLE t1; +# Bug 38839 -- same as above but for multi value insert +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 INT AUTO_INCREMENT, c2 INT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL, 1); +DELETE FROM t1 WHERE c1 = 1; +INSERT INTO t1 VALUES (2,1), (NULL, 8); +INSERT INTO t1 VALUES (NULL,9); +SELECT * FROM t1; +DROP TABLE t1; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 8a8d9698ac1..682ba19aab9 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -6429,15 +6429,26 @@ ha_innobase::extra( return(0); } +/********************************************************************** +Reset state of file to after 'open'. +This function is called after every statement for all tables used +by that statement. */ int ha_innobase::reset() { - if (prebuilt->blob_heap) { - row_mysql_prebuilt_free_blob_heap(prebuilt); - } - reset_template(prebuilt); - return 0; -} + if (prebuilt->blob_heap) { + row_mysql_prebuilt_free_blob_heap(prebuilt); + } + reset_template(prebuilt); + + /* TODO: This should really be reset in reset_template() but for now + it's safer to do it explicitly here. */ + + /* This is a statement level counter. */ + prebuilt->last_value = 0; + + return(0); +} /********************************************************************** MySQL calls this function at the start of each SQL statement inside LOCK From bc896a54c87099a7a090c0255c2a6fa89ed64786 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 12:31:26 -0700 Subject: [PATCH 067/137] Apply InnoDB snapshot innodb-5.1-ss2637, part 3. Fixes Bug #39483: InnoDB hang on adaptive hash because of out of order ::open() call by MySQL Detailed revision comments: r2630 | inaam | 2008-09-16 19:11:26 +0300 (Tue, 16 Sep 2008) | 11 lines branches/5.1 bug#39483 InnoDB hang on adaptive hash because of out of order ::open() call by MySQL Forward port of r2629 Under some conditions MySQL calls ::open with search_latch leading to a deadlock as we try to acquire dict_sys->mutex inside ::open breaking the latching order. The fix is to release search_latch. Reviewed by: Heikki --- storage/innobase/handler/ha_innodb.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 682ba19aab9..1982fe8c212 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -2298,6 +2298,14 @@ ha_innobase::open( UT_NOT_USED(test_if_locked); thd = ha_thd(); + + /* Under some cases MySQL seems to call this function while + holding btr_search_latch. This breaks the latching order as + we acquire dict_sys->mutex below and leads to a deadlock. */ + if (thd != NULL) { + innobase_release_temporary_latches(ht, thd); + } + normalize_table_name(norm_name, name); user_thd = NULL; From e4591eb25b6ad5b0a3a571c3e415df049a8e37f0 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 12:37:23 -0700 Subject: [PATCH 068/137] Apply InnoDB snapshot innodb-5.1-ss2858, part 1. Fixes Bug #35498: Cannot get table test/table1 auto-inccounter value in ::info Detailed revison comments: r2702 | sunny | 2008-09-30 11:41:56 +0300 (Tue, 30 Sep 2008) | 13 lines branches/5.1: Since handler::get_auto_increment() doesn't allow us to return the cause of failure we have to inform MySQL using the sql_print_warning() function to return the cause for autoinc failure. Previously we simply printed the error code, this patch prints the text string representing the following two error codes: DB_LOCK_WAIT_TIMEOUT DB_DEADLOCK. Bug#35498 Cannot get table test/table1 auto-inccounter value in ::info Approved by Marko. --- storage/innobase/handler/ha_innodb.cc | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 1982fe8c212..600473c2cd2 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -7456,13 +7456,23 @@ ha_innobase::innobase_get_auto_increment( } else { *value = autoinc; } - /* A deadlock error during normal processing is OK - and can be ignored. */ - } else if (error != DB_DEADLOCK) { + /* We need to print this message here because the + handler::get_auto_increment() doesn't allow a way + to return the specific error for why it failed. */ + } else if (error == DB_DEADLOCK) { + sql_print_warning( + "Deadlock in " + "innobase_get_auto_increment()"); + } else if (error == DB_LOCK_WAIT_TIMEOUT) { + sql_print_warning( + "Lock wait timeout in " + "innobase_get_auto_increment()"); + } else { - sql_print_error("InnoDB: Error: %lu in " - "::innobase_get_auto_increment()", - error); + sql_print_error( + "InnoDB: Error: %lu in " + "innobase_get_auto_increment()", + error); } } while (*value == 0 && error == DB_SUCCESS); From fe769c968eac80cae884e3b59b531df5f46ed346 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 13:00:37 -0700 Subject: [PATCH 069/137] Apply InnoDB snapshot innodb-5.1-ss2858, part 2. Fixes Bug#38231: Innodb crash in lock_reset_all_on_table() on TRUNCATE + LOCK / UNLOCK branches/5.1: Fix Bug#38231 Innodb crash in lock_reset_all_on_table() on TRUNCATE + LOCK / UNLOCK In TRUNCATE TABLE and discard tablespace: do not remove table-level S and X locks and do not assert on such locks not being wait locks. Leave such locks alone. Approved by: Heikki (rb://14) --- mysql-test/r/innodb_bug38231.result | 22 ++++ mysql-test/t/innodb_bug38231.test | 166 +++++++++++++++++++++++++++ storage/innobase/include/lock0lock.h | 17 ++- storage/innobase/lock/lock0lock.c | 83 +++++++++++--- storage/innobase/row/row0mysql.c | 14 +-- 5 files changed, 273 insertions(+), 29 deletions(-) create mode 100644 mysql-test/r/innodb_bug38231.result create mode 100644 mysql-test/t/innodb_bug38231.test diff --git a/mysql-test/r/innodb_bug38231.result b/mysql-test/r/innodb_bug38231.result new file mode 100644 index 00000000000..b5d1d91ddc0 --- /dev/null +++ b/mysql-test/r/innodb_bug38231.result @@ -0,0 +1,22 @@ +SET storage_engine=InnoDB; +INSERT INTO bug38231 VALUES (1), (10), (300); +SET autocommit=0; +SELECT * FROM bug38231 FOR UPDATE; +a +1 +10 +300 +TRUNCATE TABLE bug38231; +COMMIT; +DROP TABLE bug38231; +SET storage_engine=InnoDB; +INSERT INTO bug38231 VALUES (1), (10), (300); +SET autocommit=0; +SELECT * FROM bug38231 FOR UPDATE; +a +1 +10 +300 +TRUNCATE TABLE bug38231; +COMMIT; +DROP TABLE bug38231; diff --git a/mysql-test/t/innodb_bug38231.test b/mysql-test/t/innodb_bug38231.test new file mode 100644 index 00000000000..7ee35b2bc78 --- /dev/null +++ b/mysql-test/t/innodb_bug38231.test @@ -0,0 +1,166 @@ +# +# Bug#38231 Innodb crash in lock_reset_all_on_table() on TRUNCATE + LOCK / UNLOCK +# http://bugs.mysql.com/38231 +# + +-- source include/have_innodb.inc + +SET storage_engine=InnoDB; + +# we care only that the following SQL commands do not crash the server +-- disable_query_log +-- disable_result_log + +DROP TABLE IF EXISTS bug38231; +CREATE TABLE bug38231 (a INT); + +-- connect (con1,localhost,root,,) +-- connect (con2,localhost,root,,) +-- connect (con3,localhost,root,,) + +-- connection con1 +SET autocommit=0; +LOCK TABLE bug38231 WRITE; + +-- connection con2 +SET autocommit=0; +-- send +LOCK TABLE bug38231 WRITE; + +-- connection con3 +SET autocommit=0; +-- send +LOCK TABLE bug38231 WRITE; + +-- connection default +-- send +TRUNCATE TABLE bug38231; + +-- connection con1 +# give time to TRUNCATE and others to be executed; without sleep, sometimes +# UNLOCK executes before TRUNCATE +-- sleep 0.2 +# this crashes the server if the bug is present +UNLOCK TABLES; + +# clean up + +-- connection con2 +UNLOCK TABLES; + +-- connection con3 +UNLOCK TABLES; + +-- connection default + +-- disconnect con1 +-- disconnect con2 +-- disconnect con3 + +# test that TRUNCATE works with with row-level locks + +-- enable_query_log +-- enable_result_log + +INSERT INTO bug38231 VALUES (1), (10), (300); + +-- connect (con4,localhost,root,,) + +-- connection con4 +SET autocommit=0; +SELECT * FROM bug38231 FOR UPDATE; + +-- connection default +TRUNCATE TABLE bug38231; + +-- connection con4 +COMMIT; + +-- connection default + +-- disconnect con4 + +DROP TABLE bug38231; +# +# Bug#38231 Innodb crash in lock_reset_all_on_table() on TRUNCATE + LOCK / UNLOCK +# http://bugs.mysql.com/38231 +# + +-- source include/have_innodb.inc + +SET storage_engine=InnoDB; + +# we care only that the following SQL commands do not crash the server +-- disable_query_log +-- disable_result_log + +DROP TABLE IF EXISTS bug38231; +CREATE TABLE bug38231 (a INT); + +-- connect (con1,localhost,root,,) +-- connect (con2,localhost,root,,) +-- connect (con3,localhost,root,,) + +-- connection con1 +SET autocommit=0; +LOCK TABLE bug38231 WRITE; + +-- connection con2 +SET autocommit=0; +-- send +LOCK TABLE bug38231 WRITE; + +-- connection con3 +SET autocommit=0; +-- send +LOCK TABLE bug38231 WRITE; + +-- connection default +-- send +TRUNCATE TABLE bug38231; + +-- connection con1 +# give time to TRUNCATE and others to be executed; without sleep, sometimes +# UNLOCK executes before TRUNCATE +-- sleep 0.2 +# this crashes the server if the bug is present +UNLOCK TABLES; + +# clean up + +-- connection con2 +UNLOCK TABLES; + +-- connection con3 +UNLOCK TABLES; + +-- connection default + +-- disconnect con1 +-- disconnect con2 +-- disconnect con3 + +# test that TRUNCATE works with with row-level locks + +-- enable_query_log +-- enable_result_log + +INSERT INTO bug38231 VALUES (1), (10), (300); + +-- connect (con4,localhost,root,,) + +-- connection con4 +SET autocommit=0; +SELECT * FROM bug38231 FOR UPDATE; + +-- connection default +TRUNCATE TABLE bug38231; + +-- connection con4 +COMMIT; + +-- connection default + +-- disconnect con4 + +DROP TABLE bug38231; diff --git a/storage/innobase/include/lock0lock.h b/storage/innobase/include/lock0lock.h index 8b08b6284f6..635724bf5a1 100644 --- a/storage/innobase/include/lock0lock.h +++ b/storage/innobase/include/lock0lock.h @@ -463,14 +463,21 @@ void lock_cancel_waiting_and_release( /*============================*/ lock_t* lock); /* in: waiting lock request */ + /************************************************************************* -Resets all locks, both table and record locks, on a table to be dropped. -No lock is allowed to be a wait lock. */ +Removes locks on a table to be dropped or truncated. +If remove_also_table_sx_locks is TRUE then table-level S and X locks are +also removed in addition to other table-level and record-level locks. +No lock, that is going to be removed, is allowed to be a wait lock. */ void -lock_reset_all_on_table( -/*====================*/ - dict_table_t* table); /* in: table to be dropped */ +lock_remove_all_on_table( +/*=====================*/ + dict_table_t* table, /* in: table to be dropped + or truncated */ + ibool remove_also_table_sx_locks);/* in: also removes + table S and X locks */ + /************************************************************************* Calculates the fold value of a page file address: used in inserting or searching for a lock in the hash table. */ diff --git a/storage/innobase/lock/lock0lock.c b/storage/innobase/lock/lock0lock.c index c2ede22dccb..173d074cb82 100644 --- a/storage/innobase/lock/lock0lock.c +++ b/storage/innobase/lock/lock0lock.c @@ -3920,15 +3920,25 @@ lock_cancel_waiting_and_release( trx_end_lock_wait(lock->trx); } +/* True if a lock mode is S or X */ +#define IS_LOCK_S_OR_X(lock) \ + (lock_get_mode(lock) == LOCK_S \ + || lock_get_mode(lock) == LOCK_X) + + /************************************************************************* -Resets all record and table locks of a transaction on a table to be dropped. -No lock is allowed to be a wait lock. */ +Removes locks of a transaction on a table to be dropped. +If remove_also_table_sx_locks is TRUE then table-level S and X locks are +also removed in addition to other table-level and record-level locks. +No lock, that is going to be removed, is allowed to be a wait lock. */ static void -lock_reset_all_on_table_for_trx( -/*============================*/ - dict_table_t* table, /* in: table to be dropped */ - trx_t* trx) /* in: a transaction */ +lock_remove_all_on_table_for_trx( +/*=============================*/ + dict_table_t* table, /* in: table to be dropped */ + trx_t* trx, /* in: a transaction */ + ibool remove_also_table_sx_locks)/* in: also removes + table S and X locks */ { lock_t* lock; lock_t* prev_lock; @@ -3946,7 +3956,9 @@ lock_reset_all_on_table_for_trx( lock_rec_discard(lock); } else if (lock_get_type(lock) & LOCK_TABLE - && lock->un_member.tab_lock.table == table) { + && lock->un_member.tab_lock.table == table + && (remove_also_table_sx_locks + || !IS_LOCK_S_OR_X(lock))) { ut_a(!lock_get_wait(lock)); @@ -3958,26 +3970,65 @@ lock_reset_all_on_table_for_trx( } /************************************************************************* -Resets all locks, both table and record locks, on a table to be dropped. -No lock is allowed to be a wait lock. */ +Removes locks on a table to be dropped or truncated. +If remove_also_table_sx_locks is TRUE then table-level S and X locks are +also removed in addition to other table-level and record-level locks. +No lock, that is going to be removed, is allowed to be a wait lock. */ void -lock_reset_all_on_table( -/*====================*/ - dict_table_t* table) /* in: table to be dropped */ +lock_remove_all_on_table( +/*=====================*/ + dict_table_t* table, /* in: table to be dropped + or truncated */ + ibool remove_also_table_sx_locks)/* in: also removes + table S and X locks */ { lock_t* lock; + lock_t* prev_lock; mutex_enter(&kernel_mutex); lock = UT_LIST_GET_FIRST(table->locks); - while (lock) { - ut_a(!lock_get_wait(lock)); + while (lock != NULL) { - lock_reset_all_on_table_for_trx(table, lock->trx); + prev_lock = UT_LIST_GET_PREV(un_member.tab_lock.locks, + lock); - lock = UT_LIST_GET_FIRST(table->locks); + /* If we should remove all locks (remove_also_table_sx_locks + is TRUE), or if the lock is not table-level S or X lock, + then check we are not going to remove a wait lock. */ + if (remove_also_table_sx_locks + || !(lock_get_type(lock) == LOCK_TABLE + && IS_LOCK_S_OR_X(lock))) { + + ut_a(!lock_get_wait(lock)); + } + + lock_remove_all_on_table_for_trx(table, lock->trx, + remove_also_table_sx_locks); + + if (prev_lock == NULL) { + if (lock == UT_LIST_GET_FIRST(table->locks)) { + /* lock was not removed, pick its successor */ + lock = UT_LIST_GET_NEXT( + un_member.tab_lock.locks, lock); + } else { + /* lock was removed, pick the first one */ + lock = UT_LIST_GET_FIRST(table->locks); + } + } else if (UT_LIST_GET_NEXT(un_member.tab_lock.locks, + prev_lock) != lock) { + /* If lock was removed by + lock_remove_all_on_table_for_trx() then pick the + successor of prev_lock ... */ + lock = UT_LIST_GET_NEXT( + un_member.tab_lock.locks, prev_lock); + } else { + /* ... otherwise pick the successor of lock. */ + lock = UT_LIST_GET_NEXT( + un_member.tab_lock.locks, lock); + } } mutex_exit(&kernel_mutex); diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c index f5228618a04..74bf2267a3e 100644 --- a/storage/innobase/row/row0mysql.c +++ b/storage/innobase/row/row0mysql.c @@ -2451,8 +2451,8 @@ row_discard_tablespace_for_mysql( new_id = dict_hdr_get_new_id(DICT_HDR_TABLE_ID); - /* Remove any locks there are on the table or its records */ - lock_reset_all_on_table(table); + /* Remove all locks except the table-level S and X locks. */ + lock_remove_all_on_table(table, FALSE); info = pars_info_create(); @@ -2787,9 +2787,8 @@ row_truncate_table_for_mysql( goto funct_exit; } - /* Remove any locks there are on the table or its records */ - - lock_reset_all_on_table(table); + /* Remove all locks except the table-level S and X locks. */ + lock_remove_all_on_table(table, FALSE); trx->table_id = table->id; @@ -3139,9 +3138,8 @@ check_next_foreign: goto funct_exit; } - /* Remove any locks there are on the table or its records */ - - lock_reset_all_on_table(table); + /* Remove all locks there are on the table or its records */ + lock_remove_all_on_table(table, TRUE); trx->dict_operation = TRUE; trx->table_id = table->id; From cfd1095c79fd7e3c973cdd10e8c1a131fe36d0a1 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 13:27:13 -0700 Subject: [PATCH 070/137] Apply InnoDB snapshot innodb-5.1-ss2858, part 3. branches/5.1: Silence a compilation warning in UNIV_DEBUG. Approved by: Marko (via IM) --- storage/innobase/include/sync0sync.ic | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innobase/include/sync0sync.ic b/storage/innobase/include/sync0sync.ic index 908797f9729..ee640abefa6 100644 --- a/storage/innobase/include/sync0sync.ic +++ b/storage/innobase/include/sync0sync.ic @@ -197,7 +197,7 @@ mutex_exit( { ut_ad(mutex_own(mutex)); - ut_d(mutex->thread_id = ULINT_UNDEFINED); + ut_d(mutex->thread_id = (os_thread_id_t) ULINT_UNDEFINED); #ifdef UNIV_SYNC_DEBUG sync_thread_reset_level(mutex); From b3d77069e920a600d6efe4e06041d57732fa83e0 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 13:31:13 -0700 Subject: [PATCH 071/137] Apply InnoDB snapshot innodb-5.1-ss2858, part 4. Fixes Bug #39438: Testcase for Bug#39436 crashes on 5.1 in fil_space_get_latch Detailed revision comments: r2719 | vasil | 2008-10-03 18:17:28 +0300 (Fri, 03 Oct 2008) | 49 lines branches/5.1: Fix Bug#39438 Testcase for Bug#39436 crashes on 5.1 in fil_space_get_latch In ha_innobase::info() - do not try to get the free space for a tablespace which has been discarded with ALTER TABLE ... DISCARD TABLESPACE or if the .ibd file is missing for some other reason. ibd_file_missing and tablespace_discarded are manipulated only in row_discard_tablespace_for_mysql() and in row_import_tablespace_for_mysql() and the manipulation is protected/surrounded by row_mysql_lock_data_dictionary()/row_mysql_unlock_data_dictionary() thus we do the same in ha_innobase::info() when checking the values of those members to avoid race conditions. I have tested the code-path with UNIV_DEBUG and UNIV_SYNC_DEBUG. rb://20 Reviewed by: Inaam, Calvin Approved by: Heikki --- mysql-test/lib/mtr_report.pl | 5 ++++- mysql-test/r/innodb_bug39438.result | 1 + mysql-test/t/innodb_bug39438-master.opt | 1 + mysql-test/t/innodb_bug39438.test | 27 +++++++++++++++++++++++++ storage/innobase/handler/ha_innodb.cc | 21 ++++++++++++++++--- 5 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 mysql-test/r/innodb_bug39438.result create mode 100644 mysql-test/t/innodb_bug39438-master.opt create mode 100644 mysql-test/t/innodb_bug39438.test diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl index 3c78c3ca064..e3fabccd86d 100644 --- a/mysql-test/lib/mtr_report.pl +++ b/mysql-test/lib/mtr_report.pl @@ -412,7 +412,10 @@ sub mtr_report_stats ($) { # When trying to set lower_case_table_names = 2 # on a case sensitive file system. Bug#37402. - /lower_case_table_names was set to 2, even though your the file system '.*' is case sensitive. Now setting lower_case_table_names to 0 to avoid future problems./ + /lower_case_table_names was set to 2, even though your the file system '.*' is case sensitive. Now setting lower_case_table_names to 0 to avoid future problems./ or + + # this test is expected to print warnings + ($testname eq 'main.innodb_bug39438') ) { next; # Skip these lines diff --git a/mysql-test/r/innodb_bug39438.result b/mysql-test/r/innodb_bug39438.result new file mode 100644 index 00000000000..195775f74c8 --- /dev/null +++ b/mysql-test/r/innodb_bug39438.result @@ -0,0 +1 @@ +SET storage_engine=InnoDB; diff --git a/mysql-test/t/innodb_bug39438-master.opt b/mysql-test/t/innodb_bug39438-master.opt new file mode 100644 index 00000000000..43fac202fd4 --- /dev/null +++ b/mysql-test/t/innodb_bug39438-master.opt @@ -0,0 +1 @@ +--innodb-file-per-table=1 diff --git a/mysql-test/t/innodb_bug39438.test b/mysql-test/t/innodb_bug39438.test new file mode 100644 index 00000000000..4dc3d957c39 --- /dev/null +++ b/mysql-test/t/innodb_bug39438.test @@ -0,0 +1,27 @@ +# +# Bug#39438 Testcase for Bug#39436 crashes on 5.1 in fil_space_get_latch +# http://bugs.mysql.com/39438 +# +# This test must be run with innodb_file_per_table=1 because the crash +# only occurs if that option is turned on and DISCARD TABLESPACE only +# works with innodb_file_per_table. +# + +-- source include/have_innodb.inc + +SET storage_engine=InnoDB; + +# we care only that the following SQL commands do not crash the server +-- disable_query_log +-- disable_result_log + +DROP TABLE IF EXISTS bug39438; + +CREATE TABLE bug39438 (id INT) ENGINE=INNODB; + +ALTER TABLE bug39438 DISCARD TABLESPACE; + +# this crashes the server if the bug is present +SHOW TABLE STATUS; + +DROP TABLE bug39438; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 600473c2cd2..6e4c3b736af 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -5865,9 +5865,24 @@ ha_innobase::info( so the "old" value can remain. delete_length is initialized to 0 in the ha_statistics' constructor. */ if (!(flag & HA_STATUS_NO_LOCK)) { - stats.delete_length = - fsp_get_available_space_in_free_extents( - ib_table->space) * 1024; + + /* lock the data dictionary to avoid races with + ibd_file_missing and tablespace_discarded */ + row_mysql_lock_data_dictionary(prebuilt->trx); + + /* ib_table->space must be an existent tablespace */ + if (!ib_table->ibd_file_missing + && !ib_table->tablespace_discarded) { + + stats.delete_length = + fsp_get_available_space_in_free_extents( + ib_table->space) * 1024; + } else { + + stats.delete_length = 0; + } + + row_mysql_unlock_data_dictionary(prebuilt->trx); } stats.check_time = 0; From 3b4e69ead53fd3cec64974bb59bba1d614bd7675 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 13:34:48 -0700 Subject: [PATCH 072/137] Apply InnoDB snapshot innodb-5.1-ss2858, part 5. A follow-up to the previous patch, fix for Bug #39438. r2720 | vasil | 2008-10-03 19:52:39 +0300 (Fri, 03 Oct 2008) | 8 lines branches/5.1: Print a warning if an attempt is made to get the free space for a table whose .ibd file is missing or the tablespace has been discarded. This is a followup to r2719. Suggested by: Inaam --- storage/innobase/handler/ha_innodb.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 6e4c3b736af..3a571c7fb92 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -5879,6 +5879,12 @@ ha_innobase::info( ib_table->space) * 1024; } else { + sql_print_warning( + "Trying to get the free space for " + "table %s but its tablespace has " + "been discarded or the .ibd file " + "is missing. Setting the free space " + "to zero.", ib_table->name); stats.delete_length = 0; } From 968608efb7ed797879327d68afe4dc8ad06a1e4f Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 13:38:14 -0700 Subject: [PATCH 073/137] Apply InnoDB snapshot innodb-5.1-ss2858, part 6. Send error message to the client when a rollback occurs when trying to get an autoincrement value. This is related to the fixes for Bug#36411 and Bug#35498. Detailed revision comments: r2721 | sunny | 2008-10-04 02:08:23 +0300 (Sat, 04 Oct 2008) | 6 lines branches/5.1: We need to send the messages to the client because handler::get_auto_increment() doesn't allow a way to return the specific error for why it failed. rb://18 --- storage/innobase/handler/ha_innodb.cc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 3a571c7fb92..379269ee07f 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -7477,16 +7477,24 @@ ha_innobase::innobase_get_auto_increment( } else { *value = autoinc; } - /* We need to print this message here because the + /* We need to send the messages to the client because handler::get_auto_increment() doesn't allow a way to return the specific error for why it failed. */ } else if (error == DB_DEADLOCK) { - sql_print_warning( - "Deadlock in " + THD* thd = ha_thd(); + + push_warning( + thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_LOCK_DEADLOCK, + "InnoDB: Deadlock in " "innobase_get_auto_increment()"); } else if (error == DB_LOCK_WAIT_TIMEOUT) { - sql_print_warning( - "Lock wait timeout in " + THD* thd = ha_thd(); + + push_warning( + thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_LOCK_WAIT_TIMEOUT, + "InnoDB: Lock wait timeout in " "innobase_get_auto_increment()"); } else { @@ -7495,7 +7503,6 @@ ha_innobase::innobase_get_auto_increment( "innobase_get_auto_increment()", error); } - } while (*value == 0 && error == DB_SUCCESS); return(error); From 220ee82cb7248dd9381805f0de3c737f97f3e577 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 13:42:37 -0700 Subject: [PATCH 074/137] Apply InnoDB snapshot innodb-5.1-2858, part 7. A follow-up fix for Bug 38839, which exposed a pre-existing bug in the autoinc handling. Detailed revision comments: r2722 | sunny | 2008-10-04 02:48:04 +0300 (Sat, 04 Oct 2008) | 18 lines branches/5.1: This bug has always existed but was masked by other errors. The fix for bug# 38839 triggered this bug. When the offset and increment are > 1 we need to calculate the next value taking into consideration the two variables. Previously we simply assumed they were 1 particularly offset was never used. MySQL does its own calculation and that's probably why it seemed to work in the past. We would return what we thought was the correct next value and then MySQL would recalculate the actual value from that and return it to the caller (e.g., handler::write_row()). Several new tests have been added that try and catch some edge cases. The tests exposed a wrap around error in MySQL next value calculation which was filed as bug 39828. The tests will need to be updated once MySQL fix that bug. One good side effect of this fix is that dict_table_t size has been reduced by 8 bytes because we have moved the autoinc_increment field to the row_prebuilt_t structure. See review-board for a detailed discussion. rb://3 --- mysql-test/r/innodb-autoinc.result | 385 ++++++++++++++++++++++++++ mysql-test/t/innodb-autoinc.test | 213 +++++++++++++- storage/innobase/dict/dict0mem.c | 4 - storage/innobase/handler/ha_innodb.cc | 126 +++++++-- storage/innobase/include/dict0mem.h | 6 +- storage/innobase/include/row0mysql.h | 11 +- storage/innobase/row/row0mysql.c | 8 +- 7 files changed, 713 insertions(+), 40 deletions(-) diff --git a/mysql-test/r/innodb-autoinc.result b/mysql-test/r/innodb-autoinc.result index 70cdc67f77e..589bf2f30b0 100644 --- a/mysql-test/r/innodb-autoinc.result +++ b/mysql-test/r/innodb-autoinc.result @@ -196,3 +196,388 @@ c1 c2 3 8 5 9 DROP TABLE t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10; +SHOW VARIABLES LIKE "%auto_inc%"; +Variable_name Value +auto_increment_increment 100 +auto_increment_offset 10 +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL),(5),(NULL); +INSERT INTO t1 VALUES (250),(NULL); +SELECT * FROM t1; +c1 +5 +10 +110 +250 +310 +INSERT INTO t1 VALUES (1000); +SET @@INSERT_ID=400; +INSERT INTO t1 VALUES(NULL),(NULL); +SELECT * FROM t1; +c1 +5 +10 +110 +250 +310 +400 +410 +1000 +DROP TABLE t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +Variable_name Value +auto_increment_increment 1 +auto_increment_offset 1 +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(0); +SELECT * FROM t1; +c1 +1 +SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10; +INSERT INTO t1 VALUES (-1), (NULL),(2),(NULL); +INSERT INTO t1 VALUES (250),(NULL); +SELECT * FROM t1; +c1 +-1 +1 +2 +10 +110 +250 +410 +SET @@INSERT_ID=400; +INSERT INTO t1 VALUES(NULL),(NULL); +Got one of the listed errors +SELECT * FROM t1; +c1 +-1 +1 +2 +10 +110 +250 +410 +DROP TABLE t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +Variable_name Value +auto_increment_increment 1 +auto_increment_offset 1 +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(-1); +SELECT * FROM t1; +c1 +-1 +SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10; +SHOW VARIABLES LIKE "%auto_inc%"; +Variable_name Value +auto_increment_increment 100 +auto_increment_offset 10 +INSERT INTO t1 VALUES (-2), (NULL),(2),(NULL); +INSERT INTO t1 VALUES (250),(NULL); +SELECT * FROM t1; +c1 +-2 +-1 +1 +2 +10 +250 +310 +INSERT INTO t1 VALUES (1000); +SET @@INSERT_ID=400; +INSERT INTO t1 VALUES(NULL),(NULL); +SELECT * FROM t1; +c1 +-2 +-1 +1 +2 +10 +250 +310 +400 +410 +1000 +DROP TABLE t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +Variable_name Value +auto_increment_increment 1 +auto_increment_offset 1 +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE t1 (c1 INT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(-1); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +SELECT * FROM t1; +c1 +1 +SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10; +SHOW VARIABLES LIKE "%auto_inc%"; +Variable_name Value +auto_increment_increment 100 +auto_increment_offset 10 +INSERT INTO t1 VALUES (-2); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (250); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1; +c1 +1 +2 +10 +110 +210 +250 +310 +INSERT INTO t1 VALUES (1000); +SET @@INSERT_ID=400; +INSERT INTO t1 VALUES(NULL); +INSERT INTO t1 VALUES(NULL); +SELECT * FROM t1; +c1 +1 +2 +10 +110 +210 +250 +310 +400 +1000 +1010 +DROP TABLE t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +Variable_name Value +auto_increment_increment 1 +auto_increment_offset 1 +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE t1 (c1 INT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(-1); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +SELECT * FROM t1; +c1 +1 +SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10; +SHOW VARIABLES LIKE "%auto_inc%"; +Variable_name Value +auto_increment_increment 100 +auto_increment_offset 10 +INSERT INTO t1 VALUES (-2),(NULL),(2),(NULL); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +INSERT INTO t1 VALUES (250),(NULL); +SELECT * FROM t1; +c1 +1 +2 +10 +110 +210 +250 +410 +INSERT INTO t1 VALUES (1000); +SET @@INSERT_ID=400; +INSERT INTO t1 VALUES(NULL),(NULL); +Got one of the listed errors +SELECT * FROM t1; +c1 +1 +2 +10 +110 +210 +250 +410 +1000 +DROP TABLE t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +Variable_name Value +auto_increment_increment 1 +auto_increment_offset 1 +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE t1 (c1 BIGINT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(NULL); +INSERT INTO t1 VALUES (9223372036854775794); +SELECT * FROM t1; +c1 +1 +9223372036854775794 +SET @@SESSION.AUTO_INCREMENT_INCREMENT=2, @@SESSION.AUTO_INCREMENT_OFFSET=10; +SHOW VARIABLES LIKE "%auto_inc%"; +Variable_name Value +auto_increment_increment 2 +auto_increment_offset 10 +INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL); +SELECT * FROM t1; +c1 +1 +9223372036854775794 +9223372036854775796 +9223372036854775798 +9223372036854775800 +9223372036854775802 +9223372036854775804 +9223372036854775806 +DROP TABLE t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +Variable_name Value +auto_increment_increment 1 +auto_increment_offset 1 +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(NULL); +INSERT INTO t1 VALUES (18446744073709551603); +SELECT * FROM t1; +c1 +1 +18446744073709551603 +SET @@SESSION.AUTO_INCREMENT_INCREMENT=2, @@SESSION.AUTO_INCREMENT_OFFSET=10; +SHOW VARIABLES LIKE "%auto_inc%"; +Variable_name Value +auto_increment_increment 2 +auto_increment_offset 10 +INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL); +SELECT * FROM t1; +c1 +0 +1 +18446744073709551603 +18446744073709551604 +18446744073709551606 +18446744073709551608 +18446744073709551610 +18446744073709551612 +18446744073709551614 +DROP TABLE t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +Variable_name Value +auto_increment_increment 1 +auto_increment_offset 1 +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(NULL); +INSERT INTO t1 VALUES (18446744073709551603); +SELECT * FROM t1; +c1 +1 +18446744073709551603 +SET @@SESSION.AUTO_INCREMENT_INCREMENT=5, @@SESSION.AUTO_INCREMENT_OFFSET=7; +SHOW VARIABLES LIKE "%auto_inc%"; +Variable_name Value +auto_increment_increment 5 +auto_increment_offset 7 +INSERT INTO t1 VALUES (NULL),(NULL), (NULL); +Got one of the listed errors +SELECT * FROM t1; +c1 +1 +18446744073709551603 +DROP TABLE t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +Variable_name Value +auto_increment_increment 1 +auto_increment_offset 1 +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE t1 (c1 BIGINT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(NULL); +INSERT INTO t1 VALUES(-9223372036854775806); +INSERT INTO t1 VALUES(-9223372036854775807); +INSERT INTO t1 VALUES(-9223372036854775808); +SELECT * FROM t1; +c1 +-9223372036854775808 +-9223372036854775807 +-9223372036854775806 +1 +SET @@SESSION.AUTO_INCREMENT_INCREMENT=3, @@SESSION.AUTO_INCREMENT_OFFSET=3; +SHOW VARIABLES LIKE "%auto_inc%"; +Variable_name Value +auto_increment_increment 3 +auto_increment_offset 3 +INSERT INTO t1 VALUES (NULL),(NULL), (NULL); +SELECT * FROM t1; +c1 +-9223372036854775808 +-9223372036854775807 +-9223372036854775806 +1 +3 +6 +9 +DROP TABLE t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +Variable_name Value +auto_increment_increment 1 +auto_increment_offset 1 +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(NULL); +INSERT INTO t1 VALUES (18446744073709551610); +SELECT * FROM t1; +c1 +1 +18446744073709551610 +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1152921504606846976, @@SESSION.AUTO_INCREMENT_OFFSET=1152921504606846976; +Warnings: +Warning 1292 Truncated incorrect auto_increment_increment value: '1152921504606846976' +Warning 1292 Truncated incorrect auto_increment_offset value: '1152921504606846976' +SHOW VARIABLES LIKE "%auto_inc%"; +Variable_name Value +auto_increment_increment 65535 +auto_increment_offset 65535 +INSERT INTO t1 VALUES (NULL),(NULL), (NULL); +SELECT * FROM t1; +c1 +1 +65534 +65535 +18446744073709551610 +18446744073709551615 +DROP TABLE t1; diff --git a/mysql-test/t/innodb-autoinc.test b/mysql-test/t/innodb-autoinc.test index 1c97364199b..172913349db 100644 --- a/mysql-test/t/innodb-autoinc.test +++ b/mysql-test/t/innodb-autoinc.test @@ -156,7 +156,218 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t1 (c1 INT AUTO_INCREMENT, c2 INT, PRIMARY KEY(c1)) ENGINE=InnoDB; INSERT INTO t1 VALUES (NULL, 1); DELETE FROM t1 WHERE c1 = 1; -INSERT INTO t1 VALUES (2,1), (NULL, 8); +INSERT INTO t1 VALUES (2,1), (NULL, 8); INSERT INTO t1 VALUES (NULL,9); SELECT * FROM t1; DROP TABLE t1; + +# +# Test changes to AUTOINC next value calculation +SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10; +SHOW VARIABLES LIKE "%auto_inc%"; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL),(5),(NULL); +INSERT INTO t1 VALUES (250),(NULL); +SELECT * FROM t1; +INSERT INTO t1 VALUES (1000); +SET @@INSERT_ID=400; +INSERT INTO t1 VALUES(NULL),(NULL); +SELECT * FROM t1; +DROP TABLE t1; + +# Test with SIGNED INT column, by inserting a 0 for the first column value +# 0 is treated in the same was NULL. +# Reset the AUTOINC session variables +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(0); +SELECT * FROM t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10; +INSERT INTO t1 VALUES (-1), (NULL),(2),(NULL); +INSERT INTO t1 VALUES (250),(NULL); +SELECT * FROM t1; +SET @@INSERT_ID=400; +# Duplicate error expected here for autoinc_lock_mode != TRADITIONAL +-- error ER_DUP_ENTRY,1062 +INSERT INTO t1 VALUES(NULL),(NULL); +SELECT * FROM t1; +DROP TABLE t1; + +# Test with SIGNED INT column +# Reset the AUTOINC session variables +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(-1); +SELECT * FROM t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10; +SHOW VARIABLES LIKE "%auto_inc%"; +INSERT INTO t1 VALUES (-2), (NULL),(2),(NULL); +INSERT INTO t1 VALUES (250),(NULL); +SELECT * FROM t1; +INSERT INTO t1 VALUES (1000); +SET @@INSERT_ID=400; +INSERT INTO t1 VALUES(NULL),(NULL); +SELECT * FROM t1; +DROP TABLE t1; + +# Test with UNSIGNED INT column, single insert +# The sign in the value is ignored and a new column value is generated +# Reset the AUTOINC session variables +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 INT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(-1); +SELECT * FROM t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10; +SHOW VARIABLES LIKE "%auto_inc%"; +INSERT INTO t1 VALUES (-2); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (250); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1; +INSERT INTO t1 VALUES (1000); +SET @@INSERT_ID=400; +INSERT INTO t1 VALUES(NULL); +INSERT INTO t1 VALUES(NULL); +SELECT * FROM t1; +DROP TABLE t1; + +# Test with UNSIGNED INT column, multi-value inserts +# The sign in the value is ignored and a new column value is generated +# Reset the AUTOINC session variables +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 INT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(-1); +SELECT * FROM t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10; +SHOW VARIABLES LIKE "%auto_inc%"; +INSERT INTO t1 VALUES (-2),(NULL),(2),(NULL); +INSERT INTO t1 VALUES (250),(NULL); +SELECT * FROM t1; +INSERT INTO t1 VALUES (1000); +SET @@INSERT_ID=400; +# Duplicate error expected here for autoinc_lock_mode != TRADITIONAL +-- error ER_DUP_ENTRY,1062 +INSERT INTO t1 VALUES(NULL),(NULL); +SELECT * FROM t1; +DROP TABLE t1; + +# +# Check for overflow handling when increment is > 1 +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 BIGINT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +# TODO: Fix the autoinc init code +# We have to do this because of a bug in the AUTOINC init code. +INSERT INTO t1 VALUES(NULL); +INSERT INTO t1 VALUES (9223372036854775794); -- 2^63 - 14 +SELECT * FROM t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=2, @@SESSION.AUTO_INCREMENT_OFFSET=10; +SHOW VARIABLES LIKE "%auto_inc%"; +# This should just fit +INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL); +SELECT * FROM t1; +DROP TABLE t1; + +# +# Check for overflow handling when increment and offser are > 1 +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +# TODO: Fix the autoinc init code +# We have to do this because of a bug in the AUTOINC init code. +INSERT INTO t1 VALUES(NULL); +INSERT INTO t1 VALUES (18446744073709551603); -- 2^64 - 13 +SELECT * FROM t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=2, @@SESSION.AUTO_INCREMENT_OFFSET=10; +SHOW VARIABLES LIKE "%auto_inc%"; +# This should fail because of overflow but it doesn't, it seems to be +# a MySQL server bug. It wraps around to 0 for the last value. +# See MySQL Bug# 39828 +INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL); +SELECT * FROM t1; +DROP TABLE t1; + +# +# Check for overflow handling when increment and offset are odd numbers +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +# TODO: Fix the autoinc init code +# We have to do this because of a bug in the AUTOINC init code. +INSERT INTO t1 VALUES(NULL); +INSERT INTO t1 VALUES (18446744073709551603); -- 2^64 - 13 +SELECT * FROM t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=5, @@SESSION.AUTO_INCREMENT_OFFSET=7; +SHOW VARIABLES LIKE "%auto_inc%"; +# This should fail because of overflow but it doesn't. It fails with +# a duplicate entry message because of a MySQL server bug, it wraps +# around. See MySQL Bug# 39828, once MySQL fix the bug we can replace +# the ER_DUP_ENTRY, 1062 below with the appropriate error message +-- error ER_DUP_ENTRY,1062 +INSERT INTO t1 VALUES (NULL),(NULL), (NULL); +SELECT * FROM t1; +DROP TABLE t1; + +# Check for overflow handling when increment and offset are odd numbers +# and check for large -ve numbers +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 BIGINT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +# TODO: Fix the autoinc init code +# We have to do this because of a bug in the AUTOINC init code. +INSERT INTO t1 VALUES(NULL); +INSERT INTO t1 VALUES(-9223372036854775806); -- -2^63 + 2 +INSERT INTO t1 VALUES(-9223372036854775807); -- -2^63 + 1 +INSERT INTO t1 VALUES(-9223372036854775808); -- -2^63 +SELECT * FROM t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=3, @@SESSION.AUTO_INCREMENT_OFFSET=3; +SHOW VARIABLES LIKE "%auto_inc%"; +INSERT INTO t1 VALUES (NULL),(NULL), (NULL); +SELECT * FROM t1; +DROP TABLE t1; +# +# Check for overflow handling when increment and offset are very +# large numbers 2^60 +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +# TODO: Fix the autoinc init code +# We have to do this because of a bug in the AUTOINC init code. +INSERT INTO t1 VALUES(NULL); +INSERT INTO t1 VALUES (18446744073709551610); -- 2^64 - 2 +SELECT * FROM t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1152921504606846976, @@SESSION.AUTO_INCREMENT_OFFSET=1152921504606846976; +SHOW VARIABLES LIKE "%auto_inc%"; +# This should fail because of overflow but it doesn't. It wraps around +# and the autoinc values look bogus too. +# See MySQL Bug# 39828, once MySQL fix the bug we can enable the error +# code expected test. +# -- error ER_AUTOINC_READ_FAILED,1467 +INSERT INTO t1 VALUES (NULL),(NULL), (NULL); +SELECT * FROM t1; +DROP TABLE t1; diff --git a/storage/innobase/dict/dict0mem.c b/storage/innobase/dict/dict0mem.c index 47cf7a0bc9c..f9935b8db19 100644 --- a/storage/innobase/dict/dict0mem.c +++ b/storage/innobase/dict/dict0mem.c @@ -91,10 +91,6 @@ dict_mem_table_create( table->autoinc_inited = FALSE; - /* The actual increment value will be set by MySQL, we simply - default to 1 here.*/ - table->autoinc_increment = 1; - /* The number of transactions that are either waiting on the AUTOINC lock or have been granted the lock. */ table->n_waiting_or_granted_auto_inc_locks = 0; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 379269ee07f..f79af1e274c 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -921,6 +921,74 @@ innobase_convert_string( errors)); } +/************************************************************************* +Compute the next autoinc value. + +For MySQL replication the autoincrement values can be partitioned among +the nodes. The offset is the start or origin of the autoincrement value +for a particular node. For n nodes the increment will be n and the offset +will be in the interval [1, n]. The formula tries to allocate the next +value for a particular node. + +Note: This function is also called with increment set to the number of +values we want to reserve for multi-value inserts e.g., + + INSERT INTO T VALUES(), (), (); + +innobase_next_autoinc() will be called with increment set to +n * 3 where autoinc_lock_mode != TRADITIONAL because we want +to reserve 3 values for the multi-value INSERT above. */ +static +ulonglong +innobase_next_autoinc( +/*==================*/ + /* out: the next value */ + ulonglong current, /* in: Current value */ + ulonglong increment, /* in: increment current by */ + ulonglong offset) /* in: AUTOINC offset */ +{ + ulonglong next_value; + + /* Should never be 0. */ + ut_a(increment > 0); + + if (offset <= 1) { + /* Offset 0 and 1 are the same, because there must be at + least one node in the system. */ + if (~0x0ULL - current <= increment) { + next_value = ~0x0ULL; + } else { + next_value = current + increment; + } + } else { + if (current > offset) { + next_value = ((current - offset) / increment) + 1; + } else { + next_value = ((offset - current) / increment) + 1; + } + + ut_a(increment > 0); + ut_a(next_value > 0); + + /* Check for multiplication overflow. */ + if (increment > (~0x0ULL / next_value)) { + + next_value = ~0x0ULL; + } else { + next_value *= increment; + + /* Check for overflow. */ + if (~0x0ULL - next_value <= offset) { + next_value = ~0x0ULL; + } else { + next_value += offset; + } + } + } + + return(next_value); +} + /************************************************************************* Gets the InnoDB transaction handle for a MySQL handler object, creates an InnoDB transaction struct if the corresponding MySQL thread struct still @@ -3565,22 +3633,18 @@ no_commit: update the table upper limit. Note: last_value will be 0 if get_auto_increment() was not called.*/ - if (auto_inc > prebuilt->last_value) { + if (auto_inc > prebuilt->autoinc_last_value) { set_max_autoinc: - ut_a(prebuilt->table->autoinc_increment > 0); + ut_a(prebuilt->autoinc_increment > 0); - ulonglong have; ulonglong need; + ulonglong offset; - /* Check for overflow conditions. */ - need = prebuilt->table->autoinc_increment; - have = ~0x0ULL - auto_inc; + offset = prebuilt->autoinc_offset; + need = prebuilt->autoinc_increment; - if (have < need) { - need = have; - } - - auto_inc += need; + auto_inc = innobase_next_autoinc( + auto_inc, need, offset); err = innobase_set_max_autoinc(auto_inc); @@ -3822,7 +3886,15 @@ ha_innobase::update_row( auto_inc = table->next_number_field->val_int(); if (auto_inc != 0) { - auto_inc += prebuilt->table->autoinc_increment; + + ulonglong need; + ulonglong offset; + + offset = prebuilt->autoinc_offset; + need = prebuilt->autoinc_increment; + + auto_inc = innobase_next_autoinc( + auto_inc, need, offset); error = innobase_set_max_autoinc(auto_inc); } @@ -5844,7 +5916,7 @@ ha_innobase::info( not be updated. This will force write_row() into attempting an update of the table's AUTOINC counter. */ - prebuilt->last_value = 0; + prebuilt->autoinc_last_value = 0; } stats.records = (ha_rows)n_rows; @@ -6474,7 +6546,7 @@ int ha_innobase::reset() it's safer to do it explicitly here. */ /* This is a statement level counter. */ - prebuilt->last_value = 0; + prebuilt->autoinc_last_value = 0; return(0); } @@ -7568,7 +7640,7 @@ ha_innobase::get_auto_increment( set_if_bigger(*first_value, autoinc); /* Not in the middle of a mult-row INSERT. */ - } else if (prebuilt->last_value == 0) { + } else if (prebuilt->autoinc_last_value == 0) { set_if_bigger(*first_value, autoinc); } @@ -7577,35 +7649,33 @@ ha_innobase::get_auto_increment( /* With old style AUTOINC locking we only update the table's AUTOINC counter after attempting to insert the row. */ if (innobase_autoinc_lock_mode != AUTOINC_OLD_STYLE_LOCKING) { - ulonglong have; ulonglong need; + ulonglong next_value; - /* Check for overflow conditions. */ need = *nb_reserved_values * increment; - have = ~0x0ULL - *first_value; - - if (have < need) { - need = have; - } /* Compute the last value in the interval */ - prebuilt->last_value = *first_value + need; + next_value = innobase_next_autoinc(*first_value, need, offset); - ut_a(prebuilt->last_value >= *first_value); + prebuilt->autoinc_last_value = next_value; + + ut_a(prebuilt->autoinc_last_value >= *first_value); /* Update the table autoinc variable */ dict_table_autoinc_update( - prebuilt->table, prebuilt->last_value); + prebuilt->table, prebuilt->autoinc_last_value); } else { /* This will force write_row() into attempting an update of the table's AUTOINC counter. */ - prebuilt->last_value = 0; + prebuilt->autoinc_last_value = 0; } /* The increment to be used to increase the AUTOINC value, we use this in write_row() and update_row() to increase the autoinc counter - for columns that are filled by the user.*/ - prebuilt->table->autoinc_increment = increment; + for columns that are filled by the user. We need the offset and + the increment. */ + prebuilt->autoinc_offset = offset; + prebuilt->autoinc_increment = increment; dict_table_autoinc_unlock(prebuilt->table); } diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index 2fe72498989..6e5435493cb 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -411,11 +411,6 @@ struct dict_table_struct{ SELECT MAX(auto inc column) */ ib_ulonglong autoinc;/* autoinc counter value to give to the next inserted row */ - - ib_longlong autoinc_increment; - /* The increment step of the auto increment - column. Value must be greater than or equal - to 1 */ ulong n_waiting_or_granted_auto_inc_locks; /* This counter is used to track the number of granted and pending autoinc locks on this @@ -425,6 +420,7 @@ struct dict_table_struct{ acquired the AUTOINC lock or not. Of course only one transaction can be granted the lock but there can be multiple waiters. */ + /*----------------------*/ #ifdef UNIV_DEBUG ulint magic_n;/* magic number */ diff --git a/storage/innobase/include/row0mysql.h b/storage/innobase/include/row0mysql.h index ca9d9c6b8f8..dd6b1d00676 100644 --- a/storage/innobase/include/row0mysql.h +++ b/storage/innobase/include/row0mysql.h @@ -683,7 +683,16 @@ struct row_prebuilt_struct { to this heap */ mem_heap_t* old_vers_heap; /* memory heap where a previous version is built in consistent read */ - ulonglong last_value; /* last value of AUTO-INC interval */ + /*----------------------*/ + ulonglong autoinc_last_value;/* last value of AUTO-INC interval */ + ulonglong autoinc_increment;/* The increment step of the auto + increment column. Value must be + greater than or equal to 1. Required to + calculate the next value */ + ulonglong autoinc_offset; /* The offset passed to + get_auto_increment() by MySQL. Required + to calculate the next value */ + /*----------------------*/ ulint magic_n2; /* this should be the same as magic_n */ }; diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c index 74bf2267a3e..a3e2549f517 100644 --- a/storage/innobase/row/row0mysql.c +++ b/storage/innobase/row/row0mysql.c @@ -661,7 +661,13 @@ row_create_prebuilt( prebuilt->old_vers_heap = NULL; - prebuilt->last_value = 0; + prebuilt->autoinc_offset = 0; + + /* Default to 1, we will set the actual value later in + ha_innobase::get_auto_increment(). */ + prebuilt->autoinc_increment = 1; + + prebuilt->autoinc_last_value = 0; return(prebuilt); } From cc231f988c6cb7a4d733fc6f5a90becf5d8928b0 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 13:47:17 -0700 Subject: [PATCH 075/137] Apply InnoDB snapshot innodb-5.1-2858, part 8. Fixes Bug #39939: DROP TABLE/DISCARD TABLESPACE takes long time in buf_LRU_invalidate_tablespace() Detailed revision comments: r2742 | inaam | 2008-10-08 22:02:15 +0300 (Wed, 08 Oct 2008) | 11 lines branches/5.1: Improve implementation of buf_LRU_invalidate_tablespace by attempting hash index drop in batches instead of doing it one by one. Reviewed by: Heikki, Sunny, Marko Approved by: Heikki --- storage/innobase/buf/buf0lru.c | 127 +++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) diff --git a/storage/innobase/buf/buf0lru.c b/storage/innobase/buf/buf0lru.c index f3913ed49b7..d3c787d1578 100644 --- a/storage/innobase/buf/buf0lru.c +++ b/storage/innobase/buf/buf0lru.c @@ -42,6 +42,11 @@ initial segment in buf_LRU_get_recent_limit */ #define BUF_LRU_INITIAL_RATIO 8 +/* When dropping the search hash index entries before deleting an ibd +file, we build a local array of pages belonging to that tablespace +in the buffer pool. Following is the size of that array. */ +#define BUF_LRU_DROP_SEARCH_HASH_SIZE 1024 + /* If we switch on the InnoDB monitor because there are too few available frames in the buffer pool, we set this to TRUE */ ibool buf_lru_switched_on_innodb_mon = FALSE; @@ -65,6 +70,120 @@ buf_LRU_block_free_hashed_page( buf_block_t* block); /* in: block, must contain a file page and be in a state where it can be freed */ +/********************************************************************** +Attempts to drop page hash index on a batch of pages belonging to a +particular space id. */ +static +void +buf_LRU_drop_page_hash_batch( +/*=========================*/ + ulint id, /* in: space id */ + const ulint* arr, /* in: array of page_no */ + ulint count) /* in: number of entries in array */ +{ + ulint i; + + ut_ad(arr != NULL); + ut_ad(count <= BUF_LRU_DROP_SEARCH_HASH_SIZE); + + for (i = 0; i < count; ++i) { + btr_search_drop_page_hash_when_freed(id, arr[i]); + } +} + +/********************************************************************** +When doing a DROP TABLE/DISCARD TABLESPACE we have to drop all page +hash index entries belonging to that table. This function tries to +do that in batch. Note that this is a 'best effort' attempt and does +not guarantee that ALL hash entries will be removed. */ +static +void +buf_LRU_drop_page_hash_for_tablespace( +/*==================================*/ + ulint id) /* in: space id */ +{ + buf_block_t* block; + ulint* page_arr; + ulint num_entries; + + page_arr = ut_malloc(sizeof(ulint) + * BUF_LRU_DROP_SEARCH_HASH_SIZE); + mutex_enter(&buf_pool->mutex); + +scan_again: + num_entries = 0; + block = UT_LIST_GET_LAST(buf_pool->LRU); + + while (block != NULL) { + buf_block_t* prev_block; + + mutex_enter(&block->mutex); + prev_block = UT_LIST_GET_PREV(LRU, block); + + ut_a(block->state == BUF_BLOCK_FILE_PAGE); + + if (block->space != id + || block->buf_fix_count > 0 + || block->io_fix != 0) { + /* We leave the fixed pages as is in this scan. + To be dealt with later in the final scan. */ + mutex_exit(&block->mutex); + goto next_page; + } + + ut_ad(block->space == id); + if (block->is_hashed) { + + /* Store the offset(i.e.: page_no) in the array + so that we can drop hash index in a batch + later. */ + page_arr[num_entries] = block->offset; + mutex_exit(&block->mutex); + ut_a(num_entries < BUF_LRU_DROP_SEARCH_HASH_SIZE); + ++num_entries; + + if (num_entries < BUF_LRU_DROP_SEARCH_HASH_SIZE) { + goto next_page; + } + /* Array full. We release the buf_pool->mutex to + obey the latching order. */ + mutex_exit(&buf_pool->mutex); + + buf_LRU_drop_page_hash_batch(id, page_arr, + num_entries); + num_entries = 0; + mutex_enter(&buf_pool->mutex); + } else { + mutex_exit(&block->mutex); + } + +next_page: + /* Note that we may have released the buf_pool->mutex + above after reading the prev_block during processing + of a page_hash_batch (i.e.: when the array was full). + This means that prev_block can change in LRU list. + This is OK because this function is a 'best effort' + to drop as many search hash entries as possible and + it does not guarantee that ALL such entries will be + dropped. */ + block = prev_block; + + /* If, however, block has been removed from LRU list + to the free list then we should restart the scan. + block->state is protected by buf_pool->mutex. */ + if (block && block->state != BUF_BLOCK_FILE_PAGE) { + ut_a(num_entries == 0); + goto scan_again; + } + } + + mutex_exit(&buf_pool->mutex); + + /* Drop any remaining batch of search hashed pages. */ + buf_LRU_drop_page_hash_batch(id, page_arr, num_entries); + ut_free(page_arr); +} + /********************************************************************** Invalidates all pages belonging to a given tablespace when we are deleting the data file(s) of that tablespace. */ @@ -78,6 +197,14 @@ buf_LRU_invalidate_tablespace( ulint page_no; ibool all_freed; + /* Before we attempt to drop pages one by one we first + attempt to drop page hash index entries in batches to make + it more efficient. The batching attempt is a best effort + attempt and does not guarantee that all pages hash entries + will be dropped. We get rid of remaining page hash entries + one by one below. */ + buf_LRU_drop_page_hash_for_tablespace(id); + scan_again: mutex_enter(&(buf_pool->mutex)); From 80ba0bf66f2d2c5cab4e583d890c3533b8f31d73 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 13:48:44 -0700 Subject: [PATCH 076/137] Apply InnoDB snapshot innodb-5.1-ss2858, part 9. Improve a comment. Detailed revision comments: r2744 | marko | 2008-10-09 10:53:09 +0300 (Thu, 09 Oct 2008) | 5 lines branches/5.1: ha_innobase::delete_all_rows(): In response to a user asking why DELETE FROM t is not mapped to TRUNCATE TABLE t as it is in MyISAM, note in a comment that DELETE is transactional while TRUNCATE is not. --- storage/innobase/handler/ha_innodb.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index f79af1e274c..7a3f245de3e 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -5335,7 +5335,8 @@ ha_innobase::delete_all_rows(void) if (thd_sql_command(user_thd) != SQLCOM_TRUNCATE) { fallback: /* We only handle TRUNCATE TABLE t as a special case. - DELETE FROM t will have to use ha_innobase::delete_row(). */ + DELETE FROM t will have to use ha_innobase::delete_row(), + because DELETE is transactional while TRUNCATE is not. */ DBUG_RETURN(my_errno=HA_ERR_WRONG_COMMAND); } From a7513317937c7f163518f16b21e02009ab0d4d82 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 13:50:41 -0700 Subject: [PATCH 077/137] Apply InnoDB snapshot innodb-5.1-ss2858, part 10. Fix memory handling to avoid possible crash during error printout. (Code review, no associated bug.) Detailed revision comments: r2782 | marko | 2008-10-13 14:21:02 +0300 (Mon, 13 Oct 2008) | 5 lines branches/5.1: Backport a fix from branches/zip r2763: row_drop_database_for_mysql(): Postpone mem_free(table_name), so that an error printout will not dereference freed memory. --- storage/innobase/row/row0mysql.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c index a3e2549f517..c3183d05e3f 100644 --- a/storage/innobase/row/row0mysql.c +++ b/storage/innobase/row/row0mysql.c @@ -3441,8 +3441,6 @@ loop: err = row_drop_table_for_mysql(table_name, trx, TRUE); - mem_free(table_name); - if (err != DB_SUCCESS) { fputs("InnoDB: DROP DATABASE ", stderr); ut_print_name(stderr, trx, TRUE, name); @@ -3450,8 +3448,11 @@ loop: (ulint) err); ut_print_name(stderr, trx, TRUE, table_name); putc('\n', stderr); + mem_free(table_name); break; } + + mem_free(table_name); } if (err == DB_SUCCESS) { From 0dece1b2f0b28cf2f58129da7055e15d4488a28f Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 13:52:05 -0700 Subject: [PATCH 078/137] Apply InnoDB snapshot innodb-5.1-ss2858, part 11. White space changes. Detailed revision comments: r2826 | vasil | 2008-10-20 14:09:01 +0300 (Mon, 20 Oct 2008) | 5 lines branches/5.1: Non-functional change: use a single tab instead of 12 spaces between variable type and variable name. --- storage/innobase/handler/ha_innodb.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 7a3f245de3e..b573e5ba79b 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -7554,7 +7554,7 @@ ha_innobase::innobase_get_auto_increment( handler::get_auto_increment() doesn't allow a way to return the specific error for why it failed. */ } else if (error == DB_DEADLOCK) { - THD* thd = ha_thd(); + THD* thd = ha_thd(); push_warning( thd, MYSQL_ERROR::WARN_LEVEL_ERROR, @@ -7562,7 +7562,7 @@ ha_innobase::innobase_get_auto_increment( "InnoDB: Deadlock in " "innobase_get_auto_increment()"); } else if (error == DB_LOCK_WAIT_TIMEOUT) { - THD* thd = ha_thd(); + THD* thd = ha_thd(); push_warning( thd, MYSQL_ERROR::WARN_LEVEL_ERROR, From 3d3487658dbb90e9177823bf1abcf348dbf2378e Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 13:52:47 -0700 Subject: [PATCH 079/137] Apply InnoDB snapshot innodb-5.1-ss2858, part 12. A follow-up to fix for bug #39438. This moves some errro messages from the server error log to the client, to make it easier for users (especially in shared hosting environment) to get info about why their statement is failing. Detailed revision comments: r2832 | vasil | 2008-10-21 10:08:30 +0300 (Tue, 21 Oct 2008) | 10 lines branches/5.1: In ha_innobase::info(): Replace sql_print_warning() which prints to mysqld error log with push_warning_printf() which sends the error message to the client. Suggested by: Marko, Sunny, Michael Objected by: Inaam --- storage/innobase/handler/ha_innodb.cc | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index b573e5ba79b..c91ccf36863 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -5952,12 +5952,21 @@ ha_innobase::info( ib_table->space) * 1024; } else { - sql_print_warning( - "Trying to get the free space for " - "table %s but its tablespace has " - "been discarded or the .ibd file " - "is missing. Setting the free space " - "to zero.", ib_table->name); + THD* thd; + + thd = ha_thd(); + + push_warning_printf( + thd, + MYSQL_ERROR::WARN_LEVEL_WARN, + ER_CANT_GET_STAT, + "InnoDB: Trying to get the free " + "space for table %s but its " + "tablespace has been discarded or " + "the .ibd file is missing. Setting " + "the free space to zero.", + ib_table->name); + stats.delete_length = 0; } From 2fb7a53f4d8b5153b9033be800a4033a985f7985 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 13:56:33 -0700 Subject: [PATCH 080/137] Apply InnoDB snapshot innodb-5.1-ss2858, part 13. Fixes Bug #40224: New AUTOINC changes mask reporting of deadlock/timeout errors Detailed revision comments: r2849 | sunny | 2008-10-22 12:01:18 +0300 (Wed, 22 Oct 2008) | 8 lines branches/5.1: Return the actual error code encountered when allocating a new autoinc value. The change in behavior (bug) was introduced in 5.1.22 when we introduced the new AUTOINC locking model. rb://31 --- storage/innobase/handler/ha_innodb.cc | 93 +++++++++------------------ storage/innobase/include/row0mysql.h | 5 ++ storage/innobase/row/row0mysql.c | 1 + 3 files changed, 38 insertions(+), 61 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index c91ccf36863..195ec799ce9 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -3561,8 +3561,20 @@ no_commit: /* This is the case where the table has an auto-increment column */ if (table->next_number_field && record == table->record[0]) { + /* Reset the error code before calling + innobase_get_auto_increment(). */ + prebuilt->autoinc_error = DB_SUCCESS; + if ((error = update_auto_increment())) { + /* We don't want to mask autoinc overflow errors. */ + if (prebuilt->autoinc_error != DB_SUCCESS) { + error = prebuilt->autoinc_error; + + goto report_error; + } + + /* MySQL errors are passed straight back. */ goto func_exit; } @@ -3658,6 +3670,7 @@ set_max_autoinc: innodb_srv_conc_exit_innodb(prebuilt->trx); +report_error: error = convert_error_code_to_mysql(error, user_thd); func_exit: @@ -6056,25 +6069,12 @@ ha_innobase::info( if (flag & HA_STATUS_AUTO && table->found_next_number_field) { ulonglong auto_inc; - int ret; - /* The following function call can the first time fail in - a lock wait timeout error because it reserves the auto-inc - lock on the table. If it fails, then someone is already initing - the auto-inc counter, and the second call is guaranteed to - succeed. */ - - ret = innobase_read_and_init_auto_inc(&auto_inc); - - if (ret != 0) { - ret = innobase_read_and_init_auto_inc(&auto_inc); - - if (ret != 0) { - sql_print_error("Cannot get table %s auto-inc" - "counter value in ::info\n", - ib_table->name); - auto_inc = 0; - } + if (innobase_read_and_init_auto_inc(&auto_inc) != 0) { + sql_print_error("Cannot get table %s auto-inc" + "counter value in ::info\n", + ib_table->name); + auto_inc = 0; } stats.auto_increment_value = auto_inc; @@ -7459,7 +7459,6 @@ ha_innobase::innobase_read_and_init_auto_inc( if (auto_inc == 0) { dict_index_t* index; - ulint error; const char* autoinc_col_name; ut_a(!innodb_table->autoinc_inited); @@ -7468,10 +7467,10 @@ ha_innobase::innobase_read_and_init_auto_inc( autoinc_col_name = table->found_next_number_field->field_name; - error = row_search_max_autoinc( + prebuilt->autoinc_error = row_search_max_autoinc( index, autoinc_col_name, &auto_inc); - if (error == DB_SUCCESS) { + if (prebuilt->autoinc_error == DB_SUCCESS) { if (auto_inc < ~0x0ULL) { ++auto_inc; } @@ -7480,7 +7479,7 @@ ha_innobase::innobase_read_and_init_auto_inc( ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Error: (%lu) Couldn't read " "the max AUTOINC value from the index (%s).\n", - error, index->name); + prebuilt->autoinc_error, index->name); mysql_error = 1; } @@ -7511,22 +7510,23 @@ ha_innobase::innobase_read_and_init_auto_inc( Read the next autoinc value, initialize the table if it's not initialized. On return if there is no error then the tables AUTOINC lock is locked.*/ -ulong +ulint ha_innobase::innobase_get_auto_increment( /*=====================================*/ ulonglong* value) /* out: autoinc value */ { - ulong error; - *value = 0; /* Note: If the table is not initialized when we attempt the read below. We initialize the table's auto-inc counter and always do a reread of the AUTOINC value. */ do { - error = innobase_autoinc_lock(); + /* We need to send the correct error code to the client + because handler::get_auto_increment() doesn't allow a way + to return the specific error for why it failed. */ + prebuilt->autoinc_error = innobase_autoinc_lock(); - if (error == DB_SUCCESS) { + if (prebuilt->autoinc_error == DB_SUCCESS) { ulonglong autoinc; /* Determine the first value of the interval */ @@ -7548,46 +7548,17 @@ ha_innobase::innobase_get_auto_increment( /* Just to make sure */ ut_a(!trx->auto_inc_lock); - int mysql_error; + /* Will set prebuilt->autoinc_error if there + is a problem during init. */ + innobase_read_and_init_auto_inc(&autoinc); - mysql_error = innobase_read_and_init_auto_inc( - &autoinc); - - if (mysql_error) { - error = DB_ERROR; - } } else { *value = autoinc; } - /* We need to send the messages to the client because - handler::get_auto_increment() doesn't allow a way - to return the specific error for why it failed. */ - } else if (error == DB_DEADLOCK) { - THD* thd = ha_thd(); - - push_warning( - thd, MYSQL_ERROR::WARN_LEVEL_ERROR, - ER_LOCK_DEADLOCK, - "InnoDB: Deadlock in " - "innobase_get_auto_increment()"); - } else if (error == DB_LOCK_WAIT_TIMEOUT) { - THD* thd = ha_thd(); - - push_warning( - thd, MYSQL_ERROR::WARN_LEVEL_ERROR, - ER_LOCK_WAIT_TIMEOUT, - "InnoDB: Lock wait timeout in " - "innobase_get_auto_increment()"); - } else { - - sql_print_error( - "InnoDB: Error: %lu in " - "innobase_get_auto_increment()", - error); } - } while (*value == 0 && error == DB_SUCCESS); + } while (*value == 0 && prebuilt->autoinc_error == DB_SUCCESS); - return(error); + return(prebuilt->autoinc_error); } /******************************************************************************* diff --git a/storage/innobase/include/row0mysql.h b/storage/innobase/include/row0mysql.h index dd6b1d00676..9c3ba558d3c 100644 --- a/storage/innobase/include/row0mysql.h +++ b/storage/innobase/include/row0mysql.h @@ -692,6 +692,11 @@ struct row_prebuilt_struct { ulonglong autoinc_offset; /* The offset passed to get_auto_increment() by MySQL. Required to calculate the next value */ + ulint autoinc_error; /* The actual error code encountered + while trying to init or read the + autoinc value from the table. We + store it here so that we can return + it to MySQL */ /*----------------------*/ ulint magic_n2; /* this should be the same as magic_n */ diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c index c3183d05e3f..2d1cf22e4e7 100644 --- a/storage/innobase/row/row0mysql.c +++ b/storage/innobase/row/row0mysql.c @@ -661,6 +661,7 @@ row_create_prebuilt( prebuilt->old_vers_heap = NULL; + prebuilt->autoinc_error = 0; prebuilt->autoinc_offset = 0; /* Default to 1, we will set the actual value later in From 2ae86017c52e1dcce286a45c894b927be9c15881 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 13:57:54 -0700 Subject: [PATCH 081/137] Apply InnoDB snapshot innodb-5.1-ss2858, part 14. Fixes Bug #37788: InnoDB Plugin: AUTO_INCREMENT wrong for compressed tables (Note, this bug is not only in the plugin, the overflow checks are relevant for MySQL's InnoDB as well.) Detailed revision comments: r2852 | sunny | 2008-10-23 01:42:24 +0300 (Thu, 23 Oct 2008) | 9 lines branches/5.1: Backport r2724 from branches/zip Check column value against the col max value before updating the table's global autoinc counter value. This is part of simplifying the AUTOINC sub-system. We extract the type info from MySQL data structures at runtime. --- storage/innobase/handler/ha_innodb.cc | 100 ++++++++++++++++++++++---- storage/innobase/handler/ha_innodb.h | 1 + 2 files changed, 88 insertions(+), 13 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 195ec799ce9..ab4d4e96cef 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -945,7 +945,8 @@ innobase_next_autoinc( /* out: the next value */ ulonglong current, /* in: Current value */ ulonglong increment, /* in: increment current by */ - ulonglong offset) /* in: AUTOINC offset */ + ulonglong offset, /* in: AUTOINC offset */ + ulonglong max_value) /* in: max value for type */ { ulonglong next_value; @@ -955,8 +956,8 @@ innobase_next_autoinc( if (offset <= 1) { /* Offset 0 and 1 are the same, because there must be at least one node in the system. */ - if (~0x0ULL - current <= increment) { - next_value = ~0x0ULL; + if (max_value - current <= increment) { + next_value = max_value; } else { next_value = current + increment; } @@ -971,15 +972,15 @@ innobase_next_autoinc( ut_a(next_value > 0); /* Check for multiplication overflow. */ - if (increment > (~0x0ULL / next_value)) { + if (increment > (max_value / next_value)) { - next_value = ~0x0ULL; + next_value = max_value; } else { next_value *= increment; /* Check for overflow. */ - if (~0x0ULL - next_value <= offset) { - next_value = ~0x0ULL; + if (max_value - next_value <= offset) { + next_value = max_value; } else { next_value += offset; } @@ -3339,6 +3340,59 @@ skip_field: } } +/************************************************************************ +Get the upper limit of the MySQL integral type. */ + +ulonglong +ha_innobase::innobase_get_int_col_max_value( +/*========================================*/ + const Field* field) +{ + ulonglong max_value = 0; + + switch(field->key_type()) { + /* TINY */ + case HA_KEYTYPE_BINARY: + max_value = 0xFFULL; + break; + case HA_KEYTYPE_INT8: + max_value = 0x7FULL; + break; + /* SHORT */ + case HA_KEYTYPE_USHORT_INT: + max_value = 0xFFFFULL; + break; + case HA_KEYTYPE_SHORT_INT: + max_value = 0x7FFFULL; + break; + /* MEDIUM */ + case HA_KEYTYPE_UINT24: + max_value = 0xFFFFFFULL; + break; + case HA_KEYTYPE_INT24: + max_value = 0x7FFFFFULL; + break; + /* LONG */ + case HA_KEYTYPE_ULONG_INT: + max_value = 0xFFFFFFFFULL; + break; + case HA_KEYTYPE_LONG_INT: + max_value = 0x7FFFFFFFULL; + break; + /* BIG */ + case HA_KEYTYPE_ULONGLONG: + max_value = 0xFFFFFFFFFFFFFFFFULL; + break; + case HA_KEYTYPE_LONGLONG: + max_value = 0x7FFFFFFFFFFFFFFFULL; + break; + default: + ut_error; + } + + return(max_value); +} + /************************************************************************ This special handling is really to overcome the limitations of MySQL's binlogging. We need to eliminate the non-determinism that will arise in @@ -3598,6 +3652,7 @@ no_commit: if (auto_inc_used) { ulint err; ulonglong auto_inc; + ulonglong col_max_value; /* Note the number of rows processed for this statement, used by get_auto_increment() to determine the number of AUTO-INC @@ -3607,6 +3662,11 @@ no_commit: --trx->n_autoinc_rows; } + /* We need the upper limit of the col type to check for + whether we update the table autoinc counter or not. */ + col_max_value = innobase_get_int_col_max_value( + table->next_number_field); + /* Get the value that MySQL attempted to store in the table.*/ auto_inc = table->next_number_field->val_int(); @@ -3645,7 +3705,8 @@ no_commit: update the table upper limit. Note: last_value will be 0 if get_auto_increment() was not called.*/ - if (auto_inc > prebuilt->autoinc_last_value) { + if (auto_inc < col_max_value + && auto_inc > prebuilt->autoinc_last_value) { set_max_autoinc: ut_a(prebuilt->autoinc_increment > 0); @@ -3656,7 +3717,7 @@ set_max_autoinc: need = prebuilt->autoinc_increment; auto_inc = innobase_next_autoinc( - auto_inc, need, offset); + auto_inc, need, offset, col_max_value); err = innobase_set_max_autoinc(auto_inc); @@ -3894,11 +3955,17 @@ ha_innobase::update_row( && (trx->duplicates & (TRX_DUP_IGNORE | TRX_DUP_REPLACE)) == TRX_DUP_IGNORE) { - longlong auto_inc; + ulonglong auto_inc; + ulonglong col_max_value; auto_inc = table->next_number_field->val_int(); - if (auto_inc != 0) { + /* We need the upper limit of the col type to check for + whether we update the table autoinc counter or not. */ + col_max_value = innobase_get_int_col_max_value( + table->next_number_field); + + if (auto_inc < col_max_value && auto_inc != 0) { ulonglong need; ulonglong offset; @@ -3907,7 +3974,7 @@ ha_innobase::update_row( need = prebuilt->autoinc_increment; auto_inc = innobase_next_autoinc( - auto_inc, need, offset); + auto_inc, need, offset, col_max_value); error = innobase_set_max_autoinc(auto_inc); } @@ -7632,11 +7699,18 @@ ha_innobase::get_auto_increment( if (innobase_autoinc_lock_mode != AUTOINC_OLD_STYLE_LOCKING) { ulonglong need; ulonglong next_value; + ulonglong col_max_value; + + /* We need the upper limit of the col type to check for + whether we update the table autoinc counter or not. */ + col_max_value = innobase_get_int_col_max_value( + table->next_number_field); need = *nb_reserved_values * increment; /* Compute the last value in the interval */ - next_value = innobase_next_autoinc(*first_value, need, offset); + next_value = innobase_next_autoinc( + *first_value, need, offset, col_max_value); prebuilt->autoinc_last_value = next_value; diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index 4ffcdb1e3c2..95890e2215d 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -78,6 +78,7 @@ class ha_innobase: public handler ulong innobase_reset_autoinc(ulonglong auto_inc); ulong innobase_get_auto_increment(ulonglong* value); dict_index_t* innobase_get_index(uint keynr); + ulonglong innobase_get_int_col_max_value(const Field* field); /* Init values for the class: */ public: From 03b790c2a76e9b96f9b6ded403101298d2fe6a06 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 13:59:50 -0700 Subject: [PATCH 082/137] Apply InnoDB snapshot innodb-5.1-ss2858, part 15. Fixes Bug #39830: Table autoinc value not updated on first insert. Bug #35498: Cannot get table test/table1 auto-inccounter value in ::info Bug #36411: Failed to read auto-increment value from storage engine" in 5.1.24 auto-inc Detailed revision comments: r2854 | sunny | 2008-10-23 08:30:32 +0300 (Thu, 23 Oct 2008) | 13 lines branches/5.1: Backport changes from branches/zip r2725 Simplify the autoinc initialization code. This removes the non-determinism related to reading the table's autoinc value for the first time. This change has also reduced the sizeof dict_table_t by sizeof(ibool) bytes because we don't need the dict_table_t::autoinc_inited field anymore. rb://16 --- storage/innobase/dict/dict0dict.c | 25 +-- storage/innobase/dict/dict0mem.c | 2 +- storage/innobase/handler/ha_innodb.cc | 299 ++++++++++---------------- storage/innobase/handler/ha_innodb.h | 10 +- storage/innobase/include/dict0dict.h | 11 +- storage/innobase/include/dict0mem.h | 4 - storage/innobase/row/row0mysql.c | 2 +- 7 files changed, 139 insertions(+), 214 deletions(-) diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c index 7bc700c4268..c7a57d6a2b8 100644 --- a/storage/innobase/dict/dict0dict.c +++ b/storage/innobase/dict/dict0dict.c @@ -422,8 +422,7 @@ dict_table_autoinc_lock( } /************************************************************************ -Initializes the autoinc counter. It is not an error to initialize an already -initialized counter. */ +Unconditionally set the autoinc counter. */ void dict_table_autoinc_initialize( @@ -433,7 +432,6 @@ dict_table_autoinc_initialize( { ut_ad(mutex_own(&table->autoinc_mutex)); - table->autoinc_inited = TRUE; table->autoinc = value; } @@ -447,32 +445,25 @@ dict_table_autoinc_read( /* out: value for a new row, or 0 */ dict_table_t* table) /* in: table */ { - ib_longlong value; - ut_ad(mutex_own(&table->autoinc_mutex)); - if (!table->autoinc_inited) { - - value = 0; - } else { - value = table->autoinc; - } - - return(value); + return(table->autoinc); } /************************************************************************ Updates the autoinc counter if the value supplied is greater than the -current value. If not inited, does nothing. */ +current value. */ void -dict_table_autoinc_update( -/*======================*/ +dict_table_autoinc_update_if_greater( +/*=================================*/ dict_table_t* table, /* in: table */ ib_ulonglong value) /* in: value which was assigned to a row */ { - if (table->autoinc_inited && value > table->autoinc) { + ut_ad(mutex_own(&table->autoinc_mutex)); + + if (value > table->autoinc) { table->autoinc = value; } diff --git a/storage/innobase/dict/dict0mem.c b/storage/innobase/dict/dict0mem.c index f9935b8db19..168771ca307 100644 --- a/storage/innobase/dict/dict0mem.c +++ b/storage/innobase/dict/dict0mem.c @@ -89,7 +89,7 @@ dict_mem_table_create( mutex_create(&table->autoinc_mutex, SYNC_DICT_AUTOINC_MUTEX); - table->autoinc_inited = FALSE; + table->autoinc = 0; /* The number of transactions that are either waiting on the AUTOINC lock or have been granted the lock. */ diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index ab4d4e96cef..bf777b982db 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -953,7 +953,9 @@ innobase_next_autoinc( /* Should never be 0. */ ut_a(increment > 0); - if (offset <= 1) { + if (max_value <= current) { + next_value = max_value; + } else if (offset <= 1) { /* Offset 0 and 1 are the same, because there must be at least one node in the system. */ if (max_value - current <= increment) { @@ -978,6 +980,8 @@ innobase_next_autoinc( } else { next_value *= increment; + ut_a(max_value >= next_value); + /* Check for overflow. */ if (max_value - next_value <= offset) { next_value = max_value; @@ -987,6 +991,8 @@ innobase_next_autoinc( } } + ut_a(next_value <= max_value); + return(next_value); } @@ -2343,6 +2349,44 @@ normalize_table_name( #endif } +/************************************************************************ +Set the autoinc column max value. This should only be called once from +ha_innobase::open(). Therefore there's no need for a covering lock. */ + +ulong +ha_innobase::innobase_initialize_autoinc() +/*======================================*/ +{ + dict_index_t* index; + ulonglong auto_inc; + const char* col_name; + ulint error = DB_SUCCESS; + dict_table_t* innodb_table = prebuilt->table; + + col_name = table->found_next_number_field->field_name; + index = innobase_get_index(table->s->next_number_index); + + /* Execute SELECT MAX(col_name) FROM TABLE; */ + error = row_search_max_autoinc(index, col_name, &auto_inc); + + if (error == DB_SUCCESS) { + + /* At the this stage we dont' know the increment + or the offset, so use default inrement of 1. */ + ++auto_inc; + + dict_table_autoinc_initialize(innodb_table, auto_inc); + + } else { + ut_print_timestamp(stderr); + fprintf(stderr, " InnoDB: Error: (%lu) Couldn't read " + "the MAX(%s) autoinc value from the " + "index (%s).\n", error, col_name, index->name); + } + + return(ulong(error)); +} + /********************************************************************* Creates and opens a handle to a table which already exists in an InnoDB database. */ @@ -2534,6 +2578,26 @@ retry: info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST); + /* Only if the table has an AUTOINC column. */ + if (prebuilt->table != NULL && table->found_next_number_field != NULL) { + ulint error; + + dict_table_autoinc_lock(prebuilt->table); + + /* Since a table can already be "open" in InnoDB's internal + data dictionary, we only init the autoinc counter once, the + first time the table is loaded. We can safely reuse the + autoinc value from a previous MySQL open. */ + if (dict_table_autoinc_read(prebuilt->table) == 0) { + + error = innobase_initialize_autoinc(); + /* Should always succeed! */ + ut_a(error == DB_SUCCESS); + } + + dict_table_autoinc_unlock(prebuilt->table); + } + DBUG_RETURN(0); } @@ -3401,7 +3465,7 @@ min value of the autoinc interval. Once that is fixed we can get rid of the special lock handling.*/ ulong -ha_innobase::innobase_autoinc_lock(void) +ha_innobase::innobase_lock_autoinc(void) /*====================================*/ /* out: DB_SUCCESS if all OK else error code */ @@ -3466,7 +3530,7 @@ ha_innobase::innobase_reset_autoinc( { ulint error; - error = innobase_autoinc_lock(); + error = innobase_lock_autoinc(); if (error == DB_SUCCESS) { @@ -3491,11 +3555,11 @@ ha_innobase::innobase_set_max_autoinc( { ulint error; - error = innobase_autoinc_lock(); + error = innobase_lock_autoinc(); if (error == DB_SUCCESS) { - dict_table_autoinc_update(prebuilt->table, auto_inc); + dict_table_autoinc_update_if_greater(prebuilt->table, auto_inc); dict_table_autoinc_unlock(prebuilt->table); } @@ -3705,7 +3769,7 @@ no_commit: update the table upper limit. Note: last_value will be 0 if get_auto_increment() was not called.*/ - if (auto_inc < col_max_value + if (auto_inc <= col_max_value && auto_inc > prebuilt->autoinc_last_value) { set_max_autoinc: ut_a(prebuilt->autoinc_increment > 0); @@ -3965,7 +4029,7 @@ ha_innobase::update_row( col_max_value = innobase_get_int_col_max_value( table->next_number_field); - if (auto_inc < col_max_value && auto_inc != 0) { + if (auto_inc <= col_max_value && auto_inc != 0) { ulonglong need; ulonglong offset; @@ -4020,30 +4084,6 @@ ha_innobase::delete_row( ha_statistic_increment(&SSV::ha_delete_count); - /* Only if the table has an AUTOINC column */ - if (table->found_next_number_field && record == table->record[0]) { - ulonglong dummy = 0; - - /* First check whether the AUTOINC sub-system has been - initialized using the AUTOINC mutex. If not then we - do it the "proper" way, by acquiring the heavier locks. */ - dict_table_autoinc_lock(prebuilt->table); - - if (!prebuilt->table->autoinc_inited) { - dict_table_autoinc_unlock(prebuilt->table); - - error = innobase_get_auto_increment(&dummy); - - if (error == DB_SUCCESS) { - dict_table_autoinc_unlock(prebuilt->table); - } else { - goto error_exit; - } - } else { - dict_table_autoinc_unlock(prebuilt->table); - } - } - if (!prebuilt->upd_node) { row_get_prebuilt_update_vector(prebuilt); } @@ -4058,7 +4098,6 @@ ha_innobase::delete_row( innodb_srv_conc_exit_innodb(trx); -error_exit: error = convert_error_code_to_mysql(error, user_thd); /* Tell the InnoDB server that there might be work for @@ -6135,16 +6174,7 @@ ha_innobase::info( } if (flag & HA_STATUS_AUTO && table->found_next_number_field) { - ulonglong auto_inc; - - if (innobase_read_and_init_auto_inc(&auto_inc) != 0) { - sql_print_error("Cannot get table %s auto-inc" - "counter value in ::info\n", - ib_table->name); - auto_inc = 0; - } - - stats.auto_increment_value = auto_inc; + stats.auto_increment_value = innobase_peek_autoinc(); } prebuilt->trx->op_info = (char*)""; @@ -7475,157 +7505,59 @@ ha_innobase::store_lock( return(to); } -/*********************************************************************** -This function initializes the auto-inc counter if it has not been -initialized yet. This function does not change the value of the auto-inc -counter if it already has been initialized. In parameter ret returns -the value of the auto-inc counter. */ - -int -ha_innobase::innobase_read_and_init_auto_inc( -/*=========================================*/ - /* out: 0 or generic MySQL - error code */ - ulonglong* value) /* out: the autoinc value */ -{ - ulonglong auto_inc; - ibool stmt_start; - int mysql_error = 0; - dict_table_t* innodb_table = prebuilt->table; - ibool trx_was_not_started = FALSE; - - ut_a(prebuilt); - ut_a(prebuilt->table); - - /* Remember if we are in the beginning of an SQL statement. - This function must not change that flag. */ - stmt_start = prebuilt->sql_stat_start; - - /* Prepare prebuilt->trx in the table handle */ - update_thd(ha_thd()); - - if (prebuilt->trx->conc_state == TRX_NOT_STARTED) { - trx_was_not_started = TRUE; - } - - /* In case MySQL calls this in the middle of a SELECT query, release - possible adaptive hash latch to avoid deadlocks of threads */ - - trx_search_latch_release_if_reserved(prebuilt->trx); - - dict_table_autoinc_lock(prebuilt->table); - - auto_inc = dict_table_autoinc_read(prebuilt->table); - - /* Was the AUTOINC counter reset during normal processing, if - so then we simply start count from 1. No need to go to the index.*/ - if (auto_inc == 0 && innodb_table->autoinc_inited) { - ++auto_inc; - dict_table_autoinc_initialize(innodb_table, auto_inc); - } - - if (auto_inc == 0) { - dict_index_t* index; - const char* autoinc_col_name; - - ut_a(!innodb_table->autoinc_inited); - - index = innobase_get_index(table->s->next_number_index); - - autoinc_col_name = table->found_next_number_field->field_name; - - prebuilt->autoinc_error = row_search_max_autoinc( - index, autoinc_col_name, &auto_inc); - - if (prebuilt->autoinc_error == DB_SUCCESS) { - if (auto_inc < ~0x0ULL) { - ++auto_inc; - } - dict_table_autoinc_initialize(innodb_table, auto_inc); - } else { - ut_print_timestamp(stderr); - fprintf(stderr, " InnoDB: Error: (%lu) Couldn't read " - "the max AUTOINC value from the index (%s).\n", - prebuilt->autoinc_error, index->name); - - mysql_error = 1; - } - } - - *value = auto_inc; - - dict_table_autoinc_unlock(prebuilt->table); - - /* Since MySQL does not seem to call autocommit after SHOW TABLE - STATUS (even if we would register the trx here), we commit our - transaction here if it was started here. This is to eliminate a - dangling transaction. If the user had AUTOCOMMIT=0, then SHOW - TABLE STATUS does leave a dangling transaction if the user does not - himself call COMMIT. */ - - if (trx_was_not_started) { - - innobase_commit_low(prebuilt->trx); - } - - prebuilt->sql_stat_start = stmt_start; - - return(mysql_error); -} - /******************************************************************************* -Read the next autoinc value, initialize the table if it's not initialized. -On return if there is no error then the tables AUTOINC lock is locked.*/ +Read the next autoinc value. Acquire the relevant locks before reading +the AUTOINC value. If SUCCESS then the table AUTOINC mutex will be locked +on return and all relevant locks acquired. */ -ulint -ha_innobase::innobase_get_auto_increment( -/*=====================================*/ +ulong +ha_innobase::innobase_get_autoinc( +/*==============================*/ + /* out: DB_SUCCESS or error code */ ulonglong* value) /* out: autoinc value */ { - *value = 0; + *value = 0; + + prebuilt->autoinc_error = innobase_lock_autoinc(); - /* Note: If the table is not initialized when we attempt the - read below. We initialize the table's auto-inc counter and - always do a reread of the AUTOINC value. */ - do { - /* We need to send the correct error code to the client - because handler::get_auto_increment() doesn't allow a way - to return the specific error for why it failed. */ - prebuilt->autoinc_error = innobase_autoinc_lock(); + if (prebuilt->autoinc_error == DB_SUCCESS) { - if (prebuilt->autoinc_error == DB_SUCCESS) { - ulonglong autoinc; + /* Determine the first value of the interval */ + *value = dict_table_autoinc_read(prebuilt->table); - /* Determine the first value of the interval */ - autoinc = dict_table_autoinc_read(prebuilt->table); + /* It should have been initialized during open. */ + ut_a(*value != 0); + } + + return(ulong(prebuilt->autoinc_error)); +} - /* We need to initialize the AUTO-INC value, for - that we release all locks.*/ - if (autoinc == 0) { - trx_t* trx; +/*********************************************************************** +This function reads the global auto-inc counter. It doesn't use the +AUTOINC lock even if the lock mode is set to TRADITIONAL. */ - trx = prebuilt->trx; - dict_table_autoinc_unlock(prebuilt->table); +ulonglong +ha_innobase::innobase_peek_autoinc() +/*================================*/ + /* out: the autoinc value */ +{ + ulonglong auto_inc; + dict_table_t* innodb_table; - /* If we had reserved the AUTO-INC - lock in this SQL statement we release - it before retrying.*/ - row_unlock_table_autoinc_for_mysql(trx); + ut_a(prebuilt != NULL); + ut_a(prebuilt->table != NULL); - /* Just to make sure */ - ut_a(!trx->auto_inc_lock); + innodb_table = prebuilt->table; - /* Will set prebuilt->autoinc_error if there - is a problem during init. */ - innobase_read_and_init_auto_inc(&autoinc); + dict_table_autoinc_lock(innodb_table); - } else { - *value = autoinc; - } - } - } while (*value == 0 && prebuilt->autoinc_error == DB_SUCCESS); + auto_inc = dict_table_autoinc_read(innodb_table); - return(prebuilt->autoinc_error); + ut_a(auto_inc > 0); + + dict_table_autoinc_unlock(innodb_table); + + return(auto_inc); } /******************************************************************************* @@ -7652,7 +7584,7 @@ ha_innobase::get_auto_increment( /* Prepare prebuilt->trx in the table handle */ update_thd(ha_thd()); - error = innobase_get_auto_increment(&autoinc); + error = innobase_get_autoinc(&autoinc); if (error != DB_SUCCESS) { *first_value = (~(ulonglong) 0); @@ -7717,7 +7649,7 @@ ha_innobase::get_auto_increment( ut_a(prebuilt->autoinc_last_value >= *first_value); /* Update the table autoinc variable */ - dict_table_autoinc_update( + dict_table_autoinc_update_if_greater( prebuilt->table, prebuilt->autoinc_last_value); } else { /* This will force write_row() into attempting an update @@ -7755,6 +7687,11 @@ ha_innobase::reset_auto_increment( DBUG_RETURN(error); } + /* The next value can never be 0. */ + if (value == 0) { + value = 1; + } + innobase_reset_autoinc(value); DBUG_RETURN(0); diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index 95890e2215d..8ca72ee1a60 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -72,13 +72,15 @@ class ha_innobase: public handler int update_thd(THD* thd); int change_active_index(uint keynr); int general_fetch(uchar* buf, uint direction, uint match_mode); - int innobase_read_and_init_auto_inc(ulonglong* ret); - ulong innobase_autoinc_lock(); + ulong innobase_lock_autoinc(); + ulonglong innobase_peek_autoinc(); ulong innobase_set_max_autoinc(ulonglong auto_inc); ulong innobase_reset_autoinc(ulonglong auto_inc); - ulong innobase_get_auto_increment(ulonglong* value); + ulong innobase_get_autoinc(ulonglong* value); + ulong innobase_update_autoinc(ulonglong auto_inc); + ulong innobase_initialize_autoinc(); dict_index_t* innobase_get_index(uint keynr); - ulonglong innobase_get_int_col_max_value(const Field* field); + ulonglong innobase_get_int_col_max_value(const Field* field); /* Init values for the class: */ public: diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index f60775c8c2f..7d5ff09c7a6 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -178,8 +178,7 @@ dict_table_autoinc_lock( /*====================*/ dict_table_t* table); /* in: table */ /************************************************************************ -Initializes the autoinc counter. It is not an error to initialize an already -initialized counter. */ +Unconditionally set the autoinc counter. */ void dict_table_autoinc_initialize( @@ -196,12 +195,12 @@ dict_table_autoinc_read( /* out: value for a new row, or 0 */ dict_table_t* table); /* in: table */ /************************************************************************ -Updates the autoinc counter if the value supplied is equal or bigger than the -current value. If not inited, does nothing. */ +Updates the autoinc counter if the value supplied is greater than the +current value. */ void -dict_table_autoinc_update( -/*======================*/ +dict_table_autoinc_update_if_greater( +/*=================================*/ dict_table_t* table, /* in: table */ ib_ulonglong value); /* in: value which was assigned to a row */ diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index 6e5435493cb..ac28fdb1bae 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -405,10 +405,6 @@ struct dict_table_struct{ mutex_t autoinc_mutex; /* mutex protecting the autoincrement counter */ - ibool autoinc_inited; - /* TRUE if the autoinc counter has been - inited; MySQL gets the init value by executing - SELECT MAX(auto inc column) */ ib_ulonglong autoinc;/* autoinc counter value to give to the next inserted row */ ulong n_waiting_or_granted_auto_inc_locks; diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c index 2d1cf22e4e7..d76af54b420 100644 --- a/storage/innobase/row/row0mysql.c +++ b/storage/innobase/row/row0mysql.c @@ -2910,7 +2910,7 @@ next_rec: /* MySQL calls ha_innobase::reset_auto_increment() which does the same thing. */ dict_table_autoinc_lock(table); - dict_table_autoinc_initialize(table, 0); + dict_table_autoinc_initialize(table, 1); dict_table_autoinc_unlock(table); dict_update_statistics(table); From e4dedf7ed88b9a4746167e6e0d3b509ec2d69eeb Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Sun, 14 Dec 2008 14:26:31 -0700 Subject: [PATCH 083/137] Apply InnoDB snapshot innodb-5.1-ss2858, part 16. Fix merge mistake which resulted in a duplicate test case for bug 38231. --- mysql-test/r/innodb_bug38231.result | 11 ---- mysql-test/t/innodb_bug38231.test | 83 ----------------------------- 2 files changed, 94 deletions(-) diff --git a/mysql-test/r/innodb_bug38231.result b/mysql-test/r/innodb_bug38231.result index b5d1d91ddc0..2f909779755 100644 --- a/mysql-test/r/innodb_bug38231.result +++ b/mysql-test/r/innodb_bug38231.result @@ -9,14 +9,3 @@ a TRUNCATE TABLE bug38231; COMMIT; DROP TABLE bug38231; -SET storage_engine=InnoDB; -INSERT INTO bug38231 VALUES (1), (10), (300); -SET autocommit=0; -SELECT * FROM bug38231 FOR UPDATE; -a -1 -10 -300 -TRUNCATE TABLE bug38231; -COMMIT; -DROP TABLE bug38231; diff --git a/mysql-test/t/innodb_bug38231.test b/mysql-test/t/innodb_bug38231.test index 7ee35b2bc78..5b87969f062 100644 --- a/mysql-test/t/innodb_bug38231.test +++ b/mysql-test/t/innodb_bug38231.test @@ -81,86 +81,3 @@ COMMIT; -- disconnect con4 DROP TABLE bug38231; -# -# Bug#38231 Innodb crash in lock_reset_all_on_table() on TRUNCATE + LOCK / UNLOCK -# http://bugs.mysql.com/38231 -# - --- source include/have_innodb.inc - -SET storage_engine=InnoDB; - -# we care only that the following SQL commands do not crash the server --- disable_query_log --- disable_result_log - -DROP TABLE IF EXISTS bug38231; -CREATE TABLE bug38231 (a INT); - --- connect (con1,localhost,root,,) --- connect (con2,localhost,root,,) --- connect (con3,localhost,root,,) - --- connection con1 -SET autocommit=0; -LOCK TABLE bug38231 WRITE; - --- connection con2 -SET autocommit=0; --- send -LOCK TABLE bug38231 WRITE; - --- connection con3 -SET autocommit=0; --- send -LOCK TABLE bug38231 WRITE; - --- connection default --- send -TRUNCATE TABLE bug38231; - --- connection con1 -# give time to TRUNCATE and others to be executed; without sleep, sometimes -# UNLOCK executes before TRUNCATE --- sleep 0.2 -# this crashes the server if the bug is present -UNLOCK TABLES; - -# clean up - --- connection con2 -UNLOCK TABLES; - --- connection con3 -UNLOCK TABLES; - --- connection default - --- disconnect con1 --- disconnect con2 --- disconnect con3 - -# test that TRUNCATE works with with row-level locks - --- enable_query_log --- enable_result_log - -INSERT INTO bug38231 VALUES (1), (10), (300); - --- connect (con4,localhost,root,,) - --- connection con4 -SET autocommit=0; -SELECT * FROM bug38231 FOR UPDATE; - --- connection default -TRUNCATE TABLE bug38231; - --- connection con4 -COMMIT; - --- connection default - --- disconnect con4 - -DROP TABLE bug38231; From b774a8dd7a33c1f8bbbf7d575e3b35078404b627 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Mon, 15 Dec 2008 23:58:16 +0100 Subject: [PATCH 084/137] Update test result file for binlog_innodb.result; the tested values (change in binlog_cache_use status variable) don't change, just the starting value is reduced. --- mysql-test/suite/binlog/r/binlog_innodb.result | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/suite/binlog/r/binlog_innodb.result b/mysql-test/suite/binlog/r/binlog_innodb.result index adc90d007bd..896d8f734fc 100644 --- a/mysql-test/suite/binlog/r/binlog_innodb.result +++ b/mysql-test/suite/binlog/r/binlog_innodb.result @@ -115,14 +115,14 @@ master-bin.000001 # Xid # # COMMIT /* XID */ DROP TABLE t1; show status like "binlog_cache_use"; Variable_name Value -Binlog_cache_use 15 +Binlog_cache_use 13 show status like "binlog_cache_disk_use"; Variable_name Value Binlog_cache_disk_use 0 create table t1 (a int) engine=innodb; show status like "binlog_cache_use"; Variable_name Value -Binlog_cache_use 16 +Binlog_cache_use 14 show status like "binlog_cache_disk_use"; Variable_name Value Binlog_cache_disk_use 1 @@ -131,7 +131,7 @@ delete from t1; commit; show status like "binlog_cache_use"; Variable_name Value -Binlog_cache_use 17 +Binlog_cache_use 15 show status like "binlog_cache_disk_use"; Variable_name Value Binlog_cache_disk_use 1 From bd2629b439cac0a338c93ff93867109a8027d63b Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Tue, 16 Dec 2008 12:44:18 +0100 Subject: [PATCH 085/137] post push fix for bug#40595 Addition of hander function was_semi_consistent_read --- .../r/partition_innodb_semi_consistent.result | 128 ++++++++++++ ...artition_innodb_semi_consistent-master.opt | 1 + .../t/partition_innodb_semi_consistent.test | 194 ++++++++++++++++++ sql/ha_partition.cc | 30 +++ sql/ha_partition.h | 6 +- 5 files changed, 358 insertions(+), 1 deletion(-) create mode 100644 mysql-test/r/partition_innodb_semi_consistent.result create mode 100644 mysql-test/t/partition_innodb_semi_consistent-master.opt create mode 100644 mysql-test/t/partition_innodb_semi_consistent.test diff --git a/mysql-test/r/partition_innodb_semi_consistent.result b/mysql-test/r/partition_innodb_semi_consistent.result new file mode 100644 index 00000000000..1bb39af043a --- /dev/null +++ b/mysql-test/r/partition_innodb_semi_consistent.result @@ -0,0 +1,128 @@ +drop table if exists t1; +set binlog_format=mixed; +set session transaction isolation level read committed; +create table t1(a int not null) +engine=innodb +DEFAULT CHARSET=latin1 +PARTITION BY RANGE(a) +(PARTITION p0 VALUES LESS THAN (20), +PARTITION p1 VALUES LESS THAN MAXVALUE); +insert into t1 values (1),(2),(3),(4),(5),(6),(7); +set autocommit=0; +select * from t1 where a=3 lock in share mode; +a +3 +set binlog_format=mixed; +set session transaction isolation level read committed; +set autocommit=0; +update t1 set a=10 where a=5; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +commit; +update t1 set a=10 where a=5; +select * from t1 where a=2 for update; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +select * from t1 where a=2 limit 1 for update; +a +2 +update t1 set a=11 where a=6; +update t1 set a=12 where a=2; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +update t1 set a=13 where a=1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +commit; +update t1 set a=14 where a=1; +commit; +select * from t1; +a +10 +11 +14 +2 +3 +4 +7 +drop table t1; +SET SESSION AUTOCOMMIT = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +set binlog_format=mixed; +# Switch to connection con1 +CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256)) +ENGINE = InnoDB +PARTITION BY RANGE (a) +(PARTITION p0 VALUES LESS THAN (300), +PARTITION p1 VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (1,2); +# 1. test for locking: +BEGIN; +UPDATE t1 SET b = 12 WHERE a = 1; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +SELECT * FROM t1; +a b +1 12 +# Switch to connection con2 +UPDATE t1 SET b = 21 WHERE a = 1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +# Switch to connection con1 +SELECT * FROM t1; +a b +1 12 +ROLLBACK; +# 2. test for serialized update: +CREATE TABLE t2 (a INT); +TRUNCATE t1; +INSERT INTO t1 VALUES (1,'init'); +CREATE PROCEDURE p1() +BEGIN +UPDATE t1 SET b = CONCAT(b, '+con2') WHERE a = 1; +INSERT INTO t2 VALUES (); +END| +BEGIN; +UPDATE t1 SET b = CONCAT(b, '+con1') WHERE a = 1; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +SELECT * FROM t1; +a b +1 init+con1 +# Switch to connection con2 +CALL p1;; +# Switch to connection con1 +SELECT * FROM t1; +a b +1 init+con1 +COMMIT; +SELECT * FROM t1; +a b +1 init+con1 +# Switch to connection con2 +SELECT * FROM t1; +a b +1 init+con1+con2 +# Switch to connection con1 +# 3. test for updated key column: +TRUNCATE t1; +TRUNCATE t2; +INSERT INTO t1 VALUES (1,'init'); +BEGIN; +UPDATE t1 SET a = 2, b = CONCAT(b, '+con1') WHERE a = 1; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +SELECT * FROM t1; +a b +2 init+con1 +# Switch to connection con2 +CALL p1;; +# Switch to connection con1 +SELECT * FROM t1; +a b +2 init+con1 +COMMIT; +SELECT * FROM t1; +a b +2 init+con1 +# Switch to connection con2 +SELECT * FROM t1; +a b +2 init+con1 +DROP PROCEDURE p1; +DROP TABLE t1, t2; diff --git a/mysql-test/t/partition_innodb_semi_consistent-master.opt b/mysql-test/t/partition_innodb_semi_consistent-master.opt new file mode 100644 index 00000000000..e76299453d3 --- /dev/null +++ b/mysql-test/t/partition_innodb_semi_consistent-master.opt @@ -0,0 +1 @@ +--innodb_lock_wait_timeout=2 diff --git a/mysql-test/t/partition_innodb_semi_consistent.test b/mysql-test/t/partition_innodb_semi_consistent.test new file mode 100644 index 00000000000..cfa170f575b --- /dev/null +++ b/mysql-test/t/partition_innodb_semi_consistent.test @@ -0,0 +1,194 @@ +-- source include/have_partition.inc +-- source include/not_embedded.inc +-- source include/have_innodb.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# basic tests of semi-consistent reads +# for verifying Bug#40595: Non-matching rows not released with READ-COMMITTED +# on tables with partitions + +connect (a,localhost,root,,); +connect (b,localhost,root,,); +connection a; +set binlog_format=mixed; +set session transaction isolation level read committed; +create table t1(a int not null) +engine=innodb +DEFAULT CHARSET=latin1 +PARTITION BY RANGE(a) +(PARTITION p0 VALUES LESS THAN (20), + PARTITION p1 VALUES LESS THAN MAXVALUE); +insert into t1 values (1),(2),(3),(4),(5),(6),(7); +set autocommit=0; +# this should lock the entire table +select * from t1 where a=3 lock in share mode; +connection b; +set binlog_format=mixed; +set session transaction isolation level read committed; +set autocommit=0; +-- error ER_LOCK_WAIT_TIMEOUT +update t1 set a=10 where a=5; +connection a; +#DELETE FROM t1 WHERE a=5; +commit; +connection b; +update t1 set a=10 where a=5; +connection a; +-- error ER_LOCK_WAIT_TIMEOUT +select * from t1 where a=2 for update; +# this should lock the records (1),(2) +select * from t1 where a=2 limit 1 for update; +connection b; +update t1 set a=11 where a=6; +-- error ER_LOCK_WAIT_TIMEOUT +update t1 set a=12 where a=2; +-- error ER_LOCK_WAIT_TIMEOUT +update t1 set a=13 where a=1; +connection a; +commit; +connection b; +update t1 set a=14 where a=1; +commit; +connection a; +--sorted_result +select * from t1; +drop table t1; + +connection default; +disconnect a; +disconnect b; + +# +# Bug #31310: Locked rows silently skipped in read-committed isolation level. +# (This also tests the '*_semi_consistent*' functions in partitioning) +# Copied from include/mix1.inc + +connect (con1,localhost,root,,); +connect (con2,localhost,root,,); +SET SESSION AUTOCOMMIT = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +set binlog_format=mixed; +--echo # Switch to connection con1 +connection con1; + +eval +CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256)) +ENGINE = InnoDB +PARTITION BY RANGE (a) +(PARTITION p0 VALUES LESS THAN (300), + PARTITION p1 VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (1,2); + +--echo # 1. test for locking: + +BEGIN; +--enable_info +UPDATE t1 SET b = 12 WHERE a = 1; +--disable_info +SELECT * FROM t1; + +--echo # Switch to connection con2 +connection con2; + +--enable_info +--disable_abort_on_error +--error ER_LOCK_WAIT_TIMEOUT +UPDATE t1 SET b = 21 WHERE a = 1; +--disable_info + +--echo # Switch to connection con1 +connection con1; +SELECT * FROM t1; +ROLLBACK; + +--echo # 2. test for serialized update: + +CREATE TABLE t2 (a INT); + +TRUNCATE t1; +INSERT INTO t1 VALUES (1,'init'); + +DELIMITER |; +CREATE PROCEDURE p1() +BEGIN + UPDATE t1 SET b = CONCAT(b, '+con2') WHERE a = 1; + INSERT INTO t2 VALUES (); +END| +DELIMITER ;| + +BEGIN; +--enable_info +UPDATE t1 SET b = CONCAT(b, '+con1') WHERE a = 1; +--disable_info +SELECT * FROM t1; + +--echo # Switch to connection con2 +connection con2; + +--send CALL p1; + +--echo # Switch to connection con1 +connection con1; +SELECT * FROM t1; +COMMIT; + +let $bug31310 = 1; +while ($bug31310) +{ + let $bug31310= `SELECT 1 - COUNT(*) FROM t2`; +} + +SELECT * FROM t1; + +--echo # Switch to connection con2 +connection con2; +--reap +SELECT * FROM t1; + +--echo # Switch to connection con1 +connection con1; + +--echo # 3. test for updated key column: + +TRUNCATE t1; +TRUNCATE t2; + +INSERT INTO t1 VALUES (1,'init'); + +BEGIN; +--enable_info +UPDATE t1 SET a = 2, b = CONCAT(b, '+con1') WHERE a = 1; +--disable_info +SELECT * FROM t1; + +--echo # Switch to connection con2 +connection con2; + +--send CALL p1; + +--echo # Switch to connection con1 +connection con1; +SELECT * FROM t1; +COMMIT; + +let $bug31310 = 1; +while ($bug31310) +{ + let $bug31310= `SELECT 1 - COUNT(*) FROM t2`; +} + +SELECT * FROM t1; + +--echo # Switch to connection con2 +connection con2; +SELECT * FROM t1; + +connection default; +disconnect con1; +disconnect con2; +DROP PROCEDURE p1; +DROP TABLE t1, t2; + diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 852f437b213..47d2d36ac8d 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -2818,6 +2818,36 @@ void ha_partition::unlock_row() DBUG_VOID_RETURN; } +/** + Check if semi consistent read was used + + SYNOPSIS + was_semi_consistent_read() + + RETURN VALUE + TRUE Previous read was a semi consistent read + FALSE Previous read was not a semi consistent read + + DESCRIPTION + See handler.h: + In an UPDATE or DELETE, if the row under the cursor was locked by another + transaction, and the engine used an optimistic read of the last + committed row value under the cursor, then the engine returns 1 from this + function. MySQL must NOT try to update this optimistic value. If the + optimistic value does not match the WHERE condition, MySQL can decide to + skip over this row. Currently only works for InnoDB. This can be used to + avoid unnecessary lock waits. + + If this method returns nonzero, it will also signal the storage + engine that the next read will be a locking re-read of the row. +*/ +bool ha_partition::was_semi_consistent_read() +{ + DBUG_ENTER("ha_partition::was_semi_consistent_read"); + DBUG_ASSERT(m_last_part < m_tot_parts && + bitmap_is_set(&(m_part_info->used_partitions), m_last_part)); + DBUG_RETURN(m_file[m_last_part]->was_semi_consistent_read()); +} /** Use semi consistent read if possible diff --git a/sql/ha_partition.h b/sql/ha_partition.h index dd06d8d647b..bae2d03a8ce 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -112,7 +112,7 @@ private: uint m_reorged_parts; // Number of reorganised parts uint m_tot_parts; // Total number of partitions; uint m_no_locks; // For engines like ha_blackhole, which needs no locks - uint m_last_part; // Last file that we update,write + uint m_last_part; // Last file that we update,write,read int m_lock_type; // Remembers type of last // external_lock part_id_range m_part_spec; // Which parts to scan @@ -325,6 +325,10 @@ public: Call to unlock rows not to be updated in transaction */ virtual void unlock_row(); + /* + Check if semi consistent read + */ + virtual bool was_semi_consistent_read(); /* Call to hint about semi consistent read */ From 4bdb3d87fa3bfbbafed984c3c03c5ac609d9797b Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Tue, 16 Dec 2008 10:12:22 -0200 Subject: [PATCH 086/137] Fix warnings and bug spotted by gcc-4.3. Related to operator precedence and associativity. Make the expressions as explicit as possible. --- sql/field.h | 2 +- sql/item.cc | 6 +++--- sql/item_sum.cc | 7 +++---- sql/log_event.cc | 2 +- sql/spatial.h | 10 +++++----- sql/sql_lex.cc | 2 +- sql/table.h | 2 +- storage/federated/ha_federated.cc | 2 +- storage/heap/ha_heap.cc | 2 +- 9 files changed, 17 insertions(+), 18 deletions(-) diff --git a/sql/field.h b/sql/field.h index 81905cc64ae..23033e6cc7a 100644 --- a/sql/field.h +++ b/sql/field.h @@ -209,7 +209,7 @@ public: memcpy(ptr, ptr + l_offset, pack_length()); if (null_ptr) *null_ptr= ((*null_ptr & (uchar) ~null_bit) | - null_ptr[l_offset] & null_bit); + (null_ptr[l_offset] & null_bit)); } virtual bool binary() const { return 1; } virtual bool zero_pack() const { return 1; } diff --git a/sql/item.cc b/sql/item.cc index 7f85713915d..b8fcdb832d4 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -2628,7 +2628,7 @@ void Item_param::set_time(MYSQL_TIME *tm, timestamp_type time_type, if (value.time.year > 9999 || value.time.month > 12 || value.time.day > 31 || - time_type != MYSQL_TIMESTAMP_TIME && value.time.hour > 23 || + (time_type != MYSQL_TIMESTAMP_TIME && value.time.hour > 23) || value.time.minute > 59 || value.time.second > 59) { char buff[MAX_DATE_STRING_REP_LENGTH]; @@ -4840,8 +4840,8 @@ int Item::save_in_field(Field *field, bool no_conversions) { int error; if (result_type() == STRING_RESULT || - result_type() == REAL_RESULT && - field->result_type() == STRING_RESULT) + (result_type() == REAL_RESULT && + field->result_type() == STRING_RESULT)) { String *result; CHARSET_INFO *cs= collation.collation; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index c2b3b954634..1821136cc9d 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -654,8 +654,7 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref) return TRUE; // 'item' can be changed during fix_fields - if (!item->fixed && - item->fix_fields(thd, args) || + if ((!item->fixed && item->fix_fields(thd, args)) || (item= args[0])->check_cols(1)) return TRUE; decimals=item->decimals; @@ -981,8 +980,8 @@ void Item_sum_distinct::fix_length_and_dec() integers each <= 2^32. */ if (table_field_type == MYSQL_TYPE_INT24 || - table_field_type >= MYSQL_TYPE_TINY && - table_field_type <= MYSQL_TYPE_LONG) + (table_field_type >= MYSQL_TYPE_TINY && + table_field_type <= MYSQL_TYPE_LONG)) { val.traits= Hybrid_type_traits_fast_decimal::instance(); break; diff --git a/sql/log_event.cc b/sql/log_event.cc index 0d03593946d..cd8fa0c3a85 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -2680,7 +2680,7 @@ void Query_log_event::print_query_header(IO_CACHE* file, if (!(flags & LOG_EVENT_SUPPRESS_USE_F) && db) { - if (different_db= memcmp(print_event_info->db, db, db_len + 1)) + if ((different_db= memcmp(print_event_info->db, db, db_len + 1))) memcpy(print_event_info->db, db, db_len + 1); if (db[0] && different_db) my_b_printf(file, "use %s%s\n", db, print_event_info->delimiter); diff --git a/sql/spatial.h b/sql/spatial.h index f806861290e..69a1f24506e 100644 --- a/sql/spatial.h +++ b/sql/spatial.h @@ -116,12 +116,12 @@ struct MBR int touches(const MBR *mbr) { /* The following should be safe, even if we compare doubles */ - return ((((mbr->xmin == xmax) || (mbr->xmax == xmin)) && - ((mbr->ymin >= ymin) && (mbr->ymin <= ymax) || - (mbr->ymax >= ymin) && (mbr->ymax <= ymax))) || + return ((((mbr->xmin == xmax) || (mbr->xmax == xmin)) && + (((mbr->ymin >= ymin) && (mbr->ymin <= ymax)) || + ((mbr->ymax >= ymin) && (mbr->ymax <= ymax)))) || (((mbr->ymin == ymax) || (mbr->ymax == ymin)) && - ((mbr->xmin >= xmin) && (mbr->xmin <= xmax) || - (mbr->xmax >= xmin) && (mbr->xmax <= xmax)))); + (((mbr->xmin >= xmin) && (mbr->xmin <= xmax)) || + ((mbr->xmax >= xmin) && (mbr->xmax <= xmax))))); } int within(const MBR *mbr) diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 983d53a041d..7d0a4d18d34 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -2002,7 +2002,7 @@ void st_select_lex::print_limit(THD *thd, item->substype() == Item_subselect::ALL_SUBS)) { DBUG_ASSERT(!item->fixed || - select_limit->val_int() == LL(1) && offset_limit == 0); + (select_limit->val_int() == LL(1) && offset_limit == 0)); return; } diff --git a/sql/table.h b/sql/table.h index 8d6473661ac..a6a256b30b6 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1363,7 +1363,7 @@ struct TABLE_LIST void cleanup_items(); bool placeholder() { - return derived || view || schema_table || create && !table->db_stat || + return derived || view || schema_table || (create && !table->db_stat) || !table; } void print(THD *thd, String *str, enum_query_type query_type); diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index 2f1c5e51caa..6cfbd355c40 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -2828,7 +2828,7 @@ int ha_federated::info(uint flag) if (!(row= mysql_fetch_row(result))) goto error; - if (flag & HA_STATUS_VARIABLE | HA_STATUS_CONST) + if (flag & (HA_STATUS_VARIABLE | HA_STATUS_CONST)) { /* deleted is set in ha_federated::info diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc index be2914adac4..19863d83874 100644 --- a/storage/heap/ha_heap.cc +++ b/storage/heap/ha_heap.cc @@ -91,7 +91,7 @@ const char **ha_heap::bas_ext() const int ha_heap::open(const char *name, int mode, uint test_if_locked) { if ((test_if_locked & HA_OPEN_INTERNAL_TABLE) || - !(file= heap_open(name, mode)) && my_errno == ENOENT) + (!(file= heap_open(name, mode)) && my_errno == ENOENT)) { HA_CREATE_INFO create_info; internal_table= test(test_if_locked & HA_OPEN_INTERNAL_TABLE); From ed1049f9dc24fec8fa5412addeef9fa4cfbe0646 Mon Sep 17 00:00:00 2001 From: Matthias Leich Date: Tue, 16 Dec 2008 19:09:09 +0100 Subject: [PATCH 087/137] Fix for Bug#39854 events_scheduling fails sporadically on pushbuild Detail: - Choose the solution that was already in place (before last fix) for 6.0 - minor cleanup in comments --- mysql-test/r/events_scheduling.result | 12 ------------ mysql-test/t/events_scheduling.test | 28 +++++++-------------------- 2 files changed, 7 insertions(+), 33 deletions(-) diff --git a/mysql-test/r/events_scheduling.result b/mysql-test/r/events_scheduling.result index 63140bffaa4..7dfd10a53f8 100644 --- a/mysql-test/r/events_scheduling.result +++ b/mysql-test/r/events_scheduling.result @@ -62,18 +62,6 @@ CREATE EVENT event_4 ON SCHEDULE EVERY 1 SECOND ENDS NOW() + INTERVAL 1 SECOND ON COMPLETION PRESERVE DO INSERT INTO table_4 VALUES (1); -SELECT IF(SUM(a) >= 4, 'OK', 'ERROR') FROM table_1; -IF(SUM(a) >= 4, 'OK', 'ERROR') -OK -SELECT IF(SUM(a) >= 4, 'OK', 'ERROR') FROM table_2; -IF(SUM(a) >= 4, 'OK', 'ERROR') -OK -SELECT IF(SUM(a) >= 1, 'OK', 'ERROR') FROM table_3; -IF(SUM(a) >= 1, 'OK', 'ERROR') -OK -SELECT IF(SUM(a) >= 1, 'OK', 'ERROR') FROM table_4; -IF(SUM(a) >= 1, 'OK', 'ERROR') -OK SELECT IF(TIME_TO_SEC(TIMEDIFF(ENDS,STARTS))=6, 'OK', 'ERROR') FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA=DATABASE() AND EVENT_NAME='event_2'; diff --git a/mysql-test/t/events_scheduling.test b/mysql-test/t/events_scheduling.test index 87cfa42e283..041a2def490 100644 --- a/mysql-test/t/events_scheduling.test +++ b/mysql-test/t/events_scheduling.test @@ -58,8 +58,6 @@ ON COMPLETION PRESERVE DO INSERT INTO table_4 VALUES (1); -# Wait for the events to fire and check the data afterwards - # Let event_1 insert at least 4 records into the table let $wait_condition=select count(*) >= 4 from table_1; --source include/wait_condition.inc @@ -85,25 +83,13 @@ let $wait_condition=select count(*) = 0 from information_schema.events where event_name='event_4' and status='enabled'; --source include/wait_condition.inc -let $wait_condition=SELECT SUM(a) >= 4 FROM table_1; -source include/wait_condition.inc; -SELECT IF(SUM(a) >= 4, 'OK', 'ERROR') FROM table_1; - -# In case of a testing box under heavy load it cannot be guaranteed that -# it is really often enough checked if event_2 has to be executed. -# -> Bug#39854 events_scheduling fails sporadically on pushbuild -# Therefore we lowered here the original expectation of 5 to 4. -let $wait_condition=SELECT SUM(a) >= 4 FROM table_2; -source include/wait_condition.inc; -SELECT IF(SUM(a) >= 4, 'OK', 'ERROR') FROM table_2; - -let $wait_condition=SELECT SUM(a) >= 1 FROM table_3; -source include/wait_condition.inc; -SELECT IF(SUM(a) >= 1, 'OK', 'ERROR') FROM table_3; - -let $wait_condition=SELECT SUM(a) >= 1 FROM table_4; -source include/wait_condition.inc; -SELECT IF(SUM(a) >= 1, 'OK', 'ERROR') FROM table_4; +# +# On a busy system the scheduler may skip execution of events, +# we can't reliably expect that the data in a table to be modified +# by an event will be exact. Thus we do not SELECT from the tables +# in this test. See also +# Bug#39854 events_scheduling fails sporadically on pushbuild +# SELECT IF(TIME_TO_SEC(TIMEDIFF(ENDS,STARTS))=6, 'OK', 'ERROR') FROM INFORMATION_SCHEMA.EVENTS From aae00014e2308678d313df1120790bde5870a053 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Wed, 17 Dec 2008 17:23:21 +0400 Subject: [PATCH 088/137] Bug#24289 Status Variable "Questions" gets wrong values with Stored Routines(for 5.1) --- mysql-test/r/myisampack.result | 2 +- mysql-test/r/status2.result | 73 ++++++++++++++++++++++++++++++++++ mysql-test/t/myisampack.test | 2 +- mysql-test/t/status2.test | 68 +++++++++++++++++++++++++++++++ sql/mysqld.cc | 8 +--- sql/sql_class.h | 11 ++++- sql/sql_parse.cc | 22 +++++++++- 7 files changed, 174 insertions(+), 12 deletions(-) create mode 100644 mysql-test/r/status2.result create mode 100644 mysql-test/t/status2.test diff --git a/mysql-test/r/myisampack.result b/mysql-test/r/myisampack.result index 14b6283bf8f..7ed9b86d887 100644 --- a/mysql-test/r/myisampack.result +++ b/mysql-test/r/myisampack.result @@ -28,7 +28,7 @@ Table Op Msg_type Msg_text test.t1 check status OK DROP TABLE t1; drop table if exists t1; -create table t1(f1 int, f2 varchar(255)); +create table t1(f1 int, f2 char(255)); insert into t1 values(1, 'foo'), (2, 'bar'); insert into t1 select * from t1; insert into t1 select * from t1; diff --git a/mysql-test/r/status2.result b/mysql-test/r/status2.result new file mode 100644 index 00000000000..146fb2adbaf --- /dev/null +++ b/mysql-test/r/status2.result @@ -0,0 +1,73 @@ +# +# Bug#24289 Status Variable "Questions" gets wrong values with Stored Routines +# +FLUSH STATUS; +CREATE FUNCTION testQuestion() RETURNS INTEGER +BEGIN +DECLARE foo INTEGER; +DECLARE bar INTEGER; +SET foo=1; +SET bar=2; +RETURN foo; +END $$ +CREATE PROCEDURE testQuestion2() +BEGIN +SELECT 1; +END $$ +DROP TABLE IF EXISTS t1,t2; +CREATE TABLE t1 (c1 INT); +CREATE TABLE t2 (c1 INT); +CREATE EVENT ev1 ON SCHEDULE EVERY 1 SECOND +DO INSERT INTO t1 VALUES(1); +Assert Questions == 7 +SHOW STATUS LIKE 'Questions'; +Variable_name Value +Questions 7 +SELECT testQuestion(); +testQuestion() +1 +Assert Questions == 9 +SHOW STATUS LIKE 'Questions'; +Variable_name Value +Questions 9 +CALL testQuestion2(); +1 +1 +Assert Questions == 11 +SHOW STATUS LIKE 'Questions'; +Variable_name Value +Questions 11 +SELECT 1; +1 +1 +Assert Questions == 13 +SHOW STATUS LIKE 'Questions'; +Variable_name Value +Questions 13 +SELECT 1; +1 +1 +Assert Questions == 14 +SHOW STATUS LIKE 'Questions'; +Variable_name Value +Questions 14 +CREATE TRIGGER trigg1 AFTER INSERT ON t1 +FOR EACH ROW BEGIN +INSERT INTO t2 VALUES (1); +END; +$$ +Assert Questions == 16 +SHOW STATUS LIKE 'Questions'; +Variable_name Value +Questions 16 +INSERT INTO t1 VALUES (1); +Assert Questions == 18 +SHOW STATUS LIKE 'Questions'; +Variable_name Value +Questions 18 +DROP PROCEDURE testQuestion2; +DROP TRIGGER trigg1; +DROP FUNCTION testQuestion; +DROP EVENT ev1; +DROP TABLE t1,t2; +End of 6.0 tests diff --git a/mysql-test/t/myisampack.test b/mysql-test/t/myisampack.test index 99767f81033..3b55154d433 100644 --- a/mysql-test/t/myisampack.test +++ b/mysql-test/t/myisampack.test @@ -38,7 +38,7 @@ DROP TABLE t1; --disable_warnings drop table if exists t1; --enable_warnings -create table t1(f1 int, f2 varchar(255)); +create table t1(f1 int, f2 char(255)); insert into t1 values(1, 'foo'), (2, 'bar'); insert into t1 select * from t1; insert into t1 select * from t1; diff --git a/mysql-test/t/status2.test b/mysql-test/t/status2.test new file mode 100644 index 00000000000..2d1541c54f2 --- /dev/null +++ b/mysql-test/t/status2.test @@ -0,0 +1,68 @@ +--source include/not_embedded.inc + +--echo # +--echo # Bug#24289 Status Variable "Questions" gets wrong values with Stored Routines +--echo # +FLUSH STATUS; +DELIMITER $$; +CREATE FUNCTION testQuestion() RETURNS INTEGER +BEGIN + DECLARE foo INTEGER; + DECLARE bar INTEGER; + SET foo=1; + SET bar=2; + RETURN foo; +END $$ +CREATE PROCEDURE testQuestion2() +BEGIN + SELECT 1; +END $$ +DELIMITER ;$$ +--disable_warnings +DROP TABLE IF EXISTS t1,t2; +--enable_warnings +CREATE TABLE t1 (c1 INT); +CREATE TABLE t2 (c1 INT); +CREATE EVENT ev1 ON SCHEDULE EVERY 1 SECOND + DO INSERT INTO t1 VALUES(1); + +--echo Assert Questions == 7 +SHOW STATUS LIKE 'Questions'; +SELECT testQuestion(); +--echo Assert Questions == 9 +SHOW STATUS LIKE 'Questions'; +CALL testQuestion2(); +--echo Assert Questions == 11 +SHOW STATUS LIKE 'Questions'; +SELECT 1; +--echo Assert Questions == 13 +SHOW STATUS LIKE 'Questions'; +connect (con1,localhost,root,,); +connection con1; +SELECT 1; +connection default; +disconnect con1; +--echo Assert Questions == 14 +SHOW STATUS LIKE 'Questions'; +DELIMITER $$; +CREATE TRIGGER trigg1 AFTER INSERT ON t1 + FOR EACH ROW BEGIN + INSERT INTO t2 VALUES (1); + END; +$$ +DELIMITER ;$$ +--echo Assert Questions == 16 +SHOW STATUS LIKE 'Questions'; +INSERT INTO t1 VALUES (1); +--echo Assert Questions == 18 +SHOW STATUS LIKE 'Questions'; +# TODO: Uncomment the lines below when FLUSH GLOBAL STATUS is implemented. +# FLUSH STATUS; +# SHOW GLOBAL STATUS LIKE 'Questions'; +DROP PROCEDURE testQuestion2; +DROP TRIGGER trigg1; +DROP FUNCTION testQuestion; +DROP EVENT ev1; +DROP TABLE t1,t2; +--echo End of 6.0 tests + diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 32e0dd1542c..d52ad5c6671 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -6867,12 +6867,6 @@ The minimum value for this variable is 4096.", {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; -static int show_question(THD *thd, SHOW_VAR *var, char *buff) -{ - var->type= SHOW_LONGLONG; - var->value= (char *)&thd->query_id; - return 0; -} static int show_net_compression(THD *thd, SHOW_VAR *var, char *buff) { @@ -7289,7 +7283,7 @@ SHOW_VAR status_vars[]= { {"Qcache_queries_in_cache", (char*) &query_cache.queries_in_cache, SHOW_LONG_NOFLUSH}, {"Qcache_total_blocks", (char*) &query_cache.total_blocks, SHOW_LONG_NOFLUSH}, #endif /*HAVE_QUERY_CACHE*/ - {"Questions", (char*) &show_question, SHOW_FUNC}, + {"Questions", (char*) offsetof(STATUS_VAR, questions), SHOW_LONG_STATUS}, #ifdef HAVE_REPLICATION {"Rpl_status", (char*) &show_rpl_status, SHOW_FUNC}, #endif diff --git a/sql/sql_class.h b/sql/sql_class.h index f5cf31d1030..96b73ea76a2 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -456,8 +456,15 @@ typedef struct system_status_var ulong com_stmt_fetch; ulong com_stmt_reset; ulong com_stmt_close; - /* + Number of statements sent from the client + */ + ulong questions; + /* + IMPORTANT! + SEE last_system_status_var DEFINITION BELOW. + Below 'last_system_status_var' are all variables which doesn't make any + sense to add to the /global/ status variable counter. Status variables which it does not make sense to add to global status variable counter */ @@ -470,7 +477,7 @@ typedef struct system_status_var counter */ -#define last_system_status_var com_stmt_close +#define last_system_status_var questions void mark_transaction_to_rollback(THD *thd, bool all); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index f518e1ef9e8..bc10cadad48 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -971,8 +971,24 @@ bool dispatch_command(enum enum_server_command command, THD *thd, thd->set_time(); VOID(pthread_mutex_lock(&LOCK_thread_count)); thd->query_id= global_query_id; - if (command != COM_STATISTICS && command != COM_PING) + + switch( command ) { + /* Ignore these statements. */ + case COM_STATISTICS: + case COM_PING: + break; + /* Only increase id on these statements but don't count them. */ + case COM_STMT_PREPARE: + case COM_STMT_CLOSE: + case COM_STMT_RESET: next_query_id(); + break; + /* Increase id and count all other statements. */ + default: + statistic_increment(thd->status_var.questions, &LOCK_status); + next_query_id(); + } + thread_running++; /* TODO: set thd->lex->sql_command to SQLCOM_END here */ VOID(pthread_mutex_unlock(&LOCK_thread_count)); @@ -1229,6 +1245,10 @@ bool dispatch_command(enum enum_server_command command, THD *thd, VOID(pthread_mutex_lock(&LOCK_thread_count)); thd->query_length= length; thd->query= beginning_of_next_stmt; + /* + Count each statement from the client. + */ + statistic_increment(thd->status_var.questions, &LOCK_status); thd->query_id= next_query_id(); thd->set_time(); /* Reset the query start time. */ /* TODO: set thd->lex->sql_command to SQLCOM_END here */ From 7df22ce11ed38ab89e854c8d0a8040f0f37d64f9 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Wed, 17 Dec 2008 17:24:34 +0400 Subject: [PATCH 089/137] BUG#39746 - Debug flag breaks struct definition (server crash) Altering a table with fulltext index[es] which use pluggable fulltext parser may cause server crash in debug builds. The problem was that ALTER TABLE code wrongly assigned fulltext parser name. Also fixed that altering a table with fulltext index[es] leave stale fulltext parser locks, which prevent fulltext parsers from being uninstalled after ALTER TABLE. --- mysql-test/include/have_simple_parser.inc | 16 ++++++++++++++++ mysql-test/mysql-test-run.pl | 13 +++++++++++++ mysql-test/r/fulltext_plugin.result | 5 +++++ mysql-test/r/have_simple_parser.require | 2 ++ mysql-test/t/fulltext_plugin-master.opt | 1 + mysql-test/t/fulltext_plugin.test | 10 ++++++++++ sql/sql_table.cc | 2 +- sql/table.cc | 23 ++++++++++++----------- 8 files changed, 60 insertions(+), 12 deletions(-) create mode 100644 mysql-test/include/have_simple_parser.inc create mode 100644 mysql-test/r/fulltext_plugin.result create mode 100644 mysql-test/r/have_simple_parser.require create mode 100644 mysql-test/t/fulltext_plugin-master.opt create mode 100644 mysql-test/t/fulltext_plugin.test diff --git a/mysql-test/include/have_simple_parser.inc b/mysql-test/include/have_simple_parser.inc new file mode 100644 index 00000000000..c85786bd524 --- /dev/null +++ b/mysql-test/include/have_simple_parser.inc @@ -0,0 +1,16 @@ +# +# Check if server has support for loading udf's +# i.e it will support dlopen +# +--require r/have_dynamic_loading.require +disable_query_log; +show variables like 'have_dynamic_loading'; +enable_query_log; + +# +# Check if the variable SIMPLE_PARSER is set +# +--require r/have_simple_parser.require +disable_query_log; +eval select LENGTH('$SIMPLE_PARSER') > 0 as 'have_simple_parser'; +enable_query_log; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 20a0b639e84..a6105d2edff 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -163,6 +163,7 @@ our $exe_my_print_defaults; our $exe_perror; our $lib_udf_example; our $lib_example_plugin; +our $lib_simple_parser; our $exe_libtool; our $opt_bench= 0; @@ -1717,6 +1718,10 @@ sub executable_setup () { mtr_file_exists(vs_config_dirs('storage/example', 'ha_example.dll'), "$glob_basedir/storage/example/.libs/ha_example.so",); + # Look for the simple_parser library + $lib_simple_parser= + mtr_file_exists(vs_config_dirs('plugin/fulltext', 'mypluglib.dll'), + "$glob_basedir/plugin/fulltext/.libs/mypluglib.so",); } # Look for mysqltest executable @@ -2199,6 +2204,14 @@ sub environment_setup () { $ENV{'EXAMPLE_PLUGIN_OPT'}= ($lib_example_plugin ? "--plugin_dir=" . dirname($lib_example_plugin) : ""); + # ---------------------------------------------------- + # Add the path where mysqld will find mypluglib.so + # ---------------------------------------------------- + $ENV{'SIMPLE_PARSER'}= + ($lib_simple_parser ? basename($lib_simple_parser) : ""); + $ENV{'SIMPLE_PARSER_OPT'}= + ($lib_simple_parser ? "--plugin_dir=" . dirname($lib_simple_parser) : ""); + # ---------------------------------------------------- # Setup env so childs can execute myisampack and myisamchk # ---------------------------------------------------- diff --git a/mysql-test/r/fulltext_plugin.result b/mysql-test/r/fulltext_plugin.result new file mode 100644 index 00000000000..69ebbe07e9e --- /dev/null +++ b/mysql-test/r/fulltext_plugin.result @@ -0,0 +1,5 @@ +INSTALL PLUGIN simple_parser SONAME 'mypluglib.so'; +CREATE TABLE t1(a TEXT, b TEXT, FULLTEXT(a) WITH PARSER simple_parser); +ALTER TABLE t1 ADD FULLTEXT(b) WITH PARSER simple_parser; +DROP TABLE t1; +UNINSTALL PLUGIN simple_parser; diff --git a/mysql-test/r/have_simple_parser.require b/mysql-test/r/have_simple_parser.require new file mode 100644 index 00000000000..0e023bd6983 --- /dev/null +++ b/mysql-test/r/have_simple_parser.require @@ -0,0 +1,2 @@ +have_simple_parser +1 diff --git a/mysql-test/t/fulltext_plugin-master.opt b/mysql-test/t/fulltext_plugin-master.opt new file mode 100644 index 00000000000..a2554caa20b --- /dev/null +++ b/mysql-test/t/fulltext_plugin-master.opt @@ -0,0 +1 @@ +$SIMPLE_PARSER_OPT diff --git a/mysql-test/t/fulltext_plugin.test b/mysql-test/t/fulltext_plugin.test new file mode 100644 index 00000000000..31978dadc51 --- /dev/null +++ b/mysql-test/t/fulltext_plugin.test @@ -0,0 +1,10 @@ +--source include/have_simple_parser.inc + +# +# BUG#39746 - Debug flag breaks struct definition (server crash) +# +INSTALL PLUGIN simple_parser SONAME 'mypluglib.so'; +CREATE TABLE t1(a TEXT, b TEXT, FULLTEXT(a) WITH PARSER simple_parser); +ALTER TABLE t1 ADD FULLTEXT(b) WITH PARSER simple_parser; +DROP TABLE t1; +UNINSTALL PLUGIN simple_parser; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 8ce4c0b0a46..51b16ba0f43 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5870,7 +5870,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, if (key_info->flags & HA_USES_BLOCK_SIZE) key_create_info.block_size= key_info->block_size; if (key_info->flags & HA_USES_PARSER) - key_create_info.parser_name= *key_info->parser_name; + key_create_info.parser_name= *plugin_name(key_info->parser); if (key_info->flags & HA_SPATIAL) key_type= Key::SPATIAL; diff --git a/sql/table.cc b/sql/table.cc index 1de47a48513..95753e5353a 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -400,6 +400,8 @@ void init_tmp_table_share(THD *thd, TABLE_SHARE *share, const char *key, void free_table_share(TABLE_SHARE *share) { MEM_ROOT mem_root; + uint idx; + KEY *key_info; DBUG_ENTER("free_table_share"); DBUG_PRINT("enter", ("table: %s.%s", share->db.str, share->table_name.str)); DBUG_ASSERT(share->ref_count == 0); @@ -426,6 +428,16 @@ void free_table_share(TABLE_SHARE *share) plugin_unlock(NULL, share->db_plugin); share->db_plugin= NULL; + /* Release fulltext parsers */ + key_info= share->key_info; + for (idx= share->keys; idx; idx--, key_info++) + { + if (key_info->flags & HA_USES_PARSER) + { + plugin_unlock(NULL, key_info->parser); + key_info->flags= 0; + } + } /* We must copy mem_root from share because share is allocated through it */ memcpy((char*) &mem_root, (char*) &share->mem_root, sizeof(mem_root)); free_root(&mem_root, MYF(0)); // Free's share @@ -1943,22 +1955,11 @@ partititon_err: int closefrm(register TABLE *table, bool free_share) { int error=0; - uint idx; - KEY *key_info; DBUG_ENTER("closefrm"); DBUG_PRINT("enter", ("table: 0x%lx", (long) table)); if (table->db_stat) error=table->file->close(); - key_info= table->key_info; - for (idx= table->s->keys; idx; idx--, key_info++) - { - if (key_info->flags & HA_USES_PARSER) - { - plugin_unlock(NULL, key_info->parser); - key_info->flags= 0; - } - } my_free((char*) table->alias, MYF(MY_ALLOW_ZERO_PTR)); table->alias= 0; if (table->field) From 0737be6a5a854879d8d754a49eac29ee067aaa20 Mon Sep 17 00:00:00 2001 From: Horst Hunger Date: Wed, 17 Dec 2008 14:38:02 +0100 Subject: [PATCH 090/137] Final fix for bug#36773: Moved patch in 5.1 from rpl to bug team tree. --- mysql-test/include/wait_condition_sp.inc | 62 ++++++++++ mysql-test/r/rpl_init_slave_func.result | 67 +++++------ mysql-test/t/rpl_init_slave_func-slave.opt | 1 - mysql-test/t/rpl_init_slave_func.test | 134 +++++++++++---------- 4 files changed, 165 insertions(+), 99 deletions(-) create mode 100644 mysql-test/include/wait_condition_sp.inc delete mode 100644 mysql-test/t/rpl_init_slave_func-slave.opt diff --git a/mysql-test/include/wait_condition_sp.inc b/mysql-test/include/wait_condition_sp.inc new file mode 100644 index 00000000000..66301da557c --- /dev/null +++ b/mysql-test/include/wait_condition_sp.inc @@ -0,0 +1,62 @@ +# include/wait_condition.inc +# +# SUMMARY +# +# Waits until the passed statement returns true, or the operation +# times out. +# +# USAGE +# +# let $wait_condition= +# SELECT c = 3 FROM t; +# --source include/wait_condition.inc +# +# OR +# +# let $wait_timeout= 60; # Override default 30 seconds with 60. +# let $wait_condition= +# SELECT c = 3 FROM t; +# --source include/wait_condition.inc +# --echo Executed the test condition $wait_condition_reps times +# +# EXAMPLE +# events_bugs.test, events_time_zone.test +# + +--disable_query_log + +let $wait_counter= 300; +if ($wait_timeout) +{ + let $wait_counter= `SELECT $wait_timeout * 10`; +} +# Reset $wait_timeout so that its value won't be used on subsequent +# calls, and default will be used instead. +let $wait_timeout= 0; + +# Keep track of how many times the wait condition is tested +# This is used by some tests (e.g., main.status) +let $wait_condition_reps= 0; +while ($wait_counter) +{ + let $success= `$wait_condition`; + inc $wait_condition_reps; + if ($success) + { + let $wait_counter= 0; + } + if (!$success) + { + real_sleep 0.1; + dec $wait_counter; + } +} +if (!$success) +{ + echo Timeout in wait_condition.inc for $wait_condition; + show master status; + show slave status; +} + +--enable_query_log + diff --git a/mysql-test/r/rpl_init_slave_func.result b/mysql-test/r/rpl_init_slave_func.result index 3861f40e7d9..0d1f4d483d8 100644 --- a/mysql-test/r/rpl_init_slave_func.result +++ b/mysql-test/r/rpl_init_slave_func.result @@ -4,44 +4,43 @@ reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; -'#--------------------FN_DYNVARS_037_01-------------------------#' -SET @@global.init_slave = "SET @a = 10"; -'connect (con1,localhost,root,,)' -'connection con1' -SELECT @@global.init_slave; -@@global.init_slave -SET @a = 10 -'connection master' -'#--------------------FN_DYNVARS_037_02-------------------------#' -'check if value in slave opt file is executed' -'connection slave' -show variables like 'init_slave'; -Variable_name Value -init_slave set global max_connections=500 -show variables like 'max_connections'; -Variable_name Value -max_connections 500 -reset master; -'check if value in slave opt file doesnt apply to master' -'connection master' -show variables like 'init_slave'; -Variable_name Value -init_slave SET @a = 10 -show variables like 'max_connections'; -Variable_name Value -max_connections 151 -'connection slave' -'try creating a temporary variable in init_slave' +connection slave +SET @start_max_connections= @@global.max_connections; +SET @start_init_slave= @@global.init_slave; +SET @@global.init_slave = 'SET @@global.max_connections = @@global.max_connections + 1'; +DROP TABLE IF EXISTS t1; +CREATE TEMPORARY TABLE t1 AS SELECT @@global.init_slave AS my_column; +DESCRIBE t1; +Field Type Null Key Default Extra +my_column longtext NO NULL +DROP TABLE t1; +SELECT @@global.init_slave = 'SET @@global.max_connections = @@global.max_connections + 1'; +@@global.init_slave = 'SET @@global.max_connections = @@global.max_connections + 1' +1 +Expect 1 +SELECT @@global.max_connections= @start_max_connections; +@@global.max_connections= @start_max_connections +1 +Expect 1 +STOP SLAVE; +RESET MASTER; +RESET SLAVE; +START SLAVE; +SELECT @@global.max_connections = @start_max_connections + 1; +@@global.max_connections = @start_max_connections + 1 +1 +Expect 1 SET @@global.init_slave = "SET @a=5"; -stop slave; -reset slave; -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -start slave; +STOP SLAVE; +RESET MASTER; +RESET SLAVE; +START SLAVE; SHOW VARIABLES LIKE 'init_slave'; Variable_name Value init_slave SET @a=5 SELECT @a; @a NULL -'Bug#35365 SET statement in init_slave not execute if slave is restarted' -set global max_connections= default; +Expect NULL +SET @@global.max_connections= @start_max_connections; +SET @@global.init_slave= @start_init_slave; diff --git a/mysql-test/t/rpl_init_slave_func-slave.opt b/mysql-test/t/rpl_init_slave_func-slave.opt deleted file mode 100644 index 337e8a60d97..00000000000 --- a/mysql-test/t/rpl_init_slave_func-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---init-slave="set global max_connections=500" diff --git a/mysql-test/t/rpl_init_slave_func.test b/mysql-test/t/rpl_init_slave_func.test index b3d647f4394..f17cc1289b1 100644 --- a/mysql-test/t/rpl_init_slave_func.test +++ b/mysql-test/t/rpl_init_slave_func.test @@ -10,86 +10,92 @@ # # # Creation Date: 2008-03-08 # # Author: Rizwan # +# Modified: HHunger 2008-09-29 Fixed the bug by inserting the usual wait and # +# SQL-Satements to control master and slave, # +# deleted the sleep and made improvements like: # +# - Replaced the opt file by dynamic variables, # +# - Made the tests independant of the initial # +# values of the global variables, # +# - Reduced the test to the needed test case to # +# save run time, # +# - Beautification. # # # # Description: Test Cases of Dynamic System Variable init_slave # # that checks the behavior of this variable # # # -# Reference: http://dev.mysql.com/doc/refman/5.1/en/ # -# server-system-variables.html # +# Reference: # +# http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html # # # ############################################################################### source include/master-slave.inc; - ---echo '#--------------------FN_DYNVARS_037_01-------------------------#' -################################################################## -# Check if setting init_slave is changed in every new connection # -################################################################## - -SET @@global.init_slave = "SET @a = 10"; - ---echo 'connect (con1,localhost,root,,)' -connect (con1,localhost,root,,); ---echo 'connection con1' -connection con1; -SELECT @@global.init_slave; -disconnect con1; ---echo 'connection master' -connection master; - ---echo '#--------------------FN_DYNVARS_037_02-------------------------#' -#################################################### -# Begin the functionality Testing of init_slave # -#################################################### - -#==================================================== ---echo 'check if value in slave opt file is executed' -#==================================================== -save_master_pos; ---echo 'connection slave' +--echo connection slave connection slave; -sleep 1; -show variables like 'init_slave'; -show variables like 'max_connections'; -sync_with_master; -reset master; +# +# save the current values -#=============================================================== ---echo 'check if value in slave opt file doesnt apply to master' -#=============================================================== +SET @start_max_connections= @@global.max_connections; +SET @start_init_slave= @@global.init_slave; ---echo 'connection master' -connection master; -show variables like 'init_slave'; -show variables like 'max_connections'; -save_master_pos; ---echo 'connection slave' -connection slave; -sync_with_master; +# setting of a global value with an effect on the next start of the slave server +# check that @@global.init_slave could be set +let $my_init_slave= + 'SET @@global.max_connections = @@global.max_connections + 1'; +eval SET @@global.init_slave = $my_init_slave; -#======================================================= ---echo 'try creating a temporary variable in init_slave' -#======================================================= - -SET @@global.init_slave = "SET @a=5"; - -stop slave; ---wait_for_slave_to_stop -reset slave; -# Clean up old test tables +# show the data type of the variable --disable_warnings -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +DROP TABLE IF EXISTS t1; +CREATE TEMPORARY TABLE t1 AS SELECT @@global.init_slave AS my_column; --enable_warnings -start slave; - +DESCRIBE t1; +DROP TABLE t1; +# +# check that the new setting of @@global.init_slave becomes immediately visible +eval SELECT @@global.init_slave = $my_init_slave; +--echo Expect 1 +# wait for the slave threads have set the global variable. +let $wait_timeout= 90; +let $wait_condition= SELECT @@global.max_connections = @start_max_connections; +--source include/wait_condition_sp.inc +# check that the action in init_slave does not happen immediately +SELECT @@global.max_connections= @start_max_connections; +--echo Expect 1 +# +# reset of the server +STOP SLAVE; +--wait_for_slave_to_stop +RESET MASTER; +RESET SLAVE; +START SLAVE; +source include/wait_for_slave_to_start.inc; +# +# wait for the slave threads have set the global variable. +let $wait_timeout= 90; +let $wait_condition= SELECT @@global.max_connections = @start_max_connections + 1; +--source include/wait_condition_sp.inc +# check that the action in init_slave was executed and had the intended effect +SELECT @@global.max_connections = @start_max_connections + 1; +--echo Expect 1 +# +# Setting a variable(which is local to a session) and must not be visible +SET @@global.init_slave = "SET @a=5"; +# +STOP SLAVE; +--wait_for_slave_to_stop +RESET MASTER; +RESET SLAVE; +START SLAVE; +source include/wait_for_slave_to_start.inc; +# SHOW VARIABLES LIKE 'init_slave'; +# expect NULL SELECT @a; - ---echo 'Bug#35365 SET statement in init_slave not execute if slave is restarted' - -# Restore value -set global max_connections= default; - +--echo Expect NULL +# +# Clean up +SET @@global.max_connections= @start_max_connections; +SET @@global.init_slave= @start_init_slave; ################################################## # End of functionality Testing for init_slave # ################################################## From fcba66f10c0c4a577577dbe5c0f7550ffb88002c Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Wed, 17 Dec 2008 19:45:34 +0400 Subject: [PATCH 091/137] Bug#29263 disabled storage engines omitted in SHOW ENGINES Static disabled plugins|engines and dynamic plugins which installed but disabled are not visible in I_S PLUGINS|ENGINES tables because they are not stored into global plugin array. The fix: add such plugins|engines to plugin array with PLUGIN_IS_DISABLED status. I_S.ENGINES 'Transactions', 'XA', 'Savepoints' fields have NULL value in this case. --- mysql-test/r/warnings_engine_disabled.result | 10 ++++- .../suite/funcs_1/r/is_columns_is.result | 6 +-- mysql-test/suite/funcs_1/r/is_engines.result | 18 ++++----- mysql-test/t/warnings_engine_disabled.test | 9 ++++- sql/sql_plugin.cc | 40 ++++++++++--------- sql/sql_plugin.h | 1 + sql/sql_show.cc | 39 +++++++++++++++--- 7 files changed, 84 insertions(+), 39 deletions(-) diff --git a/mysql-test/r/warnings_engine_disabled.result b/mysql-test/r/warnings_engine_disabled.result index aa6170a60a7..e5d35fdaa5f 100644 --- a/mysql-test/r/warnings_engine_disabled.result +++ b/mysql-test/r/warnings_engine_disabled.result @@ -1,7 +1,15 @@ create table t1 (id int) engine=NDB; Warnings: +Warning 1286 Unknown table engine 'NDB' Warning 1266 Using storage engine MyISAM for table 't1' alter table t1 engine=NDB; Warnings: -Warning 1266 Using storage engine MyISAM for table 't1' +Warning 1286 Unknown table engine 'NDB' drop table t1; +SELECT ENGINE, SUPPORT FROM INFORMATION_SCHEMA.ENGINES WHERE ENGINE='ndbcluster'; +ENGINE SUPPORT +ndbcluster NO +SELECT PLUGIN_NAME, PLUGIN_STATUS FROM INFORMATION_SCHEMA.PLUGINS WHERE +PLUGIN_NAME='ndbcluster'; +PLUGIN_NAME PLUGIN_STATUS +ndbcluster DISABLED diff --git a/mysql-test/suite/funcs_1/r/is_columns_is.result b/mysql-test/suite/funcs_1/r/is_columns_is.result index 15466887ecc..94aa75c6db2 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_is.result +++ b/mysql-test/suite/funcs_1/r/is_columns_is.result @@ -43,10 +43,10 @@ NULL information_schema COLUMN_PRIVILEGES TABLE_NAME 4 NO varchar 64 192 NULL N NULL information_schema COLUMN_PRIVILEGES TABLE_SCHEMA 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema ENGINES COMMENT 3 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select NULL information_schema ENGINES ENGINE 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select -NULL information_schema ENGINES SAVEPOINTS 6 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select +NULL information_schema ENGINES SAVEPOINTS 6 NULL YES varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select NULL information_schema ENGINES SUPPORT 2 NO varchar 8 24 NULL NULL utf8 utf8_general_ci varchar(8) select -NULL information_schema ENGINES TRANSACTIONS 4 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select -NULL information_schema ENGINES XA 5 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select +NULL information_schema ENGINES TRANSACTIONS 4 NULL YES varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select +NULL information_schema ENGINES XA 5 NULL YES varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select NULL information_schema EVENTS CHARACTER_SET_CLIENT 22 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select NULL information_schema EVENTS COLLATION_CONNECTION 23 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select NULL information_schema EVENTS CREATED 17 0000-00-00 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime select diff --git a/mysql-test/suite/funcs_1/r/is_engines.result b/mysql-test/suite/funcs_1/r/is_engines.result index ba98ddd8f1e..9965fc5ad73 100644 --- a/mysql-test/suite/funcs_1/r/is_engines.result +++ b/mysql-test/suite/funcs_1/r/is_engines.result @@ -31,27 +31,27 @@ Field Type Null Key Default Extra ENGINE varchar(64) NO SUPPORT varchar(8) NO COMMENT varchar(80) NO -TRANSACTIONS varchar(3) NO -XA varchar(3) NO -SAVEPOINTS varchar(3) NO +TRANSACTIONS varchar(3) YES NULL +XA varchar(3) YES NULL +SAVEPOINTS varchar(3) YES NULL SHOW CREATE TABLE information_schema.ENGINES; Table Create Table ENGINES CREATE TEMPORARY TABLE `ENGINES` ( `ENGINE` varchar(64) NOT NULL DEFAULT '', `SUPPORT` varchar(8) NOT NULL DEFAULT '', `COMMENT` varchar(80) NOT NULL DEFAULT '', - `TRANSACTIONS` varchar(3) NOT NULL DEFAULT '', - `XA` varchar(3) NOT NULL DEFAULT '', - `SAVEPOINTS` varchar(3) NOT NULL DEFAULT '' + `TRANSACTIONS` varchar(3) DEFAULT NULL, + `XA` varchar(3) DEFAULT NULL, + `SAVEPOINTS` varchar(3) DEFAULT NULL ) ENGINE=MEMORY DEFAULT CHARSET=utf8 SHOW COLUMNS FROM information_schema.ENGINES; Field Type Null Key Default Extra ENGINE varchar(64) NO SUPPORT varchar(8) NO COMMENT varchar(80) NO -TRANSACTIONS varchar(3) NO -XA varchar(3) NO -SAVEPOINTS varchar(3) NO +TRANSACTIONS varchar(3) YES NULL +XA varchar(3) YES NULL +SAVEPOINTS varchar(3) YES NULL ######################################################################## # Testcases 3.2.1.3-3.2.1.5 + 3.2.1.8-3.2.1.12: INSERT/UPDATE/DELETE and # DDL on INFORMATION_SCHEMA tables are not supported diff --git a/mysql-test/t/warnings_engine_disabled.test b/mysql-test/t/warnings_engine_disabled.test index 0b09cff7b1e..b8751a062b7 100644 --- a/mysql-test/t/warnings_engine_disabled.test +++ b/mysql-test/t/warnings_engine_disabled.test @@ -4,7 +4,7 @@ # disable_query_log; --require r/true.require -select support = 'Disabled' as `TRUE` from information_schema.engines where engine = 'ndbcluster'; +select support = 'NO' as `TRUE` from information_schema.engines where engine = 'ndbcluster'; enable_query_log; @@ -16,4 +16,9 @@ create table t1 (id int) engine=NDB; alter table t1 engine=NDB; drop table t1; - +# +# Bug#29263 disabled storage engines omitted in SHOW ENGINES +# +SELECT ENGINE, SUPPORT FROM INFORMATION_SCHEMA.ENGINES WHERE ENGINE='ndbcluster'; +SELECT PLUGIN_NAME, PLUGIN_STATUS FROM INFORMATION_SCHEMA.PLUGINS WHERE +PLUGIN_NAME='ndbcluster'; diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 13b2bfef24d..0df1631294b 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -751,21 +751,22 @@ static bool plugin_add(MEM_ROOT *tmp_root, tmp.name.length= name_len; tmp.ref_count= 0; tmp.state= PLUGIN_IS_UNINITIALIZED; - if (!test_plugin_options(tmp_root, &tmp, argc, argv, true)) + if (test_plugin_options(tmp_root, &tmp, argc, argv, true)) + tmp.state= PLUGIN_IS_DISABLED; + + if ((tmp_plugin_ptr= plugin_insert_or_reuse(&tmp))) { - if ((tmp_plugin_ptr= plugin_insert_or_reuse(&tmp))) + plugin_array_version++; + if (!my_hash_insert(&plugin_hash[plugin->type], (uchar*)tmp_plugin_ptr)) { - plugin_array_version++; - if (!my_hash_insert(&plugin_hash[plugin->type], (uchar*)tmp_plugin_ptr)) - { - init_alloc_root(&tmp_plugin_ptr->mem_root, 4096, 4096); - DBUG_RETURN(FALSE); - } - tmp_plugin_ptr->state= PLUGIN_IS_FREED; + init_alloc_root(&tmp_plugin_ptr->mem_root, 4096, 4096); + DBUG_RETURN(FALSE); } - mysql_del_sys_var_chain(tmp.system_vars); - goto err; + tmp_plugin_ptr->state= PLUGIN_IS_FREED; } + mysql_del_sys_var_chain(tmp.system_vars); + goto err; + /* plugin was disabled */ plugin_dl_del(dl); DBUG_RETURN(FALSE); @@ -1145,11 +1146,12 @@ int plugin_init(int *argc, char **argv, int flags) tmp.plugin= plugin; tmp.name.str= (char *)plugin->name; tmp.name.length= strlen(plugin->name); - + tmp.state= 0; free_root(&tmp_root, MYF(MY_MARK_BLOCKS_FREE)); if (test_plugin_options(&tmp_root, &tmp, argc, argv, def_enabled)) - continue; - + tmp.state= PLUGIN_IS_DISABLED; + else + tmp.state= PLUGIN_IS_UNINITIALIZED; if (register_builtin(plugin, &tmp, &plugin_ptr)) goto err_unlock; @@ -1159,7 +1161,8 @@ int plugin_init(int *argc, char **argv, int flags) my_strcasecmp(&my_charset_latin1, plugin->name, "CSV")) continue; - if (plugin_initialize(plugin_ptr)) + if (plugin_ptr->state == PLUGIN_IS_UNINITIALIZED && + plugin_initialize(plugin_ptr)) goto err_unlock; /* @@ -1246,8 +1249,6 @@ static bool register_builtin(struct st_mysql_plugin *plugin, struct st_plugin_int **ptr) { DBUG_ENTER("register_builtin"); - - tmp->state= PLUGIN_IS_UNINITIALIZED; tmp->ref_count= 0; tmp->plugin_dl= 0; @@ -1296,7 +1297,7 @@ bool plugin_register_builtin(THD *thd, struct st_mysql_plugin *plugin) if (test_plugin_options(thd->mem_root, &tmp, &dummy_argc, NULL, true)) goto end; - + tmp.state= PLUGIN_IS_UNINITIALIZED; if ((result= register_builtin(plugin, &tmp, &ptr))) mysql_del_sys_var_chain(tmp.system_vars); @@ -1555,7 +1556,8 @@ void plugin_shutdown(void) We loop through all plugins and call deinit() if they have one. */ for (i= 0; i < count; i++) - if (!(plugins[i]->state & (PLUGIN_IS_UNINITIALIZED | PLUGIN_IS_FREED))) + if (!(plugins[i]->state & (PLUGIN_IS_UNINITIALIZED | PLUGIN_IS_FREED | + PLUGIN_IS_DISABLED))) { sql_print_information("Plugin '%s' will be forced to shutdown", plugins[i]->name.str); diff --git a/sql/sql_plugin.h b/sql/sql_plugin.h index e8f2cb6ee5e..8ae38d58845 100644 --- a/sql/sql_plugin.h +++ b/sql/sql_plugin.h @@ -54,6 +54,7 @@ typedef struct st_mysql_show_var SHOW_VAR; #define PLUGIN_IS_UNINITIALIZED 4 #define PLUGIN_IS_READY 8 #define PLUGIN_IS_DYING 16 +#define PLUGIN_IS_DISABLED 32 /* A handle for the dynamic library containing a plugin or plugins. */ diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 3fd06aba672..0128fd43d28 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -124,6 +124,9 @@ static my_bool show_plugins(THD *thd, plugin_ref plugin, case PLUGIN_IS_READY: table->field[2]->store(STRING_WITH_LEN("ACTIVE"), cs); break; + case PLUGIN_IS_DISABLED: + table->field[2]->store(STRING_WITH_LEN("DISABLED"), cs); + break; default: DBUG_ASSERT(0); } @@ -3930,6 +3933,25 @@ static my_bool iter_schema_engines(THD *thd, plugin_ref plugin, handlerton *default_type= ha_default_handlerton(thd); DBUG_ENTER("iter_schema_engines"); + + /* Disabled plugins */ + if (plugin_state(plugin) != PLUGIN_IS_READY) + { + + struct st_mysql_plugin *plug= plugin_decl(plugin); + if (!(wild && wild[0] && + wild_case_compare(scs, plug->name,wild))) + { + restore_record(table, s->default_values); + table->field[0]->store(plug->name, strlen(plug->name), scs); + table->field[1]->store(C_STRING_WITH_LEN("NO"), scs); + table->field[2]->store(plug->descr, strlen(plug->descr), scs); + if (schema_table_store_record(thd, table)) + DBUG_RETURN(1); + } + DBUG_RETURN(0); + } + if (!(hton->flags & HTON_HIDDEN)) { LEX_STRING *name= plugin_name(plugin); @@ -3950,10 +3972,13 @@ static my_bool iter_schema_engines(THD *thd, plugin_ref plugin, strlen(plugin_decl(plugin)->descr), scs); tmp= &yesno[test(hton->commit)]; table->field[3]->store(tmp->str, tmp->length, scs); + table->field[3]->set_notnull(); tmp= &yesno[test(hton->prepare)]; table->field[4]->store(tmp->str, tmp->length, scs); + table->field[4]->set_notnull(); tmp= &yesno[test(hton->savepoint_set)]; table->field[5]->store(tmp->str, tmp->length, scs); + table->field[5]->set_notnull(); if (schema_table_store_record(thd, table)) DBUG_RETURN(1); @@ -3964,8 +3989,12 @@ static my_bool iter_schema_engines(THD *thd, plugin_ref plugin, int fill_schema_engines(THD *thd, TABLE_LIST *tables, COND *cond) { - return plugin_foreach(thd, iter_schema_engines, - MYSQL_STORAGE_ENGINE_PLUGIN, tables->table); + DBUG_ENTER("fill_schema_engines"); + if (plugin_foreach_with_mask(thd, iter_schema_engines, + MYSQL_STORAGE_ENGINE_PLUGIN, + ~PLUGIN_IS_FREED, tables->table)) + DBUG_RETURN(1); + DBUG_RETURN(0); } @@ -6162,9 +6191,9 @@ ST_FIELD_INFO engines_fields_info[]= {"ENGINE", 64, MYSQL_TYPE_STRING, 0, 0, "Engine", SKIP_OPEN_TABLE}, {"SUPPORT", 8, MYSQL_TYPE_STRING, 0, 0, "Support", SKIP_OPEN_TABLE}, {"COMMENT", 80, MYSQL_TYPE_STRING, 0, 0, "Comment", SKIP_OPEN_TABLE}, - {"TRANSACTIONS", 3, MYSQL_TYPE_STRING, 0, 0, "Transactions", SKIP_OPEN_TABLE}, - {"XA", 3, MYSQL_TYPE_STRING, 0, 0, "XA", SKIP_OPEN_TABLE}, - {"SAVEPOINTS", 3 ,MYSQL_TYPE_STRING, 0, 0, "Savepoints", SKIP_OPEN_TABLE}, + {"TRANSACTIONS", 3, MYSQL_TYPE_STRING, 0, 1, "Transactions", SKIP_OPEN_TABLE}, + {"XA", 3, MYSQL_TYPE_STRING, 0, 1, "XA", SKIP_OPEN_TABLE}, + {"SAVEPOINTS", 3 ,MYSQL_TYPE_STRING, 0, 1, "Savepoints", SKIP_OPEN_TABLE}, {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; From 8d8983127534fe7962ac5de383f32bce2efd1261 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Fri, 19 Dec 2008 01:28:51 +0100 Subject: [PATCH 092/137] Disable part of innodb-autoinc.test, because the MySQL server asserts when compiled --with-debug, due to bug 39828, "autoinc wraps around when offset and increment > 1". This change should be reverted when that bug is fixed (and a a few other minor changes to the test as described in comments). --- mysql-test/r/innodb-autoinc.result | 12 +++++----- mysql-test/t/innodb-autoinc.test | 35 ++++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/mysql-test/r/innodb-autoinc.result b/mysql-test/r/innodb-autoinc.result index 589bf2f30b0..1e4b088c6cd 100644 --- a/mysql-test/r/innodb-autoinc.result +++ b/mysql-test/r/innodb-autoinc.result @@ -471,10 +471,9 @@ SHOW VARIABLES LIKE "%auto_inc%"; Variable_name Value auto_increment_increment 2 auto_increment_offset 10 -INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL); +INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL); SELECT * FROM t1; c1 -0 1 18446744073709551603 18446744073709551604 @@ -505,12 +504,13 @@ SHOW VARIABLES LIKE "%auto_inc%"; Variable_name Value auto_increment_increment 5 auto_increment_offset 7 -INSERT INTO t1 VALUES (NULL),(NULL), (NULL); -Got one of the listed errors +INSERT INTO t1 VALUES (NULL),(NULL); SELECT * FROM t1; c1 1 18446744073709551603 +18446744073709551607 +18446744073709551612 DROP TABLE t1; SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; SET @@INSERT_ID=1; @@ -572,12 +572,10 @@ SHOW VARIABLES LIKE "%auto_inc%"; Variable_name Value auto_increment_increment 65535 auto_increment_offset 65535 -INSERT INTO t1 VALUES (NULL),(NULL), (NULL); +INSERT INTO t1 VALUES (NULL); SELECT * FROM t1; c1 1 -65534 -65535 18446744073709551610 18446744073709551615 DROP TABLE t1; diff --git a/mysql-test/t/innodb-autoinc.test b/mysql-test/t/innodb-autoinc.test index 172913349db..021e67e699f 100644 --- a/mysql-test/t/innodb-autoinc.test +++ b/mysql-test/t/innodb-autoinc.test @@ -302,7 +302,18 @@ SHOW VARIABLES LIKE "%auto_inc%"; # This should fail because of overflow but it doesn't, it seems to be # a MySQL server bug. It wraps around to 0 for the last value. # See MySQL Bug# 39828 -INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL); +# +# Instead of wrapping around, it asserts when MySQL is compiled --with-debug +# (see sql/handler.cc:handler::update_auto_increment()). Don't test for +# overflow until Bug #39828 is fixed. +# +# Since this asserts when compiled --with-debug, we can't properly test this +# until Bug #39828 is fixed. For now, this test is meaningless. +#if Bug #39828 is fixed +#INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL); +#else +INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL); +#endif SELECT * FROM t1; DROP TABLE t1; @@ -324,8 +335,16 @@ SHOW VARIABLES LIKE "%auto_inc%"; # a duplicate entry message because of a MySQL server bug, it wraps # around. See MySQL Bug# 39828, once MySQL fix the bug we can replace # the ER_DUP_ENTRY, 1062 below with the appropriate error message --- error ER_DUP_ENTRY,1062 -INSERT INTO t1 VALUES (NULL),(NULL), (NULL); +# +# Since this asserts when compiled --with-debug, we can't properly test this +# until Bug #39828 is fixed. For now, this test is meaningless. +#if Bug #39828 is fixed +# Still need to fix this error code, error should mention overflow +#-- error ER_DUP_ENTRY,1062 +#INSERT INTO t1 VALUES (NULL),(NULL), (NULL); +#else +INSERT INTO t1 VALUES (NULL),(NULL); +#endif SELECT * FROM t1; DROP TABLE t1; @@ -368,6 +387,14 @@ SHOW VARIABLES LIKE "%auto_inc%"; # See MySQL Bug# 39828, once MySQL fix the bug we can enable the error # code expected test. # -- error ER_AUTOINC_READ_FAILED,1467 -INSERT INTO t1 VALUES (NULL),(NULL), (NULL); +# +# Since this asserts when compiled --with-debug, we can't properly test this +# until Bug #39828 is fixed. For now, this test is meaningless. +#if Bug #39828 is fixed +#-- error ER_AUTOINC_READ_FAILED,1467 +#INSERT INTO t1 VALUES (NULL),(NULL); +#else +INSERT INTO t1 VALUES (NULL); +#endif SELECT * FROM t1; DROP TABLE t1; From 4effc0bc9a28ef7bd0065f22f6d8468e70ab4aaf Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Fri, 19 Dec 2008 09:23:15 +0100 Subject: [PATCH 093/137] Bug#36312: InnoDB DATA_FREE BUG? Problem is that DATA_FREE in SHOW TABLE STATUS is not correct when not using innodb_file_per_table. The solution is to use I_S.PARTITIONS instead. This is only a small fix for correcting mean record length and always return 0 if the table is empty. --- sql/ha_partition.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 47d2d36ac8d..c8b068ca2be 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -4815,7 +4815,7 @@ int ha_partition::info(uint flag) /* Calculates statistical variables records: Estimate of number records in table - We report sum (always at least 2) + We report sum (always at least 2 if not empty) deleted: Estimate of number holes in the table due to deletes We report sum @@ -4854,13 +4854,13 @@ int ha_partition::info(uint flag) stats.check_time= file->stats.check_time; } } while (*(++file_array)); - if (stats.records < 2 && + if (stats.records && stats.records < 2 && !(m_file[0]->ha_table_flags() & HA_STATS_RECORDS_IS_EXACT)) stats.records= 2; if (stats.records > 0) stats.mean_rec_length= (ulong) (stats.data_file_length / stats.records); else - stats.mean_rec_length= 1; //? What should we set here + stats.mean_rec_length= 0; } if (flag & HA_STATUS_CONST) { From d6e7b04a03282668b4c7713c30a2a1824394f8a3 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 19 Dec 2008 08:47:28 -0200 Subject: [PATCH 094/137] Bug#41612: resolve_stack_dump does not decode 5.1 stack trace resolve_stack_dump is not able to decode a stack trace produced by glibc's backtrace() functions. The problem is that the stack trace addresses are printed between brackets and the utility is not able to ignore the brackets. The solution is to modify resolve_stack_dump so it can recognize stack trace addresses surrounded by brackets. e.g. [0xdeadbeef]. --- extra/resolve_stack_dump.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extra/resolve_stack_dump.c b/extra/resolve_stack_dump.c index 5606c17ecf3..447d63890bd 100644 --- a/extra/resolve_stack_dump.c +++ b/extra/resolve_stack_dump.c @@ -290,7 +290,8 @@ static void do_resolve() char buf[1024], *p; while (fgets(buf, sizeof(buf), fp_dump)) { - p = buf; + /* skip bracket */ + p= (p= strchr(buf, '[')) ? p+1 : buf; /* skip space */ while (my_isspace(&my_charset_latin1,*p)) ++p; From 05ae989e76aaab49537ac8b83ed8358be0476991 Mon Sep 17 00:00:00 2001 From: Sergey Petrunia Date: Fri, 19 Dec 2008 16:38:39 +0300 Subject: [PATCH 095/137] BUG#40974: Incorrect query results when using clause evaluated using range check - QUICK_INDEX_MERGE_SELECT deinitializes its rnd_pos() scan when it reaches EOF, but we need to make the deinitialization in QUICK_INDEX_MERGE_SELECT destructor also. This is because certain execution strategies can stop scanning without reaching EOF, then then try to do a full table scan on this table. Failure to deinitialize caused the full scan to use (already empty) table->sort and produce zero records. --- mysql-test/r/index_merge.result | 28 ++++++++++++++++++++++++++++ mysql-test/t/index_merge.test | 26 ++++++++++++++++++++++++++ sql/opt_range.cc | 3 +++ 3 files changed, 57 insertions(+) diff --git a/mysql-test/r/index_merge.result b/mysql-test/r/index_merge.result index ed397e8fdc8..f3fce29c910 100644 --- a/mysql-test/r/index_merge.result +++ b/mysql-test/r/index_merge.result @@ -527,4 +527,32 @@ b a y z DROP TABLE t1; +# +# BUG#40974: Incorrect query results when using clause evaluated using range check +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int); +insert into t1 values (1),(2); +create table t2(a int, b int); +insert into t2 values (1,1), (2, 1000); +create table t3 (a int, b int, filler char(100), key(a), key(b)); +insert into t3 select 1000, 1000,'filler' from t0 A, t0 B, t0 C; +insert into t3 values (1,1,'data'); +insert into t3 values (1,1,'data'); +The plan should be ALL/ALL/ALL(Range checked for each record (index map: 0x3) +explain select * from t1 +where exists (select 1 from t2, t3 +where t2.a=t1.a and (t3.a=t2.b or t3.b=t2.b or t3.b=t2.b+1)); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY t3 ALL a,b NULL NULL NULL 1002 Range checked for each record (index map: 0x3) +select * from t1 +where exists (select 1 from t2, t3 +where t2.a=t1.a and (t3.a=t2.b or t3.b=t2.b or t3.b=t2.b+1)); +a +1 +2 +drop table t0, t1, t2, t3; End of 5.0 tests diff --git a/mysql-test/t/index_merge.test b/mysql-test/t/index_merge.test index 970b9a87454..7f176a4cd11 100644 --- a/mysql-test/t/index_merge.test +++ b/mysql-test/t/index_merge.test @@ -477,4 +477,30 @@ SELECT b,a from t1 WHERE (b!='c' AND b!='f' && b!='h') OR DROP TABLE t1; +--echo # +--echo # BUG#40974: Incorrect query results when using clause evaluated using range check +--echo # +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t1 (a int); +insert into t1 values (1),(2); +create table t2(a int, b int); +insert into t2 values (1,1), (2, 1000); +create table t3 (a int, b int, filler char(100), key(a), key(b)); + +insert into t3 select 1000, 1000,'filler' from t0 A, t0 B, t0 C; +insert into t3 values (1,1,'data'); +insert into t3 values (1,1,'data'); +-- echo The plan should be ALL/ALL/ALL(Range checked for each record (index map: 0x3) +explain select * from t1 +where exists (select 1 from t2, t3 + where t2.a=t1.a and (t3.a=t2.b or t3.b=t2.b or t3.b=t2.b+1)); + +select * from t1 +where exists (select 1 from t2, t3 + where t2.a=t1.a and (t3.a=t2.b or t3.b=t2.b or t3.b=t2.b+1)); + +drop table t0, t1, t2, t3; + --echo End of 5.0 tests diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 204ebdb6f33..744415fa2fe 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1109,6 +1109,9 @@ QUICK_INDEX_MERGE_SELECT::~QUICK_INDEX_MERGE_SELECT() quick->file= NULL; quick_selects.delete_elements(); delete pk_quick_select; + /* It's ok to call the next two even if they are already deinitialized */ + end_read_record(&read_record); + free_io_cache(head); free_root(&alloc,MYF(0)); DBUG_VOID_RETURN; } From 26e804d0a78c31c9206b920245821cad42b0724f Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Tue, 23 Dec 2008 18:08:04 +0400 Subject: [PATCH 096/137] Bug#37575 UCASE fails on monthname The MONTHNAME/DAYNAME functions returns binary string, so the LOWER/UPPER functions are not effective on the result of MONTHNAME/DAYNAME call. Character set of the MONTHNAME/DAYNAME function result has been changed to connection character set. --- include/m_ctype.h | 1 + mysql-test/r/ctype_ucs.result | 53 +++++ mysql-test/r/func_time.result | 15 ++ mysql-test/t/ctype_ucs.test | 25 ++ mysql-test/t/func_time.test | 9 + sql/item_timefunc.cc | 41 +++- sql/item_timefunc.h | 18 +- sql/mysql_priv.h | 9 +- sql/mysqld.cc | 42 ++++ sql/sql_locale.cc | 436 +++++++++++++++++++++++++--------- strings/ctype.c | 10 + 11 files changed, 527 insertions(+), 132 deletions(-) diff --git a/include/m_ctype.h b/include/m_ctype.h index 218ec2daadb..007edaf7740 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -445,6 +445,7 @@ my_bool my_propagate_complex(CHARSET_INFO *cs, const uchar *str, uint len); uint my_string_repertoire(CHARSET_INFO *cs, const char *str, ulong len); my_bool my_charset_is_ascii_based(CHARSET_INFO *cs); my_bool my_charset_is_8bit_pure_ascii(CHARSET_INFO *cs); +uint my_charset_repertoire(CHARSET_INFO *cs); #define _MY_U 01 /* Upper case */ diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index 89e8f1f6221..8c0f1a108a6 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -1111,4 +1111,57 @@ set names latin1; select hex(char(0x41 using ucs2)); hex(char(0x41 using ucs2)) 0041 +SET character_set_connection=ucs2; +SELECT CHARSET(DAYNAME(19700101)); +CHARSET(DAYNAME(19700101)) +ucs2 +SELECT CHARSET(MONTHNAME(19700101)); +CHARSET(MONTHNAME(19700101)) +ucs2 +SELECT LOWER(DAYNAME(19700101)); +LOWER(DAYNAME(19700101)) +thursday +SELECT LOWER(MONTHNAME(19700101)); +LOWER(MONTHNAME(19700101)) +january +SELECT UPPER(DAYNAME(19700101)); +UPPER(DAYNAME(19700101)) +THURSDAY +SELECT UPPER(MONTHNAME(19700101)); +UPPER(MONTHNAME(19700101)) +JANUARY +SELECT HEX(MONTHNAME(19700101)); +HEX(MONTHNAME(19700101)) +004A0061006E0075006100720079 +SELECT HEX(DAYNAME(19700101)); +HEX(DAYNAME(19700101)) +00540068007500720073006400610079 +SET LC_TIME_NAMES=ru_RU; +SET NAMES utf8; +SET character_set_connection=ucs2; +SELECT CHARSET(DAYNAME(19700101)); +CHARSET(DAYNAME(19700101)) +ucs2 +SELECT CHARSET(MONTHNAME(19700101)); +CHARSET(MONTHNAME(19700101)) +ucs2 +SELECT LOWER(DAYNAME(19700101)); +LOWER(DAYNAME(19700101)) +четверг +SELECT LOWER(MONTHNAME(19700101)); +LOWER(MONTHNAME(19700101)) +января +SELECT UPPER(DAYNAME(19700101)); +UPPER(DAYNAME(19700101)) +ЧЕТВЕРГ +SELECT UPPER(MONTHNAME(19700101)); +UPPER(MONTHNAME(19700101)) +ЯНВАРЯ +SELECT HEX(MONTHNAME(19700101)); +HEX(MONTHNAME(19700101)) +042F043D043204300440044F +SELECT HEX(DAYNAME(19700101)); +HEX(DAYNAME(19700101)) +0427043504420432043504400433 +SET character_set_connection=latin1; End of 5.0 tests diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index d397947d7ca..b3505795494 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -592,6 +592,21 @@ unix_timestamp('1970-01-01 03:00:01') select unix_timestamp('2038-01-19 07:14:07'); unix_timestamp('2038-01-19 07:14:07') 0 +SELECT CHARSET(DAYNAME(19700101)); +CHARSET(DAYNAME(19700101)) +latin1 +SELECT CHARSET(MONTHNAME(19700101)); +CHARSET(MONTHNAME(19700101)) +latin1 +SELECT LOWER(DAYNAME(19700101)); +LOWER(DAYNAME(19700101)) +thursday +SELECT LOWER(MONTHNAME(19700101)); +LOWER(MONTHNAME(19700101)) +january +SELECT COERCIBILITY(MONTHNAME('1970-01-01')),COERCIBILITY(DAYNAME('1970-01-01')); +COERCIBILITY(MONTHNAME('1970-01-01')) COERCIBILITY(DAYNAME('1970-01-01')) +4 4 CREATE TABLE t1 (datetime datetime, timestamp timestamp, date date, time time); INSERT INTO t1 values ("2001-01-02 03:04:05", "2002-01-02 03:04:05", "2003-01-02", "06:07:08"); SELECT * from t1; diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index 854a2fa3c5e..715b74dd2a8 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -685,4 +685,29 @@ set names latin1; # select hex(char(0x41 using ucs2)); +# +# Bug#37575: UCASE fails on monthname +# +SET character_set_connection=ucs2; +SELECT CHARSET(DAYNAME(19700101)); +SELECT CHARSET(MONTHNAME(19700101)); +SELECT LOWER(DAYNAME(19700101)); +SELECT LOWER(MONTHNAME(19700101)); +SELECT UPPER(DAYNAME(19700101)); +SELECT UPPER(MONTHNAME(19700101)); +SELECT HEX(MONTHNAME(19700101)); +SELECT HEX(DAYNAME(19700101)); +SET LC_TIME_NAMES=ru_RU; +SET NAMES utf8; +SET character_set_connection=ucs2; +SELECT CHARSET(DAYNAME(19700101)); +SELECT CHARSET(MONTHNAME(19700101)); +SELECT LOWER(DAYNAME(19700101)); +SELECT LOWER(MONTHNAME(19700101)); +SELECT UPPER(DAYNAME(19700101)); +SELECT UPPER(MONTHNAME(19700101)); +SELECT HEX(MONTHNAME(19700101)); +SELECT HEX(DAYNAME(19700101)); +SET character_set_connection=latin1; + --echo End of 5.0 tests diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index ef22adb4251..65d8764f2ce 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -304,6 +304,15 @@ select unix_timestamp('1970-01-01 03:00:01'); # check bad date, close to the boundary (we cut them off in the very end) select unix_timestamp('2038-01-19 07:14:07'); +# +# Bug #28759: DAYNAME() and MONTHNAME() return binary string +# + +SELECT CHARSET(DAYNAME(19700101)); +SELECT CHARSET(MONTHNAME(19700101)); +SELECT LOWER(DAYNAME(19700101)); +SELECT LOWER(MONTHNAME(19700101)); +SELECT COERCIBILITY(MONTHNAME('1970-01-01')),COERCIBILITY(DAYNAME('1970-01-01')); # # Test types from + INTERVAL diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index e9e92952908..38d9d62bd99 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -1036,12 +1036,25 @@ longlong Item_func_month::val_int() } +void Item_func_monthname::fix_length_and_dec() +{ + THD* thd= current_thd; + CHARSET_INFO *cs= thd->variables.collation_connection; + uint32 repertoire= my_charset_repertoire(cs); + locale= thd->variables.lc_time_names; + collation.set(cs, DERIVATION_COERCIBLE, repertoire); + decimals=0; + max_length= locale->max_month_name_length * collation.collation->mbmaxlen; + maybe_null=1; +} + + String* Item_func_monthname::val_str(String* str) { DBUG_ASSERT(fixed == 1); const char *month_name; - uint month= (uint) val_int(); - THD *thd= current_thd; + uint month= (uint) val_int(); + uint err; if (null_value || !month) { @@ -1049,8 +1062,9 @@ String* Item_func_monthname::val_str(String* str) return (String*) 0; } null_value=0; - month_name= thd->variables.lc_time_names->month_names->type_names[month-1]; - str->set(month_name, strlen(month_name), system_charset_info); + month_name= locale->month_names->type_names[month-1]; + str->copy(month_name, strlen(month_name), &my_charset_utf8_bin, + collation.collation, &err); return str; } @@ -1169,19 +1183,32 @@ longlong Item_func_weekday::val_int() odbc_type) + test(odbc_type); } +void Item_func_dayname::fix_length_and_dec() +{ + THD* thd= current_thd; + CHARSET_INFO *cs= thd->variables.collation_connection; + uint32 repertoire= my_charset_repertoire(cs); + locale= thd->variables.lc_time_names; + collation.set(cs, DERIVATION_COERCIBLE, repertoire); + decimals=0; + max_length= locale->max_day_name_length * collation.collation->mbmaxlen; + maybe_null=1; +} + String* Item_func_dayname::val_str(String* str) { DBUG_ASSERT(fixed == 1); uint weekday=(uint) val_int(); // Always Item_func_daynr() const char *day_name; - THD *thd= current_thd; + uint err; if (null_value) return (String*) 0; - day_name= thd->variables.lc_time_names->day_names->type_names[weekday]; - str->set(day_name, strlen(day_name), system_charset_info); + day_name= locale->day_names->type_names[weekday]; + str->copy(day_name, strlen(day_name), &my_charset_utf8_bin, + collation.collation, &err); return str; } diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 81a6c3e98bd..161a77f60b4 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -108,18 +108,13 @@ public: class Item_func_monthname :public Item_func_month { + MY_LOCALE *locale; public: Item_func_monthname(Item *a) :Item_func_month(a) {} const char *func_name() const { return "monthname"; } String *val_str(String *str); enum Item_result result_type () const { return STRING_RESULT; } - void fix_length_and_dec() - { - collation.set(&my_charset_bin); - decimals=0; - max_length=10*my_charset_bin.mbmaxlen; - maybe_null=1; - } + void fix_length_and_dec(); }; @@ -272,18 +267,13 @@ public: class Item_func_dayname :public Item_func_weekday { + MY_LOCALE *locale; public: Item_func_dayname(Item *a) :Item_func_weekday(a,0) {} const char *func_name() const { return "dayname"; } String *val_str(String *str); enum Item_result result_type () const { return STRING_RESULT; } - void fix_length_and_dec() - { - collation.set(&my_charset_bin); - decimals=0; - max_length=9*MY_CHARSET_BIN_MB_MAXLEN; - maybe_null=1; - } + void fix_length_and_dec(); }; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 520d97b5e9f..a06a7e7d6e3 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -132,15 +132,20 @@ typedef struct my_locale_st TYPELIB *ab_month_names; TYPELIB *day_names; TYPELIB *ab_day_names; + uint max_month_name_length; + uint max_day_name_length; #ifdef __cplusplus my_locale_st(uint number_par, const char *name_par, const char *descr_par, bool is_ascii_par, TYPELIB *month_names_par, TYPELIB *ab_month_names_par, - TYPELIB *day_names_par, TYPELIB *ab_day_names_par) : + TYPELIB *day_names_par, TYPELIB *ab_day_names_par, + uint max_month_name_length_par, uint max_day_name_length_par) : number(number_par), name(name_par), description(descr_par), is_ascii(is_ascii_par), month_names(month_names_par), ab_month_names(ab_month_names_par), - day_names(day_names_par), ab_day_names(ab_day_names_par) + day_names(day_names_par), ab_day_names(ab_day_names_par), + max_month_name_length(max_month_name_length_par), + max_day_name_length(max_day_name_length_par) {} #endif } MY_LOCALE; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 8232cefc880..f5e5b881a37 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3616,6 +3616,44 @@ void decrement_handler_count() #endif /* defined(__NT__) || defined(HAVE_SMEM) */ +#ifndef DBUG_OFF +/* + Debugging helper function to keep the locale database + (see sql_locale.cc) and max_month_name_length and + max_day_name_length variable values in consistent state. +*/ +static void test_lc_time_sz() +{ + DBUG_ENTER("test_lc_time_sz"); + for (MY_LOCALE **loc= my_locales; *loc; loc++) + { + uint max_month_len= 0; + uint max_day_len = 0; + for (const char **month= (*loc)->month_names->type_names; *month; month++) + { + set_if_bigger(max_month_len, + my_numchars_mb(&my_charset_utf8_general_ci, + *month, *month + strlen(*month))); + } + for (const char **day= (*loc)->day_names->type_names; *day; day++) + { + set_if_bigger(max_day_len, + my_numchars_mb(&my_charset_utf8_general_ci, + *day, *day + strlen(*day))); + } + if ((*loc)->max_month_name_length != max_month_len || + (*loc)->max_day_name_length != max_day_len) + { + DBUG_PRINT("Wrong max day name(or month name) length for locale:", + ("%s", (*loc)->name)); + DBUG_ASSERT(0); + } + } + DBUG_VOID_RETURN; +} +#endif//DBUG_OFF + + #ifndef EMBEDDED_LIBRARY #ifdef __WIN__ int win_main(int argc, char **argv) @@ -3712,6 +3750,10 @@ int main(int argc, char **argv) openlog(libwrapName, LOG_PID, LOG_AUTH); #endif +#ifndef DBUG_OFF + test_lc_time_sz(); +#endif + /* We have enough space for fiddling with the argv, continue */ diff --git a/sql/sql_locale.cc b/sql/sql_locale.cc index 4e61c664106..3def9864c29 100644 --- a/sql/sql_locale.cc +++ b/sql/sql_locale.cc @@ -49,7 +49,9 @@ MY_LOCALE my_locale_ar_AE &my_locale_typelib_month_names_ar_AE, &my_locale_typelib_ab_month_names_ar_AE, &my_locale_typelib_day_names_ar_AE, - &my_locale_typelib_ab_day_names_ar_AE + &my_locale_typelib_ab_day_names_ar_AE, + 6, + 8 ); /***** LOCALE END ar_AE *****/ @@ -79,7 +81,9 @@ MY_LOCALE my_locale_ar_BH &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, - &my_locale_typelib_ab_day_names_ar_BH + &my_locale_typelib_ab_day_names_ar_BH, + 6, + 8 ); /***** LOCALE END ar_BH *****/ @@ -109,7 +113,9 @@ MY_LOCALE my_locale_ar_JO &my_locale_typelib_month_names_ar_JO, &my_locale_typelib_ab_month_names_ar_JO, &my_locale_typelib_day_names_ar_JO, - &my_locale_typelib_ab_day_names_ar_JO + &my_locale_typelib_ab_day_names_ar_JO, + 12, + 8 ); /***** LOCALE END ar_JO *****/ @@ -139,7 +145,9 @@ MY_LOCALE my_locale_ar_SA &my_locale_typelib_month_names_ar_SA, &my_locale_typelib_ab_month_names_ar_SA, &my_locale_typelib_day_names_ar_SA, - &my_locale_typelib_ab_day_names_ar_SA + &my_locale_typelib_ab_day_names_ar_SA, + 12, + 8 ); /***** LOCALE END ar_SA *****/ @@ -169,7 +177,9 @@ MY_LOCALE my_locale_ar_SY &my_locale_typelib_month_names_ar_SY, &my_locale_typelib_ab_month_names_ar_SY, &my_locale_typelib_day_names_ar_SY, - &my_locale_typelib_ab_day_names_ar_SY + &my_locale_typelib_ab_day_names_ar_SY, + 12, + 8 ); /***** LOCALE END ar_SY *****/ @@ -199,7 +209,9 @@ MY_LOCALE my_locale_be_BY &my_locale_typelib_month_names_be_BY, &my_locale_typelib_ab_month_names_be_BY, &my_locale_typelib_day_names_be_BY, - &my_locale_typelib_ab_day_names_be_BY + &my_locale_typelib_ab_day_names_be_BY, + 10, + 10 ); /***** LOCALE END be_BY *****/ @@ -229,7 +241,9 @@ MY_LOCALE my_locale_bg_BG &my_locale_typelib_month_names_bg_BG, &my_locale_typelib_ab_month_names_bg_BG, &my_locale_typelib_day_names_bg_BG, - &my_locale_typelib_ab_day_names_bg_BG + &my_locale_typelib_ab_day_names_bg_BG, + 9, + 10 ); /***** LOCALE END bg_BG *****/ @@ -259,7 +273,9 @@ MY_LOCALE my_locale_ca_ES &my_locale_typelib_month_names_ca_ES, &my_locale_typelib_ab_month_names_ca_ES, &my_locale_typelib_day_names_ca_ES, - &my_locale_typelib_ab_day_names_ca_ES + &my_locale_typelib_ab_day_names_ca_ES, + 8, + 9 ); /***** LOCALE END ca_ES *****/ @@ -289,7 +305,9 @@ MY_LOCALE my_locale_cs_CZ &my_locale_typelib_month_names_cs_CZ, &my_locale_typelib_ab_month_names_cs_CZ, &my_locale_typelib_day_names_cs_CZ, - &my_locale_typelib_ab_day_names_cs_CZ + &my_locale_typelib_ab_day_names_cs_CZ, + 8, + 7 ); /***** LOCALE END cs_CZ *****/ @@ -319,7 +337,9 @@ MY_LOCALE my_locale_da_DK &my_locale_typelib_month_names_da_DK, &my_locale_typelib_ab_month_names_da_DK, &my_locale_typelib_day_names_da_DK, - &my_locale_typelib_ab_day_names_da_DK + &my_locale_typelib_ab_day_names_da_DK, + 9, + 7 ); /***** LOCALE END da_DK *****/ @@ -349,7 +369,9 @@ MY_LOCALE my_locale_de_AT &my_locale_typelib_month_names_de_AT, &my_locale_typelib_ab_month_names_de_AT, &my_locale_typelib_day_names_de_AT, - &my_locale_typelib_ab_day_names_de_AT + &my_locale_typelib_ab_day_names_de_AT, + 9, + 10 ); /***** LOCALE END de_AT *****/ @@ -379,7 +401,9 @@ MY_LOCALE my_locale_de_DE &my_locale_typelib_month_names_de_DE, &my_locale_typelib_ab_month_names_de_DE, &my_locale_typelib_day_names_de_DE, - &my_locale_typelib_ab_day_names_de_DE + &my_locale_typelib_ab_day_names_de_DE, + 9, + 10 ); /***** LOCALE END de_DE *****/ @@ -409,7 +433,9 @@ MY_LOCALE my_locale_en_US &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, - &my_locale_typelib_ab_day_names_en_US + &my_locale_typelib_ab_day_names_en_US, + 9, + 9 ); /***** LOCALE END en_US *****/ @@ -439,7 +465,9 @@ MY_LOCALE my_locale_es_ES &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, - &my_locale_typelib_ab_day_names_es_ES + &my_locale_typelib_ab_day_names_es_ES, + 10, + 9 ); /***** LOCALE END es_ES *****/ @@ -469,7 +497,9 @@ MY_LOCALE my_locale_et_EE &my_locale_typelib_month_names_et_EE, &my_locale_typelib_ab_month_names_et_EE, &my_locale_typelib_day_names_et_EE, - &my_locale_typelib_ab_day_names_et_EE + &my_locale_typelib_ab_day_names_et_EE, + 9, + 9 ); /***** LOCALE END et_EE *****/ @@ -499,7 +529,9 @@ MY_LOCALE my_locale_eu_ES &my_locale_typelib_month_names_eu_ES, &my_locale_typelib_ab_month_names_eu_ES, &my_locale_typelib_day_names_eu_ES, - &my_locale_typelib_ab_day_names_eu_ES + &my_locale_typelib_ab_day_names_eu_ES, + 9, + 10 ); /***** LOCALE END eu_ES *****/ @@ -529,7 +561,9 @@ MY_LOCALE my_locale_fi_FI &my_locale_typelib_month_names_fi_FI, &my_locale_typelib_ab_month_names_fi_FI, &my_locale_typelib_day_names_fi_FI, - &my_locale_typelib_ab_day_names_fi_FI + &my_locale_typelib_ab_day_names_fi_FI, + 9, + 11 ); /***** LOCALE END fi_FI *****/ @@ -559,7 +593,9 @@ MY_LOCALE my_locale_fo_FO &my_locale_typelib_month_names_fo_FO, &my_locale_typelib_ab_month_names_fo_FO, &my_locale_typelib_day_names_fo_FO, - &my_locale_typelib_ab_day_names_fo_FO + &my_locale_typelib_ab_day_names_fo_FO, + 9, + 12 ); /***** LOCALE END fo_FO *****/ @@ -589,7 +625,9 @@ MY_LOCALE my_locale_fr_FR &my_locale_typelib_month_names_fr_FR, &my_locale_typelib_ab_month_names_fr_FR, &my_locale_typelib_day_names_fr_FR, - &my_locale_typelib_ab_day_names_fr_FR + &my_locale_typelib_ab_day_names_fr_FR, + 9, + 8 ); /***** LOCALE END fr_FR *****/ @@ -619,7 +657,9 @@ MY_LOCALE my_locale_gl_ES &my_locale_typelib_month_names_gl_ES, &my_locale_typelib_ab_month_names_gl_ES, &my_locale_typelib_day_names_gl_ES, - &my_locale_typelib_ab_day_names_gl_ES + &my_locale_typelib_ab_day_names_gl_ES, + 8, + 8 ); /***** LOCALE END gl_ES *****/ @@ -649,7 +689,9 @@ MY_LOCALE my_locale_gu_IN &my_locale_typelib_month_names_gu_IN, &my_locale_typelib_ab_month_names_gu_IN, &my_locale_typelib_day_names_gu_IN, - &my_locale_typelib_ab_day_names_gu_IN + &my_locale_typelib_ab_day_names_gu_IN, + 10, + 8 ); /***** LOCALE END gu_IN *****/ @@ -679,7 +721,9 @@ MY_LOCALE my_locale_he_IL &my_locale_typelib_month_names_he_IL, &my_locale_typelib_ab_month_names_he_IL, &my_locale_typelib_day_names_he_IL, - &my_locale_typelib_ab_day_names_he_IL + &my_locale_typelib_ab_day_names_he_IL, + 7, + 5 ); /***** LOCALE END he_IL *****/ @@ -709,7 +753,9 @@ MY_LOCALE my_locale_hi_IN &my_locale_typelib_month_names_hi_IN, &my_locale_typelib_ab_month_names_hi_IN, &my_locale_typelib_day_names_hi_IN, - &my_locale_typelib_ab_day_names_hi_IN + &my_locale_typelib_ab_day_names_hi_IN, + 7, + 9 ); /***** LOCALE END hi_IN *****/ @@ -739,7 +785,9 @@ MY_LOCALE my_locale_hr_HR &my_locale_typelib_month_names_hr_HR, &my_locale_typelib_ab_month_names_hr_HR, &my_locale_typelib_day_names_hr_HR, - &my_locale_typelib_ab_day_names_hr_HR + &my_locale_typelib_ab_day_names_hr_HR, + 8, + 11 ); /***** LOCALE END hr_HR *****/ @@ -769,7 +817,9 @@ MY_LOCALE my_locale_hu_HU &my_locale_typelib_month_names_hu_HU, &my_locale_typelib_ab_month_names_hu_HU, &my_locale_typelib_day_names_hu_HU, - &my_locale_typelib_ab_day_names_hu_HU + &my_locale_typelib_ab_day_names_hu_HU, + 10, + 9 ); /***** LOCALE END hu_HU *****/ @@ -799,7 +849,9 @@ MY_LOCALE my_locale_id_ID &my_locale_typelib_month_names_id_ID, &my_locale_typelib_ab_month_names_id_ID, &my_locale_typelib_day_names_id_ID, - &my_locale_typelib_ab_day_names_id_ID + &my_locale_typelib_ab_day_names_id_ID, + 9, + 6 ); /***** LOCALE END id_ID *****/ @@ -829,7 +881,9 @@ MY_LOCALE my_locale_is_IS &my_locale_typelib_month_names_is_IS, &my_locale_typelib_ab_month_names_is_IS, &my_locale_typelib_day_names_is_IS, - &my_locale_typelib_ab_day_names_is_IS + &my_locale_typelib_ab_day_names_is_IS, + 9, + 12 ); /***** LOCALE END is_IS *****/ @@ -859,7 +913,9 @@ MY_LOCALE my_locale_it_CH &my_locale_typelib_month_names_it_CH, &my_locale_typelib_ab_month_names_it_CH, &my_locale_typelib_day_names_it_CH, - &my_locale_typelib_ab_day_names_it_CH + &my_locale_typelib_ab_day_names_it_CH, + 9, + 9 ); /***** LOCALE END it_CH *****/ @@ -889,7 +945,9 @@ MY_LOCALE my_locale_ja_JP &my_locale_typelib_month_names_ja_JP, &my_locale_typelib_ab_month_names_ja_JP, &my_locale_typelib_day_names_ja_JP, - &my_locale_typelib_ab_day_names_ja_JP + &my_locale_typelib_ab_day_names_ja_JP, + 3, + 3 ); /***** LOCALE END ja_JP *****/ @@ -919,7 +977,9 @@ MY_LOCALE my_locale_ko_KR &my_locale_typelib_month_names_ko_KR, &my_locale_typelib_ab_month_names_ko_KR, &my_locale_typelib_day_names_ko_KR, - &my_locale_typelib_ab_day_names_ko_KR + &my_locale_typelib_ab_day_names_ko_KR, + 3, + 3 ); /***** LOCALE END ko_KR *****/ @@ -949,7 +1009,9 @@ MY_LOCALE my_locale_lt_LT &my_locale_typelib_month_names_lt_LT, &my_locale_typelib_ab_month_names_lt_LT, &my_locale_typelib_day_names_lt_LT, - &my_locale_typelib_ab_day_names_lt_LT + &my_locale_typelib_ab_day_names_lt_LT, + 9, + 14 ); /***** LOCALE END lt_LT *****/ @@ -979,7 +1041,9 @@ MY_LOCALE my_locale_lv_LV &my_locale_typelib_month_names_lv_LV, &my_locale_typelib_ab_month_names_lv_LV, &my_locale_typelib_day_names_lv_LV, - &my_locale_typelib_ab_day_names_lv_LV + &my_locale_typelib_ab_day_names_lv_LV, + 10, + 11 ); /***** LOCALE END lv_LV *****/ @@ -1009,7 +1073,9 @@ MY_LOCALE my_locale_mk_MK &my_locale_typelib_month_names_mk_MK, &my_locale_typelib_ab_month_names_mk_MK, &my_locale_typelib_day_names_mk_MK, - &my_locale_typelib_ab_day_names_mk_MK + &my_locale_typelib_ab_day_names_mk_MK, + 9, + 10 ); /***** LOCALE END mk_MK *****/ @@ -1039,7 +1105,9 @@ MY_LOCALE my_locale_mn_MN &my_locale_typelib_month_names_mn_MN, &my_locale_typelib_ab_month_names_mn_MN, &my_locale_typelib_day_names_mn_MN, - &my_locale_typelib_ab_day_names_mn_MN + &my_locale_typelib_ab_day_names_mn_MN, + 18, + 6 ); /***** LOCALE END mn_MN *****/ @@ -1069,7 +1137,9 @@ MY_LOCALE my_locale_ms_MY &my_locale_typelib_month_names_ms_MY, &my_locale_typelib_ab_month_names_ms_MY, &my_locale_typelib_day_names_ms_MY, - &my_locale_typelib_ab_day_names_ms_MY + &my_locale_typelib_ab_day_names_ms_MY, + 9, + 6 ); /***** LOCALE END ms_MY *****/ @@ -1099,7 +1169,9 @@ MY_LOCALE my_locale_nb_NO &my_locale_typelib_month_names_nb_NO, &my_locale_typelib_ab_month_names_nb_NO, &my_locale_typelib_day_names_nb_NO, - &my_locale_typelib_ab_day_names_nb_NO + &my_locale_typelib_ab_day_names_nb_NO, + 9, + 7 ); /***** LOCALE END nb_NO *****/ @@ -1129,7 +1201,9 @@ MY_LOCALE my_locale_nl_NL &my_locale_typelib_month_names_nl_NL, &my_locale_typelib_ab_month_names_nl_NL, &my_locale_typelib_day_names_nl_NL, - &my_locale_typelib_ab_day_names_nl_NL + &my_locale_typelib_ab_day_names_nl_NL, + 9, + 9 ); /***** LOCALE END nl_NL *****/ @@ -1159,7 +1233,9 @@ MY_LOCALE my_locale_pl_PL &my_locale_typelib_month_names_pl_PL, &my_locale_typelib_ab_month_names_pl_PL, &my_locale_typelib_day_names_pl_PL, - &my_locale_typelib_ab_day_names_pl_PL + &my_locale_typelib_ab_day_names_pl_PL, + 11, + 12 ); /***** LOCALE END pl_PL *****/ @@ -1189,7 +1265,9 @@ MY_LOCALE my_locale_pt_BR &my_locale_typelib_month_names_pt_BR, &my_locale_typelib_ab_month_names_pt_BR, &my_locale_typelib_day_names_pt_BR, - &my_locale_typelib_ab_day_names_pt_BR + &my_locale_typelib_ab_day_names_pt_BR, + 9, + 7 ); /***** LOCALE END pt_BR *****/ @@ -1219,7 +1297,9 @@ MY_LOCALE my_locale_pt_PT &my_locale_typelib_month_names_pt_PT, &my_locale_typelib_ab_month_names_pt_PT, &my_locale_typelib_day_names_pt_PT, - &my_locale_typelib_ab_day_names_pt_PT + &my_locale_typelib_ab_day_names_pt_PT, + 9, + 7 ); /***** LOCALE END pt_PT *****/ @@ -1249,7 +1329,9 @@ MY_LOCALE my_locale_ro_RO &my_locale_typelib_month_names_ro_RO, &my_locale_typelib_ab_month_names_ro_RO, &my_locale_typelib_day_names_ro_RO, - &my_locale_typelib_ab_day_names_ro_RO + &my_locale_typelib_ab_day_names_ro_RO, + 10, + 8 ); /***** LOCALE END ro_RO *****/ @@ -1279,7 +1361,9 @@ MY_LOCALE my_locale_ru_RU &my_locale_typelib_month_names_ru_RU, &my_locale_typelib_ab_month_names_ru_RU, &my_locale_typelib_day_names_ru_RU, - &my_locale_typelib_ab_day_names_ru_RU + &my_locale_typelib_ab_day_names_ru_RU, + 8, + 11 ); /***** LOCALE END ru_RU *****/ @@ -1309,7 +1393,9 @@ MY_LOCALE my_locale_ru_UA &my_locale_typelib_month_names_ru_UA, &my_locale_typelib_ab_month_names_ru_UA, &my_locale_typelib_day_names_ru_UA, - &my_locale_typelib_ab_day_names_ru_UA + &my_locale_typelib_ab_day_names_ru_UA, + 8, + 11 ); /***** LOCALE END ru_UA *****/ @@ -1339,7 +1425,9 @@ MY_LOCALE my_locale_sk_SK &my_locale_typelib_month_names_sk_SK, &my_locale_typelib_ab_month_names_sk_SK, &my_locale_typelib_day_names_sk_SK, - &my_locale_typelib_ab_day_names_sk_SK + &my_locale_typelib_ab_day_names_sk_SK, + 9, + 8 ); /***** LOCALE END sk_SK *****/ @@ -1369,7 +1457,9 @@ MY_LOCALE my_locale_sl_SI &my_locale_typelib_month_names_sl_SI, &my_locale_typelib_ab_month_names_sl_SI, &my_locale_typelib_day_names_sl_SI, - &my_locale_typelib_ab_day_names_sl_SI + &my_locale_typelib_ab_day_names_sl_SI, + 9, + 10 ); /***** LOCALE END sl_SI *****/ @@ -1399,7 +1489,9 @@ MY_LOCALE my_locale_sq_AL &my_locale_typelib_month_names_sq_AL, &my_locale_typelib_ab_month_names_sq_AL, &my_locale_typelib_day_names_sq_AL, - &my_locale_typelib_ab_day_names_sq_AL + &my_locale_typelib_ab_day_names_sq_AL, + 7, + 10 ); /***** LOCALE END sq_AL *****/ @@ -1429,7 +1521,9 @@ MY_LOCALE my_locale_sr_YU &my_locale_typelib_month_names_sr_YU, &my_locale_typelib_ab_month_names_sr_YU, &my_locale_typelib_day_names_sr_YU, - &my_locale_typelib_ab_day_names_sr_YU + &my_locale_typelib_ab_day_names_sr_YU, + 9, + 10 ); /***** LOCALE END sr_YU *****/ @@ -1459,7 +1553,9 @@ MY_LOCALE my_locale_sv_SE &my_locale_typelib_month_names_sv_SE, &my_locale_typelib_ab_month_names_sv_SE, &my_locale_typelib_day_names_sv_SE, - &my_locale_typelib_ab_day_names_sv_SE + &my_locale_typelib_ab_day_names_sv_SE, + 9, + 7 ); /***** LOCALE END sv_SE *****/ @@ -1489,7 +1585,9 @@ MY_LOCALE my_locale_ta_IN &my_locale_typelib_month_names_ta_IN, &my_locale_typelib_ab_month_names_ta_IN, &my_locale_typelib_day_names_ta_IN, - &my_locale_typelib_ab_day_names_ta_IN + &my_locale_typelib_ab_day_names_ta_IN, + 10, + 8 ); /***** LOCALE END ta_IN *****/ @@ -1519,7 +1617,9 @@ MY_LOCALE my_locale_te_IN &my_locale_typelib_month_names_te_IN, &my_locale_typelib_ab_month_names_te_IN, &my_locale_typelib_day_names_te_IN, - &my_locale_typelib_ab_day_names_te_IN + &my_locale_typelib_ab_day_names_te_IN, + 10, + 9 ); /***** LOCALE END te_IN *****/ @@ -1549,7 +1649,9 @@ MY_LOCALE my_locale_th_TH &my_locale_typelib_month_names_th_TH, &my_locale_typelib_ab_month_names_th_TH, &my_locale_typelib_day_names_th_TH, - &my_locale_typelib_ab_day_names_th_TH + &my_locale_typelib_ab_day_names_th_TH, + 10, + 8 ); /***** LOCALE END th_TH *****/ @@ -1579,7 +1681,9 @@ MY_LOCALE my_locale_tr_TR &my_locale_typelib_month_names_tr_TR, &my_locale_typelib_ab_month_names_tr_TR, &my_locale_typelib_day_names_tr_TR, - &my_locale_typelib_ab_day_names_tr_TR + &my_locale_typelib_ab_day_names_tr_TR, + 7, + 9 ); /***** LOCALE END tr_TR *****/ @@ -1609,7 +1713,9 @@ MY_LOCALE my_locale_uk_UA &my_locale_typelib_month_names_uk_UA, &my_locale_typelib_ab_month_names_uk_UA, &my_locale_typelib_day_names_uk_UA, - &my_locale_typelib_ab_day_names_uk_UA + &my_locale_typelib_ab_day_names_uk_UA, + 8, + 9 ); /***** LOCALE END uk_UA *****/ @@ -1639,7 +1745,9 @@ MY_LOCALE my_locale_ur_PK &my_locale_typelib_month_names_ur_PK, &my_locale_typelib_ab_month_names_ur_PK, &my_locale_typelib_day_names_ur_PK, - &my_locale_typelib_ab_day_names_ur_PK + &my_locale_typelib_ab_day_names_ur_PK, + 6, + 6 ); /***** LOCALE END ur_PK *****/ @@ -1669,7 +1777,9 @@ MY_LOCALE my_locale_vi_VN &my_locale_typelib_month_names_vi_VN, &my_locale_typelib_ab_month_names_vi_VN, &my_locale_typelib_day_names_vi_VN, - &my_locale_typelib_ab_day_names_vi_VN + &my_locale_typelib_ab_day_names_vi_VN, + 16, + 11 ); /***** LOCALE END vi_VN *****/ @@ -1699,7 +1809,9 @@ MY_LOCALE my_locale_zh_CN &my_locale_typelib_month_names_zh_CN, &my_locale_typelib_ab_month_names_zh_CN, &my_locale_typelib_day_names_zh_CN, - &my_locale_typelib_ab_day_names_zh_CN + &my_locale_typelib_ab_day_names_zh_CN, + 3, + 3 ); /***** LOCALE END zh_CN *****/ @@ -1729,7 +1841,9 @@ MY_LOCALE my_locale_zh_TW &my_locale_typelib_month_names_zh_TW, &my_locale_typelib_ab_month_names_zh_TW, &my_locale_typelib_day_names_zh_TW, - &my_locale_typelib_ab_day_names_zh_TW + &my_locale_typelib_ab_day_names_zh_TW, + 3, + 2 ); /***** LOCALE END zh_TW *****/ @@ -1743,7 +1857,9 @@ MY_LOCALE my_locale_ar_DZ &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, - &my_locale_typelib_ab_day_names_ar_BH + &my_locale_typelib_ab_day_names_ar_BH, + 6, + 8 ); /***** LOCALE END ar_DZ *****/ @@ -1757,7 +1873,9 @@ MY_LOCALE my_locale_ar_EG &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, - &my_locale_typelib_ab_day_names_ar_BH + &my_locale_typelib_ab_day_names_ar_BH, + 6, + 8 ); /***** LOCALE END ar_EG *****/ @@ -1771,7 +1889,9 @@ MY_LOCALE my_locale_ar_IN &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, - &my_locale_typelib_ab_day_names_ar_BH + &my_locale_typelib_ab_day_names_ar_BH, + 6, + 8 ); /***** LOCALE END ar_IN *****/ @@ -1785,7 +1905,9 @@ MY_LOCALE my_locale_ar_IQ &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, - &my_locale_typelib_ab_day_names_ar_BH + &my_locale_typelib_ab_day_names_ar_BH, + 6, + 8 ); /***** LOCALE END ar_IQ *****/ @@ -1799,7 +1921,9 @@ MY_LOCALE my_locale_ar_KW &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, - &my_locale_typelib_ab_day_names_ar_BH + &my_locale_typelib_ab_day_names_ar_BH, + 6, + 8 ); /***** LOCALE END ar_KW *****/ @@ -1813,7 +1937,9 @@ MY_LOCALE my_locale_ar_LB &my_locale_typelib_month_names_ar_JO, &my_locale_typelib_ab_month_names_ar_JO, &my_locale_typelib_day_names_ar_JO, - &my_locale_typelib_ab_day_names_ar_JO + &my_locale_typelib_ab_day_names_ar_JO, + 12, + 8 ); /***** LOCALE END ar_LB *****/ @@ -1827,7 +1953,9 @@ MY_LOCALE my_locale_ar_LY &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, - &my_locale_typelib_ab_day_names_ar_BH + &my_locale_typelib_ab_day_names_ar_BH, + 6, + 8 ); /***** LOCALE END ar_LY *****/ @@ -1841,7 +1969,9 @@ MY_LOCALE my_locale_ar_MA &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, - &my_locale_typelib_ab_day_names_ar_BH + &my_locale_typelib_ab_day_names_ar_BH, + 6, + 8 ); /***** LOCALE END ar_MA *****/ @@ -1855,7 +1985,9 @@ MY_LOCALE my_locale_ar_OM &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, - &my_locale_typelib_ab_day_names_ar_BH + &my_locale_typelib_ab_day_names_ar_BH, + 6, + 8 ); /***** LOCALE END ar_OM *****/ @@ -1869,7 +2001,9 @@ MY_LOCALE my_locale_ar_QA &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, - &my_locale_typelib_ab_day_names_ar_BH + &my_locale_typelib_ab_day_names_ar_BH, + 6, + 8 ); /***** LOCALE END ar_QA *****/ @@ -1883,7 +2017,9 @@ MY_LOCALE my_locale_ar_SD &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, - &my_locale_typelib_ab_day_names_ar_BH + &my_locale_typelib_ab_day_names_ar_BH, + 6, + 8 ); /***** LOCALE END ar_SD *****/ @@ -1897,7 +2033,9 @@ MY_LOCALE my_locale_ar_TN &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, - &my_locale_typelib_ab_day_names_ar_BH + &my_locale_typelib_ab_day_names_ar_BH, + 6, + 8 ); /***** LOCALE END ar_TN *****/ @@ -1911,7 +2049,9 @@ MY_LOCALE my_locale_ar_YE &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, - &my_locale_typelib_ab_day_names_ar_BH + &my_locale_typelib_ab_day_names_ar_BH, + 6, + 8 ); /***** LOCALE END ar_YE *****/ @@ -1925,7 +2065,9 @@ MY_LOCALE my_locale_de_BE &my_locale_typelib_month_names_de_DE, &my_locale_typelib_ab_month_names_de_DE, &my_locale_typelib_day_names_de_DE, - &my_locale_typelib_ab_day_names_de_DE + &my_locale_typelib_ab_day_names_de_DE, + 9, + 10 ); /***** LOCALE END de_BE *****/ @@ -1939,7 +2081,9 @@ MY_LOCALE my_locale_de_CH &my_locale_typelib_month_names_de_DE, &my_locale_typelib_ab_month_names_de_DE, &my_locale_typelib_day_names_de_DE, - &my_locale_typelib_ab_day_names_de_DE + &my_locale_typelib_ab_day_names_de_DE, + 9, + 10 ); /***** LOCALE END de_CH *****/ @@ -1953,7 +2097,9 @@ MY_LOCALE my_locale_de_LU &my_locale_typelib_month_names_de_DE, &my_locale_typelib_ab_month_names_de_DE, &my_locale_typelib_day_names_de_DE, - &my_locale_typelib_ab_day_names_de_DE + &my_locale_typelib_ab_day_names_de_DE, + 9, + 10 ); /***** LOCALE END de_LU *****/ @@ -1967,7 +2113,9 @@ MY_LOCALE my_locale_en_AU &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, - &my_locale_typelib_ab_day_names_en_US + &my_locale_typelib_ab_day_names_en_US, + 9, + 9 ); /***** LOCALE END en_AU *****/ @@ -1981,7 +2129,9 @@ MY_LOCALE my_locale_en_CA &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, - &my_locale_typelib_ab_day_names_en_US + &my_locale_typelib_ab_day_names_en_US, + 9, + 9 ); /***** LOCALE END en_CA *****/ @@ -1995,7 +2145,9 @@ MY_LOCALE my_locale_en_GB &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, - &my_locale_typelib_ab_day_names_en_US + &my_locale_typelib_ab_day_names_en_US, + 9, + 9 ); /***** LOCALE END en_GB *****/ @@ -2009,7 +2161,9 @@ MY_LOCALE my_locale_en_IN &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, - &my_locale_typelib_ab_day_names_en_US + &my_locale_typelib_ab_day_names_en_US, + 9, + 9 ); /***** LOCALE END en_IN *****/ @@ -2023,7 +2177,9 @@ MY_LOCALE my_locale_en_NZ &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, - &my_locale_typelib_ab_day_names_en_US + &my_locale_typelib_ab_day_names_en_US, + 9, + 9 ); /***** LOCALE END en_NZ *****/ @@ -2037,7 +2193,9 @@ MY_LOCALE my_locale_en_PH &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, - &my_locale_typelib_ab_day_names_en_US + &my_locale_typelib_ab_day_names_en_US, + 9, + 9 ); /***** LOCALE END en_PH *****/ @@ -2051,7 +2209,9 @@ MY_LOCALE my_locale_en_ZA &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, - &my_locale_typelib_ab_day_names_en_US + &my_locale_typelib_ab_day_names_en_US, + 9, + 9 ); /***** LOCALE END en_ZA *****/ @@ -2065,7 +2225,9 @@ MY_LOCALE my_locale_en_ZW &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, - &my_locale_typelib_ab_day_names_en_US + &my_locale_typelib_ab_day_names_en_US, + 9, + 9 ); /***** LOCALE END en_ZW *****/ @@ -2079,7 +2241,9 @@ MY_LOCALE my_locale_es_AR &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, - &my_locale_typelib_ab_day_names_es_ES + &my_locale_typelib_ab_day_names_es_ES, + 10, + 9 ); /***** LOCALE END es_AR *****/ @@ -2093,7 +2257,9 @@ MY_LOCALE my_locale_es_BO &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, - &my_locale_typelib_ab_day_names_es_ES + &my_locale_typelib_ab_day_names_es_ES, + 10, + 9 ); /***** LOCALE END es_BO *****/ @@ -2107,7 +2273,9 @@ MY_LOCALE my_locale_es_CL &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, - &my_locale_typelib_ab_day_names_es_ES + &my_locale_typelib_ab_day_names_es_ES, + 10, + 9 ); /***** LOCALE END es_CL *****/ @@ -2121,7 +2289,9 @@ MY_LOCALE my_locale_es_CO &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, - &my_locale_typelib_ab_day_names_es_ES + &my_locale_typelib_ab_day_names_es_ES, + 10, + 9 ); /***** LOCALE END es_CO *****/ @@ -2135,7 +2305,9 @@ MY_LOCALE my_locale_es_CR &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, - &my_locale_typelib_ab_day_names_es_ES + &my_locale_typelib_ab_day_names_es_ES, + 10, + 9 ); /***** LOCALE END es_CR *****/ @@ -2149,7 +2321,9 @@ MY_LOCALE my_locale_es_DO &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, - &my_locale_typelib_ab_day_names_es_ES + &my_locale_typelib_ab_day_names_es_ES, + 10, + 9 ); /***** LOCALE END es_DO *****/ @@ -2163,7 +2337,9 @@ MY_LOCALE my_locale_es_EC &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, - &my_locale_typelib_ab_day_names_es_ES + &my_locale_typelib_ab_day_names_es_ES, + 10, + 9 ); /***** LOCALE END es_EC *****/ @@ -2177,7 +2353,9 @@ MY_LOCALE my_locale_es_GT &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, - &my_locale_typelib_ab_day_names_es_ES + &my_locale_typelib_ab_day_names_es_ES, + 10, + 9 ); /***** LOCALE END es_GT *****/ @@ -2191,7 +2369,9 @@ MY_LOCALE my_locale_es_HN &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, - &my_locale_typelib_ab_day_names_es_ES + &my_locale_typelib_ab_day_names_es_ES, + 10, + 9 ); /***** LOCALE END es_HN *****/ @@ -2205,7 +2385,9 @@ MY_LOCALE my_locale_es_MX &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, - &my_locale_typelib_ab_day_names_es_ES + &my_locale_typelib_ab_day_names_es_ES, + 10, + 9 ); /***** LOCALE END es_MX *****/ @@ -2219,7 +2401,9 @@ MY_LOCALE my_locale_es_NI &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, - &my_locale_typelib_ab_day_names_es_ES + &my_locale_typelib_ab_day_names_es_ES, + 10, + 9 ); /***** LOCALE END es_NI *****/ @@ -2233,7 +2417,9 @@ MY_LOCALE my_locale_es_PA &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, - &my_locale_typelib_ab_day_names_es_ES + &my_locale_typelib_ab_day_names_es_ES, + 10, + 9 ); /***** LOCALE END es_PA *****/ @@ -2247,7 +2433,9 @@ MY_LOCALE my_locale_es_PE &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, - &my_locale_typelib_ab_day_names_es_ES + &my_locale_typelib_ab_day_names_es_ES, + 10, + 9 ); /***** LOCALE END es_PE *****/ @@ -2261,7 +2449,9 @@ MY_LOCALE my_locale_es_PR &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, - &my_locale_typelib_ab_day_names_es_ES + &my_locale_typelib_ab_day_names_es_ES, + 10, + 9 ); /***** LOCALE END es_PR *****/ @@ -2275,7 +2465,9 @@ MY_LOCALE my_locale_es_PY &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, - &my_locale_typelib_ab_day_names_es_ES + &my_locale_typelib_ab_day_names_es_ES, + 10, + 9 ); /***** LOCALE END es_PY *****/ @@ -2289,7 +2481,9 @@ MY_LOCALE my_locale_es_SV &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, - &my_locale_typelib_ab_day_names_es_ES + &my_locale_typelib_ab_day_names_es_ES, + 10, + 9 ); /***** LOCALE END es_SV *****/ @@ -2303,7 +2497,9 @@ MY_LOCALE my_locale_es_US &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, - &my_locale_typelib_ab_day_names_es_ES + &my_locale_typelib_ab_day_names_es_ES, + 10, + 9 ); /***** LOCALE END es_US *****/ @@ -2317,7 +2513,9 @@ MY_LOCALE my_locale_es_UY &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, - &my_locale_typelib_ab_day_names_es_ES + &my_locale_typelib_ab_day_names_es_ES, + 10, + 9 ); /***** LOCALE END es_UY *****/ @@ -2331,7 +2529,9 @@ MY_LOCALE my_locale_es_VE &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, - &my_locale_typelib_ab_day_names_es_ES + &my_locale_typelib_ab_day_names_es_ES, + 10, + 9 ); /***** LOCALE END es_VE *****/ @@ -2345,7 +2545,9 @@ MY_LOCALE my_locale_fr_BE &my_locale_typelib_month_names_fr_FR, &my_locale_typelib_ab_month_names_fr_FR, &my_locale_typelib_day_names_fr_FR, - &my_locale_typelib_ab_day_names_fr_FR + &my_locale_typelib_ab_day_names_fr_FR, + 9, + 8 ); /***** LOCALE END fr_BE *****/ @@ -2359,7 +2561,9 @@ MY_LOCALE my_locale_fr_CA &my_locale_typelib_month_names_fr_FR, &my_locale_typelib_ab_month_names_fr_FR, &my_locale_typelib_day_names_fr_FR, - &my_locale_typelib_ab_day_names_fr_FR + &my_locale_typelib_ab_day_names_fr_FR, + 9, + 8 ); /***** LOCALE END fr_CA *****/ @@ -2373,7 +2577,9 @@ MY_LOCALE my_locale_fr_CH &my_locale_typelib_month_names_fr_FR, &my_locale_typelib_ab_month_names_fr_FR, &my_locale_typelib_day_names_fr_FR, - &my_locale_typelib_ab_day_names_fr_FR + &my_locale_typelib_ab_day_names_fr_FR, + 9, + 8 ); /***** LOCALE END fr_CH *****/ @@ -2387,7 +2593,9 @@ MY_LOCALE my_locale_fr_LU &my_locale_typelib_month_names_fr_FR, &my_locale_typelib_ab_month_names_fr_FR, &my_locale_typelib_day_names_fr_FR, - &my_locale_typelib_ab_day_names_fr_FR + &my_locale_typelib_ab_day_names_fr_FR, + 9, + 8 ); /***** LOCALE END fr_LU *****/ @@ -2401,7 +2609,9 @@ MY_LOCALE my_locale_it_IT &my_locale_typelib_month_names_it_CH, &my_locale_typelib_ab_month_names_it_CH, &my_locale_typelib_day_names_it_CH, - &my_locale_typelib_ab_day_names_it_CH + &my_locale_typelib_ab_day_names_it_CH, + 9, + 9 ); /***** LOCALE END it_IT *****/ @@ -2415,7 +2625,9 @@ MY_LOCALE my_locale_nl_BE &my_locale_typelib_month_names_nl_NL, &my_locale_typelib_ab_month_names_nl_NL, &my_locale_typelib_day_names_nl_NL, - &my_locale_typelib_ab_day_names_nl_NL + &my_locale_typelib_ab_day_names_nl_NL, + 9, + 9 ); /***** LOCALE END nl_BE *****/ @@ -2429,7 +2641,9 @@ MY_LOCALE my_locale_no_NO &my_locale_typelib_month_names_nb_NO, &my_locale_typelib_ab_month_names_nb_NO, &my_locale_typelib_day_names_nb_NO, - &my_locale_typelib_ab_day_names_nb_NO + &my_locale_typelib_ab_day_names_nb_NO, + 9, + 7 ); /***** LOCALE END no_NO *****/ @@ -2443,7 +2657,9 @@ MY_LOCALE my_locale_sv_FI &my_locale_typelib_month_names_sv_SE, &my_locale_typelib_ab_month_names_sv_SE, &my_locale_typelib_day_names_sv_SE, - &my_locale_typelib_ab_day_names_sv_SE + &my_locale_typelib_ab_day_names_sv_SE, + 9, + 7 ); /***** LOCALE END sv_FI *****/ @@ -2457,7 +2673,9 @@ MY_LOCALE my_locale_zh_HK &my_locale_typelib_month_names_zh_CN, &my_locale_typelib_ab_month_names_zh_CN, &my_locale_typelib_day_names_zh_CN, - &my_locale_typelib_ab_day_names_zh_CN + &my_locale_typelib_ab_day_names_zh_CN, + 3, + 3 ); /***** LOCALE END zh_HK *****/ diff --git a/strings/ctype.c b/strings/ctype.c index 372a1a8a468..548005f8463 100644 --- a/strings/ctype.c +++ b/strings/ctype.c @@ -337,6 +337,16 @@ my_string_repertoire(CHARSET_INFO *cs, const char *str, ulong length) } +/* + Returns repertoire for charset +*/ +uint my_charset_repertoire(CHARSET_INFO *cs) +{ + return cs->state & MY_CS_PUREASCII ? + MY_REPERTOIRE_ASCII : MY_REPERTOIRE_UNICODE30; +} + + /* Detect whether a character set is ASCII compatible. From b5f005f65ab14765ba8c0d56102be9fe66b66783 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Tue, 23 Dec 2008 18:56:08 +0400 Subject: [PATCH 097/137] Bug#41079 information_schema.schema_privileges is limited to 7680 records. The problem is that we cannot insert new record into memory table when table size exceeds max memory table size. The fix is to use schema_table_store_record() function which converts memory table into MyISAM in case of table size exceeding. Note: There is no test case for this bug, the reason is that 1. The code that was added already is checked(i.e. works) with existing tests 2. Correct work of schema_table_store_record() is checked with other test cases (information_schema tests) So new code is fully covered with existing test cases. --- sql/mysql_priv.h | 1 + sql/sql_acl.cc | 119 +++++++++++++++++++++++++++++++++-------------- sql/sql_show.cc | 4 +- 3 files changed, 87 insertions(+), 37 deletions(-) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index a06a7e7d6e3..8a8513ac745 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -983,6 +983,7 @@ int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond); bool get_schema_tables_result(JOIN *join, enum enum_schema_table_state executed_place); enum enum_schema_tables get_schema_table_idx(ST_SCHEMA_TABLE *schema_table); +bool schema_table_store_record(THD *thd, TABLE *table); #define is_schema_db(X) \ !my_strcasecmp(system_charset_info, INFORMATION_SCHEMA_NAME.str, (X)) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index df5e844749f..57029f46162 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -5953,10 +5953,11 @@ int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr) } -void update_schema_privilege(TABLE *table, char *buff, const char* db, - const char* t_name, const char* column, - uint col_length, const char *priv, - uint priv_length, const char* is_grantable) +static bool update_schema_privilege(THD *thd, TABLE *table, char *buff, + const char* db, const char* t_name, + const char* column, uint col_length, + const char *priv, uint priv_length, + const char* is_grantable) { int i= 2; CHARSET_INFO *cs= system_charset_info; @@ -5970,13 +5971,14 @@ void update_schema_privilege(TABLE *table, char *buff, const char* db, table->field[i++]->store(column, col_length, cs); table->field[i++]->store(priv, priv_length, cs); table->field[i]->store(is_grantable, strlen(is_grantable), cs); - table->file->write_row(table->record[0]); + return schema_table_store_record(thd, table); } int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond) { #ifndef NO_EMBEDDED_ACCESS_CHECKS + int error= 0; uint counter; ACL_USER *acl_user; ulong want_access; @@ -6010,8 +6012,14 @@ int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond) strxmov(buff,"'",user,"'@'",host,"'",NullS); if (!(want_access & ~GRANT_ACL)) - update_schema_privilege(table, buff, 0, 0, 0, 0, - STRING_WITH_LEN("USAGE"), is_grantable); + { + if (update_schema_privilege(thd, table, buff, 0, 0, 0, 0, + STRING_WITH_LEN("USAGE"), is_grantable)) + { + error= 1; + goto err; + } + } else { uint priv_id; @@ -6019,16 +6027,22 @@ int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond) for (priv_id=0, j = SELECT_ACL;j <= GLOBAL_ACLS; priv_id++,j <<= 1) { if (test_access & j) - update_schema_privilege(table, buff, 0, 0, 0, 0, - command_array[priv_id], - command_lengths[priv_id], is_grantable); + { + if (update_schema_privilege(thd, table, buff, 0, 0, 0, 0, + command_array[priv_id], + command_lengths[priv_id], is_grantable)) + { + error= 1; + goto err; + } + } } } } - +err: pthread_mutex_unlock(&acl_cache->lock); - DBUG_RETURN(0); + DBUG_RETURN(error); #else return(0); #endif @@ -6038,6 +6052,7 @@ int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond) int fill_schema_schema_privileges(THD *thd, TABLE_LIST *tables, COND *cond) { #ifndef NO_EMBEDDED_ACCESS_CHECKS + int error= 0; uint counter; ACL_DB *acl_db; ulong want_access; @@ -6075,24 +6090,36 @@ int fill_schema_schema_privileges(THD *thd, TABLE_LIST *tables, COND *cond) } strxmov(buff,"'",user,"'@'",host,"'",NullS); if (!(want_access & ~GRANT_ACL)) - update_schema_privilege(table, buff, acl_db->db, 0, 0, - 0, STRING_WITH_LEN("USAGE"), is_grantable); + { + if (update_schema_privilege(thd, table, buff, acl_db->db, 0, 0, + 0, STRING_WITH_LEN("USAGE"), is_grantable)) + { + error= 1; + goto err; + } + } else { int cnt; ulong j,test_access= want_access & ~GRANT_ACL; for (cnt=0, j = SELECT_ACL; j <= DB_ACLS; cnt++,j <<= 1) if (test_access & j) - update_schema_privilege(table, buff, acl_db->db, 0, 0, 0, - command_array[cnt], command_lengths[cnt], - is_grantable); + { + if (update_schema_privilege(thd, table, buff, acl_db->db, 0, 0, 0, + command_array[cnt], command_lengths[cnt], + is_grantable)) + { + error= 1; + goto err; + } + } } } } - +err: pthread_mutex_unlock(&acl_cache->lock); - DBUG_RETURN(0); + DBUG_RETURN(error); #else return (0); #endif @@ -6102,6 +6129,7 @@ int fill_schema_schema_privileges(THD *thd, TABLE_LIST *tables, COND *cond) int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond) { #ifndef NO_EMBEDDED_ACCESS_CHECKS + int error= 0; uint index; char buff[100]; TABLE *table= tables->table; @@ -6141,8 +6169,15 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond) strxmov(buff, "'", user, "'@'", host, "'", NullS); if (!test_access) - update_schema_privilege(table, buff, grant_table->db, grant_table->tname, - 0, 0, STRING_WITH_LEN("USAGE"), is_grantable); + { + if (update_schema_privilege(thd, table, buff, grant_table->db, + grant_table->tname, 0, 0, + STRING_WITH_LEN("USAGE"), is_grantable)) + { + error= 1; + goto err; + } + } else { ulong j; @@ -6150,17 +6185,24 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond) for (cnt= 0, j= SELECT_ACL; j <= TABLE_ACLS; cnt++, j<<= 1) { if (test_access & j) - update_schema_privilege(table, buff, grant_table->db, - grant_table->tname, 0, 0, command_array[cnt], - command_lengths[cnt], is_grantable); + { + if (update_schema_privilege(thd, table, buff, grant_table->db, + grant_table->tname, 0, 0, + command_array[cnt], + command_lengths[cnt], is_grantable)) + { + error= 1; + goto err; + } + } } } - } + } } - +err: rw_unlock(&LOCK_grant); - DBUG_RETURN(0); + DBUG_RETURN(error); #else return (0); #endif @@ -6170,6 +6212,7 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond) int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond) { #ifndef NO_EMBEDDED_ACCESS_CHECKS + int error= 0; uint index; char buff[100]; TABLE *table= tables->table; @@ -6219,22 +6262,28 @@ int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond) GRANT_COLUMN *grant_column = (GRANT_COLUMN*) hash_element(&grant_table->hash_columns,col_index); if ((grant_column->rights & j) && (table_access & j)) - update_schema_privilege(table, buff, grant_table->db, - grant_table->tname, - grant_column->column, - grant_column->key_length, - command_array[cnt], - command_lengths[cnt], is_grantable); + { + if (update_schema_privilege(thd, table, buff, grant_table->db, + grant_table->tname, + grant_column->column, + grant_column->key_length, + command_array[cnt], + command_lengths[cnt], is_grantable)) + { + error= 1; + goto err; + } + } } } } } } } - +err: rw_unlock(&LOCK_grant); - DBUG_RETURN(0); + DBUG_RETURN(error); #else return (0); #endif diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 59082e0a295..c10580e8913 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -44,7 +44,7 @@ static void append_algorithm(TABLE_LIST *table, String *buff); static int view_store_create_info(THD *thd, TABLE_LIST *table, String *buff); -static bool schema_table_store_record(THD *thd, TABLE *table); +bool schema_table_store_record(THD *thd, TABLE *table); /*************************************************************************** @@ -1884,7 +1884,7 @@ typedef struct st_index_field_values 1 error */ -static bool schema_table_store_record(THD *thd, TABLE *table) +bool schema_table_store_record(THD *thd, TABLE *table) { int error; if ((error= table->file->write_row(table->record[0]))) From c61c1a0d60d004914cab1417868ce7a268141b10 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Tue, 23 Dec 2008 19:33:46 +0400 Subject: [PATCH 098/137] Bug#40104 regression with table names? On Winodws FN_DEVCHAR is ':' symbol. There is a check in mysql_create_table_no_lock() func on FN_DEVCHAR presence but this code is obsolete and unnecessary. So the fix is to remove unnecessary code. --- mysql-test/r/create.result | 2 ++ mysql-test/t/create.test | 6 ++++++ sql/sql_table.cc | 8 -------- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 947890d2085..67f81cb4fa5 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -1890,5 +1890,7 @@ c1 c2 DROP TABLE t1; # -- End of Bug#34274 +create table `me:i`(id int); +drop table `me:i`; End of 5.1 tests diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index 2eeca1eea90..20a607da826 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -1532,5 +1532,11 @@ DROP TABLE t1; ########################################################################### +# +# Bug#40104 regression with table names? +# +create table `me:i`(id int); +drop table `me:i`; + --echo --echo End of 5.1 tests diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 51b16ba0f43..f20117ebac7 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3427,14 +3427,6 @@ bool mysql_create_table_no_lock(THD *thd, } else { - #ifdef FN_DEVCHAR - /* check if the table name contains FN_DEVCHAR when defined */ - if (strchr(alias, FN_DEVCHAR)) - { - my_error(ER_WRONG_TABLE_NAME, MYF(0), alias); - DBUG_RETURN(TRUE); - } -#endif path_length= build_table_filename(path, sizeof(path), db, alias, reg_ext, internal_tmp_table ? FN_IS_TMP : 0); } From 4e8fae9ec233c3b8beda1f6a800e8089c36d9fa8 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Wed, 24 Dec 2008 18:45:47 +0400 Subject: [PATCH 099/137] compiler warning fix --- sql/mysqld.cc | 2 +- sql/sql_acl.cc | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index f5e5b881a37..269e1aed7cc 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3616,6 +3616,7 @@ void decrement_handler_count() #endif /* defined(__NT__) || defined(HAVE_SMEM) */ +#ifndef EMBEDDED_LIBRARY #ifndef DBUG_OFF /* Debugging helper function to keep the locale database @@ -3654,7 +3655,6 @@ static void test_lc_time_sz() #endif//DBUG_OFF -#ifndef EMBEDDED_LIBRARY #ifdef __WIN__ int win_main(int argc, char **argv) #else diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 57029f46162..22135d376fe 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -5953,6 +5953,7 @@ int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr) } +#ifndef NO_EMBEDDED_ACCESS_CHECKS static bool update_schema_privilege(THD *thd, TABLE *table, char *buff, const char* db, const char* t_name, const char* column, uint col_length, @@ -5973,6 +5974,7 @@ static bool update_schema_privilege(THD *thd, TABLE *table, char *buff, table->field[i]->store(is_grantable, strlen(is_grantable), cs); return schema_table_store_record(thd, table); } +#endif int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond) From 59543e9f80a1947aefa069730be388d8fbcb9ec7 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Wed, 24 Dec 2008 19:01:41 +0400 Subject: [PATCH 100/137] Bug#25830 SHOW TABLE STATUS behaves differently depending on table name replace wild_case_compare with my_wildcmp which is multibyte safe function --- mysql-test/r/lowercase_utf8.result | 9 +++++++++ mysql-test/t/lowercase_utf8-master.opt | 4 ++++ mysql-test/t/lowercase_utf8.test | 9 +++++++++ sql/sql_show.cc | 17 +++++++++++++---- 4 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 mysql-test/r/lowercase_utf8.result create mode 100644 mysql-test/t/lowercase_utf8-master.opt create mode 100644 mysql-test/t/lowercase_utf8.test diff --git a/mysql-test/r/lowercase_utf8.result b/mysql-test/r/lowercase_utf8.result new file mode 100644 index 00000000000..043226e1f64 --- /dev/null +++ b/mysql-test/r/lowercase_utf8.result @@ -0,0 +1,9 @@ +set names utf8; +create table `Ö` (id int); +show tables from test like 'Ö'; +Tables_in_test (Ö) +ö +show tables from test like 'ö'; +Tables_in_test (ö) +ö +drop table `Ö`; diff --git a/mysql-test/t/lowercase_utf8-master.opt b/mysql-test/t/lowercase_utf8-master.opt new file mode 100644 index 00000000000..1b70aa33023 --- /dev/null +++ b/mysql-test/t/lowercase_utf8-master.opt @@ -0,0 +1,4 @@ +--lower-case-table-names=1 --character-set-server=utf8 + + + diff --git a/mysql-test/t/lowercase_utf8.test b/mysql-test/t/lowercase_utf8.test new file mode 100644 index 00000000000..01b154598fd --- /dev/null +++ b/mysql-test/t/lowercase_utf8.test @@ -0,0 +1,9 @@ +# +# Bug#25830 SHOW TABLE STATUS behaves differently depending on table name +# +set names utf8; +create table `Ö` (id int); +show tables from test like 'Ö'; +show tables from test like 'ö'; +drop table `Ö`; + diff --git a/sql/sql_show.cc b/sql/sql_show.cc index c10580e8913..322b1851560 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -287,11 +287,17 @@ find_files(THD *thd, List *files, const char *db, #ifndef NO_EMBEDDED_ACCESS_CHECKS uint col_access=thd->col_access; #endif + uint wild_length= 0; TABLE_LIST table_list; DBUG_ENTER("find_files"); - if (wild && !wild[0]) - wild=0; + if (wild) + { + if (!wild[0]) + wild= 0; + else + wild_length= strlen(wild); + } bzero((char*) &table_list,sizeof(table_list)); @@ -340,8 +346,11 @@ find_files(THD *thd, List *files, const char *db, { if (lower_case_table_names) { - if (wild_case_compare(files_charset_info, file->name, wild)) - continue; + if (my_wildcmp(files_charset_info, + file->name, file->name + strlen(file->name), + wild, wild + wild_length, + wild_prefix, wild_one, wild_many)) + continue; } else if (wild_compare(file->name,wild,0)) continue; From 026e9c36766ba81d728e189555b8a15f0d4c52ba Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Wed, 24 Dec 2008 19:14:59 +0400 Subject: [PATCH 101/137] Bug#41456 SET PASSWORD hates CURRENT_USER() init user->user struct with thd->security_ctx->priv_user context if user->user is not initializied --- mysql-test/r/grant.result | 5 +++++ mysql-test/t/grant.test | 7 +++++++ sql/set_var.cc | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index d56020c3090..ee328d461ac 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -1151,4 +1151,9 @@ drop user 'greg'@'localhost'; drop view v1; drop table test; drop function test_function; +SELECT CURRENT_USER(); +CURRENT_USER() +root@localhost +SET PASSWORD FOR CURRENT_USER() = PASSWORD("admin"); +SET PASSWORD FOR CURRENT_USER() = PASSWORD(""); End of 5.0 tests diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index e4b95502143..14c5879d007 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -1175,4 +1175,11 @@ drop view v1; drop table test; drop function test_function; +# +# Bug#41456 SET PASSWORD hates CURRENT_USER() +# +SELECT CURRENT_USER(); +SET PASSWORD FOR CURRENT_USER() = PASSWORD("admin"); +SET PASSWORD FOR CURRENT_USER() = PASSWORD(""); + --echo End of 5.0 tests diff --git a/sql/set_var.cc b/sql/set_var.cc index 59741e5683d..a29abe6581f 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -3475,6 +3475,7 @@ int set_var_password::check(THD *thd) #ifndef NO_EMBEDDED_ACCESS_CHECKS if (!user->host.str) { + DBUG_ASSERT(thd->security_ctx->priv_host); if (*thd->security_ctx->priv_host != 0) { user->host.str= (char *) thd->security_ctx->priv_host; @@ -3486,6 +3487,12 @@ int set_var_password::check(THD *thd) user->host.length= 1; } } + if (!user->user.str) + { + DBUG_ASSERT(thd->security_ctx->priv_user); + user->user.str= (char *) thd->security_ctx->priv_user; + user->user.length= strlen(thd->security_ctx->priv_user); + } /* Returns 1 as the function sends error to client */ return check_change_password(thd, user->host.str, user->user.str, password, strlen(password)) ? 1 : 0; From a31795b82d9b2f40cb2b489c99d6d03e036f039f Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Wed, 24 Dec 2008 19:24:11 +0400 Subject: [PATCH 102/137] Bug#40953 SELECT query throws "ERROR 1062 (23000): Duplicate entry..." error Table could be marked dependent because it is either 1) an inner table of an outer join, or 2) it is a part of STRAIGHT_JOIN. In case of STRAIGHT_JOIN table->maybe_null should not be assigned. The fix is to set st_table::maybe_null to 'true' only for those tables which are used in outer join. --- mysql-test/r/select.result | 33 +++++++++++++++++++++++++++++++++ mysql-test/t/select.test | 36 ++++++++++++++++++++++++++++++++++++ sql/sql_select.cc | 2 +- sql/sql_select.h | 6 +++++- 4 files changed, 75 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index c2cd2129a32..67ce231a157 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -4355,4 +4355,37 @@ Handler_read_prev 0 Handler_read_rnd 0 Handler_read_rnd_next 6 DROP TABLE t1, t2; +CREATE TABLE t1 (f1 bigint(20) NOT NULL default '0', +f2 int(11) NOT NULL default '0', +f3 bigint(20) NOT NULL default '0', +f4 varchar(255) NOT NULL default '', +PRIMARY KEY (f1), +KEY key1 (f4), +KEY key2 (f2)); +CREATE TABLE t2 (f1 int(11) NOT NULL default '0', +f2 enum('A1','A2','A3') NOT NULL default 'A1', +f3 int(11) NOT NULL default '0', +PRIMARY KEY (f1), +KEY key1 (f3)); +CREATE TABLE t3 (f1 bigint(20) NOT NULL default '0', +f2 datetime NOT NULL default '1980-01-01 00:00:00', +PRIMARY KEY (f1)); +insert into t1 values (1, 1, 1, 'abc'); +insert into t1 values (2, 1, 2, 'def'); +insert into t1 values (3, 1, 2, 'def'); +insert into t2 values (1, 'A1', 1); +insert into t3 values (1, '1980-01-01'); +SELECT a.f3, cr.f4, count(*) count +FROM t2 a +STRAIGHT_JOIN t1 cr ON cr.f2 = a.f1 +LEFT JOIN +(t1 cr2 +JOIN t3 ae2 ON cr2.f3 = ae2.f1 +) ON a.f1 = cr2.f2 AND ae2.f2 < now() - INTERVAL 7 DAY AND +cr.f4 = cr2.f4 +GROUP BY a.f3, cr.f4; +f3 f4 count +1 abc 1 +1 def 2 +drop table t1, t2, t3; End of 5.0 tests diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 1ee87957643..1e8dc7ac2f6 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -3701,4 +3701,40 @@ SELECT DISTINCT b FROM t1 LEFT JOIN t2 USING(a) WHERE c <= 3; SHOW STATUS LIKE 'Handler_read%'; DROP TABLE t1, t2; +# +# Bug#40953 SELECT query throws "ERROR 1062 (23000): Duplicate entry..." error +# +CREATE TABLE t1 (f1 bigint(20) NOT NULL default '0', + f2 int(11) NOT NULL default '0', + f3 bigint(20) NOT NULL default '0', + f4 varchar(255) NOT NULL default '', + PRIMARY KEY (f1), + KEY key1 (f4), + KEY key2 (f2)); +CREATE TABLE t2 (f1 int(11) NOT NULL default '0', + f2 enum('A1','A2','A3') NOT NULL default 'A1', + f3 int(11) NOT NULL default '0', + PRIMARY KEY (f1), + KEY key1 (f3)); +CREATE TABLE t3 (f1 bigint(20) NOT NULL default '0', + f2 datetime NOT NULL default '1980-01-01 00:00:00', + PRIMARY KEY (f1)); + +insert into t1 values (1, 1, 1, 'abc'); +insert into t1 values (2, 1, 2, 'def'); +insert into t1 values (3, 1, 2, 'def'); +insert into t2 values (1, 'A1', 1); +insert into t3 values (1, '1980-01-01'); + +SELECT a.f3, cr.f4, count(*) count +FROM t2 a +STRAIGHT_JOIN t1 cr ON cr.f2 = a.f1 +LEFT JOIN +(t1 cr2 + JOIN t3 ae2 ON cr2.f3 = ae2.f1 +) ON a.f1 = cr2.f2 AND ae2.f2 < now() - INTERVAL 7 DAY AND +cr.f4 = cr2.f4 +GROUP BY a.f3, cr.f4; + +drop table t1, t2, t3; --echo End of 5.0 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index d2c469f99da..230b9bb36cf 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2489,7 +2489,7 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables, COND *conds, if (s->dependent & table->map) s->dependent |= table->reginfo.join_tab->dependent; } - if (s->dependent) + if (outer_join & s->table->map) s->table->maybe_null= 1; } /* Catch illegal cross references for outer joins */ diff --git a/sql/sql_select.h b/sql/sql_select.h index c2f0780f5be..8ece01d3286 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -235,7 +235,11 @@ public: fetching data from a cursor */ bool resume_nested_loop; - table_map const_table_map,found_const_table_map,outer_join; + table_map const_table_map,found_const_table_map; + /* + Bitmap of all inner tables from outer joins + */ + table_map outer_join; ha_rows send_records,found_records,examined_rows,row_limit, select_limit; /* Used to fetch no more than given amount of rows per one From 7ac7726509e282d600643998ad8edc5bab5be35f Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Sun, 28 Dec 2008 12:33:49 +0100 Subject: [PATCH 103/137] Bug#40972: some sql execution lead the whole databse crashing Problem was an errornous date that lead to end partition was before the start, leading to a crash. Solution was to check greater or equal instead of only equal between start and end partition. NOTE: partitioning pruning handles incorrect dates differently than index lookup, which can give different results in a partitioned table versus a non partitioned table for queries having 'bad' dates in the where clause. --- mysql-test/r/partition_pruning.result | 12 ++++++++++++ mysql-test/t/partition_pruning.test | 16 ++++++++++++++++ sql/sql_partition.cc | 4 ++-- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/partition_pruning.result b/mysql-test/r/partition_pruning.result index b153ad9ad47..26ddc92e97b 100644 --- a/mysql-test/r/partition_pruning.result +++ b/mysql-test/r/partition_pruning.result @@ -1,4 +1,16 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +CREATE TABLE t1 +(a INT NOT NULL AUTO_INCREMENT, +b DATETIME, +PRIMARY KEY (a,b), +KEY (b)) +PARTITION BY RANGE (to_days(b)) +(PARTITION p0 VALUES LESS THAN (733681) COMMENT = 'LESS THAN 2008-10-01', +PARTITION p1 VALUES LESS THAN (733712) COMMENT = 'LESS THAN 2008-11-01', +PARTITION pX VALUES LESS THAN MAXVALUE); +SELECT a,b FROM t1 WHERE b >= '2008-12-01' AND b < '2009-12-00'; +a b +DROP TABLE t1; create table t1 ( a int not null) partition by hash(a) partitions 2; insert into t1 values (1),(2),(3); explain select * from t1 where a=5 and a=6; diff --git a/mysql-test/t/partition_pruning.test b/mysql-test/t/partition_pruning.test index 31008d2b011..ad102062ef8 100644 --- a/mysql-test/t/partition_pruning.test +++ b/mysql-test/t/partition_pruning.test @@ -8,6 +8,22 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; --enable_warnings +# +# Bug#40972: some sql execution lead the whole database crashing +# +# Setup so the start is at partition pX and end is at p1 +# Pruning does handle 'bad' dates differently. +CREATE TABLE t1 +(a INT NOT NULL AUTO_INCREMENT, + b DATETIME, + PRIMARY KEY (a,b), + KEY (b)) +PARTITION BY RANGE (to_days(b)) +(PARTITION p0 VALUES LESS THAN (733681) COMMENT = 'LESS THAN 2008-10-01', + PARTITION p1 VALUES LESS THAN (733712) COMMENT = 'LESS THAN 2008-11-01', + PARTITION pX VALUES LESS THAN MAXVALUE); +SELECT a,b FROM t1 WHERE b >= '2008-12-01' AND b < '2009-12-00'; +DROP TABLE t1; # Check if we can infer from condition on partition fields that # no records will match. diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index c1df5552eb9..9096a2b91ef 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -6760,7 +6760,7 @@ int get_part_iter_for_interval_via_mapping(partition_info *part_info, store_key_image_to_rec(field, max_value, field_len); bool include_endp= !test(flags & NEAR_MAX); part_iter->part_nums.end= get_endpoint(part_info, 0, include_endp); - if (part_iter->part_nums.start == part_iter->part_nums.end && + if (part_iter->part_nums.start >= part_iter->part_nums.end && !part_iter->ret_null_part) return 0; /* No partitions */ } @@ -6938,7 +6938,7 @@ int get_part_iter_for_interval_via_walking(partition_info *part_info, uint32 get_next_partition_id_range(PARTITION_ITERATOR* part_iter) { - if (part_iter->part_nums.cur == part_iter->part_nums.end) + if (part_iter->part_nums.cur >= part_iter->part_nums.end) { part_iter->part_nums.cur= part_iter->part_nums.start; return NOT_A_PARTITION_ID; From f67ce4761768a3ea05f8c4c11704fd5cd2065d3a Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Mon, 29 Dec 2008 16:06:53 +0400 Subject: [PATCH 104/137] Bug#41131 "Questions" fails to increment - ignores statements instead stored procs(5.0 ver) Added global status variable 'Queries' which represents total amount of queries executed by server including statements executed by SPs. note: It's old behaviour of 'Questions' variable. --- mysql-test/r/status.result | 25 +++++++++++++++++++++++++ mysql-test/t/status.test | 36 ++++++++++++++++++++++++++++++++++++ sql/mysqld.cc | 1 + sql/sql_show.cc | 3 +++ sql/structs.h | 2 +- 5 files changed, 66 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/status.result b/mysql-test/r/status.result index 36857e22aaf..971e399a3b6 100644 --- a/mysql-test/r/status.result +++ b/mysql-test/r/status.result @@ -91,3 +91,28 @@ SHOW SESSION STATUS LIKE 'Last_query_cost'; Variable_name Value Last_query_cost 4.805836 DROP TABLE t1; +DROP PROCEDURE IF EXISTS p1; +DROP FUNCTION IF EXISTS f1; +CREATE FUNCTION f1() RETURNS INTEGER +BEGIN +DECLARE foo INTEGER; +DECLARE bar INTEGER; +SET foo=1; +SET bar=2; +RETURN foo; +END $$ +CREATE PROCEDURE p1() +BEGIN +SELECT 1; +END $$ +SELECT f1(); +f1() +1 +CALL p1(); +1 +1 +SELECT 9; +9 +9 +DROP PROCEDURE p1; +DROP FUNCTION f1; diff --git a/mysql-test/t/status.test b/mysql-test/t/status.test index 33bba3a626a..ee92d649f47 100644 --- a/mysql-test/t/status.test +++ b/mysql-test/t/status.test @@ -171,4 +171,40 @@ SHOW SESSION STATUS LIKE 'Last_query_cost'; DROP TABLE t1; +# +# Bug#41131 "Questions" fails to increment - ignores statements instead stored procs +# +connect (con1,localhost,root,,); +connection con1; +--disable_warnings +DROP PROCEDURE IF EXISTS p1; +DROP FUNCTION IF EXISTS f1; +--enable_warnings +DELIMITER $$; +CREATE FUNCTION f1() RETURNS INTEGER +BEGIN + DECLARE foo INTEGER; + DECLARE bar INTEGER; + SET foo=1; + SET bar=2; + RETURN foo; +END $$ +CREATE PROCEDURE p1() + BEGIN + SELECT 1; +END $$ +DELIMITER ;$$ +let $org_queries= `SHOW STATUS LIKE 'Queries'`; +SELECT f1(); +CALL p1(); +let $new_queries= `SHOW STATUS LIKE 'Queries'`; +--disable_log +let $diff= `SELECT SUBSTRING('$new_queries',9)-SUBSTRING('$org_queries',9)`; +--enable_log +eval SELECT $diff; +disconnect con1; +connection default; +DROP PROCEDURE p1; +DROP FUNCTION f1; + # End of 5.0 tests diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 269e1aed7cc..ca68976d939 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -6620,6 +6620,7 @@ struct show_var_st status_vars[]= { {"Qcache_queries_in_cache", (char*) &query_cache.queries_in_cache, SHOW_LONG_CONST}, {"Qcache_total_blocks", (char*) &query_cache.total_blocks, SHOW_LONG_CONST}, #endif /*HAVE_QUERY_CACHE*/ + {"Queries", (char*) 0, SHOW_QUERIES}, {"Questions", (char*) offsetof(STATUS_VAR, questions), SHOW_LONG_STATUS}, diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 322b1851560..2d8d6b13d4e 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1543,6 +1543,9 @@ static bool show_status_array(THD *thd, const char *wild, nr= (long) (thd->query_start() - server_start_time); end= int10_to_str(nr, buff, 10); break; + case SHOW_QUERIES: + end= int10_to_str((long) thd->query_id, buff, 10); + break; #ifdef HAVE_REPLICATION case SHOW_RPL_STATUS: end= strmov(buff, rpl_status_type[(int)rpl_status]); diff --git a/sql/structs.h b/sql/structs.h index ab8537612fa..9882119b7c5 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -170,7 +170,7 @@ enum SHOW_TYPE SHOW_UNDEF, SHOW_LONG, SHOW_LONGLONG, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR, SHOW_DOUBLE_STATUS, - SHOW_BOOL, SHOW_MY_BOOL, SHOW_OPENTABLES, SHOW_STARTTIME, + SHOW_BOOL, SHOW_MY_BOOL, SHOW_OPENTABLES, SHOW_STARTTIME, SHOW_QUERIES, SHOW_LONG_CONST, SHOW_INT_CONST, SHOW_HAVE, SHOW_SYS, SHOW_HA_ROWS, SHOW_VARS, #ifdef HAVE_OPENSSL From c9245922d6dc5a7dedca24c160c0ae791d55aa69 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Mon, 29 Dec 2008 16:50:51 +0400 Subject: [PATCH 105/137] Bug#41441 repair csv table crashes debug server The problem: data file can not be deleted on win because there is another opened instance of this file. Data file might be opened twice, on table opening stage and during write_row execution. We need to close both instances to satisfy Win. --- mysql-test/r/csv.result | 13 +++++++++++++ mysql-test/t/csv.test | 13 +++++++++++++ storage/csv/ha_tina.cc | 11 +++++++++++ 3 files changed, 37 insertions(+) diff --git a/mysql-test/r/csv.result b/mysql-test/r/csv.result index 8bc6114dbc2..9deaf55c535 100644 --- a/mysql-test/r/csv.result +++ b/mysql-test/r/csv.result @@ -5394,4 +5394,17 @@ select * from t1; ERROR HY000: File './test/t1.CSV' not found (Errcode: 2) unlock tables; drop table t1; +create table t1(a enum ('a') not null) engine=csv; +insert into t1 values (2); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +select * from t1 limit 1; +ERROR HY000: Table 't1' is marked as crashed and should be repaired +repair table t1; +Table Op Msg_type Msg_text +test.t1 repair Warning Data truncated for column 'a' at row 1 +test.t1 repair status OK +select * from t1 limit 1; +a +drop table t1; End of 5.1 tests diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test index ac628f96a0f..67295e8756f 100644 --- a/mysql-test/t/csv.test +++ b/mysql-test/t/csv.test @@ -1804,4 +1804,17 @@ unlock tables; drop table t1; --disconnect con1 +# +# Bug#41441 repair csv table crashes debug server +# +# Note: The test should be removed after Bug#33717 is fixed + +create table t1(a enum ('a') not null) engine=csv; +insert into t1 values (2); +--error ER_CRASHED_ON_USAGE +select * from t1 limit 1; +repair table t1; +select * from t1 limit 1; +drop table t1; + --echo End of 5.1 tests diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index a1ff0e29ad1..368ce7e28f3 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -1439,6 +1439,17 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt) a file, which descriptor is still open. EACCES will be returned when trying to delete the "to"-file in my_rename(). */ + if (share->tina_write_opened) + { + /* + Data file might be opened twice, on table opening stage and + during write_row execution. We need to close both instances + to satisfy Win. + */ + if (my_close(share->tina_write_filedes, MYF(0))) + DBUG_RETURN(my_errno ? my_errno : -1); + share->tina_write_opened= FALSE; + } if (my_close(data_file,MYF(0)) || my_close(repair_file, MYF(0)) || my_rename(repaired_fname, share->data_file_name, MYF(0))) DBUG_RETURN(-1); From 05d7673340a8c9fcf3ced59384adee63a4adf280 Mon Sep 17 00:00:00 2001 From: Sven Sandberg Date: Mon, 29 Dec 2008 17:04:10 +0100 Subject: [PATCH 106/137] BUG#40482: server/mysqlbinlog crashes when reading invalid Incident_log_event Problem: When an Incident_log_event contains a bad incident number on disk, the server crashes with an assertion. Fix: Don't validate input with assertions. Use errors. --- mysql-test/include/cleanup_fake_relay_log.inc | 16 ++++ mysql-test/include/setup_fake_relay_log.inc | 78 ++++++++++++++++++ mysql-test/std_data/bug40482-bin.000001 | Bin 0 -> 172 bytes .../suite/rpl/r/rpl_binlog_corruption.result | 8 ++ .../rpl/t/rpl_binlog_corruption-master.opt | 1 + .../suite/rpl/t/rpl_binlog_corruption.test | 42 ++++++++++ sql/log_event.cc | 15 +++- sql/log_event.h | 5 +- sql/rpl_constants.h | 4 +- 9 files changed, 162 insertions(+), 7 deletions(-) create mode 100644 mysql-test/include/cleanup_fake_relay_log.inc create mode 100644 mysql-test/include/setup_fake_relay_log.inc create mode 100644 mysql-test/std_data/bug40482-bin.000001 create mode 100644 mysql-test/suite/rpl/r/rpl_binlog_corruption.result create mode 100644 mysql-test/suite/rpl/t/rpl_binlog_corruption-master.opt create mode 100644 mysql-test/suite/rpl/t/rpl_binlog_corruption.test diff --git a/mysql-test/include/cleanup_fake_relay_log.inc b/mysql-test/include/cleanup_fake_relay_log.inc new file mode 100644 index 00000000000..43aa46cb657 --- /dev/null +++ b/mysql-test/include/cleanup_fake_relay_log.inc @@ -0,0 +1,16 @@ +# ==== Purpose ==== +# +# Clean up files create by setup_fake_relay_log.inc. +# +# ==== Usage ==== +# +# See setup_fake_relay_log.inc + +--echo Cleaning up after setup_fake_relay_log.inc + +# Remove files. +remove_file $_fake_relay_log; +remove_file $_fake_relay_index; +--disable_query_log +eval SET @@global.relay_log_purge= $_fake_relay_log_purge; +--enable_query_log diff --git a/mysql-test/include/setup_fake_relay_log.inc b/mysql-test/include/setup_fake_relay_log.inc new file mode 100644 index 00000000000..8113ed6dc10 --- /dev/null +++ b/mysql-test/include/setup_fake_relay_log.inc @@ -0,0 +1,78 @@ +# ==== Purpose ==== +# +# Setup replication from an existing relay log in the current +# connection. +# +# ==== Usage ==== +# +# Make sure the slave is not running and issue: +# +# let $fake_relay_log= /path/to/fake-relay-log-file.000001 +# source include/setup_fake_relay_log.inc; +# START SLAVE SQL_THREAD; # setup_fake_relay_log doesn't start slave +# ... +# source include/cleanup_fake_relay_log.inc +# +# You must run the server with --relay-log=FILE. You probably want to +# run with --replicate-same-server-id too. +# +# ==== Implementation ==== +# +# First makes a sanity check, ensuring that the slave threads are not +# running. Then copies the $fake_relay_log to RELAY_BIN-fake.000001, +# where RELAY_BIN is the basename of the relay log, and updates +# RELAY_BIN.index. Finally issues CHANGE MASTER so that it uses the +# given files. +# +# ==== Side effects ==== +# +# Creates a binlog file and a binlog index file, and sets +# @@global.relay_log_purge=1. All this is restored when you call +# cleanup_fake_relay_log.inc. +# +# Enables the query log. + + +--disable_query_log + +# Print message. +let $_fake_relay_log_printable= `SELECT REPLACE('$fake_relay_log', '$MYSQL_TEST_DIR', 'MYSQL_TEST_DIR')`; +--echo Setting up fake replication from $_fake_relay_log_printable + +# Sanity check. +let $_sql_running= query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1); +let $_io_running= query_get_value(SHOW SLAVE STATUS, Slave_IO_Running, 1); +if (`SELECT "$_sql_running" = "Yes" OR "$_io_running" = "Yes"`) { + --echo Error: Slave was running when test case sourced + --echo include/setup_fake_replication.inc + --echo Slave_IO_Running = $_io_running; Slave_SQL_Running = $_sql_running + --echo Printing some debug info: + SHOW SLAVE STATUS; + SHOW MASTER STATUS; + SHOW BINLOG EVENTS; + SHOW PROCESSLIST; +} + +# Read server variables. +let $MYSQLD_DATADIR= `SELECT @@datadir`; +let $_fake_filename= query_get_value(SHOW VARIABLES LIKE 'relay_log', Value, 1); +if (`SELECT '$_fake_filename' = ''`) { + --echo Badly written test case: relay_log variable is empty. Please use the + --echo server option --relay-log=FILE. +} +let $_fake_relay_log= $MYSQLD_DATADIR/$_fake_filename-fake.000001; +let $_fake_relay_index= $MYSQLD_DATADIR/$_fake_filename.index; +# Need to restore relay_log_purge in cleanup_fake_relay_log.inc, since +# CHANGE MASTER modifies it (see the manual for CHANGE MASTER). +let $_fake_relay_log_purge= `SELECT @@global.relay_log_purge`; + +# Create relay log file. +copy_file $fake_relay_log $_fake_relay_log; + +# Create relay log index. +eval SELECT '$_fake_relay_log' INTO OUTFILE '$_fake_relay_index'; + +# Setup replication from existing relay log. +eval CHANGE MASTER TO MASTER_HOST='dummy.localdomain', RELAY_LOG_FILE='$_fake_relay_log', RELAY_LOG_POS=4; + +--enable_query_log diff --git a/mysql-test/std_data/bug40482-bin.000001 b/mysql-test/std_data/bug40482-bin.000001 new file mode 100644 index 0000000000000000000000000000000000000000..d001bf664c7096f862e741ef6d93f58b6bdd6796 GIT binary patch literal 172 zcmeyDl$mF&%J0d~$iTpm2E(uint2korr(buf + common_header_len)); + int incident_number= uint2korr(buf + common_header_len); + if (incident_number >= INCIDENT_COUNT || + incident_number <= INCIDENT_NONE) + { + // If the incident is not recognized, this binlog event is + // invalid. If we set incident_number to INCIDENT_NONE, the + // invalidity will be detected by is_valid(). + incident_number= INCIDENT_NONE; + DBUG_VOID_RETURN; + } + m_incident= static_cast(incident_number); char const *ptr= buf + common_header_len + post_header_len; char const *const str_end= buf + event_len; uint8 len= 0; // Assignment to keep compiler happy @@ -9085,9 +9095,6 @@ Incident_log_event::description() const DBUG_PRINT("info", ("m_incident: %d", m_incident)); - DBUG_ASSERT(0 <= m_incident); - DBUG_ASSERT((size_t) m_incident <= sizeof(description)/sizeof(*description)); - return description[m_incident]; } diff --git a/sql/log_event.h b/sql/log_event.h index 3c109b798d3..db14341b51d 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -3870,7 +3870,10 @@ public: virtual Log_event_type get_type_code() { return INCIDENT_EVENT; } - virtual bool is_valid() const { return 1; } + virtual bool is_valid() const + { + return m_incident > INCIDENT_NONE && m_incident < INCIDENT_COUNT; + } virtual int get_data_size() { return INCIDENT_HEADER_LEN + 1 + m_message.length; } diff --git a/sql/rpl_constants.h b/sql/rpl_constants.h index 426e80a328d..32fb4b8a7f2 100644 --- a/sql/rpl_constants.h +++ b/sql/rpl_constants.h @@ -6,10 +6,10 @@ */ enum Incident { /** No incident */ - INCIDENT_NONE, + INCIDENT_NONE = 0, /** There are possibly lost events in the replication stream */ - INCIDENT_LOST_EVENTS, + INCIDENT_LOST_EVENTS = 1, /** Shall be last event of the enumeration */ INCIDENT_COUNT From db36c3250ae73e2b785155ea6c19b5d32715c0a6 Mon Sep 17 00:00:00 2001 From: Sven Sandberg Date: Tue, 30 Dec 2008 09:48:19 +0100 Subject: [PATCH 107/137] BUG#41793: rpl_binlog_corruption disabled in main (needs new mtr) Disabled rpl_binlog_corruption since it requires the new mtr, which only exists in 5.1-rpl / 6.0-rpl. Please re-enable the test in 5.1-rpl / 6.0-rpl. --- mysql-test/suite/rpl/t/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/rpl/t/disabled.def b/mysql-test/suite/rpl/t/disabled.def index 8cae44a3607..f3f329c4b5b 100644 --- a/mysql-test/suite/rpl/t/disabled.def +++ b/mysql-test/suite/rpl/t/disabled.def @@ -10,3 +10,4 @@ # ############################################################################## +rpl_binlog_corruption : BUG#41793 2008-12-30 sven rpl_binlog_corruption disabled in main (needs new mtr) From 33cbf93cedf153f502f8bd2980c71d2cc0025eda Mon Sep 17 00:00:00 2001 From: Gleb Shchepa Date: Wed, 31 Dec 2008 15:55:04 +0400 Subject: [PATCH 108/137] Bug #41363: crash of mysqld on windows with aggregate in case Execution of queries containing the CASE function of aggregate function like in "SELECT ... CASE ARGV(...) WHEN ..." crashed the server. The CASE function caches pointers to concrete comparison functions for an each pair of types of CASE-WHERE clause parameters, i.e. for the "CASE INT_RESULT WHERE REAL_RESULT THEN ... WHERE DECIMAL_RESULT ... END" function call it caches comparisons for INT_RESULT with REAL_RESULT and for INT_RESULT with DECIMAL_RESULT. Usually a result type is known after a call to the fix_fields function, however, the setup_copy_fields function call may wrap aggregate items with Item_copy_string that has STRING_RESULT result type, so setup_copy_fields may change argument result types of the CASE function after call to Item_func_case::fix_fields/fix_length_and_dec. Then the Item_func_case::find_item function tries to use comparison function for unexpected pair of the STRING_RESULT and some other type - that caused an assertion failure of server crash. The Item_func_case::fix_length_and_dec function has been modified to take into account possible STRING_RESULT result type in the presence of aggregate arguments of the CASE function. --- mysql-test/r/func_in.result | 12 ++++++++++++ mysql-test/t/func_in.test | 13 +++++++++++++ sql/item_cmpfunc.cc | 10 ++++++++++ 3 files changed, 35 insertions(+) diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result index e761fb851fb..1e967b668c5 100644 --- a/mysql-test/r/func_in.result +++ b/mysql-test/r/func_in.result @@ -575,4 +575,16 @@ id select * from t1 where NOT id in (null, 1); id drop table t1; +CREATE TABLE t1(c0 INTEGER, c1 INTEGER, c2 INTEGER); +INSERT INTO t1 VALUES(1, 1, 1), (1, 1, 1); +SELECT CASE AVG (c0) WHEN c1 * c2 THEN 1 END FROM t1; +CASE AVG (c0) WHEN c1 * c2 THEN 1 END +1 +SELECT CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END FROM t1; +CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END +2 +SELECT CASE c1 WHEN c1 + 1 THEN 1 END, ABS(AVG(c0)) FROM t1; +CASE c1 WHEN c1 + 1 THEN 1 END ABS(AVG(c0)) +NULL 1.0000 +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test index d0d4dea0713..3fc1697f146 100644 --- a/mysql-test/t/func_in.test +++ b/mysql-test/t/func_in.test @@ -426,4 +426,17 @@ select * from t1 where NOT id in (select null union all select 1); select * from t1 where NOT id in (null, 1); drop table t1; +# +# Bug #41363: crash of mysqld on windows with aggregate in case +# + +CREATE TABLE t1(c0 INTEGER, c1 INTEGER, c2 INTEGER); +INSERT INTO t1 VALUES(1, 1, 1), (1, 1, 1); + +SELECT CASE AVG (c0) WHEN c1 * c2 THEN 1 END FROM t1; +SELECT CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END FROM t1; +SELECT CASE c1 WHEN c1 + 1 THEN 1 END, ABS(AVG(c0)) FROM t1; + +DROP TABLE t1; + --echo End of 5.1 tests diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index c6b70440b41..813e50e0693 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2713,6 +2713,16 @@ void Item_func_case::fix_length_and_dec() nagg++; if (!(found_types= collect_cmp_types(agg, nagg))) return; + if (with_sum_func || current_thd->lex->current_select->group_list.elements) + { + /* + See TODO commentary in the setup_copy_fields function: + item in a group may be wrapped with an Item_copy_string item. + That item has a STRING_RESULT result type, so we need + to take this type into account. + */ + found_types |= (1 << item_cmp_type(left_result_type, STRING_RESULT)); + } for (i= 0; i <= (uint)DECIMAL_RESULT; i++) { From e56284128f628691dff3541d326b819b87eda571 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Mon, 5 Jan 2009 12:37:56 +0200 Subject: [PATCH 109/137] Reverted the fix for bug #25830 because of omissions and non-complete test case. --- mysql-test/r/lowercase_utf8.result | 9 --------- mysql-test/t/lowercase_utf8-master.opt | 4 ---- mysql-test/t/lowercase_utf8.test | 9 --------- sql/sql_show.cc | 17 ++++------------- 4 files changed, 4 insertions(+), 35 deletions(-) delete mode 100644 mysql-test/r/lowercase_utf8.result delete mode 100644 mysql-test/t/lowercase_utf8-master.opt delete mode 100644 mysql-test/t/lowercase_utf8.test diff --git a/mysql-test/r/lowercase_utf8.result b/mysql-test/r/lowercase_utf8.result deleted file mode 100644 index 043226e1f64..00000000000 --- a/mysql-test/r/lowercase_utf8.result +++ /dev/null @@ -1,9 +0,0 @@ -set names utf8; -create table `Ö` (id int); -show tables from test like 'Ö'; -Tables_in_test (Ö) -ö -show tables from test like 'ö'; -Tables_in_test (ö) -ö -drop table `Ö`; diff --git a/mysql-test/t/lowercase_utf8-master.opt b/mysql-test/t/lowercase_utf8-master.opt deleted file mode 100644 index 1b70aa33023..00000000000 --- a/mysql-test/t/lowercase_utf8-master.opt +++ /dev/null @@ -1,4 +0,0 @@ ---lower-case-table-names=1 --character-set-server=utf8 - - - diff --git a/mysql-test/t/lowercase_utf8.test b/mysql-test/t/lowercase_utf8.test deleted file mode 100644 index 01b154598fd..00000000000 --- a/mysql-test/t/lowercase_utf8.test +++ /dev/null @@ -1,9 +0,0 @@ -# -# Bug#25830 SHOW TABLE STATUS behaves differently depending on table name -# -set names utf8; -create table `Ö` (id int); -show tables from test like 'Ö'; -show tables from test like 'ö'; -drop table `Ö`; - diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 2d8d6b13d4e..d6bb3427fe4 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -287,17 +287,11 @@ find_files(THD *thd, List *files, const char *db, #ifndef NO_EMBEDDED_ACCESS_CHECKS uint col_access=thd->col_access; #endif - uint wild_length= 0; TABLE_LIST table_list; DBUG_ENTER("find_files"); - if (wild) - { - if (!wild[0]) - wild= 0; - else - wild_length= strlen(wild); - } + if (wild && !wild[0]) + wild=0; bzero((char*) &table_list,sizeof(table_list)); @@ -346,11 +340,8 @@ find_files(THD *thd, List *files, const char *db, { if (lower_case_table_names) { - if (my_wildcmp(files_charset_info, - file->name, file->name + strlen(file->name), - wild, wild + wild_length, - wild_prefix, wild_one, wild_many)) - continue; + if (wild_case_compare(files_charset_info, file->name, wild)) + continue; } else if (wild_compare(file->name,wild,0)) continue; From ece07248f4cd7b6db4d352adf5be719d23ce2d85 Mon Sep 17 00:00:00 2001 From: Patrick Crews Date: Mon, 5 Jan 2009 12:10:22 -0500 Subject: [PATCH 110/137] Bug#38833: mysql-test-run needs diff. Problem w/ error handling in calling diff on Windows. Added function to check for diff and return an error message if the utility is not present. Previously, the way we did this didn't work on Windows, but did work on *Nix systems. --- client/mysqltest.c | 81 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 63 insertions(+), 18 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 9c7c4d62f6f..d73cf78d9d4 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1329,6 +1329,35 @@ static int run_tool(const char *tool_path, DYNAMIC_STRING *ds_res, ...) DBUG_RETURN(ret); } +/* + Test if diff is present. This is needed on Windows systems + as the OS returns 1 whether diff is successful or if it is + not present. + + We run diff -v and look for output in stdout. + We don't redirect stderr to stdout to make for a simplified check + Windows will output '"diff"' is not recognized... to stderr if it is + not present. +*/ + +int diff_check() +{ + char buf[512]= {0}; + FILE *res_file; + char *cmd = "diff -v"; + int have_diff = 0; + + if (!(res_file= popen(cmd, "r"))) + die("popen(\"%s\", \"r\") failed", cmd); + +/* if diff is not present, nothing will be in stdout to increment have_diff */ + if (fgets(buf, sizeof(buf), res_file)) + { + have_diff += 1; + } + pclose(res_file); + return have_diff; +} /* Show the diff of two files using the systems builtin diff @@ -1348,34 +1377,51 @@ void show_diff(DYNAMIC_STRING* ds, { DYNAMIC_STRING ds_tmp; + int have_diff = 0; if (init_dynamic_string(&ds_tmp, "", 256, 256)) die("Out of memory"); + + /* determine if we have diff on Windows + needs special processing due to return values + on that OS + */ + have_diff = diff_check(); - /* First try with unified diff */ - if (run_tool("diff", - &ds_tmp, /* Get output from diff in ds_tmp */ - "-u", - filename1, - filename2, - "2>&1", - NULL) > 1) /* Most "diff" tools return >1 if error */ + if (have_diff) { - dynstr_set(&ds_tmp, ""); - - /* Fallback to context diff with "diff -c" */ + /* First try with unified diff */ if (run_tool("diff", &ds_tmp, /* Get output from diff in ds_tmp */ - "-c", + "-u", filename1, filename2, "2>&1", NULL) > 1) /* Most "diff" tools return >1 if error */ { - /* - Fallback to dump both files to result file and inform - about installing "diff" - */ + dynstr_set(&ds_tmp, ""); + + /* Fallback to context diff with "diff -c" */ + if (run_tool("diff", + &ds_tmp, /* Get output from diff in ds_tmp */ + "-c", + filename1, + filename2, + "2>&1", + NULL) > 1) /* Most "diff" tools return >1 if error */ + { + have_diff= 1; + } + } + } + +if (!(have_diff)) + { + /* + Fallback to dump both files to result file and inform + about installing "diff" + */ + dynstr_set(&ds_tmp, ""); dynstr_append(&ds_tmp, @@ -1399,8 +1445,7 @@ void show_diff(DYNAMIC_STRING* ds, dynstr_append(&ds_tmp, " >>>\n"); cat_file(&ds_tmp, filename2); dynstr_append(&ds_tmp, "<<<<\n"); - } - } + } if (ds) { From dc5a0f4481e09fa7423231c154e1bb1a8f8c55d1 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Wed, 7 Jan 2009 10:11:37 -0200 Subject: [PATCH 111/137] Bug#41348: INSERT INTO tbl SELECT * FROM temp_tbl overwrites locking type of temp table The problem is that INSERT INTO .. SELECT FROM .. and CREATE TABLE .. SELECT FROM a temporary table could inadvertently overwrite the locking type of the temporary table. The lock type of temporary tables should be a write lock by default. The solution is to reset the lock type of temporary tables back to its default value after they are used in a statement. --- mysql-test/r/innodb_mysql.result | 21 ++++++++++++++++ mysql-test/r/temp_table.result | 16 +++++++++++++ mysql-test/t/innodb_mysql.test | 41 ++++++++++++++++++++++++++++++++ mysql-test/t/temp_table.test | 31 ++++++++++++++++++++++++ sql/sql_base.cc | 23 +++++++++++++++++- 5 files changed, 131 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index 075b4f84f2d..a1116a78bda 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -1767,4 +1767,25 @@ ref NULL rows 6 Extra Using where; Using index DROP TABLE foo, bar, foo2; +DROP TABLE IF EXISTS t1,t3,t2; +DROP FUNCTION IF EXISTS f1; +CREATE FUNCTION f1() RETURNS VARCHAR(250) +BEGIN +return 'hhhhhhh' ; +END| +CREATE TABLE t1 (a VARCHAR(20), b VARCHAR(20), c VARCHAR(20)) ENGINE=INNODB; +BEGIN WORK; +CREATE TEMPORARY TABLE t2 (a VARCHAR(20), b VARCHAR(20), c varchar(20)) ENGINE=INNODB; +CREATE TEMPORARY TABLE t3 LIKE t2; +INSERT INTO t1 VALUES ('a','b',NULL),('c','d',NULL),('e','f',NULL); +SET @stmt := CONCAT('INSERT INTO t2 SELECT tbl.a, tbl.b, f1()',' FROM t1 tbl'); +PREPARE stmt1 FROM @stmt; +SET @stmt := CONCAT('INSERT INTO t3', ' SELECT * FROM t2'); +PREPARE stmt3 FROM @stmt; +EXECUTE stmt1; +COMMIT; +DEALLOCATE PREPARE stmt1; +DEALLOCATE PREPARE stmt3; +DROP TABLE t1,t3,t2; +DROP FUNCTION f1; End of 5.1 tests diff --git a/mysql-test/r/temp_table.result b/mysql-test/r/temp_table.result index 6df09463d02..ba6b9f81a2d 100644 --- a/mysql-test/r/temp_table.result +++ b/mysql-test/r/temp_table.result @@ -194,4 +194,20 @@ DELETE FROM t1; SELECT * FROM t1; a b DROP TABLE t1; +DROP TABLE IF EXISTS t1,t2; +DROP FUNCTION IF EXISTS f1; +CREATE TEMPORARY TABLE t1 (a INT); +CREATE TEMPORARY TABLE t2 LIKE t1; +CREATE FUNCTION f1() RETURNS INT +BEGIN +return 1; +END| +INSERT INTO t2 SELECT * FROM t1; +INSERT INTO t1 SELECT f1(); +CREATE TABLE t3 SELECT * FROM t1; +INSERT INTO t1 SELECT f1(); +UPDATE t1,t2 SET t1.a = t2.a; +INSERT INTO t2 SELECT f1(); +DROP TABLE t1,t2,t3; +DROP FUNCTION f1; End of 5.1 tests diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test index 1f9c08ac43b..5a2e115a98d 100644 --- a/mysql-test/t/innodb_mysql.test +++ b/mysql-test/t/innodb_mysql.test @@ -91,4 +91,45 @@ INSERT INTO foo2 SELECT * FROM foo; DROP TABLE foo, bar, foo2; +# +# Bug#41348: INSERT INTO tbl SELECT * FROM temp_tbl overwrites locking type of temp table +# + +--disable_warnings +DROP TABLE IF EXISTS t1,t3,t2; +DROP FUNCTION IF EXISTS f1; +--enable_warnings + +DELIMITER |; +CREATE FUNCTION f1() RETURNS VARCHAR(250) + BEGIN + return 'hhhhhhh' ; + END| +DELIMITER ;| + +CREATE TABLE t1 (a VARCHAR(20), b VARCHAR(20), c VARCHAR(20)) ENGINE=INNODB; + +BEGIN WORK; + +CREATE TEMPORARY TABLE t2 (a VARCHAR(20), b VARCHAR(20), c varchar(20)) ENGINE=INNODB; +CREATE TEMPORARY TABLE t3 LIKE t2; + +INSERT INTO t1 VALUES ('a','b',NULL),('c','d',NULL),('e','f',NULL); + +SET @stmt := CONCAT('INSERT INTO t2 SELECT tbl.a, tbl.b, f1()',' FROM t1 tbl'); +PREPARE stmt1 FROM @stmt; + +SET @stmt := CONCAT('INSERT INTO t3', ' SELECT * FROM t2'); +PREPARE stmt3 FROM @stmt; + +EXECUTE stmt1; + +COMMIT; + +DEALLOCATE PREPARE stmt1; +DEALLOCATE PREPARE stmt3; + +DROP TABLE t1,t3,t2; +DROP FUNCTION f1; + --echo End of 5.1 tests diff --git a/mysql-test/t/temp_table.test b/mysql-test/t/temp_table.test index 4ab8a982e63..2bfa4936c91 100644 --- a/mysql-test/t/temp_table.test +++ b/mysql-test/t/temp_table.test @@ -204,4 +204,35 @@ DELETE FROM t1; SELECT * FROM t1; DROP TABLE t1; +# +# Bug#41348: INSERT INTO tbl SELECT * FROM temp_tbl overwrites locking type of temp table +# + +--disable_warnings +DROP TABLE IF EXISTS t1,t2; +DROP FUNCTION IF EXISTS f1; +--enable_warnings + +CREATE TEMPORARY TABLE t1 (a INT); +CREATE TEMPORARY TABLE t2 LIKE t1; + +DELIMITER |; +CREATE FUNCTION f1() RETURNS INT + BEGIN + return 1; + END| +DELIMITER ;| + +INSERT INTO t2 SELECT * FROM t1; +INSERT INTO t1 SELECT f1(); + +CREATE TABLE t3 SELECT * FROM t1; +INSERT INTO t1 SELECT f1(); + +UPDATE t1,t2 SET t1.a = t2.a; +INSERT INTO t2 SELECT f1(); + +DROP TABLE t1,t2,t3; +DROP FUNCTION f1; + --echo End of 5.1 tests diff --git a/sql/sql_base.cc b/sql/sql_base.cc index ea664cd5091..6db9f1df0f2 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1111,6 +1111,27 @@ static void mark_temp_tables_as_free_for_reuse(THD *thd) */ if (table->child_l || table->parent) detach_merge_children(table, TRUE); + /* + Reset temporary table lock type to it's default value (TL_WRITE). + + Statements such as INSERT INTO .. SELECT FROM tmp, CREATE TABLE + .. SELECT FROM tmp and UPDATE may under some circumstances modify + the lock type of the tables participating in the statement. This + isn't a problem for non-temporary tables since their lock type is + reset at every open, but the same does not occur for temporary + tables for historical reasons. + + Furthermore, the lock type of temporary tables is not really that + important because they can only be used by one query at a time and + not even twice in a query -- a temporary table is represented by + only one TABLE object. Nonetheless, it's safer from a maintenance + point of view to reset the lock type of this singleton TABLE object + as to not cause problems when the table is reused. + + Even under LOCK TABLES mode its okay to reset the lock type as + LOCK TABLES is allowed (but ignored) for a temporary table. + */ + table->reginfo.lock_type= TL_WRITE; } } } @@ -4681,7 +4702,7 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags) else if (tables->lock_type == TL_READ_DEFAULT) tables->table->reginfo.lock_type= read_lock_type_for_table(thd, tables->table); - else if (tables->table->s->tmp_table == NO_TMP_TABLE) + else tables->table->reginfo.lock_type= tables->lock_type; } tables->table->grant= tables->grant; From b2944d215c7e2532edfed85ef6b109b37f5b7a11 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 7 Jan 2009 13:44:32 +0100 Subject: [PATCH 112/137] fix misspelling --- sql/mysqld.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 022dbdbe7e3..1e9d942b1dd 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -230,7 +230,7 @@ extern "C" sig_handler handle_segfault(int sig); #if defined(__linux__) #define ENABLE_TEMP_POOL 1 #else -#define ENABLE_TEMP_TOOL 0 +#define ENABLE_TEMP_POOL 0 #endif /* Constants */ From d4461fcc6c2d11dc0c1ca1cc6091533caf85a9b8 Mon Sep 17 00:00:00 2001 From: Matthias Leich Date: Wed, 7 Jan 2009 22:38:03 +0100 Subject: [PATCH 113/137] Fix of Bug#41932 funcs_1: is_collation_character_set_applicability path too long for tar --- ...er_set_applicability.result => is_coll_char_set_appl.result} | 0 ...racter_set_applicability.test => is_coll_char_set_appl.test} | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename mysql-test/suite/funcs_1/r/{is_collation_character_set_applicability.result => is_coll_char_set_appl.result} (100%) rename mysql-test/suite/funcs_1/t/{is_collation_character_set_applicability.test => is_coll_char_set_appl.test} (98%) diff --git a/mysql-test/suite/funcs_1/r/is_collation_character_set_applicability.result b/mysql-test/suite/funcs_1/r/is_coll_char_set_appl.result similarity index 100% rename from mysql-test/suite/funcs_1/r/is_collation_character_set_applicability.result rename to mysql-test/suite/funcs_1/r/is_coll_char_set_appl.result diff --git a/mysql-test/suite/funcs_1/t/is_collation_character_set_applicability.test b/mysql-test/suite/funcs_1/t/is_coll_char_set_appl.test similarity index 98% rename from mysql-test/suite/funcs_1/t/is_collation_character_set_applicability.test rename to mysql-test/suite/funcs_1/t/is_coll_char_set_appl.test index cda7b578aae..2175de5d25a 100644 --- a/mysql-test/suite/funcs_1/t/is_collation_character_set_applicability.test +++ b/mysql-test/suite/funcs_1/t/is_coll_char_set_appl.test @@ -1,4 +1,4 @@ -# suite/funcs_1/t/is_collation_character_set_applicability.test +# suite/funcs_1/t/is_coll_char_set_appl.test # # Check the layout of information_schema.collation_character_set_applicability # and some functionality realted tests. From e6100a222d187819d92c63ae5b1e29907ce8f0da Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Thu, 8 Jan 2009 03:06:54 +0100 Subject: [PATCH 114/137] Fix a few problems after latest bunch of InnoDB snapshot changes: The binlog_innodb test was sensitive to what tests ran before it. Now run FLUSH STATUS before performing operations that need to be checked. sys_var_thd_ulong::update() was improperly casting an option value from ulonglong to ulong before comparing it to the max allowed value. On systems where ulong and ulonglong are of different size, this caused values greater than ULONG_MAX to wrap around (not be truncated to ULONG_MAX, which appears to have been the intention of the original coder), and caused some checks to work incorrectly. This wasn't generally visible to the user, because later checks would prevent the wrapped-around value from being used. But it caused warning messages to differ between 32- and 64-bit platforms. Fix is to just remove the cast. Also added a DBUG_ASSERT to ensure that the value really is capped properly before finally stuffing it into the ulong. --- mysql-test/suite/binlog/r/binlog_innodb.result | 7 ++++--- mysql-test/suite/binlog/t/binlog_innodb.test | 1 + sql/set_var.cc | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/mysql-test/suite/binlog/r/binlog_innodb.result b/mysql-test/suite/binlog/r/binlog_innodb.result index 896d8f734fc..919ac33ef35 100644 --- a/mysql-test/suite/binlog/r/binlog_innodb.result +++ b/mysql-test/suite/binlog/r/binlog_innodb.result @@ -113,16 +113,17 @@ master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ DROP TABLE t1; +flush status; show status like "binlog_cache_use"; Variable_name Value -Binlog_cache_use 13 +Binlog_cache_use 0 show status like "binlog_cache_disk_use"; Variable_name Value Binlog_cache_disk_use 0 create table t1 (a int) engine=innodb; show status like "binlog_cache_use"; Variable_name Value -Binlog_cache_use 14 +Binlog_cache_use 1 show status like "binlog_cache_disk_use"; Variable_name Value Binlog_cache_disk_use 1 @@ -131,7 +132,7 @@ delete from t1; commit; show status like "binlog_cache_use"; Variable_name Value -Binlog_cache_use 15 +Binlog_cache_use 2 show status like "binlog_cache_disk_use"; Variable_name Value Binlog_cache_disk_use 1 diff --git a/mysql-test/suite/binlog/t/binlog_innodb.test b/mysql-test/suite/binlog/t/binlog_innodb.test index df99e3786ee..f84fd65226a 100644 --- a/mysql-test/suite/binlog/t/binlog_innodb.test +++ b/mysql-test/suite/binlog/t/binlog_innodb.test @@ -101,6 +101,7 @@ DROP TABLE t1; # Actually this test has nothing to do with innodb per se, it just requires # transactional table. # +flush status; show status like "binlog_cache_use"; show status like "binlog_cache_disk_use"; diff --git a/sql/set_var.cc b/sql/set_var.cc index a371c1113ef..308735f52f2 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1527,14 +1527,14 @@ bool sys_var_thd_ulong::update(THD *thd, set_var *var) ulonglong tmp= var->save_result.ulonglong_value; /* Don't use bigger value than given with --maximum-variable-name=.. */ - if ((ulong) tmp > max_system_variables.*offset) + if (tmp > max_system_variables.*offset) { throw_bounds_warning(thd, TRUE, TRUE, name, (longlong) tmp); tmp= max_system_variables.*offset; } if (option_limits) - tmp= (ulong) fix_unsigned(thd, tmp, option_limits); + tmp= fix_unsigned(thd, tmp, option_limits); #if SIZEOF_LONG < SIZEOF_LONG_LONG else if (tmp > ULONG_MAX) { @@ -1543,6 +1543,7 @@ bool sys_var_thd_ulong::update(THD *thd, set_var *var) } #endif + DBUG_ASSERT(tmp <= ULONG_MAX); if (var->type == OPT_GLOBAL) global_system_variables.*offset= (ulong) tmp; else From 17bbe30cb0770459a03bd9ae78095e8fc8e7234f Mon Sep 17 00:00:00 2001 From: "Tatiana A. Nurnberg" Date: Thu, 8 Jan 2009 10:25:31 +0100 Subject: [PATCH 115/137] Bug#41470: DATE_FORMAT() crashes the complete server with a valid date Passing dubious "year zero" in non-zero date (not "0000-00-00") could lead to negative value for year internally, while variable was unsigned. This led to Really Bad Things further down the line. Now doing calculations with signed type for year internally. --- mysql-test/r/date_formats.result | 10 ++++++++++ mysql-test/t/date_formats.test | 12 ++++++++++++ sql-common/my_time.c | 13 +++++++------ 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index 6833a7f1594..43f656e3c99 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -593,3 +593,13 @@ select str_to_date('04/30/2004 ', '%m/%d/%Y '); str_to_date('04/30/2004 ', '%m/%d/%Y ') 2004-04-30 "End of 4.1 tests" +SELECT DATE_FORMAT("0000-01-01",'%W %d %M %Y') as valid_date; +valid_date +Sunday 01 January 0000 +SELECT DATE_FORMAT("0000-02-28",'%W %d %M %Y') as valid_date; +valid_date +Tuesday 28 February 0000 +SELECT DATE_FORMAT("2009-01-01",'%W %d %M %Y') as valid_date; +valid_date +Thursday 01 January 2009 +"End of 5.0 tests" diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test index faa6d4242db..0c02398acc1 100644 --- a/mysql-test/t/date_formats.test +++ b/mysql-test/t/date_formats.test @@ -337,3 +337,15 @@ select str_to_date('04/30 /2004', '%m /%d /%Y'); select str_to_date('04/30/2004 ', '%m/%d/%Y '); --echo "End of 4.1 tests" + +# +# Bug #41470: DATE_FORMAT() crashes the complete server with a valid date +# + +# show that these two do not crash the server: +SELECT DATE_FORMAT("0000-01-01",'%W %d %M %Y') as valid_date; +SELECT DATE_FORMAT("0000-02-28",'%W %d %M %Y') as valid_date; +# show that date within the Gregorian range render correct results: (THU) +SELECT DATE_FORMAT("2009-01-01",'%W %d %M %Y') as valid_date; + +--echo "End of 5.0 tests" diff --git a/sql-common/my_time.c b/sql-common/my_time.c index 1781251fca1..16a64ebd947 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -765,19 +765,20 @@ long calc_daynr(uint year,uint month,uint day) { long delsum; int temp; + int y= year; /* may be < 0 temporarily */ DBUG_ENTER("calc_daynr"); - if (year == 0 && month == 0 && day == 0) + if (y == 0 && month == 0 && day == 0) DBUG_RETURN(0); /* Skip errors */ - delsum= (long) (365L * year+ 31*(month-1) +day); + delsum= (long) (365L * y+ 31*(month-1) +day); if (month <= 2) - year--; + y--; else delsum-= (long) (month*4+23)/10; - temp=(int) ((year/100+1)*3)/4; + temp=(int) ((y/100+1)*3)/4; DBUG_PRINT("exit",("year: %d month: %d day: %d -> daynr: %ld", - year+(month <= 2),month,day,delsum+year/4-temp)); - DBUG_RETURN(delsum+(int) year/4-temp); + y+(month <= 2),month,day,delsum+y/4-temp)); + DBUG_RETURN(delsum+(int) y/4-temp); } /* calc_daynr */ From e39288b4e4fd7e06b17b35be195ea6d8e4377014 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Thu, 8 Jan 2009 10:31:34 -0200 Subject: [PATCH 116/137] Bug#41889: Test main.innodb_bug38231 is failing w/embedded server (server crash) The problem is that a mysql connection instance is not thread-safe and reentrant, meaning that it can't be used concurrently and can't be re-entered while it's already running. This applies for any form of the server (embedded or not), but this rule can be violated in a test case if the test sends a new command without waiting for the result of previous command that was sent asynchronously and this can lead to hangs when over a network or to crashes under embedded server as the server query execution path will be re-entered concurrently with the same connection structure. The solution is to rework the test case so that the aforementioned rule is obeyed. --- mysql-test/t/innodb_bug38231.test | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/mysql-test/t/innodb_bug38231.test b/mysql-test/t/innodb_bug38231.test index 5b87969f062..b3fcd89f371 100644 --- a/mysql-test/t/innodb_bug38231.test +++ b/mysql-test/t/innodb_bug38231.test @@ -16,7 +16,6 @@ CREATE TABLE bug38231 (a INT); -- connect (con1,localhost,root,,) -- connect (con2,localhost,root,,) --- connect (con3,localhost,root,,) -- connection con1 SET autocommit=0; @@ -27,11 +26,6 @@ SET autocommit=0; -- send LOCK TABLE bug38231 WRITE; --- connection con3 -SET autocommit=0; --- send -LOCK TABLE bug38231 WRITE; - -- connection default -- send TRUNCATE TABLE bug38231; @@ -39,6 +33,7 @@ TRUNCATE TABLE bug38231; -- connection con1 # give time to TRUNCATE and others to be executed; without sleep, sometimes # UNLOCK executes before TRUNCATE +# TODO: Replace with wait_condition once possible under embedded server. -- sleep 0.2 # this crashes the server if the bug is present UNLOCK TABLES; @@ -46,16 +41,13 @@ UNLOCK TABLES; # clean up -- connection con2 -UNLOCK TABLES; - --- connection con3 +-- reap UNLOCK TABLES; -- connection default - +-- reap -- disconnect con1 -- disconnect con2 --- disconnect con3 # test that TRUNCATE works with with row-level locks From 8c29445872cb63896518c8c5202bd88815778432 Mon Sep 17 00:00:00 2001 From: Horst Hunger Date: Thu, 8 Jan 2009 19:13:57 +0100 Subject: [PATCH 117/137] Patch for bug#36875: Inserted review results. --- mysql-test/include/have_32bit.inc | 2 +- mysql-test/include/have_64bit.inc | 2 +- .../sys_vars/inc/sort_buffer_size_basic.inc | 52 ++++++++++------ .../r/sort_buffer_size_basic_32.result | 60 +++++++++---------- .../r/sort_buffer_size_basic_64.result | 60 +++++++++---------- 5 files changed, 97 insertions(+), 79 deletions(-) diff --git a/mysql-test/include/have_32bit.inc b/mysql-test/include/have_32bit.inc index b09a813967d..66684fb5325 100644 --- a/mysql-test/include/have_32bit.inc +++ b/mysql-test/include/have_32bit.inc @@ -11,6 +11,6 @@ eval SET @@global.sort_buffer_size = $save; --enable_query_log if (!$mach32) { - skip Need a 32 bit machine; + skip Need a 32 bit machine/binary; } diff --git a/mysql-test/include/have_64bit.inc b/mysql-test/include/have_64bit.inc index 31529a0c9d4..cbba5e1d338 100644 --- a/mysql-test/include/have_64bit.inc +++ b/mysql-test/include/have_64bit.inc @@ -9,6 +9,6 @@ eval SET @@session.sort_buffer_size = $save; --enable_query_log if (!$mach64) { - skip Need a 64 bit machine; + skip Need a 64 binary ; } diff --git a/mysql-test/suite/sys_vars/inc/sort_buffer_size_basic.inc b/mysql-test/suite/sys_vars/inc/sort_buffer_size_basic.inc index 10acf709386..19d8b442c2c 100644 --- a/mysql-test/suite/sys_vars/inc/sort_buffer_size_basic.inc +++ b/mysql-test/suite/sys_vars/inc/sort_buffer_size_basic.inc @@ -40,9 +40,12 @@ # Save initial value # ############################################################# -# due to differences when running on Windows (bug filed) +# due to differences when running on Windows (Bug#36695) --source include/not_windows.inc +let $kbrange32 = BETWEEN 32776 AND 32999; +let $mbrange2 = BETWEEN 2097116 AND 2100000; + --disable_warnings SET @start_global_value = @@global.sort_buffer_size; @@ -55,11 +58,13 @@ SET @start_session_value = @@session.sort_buffer_size; SET @@global.sort_buffer_size = 1000; SET @@global.sort_buffer_size = DEFAULT; -SELECT @@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000; +eval +SELECT @@global.sort_buffer_size $mbrange2; SET @@session.sort_buffer_size = 2000; SET @@session.sort_buffer_size = DEFAULT; -SELECT @@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000; +eval +SELECT @@session.sort_buffer_size $mbrange2; --echo '#--------------------FN_DYNVARS_151_02-------------------------#' @@ -68,10 +73,12 @@ SELECT @@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 30 ###################################################################### SET @@global.sort_buffer_size = DEFAULT; -SELECT @@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000; +eval +SELECT @@global.sort_buffer_size $mbrange2; SET @@session.sort_buffer_size = DEFAULT; -SELECT @@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000; +eval +SELECT @@session.sort_buffer_size $mbrange2; --echo '#--------------------FN_DYNVARS_151_03-------------------------#' @@ -80,9 +87,11 @@ SELECT @@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 30 ################################################################################ SET @@global.sort_buffer_size = 32776; -SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; +eval +SELECT @@global.sort_buffer_size $kbrange32; SET @@global.sort_buffer_size = 32777; -SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; +eval +SELECT @@global.sort_buffer_size $kbrange32; SET @@global.sort_buffer_size = 4294967295; SELECT @@global.sort_buffer_size; SET @@global.sort_buffer_size = 4294967294; @@ -94,9 +103,11 @@ SELECT @@global.sort_buffer_size; ################################################################################### SET @@session.sort_buffer_size = 32776; -SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000; +eval +SELECT @@session.sort_buffer_size $kbrange32; SET @@session.sort_buffer_size = 32777; -SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000; +eval +SELECT @@session.sort_buffer_size $kbrange32; SET @@session.sort_buffer_size = 4294967295; SELECT @@session.sort_buffer_size; SET @@session.sort_buffer_size = 4294967294; @@ -109,9 +120,11 @@ SELECT @@session.sort_buffer_size; ################################################################## SET @@global.sort_buffer_size = 32775; -SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; +eval +SELECT @@global.sort_buffer_size $kbrange32; SET @@global.sort_buffer_size = -1024; -SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; +eval +SELECT @@global.sort_buffer_size $kbrange32; SET @@global.sort_buffer_size = 4294967296; SELECT @@global.sort_buffer_size; --Error ER_PARSE_ERROR @@ -122,9 +135,11 @@ SET @@global.sort_buffer_size = test; SELECT @@global.sort_buffer_size; SET @@session.sort_buffer_size = 32775; -SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000; +eval +SELECT @@session.sort_buffer_size $kbrange32; SET @@session.sort_buffer_size = -2; -SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000; +eval +SELECT @@session.sort_buffer_size $kbrange32; --Error ER_PARSE_ERROR SET @@session.sort_buffer_size = 65530.34.; SET @@session.sort_buffer_size = 4294967296; @@ -148,7 +163,7 @@ SELECT @@global.sort_buffer_size = VARIABLE_VALUE FROM #################################################################### SELECT @@session.sort_buffer_size = VARIABLE_VALUE FROM - INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='sort_buffer_size'; +INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='sort_buffer_size'; --echo '#------------------FN_DYNVARS_151_08-----------------------#' @@ -157,9 +172,11 @@ SELECT @@session.sort_buffer_size = VARIABLE_VALUE FROM #################################################################### SET @@global.sort_buffer_size = TRUE; -SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; +eval +SELECT @@global.sort_buffer_size $kbrange32; SET @@global.sort_buffer_size = FALSE; -SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; +eval +SELECT @@global.sort_buffer_size $kbrange32; --echo '#---------------------FN_DYNVARS_151_09----------------------#' #################################################################################### @@ -185,7 +202,8 @@ SELECT @@local.sort_buffer_size = @@session.sort_buffer_size; ################################################################################### SET sort_buffer_size = 9100; -SELECT @@sort_buffer_size >= 32776 AND @@sort_buffer_size < 33000; +eval +SELECT @@sort_buffer_size $kbrange32; --Error ER_UNKNOWN_TABLE SELECT local.sort_buffer_size; --Error ER_UNKNOWN_TABLE diff --git a/mysql-test/suite/sys_vars/r/sort_buffer_size_basic_32.result b/mysql-test/suite/sys_vars/r/sort_buffer_size_basic_32.result index 353ea9dee8c..9d3eadcc26f 100644 --- a/mysql-test/suite/sys_vars/r/sort_buffer_size_basic_32.result +++ b/mysql-test/suite/sys_vars/r/sort_buffer_size_basic_32.result @@ -3,31 +3,31 @@ SET @start_session_value = @@session.sort_buffer_size; '#--------------------FN_DYNVARS_151_01-------------------------#' SET @@global.sort_buffer_size = 1000; SET @@global.sort_buffer_size = DEFAULT; -SELECT @@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000; -@@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000 +SELECT @@global.sort_buffer_size BETWEEN 2097116 AND 2100000; +@@global.sort_buffer_size BETWEEN 2097116 AND 2100000 1 SET @@session.sort_buffer_size = 2000; SET @@session.sort_buffer_size = DEFAULT; -SELECT @@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000; -@@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000 +SELECT @@session.sort_buffer_size BETWEEN 2097116 AND 2100000; +@@session.sort_buffer_size BETWEEN 2097116 AND 2100000 1 '#--------------------FN_DYNVARS_151_02-------------------------#' SET @@global.sort_buffer_size = DEFAULT; -SELECT @@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000; -@@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000 +SELECT @@global.sort_buffer_size BETWEEN 2097116 AND 2100000; +@@global.sort_buffer_size BETWEEN 2097116 AND 2100000 1 SET @@session.sort_buffer_size = DEFAULT; -SELECT @@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000; -@@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000 +SELECT @@session.sort_buffer_size BETWEEN 2097116 AND 2100000; +@@session.sort_buffer_size BETWEEN 2097116 AND 2100000 1 '#--------------------FN_DYNVARS_151_03-------------------------#' SET @@global.sort_buffer_size = 32776; -SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; -@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000 +SELECT @@global.sort_buffer_size BETWEEN 32776 AND 32999; +@@global.sort_buffer_size BETWEEN 32776 AND 32999 1 SET @@global.sort_buffer_size = 32777; -SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; -@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000 +SELECT @@global.sort_buffer_size BETWEEN 32776 AND 32999; +@@global.sort_buffer_size BETWEEN 32776 AND 32999 1 SET @@global.sort_buffer_size = 4294967295; SELECT @@global.sort_buffer_size; @@ -39,12 +39,12 @@ SELECT @@global.sort_buffer_size; 4294967294 '#--------------------FN_DYNVARS_151_04-------------------------#' SET @@session.sort_buffer_size = 32776; -SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000; -@@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000 +SELECT @@session.sort_buffer_size BETWEEN 32776 AND 32999; +@@session.sort_buffer_size BETWEEN 32776 AND 32999 1 SET @@session.sort_buffer_size = 32777; -SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000; -@@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000 +SELECT @@session.sort_buffer_size BETWEEN 32776 AND 32999; +@@session.sort_buffer_size BETWEEN 32776 AND 32999 1 SET @@session.sort_buffer_size = 4294967295; SELECT @@session.sort_buffer_size; @@ -56,12 +56,12 @@ SELECT @@session.sort_buffer_size; 4294967294 '#------------------FN_DYNVARS_151_05-----------------------#' SET @@global.sort_buffer_size = 32775; -SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; -@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000 +SELECT @@global.sort_buffer_size BETWEEN 32776 AND 32999; +@@global.sort_buffer_size BETWEEN 32776 AND 32999 1 SET @@global.sort_buffer_size = -1024; -SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; -@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000 +SELECT @@global.sort_buffer_size BETWEEN 32776 AND 32999; +@@global.sort_buffer_size BETWEEN 32776 AND 32999 1 SET @@global.sort_buffer_size = 4294967296; SELECT @@global.sort_buffer_size; @@ -78,12 +78,12 @@ SELECT @@global.sort_buffer_size; @@global.sort_buffer_size 4294967295 SET @@session.sort_buffer_size = 32775; -SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000; -@@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000 +SELECT @@session.sort_buffer_size BETWEEN 32776 AND 32999; +@@session.sort_buffer_size BETWEEN 32776 AND 32999 1 SET @@session.sort_buffer_size = -2; -SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000; -@@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000 +SELECT @@session.sort_buffer_size BETWEEN 32776 AND 32999; +@@session.sort_buffer_size BETWEEN 32776 AND 32999 1 SET @@session.sort_buffer_size = 65530.34.; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1 @@ -105,12 +105,12 @@ INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='sort_buffer_size'; 1 '#------------------FN_DYNVARS_151_08-----------------------#' SET @@global.sort_buffer_size = TRUE; -SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; -@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000 +SELECT @@global.sort_buffer_size BETWEEN 32776 AND 32999; +@@global.sort_buffer_size BETWEEN 32776 AND 32999 1 SET @@global.sort_buffer_size = FALSE; -SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; -@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000 +SELECT @@global.sort_buffer_size BETWEEN 32776 AND 32999; +@@global.sort_buffer_size BETWEEN 32776 AND 32999 1 '#---------------------FN_DYNVARS_151_09----------------------#' SET @@global.sort_buffer_size = 9000; @@ -127,8 +127,8 @@ SELECT @@local.sort_buffer_size = @@session.sort_buffer_size; 1 '#---------------------FN_DYNVARS_151_11----------------------#' SET sort_buffer_size = 9100; -SELECT @@sort_buffer_size >= 32776 AND @@sort_buffer_size < 33000; -@@sort_buffer_size >= 32776 AND @@sort_buffer_size < 33000 +SELECT @@sort_buffer_size BETWEEN 32776 AND 32999; +@@sort_buffer_size BETWEEN 32776 AND 32999 1 SELECT local.sort_buffer_size; ERROR 42S02: Unknown table 'local' in field list diff --git a/mysql-test/suite/sys_vars/r/sort_buffer_size_basic_64.result b/mysql-test/suite/sys_vars/r/sort_buffer_size_basic_64.result index 3708f88f889..c993c8a0a88 100644 --- a/mysql-test/suite/sys_vars/r/sort_buffer_size_basic_64.result +++ b/mysql-test/suite/sys_vars/r/sort_buffer_size_basic_64.result @@ -3,31 +3,31 @@ SET @start_session_value = @@session.sort_buffer_size; '#--------------------FN_DYNVARS_151_01-------------------------#' SET @@global.sort_buffer_size = 1000; SET @@global.sort_buffer_size = DEFAULT; -SELECT @@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000; -@@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000 +SELECT @@global.sort_buffer_size BETWEEN 2097116 AND 2100000; +@@global.sort_buffer_size BETWEEN 2097116 AND 2100000 1 SET @@session.sort_buffer_size = 2000; SET @@session.sort_buffer_size = DEFAULT; -SELECT @@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000; -@@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000 +SELECT @@session.sort_buffer_size BETWEEN 2097116 AND 2100000; +@@session.sort_buffer_size BETWEEN 2097116 AND 2100000 1 '#--------------------FN_DYNVARS_151_02-------------------------#' SET @@global.sort_buffer_size = DEFAULT; -SELECT @@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000; -@@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000 +SELECT @@global.sort_buffer_size BETWEEN 2097116 AND 2100000; +@@global.sort_buffer_size BETWEEN 2097116 AND 2100000 1 SET @@session.sort_buffer_size = DEFAULT; -SELECT @@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000; -@@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000 +SELECT @@session.sort_buffer_size BETWEEN 2097116 AND 2100000; +@@session.sort_buffer_size BETWEEN 2097116 AND 2100000 1 '#--------------------FN_DYNVARS_151_03-------------------------#' SET @@global.sort_buffer_size = 32776; -SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; -@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000 +SELECT @@global.sort_buffer_size BETWEEN 32776 AND 32999; +@@global.sort_buffer_size BETWEEN 32776 AND 32999 1 SET @@global.sort_buffer_size = 32777; -SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; -@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000 +SELECT @@global.sort_buffer_size BETWEEN 32776 AND 32999; +@@global.sort_buffer_size BETWEEN 32776 AND 32999 1 SET @@global.sort_buffer_size = 4294967295; SELECT @@global.sort_buffer_size; @@ -39,12 +39,12 @@ SELECT @@global.sort_buffer_size; 4294967294 '#--------------------FN_DYNVARS_151_04-------------------------#' SET @@session.sort_buffer_size = 32776; -SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000; -@@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000 +SELECT @@session.sort_buffer_size BETWEEN 32776 AND 32999; +@@session.sort_buffer_size BETWEEN 32776 AND 32999 1 SET @@session.sort_buffer_size = 32777; -SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000; -@@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000 +SELECT @@session.sort_buffer_size BETWEEN 32776 AND 32999; +@@session.sort_buffer_size BETWEEN 32776 AND 32999 1 SET @@session.sort_buffer_size = 4294967295; SELECT @@session.sort_buffer_size; @@ -56,12 +56,12 @@ SELECT @@session.sort_buffer_size; 4294967294 '#------------------FN_DYNVARS_151_05-----------------------#' SET @@global.sort_buffer_size = 32775; -SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; -@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000 +SELECT @@global.sort_buffer_size BETWEEN 32776 AND 32999; +@@global.sort_buffer_size BETWEEN 32776 AND 32999 1 SET @@global.sort_buffer_size = -1024; -SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; -@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000 +SELECT @@global.sort_buffer_size BETWEEN 32776 AND 32999; +@@global.sort_buffer_size BETWEEN 32776 AND 32999 1 SET @@global.sort_buffer_size = 4294967296; SELECT @@global.sort_buffer_size; @@ -78,12 +78,12 @@ SELECT @@global.sort_buffer_size; @@global.sort_buffer_size 4294967296 SET @@session.sort_buffer_size = 32775; -SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000; -@@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000 +SELECT @@session.sort_buffer_size BETWEEN 32776 AND 32999; +@@session.sort_buffer_size BETWEEN 32776 AND 32999 1 SET @@session.sort_buffer_size = -2; -SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000; -@@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000 +SELECT @@session.sort_buffer_size BETWEEN 32776 AND 32999; +@@session.sort_buffer_size BETWEEN 32776 AND 32999 1 SET @@session.sort_buffer_size = 65530.34.; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1 @@ -105,12 +105,12 @@ INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='sort_buffer_size'; 1 '#------------------FN_DYNVARS_151_08-----------------------#' SET @@global.sort_buffer_size = TRUE; -SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; -@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000 +SELECT @@global.sort_buffer_size BETWEEN 32776 AND 32999; +@@global.sort_buffer_size BETWEEN 32776 AND 32999 1 SET @@global.sort_buffer_size = FALSE; -SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000; -@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000 +SELECT @@global.sort_buffer_size BETWEEN 32776 AND 32999; +@@global.sort_buffer_size BETWEEN 32776 AND 32999 1 '#---------------------FN_DYNVARS_151_09----------------------#' SET @@global.sort_buffer_size = 9000; @@ -127,8 +127,8 @@ SELECT @@local.sort_buffer_size = @@session.sort_buffer_size; 1 '#---------------------FN_DYNVARS_151_11----------------------#' SET sort_buffer_size = 9100; -SELECT @@sort_buffer_size >= 32776 AND @@sort_buffer_size < 33000; -@@sort_buffer_size >= 32776 AND @@sort_buffer_size < 33000 +SELECT @@sort_buffer_size BETWEEN 32776 AND 32999; +@@sort_buffer_size BETWEEN 32776 AND 32999 1 SELECT local.sort_buffer_size; ERROR 42S02: Unknown table 'local' in field list From 56b7d87f73b664fd54b8c335b2948364ff364047 Mon Sep 17 00:00:00 2001 From: Sven Sandberg Date: Fri, 9 Jan 2009 10:48:01 +0100 Subject: [PATCH 118/137] BUG#41961: Some log_event types do not skip post-header when reading Problem: when the server reads a log_event from file, it should read the post-header lengths from the format_description_log_event. Some event types which currently have post-header length 0 did not do this, and instead had a hard-coded zero length for the post-header. That means the current server version will not be able to read future versions of these events. Fix: make the reader functions read the post-header. --- sql/log_event.cc | 54 +++++++++++++++++++++++++++++++++++++++++------- sql/log_event.h | 8 +++++++ 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/sql/log_event.cc b/sql/log_event.cc index 74ad018df55..3d6585778cf 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -3425,7 +3425,8 @@ Format_description_log_event(uint8 binlog_ver, const char* server_ver) number_of_event_types= LOG_EVENT_TYPES; /* we'll catch my_malloc() error in is_valid() */ post_header_len=(uint8*) my_malloc(number_of_event_types*sizeof(uint8), - MYF(MY_ZEROFILL)); + MYF(0)); + /* This long list of assignments is not beautiful, but I see no way to make it nicer, as the right members are #defines, not array members, so @@ -3433,16 +3434,40 @@ Format_description_log_event(uint8 binlog_ver, const char* server_ver) */ if (post_header_len) { + // Allows us to sanity-check that all events initialized their + // events (see the end of this 'if' block). + IF_DBUG(memset(post_header_len, 255, + number_of_event_types*sizeof(uint8));); + + /* Note: all event types must explicitly fill in their lengths here. */ post_header_len[START_EVENT_V3-1]= START_V3_HEADER_LEN; post_header_len[QUERY_EVENT-1]= QUERY_HEADER_LEN; + post_header_len[STOP_EVENT-1]= STOP_HEADER_LEN; post_header_len[ROTATE_EVENT-1]= ROTATE_HEADER_LEN; + post_header_len[INTVAR_EVENT-1]= INTVAR_HEADER_LEN; post_header_len[LOAD_EVENT-1]= LOAD_HEADER_LEN; + post_header_len[SLAVE_EVENT-1]= SLAVE_HEADER_LEN; post_header_len[CREATE_FILE_EVENT-1]= CREATE_FILE_HEADER_LEN; post_header_len[APPEND_BLOCK_EVENT-1]= APPEND_BLOCK_HEADER_LEN; post_header_len[EXEC_LOAD_EVENT-1]= EXEC_LOAD_HEADER_LEN; post_header_len[DELETE_FILE_EVENT-1]= DELETE_FILE_HEADER_LEN; - post_header_len[NEW_LOAD_EVENT-1]= post_header_len[LOAD_EVENT-1]; + post_header_len[NEW_LOAD_EVENT-1]= NEW_LOAD_HEADER_LEN; + post_header_len[RAND_EVENT-1]= RAND_HEADER_LEN; + post_header_len[USER_VAR_EVENT-1]= USER_VAR_HEADER_LEN; post_header_len[FORMAT_DESCRIPTION_EVENT-1]= FORMAT_DESCRIPTION_HEADER_LEN; + post_header_len[XID_EVENT-1]= XID_HEADER_LEN; + post_header_len[BEGIN_LOAD_QUERY_EVENT-1]= BEGIN_LOAD_QUERY_HEADER_LEN; + post_header_len[EXECUTE_LOAD_QUERY_EVENT-1]= EXECUTE_LOAD_QUERY_HEADER_LEN; + /* + The PRE_GA events are never be written to any binlog, but + their lengths are included in Format_description_log_event. + Hence, we need to be assign some value here, to avoid reading + uninitialized memory when the array is written to disk. + */ + post_header_len[PRE_GA_WRITE_ROWS_EVENT-1] = 0; + post_header_len[PRE_GA_UPDATE_ROWS_EVENT-1] = 0; + post_header_len[PRE_GA_DELETE_ROWS_EVENT-1] = 0; + post_header_len[TABLE_MAP_EVENT-1]= TABLE_MAP_HEADER_LEN; post_header_len[WRITE_ROWS_EVENT-1]= ROWS_HEADER_LEN; post_header_len[UPDATE_ROWS_EVENT-1]= ROWS_HEADER_LEN; @@ -3462,9 +3487,14 @@ Format_description_log_event(uint8 binlog_ver, const char* server_ver) post_header_len[WRITE_ROWS_EVENT-1]= post_header_len[UPDATE_ROWS_EVENT-1]= post_header_len[DELETE_ROWS_EVENT-1]= 6;); - post_header_len[BEGIN_LOAD_QUERY_EVENT-1]= post_header_len[APPEND_BLOCK_EVENT-1]; - post_header_len[EXECUTE_LOAD_QUERY_EVENT-1]= EXECUTE_LOAD_QUERY_HEADER_LEN; post_header_len[INCIDENT_EVENT-1]= INCIDENT_HEADER_LEN; + + // Sanity-check that all post header lengths are initialized. + IF_DBUG({ + int i; + for (i=0; icommon_header_len; + /* The Post-Header is empty. The Varible Data part begins immediately. */ + buf+= description_event->common_header_len + + description_event->post_header_len[INTVAR_EVENT-1]; type= buf[I_TYPE_OFFSET]; val= uint8korr(buf+I_VAL_OFFSET); } @@ -4957,7 +4989,9 @@ Rand_log_event::Rand_log_event(const char* buf, const Format_description_log_event* description_event) :Log_event(buf, description_event) { - buf+= description_event->common_header_len; + /* The Post-Header is empty. The Variable Data part begins immediately. */ + buf+= description_event->common_header_len + + description_event->post_header_len[RAND_EVENT-1]; seed1= uint8korr(buf+RAND_SEED1_OFFSET); seed2= uint8korr(buf+RAND_SEED2_OFFSET); } @@ -5061,7 +5095,9 @@ Xid_log_event(const char* buf, const Format_description_log_event *description_event) :Log_event(buf, description_event) { - buf+= description_event->common_header_len; + /* The Post-Header is empty. The Variable Data part begins immediately. */ + buf+= description_event->common_header_len + + description_event->post_header_len[XID_EVENT-1]; memcpy((char*) &xid, buf, sizeof(xid)); } @@ -5207,7 +5243,9 @@ User_var_log_event(const char* buf, const Format_description_log_event* description_event) :Log_event(buf, description_event) { - buf+= description_event->common_header_len; + /* The Post-Header is empty. The Variable Data part begins immediately. */ + buf+= description_event->common_header_len + + description_event->post_header_len[USER_VAR_EVENT-1]; name_len= uint4korr(buf); name= (char *) buf + UV_NAME_LEN_SIZE; buf+= UV_NAME_LEN_SIZE + name_len; diff --git a/sql/log_event.h b/sql/log_event.h index db14341b51d..185d2d21a02 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -227,14 +227,22 @@ struct sql_ex_info #define QUERY_HEADER_MINIMAL_LEN (4 + 4 + 1 + 2) // where 5.0 differs: 2 for len of N-bytes vars. #define QUERY_HEADER_LEN (QUERY_HEADER_MINIMAL_LEN + 2) +#define STOP_HEADER_LEN 0 #define LOAD_HEADER_LEN (4 + 4 + 4 + 1 +1 + 4) +#define SLAVE_HEADER_LEN 0 #define START_V3_HEADER_LEN (2 + ST_SERVER_VER_LEN + 4) #define ROTATE_HEADER_LEN 8 // this is FROZEN (the Rotate post-header is frozen) +#define INTVAR_HEADER_LEN 0 #define CREATE_FILE_HEADER_LEN 4 #define APPEND_BLOCK_HEADER_LEN 4 #define EXEC_LOAD_HEADER_LEN 4 #define DELETE_FILE_HEADER_LEN 4 +#define NEW_LOAD_HEADER_LEN LOAD_HEADER_LEN +#define RAND_HEADER_LEN 0 +#define USER_VAR_HEADER_LEN 0 #define FORMAT_DESCRIPTION_HEADER_LEN (START_V3_HEADER_LEN+1+LOG_EVENT_TYPES) +#define XID_HEADER_LEN 0 +#define BEGIN_LOAD_QUERY_HEADER_LEN APPEND_BLOCK_HEADER_LEN #define ROWS_HEADER_LEN 8 #define TABLE_MAP_HEADER_LEN 8 #define EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN (4 + 4 + 4 + 1) From 577e390eceb06a6c35198d0026c11b47a3d33232 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 9 Jan 2009 08:20:32 -0200 Subject: [PATCH 119/137] Bug#37016: TRUNCATE TABLE removes some rows but not all The special TRUNCATE TABLE (DDL) transaction wasn't being properly rolled back if a error occurred during row by row deletion. The error can be caused by a foreign key restriction imposed by InnoDB SE and would cause the server to erroneously issue a implicit commit. The solution is to rollback the transaction if a truncation via row by row deletion fails, otherwise commit. All effects of a TRUNCATE ABLE operation are rolled back if a row by row deletion fails. --- mysql-test/include/commit.inc | 6 ++-- mysql-test/r/commit_1innodb.result | 6 ++-- mysql-test/r/innodb_mysql.result | 58 ++++++++++++++++++++++++++++++ mysql-test/t/innodb_mysql.test | 52 +++++++++++++++++++++++++++ sql/sql_delete.cc | 40 +++++++++++---------- 5 files changed, 137 insertions(+), 25 deletions(-) diff --git a/mysql-test/include/commit.inc b/mysql-test/include/commit.inc index 48b0eac12e5..de5eca8b1f6 100644 --- a/mysql-test/include/commit.inc +++ b/mysql-test/include/commit.inc @@ -617,10 +617,10 @@ call p_verify_status_increment(0, 0, 0, 0); --echo --echo # No test because of Bug#8729 "rename table fails on temporary table" ---echo # 24. DDL: TRUNCATE TEMPORARY TABLE, does not start a transaction +--echo # 24. DDL: TRUNCATE TEMPORARY TABLE --echo truncate table t2; -call p_verify_status_increment(2, 0, 2, 0); +call p_verify_status_increment(4, 0, 4, 0); commit; --echo # There is nothing left to commit call p_verify_status_increment(0, 0, 0, 0); @@ -733,7 +733,7 @@ call p_verify_status_increment(1, 0, 1, 0); rename table t4 to t3; call p_verify_status_increment(1, 0, 1, 0); truncate table t3; -call p_verify_status_increment(2, 2, 2, 2); +call p_verify_status_increment(4, 4, 2, 2); create view v1 as select * from t2; call p_verify_status_increment(1, 0, 1, 0); check table t1; diff --git a/mysql-test/r/commit_1innodb.result b/mysql-test/r/commit_1innodb.result index 766b920f630..72e6b01bb03 100644 --- a/mysql-test/r/commit_1innodb.result +++ b/mysql-test/r/commit_1innodb.result @@ -683,10 +683,10 @@ SUCCESS # 23. DDL: RENAME TEMPORARY TABLE, does not start a transaction # No test because of Bug#8729 "rename table fails on temporary table" -# 24. DDL: TRUNCATE TEMPORARY TABLE, does not start a transaction +# 24. DDL: TRUNCATE TEMPORARY TABLE truncate table t2; -call p_verify_status_increment(2, 0, 2, 0); +call p_verify_status_increment(4, 0, 4, 0); SUCCESS commit; @@ -853,7 +853,7 @@ call p_verify_status_increment(1, 0, 1, 0); SUCCESS truncate table t3; -call p_verify_status_increment(2, 2, 2, 2); +call p_verify_status_increment(4, 4, 2, 2); SUCCESS create view v1 as select * from t2; diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index a1116a78bda..6fcc9415d12 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -1788,4 +1788,62 @@ DEALLOCATE PREPARE stmt1; DEALLOCATE PREPARE stmt3; DROP TABLE t1,t3,t2; DROP FUNCTION f1; +DROP TABLE IF EXISTS t1,t2; +CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB; +CREATE TABLE t2 (id INT PRIMARY KEY, +t1_id INT, INDEX par_ind (t1_id), +FOREIGN KEY (t1_id) REFERENCES t1(id)) ENGINE=INNODB; +INSERT INTO t1 VALUES (1),(2); +INSERT INTO t2 VALUES (3,2); +SET AUTOCOMMIT = 0; +START TRANSACTION; +TRUNCATE TABLE t1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`t1_id`) REFERENCES `t1` (`id`)) +SELECT * FROM t1; +id +1 +2 +COMMIT; +SELECT * FROM t1; +id +1 +2 +START TRANSACTION; +TRUNCATE TABLE t1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`t1_id`) REFERENCES `t1` (`id`)) +SELECT * FROM t1; +id +1 +2 +ROLLBACK; +SELECT * FROM t1; +id +1 +2 +SET AUTOCOMMIT = 1; +START TRANSACTION; +SELECT * FROM t1; +id +1 +2 +COMMIT; +TRUNCATE TABLE t1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`t1_id`) REFERENCES `t1` (`id`)) +SELECT * FROM t1; +id +1 +2 +DELETE FROM t2 WHERE id = 3; +START TRANSACTION; +SELECT * FROM t1; +id +1 +2 +TRUNCATE TABLE t1; +ROLLBACK; +SELECT * FROM t1; +id +TRUNCATE TABLE t2; +DROP TABLE t2; +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test index 5a2e115a98d..21ee440f10b 100644 --- a/mysql-test/t/innodb_mysql.test +++ b/mysql-test/t/innodb_mysql.test @@ -132,4 +132,56 @@ DEALLOCATE PREPARE stmt3; DROP TABLE t1,t3,t2; DROP FUNCTION f1; +# +# Bug#37016: TRUNCATE TABLE removes some rows but not all +# + +--disable_warnings +DROP TABLE IF EXISTS t1,t2; +--enable_warnings + +CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB; +CREATE TABLE t2 (id INT PRIMARY KEY, + t1_id INT, INDEX par_ind (t1_id), + FOREIGN KEY (t1_id) REFERENCES t1(id)) ENGINE=INNODB; +INSERT INTO t1 VALUES (1),(2); +INSERT INTO t2 VALUES (3,2); + +SET AUTOCOMMIT = 0; + +START TRANSACTION; +--error ER_ROW_IS_REFERENCED_2 +TRUNCATE TABLE t1; +SELECT * FROM t1; +COMMIT; +SELECT * FROM t1; + +START TRANSACTION; +--error ER_ROW_IS_REFERENCED_2 +TRUNCATE TABLE t1; +SELECT * FROM t1; +ROLLBACK; +SELECT * FROM t1; + +SET AUTOCOMMIT = 1; + +START TRANSACTION; +SELECT * FROM t1; +COMMIT; + +--error ER_ROW_IS_REFERENCED_2 +TRUNCATE TABLE t1; +SELECT * FROM t1; +DELETE FROM t2 WHERE id = 3; + +START TRANSACTION; +SELECT * FROM t1; +TRUNCATE TABLE t1; +ROLLBACK; +SELECT * FROM t1; +TRUNCATE TABLE t2; + +DROP TABLE t2; +DROP TABLE t1; + --echo End of 5.1 tests diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index f7c44152571..b56e042e3d5 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -950,6 +950,26 @@ bool multi_delete::send_eof() TRUNCATE TABLE ****************************************************************************/ +/* + Row-by-row truncation if the engine does not support table recreation. + Probably a InnoDB table. +*/ + +static bool mysql_truncate_by_delete(THD *thd, TABLE_LIST *table_list) +{ + bool error, save_binlog_row_based= thd->current_stmt_binlog_row_based; + DBUG_ENTER("mysql_truncate_by_delete"); + table_list->lock_type= TL_WRITE; + mysql_init_select(thd->lex); + thd->clear_current_stmt_binlog_row_based(); + error= mysql_delete(thd, table_list, NULL, NULL, HA_POS_ERROR, LL(0), TRUE); + ha_autocommit_or_rollback(thd, error); + end_trans(thd, error ? ROLLBACK : COMMIT); + thd->current_stmt_binlog_row_based= save_binlog_row_based; + DBUG_RETURN(error); +} + + /* Optimize delete of all rows by doing a full generate of the table This will work even if the .ISM and .ISD tables are destroyed @@ -1055,24 +1075,6 @@ end: DBUG_RETURN(error); trunc_by_del: - /* Probably InnoDB table */ - ulonglong save_options= thd->options; - table_list->lock_type= TL_WRITE; - thd->options&= ~(OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT); - ha_enable_transaction(thd, FALSE); - mysql_init_select(thd->lex); - bool save_binlog_row_based= thd->current_stmt_binlog_row_based; - thd->clear_current_stmt_binlog_row_based(); - error= mysql_delete(thd, table_list, (COND*) 0, (SQL_LIST*) 0, - HA_POS_ERROR, LL(0), TRUE); - ha_enable_transaction(thd, TRUE); - /* - Safety, in case the engine ignored ha_enable_transaction(FALSE) - above. Also clears thd->transaction.*. - */ - error= ha_autocommit_or_rollback(thd, error); - ha_commit(thd); - thd->options= save_options; - thd->current_stmt_binlog_row_based= save_binlog_row_based; + error= mysql_truncate_by_delete(thd, table_list); DBUG_RETURN(error); } From 7c3ae5164738c931938195fd2184a1fff754be1c Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 9 Jan 2009 13:50:18 +0200 Subject: [PATCH 120/137] Bug #41437: Value stored in 'case' lacks charset, causes segfault When substituting system constant functions with a constant result the server was not expecting that the function may return NULL. Fixed by checking for NULL and returning Item_null (in the relevant collation) if the result of the system constant function was NULL. --- mysql-test/r/mysql.result | 2 ++ mysql-test/t/mysql.test | 5 +++++ sql/item_strfunc.cc | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index 95bdcab6ba1..9bad3b9f791 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -186,4 +186,6 @@ delimiter 2 2 2 +@z:='1' @z=database() +1 NULL End of 5.0 tests diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index 76941af893a..68a01a309d4 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -309,4 +309,9 @@ EOF --exec $MYSQL -c < $MYSQLTEST_VARDIR/tmp/bug38158.sql 2>&1 remove_file $MYSQLTEST_VARDIR/tmp/bug38158.sql; +# +# Bug #41437: Value stored in 'case' lacks charset, causees segfault +# +--exec $MYSQL -e "select @z:='1',@z=database()" + --echo End of 5.0 tests diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index d1e3f45bba1..34f974042a5 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1696,6 +1696,12 @@ Item *Item_func_sysconst::safe_charset_converter(CHARSET_INFO *tocs) Item_string *conv; uint conv_errors; String tmp, cstr, *ostr= val_str(&tmp); + if (null_value) + { + Item *null_item= new Item_null((char *) fully_qualified_func_name()); + null_item->collation.set (tocs); + return null_item; + } cstr.copy(ostr->ptr(), ostr->length(), ostr->charset(), tocs, &conv_errors); if (conv_errors || !(conv= new Item_static_string_func(fully_qualified_func_name(), From 53ba196e11ef7b7d49e679224469eb40ecbe81e6 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 9 Jan 2009 14:04:47 +0200 Subject: [PATCH 121/137] Bug #41543: Assertion `m_status == DA_ERROR' failed in Diagnostics_area::sql_errno No need to mask the error code returned by getting the next row to end of file when doing filesort. --- mysql-test/r/innodb_mysql_rbk.result | 21 ++++++++++++++ mysql-test/t/innodb_mysql_rbk-master.opt | 1 + mysql-test/t/innodb_mysql_rbk.test | 35 ++++++++++++++++++++++++ sql/filesort.cc | 3 -- 4 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 mysql-test/r/innodb_mysql_rbk.result create mode 100644 mysql-test/t/innodb_mysql_rbk-master.opt create mode 100644 mysql-test/t/innodb_mysql_rbk.test diff --git a/mysql-test/r/innodb_mysql_rbk.result b/mysql-test/r/innodb_mysql_rbk.result new file mode 100644 index 00000000000..21ac4295325 --- /dev/null +++ b/mysql-test/r/innodb_mysql_rbk.result @@ -0,0 +1,21 @@ +CREATE TABLE t1(a INT, b INT NOT NULL, PRIMARY KEY (a)) ENGINE=innodb +DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7); +START TRANSACTION; +SELECT * FROM t1 WHERE b=3 LIMIT 1 FOR UPDATE; +a b +3 3 +START TRANSACTION; +UPDATE t1 SET b=b+12 WHERE a > 2 ORDER BY a; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +START TRANSACTION; +SELECT * FROM t1 WHERE b=3 LIMIT 1 FOR UPDATE; +a b +3 3 +START TRANSACTION; +UPDATE t1 SET b=10 WHERE a > 1 ORDER BY a; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SELECT * FROM t1 WHERE b = 10; +a b +DROP TABLE t1; diff --git a/mysql-test/t/innodb_mysql_rbk-master.opt b/mysql-test/t/innodb_mysql_rbk-master.opt new file mode 100644 index 00000000000..0e400f9c36b --- /dev/null +++ b/mysql-test/t/innodb_mysql_rbk-master.opt @@ -0,0 +1 @@ +--innodb_lock_wait_timeout=1 --innodb_rollback_on_timeout=1 diff --git a/mysql-test/t/innodb_mysql_rbk.test b/mysql-test/t/innodb_mysql_rbk.test new file mode 100644 index 00000000000..d2368c81f95 --- /dev/null +++ b/mysql-test/t/innodb_mysql_rbk.test @@ -0,0 +1,35 @@ +-- source include/have_innodb.inc + +# +# Bug #41453: Assertion `m_status == DA_ERROR' failed in +# Diagnostics_area::sql_errno +# + +CREATE TABLE t1(a INT, b INT NOT NULL, PRIMARY KEY (a)) ENGINE=innodb +DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7); +CONNECT (con1,localhost,root,,); +CONNECT (con2,localhost,root,,); + +CONNECTION con1; +START TRANSACTION; +SELECT * FROM t1 WHERE b=3 LIMIT 1 FOR UPDATE; +CONNECTION con2; +START TRANSACTION; +--error ER_LOCK_WAIT_TIMEOUT +UPDATE t1 SET b=b+12 WHERE a > 2 ORDER BY a; +ROLLBACK; + +CONNECTION con1; +START TRANSACTION; +SELECT * FROM t1 WHERE b=3 LIMIT 1 FOR UPDATE; +CONNECTION con2; +START TRANSACTION; +--error ER_LOCK_WAIT_TIMEOUT +UPDATE t1 SET b=10 WHERE a > 1 ORDER BY a; +SELECT * FROM t1 WHERE b = 10; + +CONNECTION default; +DISCONNECT con1; +DISCONNECT con2; +DROP TABLE t1; diff --git a/sql/filesort.cc b/sql/filesort.cc index 2850ada1ffb..5d8b4e869c8 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -562,10 +562,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, if (quick_select) { if ((error= select->quick->get_next())) - { - error= HA_ERR_END_OF_FILE; break; - } file->position(sort_form->record[0]); DBUG_EXECUTE_IF("debug_filesort", dbug_print_record(sort_form, TRUE);); } From a24862ed462d6cbe6f0f34b55f0beb50b62638f3 Mon Sep 17 00:00:00 2001 From: Sven Sandberg Date: Fri, 9 Jan 2009 13:49:24 +0100 Subject: [PATCH 122/137] BUG#41924: high-level replication functions are not commented Adding comments to some of the high-level functions in replication. --- sql/log_event.h | 22 ++++---- sql/repl_failsafe.cc | 10 ++++ sql/slave.cc | 39 ++++++++++++-- sql/sql_binlog.cc | 5 +- sql/sql_lex.h | 9 ++++ sql/sql_repl.cc | 123 ++++++++++++++++++++++++++++++++++++------- 6 files changed, 172 insertions(+), 36 deletions(-) diff --git a/sql/log_event.h b/sql/log_event.h index 185d2d21a02..e546cff8b7b 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -327,18 +327,16 @@ struct sql_ex_info #define Q_CHARSET_DATABASE_CODE 8 #define Q_TABLE_MAP_FOR_UPDATE_CODE 9 -/* Intvar event post-header */ +/* Intvar event data */ #define I_TYPE_OFFSET 0 #define I_VAL_OFFSET 1 -/* Rand event post-header */ - +/* Rand event data */ #define RAND_SEED1_OFFSET 0 #define RAND_SEED2_OFFSET 8 -/* User_var event post-header */ - +/* User_var event data */ #define UV_VAL_LEN_SIZE 4 #define UV_VAL_IS_NULL 1 #define UV_VAL_TYPE_SIZE 1 @@ -346,7 +344,6 @@ struct sql_ex_info #define UV_CHARSET_NUMBER_SIZE 4 /* Load event post-header */ - #define L_THREAD_ID_OFFSET 0 #define L_EXEC_TIME_OFFSET 4 #define L_SKIP_LINES_OFFSET 8 @@ -357,7 +354,6 @@ struct sql_ex_info #define L_DATA_OFFSET LOAD_HEADER_LEN /* Rotate event post-header */ - #define R_POS_OFFSET 0 #define R_IDENT_OFFSET 8 @@ -2214,10 +2210,11 @@ protected: @section Intvar_log_event_binary_format Binary Format - The Post-Header has two components: + The Post-Header for this event type is empty. The Body has two + components: - + @@ -2291,11 +2288,12 @@ private: which are stored internally as two 64-bit numbers. @section Rand_log_event_binary_format Binary Format - This event type has no Post-Header. The Body of this event type has - two components: + + The Post-Header for this event type is empty. The Body has two + components:
Post-Header for Intvar_log_eventBody for Intvar_log_event
Name
- + diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index d7e783f534f..582348608de 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -644,6 +644,16 @@ err: } #endif + +/** + Execute a SHOW SLAVE HOSTS statement. + + @param thd Pointer to THD object for the client thread executing the + statement. + + @retval FALSE success + @retval TRUE failure +*/ bool show_slave_hosts(THD* thd) { List field_list; diff --git a/sql/slave.cc b/sql/slave.cc index 43b70f29a68..22c61b3ec6c 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1357,6 +1357,17 @@ int register_slave_on_master(MYSQL* mysql, Master_info *mi, } +/** + Execute a SHOW SLAVE STATUS statement. + + @param thd Pointer to THD object for the client thread executing the + statement. + + @param mi Pointer to Master_info object for the IO thread. + + @retval FALSE success + @retval TRUE failure +*/ bool show_master_info(THD* thd, Master_info* mi) { // TODO: fix this for multi-master @@ -2062,7 +2073,7 @@ int apply_event_and_update_pos(Log_event* ev, THD* thd, Relay_log_info* rli, fewer times, 0 is returned. - init_master_info or init_relay_log_pos failed. (These are called - if a failure occurs when applying the event.) + if a failure occurs when applying the event.) - An error occurred when updating the binlog position. @@ -2307,8 +2318,14 @@ static int try_to_reconnect(THD *thd, MYSQL *mysql, Master_info *mi, } -/* Slave I/O Thread entry point */ +/** + Slave IO thread entry point. + @param arg Pointer to Master_info struct that holds information for + the IO thread. + + @return Always 0. +*/ pthread_handler_t handle_slave_io(void *arg) { THD *thd; // needs to be first for thread_stack @@ -2616,8 +2633,14 @@ err: } -/* Slave SQL Thread entry point */ +/** + Slave SQL thread entry point. + @param arg Pointer to Relay_log_info object that holds information + for the SQL thread. + + @return Always 0. +*/ pthread_handler_t handle_slave_sql(void *arg) { THD *thd; /* needs to be first for thread_stack */ @@ -3710,6 +3733,16 @@ static IO_CACHE *reopen_relay_log(Relay_log_info *rli, const char **errmsg) } +/** + Reads next event from the relay log. Should be called from the + slave IO thread. + + @param rli Relay_log_info structure for the slave IO thread. + + @return The event read, or NULL on error. If an error occurs, the + error is reported through the sql_print_information() or + sql_print_error() functions. +*/ static Log_event* next_event(Relay_log_info* rli) { Log_event* ev; diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc index 7ca7bef3a56..96e99b57e3c 100644 --- a/sql/sql_binlog.cc +++ b/sql/sql_binlog.cc @@ -18,7 +18,7 @@ #include "base64.h" /** - Execute a BINLOG statement + Execute a BINLOG statement. To execute the BINLOG command properly the server needs to know which format the BINLOG command's event is in. Therefore, the first @@ -26,6 +26,9 @@ Format_description_log_event, as outputted by mysqlbinlog. This Format_description_log_event is cached in rli->description_event_for_exec. + + @param thd Pointer to THD object for the client thread executing the + statement. */ void mysql_client_binlog_statement(THD* thd) diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 26bd8d18750..ed6b9e7d8df 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -190,6 +190,15 @@ typedef struct st_lex_server_options char *server_name, *host, *db, *username, *password, *scheme, *socket, *owner; } LEX_SERVER_OPTIONS; + +/** + Structure to hold parameters for CHANGE MASTER or START/STOP SLAVE + or SHOW NEW MASTER. + + Remark: this should not be confused with Master_info (and perhaps + would better be renamed to st_lex_replication_info). Some fields, + e.g., delay, are saved in Relay_log_info, not in Master_info. +*/ typedef struct st_lex_master_info { char *host, *user, *password, *log_file_name; diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index eac7a50417a..646bfdaefe8 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -257,6 +257,17 @@ bool purge_error_message(THD* thd, int res) } +/** + Execute a PURGE BINARY LOGS TO command. + + @param thd Pointer to THD object for the client thread executing the + statement. + + @param to_log Name of the last log to purge. + + @retval FALSE success + @retval TRUE failure +*/ bool purge_master_logs(THD* thd, const char* to_log) { char search_file_name[FN_REFLEN]; @@ -273,6 +284,17 @@ bool purge_master_logs(THD* thd, const char* to_log) } +/** + Execute a PURGE BINARY LOGS BEFORE command. + + @param thd Pointer to THD object for the client thread executing the + statement. + + @param purge_time Date before which logs should be purged. + + @retval FALSE success + @retval TRUE failure +*/ bool purge_master_logs_before_date(THD* thd, time_t purge_time) { if (!mysql_bin_log.is_open()) @@ -765,6 +787,20 @@ err: DBUG_VOID_RETURN; } + +/** + Execute a START SLAVE statement. + + @param thd Pointer to THD object for the client thread executing the + statement. + + @param mi Pointer to Master_info object for the slave's IO thread. + + @param net_report If true, saves the exit status into thd->main_da. + + @retval 0 success + @retval 1 error +*/ int start_slave(THD* thd , Master_info* mi, bool net_report) { int slave_errno= 0; @@ -890,6 +926,19 @@ int start_slave(THD* thd , Master_info* mi, bool net_report) } +/** + Execute a STOP SLAVE statement. + + @param thd Pointer to THD object for the client thread executing the + statement. + + @param mi Pointer to Master_info object for the slave's IO thread. + + @param net_report If true, saves the exit status into thd->main_da. + + @retval 0 success + @retval 1 error +*/ int stop_slave(THD* thd, Master_info* mi, bool net_report ) { DBUG_ENTER("stop_slave"); @@ -942,20 +991,17 @@ int stop_slave(THD* thd, Master_info* mi, bool net_report ) } -/* - Remove all relay logs and start replication from the start +/** + Execute a RESET SLAVE statement. - SYNOPSIS - reset_slave() - thd Thread handler - mi Master info for the slave + @param thd Pointer to THD object of the client thread executing the + statement. - RETURN - 0 ok - 1 error + @param mi Pointer to Master_info object for the slave. + + @retval 0 success + @retval 1 error */ - - int reset_slave(THD *thd, Master_info* mi) { MY_STAT stat_area; @@ -1070,6 +1116,18 @@ void kill_zombie_dump_threads(uint32 slave_server_id) } +/** + Execute a CHANGE MASTER statement. + + @param thd Pointer to THD object for the client thread executing the + statement. + + @param mi Pointer to Master_info object belonging to the slave's IO + thread. + + @retval FALSE success + @retval TRUE error +*/ bool change_master(THD* thd, Master_info* mi) { int thread_mask; @@ -1283,6 +1341,16 @@ bool change_master(THD* thd, Master_info* mi) DBUG_RETURN(FALSE); } + +/** + Execute a RESET MASTER statement. + + @param thd Pointer to THD object of the client thread executing the + statement. + + @retval 0 success + @retval 1 error +*/ int reset_master(THD* thd) { if (!mysql_bin_log.is_open()) @@ -1312,6 +1380,15 @@ int cmp_master_pos(const char* log_file_name1, ulonglong log_pos1, } +/** + Execute a SHOW BINLOG EVENTS statement. + + @param thd Pointer to THD object for the client thread executing the + statement. + + @retval FALSE success + @retval TRUE failure +*/ bool mysql_show_binlog_events(THD* thd) { Protocol *protocol= thd->protocol; @@ -1462,6 +1539,15 @@ err: } +/** + Execute a SHOW MASTER STATUS statement. + + @param thd Pointer to THD object for the client thread executing the + statement. + + @retval FALSE success + @retval TRUE failure +*/ bool show_binlog_info(THD* thd) { Protocol *protocol= thd->protocol; @@ -1495,18 +1581,15 @@ bool show_binlog_info(THD* thd) } -/* - Send a list of all binary logs to client +/** + Execute a SHOW BINARY LOGS statement. - SYNOPSIS - show_binlogs() - thd Thread specific variable + @param thd Pointer to THD object for the client thread executing the + statement. - RETURN VALUES - FALSE OK - TRUE error + @retval FALSE success + @retval TRUE failure */ - bool show_binlogs(THD* thd) { IO_CACHE *index_file; From b43b8c2479505c1369201082cf45e255938da7b4 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Fri, 9 Jan 2009 14:18:08 +0100 Subject: [PATCH 123/137] Bug#40972: Partition pruning can lead to crash for bad dates post push fix, added test found a valgrind warning --- sql/sql_partition.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index ad24aa3c283..ae55c194c3c 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -6678,6 +6678,7 @@ int get_part_iter_for_interval_via_mapping(partition_info *part_info, uint32 max_endpoint_val; get_endpoint_func get_endpoint; uint field_len= field->pack_length_in_rec(); + part_iter->ret_null_part= part_iter->ret_null_part_orig= FALSE; if (part_info->part_type == RANGE_PARTITION) { @@ -6698,7 +6699,6 @@ int get_part_iter_for_interval_via_mapping(partition_info *part_info, max_endpoint_val= part_info->no_list_values; part_iter->get_next= get_next_partition_id_list; part_iter->part_info= part_info; - part_iter->ret_null_part= part_iter->ret_null_part_orig= FALSE; if (max_endpoint_val == 0) { /* From c6d81f84675a70f5e5ea1b8e6218788395fa19a0 Mon Sep 17 00:00:00 2001 From: Matthias Leich Date: Fri, 9 Jan 2009 15:10:03 +0100 Subject: [PATCH 124/137] 1. Fix for Bug#41111 events_bugs fails sporadically on pushbuild 2. Avoid bad effects of bug 41925 Warning 1366 Incorrect string value: ... for column processlist.info 3. Add poll routines which ensure that subtests meet stable scenarios. This does not change the sense of the subtests. --- mysql-test/include/check_events_off.inc | 31 ++ .../include/no_running_event_scheduler.inc | 23 ++ mysql-test/include/no_running_events.inc | 25 ++ .../include/running_event_scheduler.inc | 30 ++ mysql-test/r/events_bugs.result | 27 +- mysql-test/t/events_bugs.test | 268 ++++++++++++++---- 6 files changed, 337 insertions(+), 67 deletions(-) create mode 100644 mysql-test/include/check_events_off.inc create mode 100644 mysql-test/include/no_running_event_scheduler.inc create mode 100644 mysql-test/include/no_running_events.inc create mode 100644 mysql-test/include/running_event_scheduler.inc diff --git a/mysql-test/include/check_events_off.inc b/mysql-test/include/check_events_off.inc new file mode 100644 index 00000000000..599a4b9e504 --- /dev/null +++ b/mysql-test/include/check_events_off.inc @@ -0,0 +1,31 @@ +########## include/check_events_off.inc #################################### +# # +# Purpose: # +# Wait till we can expect that we have no event activity till the scheduler is # +# switched on again. # +# = There will be no modifications of user tables by existing events # +# except they use "INSERT DELAYED" or the server system variable # +# "concurrent_inserts" is not switched off. # +# Only some storage engines support concurrent_inserts" or "INSERT DELAYED". # +# # +# Creation: # +# 2008-12-19 mleich Implement this check needed for bug fixes in tests # +# # +################################################################################ + +# 1. Check that the server system variable shows the state needed +if (`SELECT @@global.event_scheduler <> 'OFF'`) +{ + --echo # Error: We expect here that the event scheduler is switched off. + SELECT @@global.event_scheduler; + --echo # Thinkable reasons: + --echo # 1. SET GLOBAL event_scheduler = OFF had not the expected effect. + --echo # 2. Use of the current routine (include/check_events_off.inc) + --echo # within the wrong situation + --die +} +# 2. Wait till we have no event_scheduler session within the processlist +--source include/no_running_event_scheduler.inc +# 3. Wait till we have no event executor sessions within the processlist +--source include/no_running_events.inc + diff --git a/mysql-test/include/no_running_event_scheduler.inc b/mysql-test/include/no_running_event_scheduler.inc new file mode 100644 index 00000000000..92813df9f96 --- /dev/null +++ b/mysql-test/include/no_running_event_scheduler.inc @@ -0,0 +1,23 @@ +########## include/no_running_event_scheduler.inc ########################## +# # +# Wait till the event scheduler disappeared from processlist. # +# # +# The characteristics of the event_scheduler entry within the processlist is # +# user = 'event_scheduler' and command = 'Daemon'. I am not 100% sure if # +# ther is no short phase with command <> 'Daemon'. # +# A query with WHERE user = 'event_scheduler' only will also catch events in # +# startup phase. This is no problem since this phase is very short. # +# # +# A wait_timeout of >= 3 seconds was within experiments sufficient even on a # +# testing box with heavy parallel load. Therefore 5 seconds should be enough. # +# # +# Creation: # +# 2008-12-19 mleich Implement this check needed for test bug fixes # +# # +################################################################################ + +let $wait_timeout= 5; +let $wait_condition= + SELECT COUNT(*) = 0 FROM information_schema.processlist + WHERE user = 'event_scheduler'; +--source include/wait_condition.inc diff --git a/mysql-test/include/no_running_events.inc b/mysql-test/include/no_running_events.inc new file mode 100644 index 00000000000..8090b2706b8 --- /dev/null +++ b/mysql-test/include/no_running_events.inc @@ -0,0 +1,25 @@ +########## include/no_running_events.inc ################################### +# # +# Wait till all event executors have finished their work. # +# # +# Different event executors share the characteristics that their entry within # +# processlist contains command = 'Connect'. # +# Of course the corresponding query will also catch other connections being # +# within the connect phase. This is no problem since the connect phase is # +# usually very short. # +# # +# A wait_timeout of >= 3 seconds was during experiments in case of "simple" # +# SQL commands sufficient even on a testing box with heavy parallel load. # +# "simple" = no sleeps, no long running commands, no waiting for lock ... # +# We use here the default of 30 seconds because this wastes some time only in # +# case of unexpected situations. # +# # +# Creation: # +# 2008-12-19 mleich Implement this check needed for test bug fixes # +# # +################################################################################ + +let $wait_condition= + SELECT COUNT(*) = 0 FROM information_schema.processlist + WHERE command = 'Connect'; +--source include/wait_condition.inc diff --git a/mysql-test/include/running_event_scheduler.inc b/mysql-test/include/running_event_scheduler.inc new file mode 100644 index 00000000000..296bf842e82 --- /dev/null +++ b/mysql-test/include/running_event_scheduler.inc @@ -0,0 +1,30 @@ +############# include/running_event_scheduler.inc ########################## +# # +# Wait till the event scheduler reached its final state within the processlist.# +# # +# The characteristics of the event_scheduler entry within the processlist is # +# user = 'event_scheduler' and command = 'Daemon'. I am not 100% sure if # +# ther is no short phase with command <> 'Daemon'. # +# A query with WHERE user = 'event_scheduler' only will also catch events in # +# startup phase. # +# # +# Creation: # +# 2008-12-19 mleich Implement this check needed for test bug fixes # +# # +################################################################################ + +# 1. Check that the server system variable shows the state needed +if (`SELECT @@global.event_scheduler <> 'ON'`) +{ + --echo # Error: We expect here that the event scheduler is switched on. + SELECT @@global.event_scheduler; + --echo # Thinkable reasons: + --echo # 1. SET GLOBAL event_scheduler = ON had not the expected effect. + --echo # 2. Use of the current routine (include/running_event_scheduler.inc) + --echo # within the wrong situation + --die +} +let $wait_condition= + SELECT COUNT(*) = 1 FROM information_schema.processlist + WHERE user = 'event_scheduler' AND command = 'Daemon'; +--source include/wait_condition.inc diff --git a/mysql-test/r/events_bugs.result b/mysql-test/r/events_bugs.result index c698531dfec..f0fa1bc3efa 100644 --- a/mysql-test/r/events_bugs.result +++ b/mysql-test/r/events_bugs.result @@ -3,6 +3,8 @@ drop database if exists mysqltest_db1; drop database if exists mysqltest_db2; create database events_test; use events_test; +set @concurrent_insert= @@global.concurrent_insert; +set @@global.concurrent_insert = 0; select * from information_schema.global_variables where variable_name like 'event_scheduler'; VARIABLE_NAME VARIABLE_VALUE EVENT_SCHEDULER ON @@ -60,7 +62,7 @@ select get_lock('test_bug16407', 60); end| "Now if everything is fine the event has compiled and is locked" select /*1*/ user, host, db, info from information_schema.processlist -where info = 'select get_lock(\'test_bug16407\', 60)'; +where state = 'User lock' and info = 'select get_lock(\'test_bug16407\', 60)'; user host db info root localhost events_test select get_lock('test_bug16407', 60) select release_lock('test_bug16407'); @@ -84,7 +86,7 @@ get_lock('ee_16407_2', 60) set global event_scheduler= 1; "Another sql_mode test" set sql_mode="traditional"; -create table events_smode_test(ev_name char(10), a date) engine=myisam; +create table events_smode_test(ev_name char(10), a date); "This should never insert something" create event ee_16407_2 on schedule every 60 second do begin @@ -92,7 +94,7 @@ select get_lock('ee_16407_2', 60) /*ee_16407_2*/; select release_lock('ee_16407_2'); insert into events_test.events_smode_test values('ee_16407_2','1980-19-02'); end| -insert into events_smode_test values ('test','1980-19-02')| +insert into events_test.events_smode_test values ('test','1980-19-02')| ERROR 22007: Incorrect date value: '1980-19-02' for column 'a' at row 1 "This is ok" create event ee_16407_3 on schedule every 60 second do @@ -116,7 +118,7 @@ events_test ee_16407_2 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ events_test ee_16407_3 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER events_test ee_16407_4 select /*2*/ user, host, db, info from information_schema.processlist -where info = 'select get_lock(\'ee_16407_2\', 60)'; +where state = 'User lock' and info = 'select get_lock(\'ee_16407_2\', 60)'; user host db info root localhost events_test select get_lock('ee_16407_2', 60) root localhost events_test select get_lock('ee_16407_2', 60) @@ -125,10 +127,10 @@ select release_lock('ee_16407_2'); release_lock('ee_16407_2') 1 select /*3*/ user, host, db, info from information_schema.processlist -where info = 'select get_lock(\'ee_16407_2\', 60)'; +where state = 'User lock' and info = 'select get_lock(\'ee_16407_2\', 60)'; user host db info set global event_scheduler= off; -select * from events_smode_test order by ev_name, a; +select * from events_test.events_smode_test order by ev_name, a; ev_name a ee_16407_3 1980-02-19 ee_16407_3 1980-02-29 @@ -143,7 +145,7 @@ drop event ee_16407_2; drop event ee_16407_3; drop event ee_16407_4; "And now one last test regarding sql_mode and call of SP from an event" -delete from events_smode_test; +delete from events_test.events_smode_test; set sql_mode='ansi'; select get_lock('ee_16407_5', 60); get_lock('ee_16407_5', 60) @@ -166,10 +168,8 @@ call events_test.ee_16407_6_pendant(); end| "Should have 2 locked processes" select /*4*/ user, host, db, info from information_schema.processlist -where (command!='Daemon' || user='event_scheduler') and (info is null or info not like '%processlist%') -order by info; +where state = 'User lock' and info = 'select get_lock(\'ee_16407_5\', 60)'; user host db info -event_scheduler localhost NULL NULL root localhost events_test select get_lock('ee_16407_5', 60) root localhost events_test select get_lock('ee_16407_5', 60) select release_lock('ee_16407_5'); @@ -177,11 +177,9 @@ release_lock('ee_16407_5') 1 "Should have 0 processes locked" select /*5*/ user, host, db, info from information_schema.processlist -where (command!='Daemon' || user='event_scheduler') and (info is null or info not like '%processlist%') -order by info; +where state = 'User lock' and info = 'select get_lock(\'ee_16407_5\', 60)'; user host db info -event_scheduler localhost NULL NULL -select * from events_smode_test order by ev_name, a; +select * from events_test.events_smode_test order by ev_name, a; ev_name a ee_16407_6 2004-02-29 "And here we check one more time before we drop the events" @@ -740,3 +738,4 @@ name drop event e1; DROP DATABASE events_test; SET GLOBAL event_scheduler = 'ON'; +SET @@global.concurrent_insert = @concurrent_insert; diff --git a/mysql-test/t/events_bugs.test b/mysql-test/t/events_bugs.test index e86734c167c..d4b6e78ab3d 100644 --- a/mysql-test/t/events_bugs.test +++ b/mysql-test/t/events_bugs.test @@ -1,40 +1,133 @@ #### t/events_bugs.test # # Last change: -# 2008-10-16 mleich +# 2009-01-08 mleich # - Fix for -# Bug#39848 events_bugs fails sporadically on pushbuild -# (missing rows in table event_log) -# Bug#39863 events_bugs fails sporadically on pushbuild (extra processes -# in I_S.PROCESSLIST) -# Bug#39978 main.events_bugs does not clean up -# Bug#39569 events_bugs fails sporadically on pushbuild (should have -# failed with errno 1539) -# - Minor improvements of formatting +# Bug#41111 events_bugs fails sporadically on pushbuild +# - Avoid effects of +# Bug#41925 Warning 1366 Incorrect string value: ... for column processlist.info +# +# Please set $ +let $fixed_bug41925= 0; +# +# Dear maintainer of this test. Please do NOT remove the next big comment. +# The tests for events were quite unstable over a significant time because the +# effects of events in general and their representation within the processlist +# were partially not known. Therefore I had to make excessive experiments. +# The comment with the outcome of these experiments will be moved into a README +# file as soon as the tests for events get their own testsuite. +# +# Outcome of some experiments (mleich, mysql-5.1 2008-12): +# -------------------------------------------------------- +# 0. Most time used setup: +# High parallel I/O load +# set global event_scheduler= off; +# sleep 3; +# use events_test; +# create event e_16407 on schedule every 2 second do +# begin +# select 'FIRST COMMAND', sleep(0.5); +# select 'SECOND COMMAND'; +# end| +# set global event_scheduler= on; +# Start observation of the processlist +# +# +# 1. SET GLOBAL event_scheduler = 'ON' and immediate observation of the processlist. +# 1.1 Effects around event scheduler: +# 1.1.1 First phase (very short) +# No user 'event_scheduler' within information_schema.processlist. +# 1.1.2 Second phase observed (independend of probably existing events and very short) was +# USER HOST DB COMMAND TIME STATE INFO +# event_scheduler localhost NULL Daemon 0 Initialized NULL +# 1.1.3 Third phase observed: +# 1.1.3.1 Case we do not have existing events (rather long) +# USER HOST DB COMMAND TIME STATE INFO +# event_scheduler localhost NULL Daemon 0 Waiting on empty queue NULL +# 1.1.3.2 Case there exists already an event +# 1.1.3.2.1 Event executor is not visible in processlist but comes up soon +# USER HOST DB COMMAND TIME STATE INFO +# event_scheduler localhost NULL Daemon 0 NULL +# or +# event_scheduler localhost NULL Daemon 0 NULL NULL +# 1.1.3.2.2 A bit later, at least one event executor is or was visible in processlist +# The states mentioned in 3.2.1 or a bit later +# USER HOST DB COMMAND TIME STATE INFO +# event_scheduler localhost NULL Daemon 0 Waiting for next activation NULL +# 1.2 Effects around event executor: +# Typical processlist content: +# USER evtest1 -- Definer of event +# DB events_test -- DB during time of event creation (use DB is not allowed in events) +# COMMAND Connect +# STATE NULL +# INFO SET @evname = 'ev_sched_1823' -- Part of the event code +# +# State before "User sleep select 'FIRST COMMAND', sleep(0.5);" +# ID USER HOST DB COMMAND TIME STATE INFO +# 7 event_scheduler localhost NULL Connect 0 NULL NULL +# !! The user is not the event creator and the DB is different. !! +# !! This means that we must get later a change of the identity. !! +# or +# USER HOST DB COMMAND TIME STATE INFO +# root localhost events_test Connect 0 checking permissions +# or +# USER HOST DB COMMAND TIME STATE INFO +# root localhost events_test Connect 0 checking permissions CREATE PROCEDURE .... +# or +# USER HOST DB COMMAND TIME STATE INFO +# root localhost events_test Connect 0 NULL select 'FIRST COMMAND', sleep(0.5) +# or +# USER HOST DB COMMAND TIME STATE INFO +# root localhost events_test Connect 0 checking permissions select 'FIRST COMMAND'... +# or +# USER HOST DB COMMAND TIME STATE INFO +# root localhost events_test Connect 0 Opening table select 'FIRST COMMAND', sleep(0.5) +# or +# USER HOST DB COMMAND TIME STATE INFO +# root localhost events_test Connect 0 Locked select 'FIRST COMMAND', sleep(0.5) +# or +# USER HOST DB COMMAND TIME STATE INFO +# root localhost events_test Connect 0 executing select 'FIRST COMMAND', sleep(0.5) +# +# State "User sleep select 'FIRST COMMAND', sleep(0.5);" reached +# USER HOST DB COMMAND TIME STATE INFO +# root localhost events_test Connect 0 User sleep select 'FIRST COMMAND', sleep(0.5) +# +# State at end (! It looks like a slow CREATE PROC !) of event code execution was sometimes +# USER HOST DB COMMAND TIME STATE INFO +# root localhost events_test Connect 0 logging slow query CREATE PROCEDURE `e_16407`... +# +# State after running some event code was sometimes +# USER HOST DB COMMAND TIME STATE INFO +# root localhost events_test Connect 0 logging slow query select 'SECOND COMMAND' +# +# State somewhere (I guess just before the event executor disappears) +# USER HOST DB COMMAND TIME STATE INFO +# Event thread fin events_test Connect 0 Clearing NULL # # -# Outcome of some experiments (mleich): -# 1. SET GLOBAL event_scheduler = 'ON'; -# Immediate observation of the processlist. -# Effects: -# 1. There is no guarantee to find immediate the user 'event_scheduler' -# within information_schema.processlist. -# 2. Some states of the user 'event_scheduler' found in PROCESSLIST: -# USER HOST DB COMMAND TIME STATE INFO -# event_scheduler localhost NULL Daemon 0 Waiting on empty queue NULL -# event_scheduler localhost NULL Daemon 0 Initialized NULL # 2. SET GLOBAL event_scheduler = 'OFF'; # Immediate observation of the processlist. # Effects: # 1. I never found the user 'event_scheduler' within the processlist. # 2. Events just during execution could be found within the processlist # = It does not look like "SET GLOBAL event_scheduler = 'OFF'" stops them. -# 3. An event gets executed -# USER evtest1 (Definer of event) -# DB events_test (DB during time of event creation) -# COMMAND Connect -# STATE NULL -# INFO SET @evname = 'ev_sched_1823' (Part of the event code) +# ==> Everything mentioned in 1.2 above could be observed. +# +# Several subtests were weak because they showed random result set differences after issuing +# "SET GLOBAL EVENT_SCHEDULER= off;". +# 1. Reason one: There were already event executors +# Fix: Wait till there is no event executor active ==> no session WHERE +# - command IN ('Connect') +# There must be no parallel session being just in "Connect" phase! +# or +# - user = +# There must be no parallel session of this person. +# or user = 'event_scheduler' with command = 'Connect' +# The session which will soon change its identity to event creator. +# +# 2. Reason two: If an event modifies a MyISAM table than a delayed visibilty of changes +# might occur (concurrent_inserts=on or delayed inserts ...). # # Can't test with embedded server that doesn't support grants @@ -47,6 +140,10 @@ drop database if exists mysqltest_db2; --enable_warnings create database events_test; use events_test; +# We use MyISAM tables and must avoid effects (visibility of changes might be +# delayed) caused by concurrent_insert on (default). +set @concurrent_insert= @@global.concurrent_insert; +set @@global.concurrent_insert = 0; # # START: Bug #31332 --event-scheduler option misbehaving @@ -56,8 +153,11 @@ use events_test; # option with no argument in events_bugs-master.opt turns the scheduler on. select * from information_schema.global_variables where variable_name like 'event_scheduler'; +# Check that the event_scheduler is really running +--source include/running_event_scheduler.inc SET GLOBAL event_scheduler = 'OFF'; +--source include/check_events_off.inc # # END: Bug #31332 @@ -132,8 +232,10 @@ create event e_55 on schedule every 10 hour starts 10000101000000 do drop table # Start - 16407: Events: Changes in sql_mode won't be taken into account # set global event_scheduler=off; +--source include/check_events_off.inc delete from mysql.event; set global event_scheduler= on; +--source include/running_event_scheduler.inc set @old_sql_mode:=@@sql_mode; set sql_mode=ansi; select get_lock('test_bug16407', 60); @@ -148,13 +250,13 @@ delimiter ;| # We wait till one event runs and hangs when trying to get the user lock. let $wait_condition= select count(*) > 0 from information_schema.processlist - where info = 'select get_lock(\'test_bug16407\', 60)'; + where state = 'User lock' and info = 'select get_lock(\'test_bug16407\', 60)'; --source include/wait_condition.inc --echo "Now if everything is fine the event has compiled and is locked" # Expect to see one session in events_test waiting for the user lock. select /*1*/ user, host, db, info from information_schema.processlist -where info = 'select get_lock(\'test_bug16407\', 60)'; +where state = 'User lock' and info = 'select get_lock(\'test_bug16407\', 60)'; select release_lock('test_bug16407'); # Try to avoid # Bug#39863 events_bugs fails sporadically on pushbuild (extra processes in I_S.PROCESSLIST) @@ -162,23 +264,27 @@ select release_lock('test_bug16407'); # Bug#32782 User lock hash fails to find lock # "various issues related to missing or incorrect return results # from release_lock()." -# Therefore we check here if the event executing session disappeared or +# Therefore we check here if the event executor is no more locked or # we waited >= 5 seconds for this to happen. let $wait_timeout= 5; let $wait_condition= select count(*) = 0 from information_schema.processlist - where info = 'select get_lock(\'test_bug16407\', 60)'; + where state = 'User lock' and info = 'select get_lock(\'test_bug16407\', 60)'; --source include/wait_condition.inc if (!`$wait_condition`) { - --echo ERROR: There must be no session with info = 'select get_lock('test_bug16407', 60) within the processlist. + --echo ERROR: There must be no session with + --echo state = 'User lock' and info = 'select get_lock('test_bug16407', 60) + --echo within the processlist. --echo We probably hit Bug#32782 User lock hash fails to find lock - eval select * from information_schema.processlist; + SELECT * FROM information_schema.processlist; --echo Abort exit; } set global event_scheduler= off; +# Wait till the event scheduler and all event executors have finished their work. +--source include/check_events_off.inc select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name; --echo "Let's check whether we change the sql_mode on ALTER EVENT" @@ -191,9 +297,10 @@ set sql_mode="ansi"; select get_lock('ee_16407_2', 60); set global event_scheduler= 1; +--source include/running_event_scheduler.inc --echo "Another sql_mode test" set sql_mode="traditional"; -create table events_smode_test(ev_name char(10), a date) engine=myisam; +create table events_smode_test(ev_name char(10), a date); --echo "This should never insert something" delimiter |; create event ee_16407_2 on schedule every 60 second do @@ -203,7 +310,7 @@ begin insert into events_test.events_smode_test values('ee_16407_2','1980-19-02'); end| --error ER_TRUNCATED_WRONG_VALUE -insert into events_smode_test values ('test','1980-19-02')| +insert into events_test.events_smode_test values ('test','1980-19-02')| --echo "This is ok" create event ee_16407_3 on schedule every 60 second do begin @@ -223,13 +330,20 @@ end| delimiter ;| select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name; +# We wait till we have three event executors waiting for the removal of the lock. let $wait_condition= select count(*) = 3 from information_schema.processlist - where info = 'select get_lock(\'ee_16407_2\', 60)'; + where state = 'User lock' and info = 'select get_lock(\'ee_16407_2\', 60)'; --source include/wait_condition.inc +# There is an extreme low risk that an additional event execution is just coming +# up because +# - the events have to be started every 60 seconds. +# - we are just after event creation + waiting for seeing 3 locked +# We expect to see three event executors in state 'User lock'. select /*2*/ user, host, db, info from information_schema.processlist -where info = 'select get_lock(\'ee_16407_2\', 60)'; +where state = 'User lock' and info = 'select get_lock(\'ee_16407_2\', 60)'; + select release_lock('ee_16407_2'); # Try to avoid @@ -244,13 +358,37 @@ let $wait_timeout= 5; let $wait_condition= select count(*) = 0 from information_schema.processlist - where info = 'select get_lock(\'ee_16407_2\', 60)'; + where state = 'User lock' and info = 'select get_lock(\'ee_16407_2\', 60)'; --source include/wait_condition.inc +if (!`$wait_condition`) +{ + --echo ERROR: There must be no session with + --echo state = 'User lock' and info = 'select get_lock('test_bug16407_2', 60) + --echo within the processlist. + --echo We probably hit Bug#32782 User lock hash fails to find lock + SELECT * FROM information_schema.processlist; + --echo Abort + exit; +} +# We expect to see no event executors in state 'User lock'. +if(!$fixed_bug41925) +{ + --disable_warnings +} select /*3*/ user, host, db, info from information_schema.processlist -where info = 'select get_lock(\'ee_16407_2\', 60)'; +where state = 'User lock' and info = 'select get_lock(\'ee_16407_2\', 60)'; +if(!$fixed_bug41925) +{ + --enable_warnings +} + set global event_scheduler= off; -select * from events_smode_test order by ev_name, a; +# Wait till the event scheduler and all event executors have finished their work. +# Without this the next queries will give unstable results. +--source include/check_events_off.inc + +select * from events_test.events_smode_test order by ev_name, a; --echo "OK, last check before we drop them" select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name; drop event ee_16407_2; @@ -259,11 +397,12 @@ drop event ee_16407_4; --echo "And now one last test regarding sql_mode and call of SP from an event" -delete from events_smode_test; +delete from events_test.events_smode_test; set sql_mode='ansi'; select get_lock('ee_16407_5', 60); set global event_scheduler= on; +--source include/running_event_scheduler.inc set sql_mode='traditional'; delimiter |; @@ -286,34 +425,46 @@ delimiter ;| let $wait_condition= select count(*) = 2 from information_schema.processlist - where info = 'select get_lock(\'ee_16407_5\', 60)'; + where state = 'User lock' and info = 'select get_lock(\'ee_16407_5\', 60)'; --source include/wait_condition.inc --echo "Should have 2 locked processes" select /*4*/ user, host, db, info from information_schema.processlist -where (command!='Daemon' || user='event_scheduler') and (info is null or info not like '%processlist%') -order by info; +where state = 'User lock' and info = 'select get_lock(\'ee_16407_5\', 60)'; + select release_lock('ee_16407_5'); let $wait_condition= - select count(*) = 1 and user = 'event_scheduler' and info is null - from information_schema.processlist - where (command!='Daemon' || user='event_scheduler') - and (info is null or info not like '%processlist%'); + select count(*) = 0 from information_schema.processlist + where state = 'User lock' and info = 'select get_lock(\'ee_16407_5\', 60)'; --source include/wait_condition.inc --echo "Should have 0 processes locked" +if(!$fixed_bug41925) +{ + --disable_warnings +} select /*5*/ user, host, db, info from information_schema.processlist -where (command!='Daemon' || user='event_scheduler') and (info is null or info not like '%processlist%') -order by info; -select * from events_smode_test order by ev_name, a; +where state = 'User lock' and info = 'select get_lock(\'ee_16407_5\', 60)'; +if(!$fixed_bug41925) +{ + --enable_warnings +} + +# Wait till all event executors have finished their work, so that we can be sure +# that their changes to events_smode_test are done. +--source include/no_running_events.inc + +select * from events_test.events_smode_test order by ev_name, a; --echo "And here we check one more time before we drop the events" select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name; + drop event ee_16407_5; drop event ee_16407_6; drop procedure ee_16407_5_pendant; drop procedure ee_16407_6_pendant; set global event_scheduler= off; +--source include/check_events_off.inc drop table events_smode_test; set sql_mode=@old_sql_mode; # @@ -324,6 +475,7 @@ set sql_mode=@old_sql_mode; # START - 18897: Events: unauthorized action possible with alter event rename # set global event_scheduler=off; +--source include/check_events_off.inc --disable_warnings delete from mysql.user where User like 'mysqltest_%'; delete from mysql.db where User like 'mysqltest_%'; @@ -409,6 +561,7 @@ create function f22830 () returns int return 5; select get_lock('ee_22830', 60); set global event_scheduler=on; +--source include/running_event_scheduler.inc delimiter |; create procedure p22830_wait() @@ -456,6 +609,7 @@ let $wait_condition= --source include/wait_condition.inc set global event_scheduler=off; +--source include/check_events_off.inc select event_name, event_definition, interval_value, interval_field from information_schema.events order by event_name; drop procedure p22830_wait; drop function f22830; @@ -537,6 +691,7 @@ DROP USER mysqltest_u1@localhost; # For the actual tests of time zones please see events_time_zone.test # SET GLOBAL EVENT_SCHEDULER= OFF; +--source include/check_events_off.inc SET @save_time_zone= @@TIME_ZONE; #---------------------------------------------------------------------- @@ -749,6 +904,7 @@ let $engine=MyISAM; USE test; SHOW GRANTS FOR CURRENT_USER; SET GLOBAL event_scheduler = ON; +--source include/running_event_scheduler.inc eval CREATE TABLE events_test.event_log (id int KEY AUTO_INCREMENT, ev_nm char(40), ev_cnt int, ev_tm timestamp) @@ -817,12 +973,14 @@ disconnect e1; DROP EVENT events_test.ev_sched_1823; DROP TABLE events_test.event_log; SET GLOBAL event_scheduler = OFF; +--source include/check_events_off.inc # # Bug#28641 CREATE EVENT with '2038.01.18 03:00:00' let server crash. # SET GLOBAL event_scheduler= ON; +--source include/running_event_scheduler.inc DELIMITER |; CREATE EVENT bug28641 ON SCHEDULE AT '2038.01.18 03:00:00' DO BEGIN @@ -831,6 +989,7 @@ END;| DELIMITER ;| SET GLOBAL event_scheduler= OFF; +--source include/check_events_off.inc DROP EVENT bug28641; ########################################################################### @@ -955,6 +1114,7 @@ SET GLOBAL READ_ONLY = 1; --echo SET GLOBAL EVENT_SCHEDULER = ON; +--source include/running_event_scheduler.inc --echo @@ -980,6 +1140,7 @@ let $wait_condition = --echo SET GLOBAL EVENT_SCHEDULER = OFF; +--source include/check_events_off.inc --echo @@ -1056,14 +1217,15 @@ drop event e1; # ########################################################################### -let $wait_condition= - select count(*) = 0 from information_schema.processlist - where db='events_test' and command = 'Connect' and user=current_user(); ---source include/wait_condition.inc +# Ensure that all event executors have finished their work and cannot harm +# the next test. +--source include/no_running_events.inc DROP DATABASE events_test; # Restore the original state (option with no argument in events_bugs-master.opt # turns the scheduler on). SET GLOBAL event_scheduler = 'ON'; +--source include/running_event_scheduler.inc +SET @@global.concurrent_insert = @concurrent_insert; # THIS MUST BE THE LAST LINE in this file. From 06b3e7e21d4c7778a2ac30fbedea211ab4adcdac Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 9 Jan 2009 20:30:55 +0200 Subject: [PATCH 125/137] fixed a compile warning --- client/mysqltest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index d73cf78d9d4..62ec5a88599 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1344,7 +1344,7 @@ int diff_check() { char buf[512]= {0}; FILE *res_file; - char *cmd = "diff -v"; + const char *cmd = "diff -v"; int have_diff = 0; if (!(res_file= popen(cmd, "r"))) From a7d03bf4edbaff35f3d9447d7e3ad0c29fb7dd62 Mon Sep 17 00:00:00 2001 From: "Tatiana A. Nurnberg" Date: Mon, 12 Jan 2009 06:32:49 +0100 Subject: [PATCH 126/137] Bug#31177: Server variables can't be set to their current values Bounds-checks and blocksize corrections were applied to user-input, but constants in the server were trusted implicitly. If these values did not actually meet the requirements, the user could not set change a variable, then set it back to the (wonky) factory default or maximum by explicitly specifying it (SET = vs SET =DEFAULT). Now checks also apply to the server's presets. Wonky values and maxima get corrected at startup. Consequently all non-offsetted values the user sees are valid, and users can set the variable to that exact value if they so desire. --- mysql-test/r/read_buffer_size_basic.result | 4 ++++ mysql-test/r/read_rnd_buffer_size_basic.result | 4 ++++ mysys/my_getopt.c | 14 ++++++++------ sql/mysqld.cc | 2 +- storage/innobase/handler/ha_innodb.cc | 6 +++--- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/mysql-test/r/read_buffer_size_basic.result b/mysql-test/r/read_buffer_size_basic.result index 799f7b56235..3c007dc1515 100644 --- a/mysql-test/r/read_buffer_size_basic.result +++ b/mysql-test/r/read_buffer_size_basic.result @@ -86,6 +86,8 @@ SELECT @@global.read_buffer_size= 8200 OR @@global.read_buffer_size= 8228 ; @@global.read_buffer_size= 8200 OR @@global.read_buffer_size= 8228 1 SET @@global.read_buffer_size = 2147479553; +Warnings: +Warning 1292 Truncated incorrect read_buffer_size value: '2147479553' SELECT @@global.read_buffer_size; @@global.read_buffer_size 2147479552 @@ -114,6 +116,8 @@ SELECT @@session.read_buffer_size= 8200 OR @@session.read_buffer_size= 8228 ; SET @@session.read_buffer_size = 65530.34.; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1 SET @@session.read_buffer_size = 2147479553; +Warnings: +Warning 1292 Truncated incorrect read_buffer_size value: '2147479553' SELECT @@session.read_buffer_size; @@session.read_buffer_size 2147479552 diff --git a/mysql-test/r/read_rnd_buffer_size_basic.result b/mysql-test/r/read_rnd_buffer_size_basic.result index c51b0591054..c6440ac032e 100644 --- a/mysql-test/r/read_rnd_buffer_size_basic.result +++ b/mysql-test/r/read_rnd_buffer_size_basic.result @@ -88,6 +88,8 @@ SELECT @@global.read_rnd_buffer_size= 8200 OR @@global.read_rnd_buffer_size= 822 @@global.read_rnd_buffer_size= 8200 OR @@global.read_rnd_buffer_size= 8228 1 SET @@global.read_rnd_buffer_size = 2147479553; +Warnings: +Warning 1292 Truncated incorrect read_rnd_buffer_size value: '2147479553' SELECT @@global.read_rnd_buffer_size; @@global.read_rnd_buffer_size 2147479552 @@ -116,6 +118,8 @@ SELECT @@session.read_rnd_buffer_size= 8200 OR @@session.read_rnd_buffer_size= 8 SET @@session.read_rnd_buffer_size = 65530.34.; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1 SET @@session.read_rnd_buffer_size = 2147479553; +Warnings: +Warning 1292 Truncated incorrect read_rnd_buffer_size value: '2147479553' SELECT @@session.read_rnd_buffer_size; @@session.read_rnd_buffer_size 2147479552 diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 0f8055860d4..f97550d4429 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -976,24 +976,26 @@ static void init_one_value(const struct my_option *option, uchar* *variable, *((my_bool*) variable)= (my_bool) value; break; case GET_INT: - *((int*) variable)= (int) value; + *((int*) variable)= (int) getopt_ll_limit_value((int) value, option, NULL); break; - case GET_UINT: case GET_ENUM: *((uint*) variable)= (uint) value; break; + case GET_UINT: + *((uint*) variable)= (uint) getopt_ull_limit_value((uint) value, option, NULL); + break; case GET_LONG: - *((long*) variable)= (long) value; + *((long*) variable)= (long) getopt_ll_limit_value((long) value, option, NULL); break; case GET_ULONG: - *((ulong*) variable)= (ulong) value; + *((ulong*) variable)= (ulong) getopt_ull_limit_value((ulong) value, option, NULL); break; case GET_LL: - *((longlong*) variable)= (longlong) value; + *((longlong*) variable)= (longlong) getopt_ll_limit_value((longlong) value, option, NULL); break; case GET_ULL: case GET_SET: - *((ulonglong*) variable)= (ulonglong) value; + *((ulonglong*) variable)= (ulonglong) getopt_ull_limit_value((ulonglong) value, option, NULL); break; case GET_DOUBLE: *((double*) variable)= (double) value; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 1e9d942b1dd..a2ccbc42e77 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -6611,7 +6611,7 @@ The minimum value for this variable is 4096.", {"max_user_connections", OPT_MAX_USER_CONNECTIONS, "The maximum number of active connections for a single user (0 = no limit).", (uchar**) &max_user_connections, (uchar**) &max_user_connections, 0, GET_UINT, - REQUIRED_ARG, 0, 1, UINT_MAX, 0, 1, 0}, + REQUIRED_ARG, 0, 0, UINT_MAX, 0, 1, 0}, {"max_write_lock_count", OPT_MAX_WRITE_LOCK_COUNT, "After this many write locks, allow some read locks to run in between.", (uchar**) &max_write_lock_count, (uchar**) &max_write_lock_count, 0, GET_ULONG, diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index bf777b982db..6358f7ce055 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -8249,7 +8249,7 @@ static MYSQL_SYSVAR_BOOL(adaptive_hash_index, innobase_adaptive_hash_index, static MYSQL_SYSVAR_LONG(additional_mem_pool_size, innobase_additional_mem_pool_size, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, "Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.", - NULL, NULL, 1*1024*1024L, 512*1024L, ~0L, 1024); + NULL, NULL, 1*1024*1024L, 512*1024L, LONG_MAX, 1024); static MYSQL_SYSVAR_ULONG(autoextend_increment, srv_auto_extend_increment, PLUGIN_VAR_RQCMDARG, @@ -8289,7 +8289,7 @@ static MYSQL_SYSVAR_LONG(lock_wait_timeout, innobase_lock_wait_timeout, static MYSQL_SYSVAR_LONG(log_buffer_size, innobase_log_buffer_size, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, "The size of the buffer which InnoDB uses to write log to the log files on disk.", - NULL, NULL, 1024*1024L, 256*1024L, ~0L, 1024); + NULL, NULL, 1024*1024L, 256*1024L, LONG_MAX, 1024); static MYSQL_SYSVAR_LONGLONG(log_file_size, innobase_log_file_size, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, @@ -8309,7 +8309,7 @@ static MYSQL_SYSVAR_LONG(mirrored_log_groups, innobase_mirrored_log_groups, static MYSQL_SYSVAR_LONG(open_files, innobase_open_files, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, "How many files at the maximum InnoDB keeps open at the same time.", - NULL, NULL, 300L, 10L, ~0L, 0); + NULL, NULL, 300L, 10L, LONG_MAX, 0); static MYSQL_SYSVAR_ULONG(sync_spin_loops, srv_n_spin_wait_rounds, PLUGIN_VAR_RQCMDARG, From a13eda38ae78c42730a406f808cb36fd1b61bc57 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Mon, 12 Jan 2009 10:48:33 -0200 Subject: [PATCH 127/137] Post-merge fix for bug 37016: Update test case for row-based logging. --- mysql-test/include/commit.inc | 2 +- mysql-test/r/commit_1innodb.result | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/include/commit.inc b/mysql-test/include/commit.inc index de5eca8b1f6..beae927764f 100644 --- a/mysql-test/include/commit.inc +++ b/mysql-test/include/commit.inc @@ -733,7 +733,7 @@ call p_verify_status_increment(1, 0, 1, 0); rename table t4 to t3; call p_verify_status_increment(1, 0, 1, 0); truncate table t3; -call p_verify_status_increment(4, 4, 2, 2); +call p_verify_status_increment(4, 4, 4, 4); create view v1 as select * from t2; call p_verify_status_increment(1, 0, 1, 0); check table t1; diff --git a/mysql-test/r/commit_1innodb.result b/mysql-test/r/commit_1innodb.result index 72e6b01bb03..eddd31c9374 100644 --- a/mysql-test/r/commit_1innodb.result +++ b/mysql-test/r/commit_1innodb.result @@ -853,7 +853,7 @@ call p_verify_status_increment(1, 0, 1, 0); SUCCESS truncate table t3; -call p_verify_status_increment(4, 4, 2, 2); +call p_verify_status_increment(4, 4, 4, 4); SUCCESS create view v1 as select * from t2; From b180a1023335c40aba2be060471cedad5e3c0028 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Mon, 12 Jan 2009 18:17:15 +0200 Subject: [PATCH 128/137] Fixed a warning in sql_profile.cc --- sql/sql_profile.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc index c62cf6401ba..cb5b3722559 100644 --- a/sql/sql_profile.cc +++ b/sql/sql_profile.cc @@ -552,8 +552,8 @@ int PROFILING::fill_statistics_info(THD *thd, TABLE_LIST *tables, Item *cond) The order of these fields is set by the query_profile_statistics_info array. */ - table->field[0]->store((ulonglong) query->profiling_query_id); - table->field[1]->store((ulonglong) seq); /* the step in the sequence */ + table->field[0]->store((ulonglong) query->profiling_query_id, TRUE); + table->field[1]->store((ulonglong) seq, TRUE); /* the step in the sequence */ /* This entry, n, has a point in time, T(n), and a status phrase, S(n). The status phrase S(n) describes the period of time that begins at From e3716a3dc0084ef4b62f84fd6482bb646e75b403 Mon Sep 17 00:00:00 2001 From: Chad MILLER Date: Mon, 12 Jan 2009 14:48:02 -0500 Subject: [PATCH 129/137] Bug#38364: gen_lex_hash segmentation fault in debug build Bug#36428: MY_MUTEX_INIT_FAST is used before initialization On some thread implementations, we need a fake mutex attri- bute as a placeholder, which we define as a global variable, "my_fast_mutexattr". Well. that must be initialized before used in any mutexes, and the ordering of initializations in the API function my_init() was wrong. Now, put my_thread_global_init(), which initializes the attri- butes that mutexes require. --- mysys/my_init.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mysys/my_init.c b/mysys/my_init.c index 4b45d5ddc1a..0eec242818d 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -78,8 +78,12 @@ my_bool my_init(void) my_umask= 0660; /* Default umask for new files */ my_umask_dir= 0700; /* Default umask for new directories */ init_glob_errs(); -#if defined(THREAD) && defined(SAFE_MUTEX) +#if defined(THREAD) + if (my_thread_global_init()) + return 1; +# if defined(SAFE_MUTEX) safe_mutex_global_init(); /* Must be called early */ +# endif #endif #if defined(THREAD) && defined(MY_PTHREAD_FASTMUTEX) && !defined(SAFE_MUTEX) fastmutex_global_init(); /* Must be called early */ @@ -89,8 +93,6 @@ my_bool my_init(void) #if defined(HAVE_PTHREAD_INIT) pthread_init(); /* Must be called before DBUG_ENTER */ #endif - if (my_thread_global_init()) - return 1; #if !defined( __WIN__) && !defined(__NETWARE__) sigfillset(&my_signals); /* signals blocked by mf_brkhant */ #endif From 4e550c9d897f403f5f3cc4799aa596f89b2bd229 Mon Sep 17 00:00:00 2001 From: Patrick Crews Date: Mon, 12 Jan 2009 18:45:35 -0500 Subject: [PATCH 130/137] Bug#41888: Test binlog.binlog_database causing binlog_innodb to fail on Pushbuild. Added cleanup of status variables to the end of binlog_database. Re-recorded .result file to account for cleanup statement. NOTE: binlog.binlog_innodb also has had an FLUSH STATUS; statement added to it as well, but adding this cleanup as a preventative measure. --- mysql-test/extra/binlog_tests/database.test | 2 ++ mysql-test/suite/binlog/r/binlog_database.result | 3 +++ 2 files changed, 5 insertions(+) diff --git a/mysql-test/extra/binlog_tests/database.test b/mysql-test/extra/binlog_tests/database.test index 2e445f98adf..326ecedb60e 100644 --- a/mysql-test/extra/binlog_tests/database.test +++ b/mysql-test/extra/binlog_tests/database.test @@ -28,3 +28,5 @@ enable_warnings; insert into t1 values (1); drop table tt1, t1; source include/show_binlog_events.inc; + +FLUSH STATUS; diff --git a/mysql-test/suite/binlog/r/binlog_database.result b/mysql-test/suite/binlog/r/binlog_database.result index 3b470fe11af..39b889d8d0a 100644 --- a/mysql-test/suite/binlog/r/binlog_database.result +++ b/mysql-test/suite/binlog/r/binlog_database.result @@ -33,6 +33,7 @@ master-bin.000001 # Query # # use `test`; insert into t1 values (1) master-bin.000001 # Query # # drop database if exists mysqltest1 master-bin.000001 # Query # # use `test`; insert into t1 values (1) master-bin.000001 # Query # # use `test`; drop table tt1, t1 +FLUSH STATUS; set binlog_format=mixed; reset master; create database testing_1; @@ -68,6 +69,7 @@ master-bin.000001 # Query # # use `test`; insert into t1 values (1) master-bin.000001 # Query # # drop database if exists mysqltest1 master-bin.000001 # Query # # use `test`; insert into t1 values (1) master-bin.000001 # Query # # use `test`; drop table tt1, t1 +FLUSH STATUS; set binlog_format=row; reset master; create database testing_1; @@ -108,6 +110,7 @@ master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Query # # use `test`; COMMIT master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */ +FLUSH STATUS; show databases; Database information_schema From d657438ea041cec292f366f0ad4427b4027da4c7 Mon Sep 17 00:00:00 2001 From: Matthias Leich Date: Tue, 13 Jan 2009 14:09:24 +0100 Subject: [PATCH 131/137] Fix for Bug#40377 sporadic pushbuild failure in log_state: result mismatch + add workaround for bug 38124 + messages into the protocol when sessions are switched + replace error numbers by error names + reset of system variables to initial values per subtest + remove a file created by this test + minor improvements in structure and formatting --- mysql-test/r/log_state.result | 81 ++++++++------ mysql-test/t/log_state.test | 200 +++++++++++++++++++++++++--------- 2 files changed, 195 insertions(+), 86 deletions(-) diff --git a/mysql-test/r/log_state.result b/mysql-test/r/log_state.result index 63903a034d2..5c3e3d789a1 100644 --- a/mysql-test/r/log_state.result +++ b/mysql-test/r/log_state.result @@ -1,3 +1,7 @@ +SET @old_general_log= @@global.general_log; +SET @old_general_log_file= @@global.general_log_file; +SET @old_slow_query_log= @@global.slow_query_log; +SET @old_slow_query_log_file= @@global.slow_query_log_file; set global general_log= OFF; truncate table mysql.general_log; truncate table mysql.slow_log; @@ -33,20 +37,26 @@ general_log ON log ON log_slow_queries OFF slow_query_log OFF -set session long_query_time=1; -select sleep(2); -sleep(2) +# Establish connection con1 (user=root) +# Switch to connection con1 +set @long_query_time = ; +set session long_query_time = @long_query_time; +select sleep(@long_query_time + 1); +sleep(@long_query_time + 1) 0 select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%'; start_time user_host query_time lock_time rows_sent rows_examined db last_insert_id insert_id server_id sql_text +# Switch to connection default set global slow_query_log= ON; -set session long_query_time=1; -select sleep(2); -sleep(2) +# Switch to connection con1 +set session long_query_time = @long_query_time; +select sleep(@long_query_time + 1); +sleep(@long_query_time + 1) 0 select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%'; start_time user_host query_time lock_time rows_sent rows_examined db last_insert_id insert_id server_id sql_text -TIMESTAMP USER_HOST QUERY_TIME 00:00:00 1 0 test 0 0 1 select sleep(2) +TIMESTAMP USER_HOST QUERY_TIME 00:00:00 1 0 test 0 0 1 select sleep(@long_query_time + 1) +# Switch to connection default show global variables where Variable_name = 'log' or Variable_name = 'log_slow_queries' or Variable_name = 'general_log' or Variable_name = 'slow_query_log'; @@ -92,8 +102,8 @@ slow_query_log_file # show variables like 'log_output'; Variable_name Value log_output FILE,TABLE -set global general_log_file='/not exiting path/log.master'; -ERROR 42000: Variable 'general_log_file' can't be set to the value of '/not exiting path/log.master' +set global general_log_file='/not existing path/log.master'; +ERROR 42000: Variable 'general_log_file' can't be set to the value of '/not existing path/log.master' set global general_log_file='MYSQLTEST_VARDIR'; ERROR 42000: Variable 'general_log_file' can't be set to the value of 'MYSQLTEST_VARDIR' set global general_log_file=''; @@ -153,8 +163,10 @@ select * from mysql.general_log; event_time user_host thread_id server_id command_type argument TIMESTAMP USER_HOST # 1 Query drop table t1 TIMESTAMP USER_HOST # 1 Query select * from mysql.general_log -SET @old_general_log_state = @@global.general_log; -SET @old_slow_log_state = @@global.slow_query_log; +SET @@global.general_log = @old_general_log; +SET @@global.general_log_file = @old_general_log_file; +SET @@global.slow_query_log = @old_slow_query_log; +SET @@global.slow_query_log_file = @old_slow_query_log_file; SET GLOBAL general_log = ON; SET GLOBAL slow_query_log = ON; FLUSH TABLES WITH READ LOCK; @@ -173,10 +185,9 @@ SET GLOBAL READ_ONLY = ON; SET GLOBAL general_log = ON; SET GLOBAL slow_query_log = ON; SET GLOBAL READ_ONLY = OFF; -SET GLOBAL general_log = @old_general_log_state; -SET GLOBAL slow_query_log = @old_slow_log_state; -SET @old_general_log_state = @@global.general_log; -SET @old_slow_log_state = @@global.slow_query_log; +SET GLOBAL general_log = @old_general_log; +SET GLOBAL slow_query_log = @old_slow_query_log; +SET GLOBAL general_log = ON; SHOW VARIABLES LIKE 'general_log'; Variable_name Value general_log ON @@ -239,29 +250,24 @@ log_slow_queries ON SELECT @@slow_query_log, @@log_slow_queries; @@slow_query_log @@log_slow_queries 1 1 -SET GLOBAL general_log = @old_general_log_state; -SET GLOBAL slow_query_log = @old_slow_log_state; -set @old_general_log_file= @@global.general_log_file; -set @old_slow_query_log_file= @@global.slow_query_log_file; -set global general_log_file= concat('/not exiting path/log.maste', 'r'); -ERROR 42000: Variable 'general_log_file' can't be set to the value of '/not exiting path/log.master' -set global general_log_file= NULL; +SET GLOBAL general_log = @old_general_log; +SET GLOBAL slow_query_log = @old_slow_query_log; +SET GLOBAL general_log_file= CONCAT('/not existing path/log.maste', 'r'); +ERROR 42000: Variable 'general_log_file' can't be set to the value of '/not existing path/log.master' +SET GLOBAL general_log_file= NULL; ERROR 42000: Variable 'general_log_file' can't be set to the value of 'NULL' -set global slow_query_log_file= concat('/not exiting path/log.maste', 'r'); -ERROR 42000: Variable 'slow_query_log_file' can't be set to the value of '/not exiting path/log.master' -set global slow_query_log_file= NULL; +SET GLOBAL slow_query_log_file= CONCAT('/not existing path/log.maste', 'r'); +ERROR 42000: Variable 'slow_query_log_file' can't be set to the value of '/not existing path/log.master' +SET GLOBAL slow_query_log_file= NULL; ERROR 42000: Variable 'slow_query_log_file' can't be set to the value of 'NULL' -set global general_log_file= @old_general_log_file; -set global slow_query_log_file= @old_slow_query_log_file; +SET GLOBAL general_log_file= @old_general_log_file; +SET GLOBAL slow_query_log_file= @old_slow_query_log_file; # -- # -- Bug#32748: Inconsistent handling of assignments to -# -- general_log_file/slow_query_log_file. +# -- general_log_file/slow_query_log_file. # -- -SET @general_log_file_saved = @@global.general_log_file; -SET @slow_query_log_file_saved = @@global.slow_query_log_file; - SET GLOBAL general_log_file = 'bug32748.query.log'; SET GLOBAL slow_query_log_file = 'bug32748.slow.log'; @@ -270,8 +276,8 @@ Variable_name Value general_log_file bug32748.query.log slow_query_log_file bug32748.slow.log -SET GLOBAL general_log_file = @general_log_file_saved; -SET GLOBAL slow_query_log_file = @slow_query_log_file_saved; +SET GLOBAL general_log_file = @old_general_log_file; +SET GLOBAL slow_query_log_file = @old_slow_query_log_file; # -- End of Bug#32748. deprecated: @@ -298,4 +304,13 @@ SET GLOBAL general_log_file = @my_glf; SET GLOBAL slow_query_log_file = @my_sqlf; SET GLOBAL general_log = DEFAULT; SET GLOBAL slow_query_log = DEFAULT; +SET @@global.general_log = @old_general_log; +SET @@global.general_log_file = @old_general_log_file; +SET @@global.slow_query_log = @old_slow_query_log; +SET @@global.slow_query_log_file = @old_slow_query_log_file; End of 5.1 tests +# Close connection con1 +SET global general_log = @old_general_log; +SET global general_log_file = @old_general_log_file; +SET global slow_query_log = @old_slow_query_log; +SET global slow_query_log_file = @old_slow_query_log_file; diff --git a/mysql-test/t/log_state.test b/mysql-test/t/log_state.test index 977b74aa1e3..e8ff60a8637 100644 --- a/mysql-test/t/log_state.test +++ b/mysql-test/t/log_state.test @@ -1,6 +1,28 @@ --- source include/not_embedded.inc +### t/log_state.test ### +# +# This test suffers from server +# Bug#38124 "general_log_file" variable silently unset when using expression +# In short: +# SET GLOBAL general_log_file = @ +# SET GLOBAL slow_query_log = @ +# cause that the value of these server system variables is set to default +# instead of the assigned values. There comes no error message or warning. +# If this bug is fixed please +# 1. try this test with "let $fixed_bug38124 = 0;" +# 2. remove all workarounds if 1. was successful. +let $fixed_bug38124 = 0; + +--source include/not_embedded.inc --source include/have_csv.inc +# Several subtests modify global variables. Save the initial values only here, +# but reset to the initial values per subtest. +SET @old_general_log= @@global.general_log; +SET @old_general_log_file= @@global.general_log_file; +SET @old_slow_query_log= @@global.slow_query_log; +SET @old_slow_query_log_file= @@global.slow_query_log_file; + + --disable_ps_protocol set global general_log= OFF; truncate table mysql.general_log; @@ -23,20 +45,32 @@ show global variables where Variable_name = 'log' or Variable_name = 'log_slow_queries' or Variable_name = 'general_log' or Variable_name = 'slow_query_log'; +--echo # Establish connection con1 (user=root) connect (con1,localhost,root,,); +--echo # Switch to connection con1 connection con1; -set session long_query_time=1; -select sleep(2); +# Please increase @long_query_time if the corresponding selects show an +# additional unexpected entry like +# start_time ... sql_text +# TIMESTAMP ... set session long_query_time=... +# (Bug#40377 sporadic pushbuild failure in log_state: result mismatch) +--replace_result 2 +set @long_query_time = 2; +set session long_query_time = @long_query_time; +select sleep(@long_query_time + 1); --replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%'; +--echo # Switch to connection default connection default; set global slow_query_log= ON; +--echo # Switch to connection con1 connection con1; -set session long_query_time=1; -select sleep(2); +set session long_query_time = @long_query_time; +select sleep(@long_query_time + 1); --replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%'; +--echo # Switch to connection default connection default; show global variables where Variable_name = 'log' or Variable_name = 'log_slow_queries' or @@ -71,16 +105,16 @@ show variables like 'slow_query_log_file'; show variables like 'log_output'; # Can't set general_log_file to a non existing file ---error 1231 -set global general_log_file='/not exiting path/log.master'; +--error ER_WRONG_VALUE_FOR_VAR +set global general_log_file='/not existing path/log.master'; # Can't set general_log_file to a directory --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---error 1231 +--error ER_WRONG_VALUE_FOR_VAR eval set global general_log_file='$MYSQLTEST_VARDIR'; # Can't set general_log_file to empty string ---error 1231 +--error ER_WRONG_VALUE_FOR_VAR set global general_log_file=''; --replace_column 2 # @@ -126,17 +160,30 @@ drop table t1; --replace_column 1 TIMESTAMP 2 USER_HOST 3 # select * from mysql.general_log; +# Reset to initial values +SET @@global.general_log = @old_general_log; +SET @@global.general_log_file = @old_general_log_file; +SET @@global.slow_query_log = @old_slow_query_log; +SET @@global.slow_query_log_file = @old_slow_query_log_file; +if(!$fixed_bug38124) +{ + --disable_query_log + let $my_var = `SELECT @old_general_log_file`; + eval SET @@global.general_log_file = '$my_var'; + let $my_var = `SELECT @old_slow_query_log_file`; + eval SET @@global.slow_query_log_file = '$my_var'; + --enable_query_log +} + + +########################################################################### + # # Bug#29129 (Resetting general_log while the GLOBAL READ LOCK is set causes -# a deadlock) - -# save state - -SET @old_general_log_state = @@global.general_log; -SET @old_slow_log_state = @@global.slow_query_log; +# a deadlock) +# # Test ON->OFF transition under a GLOBAL READ LOCK - SET GLOBAL general_log = ON; SET GLOBAL slow_query_log = ON; @@ -148,7 +195,6 @@ SET GLOBAL slow_query_log = OFF; UNLOCK TABLES; # Test OFF->ON transition under a GLOBAL READ LOCK - FLUSH TABLES WITH READ LOCK; SET GLOBAL general_log = ON; @@ -157,7 +203,6 @@ SET GLOBAL slow_query_log = ON; UNLOCK TABLES; # Test ON->OFF transition under a GLOBAL READ_ONLY - SET GLOBAL READ_ONLY = ON; SET GLOBAL general_log = OFF; @@ -166,7 +211,6 @@ SET GLOBAL slow_query_log = OFF; SET GLOBAL READ_ONLY = OFF; # Test OFF->ON transition under a GLOBAL READ_ONLY - SET GLOBAL READ_ONLY = ON; SET GLOBAL general_log = ON; @@ -174,17 +218,18 @@ SET GLOBAL slow_query_log = ON; SET GLOBAL READ_ONLY = OFF; -# Restore state +# Reset to initial values +SET GLOBAL general_log = @old_general_log; +SET GLOBAL slow_query_log = @old_slow_query_log; -SET GLOBAL general_log = @old_general_log_state; -SET GLOBAL slow_query_log = @old_slow_log_state; + +########################################################################### # -# Bug #29131: SHOW VARIABLES reports variable 'log' but SET doesn't recognize it +# Bug#29131: SHOW VARIABLES reports variable 'log' but SET doesn't recognize it # -SET @old_general_log_state = @@global.general_log; -SET @old_slow_log_state = @@global.slow_query_log; +SET GLOBAL general_log = ON; SHOW VARIABLES LIKE 'general_log'; SHOW VARIABLES LIKE 'log'; @@ -210,39 +255,47 @@ SHOW VARIABLES LIKE 'slow_query_log'; SHOW VARIABLES LIKE 'log_slow_queries'; SELECT @@slow_query_log, @@log_slow_queries; -SET GLOBAL general_log = @old_general_log_state; -SET GLOBAL slow_query_log = @old_slow_log_state; +SET GLOBAL general_log = @old_general_log; +SET GLOBAL slow_query_log = @old_slow_query_log; + + +########################################################################### # -# Bug #31604: server crash when setting slow_query_log_file/general_log_file +# Bug#31604: server crash when setting slow_query_log_file/general_log_file # -set @old_general_log_file= @@global.general_log_file; -set @old_slow_query_log_file= @@global.slow_query_log_file; ---error 1231 -set global general_log_file= concat('/not exiting path/log.maste', 'r'); ---error 1231 -set global general_log_file= NULL; ---error 1231 -set global slow_query_log_file= concat('/not exiting path/log.maste', 'r'); ---error 1231 -set global slow_query_log_file= NULL; +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL general_log_file= CONCAT('/not existing path/log.maste', 'r'); +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL general_log_file= NULL; +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL slow_query_log_file= CONCAT('/not existing path/log.maste', 'r'); +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL slow_query_log_file= NULL; + +# Reset to initial values in case a setting above was successful. +SET GLOBAL general_log_file= @old_general_log_file; +SET GLOBAL slow_query_log_file= @old_slow_query_log_file; +if(!$fixed_bug38124) +{ + --disable_query_log + let $my_var = `SELECT @old_general_log_file`; + eval SET @@global.general_log_file = '$my_var'; + let $my_var = `SELECT @old_slow_query_log_file`; + eval SET @@global.slow_query_log_file = '$my_var'; + --enable_query_log +} -set global general_log_file= @old_general_log_file; -set global slow_query_log_file= @old_slow_query_log_file; ########################################################################### --echo --echo # -- --echo # -- Bug#32748: Inconsistent handling of assignments to ---echo # -- general_log_file/slow_query_log_file. +--echo # -- general_log_file/slow_query_log_file. --echo # -- ---echo -SET @general_log_file_saved = @@global.general_log_file; -SET @slow_query_log_file_saved = @@global.slow_query_log_file; - --echo SET GLOBAL general_log_file = 'bug32748.query.log'; SET GLOBAL slow_query_log_file = 'bug32748.slow.log'; @@ -250,27 +303,37 @@ SET GLOBAL slow_query_log_file = 'bug32748.slow.log'; --echo SHOW VARIABLES LIKE '%log_file'; +# Reset to initial values --echo -SET GLOBAL general_log_file = @general_log_file_saved; -SET GLOBAL slow_query_log_file = @slow_query_log_file_saved; +SET GLOBAL general_log_file = @old_general_log_file; +SET GLOBAL slow_query_log_file = @old_slow_query_log_file; +if(!$fixed_bug38124) +{ + --disable_query_log + let $my_var = `SELECT @old_general_log_file`; + eval SET @@global.general_log_file = '$my_var'; + let $my_var = `SELECT @old_slow_query_log_file`; + eval SET @@global.slow_query_log_file = '$my_var'; + --enable_query_log +} --echo --echo # -- End of Bug#32748. + ########################################################################### +# WL#4403 - deprecate @log and @slow_log_queries variables - -## WL#4403 - deprecate @log and @slow_log_queries variables - -## these are all deprecated -- show for command-line as well! +# These server system variables are all deprecated +# -- show for command-line as well! --echo deprecated: SET GLOBAL log = 0; SET GLOBAL log_slow_queries = 0; SET GLOBAL log = DEFAULT; SET GLOBAL log_slow_queries = DEFAULT; -## these are NOT deprecated +# These server system variables are NOT deprecated. --echo not deprecated: SELECT @@global.general_log_file INTO @my_glf; SELECT @@global.slow_query_log_file INTO @my_sqlf; @@ -283,6 +346,20 @@ SET GLOBAL slow_query_log_file = @my_sqlf; SET GLOBAL general_log = DEFAULT; SET GLOBAL slow_query_log = DEFAULT; +## Reset to initial values +SET @@global.general_log = @old_general_log; +SET @@global.general_log_file = @old_general_log_file; +SET @@global.slow_query_log = @old_slow_query_log; +SET @@global.slow_query_log_file = @old_slow_query_log_file; +if(!$fixed_bug38124) +{ + --disable_query_log + let $my_var = `SELECT @old_general_log_file`; + eval SET @@global.general_log_file = '$my_var'; + let $my_var = `SELECT @old_slow_query_log_file`; + eval SET @@global.slow_query_log_file = '$my_var'; + --enable_query_log +} --echo End of 5.1 tests @@ -290,10 +367,27 @@ SET GLOBAL slow_query_log = DEFAULT; --enable_ps_protocol # -# Cleanup (must be done last to avoid delayed 'Quit' message in general log) +# Cleanup # +# Disconnect must be done last to avoid delayed 'Quit' message in general log +--echo # Close connection con1 disconnect con1; +# Reset global system variables to initial values if forgotten somewhere above. +SET global general_log = @old_general_log; +SET global general_log_file = @old_general_log_file; +SET global slow_query_log = @old_slow_query_log; +SET global slow_query_log_file = @old_slow_query_log_file; +if(!$fixed_bug38124) +{ + --disable_query_log + let $my_var = `SELECT @old_general_log_file`; + eval SET @@global.general_log_file = '$my_var'; + let $my_var = `SELECT @old_slow_query_log_file`; + eval SET @@global.slow_query_log_file = '$my_var'; + --enable_query_log +} # Remove the log files that was created in the "default location" # i.e var/run --remove_file $MYSQLTEST_VARDIR/run/master.log +--remove_file $MYSQLTEST_VARDIR/tmp/log.master From 50ad9d1fca2d3ea7f61a50f92b6952dab712209c Mon Sep 17 00:00:00 2001 From: Matthias Leich Date: Tue, 13 Jan 2009 15:04:28 +0100 Subject: [PATCH 132/137] Merge of fix for bug 41776 type_date.test may fail if run around midnight. into GCA tree. --- mysql-test/r/type_date.result | 13 ++++++++----- mysql-test/t/type_date.test | 31 +++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result index 7cb71831bce..f96e07b0c5e 100644 --- a/mysql-test/r/type_date.result +++ b/mysql-test/r/type_date.result @@ -65,12 +65,15 @@ CREATE TABLE t1(AFIELD INT); INSERT INTO t1 VALUES(1); CREATE TABLE t2(GMT VARCHAR(32)); INSERT INTO t2 VALUES('GMT-0800'); -SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT)) FROM t1, t2 GROUP BY t1.AFIELD; -DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT)) +SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)) +FROM t1, t2 GROUP BY t1.AFIELD; +DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)) Wed, 06 March 2002 10:11:12 GMT-0800 INSERT INTO t1 VALUES(1); -SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT)), DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT)) FROM t1,t2 GROUP BY t1.AFIELD; -DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT)) DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT)) +SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)), +DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)) +FROM t1,t2 GROUP BY t1.AFIELD; +DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)) DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)) Wed, 06 March 2002 10:11:12 GMT-0800 Wed, 06 March 2002 10:11:12 GMT-0800 drop table t1,t2; CREATE TABLE t1 (f1 time default NULL, f2 time default NULL); @@ -155,7 +158,7 @@ str_to_date( '', a ) 0000-00-00 00:00:00 NULL DROP TABLE t1; -CREATE TABLE t1 (a DATE, b int, PRIMARY KEY (a,b)); +CREATE TABLE t1 (a DATE, b INT, PRIMARY KEY (a,b)); INSERT INTO t1 VALUES (DATE(NOW()), 1); SELECT COUNT(*) FROM t1 WHERE a = NOW(); COUNT(*) diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test index 9bc428c3715..aec60bc2dee 100644 --- a/mysql-test/t/type_date.test +++ b/mysql-test/t/type_date.test @@ -62,7 +62,7 @@ drop table t1; # Test of date and not null # -create table t1 (date date); +create table t1 (date date); insert into t1 values ("2000-08-10"),("2000-08-11"); select date_add(date,INTERVAL 1 DAY),date_add(date,INTERVAL 1 SECOND) from t1; drop table t1; @@ -75,9 +75,12 @@ CREATE TABLE t1(AFIELD INT); INSERT INTO t1 VALUES(1); CREATE TABLE t2(GMT VARCHAR(32)); INSERT INTO t2 VALUES('GMT-0800'); -SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT)) FROM t1, t2 GROUP BY t1.AFIELD; +SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)) +FROM t1, t2 GROUP BY t1.AFIELD; INSERT INTO t1 VALUES(1); -SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT)), DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT)) FROM t1,t2 GROUP BY t1.AFIELD; +SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)), + DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)) +FROM t1,t2 GROUP BY t1.AFIELD; drop table t1,t2; # @@ -90,7 +93,7 @@ SELECT DATE_FORMAT(f1, "%l.%i %p") , DATE_FORMAT(f2, "%l.%i %p") FROM t1; DROP TABLE t1; # -# Bug 4937: different date -> string conversion when using SELECT ... UNION +# Bug#4937: different date -> string conversion when using SELECT ... UNION # and INSERT ... SELECT ... UNION # @@ -141,7 +144,7 @@ select * from t1; drop table t1; # -# Bug #30942: select str_to_date from derived table returns varying results +# Bug#30942: select str_to_date from derived table returns varying results # CREATE TABLE t1 ( a INT @@ -155,10 +158,22 @@ DROP TABLE t1; # -# Bug #31221: Optimizer incorrectly identifies impossible WHERE clause +# Bug#31221: Optimizer incorrectly identifies impossible WHERE clause # -CREATE TABLE t1 (a DATE, b int, PRIMARY KEY (a,b)); +CREATE TABLE t1 (a DATE, b INT, PRIMARY KEY (a,b)); +## The current sub test could fail (difference to expected result) if we +## have just reached midnight. +## (Bug#41776 type_date.test may fail if run around midnight) +## Therefore we sleep a bit if we are too close to midnight. +## The complete test itself needs in average less than 1 second. +## Therefore a time_distance to midnight of 5 seconds should be sufficient. +if (`SELECT CURTIME() > SEC_TO_TIME(24 * 3600 - 5)`) +{ + # We are here when CURTIME() is between '23:59:56' and '23:59:59'. + # So a sleep time of 5 seconds brings us between '00:00:01' and '00:00:04'. + --real_sleep 5 +} INSERT INTO t1 VALUES (DATE(NOW()), 1); SELECT COUNT(*) FROM t1 WHERE a = NOW(); EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW(); @@ -174,7 +189,7 @@ EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW(); DROP TABLE t1; # -# Bug #28687: Search fails on '0000-00-00' date after sql_mode change +# Bug#28687: Search fails on '0000-00-00' date after sql_mode change # CREATE TABLE t1 (a DATE); From 9904550760ce5ab4d5a449c97394aab2751b9993 Mon Sep 17 00:00:00 2001 From: He Zhenxing Date: Wed, 14 Jan 2009 16:27:32 +0800 Subject: [PATCH 133/137] BUG#41986 Replication slave does not pick up proper AUTO_INCREMENT value for Innodb tables The next number (AUTO_INCREMENT) field of the table for write rows events are not initialized, and cause some engines (innodb) not correctly update the tables's auto_increment value. This patch fixed this problem by honor next number fields if present. --- .../extra/rpl_tests/rpl_auto_increment.test | 17 +++++++++++++++++ .../suite/rpl/r/rpl_auto_increment.result | 17 +++++++++++++++++ sql/log_event.cc | 4 ++++ 3 files changed, 38 insertions(+) diff --git a/mysql-test/extra/rpl_tests/rpl_auto_increment.test b/mysql-test/extra/rpl_tests/rpl_auto_increment.test index 1fa3cf034f6..24448a38408 100644 --- a/mysql-test/extra/rpl_tests/rpl_auto_increment.test +++ b/mysql-test/extra/rpl_tests/rpl_auto_increment.test @@ -145,6 +145,23 @@ select * from t3 order by a; connection master; drop table t1,t2,t3; +sync_slave_with_master; + +# +# BUG#41986 Replication slave does not pick up proper AUTO_INCREMENT value for Innodb tables +# +connection master; +set auto_increment_increment=1; +set auto_increment_offset=1; +CREATE TABLE t1 (id MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=innodb; +INSERT INTO t1 VALUES (NULL), (NULL), (NULL); +show create table t1; + +sync_slave_with_master; +show create table t1; + +connection master; +drop table t1; # End cleanup sync_slave_with_master; diff --git a/mysql-test/suite/rpl/r/rpl_auto_increment.result b/mysql-test/suite/rpl/r/rpl_auto_increment.result index 083f3a4e901..2a4c3a09361 100644 --- a/mysql-test/suite/rpl/r/rpl_auto_increment.result +++ b/mysql-test/suite/rpl/r/rpl_auto_increment.result @@ -227,3 +227,20 @@ select * from t3 order by a; a 127 drop table t1,t2,t3; +set auto_increment_increment=1; +set auto_increment_offset=1; +CREATE TABLE t1 (id MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=innodb; +INSERT INTO t1 VALUES (NULL), (NULL), (NULL); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` mediumint(9) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` mediumint(9) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 +drop table t1; diff --git a/sql/log_event.cc b/sql/log_event.cc index dfaf8e3c931..cf338d8fd80 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -8091,6 +8091,9 @@ Write_rows_log_event::do_before_row_operations(const Slave_reporting_capability analyze if explicit data is provided for slave's TIMESTAMP columns). */ m_table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET; + + /* Honor next number column if present */ + m_table->next_number_field= m_table->found_next_number_field; return error; } @@ -8099,6 +8102,7 @@ Write_rows_log_event::do_after_row_operations(const Slave_reporting_capability * int error) { int local_error= 0; + m_table->next_number_field=0; if (bit_is_set(slave_exec_mode, SLAVE_EXEC_MODE_IDEMPOTENT) == 1 || m_table->s->db_type()->db_type == DB_TYPE_NDBCLUSTER) { From 347762946e84c24dba28a4f8302159c2e35d59ec Mon Sep 17 00:00:00 2001 From: Ramil Kalimullin Date: Wed, 14 Jan 2009 18:50:51 +0400 Subject: [PATCH 134/137] Fix for bug#33094: Error in upgrading from 5.0 to 5.1 when table contains triggers and #41385: Crash when attempting to repair a #mysql50# upgraded table with triggers. Problem: 1. trigger code didn't assume a table name may have a "#mysql50#" prefix, that may lead to a failing ASSERT(). 2. "ALTER DATABASE ... UPGRADE DATA DIRECTORY NAME" failed for databases with "#mysql50#" prefix if any trigger. 3. mysqlcheck --fix-table-name didn't use UTF8 as a default character set that resulted in (parsing) errors for tables with non-latin symbols in their names and definitions of triggers. Fix: 1. properly handle table/database names with "#mysql50#" prefix. 2. handle --default-character-set mysqlcheck option; if mysqlcheck is launched with --fix-table-name or --fix-db-name set default character set to UTF8 if no --default-character-set option given. Note: if given --fix-table-name or --fix-db-name option, without --default-character-set mysqlcheck option default character set is UTF8. --- client/mysqlcheck.c | 27 +++++++---- mysql-test/r/mysqlcheck.result | 55 +++++++++++++++++++++ mysql-test/t/mysqlcheck.test | 73 ++++++++++++++++++++++++++++ sql/mysql_priv.h | 1 + sql/sql_table.cc | 31 ++++++++++-- sql/sql_trigger.cc | 88 +++++++++++++++++++++++++--------- sql/sql_trigger.h | 6 ++- 7 files changed, 241 insertions(+), 40 deletions(-) diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 17ebca497e4..86e1b3352b4 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -40,15 +40,13 @@ static uint verbose = 0, opt_mysql_port=0; static int my_end_arg; static char * opt_mysql_unix_port = 0; static char *opt_password = 0, *current_user = 0, - *default_charset = (char *)MYSQL_DEFAULT_CHARSET_NAME, - *current_host = 0; + *default_charset= 0, *current_host= 0; static int first_error = 0; DYNAMIC_ARRAY tables4repair; #ifdef HAVE_SMEM static char *shared_memory_base_name=0; #endif static uint opt_protocol=0; -static CHARSET_INFO *charset_info= &my_charset_latin1; enum operations { DO_CHECK, DO_REPAIR, DO_ANALYZE, DO_OPTIMIZE, DO_UPGRADE }; @@ -282,12 +280,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; case OPT_FIX_DB_NAMES: what_to_do= DO_UPGRADE; - default_charset= (char*) "utf8"; opt_databases= 1; break; case OPT_FIX_TABLE_NAMES: what_to_do= DO_UPGRADE; - default_charset= (char*) "utf8"; break; case 'p': if (argument) @@ -367,11 +363,20 @@ static int get_options(int *argc, char ***argv) what_to_do = DO_CHECK; } - /* TODO: This variable is not yet used */ - if (strcmp(default_charset, charset_info->csname) && - !(charset_info= get_charset_by_csname(default_charset, - MY_CS_PRIMARY, MYF(MY_WME)))) - exit(1); + /* + If there's no --default-character-set option given with + --fix-table-name or --fix-db-name set the default character set to "utf8". + */ + if (!default_charset && (opt_fix_db_names || opt_fix_table_names)) + { + default_charset= (char*) "utf8"; + } + if (default_charset && !get_charset_by_csname(default_charset, MY_CS_PRIMARY, + MYF(MY_WME))) + { + printf("Unsupported character set: %s\n", default_charset); + return 1; + } if (*argc > 0 && opt_alldbs) { printf("You should give only options, no arguments at all, with option\n"); @@ -779,6 +784,8 @@ static int dbConnect(char *host, char *user, char *passwd) if (shared_memory_base_name) mysql_options(&mysql_connection,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name); #endif + if (default_charset) + mysql_options(&mysql_connection, MYSQL_SET_CHARSET_NAME, default_charset); if (!(sock = mysql_real_connect(&mysql_connection, host, user, passwd, NULL, opt_mysql_port, opt_mysql_unix_port, 0))) { diff --git a/mysql-test/r/mysqlcheck.result b/mysql-test/r/mysqlcheck.result index e222d66c5b6..313cba51ec9 100644 --- a/mysql-test/r/mysqlcheck.result +++ b/mysql-test/r/mysqlcheck.result @@ -130,3 +130,58 @@ v1 v-1 drop view v1, `v-1`; drop table t1; +SET NAMES utf8; +CREATE TABLE `#mysql50#@` (a INT); +SHOW TABLES; +Tables_in_test +#mysql50#@ +SET NAMES DEFAULT; +mysqlcheck --fix-table-names --databases test +SET NAMES utf8; +SHOW TABLES; +Tables_in_test +@ +DROP TABLE `@`; +CREATE TABLE `я` (a INT); +SET NAMES DEFAULT; +mysqlcheck --default-character-set="latin1" --databases test +test.? +Error : Table 'test.?' doesn't exist +error : Corrupt +mysqlcheck --default-character-set="utf8" --databases test +test.я OK +SET NAMES utf8; +DROP TABLE `я`; +SET NAMES DEFAULT; +CREATE DATABASE `#mysql50#a@b`; +USE `#mysql50#a@b`; +CREATE TABLE `#mysql50#c@d` (a INT); +CREATE TABLE t1 (a INT); +SELECT * FROM INFORMATION_SCHEMA.TRIGGERS +WHERE TRIGGER_SCHEMA="#mysql50#a@b" ORDER BY trigger_name; +TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION +NULL #mysql50#a@b tr1 INSERT NULL #mysql50#a@b #mysql50#c@d 0 NULL SET NEW.a = 10 * NEW.a ROW BEFORE NULL NULL OLD NEW NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci +NULL #mysql50#a@b tr2 INSERT NULL #mysql50#a@b t1 0 NULL SET NEW.a = 100 * NEW.a ROW BEFORE NULL NULL OLD NEW NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci +Warnings: +Warning 1603 Triggers for table `#mysql50#a@b`.`#mysql50#c@d` have no creation context +Warning 1603 Triggers for table `#mysql50#a@b`.`t1` have no creation context +mysqlcheck --fix-db-names --fix-table-names --all-databases +USE `a@b`; +SELECT * FROM INFORMATION_SCHEMA.TRIGGERS +WHERE TRIGGER_SCHEMA="a@b" ORDER BY trigger_name; +TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION +NULL a@b tr1 INSERT NULL a@b c@d 0 NULL SET NEW.a = 10 * NEW.a ROW BEFORE NULL NULL OLD NEW NULL root@localhost utf8 utf8_general_ci latin1_swedish_ci +NULL a@b tr2 INSERT NULL a@b t1 0 NULL SET NEW.a = 100 * NEW.a ROW BEFORE NULL NULL OLD NEW NULL root@localhost utf8 utf8_general_ci latin1_swedish_ci +INSERT INTO `c@d` VALUES (2), (1); +SELECT * FROM `c@d`; +a +20 +10 +INSERT INTO t1 VALUES (3), (5); +SELECT * FROM t1; +a +300 +500 +DROP DATABASE `a@b`; +USE test; +End of 5.1 tests diff --git a/mysql-test/t/mysqlcheck.test b/mysql-test/t/mysqlcheck.test index 0e675731fd5..b085cc5866a 100644 --- a/mysql-test/t/mysqlcheck.test +++ b/mysql-test/t/mysqlcheck.test @@ -112,3 +112,76 @@ show tables; show tables; drop view v1, `v-1`; drop table t1; + +# +# Bug #33094: Error in upgrading from 5.0 to 5.1 when table contains triggers +# Bug #41385: Crash when attempting to repair a #mysql50# upgraded table with +# triggers +# +SET NAMES utf8; +CREATE TABLE `#mysql50#@` (a INT); +SHOW TABLES; +SET NAMES DEFAULT; +--echo mysqlcheck --fix-table-names --databases test +--exec $MYSQL_CHECK --fix-table-names --databases test +SET NAMES utf8; +SHOW TABLES; +DROP TABLE `@`; + +CREATE TABLE `я` (a INT); +SET NAMES DEFAULT; +--echo mysqlcheck --default-character-set="latin1" --databases test +--exec $MYSQL_CHECK --default-character-set="latin1" --databases test +--echo mysqlcheck --default-character-set="utf8" --databases test +--exec $MYSQL_CHECK --default-character-set="utf8" --databases test +SET NAMES utf8; +DROP TABLE `я`; +SET NAMES DEFAULT; + +CREATE DATABASE `#mysql50#a@b`; +USE `#mysql50#a@b`; +CREATE TABLE `#mysql50#c@d` (a INT); +CREATE TABLE t1 (a INT); + +# Create 5.0 like triggers +--write_file $MYSQLTEST_VARDIR/master-data/a@b/c@d.TRG +TYPE=TRIGGERS +triggers='CREATE DEFINER=`root`@`localhost` TRIGGER tr1 BEFORE INSERT ON `c@d` FOR EACH ROW SET NEW.a = 10 * NEW.a' +sql_modes=0 +definers='root@localhost' +EOF +--write_file $MYSQLTEST_VARDIR/master-data/a@b/tr1.TRN +TYPE=TRIGGERNAME +trigger_table=c@d +EOF +--write_file $MYSQLTEST_VARDIR/master-data/a@b/t1.TRG +TYPE=TRIGGERS +triggers='CREATE DEFINER=`root`@`localhost` TRIGGER tr2 BEFORE INSERT ON `a@b`.t1 FOR EACH ROW SET NEW.a = 100 * NEW.a' +sql_modes=0 +definers='root@localhost' +EOF +--write_file $MYSQLTEST_VARDIR/master-data/a@b/tr2.TRN +TYPE=TRIGGERNAME +trigger_table=t1 +EOF + +SELECT * FROM INFORMATION_SCHEMA.TRIGGERS + WHERE TRIGGER_SCHEMA="#mysql50#a@b" ORDER BY trigger_name; + +--echo mysqlcheck --fix-db-names --fix-table-names --all-databases +--exec $MYSQL_CHECK --fix-db-names --fix-table-names --all-databases + +USE `a@b`; +SELECT * FROM INFORMATION_SCHEMA.TRIGGERS + WHERE TRIGGER_SCHEMA="a@b" ORDER BY trigger_name; + +INSERT INTO `c@d` VALUES (2), (1); +SELECT * FROM `c@d`; +INSERT INTO t1 VALUES (3), (5); +SELECT * FROM t1; + +DROP DATABASE `a@b`; + +USE test; + +--echo End of 5.1 tests diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index fb09ef810d9..c32ebc6d39d 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -2230,6 +2230,7 @@ uint strconvert(CHARSET_INFO *from_cs, const char *from, CHARSET_INFO *to_cs, char *to, uint to_length, uint *errors); uint filename_to_tablename(const char *from, char *to, uint to_length); uint tablename_to_filename(const char *from, char *to, uint to_length); +uint check_n_cut_mysql50_prefix(const char *from, char *to, uint to_length); #endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */ #ifdef MYSQL_SERVER uint build_table_filename(char *buff, size_t bufflen, const char *db, diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 224cf1123e2..3ec03be72a5 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -114,6 +114,30 @@ uint filename_to_tablename(const char *from, char *to, uint to_length) } +/** + Check if given string begins with "#mysql50#" prefix, cut it if so. + + @param from string to check and cut + @param to[out] buffer for result string + @param to_length its size + + @retval + 0 no prefix found + @retval + non-0 result string length +*/ + +uint check_n_cut_mysql50_prefix(const char *from, char *to, uint to_length) +{ + if (from[0] == '#' && + !strncmp(from, MYSQL50_TABLE_NAME_PREFIX, + MYSQL50_TABLE_NAME_PREFIX_LENGTH)) + return (uint) (strmake(to, from + MYSQL50_TABLE_NAME_PREFIX_LENGTH, + to_length - 1) - to); + return 0; +} + + /* Translate a table name to a file name (WL #1324). @@ -133,11 +157,8 @@ uint tablename_to_filename(const char *from, char *to, uint to_length) DBUG_ENTER("tablename_to_filename"); DBUG_PRINT("enter", ("from '%s'", from)); - if (from[0] == '#' && !strncmp(from, MYSQL50_TABLE_NAME_PREFIX, - MYSQL50_TABLE_NAME_PREFIX_LENGTH)) - DBUG_RETURN((uint) (strmake(to, from+MYSQL50_TABLE_NAME_PREFIX_LENGTH, - to_length-1) - - (from + MYSQL50_TABLE_NAME_PREFIX_LENGTH))); + if ((length= check_n_cut_mysql50_prefix(from, to, to_length))) + DBUG_RETURN(length); length= strconvert(system_charset_info, from, &my_charset_filename, to, to_length, &errors); if (check_if_legal_tablename(to) && diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 5c8b1d96646..108d5095691 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -1368,15 +1368,27 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db, if (triggers->on_table_names_list.push_back(on_table_name, &table->mem_root)) goto err_with_lex_cleanup; - +#ifndef DBUG_OFF /* Let us check that we correctly update trigger definitions when we rename tables with triggers. + + In special cases like "RENAME TABLE `#mysql50#somename` TO `somename`" + or "ALTER DATABASE `#mysql50#somename` UPGRADE DATA DIRECTORY NAME" + we might be given table or database name with "#mysql50#" prefix (and + trigger's definiton contains un-prefixed version of the same name). + To remove this prefix we use check_n_cut_mysql50_prefix(). */ - DBUG_ASSERT(!my_strcasecmp(table_alias_charset, lex.query_tables->db, db) && - !my_strcasecmp(table_alias_charset, lex.query_tables->table_name, - table_name)); + char fname[NAME_LEN + 1]; + DBUG_ASSERT((!my_strcasecmp(table_alias_charset, lex.query_tables->db, db) || + (check_n_cut_mysql50_prefix(db, fname, sizeof(fname)) && + !my_strcasecmp(table_alias_charset, lex.query_tables->db, fname))) && + (!my_strcasecmp(table_alias_charset, lex.query_tables->table_name, + table_name) || + (check_n_cut_mysql50_prefix(table_name, fname, sizeof(fname)) && + !my_strcasecmp(table_alias_charset, lex.query_tables->table_name, fname)))); +#endif if (names_only) { lex_end(&lex); @@ -1692,7 +1704,8 @@ end: (change name of table in triggers' definitions). @param thd Thread context - @param db_name Database of subject table + @param old_db_name Old database of subject table + @param new_db_name New database of subject table @param old_table_name Old subject table's name @param new_table_name New subject table's name @@ -1704,7 +1717,8 @@ end: bool Table_triggers_list::change_table_name_in_triggers(THD *thd, - const char *db_name, + const char *old_db_name, + const char *new_db_name, LEX_STRING *old_table_name, LEX_STRING *new_table_name) { @@ -1757,11 +1771,11 @@ Table_triggers_list::change_table_name_in_triggers(THD *thd, if (thd->is_fatal_error) return TRUE; /* OOM */ - if (save_trigger_file(this, db_name, new_table_name->str)) + if (save_trigger_file(this, new_db_name, new_table_name->str)) return TRUE; - if (rm_trigger_file(path_buff, db_name, old_table_name->str)) + if (rm_trigger_file(path_buff, old_db_name, old_table_name->str)) { - (void) rm_trigger_file(path_buff, db_name, new_table_name->str); + (void) rm_trigger_file(path_buff, new_db_name, new_table_name->str); return TRUE; } return FALSE; @@ -1772,7 +1786,8 @@ Table_triggers_list::change_table_name_in_triggers(THD *thd, Iterate though Table_triggers_list::names_list list and update .TRN files after renaming triggers' subject table. - @param db_name Database of subject table + @param old_db_name Old database of subject table + @param new_db_name New database of subject table @param new_table_name New subject table's name @param stopper Pointer to Table_triggers_list::names_list at which we should stop updating. @@ -1785,7 +1800,8 @@ Table_triggers_list::change_table_name_in_triggers(THD *thd, */ LEX_STRING* -Table_triggers_list::change_table_name_in_trignames(const char *db_name, +Table_triggers_list::change_table_name_in_trignames(const char *old_db_name, + const char *new_db_name, LEX_STRING *new_table_name, LEX_STRING *stopper) { @@ -1798,7 +1814,7 @@ Table_triggers_list::change_table_name_in_trignames(const char *db_name, while ((trigger= it_name++) != stopper) { trigname_file.length= build_table_filename(trigname_buff, FN_REFLEN-1, - db_name, trigger->str, + new_db_name, trigger->str, TRN_EXT, 0); trigname_file.str= trigname_buff; @@ -1807,6 +1823,16 @@ Table_triggers_list::change_table_name_in_trignames(const char *db_name, if (sql_create_definition_file(NULL, &trigname_file, &trigname_file_type, (uchar*)&trigname, trigname_file_parameters)) return trigger; + + /* Remove stale .TRN file in case of database upgrade */ + if (old_db_name) + { + if (rm_trigname_file(trigname_buff, old_db_name, trigger->str)) + { + (void) rm_trigname_file(trigname_buff, new_db_name, trigger->str); + return trigger; + } + } } return 0; @@ -1840,6 +1866,7 @@ bool Table_triggers_list::change_table_name(THD *thd, const char *db, { TABLE table; bool result= 0; + bool upgrading50to51= FALSE; LEX_STRING *err_trigname; DBUG_ENTER("change_table_name"); @@ -1877,14 +1904,27 @@ bool Table_triggers_list::change_table_name(THD *thd, const char *db, moving table with them between two schemas raises too many questions. (E.g. what should happen if in new schema we already have trigger with same name ?). + + In case of "ALTER DATABASE `#mysql50#db1` UPGRADE DATA DIRECTORY NAME" + we will be given table name with "#mysql50#" prefix + To remove this prefix we use check_n_cut_mysql50_prefix(). */ if (my_strcasecmp(table_alias_charset, db, new_db)) { - my_error(ER_TRG_IN_WRONG_SCHEMA, MYF(0)); - result= 1; - goto end; + char dbname[NAME_LEN + 1]; + if (check_n_cut_mysql50_prefix(db, dbname, sizeof(dbname)) && + !my_strcasecmp(table_alias_charset, dbname, new_db)) + { + upgrading50to51= TRUE; + } + else + { + my_error(ER_TRG_IN_WRONG_SCHEMA, MYF(0)); + result= 1; + goto end; + } } - if (table.triggers->change_table_name_in_triggers(thd, db, + if (table.triggers->change_table_name_in_triggers(thd, db, new_db, &old_table_name, &new_table_name)) { @@ -1892,7 +1932,8 @@ bool Table_triggers_list::change_table_name(THD *thd, const char *db, goto end; } if ((err_trigname= table.triggers->change_table_name_in_trignames( - db, &new_table_name, 0))) + upgrading50to51 ? db : NULL, + new_db, &new_table_name, 0))) { /* If we were unable to update one of .TRN files properly we will @@ -1900,16 +1941,17 @@ bool Table_triggers_list::change_table_name(THD *thd, const char *db, We assume that we will be able to undo our changes without errors (we can't do much if there will be an error anyway). */ - (void) table.triggers->change_table_name_in_trignames(db, - &old_table_name, - err_trigname); - (void) table.triggers->change_table_name_in_triggers(thd, db, - &new_table_name, - &old_table_name); + (void) table.triggers->change_table_name_in_trignames( + upgrading50to51 ? new_db : NULL, db, + &old_table_name, err_trigname); + (void) table.triggers->change_table_name_in_triggers( + thd, db, new_db, + &new_table_name, &old_table_name); result= 1; goto end; } } + end: delete table.triggers; free_root(&table.mem_root, MYF(0)); diff --git a/sql/sql_trigger.h b/sql/sql_trigger.h index 1b0edf6bea8..f6754a75284 100644 --- a/sql/sql_trigger.h +++ b/sql/sql_trigger.h @@ -146,11 +146,13 @@ public: private: bool prepare_record1_accessors(TABLE *table); - LEX_STRING* change_table_name_in_trignames(const char *db_name, + LEX_STRING* change_table_name_in_trignames(const char *old_db_name, + const char *new_db_name, LEX_STRING *new_table_name, LEX_STRING *stopper); bool change_table_name_in_triggers(THD *thd, - const char *db_name, + const char *old_db_name, + const char *new_db_name, LEX_STRING *old_table_name, LEX_STRING *new_table_name); }; From 10408c632d68aad24024d7225baf1eaba787f50f Mon Sep 17 00:00:00 2001 From: "timothy.smith@sun.com" <> Date: Wed, 14 Jan 2009 20:16:10 +0100 Subject: [PATCH 135/137] Raise version number after cloning 5.0.76 --- configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 06586d6487e..12c31b33d1b 100644 --- a/configure.in +++ b/configure.in @@ -7,7 +7,7 @@ AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! # remember to also change ndb version below and update version.c in ndb -AM_INIT_AUTOMAKE(mysql, 5.0.76) +AM_INIT_AUTOMAKE(mysql, 5.0.78) AM_CONFIG_HEADER([include/config.h:config.h.in]) PROTOCOL_VERSION=10 @@ -23,7 +23,7 @@ NDB_SHARED_LIB_VERSION=$NDB_SHARED_LIB_MAJOR_VERSION:0:0 # ndb version NDB_VERSION_MAJOR=5 NDB_VERSION_MINOR=0 -NDB_VERSION_BUILD=76 +NDB_VERSION_BUILD=78 NDB_VERSION_STATUS="" # Set all version vars based on $VERSION. How do we do this more elegant ? From 2dba01b2fa6240cf339076e352de922c6efaf934 Mon Sep 17 00:00:00 2001 From: Ramil Kalimullin Date: Thu, 15 Jan 2009 00:54:25 +0400 Subject: [PATCH 136/137] bug#33094: Error in upgrading from 5.0 to 5.1 when table contains triggers Post-fix test failure: fixed mysqlcheck.test on Windows platforms. --- mysql-test/r/mysqlcheck.result | 2 +- mysql-test/t/mysqlcheck.test | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/mysqlcheck.result b/mysql-test/r/mysqlcheck.result index 313cba51ec9..2febfcf7eb4 100644 --- a/mysql-test/r/mysqlcheck.result +++ b/mysql-test/r/mysqlcheck.result @@ -146,7 +146,7 @@ CREATE TABLE `я` (a INT); SET NAMES DEFAULT; mysqlcheck --default-character-set="latin1" --databases test test.? -Error : Table 'test.?' doesn't exist +Error : Table doesn't exist error : Corrupt mysqlcheck --default-character-set="utf8" --databases test test.я OK diff --git a/mysql-test/t/mysqlcheck.test b/mysql-test/t/mysqlcheck.test index b085cc5866a..7ecbc92f8f0 100644 --- a/mysql-test/t/mysqlcheck.test +++ b/mysql-test/t/mysqlcheck.test @@ -131,6 +131,8 @@ DROP TABLE `@`; CREATE TABLE `я` (a INT); SET NAMES DEFAULT; --echo mysqlcheck --default-character-set="latin1" --databases test +# Error returned depends on platform, replace it with "Table doesn't exist" +--replace_result "Can't find file: './test/@003f.frm' (errno: 22)" "Table doesn't exist" "Table 'test.?' doesn't exist" "Table doesn't exist" --exec $MYSQL_CHECK --default-character-set="latin1" --databases test --echo mysqlcheck --default-character-set="utf8" --databases test --exec $MYSQL_CHECK --default-character-set="utf8" --databases test From d535a2b92ea178b9114fd6693eae45d6ddd5d39e Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Thu, 15 Jan 2009 00:14:07 +0100 Subject: [PATCH 137/137] Oops, bumped version too high. Drop it back down from 5.0.78 to 5.0.77. --- configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 12c31b33d1b..ff0e9de9ec2 100644 --- a/configure.in +++ b/configure.in @@ -7,7 +7,7 @@ AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! # remember to also change ndb version below and update version.c in ndb -AM_INIT_AUTOMAKE(mysql, 5.0.78) +AM_INIT_AUTOMAKE(mysql, 5.0.77) AM_CONFIG_HEADER([include/config.h:config.h.in]) PROTOCOL_VERSION=10 @@ -23,7 +23,7 @@ NDB_SHARED_LIB_VERSION=$NDB_SHARED_LIB_MAJOR_VERSION:0:0 # ndb version NDB_VERSION_MAJOR=5 NDB_VERSION_MINOR=0 -NDB_VERSION_BUILD=78 +NDB_VERSION_BUILD=77 NDB_VERSION_STATUS="" # Set all version vars based on $VERSION. How do we do this more elegant ?
Post-Header for Intvar_log_eventBody for Rand_log_event
Name