From 5c12bc88b9de85f54ab15b22fe57fcc722f0c918 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Feb 2005 15:20:38 +0100 Subject: [PATCH 01/16] use EXTRA_DIST instead of noinst_HEADERS --- ndb/test/run-test/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ndb/test/run-test/Makefile.am b/ndb/test/run-test/Makefile.am index 127ef22f37c..6b3ba0bff09 100644 --- a/ndb/test/run-test/Makefile.am +++ b/ndb/test/run-test/Makefile.am @@ -10,7 +10,7 @@ test_DATA=daily-basic-tests.txt daily-devel-tests.txt test_SCRIPTS=atrt-analyze-result.sh atrt-gather-result.sh atrt-setup.sh \ atrt-clear-result.sh make-config.sh make-index.sh make-html-reports.sh -atrt_SOURCES = main.cpp +atrt_SOURCES = main.cpp run-test.hpp INCLUDES_LOC = -I$(top_srcdir)/ndb/test/include LDADD_LOC = $(top_builddir)/ndb/test/src/libNDBT.a \ $(top_builddir)/ndb/src/libndbclient.la \ @@ -21,7 +21,7 @@ LDADD_LOC = $(top_builddir)/ndb/test/src/libNDBT.a \ wrappersdir=$(prefix)/bin wrappers_SCRIPTS=atrt-testBackup atrt-mysql-test-run -noinst_HEADERS = run-test.hpp $(test_DATA) $(test_SCRIPTS) $(wrappers_SCRIPTS) README.ATRT +EXTRA_DIST = $(test_DATA) $(test_SCRIPTS) $(wrappers_SCRIPTS) README.ATRT # Don't update the files from bitkeeper %::SCCS/s.% From cb754b989ae94454ca14cc0ba7bcb107f4a307d2 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Feb 2005 20:31:23 -0800 Subject: [PATCH 02/16] Fix extra blank line in emails sent by post-commit trigger. BitKeeper/triggers/post-commit: Remove extra blank link --- BitKeeper/triggers/post-commit | 1 - 1 file changed, 1 deletion(-) diff --git a/BitKeeper/triggers/post-commit b/BitKeeper/triggers/post-commit index 5dc351024e0..a38b1f5a068 100755 --- a/BitKeeper/triggers/post-commit +++ b/BitKeeper/triggers/post-commit @@ -61,7 +61,6 @@ From: $FROM To: $INTERNALS Subject: bk commit into $VERSION tree ($CHANGESET)$BS $BH - Below is the list of changes that have just been committed into a local $VERSION repository of $USER. When $USER does a push these changes will be propagated to the main repository and, within 24 hours after the From aa3727d7dc294e82b6e9ba81db0b86c56b804e5d Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 11 Feb 2005 10:39:26 -0800 Subject: [PATCH 03/16] select.result: After revision of the fix for bug #7520. table.cc: Revised the fix for bug #7520. Made it compliant with 5.0 code where the bug does not exist. sql/table.cc: Revised the fix for bug #7520. Made it compliant with 5.0 code where the bug does not exist. mysql-test/r/select.result: After revision of the fix for bug #7520. --- mysql-test/r/select.result | 2 +- sql/table.cc | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 4c6ad1c34f0..17897b2f549 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2371,7 +2371,7 @@ INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a; table type possible_keys key key_len ref rows Extra t1 ALL NULL NULL NULL NULL 5 -t2 ref a a 23 t1.a 5 +t2 ALL a NULL NULL NULL 4 EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a; table type possible_keys key key_len ref rows Extra t1 ALL NULL NULL NULL NULL 5 diff --git a/sql/table.cc b/sql/table.cc index 244c7fa94f3..43ac122c7f3 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -143,7 +143,6 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, goto err_not_open; /* purecov: inspected */ bzero((char*) keyinfo,n_length); outparam->key_info=keyinfo; - outparam->max_key_length= outparam->total_key_length= 0; key_part= my_reinterpret_cast(KEY_PART_INFO*) (keyinfo+keys); strpos=disk_buff+6; @@ -199,11 +198,6 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, } key_part->store_length=key_part->length; } - set_if_bigger(outparam->max_key_length,keyinfo->key_length+ - keyinfo->key_parts); - outparam->total_key_length+= keyinfo->key_length; - if (keyinfo->flags & HA_NOSAME) - set_if_bigger(outparam->max_unique_length,keyinfo->key_length); } keynames=(char*) key_part; strpos+= (strmov(keynames, (char *) strpos) - keynames)+1; @@ -486,7 +480,6 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, if (!(field->flags & BINARY_FLAG)) keyinfo->flags|= HA_END_SPACE_KEY; } - set_if_bigger(outparam->max_key_length, keyinfo->key_length); if (i == 0 && key != primary_key) field->flags |= ((keyinfo->flags & HA_NOSAME) && @@ -547,6 +540,12 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, } } keyinfo->usable_key_parts=usable_parts; // Filesort + + set_if_bigger(outparam->max_key_length,keyinfo->key_length+ + keyinfo->key_parts); + outparam->total_key_length+= keyinfo->key_length; + if (keyinfo->flags & HA_NOSAME) + set_if_bigger(outparam->max_unique_length,keyinfo->key_length); } if (primary_key < MAX_KEY && (outparam->keys_in_use & ((key_map) 1 << primary_key))) From 537531f0e8990debfb82bdbaac2f237d46098fb1 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 11 Feb 2005 21:57:37 +0200 Subject: [PATCH 04/16] Fixed mistyping (thnx to Konstantin) sql/sql_cache.cc: Fixed mistyping --- sql/sql_cache.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index f503a63e752..d729a6cc301 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1337,7 +1337,7 @@ ulong Query_cache::init_cache() init(); approx_additional_data_size = (sizeof(Query_cache) + sizeof(gptr)*(def_query_hash_size+ - def_query_hash_size)); + def_table_hash_size)); if (query_cache_size < approx_additional_data_size) goto err; From cf78ff694732aa3e11a8bd82c25df64664fff18a Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 11 Feb 2005 13:44:54 -0800 Subject: [PATCH 05/16] distinct.result: Adjustment of the result file after the revision of the fix for bug #7520. mysql-test/r/distinct.result: Adjustment of the result file after the revision of the fix for bug #7520. --- mysql-test/r/distinct.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result index a0343f13394..d37c1e518fa 100644 --- a/mysql-test/r/distinct.result +++ b/mysql-test/r/distinct.result @@ -190,7 +190,7 @@ insert into t3 select * from t4; explain select distinct t1.a from t1,t3 where t1.a=t3.a; table type possible_keys key key_len ref rows Extra t1 index PRIMARY PRIMARY 4 NULL 4 Using index; Using temporary -t3 ref a a 5 t1.a 10 Using where; Using index; Distinct +t3 ref a a 5 t1.a 12 Using where; Using index; Distinct select distinct t1.a from t1,t3 where t1.a=t3.a; a 1 From bae820dc664a70e2c9cc26a9ded324260a53d671 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 12 Feb 2005 00:05:13 +0100 Subject: [PATCH 06/16] make LOAD INDEX to work --- myisam/mi_preload.c | 8 ++++---- mysql-test/r/preload.result | 28 ++++++++++++++-------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/myisam/mi_preload.c b/myisam/mi_preload.c index 5e03d489efe..317ab4ad7fe 100644 --- a/myisam/mi_preload.c +++ b/myisam/mi_preload.c @@ -71,15 +71,15 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_RELEASE)) goto err; - + do { /* Read the next block of index file into the preload buffer */ if ((my_off_t) length > (key_file_length-pos)) length= (ulong) (key_file_length-pos); - if (my_pread(share->kfile, (byte*) buff, length, pos, MYF(MY_FAE))) + if (my_pread(share->kfile, (byte*) buff, length, pos, MYF(MY_FAE|MY_FNABP))) goto err; - + if (ignore_leaves) { uchar *end= buff+length; @@ -88,7 +88,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) if (mi_test_if_nod(buff)) { if (key_cache_insert(share->key_cache, - share->kfile, pos, DFLT_INIT_HITS, + share->kfile, pos, DFLT_INIT_HITS, (byte*) buff, block_length)) goto err; } diff --git a/mysql-test/r/preload.result b/mysql-test/r/preload.result index f0b99a8d6f1..7237a0da7e0 100644 --- a/mysql-test/r/preload.result +++ b/mysql-test/r/preload.result @@ -74,15 +74,15 @@ Table Op Msg_type Msg_text test.t1 preload_keys status OK show status like "key_read%"; Variable_name Value -Key_read_requests 0 -Key_reads 0 +Key_read_requests 581 +Key_reads 581 select count(*) from t1 where b = 'test1'; count(*) 4181 show status like "key_read%"; Variable_name Value -Key_read_requests 217 -Key_reads 45 +Key_read_requests 798 +Key_reads 581 flush tables; flush status; show status like "key_read%"; @@ -98,15 +98,15 @@ Table Op Msg_type Msg_text test.t1 preload_keys status OK show status like "key_read%"; Variable_name Value -Key_read_requests 0 -Key_reads 0 +Key_read_requests 10 +Key_reads 10 select count(*) from t1 where b = 'test1'; count(*) 4181 show status like "key_read%"; Variable_name Value -Key_read_requests 217 -Key_reads 45 +Key_read_requests 227 +Key_reads 52 flush tables; flush status; show status like "key_read%"; @@ -123,8 +123,8 @@ test.t1 preload_keys status OK test.t2 preload_keys status OK show status like "key_read%"; Variable_name Value -Key_read_requests 0 -Key_reads 0 +Key_read_requests 587 +Key_reads 587 select count(*) from t1 where b = 'test1'; count(*) 4181 @@ -133,8 +133,8 @@ count(*) 2584 show status like "key_read%"; Variable_name Value -Key_read_requests 351 -Key_reads 73 +Key_read_requests 938 +Key_reads 613 flush tables; flush status; show status like "key_read%"; @@ -147,8 +147,8 @@ test.t3 preload_keys error Table 'test.t3' doesn't exist test.t2 preload_keys status OK show status like "key_read%"; Variable_name Value -Key_read_requests 0 -Key_reads 0 +Key_read_requests 355 +Key_reads 355 flush tables; flush status; show status like "key_read%"; From 2d619d7cadf45348614884d4cde7ded316e47412 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 12 Feb 2005 16:27:22 +0400 Subject: [PATCH 07/16] Bug#8235 Connection collation change & table create with default result in crash mysql-test/r/ctype_ucs.result: Test case mysql-test/t/ctype_ucs.test: Test case sql/field.cc: Fixed minus check to be UCS2-compatible strings/ctype-ucs2.c: Missing my_scan_ucs2() was added. --- mysql-test/r/ctype_ucs.result | 14 ++++++++++++++ mysql-test/t/ctype_ucs.test | 21 +++++++++++++++++++++ sql/field.cc | 12 ++++++++++-- strings/ctype-ucs2.c | 25 ++++++++++++++++++++++++- 4 files changed, 69 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index 3f50d9dfa1b..0807cfabf2a 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -613,3 +613,17 @@ ucs2_bin 00610009 ucs2_bin 0061 ucs2_bin 00610020 drop table t1; +SET NAMES latin1; +SET collation_connection='ucs2_swedish_ci'; +CREATE TABLE t1 (Field1 int(10) default '0'); +INSERT INTO t1 VALUES ('-1'); +SELECT * FROM t1; +Field1 +-1 +DROP TABLE t1; +CREATE TABLE t1 (Field1 int(10) unsigned default '0'); +INSERT INTO t1 VALUES ('-1'); +Warnings: +Warning 1265 Data truncated for column 'Field1' at row 1 +DROP TABLE t1; +SET NAMES latin1; diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index 1a0ba82d6ff..38956e12a3b 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -390,3 +390,24 @@ SET collation_connection='ucs2_general_ci'; SET NAMES latin1; SET collation_connection='ucs2_bin'; -- source include/ctype_filesort.inc + +SET NAMES latin1; +# +# Bug#8235 +# +# This bug also helped to find another problem that +# INSERT of a UCS2 string containing a negative number +# into a unsigned int column didn't produce warnings. +# This test covers both problems. +# +SET collation_connection='ucs2_swedish_ci'; +CREATE TABLE t1 (Field1 int(10) default '0'); +# no warnings, negative numbers are allowed +INSERT INTO t1 VALUES ('-1'); +SELECT * FROM t1; +DROP TABLE t1; +CREATE TABLE t1 (Field1 int(10) unsigned default '0'); +# this should generate a "Data truncated" warning +INSERT INTO t1 VALUES ('-1'); +DROP TABLE t1; +SET NAMES latin1; diff --git a/sql/field.cc b/sql/field.cc index e2f75034e52..fa0e202d513 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1777,6 +1777,14 @@ void Field_medium::sql_type(String &res) const ****************************************************************************/ +static bool test_if_minus(CHARSET_INFO *cs, + const char *s, const char *e) +{ + my_wc_t wc; + return cs->cset->mb_wc(cs, &wc, (uchar*) s, (uchar*) e) > 0 && wc == '-'; +} + + int Field_long::store(const char *from,uint len,CHARSET_INFO *cs) { long tmp; @@ -1790,7 +1798,7 @@ int Field_long::store(const char *from,uint len,CHARSET_INFO *cs) if (unsigned_flag) { - if (!len || *from == '-') + if (!len || test_if_minus(cs, from, from + len)) { tmp=0; // Set negative to 0 my_errno=ERANGE; @@ -2086,7 +2094,7 @@ int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs) my_errno=0; if (unsigned_flag) { - if (!len || *from == '-') + if (!len || test_if_minus(cs, from, from + len)) { tmp=0; // Set negative to 0 my_errno= ERANGE; diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index ea11f8816a5..e92704b83d7 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1480,6 +1480,29 @@ my_bool my_like_range_ucs2(CHARSET_INFO *cs, return 0; } + +ulong my_scan_ucs2(CHARSET_INFO *cs __attribute__((unused)), + const char *str, const char *end, int sequence_type) +{ + const char *str0= str; + end--; /* for easier loop condition, because of two bytes per character */ + + switch (sequence_type) + { + case MY_SEQ_SPACES: + for ( ; str < end; str+= 2) + { + if (str[0] != '\0' || str[1] != ' ') + break; + } + return str - str0; + default: + return 0; + } +} + + + static MY_COLLATION_HANDLER my_collation_ucs2_general_ci_handler = { NULL, /* init */ @@ -1534,7 +1557,7 @@ MY_CHARSET_HANDLER my_charset_ucs2_handler= my_strntoull_ucs2, my_strntod_ucs2, my_strtoll10_ucs2, - my_scan_8bit + my_scan_ucs2 }; From 4810f300d29a81db4c96d6cfc0185927eddb2568 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 12 Feb 2005 20:09:40 +0400 Subject: [PATCH 08/16] Fix for bug #8477 (Embedded query_cache test crashes) libmysqld/emb_qcache.cc: Querycahce data transition fixed --- libmysqld/emb_qcache.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/libmysqld/emb_qcache.cc b/libmysqld/emb_qcache.cc index 7d83023abd5..2d3d82b7952 100644 --- a/libmysqld/emb_qcache.cc +++ b/libmysqld/emb_qcache.cc @@ -71,9 +71,11 @@ void Querycache_stream::store_int(uint i) cur_data+= 4; return; } - memcpy(cur_data, &i, rest_len); + char buf[4]; + int4store(buf, i); + memcpy(cur_data, buf, rest_len); use_next_block(); - memcpy(cur_data, ((byte*)&i)+rest_len, 4-rest_len); + memcpy(cur_data, buf+rest_len, 4-rest_len); cur_data+= 4-rest_len; } @@ -186,10 +188,12 @@ uint Querycache_stream::load_int() cur_data+= 4; return result; } - memcpy(&result, cur_data, rest_len); + char buf[4]; + memcpy(buf, cur_data, rest_len); use_next_block(); - memcpy(((byte*)&result)+rest_len, cur_data, 4-rest_len); + memcpy(buf+rest_len, cur_data, 4-rest_len); cur_data+= 4-rest_len; + result= uint4korr(buf); return result; } @@ -270,10 +274,10 @@ int Querycache_stream::load_column(MEM_ROOT *alloc, char** column) return 0; } len--; - if (!(*column= (char *)alloc_root(alloc, len + 4 + 1))) + if (!(*column= (char *)alloc_root(alloc, len + sizeof(uint) + 1))) return 1; - int4store(*column, len); - (*column)+= 4; + *((uint*)*column)= len; + (*column)+= sizeof(uint); load_str_only(*column, len); return 1; } From a8b9f30eb3e5f68a49c6db4476c0ef759ca52157 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 12 Feb 2005 19:17:33 +0100 Subject: [PATCH 09/16] new static archive_inited variable, so that archive_db_end() will do something only if archive_db_init() was run before (protection against destroying uninited mutex in the case where mysqld fails early at startup (before archive_db_init() was called) and then calls archive_db_end() to clean up). sql/examples/ha_archive.cc: new static archive_inited variable, so that archive_db_end() will do something only if archive_db_init() was run before. --- sql/examples/ha_archive.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sql/examples/ha_archive.cc b/sql/examples/ha_archive.cc index 491056d0e59..bc4af0c7dc7 100644 --- a/sql/examples/ha_archive.cc +++ b/sql/examples/ha_archive.cc @@ -114,6 +114,8 @@ data - The data is stored in a "row +blobs" format. */ +/* If the archive storage engine has been inited */ +static bool archive_inited= 0; /* Variables for archive share methods */ pthread_mutex_t archive_mutex; static HASH archive_open_tables; @@ -157,6 +159,7 @@ static byte* archive_get_key(ARCHIVE_SHARE *share,uint *length, bool archive_db_init() { + archive_inited= 1; VOID(pthread_mutex_init(&archive_mutex, MY_MUTEX_INIT_FAST)); return (hash_init(&archive_open_tables, system_charset_info, 32, 0, 0, (hash_get_key) archive_get_key, 0, 0)); @@ -176,8 +179,12 @@ bool archive_db_init() bool archive_db_end() { - hash_free(&archive_open_tables); - VOID(pthread_mutex_destroy(&archive_mutex)); + if (archive_inited) + { + hash_free(&archive_open_tables); + VOID(pthread_mutex_destroy(&archive_mutex)); + } + archive_inited= 0; return FALSE; } From 4c21a10f27c6a15690b5640352d23f1c111ac729 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 13 Feb 2005 21:00:07 +0200 Subject: [PATCH 10/16] row0mysql.c: Backport the column prefix memory corruption fix from 5.0 innobase/row/row0mysql.c: Backport the column prefix memory corruption fix from 5.0 --- innobase/row/row0mysql.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index 1ab7bb1deb0..a915200161f 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -399,7 +399,7 @@ row_create_prebuilt( prebuilt->sel_graph = NULL; prebuilt->search_tuple = dtuple_create(heap, - dict_table_get_n_cols(table)); + 2 * dict_table_get_n_cols(table)); clust_index = dict_table_get_first_index(table); From a8d2152f973dc56897725356cd0f88310a7689b8 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 13 Feb 2005 22:35:52 +0000 Subject: [PATCH 11/16] Bug#2435 Alter handling for UNION syntax Tests for UNION and parentheses mysql-test/r/union.result: Bug#2435 Tests for UNION and parentheses mysql-test/t/union.test: Bug#2435 Tests for UNION and parentheses sql/sql_yacc.yy: Bug#2435 Amend handling of UNION with parentheses. --- mysql-test/r/union.result | 22 ++++++++++++++++++++++ mysql-test/t/union.test | 12 ++++++++++++ sql/sql_yacc.yy | 35 ++++++++++++++++++++++++++++------- 3 files changed, 62 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 115ef6a47f9..f58f0f5b0ac 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -1173,3 +1173,25 @@ show columns from t4; Field Type Null Key Default Extra sdate date YES NULL drop table t1, t2, t3, t4; +create table t1 (a int not null, b char (10) not null); +insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c'); +select * from ((select * from t1 limit 1)) a; +a b +1 a +select * from ((select * from t1 limit 1) union (select * from t1 limit 1)) a; +a b +1 a +select * from ((select * from t1 limit 1) union (select * from t1 limit 1) union (select * from t1 limit 1)) a; +a b +1 a +select * from ((((select * from t1))) union (select * from t1) union (select * from t1)) a; +a b +1 a +2 b +3 c +select * from ((select * from t1) union (((select * from t1))) union (select * from t1)) a; +a b +1 a +2 b +3 c +drop table t1; diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 90b2197603b..82f26f63254 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -699,3 +699,15 @@ union order by sdate; show columns from t4; drop table t1, t2, t3, t4; + +# +# Bug #2435 UNION with parentheses not supported +# +create table t1 (a int not null, b char (10) not null); +insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c'); +select * from ((select * from t1 limit 1)) a; +select * from ((select * from t1 limit 1) union (select * from t1 limit 1)) a; +select * from ((select * from t1 limit 1) union (select * from t1 limit 1) union (select * from t1 limit 1)) a; +select * from ((((select * from t1))) union (select * from t1) union (select * from t1)) a; +select * from ((select * from t1) union (((select * from t1))) union (select * from t1)) a; +drop table t1; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index e70efe14557..988323811ac 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -2389,7 +2389,10 @@ select: select_init: SELECT_SYM select_init2 | - '(' SELECT_SYM select_part2 ')' + '(' select_paren ')' union_opt; + +select_paren: + SELECT_SYM select_part2 { LEX *lex= Lex; SELECT_LEX * sel= lex->current_select; @@ -2408,7 +2411,8 @@ select_init: if (sel->master_unit()->fake_select_lex) sel->master_unit()->global_parameters= sel->master_unit()->fake_select_lex; - } union_opt; + } + | '(' select_paren ')'; select_init2: select_part2 @@ -3404,8 +3408,7 @@ when_list2: }; join_table_list: - '(' join_table_list ')' { $$=$2; } - | join_table { $$=$1; } + join_table { $$=$1; } | join_table_list ',' join_table_list { $$=$3; } | join_table_list normal_join join_table_list { $$=$3; } | join_table_list STRAIGHT_JOIN join_table_list @@ -3482,7 +3485,7 @@ join_table: } | '{' ident join_table LEFT OUTER JOIN_SYM join_table ON expr '}' { add_join_on($7,$9); $7->outer_join|=JOIN_TYPE_LEFT; $$=$7; } - | '(' SELECT_SYM select_derived ')' opt_table_alias + | '(' select_derived union_opt ')' opt_table_alias { LEX *lex=Lex; SELECT_LEX_UNIT *unit= lex->current_select->master_unit(); @@ -3493,9 +3496,27 @@ join_table: (List *)0))) YYABORT; - }; + } + | '(' join_table_list ')' { $$=$2; }; select_derived: + SELECT_SYM select_derived2 + | '(' select_derived ')' + { + LEX *lex= Lex; + SELECT_LEX * sel= lex->current_select; + if (sel->set_braces(1)) + { + yyerror(ER(ER_SYNTAX_ERROR)); + YYABORT; + } + /* select in braces, can't contain global parameters */ + if (sel->master_unit()->fake_select_lex) + sel->master_unit()->global_parameters= + sel->master_unit()->fake_select_lex; + }; + +select_derived2: { LEX *lex= Lex; lex->derived_tables= 1; @@ -3517,7 +3538,7 @@ select_derived: { Select->parsing_place= NO_MATTER; } - opt_select_from union_opt + opt_select_from ; opt_outer: From e2b6480162743d7eaa62bf7b64e92778191b25d9 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 Feb 2005 11:14:04 +0100 Subject: [PATCH 12/16] remove passwordless remote accounts from windows distro --- scripts/mysql_create_system_tables.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/mysql_create_system_tables.sh b/scripts/mysql_create_system_tables.sh index f524b322388..83fdc0639ce 100644 --- a/scripts/mysql_create_system_tables.sh +++ b/scripts/mysql_create_system_tables.sh @@ -163,9 +163,7 @@ then INSERT INTO user (host,user) values ('localhost','');" else i_u="$i_u - INSERT INTO user VALUES ('%','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0); - INSERT INTO user VALUES ('localhost','','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0); - INSERT INTO user VALUES ('%','','','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','','','','',0,0,0);" + INSERT INTO user VALUES ('localhost','','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);" fi fi fi From de3f93c6ff8e59490db22d1b0781601bf30a4039 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 Feb 2005 18:54:12 +0400 Subject: [PATCH 13/16] Bug#8351 Fix for crash when using a double quote in boolean fulltext query. mysql-test/r/fulltext.result: Added a test case for bug #8351. mysql-test/t/fulltext.test: Added a test case for bug #8351. BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 1 + myisam/ft_boolean_search.c | 36 ++++++++++++++---------------------- mysql-test/r/fulltext.result | 7 +++++++ mysql-test/t/fulltext.test | 8 ++++++++ 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 59882283d5d..b88eb69544d 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -203,6 +203,7 @@ serg@sergbook.mysql.com sergefp@mysql.com sinisa@rhols221.adsl.netsonic.fi stewart@mysql.com +svoj@mysql.com tfr@beta.frontier86.ee tfr@indrek.tfr.cafe.ee tfr@sarvik.tfr.cafe.ee diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c index 4253b5ff96f..62c68322595 100644 --- a/myisam/ft_boolean_search.c +++ b/myisam/ft_boolean_search.c @@ -435,32 +435,24 @@ static int _ftb_strstr(const byte *s0, const byte *e0, const byte *s1, const byte *e1, CHARSET_INFO *cs) { - const byte *p0, *p1; - my_bool s_after, e_before; - - s_after=true_word_char(cs, s1[0]); - e_before=true_word_char(cs, e1[-1]); - p0=s0; + const byte *p0= s0; + my_bool s_after= true_word_char(cs, s1[0]); + my_bool e_before= true_word_char(cs, e1[-1]); + uint p0_len; + my_match_t m[2]; while (p0 < e0) { - while (p0 < e0 && cs->to_upper[(uint) (uchar) *p0++] != - cs->to_upper[(uint) (uchar) *s1]) - /* no-op */; - if (p0 >= e0) - return 0; - - if (s_after && p0-1 > s0 && true_word_char(cs, p0[-2])) - continue; - - p1=s1+1; - while (p0 < e0 && p1 < e1 && cs->to_upper[(uint) (uchar) *p0] == - cs->to_upper[(uint) (uchar) *p1]) - p0++, p1++; - if (p1 == e1 && (!e_before || p0 == e0 || !true_word_char(cs, p0[0]))) - return 1; + if (cs->coll->instr(cs, p0, e0 - p0, s1, e1 - s1, m, 2) != 2) + return(0); + if ((!s_after || p0 + m[1].beg == s0 || !true_word_char(cs, p0[m[1].beg-1])) && + (!e_before || p0 + m[1].end == e0 || !true_word_char(cs, p0[m[1].end]))) + return(1); + p0+= m[1].beg; + p0+= (p0_len= my_mbcharlen(cs, *(uchar *)p0)) ? p0_len : 1; } - return 0; + + return(0); } diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index a042248ba34..67644a68598 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -408,3 +408,10 @@ insert t1 values (1, "aaaa"), (2, "bbbb"); insert t2 values (10, "aaaa"), (2, "cccc"); replace t1 select * from t2; drop table t1, t2; +CREATE TABLE t1 (t VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_unicode_ci, FULLTEXT (t)); +SET NAMES latin1; +INSERT INTO t1 VALUES('Mit freundlichem Grüß aus Osnabrück'); +SELECT COUNT(*) FROM t1 WHERE MATCH(t) AGAINST ('"osnabrück"' IN BOOLEAN MODE); +COUNT(*) +1 +DROP TABLE t1; diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 62dcecaff68..50d01da080f 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -322,3 +322,11 @@ insert t2 values (10, "aaaa"), (2, "cccc"); replace t1 select * from t2; drop table t1, t2; +# +# bug#8351 +# +CREATE TABLE t1 (t VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_unicode_ci, FULLTEXT (t)); +SET NAMES latin1; +INSERT INTO t1 VALUES('Mit freundlichem Grüß aus Osnabrück'); +SELECT COUNT(*) FROM t1 WHERE MATCH(t) AGAINST ('"osnabrück"' IN BOOLEAN MODE); +DROP TABLE t1; From de109e463bb699305bdcf116280c412dc7da2566 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Feb 2005 03:55:44 +0300 Subject: [PATCH 14/16] Fix signatures of placement operator delete in places where placement delete is declared. As we don't use exceptions placement delete is never called and the fix only affects numerous warnings when compiling with MS Visual C++. For more info see http://www.gotw.ca/gotw/010.htm. sql/item.h: Fix the signature of placement operator delete for class Item. sql/sql_class.cc: Add placement delete operator to suppress a warning under Windows. sql/sql_lex.h: Fix the signature of placement operator delete for class LEX sql/sql_list.h: Fix the signature of placement operator delete for class Sql_alloc sql/sql_string.h: Fix the signature of placement operator delete for class Sql_string --- sql/item.h | 2 +- sql/sql_class.cc | 2 ++ sql/sql_lex.h | 2 +- sql/sql_list.h | 4 ++-- sql/sql_string.h | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sql/item.h b/sql/item.h index a8b892292d3..db5010799fa 100644 --- a/sql/item.h +++ b/sql/item.h @@ -119,7 +119,7 @@ public: static void *operator new(size_t size, MEM_ROOT *mem_root) { return (void*) alloc_root(mem_root, (uint) size); } static void operator delete(void *ptr,size_t size) {} - static void operator delete(void *ptr,size_t size, MEM_ROOT *mem_root) {} + static void operator delete(void *ptr, MEM_ROOT *mem_root) {} enum Type {FIELD_ITEM, FUNC_ITEM, SUM_FUNC_ITEM, STRING_ITEM, INT_ITEM, REAL_ITEM, NULL_ITEM, VARBIN_ITEM, diff --git a/sql/sql_class.cc b/sql/sql_class.cc index e11d8369f57..918e70fbc84 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -707,6 +707,8 @@ struct Item_change_record: public ilink Item *old_value; /* Placement new was hidden by `new' in ilink (TODO: check): */ static void *operator new(size_t size, void *mem) { return mem; } + static void operator delete(void *ptr, size_t size) {} + static void operator delete(void *ptr, void *mem) { /* never called */ } }; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 7cb71607edf..3e2f6a3f2b5 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -241,7 +241,7 @@ public: static void *operator new(size_t size, MEM_ROOT *mem_root) { return (void*) alloc_root(mem_root, (uint) size); } static void operator delete(void *ptr,size_t size) {} - static void operator delete(void *ptr,size_t size, MEM_ROOT *mem_root) {} + static void operator delete(void *ptr, MEM_ROOT *mem_root) {} st_select_lex_node(): linkage(UNSPECIFIED_TYPE) {} virtual ~st_select_lex_node() {} inline st_select_lex_node* get_master() { return master; } diff --git a/sql/sql_list.h b/sql/sql_list.h index a607b31d60c..be3e29b0c62 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -41,8 +41,8 @@ public: static void *operator new(size_t size, MEM_ROOT *mem_root) { return (void*) alloc_root(mem_root, (uint) size); } static void operator delete(void *ptr, size_t size) { TRASH(ptr, size); } - static void operator delete(void *ptr, size_t size, MEM_ROOT *mem_root) - { TRASH(ptr, size); } + static void operator delete(void *ptr, MEM_ROOT *mem_root) + { /* never called */ } static void operator delete[](void *ptr, size_t size) { TRASH(ptr, size); } #ifdef HAVE_purify bool dummy; diff --git a/sql/sql_string.h b/sql/sql_string.h index 9136dddbbf2..3ad4689cf36 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -73,7 +73,7 @@ public: { return (void*) alloc_root(mem_root, (uint) size); } static void operator delete(void *ptr_arg,size_t size) {} - static void operator delete(void *ptr_arg,size_t size, MEM_ROOT *mem_root) + static void operator delete(void *ptr_arg, MEM_ROOT *mem_root) {} ~String() { free(); } From 1d633f645a7c2c8186a5b605dc1bcaf95787cc7a Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Feb 2005 15:01:20 +0400 Subject: [PATCH 15/16] A fix. "(int) var" type cast doesn't work correctly for uint32 var on some 64-bit platforms (e.g. IRIX, non-debug build). --- sql/item_strfunc.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index a92c4e94c87..bbbcadbb071 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1645,7 +1645,8 @@ String *Item_func_format::val_str(String *str) { DBUG_ASSERT(fixed == 1); double nr =args[0]->val(); - uint32 diff,length,str_length; + int diff; + uint32 length, str_length; uint dec; if ((null_value=args[0]->null_value)) return 0; /* purecov: inspected */ @@ -1670,9 +1671,12 @@ String *Item_func_format::val_str(String *str) pos[0]= pos[-(int) diff]; while (diff) { - pos[0]=pos[-(int) diff]; pos--; - pos[0]=pos[-(int) diff]; pos--; - pos[0]=pos[-(int) diff]; pos--; + *pos= *(pos - diff); + pos--; + *pos= *(pos - diff); + pos--; + *pos= *(pos - diff); + pos--; pos[0]=','; pos--; diff--; From 358cfd6c4220d3d1d1f596f6313fcba1819ff1a6 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Feb 2005 14:42:13 +0200 Subject: [PATCH 16/16] Better bug fix for #5569: "Incorrect "Access Denied" error with SAME login DIFFERENT host" This fixes also the reverse lookup bug introduced by the previous patch mysql-test/t/group_by.test: Remove empty line vio/viosocket.c: Added function comment --- mysql-test/t/group_by.test | 1 - sql/sql_parse.cc | 23 +++++++++++++---------- vio/viosocket.c | 12 ++++++++++++ 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index 5af78b924f8..2e5446c2d92 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -455,4 +455,3 @@ select min(a) is null from t1; select min(a) is null or null from t1; select 1 and min(a) is null from t1; drop table t1; - diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index cd0abafc0c9..613484ebf50 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -504,8 +504,6 @@ check_connections(THD *thd) DBUG_PRINT("info",("New connection received on %s", vio_description(net->vio))); - vio_in_addr(net->vio,&thd->remote.sin_addr); - if (!thd->host) // If TCP/IP connection { char ip[30]; @@ -515,6 +513,7 @@ check_connections(THD *thd) if (!(thd->ip = my_strdup(ip,MYF(0)))) return (ER_OUT_OF_RESOURCES); thd->host_or_ip=thd->ip; + vio_in_addr(net->vio, &thd->remote.sin_addr); #if !defined(HAVE_SYS_UN_H) || defined(HAVE_mit_thread) /* Fast local hostname resolve for Win32 */ if (!strcmp(thd->ip,"127.0.0.1")) @@ -524,17 +523,19 @@ check_connections(THD *thd) } else #endif - if (!(specialflag & SPECIAL_NO_RESOLVE)) { - thd->host=ip_to_hostname(&thd->remote.sin_addr,&connect_errors); - /* Cut very long hostnames to avoid possible overflows */ - if (thd->host) + if (!(specialflag & SPECIAL_NO_RESOLVE)) { - thd->host[min(strlen(thd->host), HOSTNAME_LENGTH)]= 0; - thd->host_or_ip= thd->host; + thd->host=ip_to_hostname(&thd->remote.sin_addr,&connect_errors); + /* Cut very long hostnames to avoid possible overflows */ + if (thd->host) + { + thd->host[min(strlen(thd->host), HOSTNAME_LENGTH)]= 0; + thd->host_or_ip= thd->host; + } + if (connect_errors > max_connect_errors) + return(ER_HOST_IS_BLOCKED); } - if (connect_errors > max_connect_errors) - return(ER_HOST_IS_BLOCKED); } DBUG_PRINT("info",("Host: %s ip: %s", thd->host ? thd->host : "unknown host", @@ -547,6 +548,8 @@ check_connections(THD *thd) DBUG_PRINT("info",("Host: %s",thd->host)); thd->host_or_ip= thd->host; thd->ip= 0; + /* Reset sin_addr */ + bzero((char*) &thd->remote, sizeof(thd->remote)); } vio_keepalive(net->vio, TRUE); diff --git a/vio/viosocket.c b/vio/viosocket.c index 1b6f46c57cf..f45c9dd98c4 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -291,6 +291,18 @@ my_bool vio_peer_addr(Vio * vio, char *buf, uint16 *port) } +/* + Get in_addr for a TCP/IP connection + + SYNOPSIS + vio_in_addr() + vio vio handle + in put in_addr here + + NOTES + one must call vio_peer_addr() before calling this one +*/ + void vio_in_addr(Vio *vio, struct in_addr *in) { DBUG_ENTER("vio_in_addr");