diff options
author | unknown <tomas@poseidon.ndb.mysql.com> | 2005-02-14 16:19:57 +0100 |
---|---|---|
committer | unknown <tomas@poseidon.ndb.mysql.com> | 2005-02-14 16:19:57 +0100 |
commit | 4b4c887a020fb35b4f7fb253ebc5f6e7a86756ea (patch) | |
tree | 48f4b81c93e9970d68ea09a398911718f88a066d | |
parent | 211e8b035413c912309dc030c874fd1ccd6205b9 (diff) | |
parent | e2b6480162743d7eaa62bf7b64e92778191b25d9 (diff) | |
download | mariadb-git-4b4c887a020fb35b4f7fb253ebc5f6e7a86756ea.tar.gz |
Merge tulin@bk-internal.mysql.com:/home/bk/mysql-4.1
into poseidon.ndb.mysql.com:/home/tomas/mysql-4.1
-rwxr-xr-x | BitKeeper/triggers/post-commit | 20 | ||||
-rwxr-xr-x | Build-tools/Do-compile | 6 | ||||
-rw-r--r-- | VC++Files/tests/mysql_client_test.dsp | 12 | ||||
-rw-r--r-- | extra/replace.c | 26 | ||||
-rw-r--r-- | include/my_pthread.h | 2 | ||||
-rw-r--r-- | innobase/row/row0mysql.c | 2 | ||||
-rw-r--r-- | libmysql/libmysql.c | 22 | ||||
-rw-r--r-- | libmysqld/emb_qcache.cc | 18 | ||||
-rw-r--r-- | myisam/mi_preload.c | 8 | ||||
-rw-r--r-- | mysql-test/r/ctype_ucs.result | 14 | ||||
-rw-r--r-- | mysql-test/r/distinct.result | 2 | ||||
-rw-r--r-- | mysql-test/r/preload.result | 28 | ||||
-rw-r--r-- | mysql-test/r/select.result | 13 | ||||
-rw-r--r-- | mysql-test/r/union.result | 22 | ||||
-rw-r--r-- | mysql-test/t/ctype_ucs.test | 21 | ||||
-rw-r--r-- | mysql-test/t/select.test | 15 | ||||
-rw-r--r-- | mysql-test/t/union.test | 12 | ||||
-rw-r--r-- | scripts/mysql_create_system_tables.sh | 4 | ||||
-rw-r--r-- | sql/examples/ha_archive.cc | 11 | ||||
-rw-r--r-- | sql/field.cc | 12 | ||||
-rw-r--r-- | sql/item.cc | 2 | ||||
-rw-r--r-- | sql/log.cc | 2 | ||||
-rw-r--r-- | sql/sql_cache.cc | 2 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 35 | ||||
-rw-r--r-- | sql/table.cc | 12 | ||||
-rw-r--r-- | strings/ctype-ucs2.c | 25 | ||||
-rw-r--r-- | tests/mysql_client_test.c | 75 |
27 files changed, 343 insertions, 80 deletions
diff --git a/BitKeeper/triggers/post-commit b/BitKeeper/triggers/post-commit index 3f347e4c596..184c6243ef8 100755 --- a/BitKeeper/triggers/post-commit +++ b/BitKeeper/triggers/post-commit @@ -20,14 +20,20 @@ if [ "$BK_STATUS" = OK ] then CHANGESET=`bk -R prs -r+ -h -d':P:::I:' ChangeSet` -BUG=`bk -R prs -r+ -h -d':C:' ChangeSet | sed -ne 's/^.*[Bb][Uu][Gg] *# *\([0-9][0-9]*\).*$/ BUG#\1/p'` +BUG=`bk -R prs -r+ -h -d':C:' ChangeSet | sed -ne 's/^.*[Bb][Uu][Gg] *# *\([0-9][0-9]*\).*$/\1/p'` WL=`bk -R prs -r+ -h -d':C:' ChangeSet | sed -ne 's/^.*[Ww][Ll] *# *\([0-9][0-9]*\).*$/ WL#\1/p'` if [ "$BUG" = "" ] then TO=dev-public@mysql.com + BS="" + BH="" else TO=dev-bugs@mysql.com + BS=" BUG#$BUG" +# need newline here + BH="X-Bug: $BUG +" fi #++ # dev-public@ / dev-bugs@ @@ -38,8 +44,8 @@ fi List-ID: <bk.mysql-$VERSION> From: $FROM To: $TO -Subject: bk commit - $VERSION tree ($CHANGESET)${BUG}${WL} - +Subject: bk commit - $VERSION tree ($CHANGESET)${BS}${WL} +$BH EOF bk changes -v -r+ bk cset -r+ -d @@ -54,14 +60,14 @@ EOF List-ID: <bk.mysql-$VERSION> From: $FROM To: $INTERNALS -Subject: bk commit into $VERSION tree ($CHANGESET) - +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 push, to the public repository. For information on how to access the public repository -see http://www.mysql.com/doc/I/n/Installing_source_tree.html +see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html EOF bk changes -v -r+ @@ -81,7 +87,7 @@ EOF List-ID: <bk.mysql-$VERSION> From: $FROM To: $DOCS -Subject: bk commit - $VERSION tree (Manual) ($CHANGESET) +Subject: bk commit - $VERSION tree (Manual) ($CHANGESET)$BS EOF bk changes -v -r+ diff --git a/Build-tools/Do-compile b/Build-tools/Do-compile index 1c3ff01796f..e7ab3357de9 100755 --- a/Build-tools/Do-compile +++ b/Build-tools/Do-compile @@ -806,7 +806,7 @@ sub find sub rm_all { my(@rm_files)=@_; - my($dir,$current_dir,@files,@dirs); + my($dir,$current_dir,@files,@dirs,$removed); $current_dir = `pwd`; chomp($current_dir); foreach $dir (@rm_files) @@ -830,7 +830,9 @@ sub rm_all } if ($#files >= 0) { - system("rm -f " . join(" ",@files)) && abort("Can't remove files from $dir"); + $removed= unlink @files; + print "rm_all : removed $removed files in $current_dir/$dir\n" if ($opt_debug); + abort("Can't remove all $#files+1 from $current_dir/$dir, just $removed") if $removed != $#files+1; } foreach $dir (@dirs) { diff --git a/VC++Files/tests/mysql_client_test.dsp b/VC++Files/tests/mysql_client_test.dsp index 07014487bd1..3d1e6728181 100644 --- a/VC++Files/tests/mysql_client_test.dsp +++ b/VC++Files/tests/mysql_client_test.dsp @@ -66,18 +66,18 @@ LINK32=link.exe # PROP Output_Dir ".\Release"
# PROP Intermediate_Dir ".\Release"
# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /I "../include" /I "../" /W3 /Ob1 /G6 /D "DBUG_OFF" /D "_WINDOWS" /D "SAFE_MUTEX" /D "USE_TLS" /D "MYSQL_CLIENT" /D "__WIN__" /D "_WIN32" /GF /Gy /Fp".\Release/client_test.pch" /Fo".\Release/" /Fd".\Release/" /c /GX
-# ADD CPP /nologo /MTd /I "../include" /I "../" /W3 /Ob1 /G6 /D "DBUG_OFF" /D "_WINDOWS" /D "SAFE_MUTEX" /D "USE_TLS" /D "MYSQL_CLIENT" /D "__WIN__" /D "_WIN32" /GF /Gy /Fp".\Release/client_test.pch" /Fo".\Release/" /Fd".\Release/" /c /GX
-# ADD BASE MTL /nologo /tlb".\Release\client_test.tlb" /win32
-# ADD MTL /nologo /tlb".\Release\client_test.tlb" /win32
+# ADD BASE CPP /nologo /MTd /I "../include" /I "../" /W3 /Ob1 /G6 /D "DBUG_OFF" /D "_WINDOWS" /D "SAFE_MUTEX" /D "USE_TLS" /D "MYSQL_CLIENT" /D "__WIN__" /D "_WIN32" /GF /Gy /Fp".\Release/mysql_client_test.pch" /Fo".\Release/" /Fd".\Release/" /c /GX +# ADD CPP /nologo /MTd /I "../include" /I "../" /W3 /Ob1 /G6 /D "DBUG_OFF" /D "_WINDOWS" /D "SAFE_MUTEX" /D "USE_TLS" /D "MYSQL_CLIENT" /D "__WIN__" /D "_WIN32" /GF /Gy /Fp".\Release/mysql_client_test.pch" /Fo".\Release/" /Fd".\Release/" /c /GX +# ADD BASE MTL /nologo /tlb".\Release\mysql_client_test.tlb" /win32 +# ADD MTL /nologo /tlb".\Release\mysql_client_test.tlb" /win32 # ADD BASE RSC /l 1033
# ADD RSC /l 1033
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /out:"..\tests\client_test.exe" /incremental:no /pdb:".\Release\client_test.pdb" /pdbtype:sept /subsystem:console
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /out:"..\tests\client_test.exe" /incremental:no /pdb:".\Release\client_test.pdb" /pdbtype:sept /subsystem:console
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /out:"..\tests\mysql_client_test.exe" /incremental:no /pdb:".\Release\mysql_client_test.pdb" /pdbtype:sept /subsystem:console +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /out:"..\tests\mysql_client_test.exe" /incremental:no /pdb:".\Release\mysql_client_test.pdb" /pdbtype:sept /subsystem:console !ENDIF
diff --git a/extra/replace.c b/extra/replace.c index 5a086e5ca9c..98945ed35b3 100644 --- a/extra/replace.c +++ b/extra/replace.c @@ -376,8 +376,8 @@ static REP_SET *make_new_set(REP_SETS *sets); static void make_sets_invisible(REP_SETS *sets); static void free_last_set(REP_SETS *sets); static void free_sets(REP_SETS *sets); -static void set_bit(REP_SET *set, uint bit); -static void clear_bit(REP_SET *set, uint bit); +static void internal_set_bit(REP_SET *set, uint bit); +static void internal_clear_bit(REP_SET *set, uint bit); static void or_bits(REP_SET *to,REP_SET *from); static void copy_bits(REP_SET *to,REP_SET *from); static int cmp_bits(REP_SET *set1,REP_SET *set2); @@ -454,7 +454,7 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count, { if (from[i][0] == '\\' && from[i][1] == '^') { - set_bit(start_states,states+1); + internal_set_bit(start_states,states+1); if (!from[i][2]) { start_states->table_offset=i; @@ -463,8 +463,8 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count, } else if (from[i][0] == '\\' && from[i][1] == '$') { - set_bit(start_states,states); - set_bit(word_states,states); + internal_set_bit(start_states,states); + internal_set_bit(word_states,states); if (!from[i][2] && start_states->table_offset == (uint) ~0) { start_states->table_offset=i; @@ -473,11 +473,11 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count, } else { - set_bit(word_states,states); + internal_set_bit(word_states,states); if (from[i][0] == '\\' && (from[i][1] == 'b' && from[i][2])) - set_bit(start_states,states+1); + internal_set_bit(start_states,states+1); else - set_bit(start_states,states); + internal_set_bit(start_states,states); } for (pos=from[i], len=0; *pos ; pos++) { @@ -583,9 +583,9 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count, follow[i].len > found_end) found_end=follow[i].len; if (chr && follow[i].chr) - set_bit(new_set,i+1); /* To next set */ + internal_set_bit(new_set,i+1); /* To next set */ else - set_bit(new_set,i); + internal_set_bit(new_set,i); } } if (found_end) @@ -602,7 +602,7 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count, if (follow[bit_nr-1].len < found_end || (new_set->found_len && (chr == 0 || !follow[bit_nr].chr))) - clear_bit(new_set,i); + internal_clear_bit(new_set,i); else { if (chr == 0 || !follow[bit_nr].chr) @@ -751,13 +751,13 @@ static void free_sets(REP_SETS *sets) return; } -static void set_bit(REP_SET *set, uint bit) +static void internal_set_bit(REP_SET *set, uint bit) { set->bits[bit / WORD_BIT] |= 1 << (bit % WORD_BIT); return; } -static void clear_bit(REP_SET *set, uint bit) +static void internal_clear_bit(REP_SET *set, uint bit) { set->bits[bit / WORD_BIT] &= ~ (1 << (bit % WORD_BIT)); return; diff --git a/include/my_pthread.h b/include/my_pthread.h index c4138a47b3c..f8cd3e0de71 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -637,7 +637,7 @@ extern int pthread_dummy(int); MySQL can survive with 32K, but some glibc libraries require > 128K stack To resolve hostnames */ -#define DEFAULT_THREAD_STACK (192*1024L) +#define DEFAULT_THREAD_STACK (256*1024L) #else #define DEFAULT_THREAD_STACK (192*1024) #endif diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index b7cd730828a..482cf698547 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -417,7 +417,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); diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 3d84059e981..9c49c7eb15b 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1788,6 +1788,18 @@ static my_bool my_realloc_str(NET *net, ulong length) } +/* Clear possible error statee of struct NET */ + +static void net_clear_error(NET *net) +{ + if (net->last_errno) + { + net->last_errno= 0; + net->last_error[0]= '\0'; + strmov(net->sqlstate, not_error_sqlstate); + } +} + /* Set statement error code, sqlstate, and error message from given errcode and sqlstate. @@ -2467,6 +2479,11 @@ int cli_stmt_execute(MYSQL_STMT *stmt) set_stmt_error(stmt, CR_PARAMS_NOT_BOUND, unknown_sqlstate); DBUG_RETURN(1); } + if (stmt->mysql->status != MYSQL_STATUS_READY) + { + set_stmt_error(stmt, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate); + DBUG_RETURN(1); + } net_clear(net); /* Sets net->write_pos */ /* Reserve place for null-marker bytes */ @@ -4501,6 +4518,11 @@ my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt) if (mysql) { mysql->stmts= list_delete(mysql->stmts, &stmt->list); + /* + Clear NET error state: if the following commands come through + successfully, connection will still be usable for other commands. + */ + net_clear_error(&mysql->net); if ((int) stmt->state > (int) MYSQL_STMT_INIT_DONE) { char buff[MYSQL_STMT_HEADER]; /* 4 bytes - stmt id */ 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; } 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/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/r/distinct.result b/mysql-test/r/distinct.result index 80af2dd0983..f4bc4263c4d 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; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 4 Using index; Using temporary -1 SIMPLE t3 ref a a 5 test.t1.a 10 Using where; Using index; Distinct +1 SIMPLE t3 ref a a 5 test.t1.a 11 Using where; Using index; Distinct select distinct t1.a from t1,t3 where t1.a=t3.a; a 1 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%"; diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index a05b379ed88..70ac33964ad 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2387,3 +2387,16 @@ EXPLAIN SELECT i FROM t1 WHERE i=1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index DROP TABLE t1; +CREATE TABLE t1 ( a BLOB, INDEX (a(20)) ); +CREATE TABLE t2 ( a BLOB, INDEX (a(20)) ); +INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five'); +INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 +1 SIMPLE t2 ref a a 23 test.t1.a 2 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 +1 SIMPLE t2 ref a a 23 test.t1.a 2 +DROP TABLE t1, t2; 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/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/mysql-test/t/select.test b/mysql-test/t/select.test index 9bbd26a9c1c..c00395d95e7 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -1930,3 +1930,18 @@ INSERT INTO t1 VALUES (3,'c'); EXPLAIN SELECT i FROM t1 WHERE i=1; DROP TABLE t1; + +# +# Test case for bug 7520: a wrong cost of the index for a BLOB field +# + +CREATE TABLE t1 ( a BLOB, INDEX (a(20)) ); +CREATE TABLE t2 ( a BLOB, INDEX (a(20)) ); + +INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five'); +INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a; +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a; + +DROP TABLE t1, t2; 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/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 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; } 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/sql/item.cc b/sql/item.cc index 17d41fda677..4b3acbe5a3c 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -2797,7 +2797,7 @@ bool Item_type_holder::join_types(THD *thd, Item *item, TABLE *table) bool use_new_field= 0, use_expression_type= 0; Item_result new_result_type= type_convertor[item_type][item->result_type()]; Field *field= get_holder_example_field(thd, item, table); - bool item_is_a_field= field; + bool item_is_a_field= (field != NULL); /* Check if both items point to fields: in this case we can adjust column types of result table in the union smartly. diff --git a/sql/log.cc b/sql/log.cc index 38844877f1b..46b44837e0f 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1274,7 +1274,7 @@ bool MYSQL_LOG::write(Log_event* event_info) binlog_[wild_]{do|ignore}_table?" (WL#1049)" */ if ((thd && !(thd->options & OPTION_BIN_LOG)) || - (local_db && !db_ok(local_db, binlog_do_db, binlog_ignore_db))) + (!db_ok(local_db, binlog_do_db, binlog_ignore_db))) { VOID(pthread_mutex_unlock(&LOCK_log)); DBUG_PRINT("error",("!db_ok('%s')", local_db)); diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index e1367412601..6eff958257b 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1421,7 +1421,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; 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<String> *)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: diff --git a/sql/table.cc b/sql/table.cc index 6427755dab4..064d7f1afc1 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -195,7 +195,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; @@ -251,11 +250,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; @@ -685,6 +679,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.is_set(primary_key))) 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 }; diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 83f8f6ab143..14b3ddbf8b2 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -24,6 +24,7 @@ #include <my_global.h> #include <my_sys.h> #include <mysql.h> +#include <errmsg.h> #include <my_getopt.h> #include <m_string.h> @@ -11532,6 +11533,78 @@ static void test_bug6761(void) myquery(rc); } + +/* Bug#8330 - mysql_stmt_execute crashes (libmysql) */ + +static void test_bug8330() +{ + const char *stmt_text; + MYSQL_STMT *stmt[2]; + int i, rc; + char *query= "select a,b from t1 where a=?"; + MYSQL_BIND bind[2]; + long lval[2]; + + myheader("test_bug8330"); + + stmt_text= "drop table if exists t1"; + /* in case some previos test failed */ + rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + myquery(rc); + stmt_text= "create table t1 (a int, b int)"; + rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + myquery(rc); + + bzero(bind, sizeof(bind)); + for (i=0; i < 2; i++) + { + stmt[i]= mysql_stmt_init(mysql); + rc= mysql_stmt_prepare(stmt[i], query, strlen(query)); + check_execute(stmt[i], rc); + + bind[i].buffer_type= MYSQL_TYPE_LONG; + bind[i].buffer= (void*) &lval[i]; + bind[i].is_null= 0; + mysql_stmt_bind_param(stmt[i], &bind[i]); + } + + rc= mysql_stmt_execute(stmt[0]); + check_execute(stmt[0], rc); + + rc= mysql_stmt_execute(stmt[1]); + DIE_UNLESS(rc && mysql_stmt_errno(stmt[1]) == CR_COMMANDS_OUT_OF_SYNC); + rc= mysql_stmt_execute(stmt[0]); + check_execute(stmt[0], rc); + + mysql_stmt_close(stmt[0]); + mysql_stmt_close(stmt[1]); + + stmt_text= "drop table t1"; + rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + myquery(rc); +} + + +/* Bug#7990 - mysql_stmt_close doesn't reset mysql->net.last_error */ + +static void test_bug7990() +{ + MYSQL_STMT *stmt; + int rc; + myheader("test_bug7990"); + + stmt= mysql_stmt_init(mysql); + rc= mysql_stmt_prepare(stmt, "foo", 3); + /* + XXX: the fact that we store errno both in STMT and in + MYSQL is not documented and is subject to change in 5.0 + */ + DIE_UNLESS(rc && mysql_stmt_errno(stmt) && mysql_errno(mysql)); + mysql_stmt_close(stmt); + DIE_UNLESS(!mysql_errno(mysql)); +} + + /* Read and parse arguments and MySQL options from my.cnf */ @@ -11739,6 +11812,8 @@ static struct my_tests_st my_tests[]= { { "test_conversion", test_conversion }, { "test_rewind", test_rewind }, { "test_bug6761", test_bug6761 }, + { "test_bug8330", test_bug8330 }, + { "test_bug7990", test_bug7990 }, { 0, 0 } }; |