From 519bf5b6fc9ff01196e7be959c78687177a2c639 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 21 Feb 2006 14:55:54 +0100 Subject: [PATCH 001/203] Bug#11589 mysqltest, --ps-protocol, strange output, float/double/real with zerofill - Add zerofill in client if real/float/double is bound to string and fetched using binary protocol. --- libmysql/libmysql.c | 10 +++++++++- mysql-test/r/type_float.result | 16 ++++++++++++++++ mysql-test/t/type_float.test | 18 ++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 11ee7284cbf..59a28d0a1f1 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -3850,7 +3850,15 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, sprintf(buff, "%.*f", (int) field->decimals, value); end= strend(buff); } - fetch_string_with_conversion(param, buff, (uint) (end - buff)); + uint length= (uint) (end-buff); + if (field->flags & ZEROFILL_FLAG && length < field->length && + field->length < MAX_DOUBLE_STRING_REP_LENGTH-1) + { + bmove_upp((char*) buff+field->length,buff+length, length); + bfill((char*) buff, field->length - length,'0'); + length= field->length; + } + fetch_string_with_conversion(param, buff, length); break; } } diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result index c10cb7d71f7..a46ff64e0ba 100644 --- a/mysql-test/r/type_float.result +++ b/mysql-test/r/type_float.result @@ -244,3 +244,19 @@ create table t1 (s1 float(0,2)); ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 's1'). create table t1 (s1 float(1,2)); ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 's1'). +CREATE TABLE t1 ( +f1 real zerofill, +f2 double zerofill, +f3 float zerofill); +INSERT INTO t1 VALUES ( 0.314152e+1, 0.314152e+1, 0.314152e+1); +PREPARE stmt1 FROM 'select f1, f2, f3 FROM t1'; +select f1, f2, f3 FROM t1; +f1 f2 f3 +0000000000000003.14152 0000000000000003.14152 000003.14152 +select f1, f2, f3 FROM t1; +f1 f2 f3 +0000000000000003.14152 0000000000000003.14152 000003.14152 +EXECUTE stmt1; +f1 f2 f3 +0000000000000003.14152 0000000000000003.14152 000003.14152 +DROP TABLE t1; diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test index 6a0814ef113..9893d3c7338 100644 --- a/mysql-test/t/type_float.test +++ b/mysql-test/t/type_float.test @@ -169,3 +169,21 @@ drop table t1, t2, t3; create table t1 (s1 float(0,2)); --error 1427 create table t1 (s1 float(1,2)); + +# +# MySQL Bugs: #11589: mysqltest --ps-protocol, strange output, float/double/real with zerofill +# + +CREATE TABLE t1 ( + f1 real zerofill, + f2 double zerofill, + f3 float zerofill); +INSERT INTO t1 VALUES ( 0.314152e+1, 0.314152e+1, 0.314152e+1); + +let $my_stmt= select f1, f2, f3 FROM t1; +eval PREPARE stmt1 FROM '$my_stmt'; +select f1, f2, f3 FROM t1; +eval $my_stmt; +EXECUTE stmt1; + +DROP TABLE t1; From 168b2538e348591a35fa1c23c1dcce86aea6a738 Mon Sep 17 00:00:00 2001 From: "holyfoot/hf@mysql.com/hfmain.(none)" <> Date: Sun, 11 Mar 2007 22:30:54 +0400 Subject: [PATCH 002/203] Bug #26527 LOAD DATA INFILE extremely slow with partitioned table mysql_load calls hander::start_bulk_insert(0) to prepare caches for big inserts. As ha_partition didn't allow these caches for underlaying tables, the inserts were much slower --- sql/ha_partition.cc | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index db0d118c2e0..e5b61b29423 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -2865,12 +2865,7 @@ void ha_partition::start_bulk_insert(ha_rows rows) handler **file; DBUG_ENTER("ha_partition::start_bulk_insert"); - if (!rows) - { - /* Avoid allocation big caches in all underlaying handlers */ - DBUG_VOID_RETURN; - } - rows= rows/m_tot_parts + 1; + rows= rows ? rows/m_tot_parts + 1 : 0; file= m_file; do { From 68e2efcc29309883d8a1df8c59e830195e3fced9 Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@macbook.gmz" <> Date: Wed, 6 Jun 2007 17:54:14 +0300 Subject: [PATCH 003/203] Bug #28701: Views don't have indexes. So they can't take index hints. Added a check and disabled the usage of hints for views. --- mysql-test/r/view.result | 13 ++++++++++++- mysql-test/t/view.test | 22 +++++++++++++++++++++- sql/sql_view.cc | 9 +++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 43e147724c8..39e84151187 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -612,7 +612,7 @@ drop table t1; create table t1 (a int, b int); create view v1 as select a, sum(b) from t1 group by a; select b from v1 use index (some_index) where b=1; -ERROR HY000: Key 'some_index' doesn't exist in table 'v1' +ERROR HY000: Incorrect usage of USE INDEX and VIEW drop view v1; drop table t1; create table t1 (col1 char(5),col2 char(5)); @@ -3455,4 +3455,15 @@ a1 c 2 0 DROP VIEW v1,v2; DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM v1 USE KEY(non_existant); +ERROR HY000: Incorrect usage of USE INDEX and VIEW +SELECT * FROM v1 FORCE KEY(non_existant); +ERROR HY000: Incorrect usage of FORCE INDEX and VIEW +SELECT * FROM v1 IGNORE KEY(non_existant); +ERROR HY000: Incorrect usage of IGNORE INDEX and VIEW +DROP VIEW v1; +DROP TABLE t1; End of 5.0 tests. diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index f574451af08..d209e5848ea 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -506,7 +506,7 @@ drop table t1; # create table t1 (a int, b int); create view v1 as select a, sum(b) from t1 group by a; --- error 1176 +--error ER_WRONG_USAGE select b from v1 use index (some_index) where b=1; drop view v1; drop table t1; @@ -3320,4 +3320,24 @@ SELECT * FROM t1; DROP VIEW v1,v2; DROP TABLE t1,t2,t3,t4; + +# +# Bug #28701: SELECTs from VIEWs completely ignore USE/FORCE KEY, allowing +# invalid statements +# + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +CREATE VIEW v1 AS SELECT * FROM t1; +--error ER_WRONG_USAGE +SELECT * FROM v1 USE KEY(non_existant); +--error ER_WRONG_USAGE +SELECT * FROM v1 FORCE KEY(non_existant); +--error ER_WRONG_USAGE +SELECT * FROM v1 IGNORE KEY(non_existant); + +DROP VIEW v1; +DROP TABLE t1; + + --echo End of 5.0 tests. diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 0fb4d3aaea8..faefeb2aef4 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -918,6 +918,15 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table, DBUG_RETURN(0); } + if (table->use_index || table->ignore_index) + { + my_error(ER_WRONG_USAGE, MYF(0), + table->ignore_index ? "IGNORE INDEX" : + (table->force_index ? "FORCE INDEX" : "USE INDEX"), + "VIEW"); + DBUG_RETURN(TRUE); + } + /* check loop via view definition */ for (TABLE_LIST *precedent= table->referencing_view; precedent; From 7c2c8f07e43a5ce3998473bef6565e9e60ac533f Mon Sep 17 00:00:00 2001 From: "dkatz@damien-katzs-computer.local" <> Date: Fri, 27 Jul 2007 16:26:26 -0400 Subject: [PATCH 004/203] Bug #29419 "Specifying a join_buffer > 4GB on 64 bit machines not possible." Use size_t instead of uint when calculating join buffer size, because uint can be overflown on 64-bit platforms and join_buffer_size > 4 GB. The test case for this bug is a part of the test suite for bug #5731. --- sql/sql_select.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index d8bf8466f58..89bdd22a3de 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -13014,7 +13014,8 @@ static int join_init_cache(THD *thd,JOIN_TAB *tables,uint table_count) { reg1 uint i; - uint length,blobs,size; + uint length, blobs; + size_t size; CACHE_FIELD *copy,**blob_ptr; JOIN_CACHE *cache; JOIN_TAB *join_tab; @@ -13130,7 +13131,7 @@ store_record_in_cache(JOIN_CACHE *cache) length=cache->length; if (cache->blobs) length+=used_blob_length(cache->blob_ptr); - if ((last_record=(length+cache->length > (uint) (cache->end - pos)))) + if ((last_record= (length + cache->length > (size_t) (cache->end - pos)))) cache->ptr_record=cache->records; /* @@ -13176,7 +13177,7 @@ store_record_in_cache(JOIN_CACHE *cache) } } cache->pos=pos; - return last_record || (uint) (cache->end -pos) < cache->length; + return last_record || (size_t) (cache->end - pos) < cache->length; } From 9a64fe87ab65425c1795357c9d0e24b613e1da88 Mon Sep 17 00:00:00 2001 From: "svoj@mysql.com/april.(none)" <> Date: Fri, 3 Aug 2007 03:50:19 +0500 Subject: [PATCH 005/203] BUG#27040 - Incorrect FTS parser name output When a table uses two (or more) fulltext keys with different fulltext parsers, all fulltext keys (excluding those that use built-in parser) were using first parser that was mentioned in .frm. With this fix fulltext keys use proper (assigned during create table) fulltext parser. This code was contributed by Yoshinori Matsunobu ymatsunobu@mysql.com on 2007-03-12 The copyright was assigned and transferred under the terms of the MySQL Contributor License Agreement. --- sql/table.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/table.cc b/sql/table.cc index e6f9b1086c7..1e8a37faaa6 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -918,6 +918,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, } parser_name.str= (char*) next_chunk; parser_name.length= strlen((char*) next_chunk); + next_chunk+= parser_name.length + 1; keyinfo->parser= my_plugin_lock_by_name(NULL, &parser_name, MYSQL_FTPARSER_PLUGIN); if (! keyinfo->parser) From edbe12ac02bd560687042ccc489c79c6d2a9bce2 Mon Sep 17 00:00:00 2001 From: "antony@pcg5ppc.xiphis.org" <> Date: Thu, 16 Aug 2007 14:00:35 -0700 Subject: [PATCH 006/203] Bug#30359 "Test federated_bug_25714 issues non-existing shell command" Problem caused by missing '$' symbol in eval statement causing it to always attempt to run test even if the test was not compiled. --- mysql-test/include/have_bug25714.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/include/have_bug25714.inc b/mysql-test/include/have_bug25714.inc index 0c995cd0d4c..0c09ae1a035 100644 --- a/mysql-test/include/have_bug25714.inc +++ b/mysql-test/include/have_bug25714.inc @@ -3,5 +3,5 @@ # --require r/have_bug25714.require disable_query_log; -eval select LENGTH("MYSQL_BUG25714") > 0 as "have_bug25714_exe"; +eval select LENGTH("$MYSQL_BUG25714") > 0 as "have_bug25714_exe"; enable_query_log; From b1b2108275d8737b8381ccd0bd64dbaaef04530c Mon Sep 17 00:00:00 2001 From: "thek@adventure.(none)" <> Date: Thu, 23 Aug 2007 10:22:20 +0200 Subject: [PATCH 007/203] Bug#27358 INSERT DELAYED does not honour SQL_MODE of the client SQL_MODE was ignored when a client issued INSERT DELAYED. Some system settings weren't copied as intended when a record was saved for a delayed insert. --- mysql-test/r/bdb_notembedded.result | 35 -------------------------- mysql-test/r/delayed.result | 29 ++++++++++++++++++++++ mysql-test/t/bdb_notembedded.test | 38 ----------------------------- mysql-test/t/delayed.test | 31 +++++++++++++++++++++++ sql/sql_insert.cc | 8 ++++++ 5 files changed, 68 insertions(+), 73 deletions(-) delete mode 100644 mysql-test/r/bdb_notembedded.result delete mode 100644 mysql-test/t/bdb_notembedded.test diff --git a/mysql-test/r/bdb_notembedded.result b/mysql-test/r/bdb_notembedded.result deleted file mode 100644 index 14cb5fad915..00000000000 --- a/mysql-test/r/bdb_notembedded.result +++ /dev/null @@ -1,35 +0,0 @@ -set autocommit=1; -reset master; -create table bug16206 (a int); -insert into bug16206 values(1); -start transaction; -insert into bug16206 values(2); -commit; -show binlog events; -Log_name Pos Event_type Server_id End_log_pos Info -f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 -f n Query 1 n use `test`; create table bug16206 (a int) -f n Query 1 n use `test`; insert into bug16206 values(1) -f n Query 1 n use `test`; insert into bug16206 values(2) -drop table bug16206; -reset master; -create table bug16206 (a int) engine= bdb; -insert into bug16206 values(0); -insert into bug16206 values(1); -start transaction; -insert into bug16206 values(2); -commit; -insert into bug16206 values(3); -show binlog events; -Log_name Pos Event_type Server_id End_log_pos Info -f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 -f n Query 1 n use `test`; create table bug16206 (a int) engine= bdb -f n Query 1 n use `test`; insert into bug16206 values(0) -f n Query 1 n use `test`; insert into bug16206 values(1) -f n Query 1 n use `test`; BEGIN -f n Query 1 n use `test`; insert into bug16206 values(2) -f n Query 1 n use `test`; COMMIT -f n Query 1 n use `test`; insert into bug16206 values(3) -drop table bug16206; -set autocommit=0; -End of 5.0 tests diff --git a/mysql-test/r/delayed.result b/mysql-test/r/delayed.result index b37679847be..5b56a6e27bc 100644 --- a/mysql-test/r/delayed.result +++ b/mysql-test/r/delayed.result @@ -255,3 +255,32 @@ CREATE TABLE t2(c1 INT) ENGINE=MERGE UNION=(t1); INSERT DELAYED INTO t2 VALUES(1); ERROR HY000: Table storage engine for 't2' doesn't have this option DROP TABLE t1, t2; +DROP TABLE IF EXISTS t1,t2; +SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO'; +CREATE TABLE `t1` ( +`id` int(11) PRIMARY KEY auto_increment, +`f1` varchar(10) NOT NULL UNIQUE +); +INSERT DELAYED INTO t1 VALUES(0,"test1"); +SELECT * FROM t1; +id f1 +0 test1 +SET SQL_MODE='PIPES_AS_CONCAT'; +INSERT DELAYED INTO t1 VALUES(0,'a' || 'b'); +SELECT * FROM t1; +id f1 +0 test1 +1 ab +SET SQL_MODE='ERROR_FOR_DIVISION_BY_ZERO,STRICT_ALL_TABLES'; +INSERT DELAYED INTO t1 VALUES(mod(1,0),"test3"); +ERROR 22012: Division by 0 +CREATE TABLE t2 ( +`id` int(11) PRIMARY KEY auto_increment, +`f1` date +); +SET SQL_MODE='NO_ZERO_DATE,STRICT_ALL_TABLES,NO_ZERO_IN_DATE'; +INSERT DELAYED INTO t2 VALUES (0,'0000-00-00'); +ERROR 22007: Incorrect date value: '0000-00-00' for column 'f1' at row 1 +INSERT DELAYED INTO t2 VALUES (0,'2007-00-00'); +ERROR 22007: Incorrect date value: '2007-00-00' for column 'f1' at row 1 +DROP TABLE t1,t2; diff --git a/mysql-test/t/bdb_notembedded.test b/mysql-test/t/bdb_notembedded.test deleted file mode 100644 index 24e64ebbfb2..00000000000 --- a/mysql-test/t/bdb_notembedded.test +++ /dev/null @@ -1,38 +0,0 @@ --- source include/not_embedded.inc --- source include/have_bdb.inc - -# -# Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit mode -# -set autocommit=1; - -let $VERSION=`select version()`; - -reset master; -create table bug16206 (a int); -insert into bug16206 values(1); -start transaction; -insert into bug16206 values(2); -commit; ---replace_result $VERSION VERSION ---replace_column 1 f 2 n 5 n -show binlog events; -drop table bug16206; - -reset master; -create table bug16206 (a int) engine= bdb; -insert into bug16206 values(0); -insert into bug16206 values(1); -start transaction; -insert into bug16206 values(2); -commit; -insert into bug16206 values(3); ---replace_result $VERSION VERSION ---replace_column 1 f 2 n 5 n -show binlog events; -drop table bug16206; - -set autocommit=0; - - ---echo End of 5.0 tests diff --git a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test index 13615c8c269..505556998be 100644 --- a/mysql-test/t/delayed.test +++ b/mysql-test/t/delayed.test @@ -251,4 +251,35 @@ CREATE TABLE t2(c1 INT) ENGINE=MERGE UNION=(t1); --error 1031 INSERT DELAYED INTO t2 VALUES(1); DROP TABLE t1, t2; +# +# Bug#27358 INSERT DELAYED does not honour SQL_MODE of the client +# +--disable_warnings +DROP TABLE IF EXISTS t1,t2; +--enable_warnings +SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO'; +CREATE TABLE `t1` ( + `id` int(11) PRIMARY KEY auto_increment, + `f1` varchar(10) NOT NULL UNIQUE +); +INSERT DELAYED INTO t1 VALUES(0,"test1"); +sleep 1; +SELECT * FROM t1; +SET SQL_MODE='PIPES_AS_CONCAT'; +INSERT DELAYED INTO t1 VALUES(0,'a' || 'b'); +sleep 1; +SELECT * FROM t1; +SET SQL_MODE='ERROR_FOR_DIVISION_BY_ZERO,STRICT_ALL_TABLES'; +--error 1365 +INSERT DELAYED INTO t1 VALUES(mod(1,0),"test3"); +CREATE TABLE t2 ( + `id` int(11) PRIMARY KEY auto_increment, + `f1` date +); +SET SQL_MODE='NO_ZERO_DATE,STRICT_ALL_TABLES,NO_ZERO_IN_DATE'; +--error ER_TRUNCATED_WRONG_VALUE +INSERT DELAYED INTO t2 VALUES (0,'0000-00-00'); +--error ER_TRUNCATED_WRONG_VALUE +INSERT DELAYED INTO t2 VALUES (0,'2007-00-00'); +DROP TABLE t1,t2; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 5edce08e481..07f2ed8694e 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1587,6 +1587,8 @@ public: ulonglong next_insert_id; ulong auto_increment_increment; ulong auto_increment_offset; + ulong sql_mode; + bool auto_increment_field_not_null; timestamp_auto_set_type timestamp_field_type; uint query_length; @@ -2048,6 +2050,9 @@ int write_delayed(THD *thd,TABLE *table,enum_duplicates duplic, bool ignore, /* The session variable settings can always be copied. */ row->auto_increment_increment= thd->variables.auto_increment_increment; row->auto_increment_offset= thd->variables.auto_increment_offset; + row->sql_mode= thd->variables.sql_mode; + row->auto_increment_field_not_null= table->auto_increment_field_not_null; + /* Next insert id must be set for the first value in a multi-row insert only. So clear it after the first use. Assume a multi-row insert. @@ -2436,10 +2441,13 @@ bool Delayed_insert::handle_inserts(void) thd.last_insert_id_used=row->last_insert_id_used; thd.insert_id_used=row->insert_id_used; table->timestamp_field_type= row->timestamp_field_type; + table->auto_increment_field_not_null= row->auto_increment_field_not_null; /* The session variable settings can always be copied. */ thd.variables.auto_increment_increment= row->auto_increment_increment; thd.variables.auto_increment_offset= row->auto_increment_offset; + thd.variables.sql_mode= row->sql_mode; + /* Next insert id must be used only if non-zero. */ if (row->next_insert_id) thd.next_insert_id= row->next_insert_id; From 39e53b4fee9296b214981b2ac19a4436a3d321fa Mon Sep 17 00:00:00 2001 From: "kaa@polly.local" <> Date: Wed, 29 Aug 2007 19:20:18 +0400 Subject: [PATCH 008/203] Backport of my_malloc() changes from 5.1 to make it 64-bit safe on Unix platforms. This is required to allow key_buffer_size > 4 GB (bug #5731). --- include/my_sys.h | 26 +++++++++++++------------- mysys/my_largepage.c | 12 ++++++------ mysys/my_malloc.c | 16 ++++++++-------- mysys/safemalloc.c | 27 +++++++++++++-------------- 4 files changed, 40 insertions(+), 41 deletions(-) diff --git a/include/my_sys.h b/include/my_sys.h index 7df2718c7b1..4f7e75a836e 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -147,14 +147,14 @@ extern ulonglong sf_malloc_mem_limit; #define TERMINATE(A) {} #define QUICK_SAFEMALLOC #define NORMAL_SAFEMALLOC -extern gptr my_malloc(uint Size,myf MyFlags); +extern gptr my_malloc(size_t Size, myf MyFlags); #define my_malloc_ci(SZ,FLAG) my_malloc( SZ, FLAG ) extern gptr my_realloc(gptr oldpoint,uint Size,myf MyFlags); extern void my_no_flags_free(gptr ptr); -extern gptr my_memdup(const byte *from,uint length,myf MyFlags); +extern gptr my_memdup(const byte *from, size_t length, myf MyFlags); extern char *my_strdup(const char *from,myf MyFlags); -extern char *my_strdup_with_length(const char *from, uint length, - myf MyFlags); +extern char *my_strdup_with_length(const char *from, size_t length, + myf MyFlags); /* we do use FG (as a no-op) in below so that a typo on FG is caught */ #define my_free(PTR,FG) ((void)FG,my_no_flags_free(PTR)) #define CALLER_INFO_PROTO /* nothing */ @@ -165,7 +165,7 @@ extern char *my_strdup_with_length(const char *from, uint length, #ifdef HAVE_LARGE_PAGES extern uint my_get_large_page_size(void); -extern gptr my_large_malloc(uint size, myf my_flags); +extern gptr my_large_malloc(size_t size, myf my_flags); extern void my_large_free(gptr ptr, myf my_flags); #else #define my_get_large_page_size() (0) @@ -590,18 +590,18 @@ extern uint my_fwrite(FILE *stream,const byte *Buffer,uint Count, myf MyFlags); extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags); extern my_off_t my_ftell(FILE *stream,myf MyFlags); -extern gptr _mymalloc(uint uSize,const char *sFile, - uint uLine, myf MyFlag); -extern gptr _myrealloc(gptr pPtr,uint uSize,const char *sFile, - uint uLine, myf MyFlag); +extern gptr _mymalloc(size_t uSize, const char *sFile, + uint uLine, myf MyFlag); +extern gptr _myrealloc(gptr pPtr, size_t uSize, const char *sFile, + uint uLine, myf MyFlag); extern gptr my_multi_malloc _VARARGS((myf MyFlags, ...)); -extern void _myfree(gptr pPtr,const char *sFile,uint uLine, myf MyFlag); +extern void _myfree(gptr pPtr, const char *sFile, uint uLine, myf MyFlag); extern int _sanity(const char *sFile,unsigned int uLine); -extern gptr _my_memdup(const byte *from,uint length, - const char *sFile, uint uLine,myf MyFlag); +extern gptr _my_memdup(const byte *from, size_t length, + const char *sFile, uint uLine, myf MyFlag); extern my_string _my_strdup(const char *from, const char *sFile, uint uLine, myf MyFlag); -extern char *_my_strdup_with_length(const char *from, uint length, +extern char *_my_strdup_with_length(const char *from, size_t length, const char *sFile, uint uLine, myf MyFlag); diff --git a/mysys/my_largepage.c b/mysys/my_largepage.c index 9714c582acb..082b6368a64 100644 --- a/mysys/my_largepage.c +++ b/mysys/my_largepage.c @@ -26,7 +26,7 @@ #endif static uint my_get_large_page_size_int(void); -static gptr my_large_malloc_int(uint size, myf my_flags); +static gptr my_large_malloc_int(size_t size, myf my_flags); static my_bool my_large_free_int(gptr ptr, myf my_flags); /* Gets the size of large pages from the OS */ @@ -48,7 +48,7 @@ uint my_get_large_page_size(void) my_malloc_lock() in case of failure */ -gptr my_large_malloc(uint size, myf my_flags) +gptr my_large_malloc(size_t size, myf my_flags) { gptr ptr; DBUG_ENTER("my_large_malloc"); @@ -113,7 +113,7 @@ finish: #if HAVE_DECL_SHM_HUGETLB /* Linux-specific large pages allocator */ -gptr my_large_malloc_int(uint size, myf my_flags) +gptr my_large_malloc_int(size_t size, myf my_flags) { int shmid; gptr ptr; @@ -123,13 +123,13 @@ gptr my_large_malloc_int(uint size, myf my_flags) /* Align block size to my_large_page_size */ size = ((size - 1) & ~(my_large_page_size - 1)) + my_large_page_size; - shmid = shmget(IPC_PRIVATE, (size_t)size, SHM_HUGETLB | SHM_R | SHM_W); + shmid = shmget(IPC_PRIVATE, size, SHM_HUGETLB | SHM_R | SHM_W); if (shmid < 0) { if (my_flags & MY_WME) fprintf(stderr, - "Warning: Failed to allocate %d bytes from HugeTLB memory." - " errno %d\n", size, errno); + "Warning: Failed to allocate %lu bytesx from HugeTLB memory." + " errno %d\n", (ulong) size, errno); DBUG_RETURN(NULL); } diff --git a/mysys/my_malloc.c b/mysys/my_malloc.c index 38d0263b495..256b14a9605 100644 --- a/mysys/my_malloc.c +++ b/mysys/my_malloc.c @@ -23,11 +23,11 @@ /* My memory allocator */ -gptr my_malloc(unsigned int size, myf my_flags) +gptr my_malloc(size_t size, myf my_flags) { gptr point; DBUG_ENTER("my_malloc"); - DBUG_PRINT("my",("size: %u my_flags: %d",size, my_flags)); + DBUG_PRINT("my",("size: %lu my_flags: %d", (ulong) size, my_flags)); if (!size) size=1; /* Safety */ @@ -63,11 +63,11 @@ void my_no_flags_free(gptr ptr) /* malloc and copy */ -gptr my_memdup(const byte *from, uint length, myf my_flags) +gptr my_memdup(const byte *from, size_t length, myf my_flags) { gptr ptr; if ((ptr=my_malloc(length,my_flags)) != 0) - memcpy((byte*) ptr, (byte*) from,(size_t) length); + memcpy((byte*) ptr, (byte*)from, length); return(ptr); } @@ -75,19 +75,19 @@ gptr my_memdup(const byte *from, uint length, myf my_flags) char *my_strdup(const char *from, myf my_flags) { gptr ptr; - uint length=(uint) strlen(from)+1; + size_t length= strlen(from)+1; if ((ptr=my_malloc(length,my_flags)) != 0) - memcpy((byte*) ptr, (byte*) from,(size_t) length); + memcpy((byte*) ptr, (byte*) from, length); return((my_string) ptr); } -char *my_strdup_with_length(const char *from, uint length, myf my_flags) +char *my_strdup_with_length(const char *from, size_t length, myf my_flags) { gptr ptr; if ((ptr=my_malloc(length+1,my_flags)) != 0) { - memcpy((byte*) ptr, (byte*) from,(size_t) length); + memcpy((byte*) ptr, (byte*) from, length); ((char*) ptr)[length]=0; } return((char*) ptr); diff --git a/mysys/safemalloc.c b/mysys/safemalloc.c index a7d8f372151..1cdbd1ecbf2 100644 --- a/mysys/safemalloc.c +++ b/mysys/safemalloc.c @@ -119,12 +119,12 @@ static int _checkchunk(struct st_irem *pRec, const char *sFile, uint uLine); /* Allocate some memory. */ -gptr _mymalloc(uint size, const char *filename, uint lineno, myf MyFlags) +gptr _mymalloc(size_t size, const char *filename, uint lineno, myf MyFlags) { struct st_irem *irem; char *data; DBUG_ENTER("_mymalloc"); - DBUG_PRINT("enter",("Size: %u",size)); + DBUG_PRINT("enter",("Size: %lu", (ulong) size)); if (!sf_malloc_quick) (void) _sanity (filename, lineno); @@ -151,8 +151,8 @@ gptr _mymalloc(uint size, const char *filename, uint lineno, myf MyFlags) my_errno=errno; sprintf(buff,"Out of memory at line %d, '%s'", lineno, filename); my_message(EE_OUTOFMEMORY, buff, MYF(ME_BELL+ME_WAITTANG+ME_NOREFRESH)); - sprintf(buff,"needed %d byte (%ldk), memory in use: %ld bytes (%ldk)", - size, (size + 1023L) / 1024L, + sprintf(buff,"needed %u byte (%ldk), memory in use: %ld bytes (%ldk)", + (uint) size, (uint) (size + 1023L) / 1024L, sf_malloc_max_memory, (sf_malloc_max_memory + 1023L) / 1024L); my_message(EE_OUTOFMEMORY, buff, MYF(ME_BELL+ME_WAITTANG+ME_NOREFRESH)); } @@ -207,8 +207,8 @@ gptr _mymalloc(uint size, const char *filename, uint lineno, myf MyFlags) Free then old memoryblock */ -gptr _myrealloc(register gptr ptr, register uint size, - const char *filename, uint lineno, myf MyFlags) +gptr _myrealloc(register gptr ptr, register size_t size, + const char *filename, uint lineno, myf MyFlags) { struct st_irem *irem; char *data; @@ -373,8 +373,7 @@ void TERMINATE(FILE *file) { if (file) { - fprintf(file, "Warning: Not freed memory segments: %u\n", - sf_malloc_count); + fprintf(file, "Warning: Not freed memory segments: %u\n", sf_malloc_count); (void) fflush(file); } DBUG_PRINT("safe",("sf_malloc_count: %u", sf_malloc_count)); @@ -503,8 +502,8 @@ int _sanity(const char *filename, uint lineno) /* malloc and copy */ -gptr _my_memdup(const byte *from, uint length, const char *filename, - uint lineno, myf MyFlags) +gptr _my_memdup(const byte *from, size_t length, const char *filename, + uint lineno, myf MyFlags) { gptr ptr; if ((ptr=_mymalloc(length,filename,lineno,MyFlags)) != 0) @@ -517,16 +516,16 @@ char *_my_strdup(const char *from, const char *filename, uint lineno, myf MyFlags) { gptr ptr; - uint length=(uint) strlen(from)+1; + size_t length= strlen(from)+1; if ((ptr=_mymalloc(length,filename,lineno,MyFlags)) != 0) memcpy((byte*) ptr, (byte*) from,(size_t) length); return((char*) ptr); } /* _my_strdup */ -char *_my_strdup_with_length(const char *from, uint length, - const char *filename, uint lineno, - myf MyFlags) +char *_my_strdup_with_length(const char *from, size_t length, + const char *filename, uint lineno, + myf MyFlags) { gptr ptr; if ((ptr=_mymalloc(length+1,filename,lineno,MyFlags)) != 0) From f02a1f2c9191949f85bc61daa3450d13d465bf4f Mon Sep 17 00:00:00 2001 From: "kaa@polly.local" <> Date: Wed, 29 Aug 2007 20:33:44 +0400 Subject: [PATCH 009/203] Limit join_buffer_size, sort_buffer_size and myisam_sort_buffer_size to 4GB on all platforms, since the related code in 5.0 is not 64-bit safe. This is patch is a part of work on bug #5731 and will be null-merged to 5.1. --- sql/mysqld.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 08c2b60fa79..967b94d6b5c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5829,7 +5829,7 @@ log and this option does nothing anymore.", "The size of the buffer that is used for full joins.", (gptr*) &global_system_variables.join_buff_size, (gptr*) &max_system_variables.join_buff_size, 0, GET_ULONG, - REQUIRED_ARG, 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ~0L, MALLOC_OVERHEAD, + REQUIRED_ARG, 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, UINT_MAX32, MALLOC_OVERHEAD, IO_SIZE, 0}, {"keep_files_on_create", OPT_KEEP_FILES_ON_CREATE, "Don't overwrite stale .MYD and .MYI even if no directory is specified.", @@ -5998,7 +5998,7 @@ The minimum value for this variable is 4096.", "The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE.", (gptr*) &global_system_variables.myisam_sort_buff_size, (gptr*) &max_system_variables.myisam_sort_buff_size, 0, - GET_ULONG, REQUIRED_ARG, 8192*1024, 4, ~0L, 0, 1, 0}, + GET_ULONG, REQUIRED_ARG, 8192*1024, 4, UINT_MAX32, 0, 1, 0}, {"myisam_stats_method", OPT_MYISAM_STATS_METHOD, "Specifies how MyISAM index statistics collection code should threat NULLs. " "Possible values of name are \"nulls_unequal\" (default behavior for 4.1/5.0), " @@ -6144,7 +6144,7 @@ The minimum value for this variable is 4096.", "Each thread that needs to do a sort allocates a buffer of this size.", (gptr*) &global_system_variables.sortbuff_size, (gptr*) &max_system_variables.sortbuff_size, 0, GET_ULONG, REQUIRED_ARG, - MAX_SORT_MEMORY, MIN_SORT_MEMORY+MALLOC_OVERHEAD*2, ~0L, MALLOC_OVERHEAD, + MAX_SORT_MEMORY, MIN_SORT_MEMORY+MALLOC_OVERHEAD*2, UINT_MAX32, MALLOC_OVERHEAD, 1, 0}, #ifdef HAVE_BERKELEY_DB {"sync-bdb-logs", OPT_BDB_SYNC, From ab0373e78a5a711fdcd58c66119a72e6279e5547 Mon Sep 17 00:00:00 2001 From: "kaa@polly.local" <> Date: Wed, 29 Aug 2007 20:45:04 +0400 Subject: [PATCH 010/203] Backport of the keycache changes from http://lists.mysql.com/commits/31517 to make keycache 64-bit safe in 5.0. This is for bug #5731. --- include/keycache.h | 10 +++++----- mysys/mf_keycache.c | 25 +++++++++++++------------ 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/include/keycache.h b/include/keycache.h index 54c099fc474..424b4086cb4 100644 --- a/include/keycache.h +++ b/include/keycache.h @@ -46,7 +46,7 @@ typedef struct st_key_cache my_bool key_cache_inited; my_bool resize_in_flush; /* true during flush of resize operation */ my_bool can_be_used; /* usage of cache for read/write is allowed */ - ulong key_cache_mem_size; /* specified size of the cache memory */ + size_t key_cache_mem_size; /* specified size of the cache memory */ uint key_cache_block_size; /* size of the page buffer of a cache block */ ulong min_warm_blocks; /* min number of warm blocks; */ ulong age_threshold; /* age threshold for hot blocks */ @@ -101,11 +101,11 @@ typedef struct st_key_cache extern KEY_CACHE dflt_key_cache_var, *dflt_key_cache; extern int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, - ulong use_mem, uint division_limit, - uint age_threshold); + size_t use_mem, uint division_limit, + uint age_threshold); extern int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, - ulong use_mem, uint division_limit, - uint age_threshold); + size_t use_mem, uint division_limit, + uint age_threshold); extern void change_key_cache_param(KEY_CACHE *keycache, uint division_limit, uint age_threshold); extern byte *key_cache_read(KEY_CACHE *keycache, diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index af910678a1f..83363e6960d 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -301,10 +301,11 @@ static uint next_power(uint value) */ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, - ulong use_mem, uint division_limit, - uint age_threshold) + size_t use_mem, uint division_limit, + uint age_threshold) { - uint blocks, hash_links, length; + ulong blocks, hash_links; + size_t length; int error; DBUG_ENTER("init_key_cache"); DBUG_ASSERT(key_cache_block_size >= 512); @@ -332,8 +333,8 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, DBUG_PRINT("info", ("key_cache_block_size: %u", key_cache_block_size)); - blocks= (uint) (use_mem / (sizeof(BLOCK_LINK) + 2 * sizeof(HASH_LINK) + - sizeof(HASH_LINK*) * 5/4 + key_cache_block_size)); + blocks= (ulong) (use_mem / (sizeof(BLOCK_LINK) + 2 * sizeof(HASH_LINK) + + sizeof(HASH_LINK*) * 5/4 + key_cache_block_size)); /* It doesn't make sense to have too few blocks (less than 8) */ if (blocks >= 8 && keycache->disk_blocks < 0) { @@ -351,18 +352,18 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, ALIGN_SIZE(hash_links * sizeof(HASH_LINK)) + ALIGN_SIZE(sizeof(HASH_LINK*) * keycache->hash_entries))) + - ((ulong) blocks * keycache->key_cache_block_size) > use_mem) + ((size_t) blocks * keycache->key_cache_block_size) > use_mem) blocks--; /* Allocate memory for cache page buffers */ if ((keycache->block_mem= - my_large_malloc((ulong) blocks * keycache->key_cache_block_size, - MYF(MY_WME)))) + my_large_malloc((size_t) blocks * keycache->key_cache_block_size, + MYF(MY_WME)))) { /* Allocate memory for blocks, hash_links and hash entries; For each block 2 hash links are allocated */ - if ((keycache->block_root= (BLOCK_LINK*) my_malloc((uint) length, + if ((keycache->block_root= (BLOCK_LINK*) my_malloc(length, MYF(0)))) break; my_large_free(keycache->block_mem, MYF(0)); @@ -375,7 +376,7 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, } blocks= blocks / 4*3; } - keycache->blocks_unused= (ulong) blocks; + keycache->blocks_unused= blocks; keycache->disk_blocks= (int) blocks; keycache->hash_links= hash_links; keycache->hash_root= (HASH_LINK**) ((char*) keycache->block_root + @@ -480,8 +481,8 @@ err: */ int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, - ulong use_mem, uint division_limit, - uint age_threshold) + size_t use_mem, uint division_limit, + uint age_threshold) { int blocks; struct st_my_thread_var *thread; From 0c199938073a2f1359732568707c430f3f0a473f Mon Sep 17 00:00:00 2001 From: "kaa@polly.(none)" <> Date: Mon, 3 Sep 2007 12:57:47 +0400 Subject: [PATCH 011/203] Use SIZE_T_MAX instead of ulong as a limit for key_buffer_size to allow key_bufer_size > 4G on Windows in 5.1. This is for bug #5731. --- include/my_global.h | 3 +++ sql/mysqld.cc | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/my_global.h b/include/my_global.h index 8b6cdef8daa..b9452adebbb 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -863,6 +863,9 @@ typedef SOCKET_SIZE_TYPE size_socket; #ifndef SSIZE_MAX #define SSIZE_MAX ((~((size_t) 0)) / 2) #endif +#ifndef SIZE_T_MAX +#define SIZE_T_MAX ~((size_t) 0) +#endif #ifndef HAVE_FINITE #define finite(x) (1.0 / fabs(x) > 0.0) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 6ea1cf111bb..2b7867b4e88 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5969,7 +5969,7 @@ log and this option does nothing anymore.", (uchar**) &dflt_key_cache_var.param_buff_size, (uchar**) 0, 0, (GET_ULL | GET_ASK_ADDR), - REQUIRED_ARG, KEY_CACHE_SIZE, MALLOC_OVERHEAD, ~(ulong) 0, MALLOC_OVERHEAD, + REQUIRED_ARG, KEY_CACHE_SIZE, MALLOC_OVERHEAD, SIZE_T_MAX, MALLOC_OVERHEAD, IO_SIZE, 0}, {"key_cache_age_threshold", OPT_KEY_CACHE_AGE_THRESHOLD, "This characterizes the number of hits a hot block has to be untouched until it is considered aged enough to be downgraded to a warm block. This specifies the percentage ratio of that number of hits to the total number of blocks in key cache", From d8e67d455665e06e607fdd43f3e81e3668f76b2e Mon Sep 17 00:00:00 2001 From: "dkatz@damien-katzs-computer.local" <> Date: Wed, 5 Sep 2007 15:06:10 -0400 Subject: [PATCH 012/203] Bug #29804 UDF parameters don't contain correct string length Previously, UDF *_init functions were passed constant strings with erroneous lengths. The length came from the containing variable's size, not the length of the value itself. Now the *_init functions get the constant as a null terminated string with the correct length supplied too. --- mysql-test/r/udf.result | 24 ++++++++++++++++++++++++ mysql-test/t/udf.test | 36 ++++++++++++++++++++++++++++++++++++ sql/item_func.cc | 3 ++- sql/udf_example.c | 35 +++++++++++++++++++++++++++++++++++ sql/udf_example.def | 2 ++ 5 files changed, 99 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/udf.result b/mysql-test/r/udf.result index 2e9cf217ed6..885f5f8078e 100644 --- a/mysql-test/r/udf.result +++ b/mysql-test/r/udf.result @@ -296,4 +296,28 @@ Qcache_queries_in_cache 0 drop table t1; drop function metaphon; set GLOBAL query_cache_size=default; +CREATE TABLE const_len_bug ( +str_const varchar(4000), +result1 varchar(4000), +result2 varchar(4000) +); +CREATE TRIGGER check_const_len_trigger BEFORE INSERT ON const_len_bug FOR EACH ROW BEGIN +set NEW.str_const = 'bar'; +set NEW.result2 = check_const_len(NEW.str_const); +END | +CREATE PROCEDURE check_const_len_sp (IN str_const VARCHAR(4000)) +BEGIN +DECLARE result VARCHAR(4000); +SET result = check_const_len(str_const); +insert into const_len_bug values(str_const, result, ""); +END | +CREATE FUNCTION check_const_len RETURNS string SONAME "UDF_EXAMPLE_LIB"; +CALL check_const_len_sp("foo"); +SELECT * from const_len_bug; +str_const result1 result2 +bar Correct length Correct length +DROP FUNCTION check_const_len; +DROP PROCEDURE check_const_len_sp; +DROP TRIGGER check_const_len_trigger; +DROP TABLE const_len_bug; End of 5.0 tests. diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test index 75af1f4be4b..beb18206a2e 100644 --- a/mysql-test/t/udf.test +++ b/mysql-test/t/udf.test @@ -312,4 +312,40 @@ drop function metaphon; set GLOBAL query_cache_size=default; +# +# Bug #29804 UDF parameters don't contain correct string length +# + +CREATE TABLE const_len_bug ( + str_const varchar(4000), + result1 varchar(4000), + result2 varchar(4000) +); + +DELIMITER |; +CREATE TRIGGER check_const_len_trigger BEFORE INSERT ON const_len_bug FOR EACH ROW BEGIN + set NEW.str_const = 'bar'; + set NEW.result2 = check_const_len(NEW.str_const); +END | + +CREATE PROCEDURE check_const_len_sp (IN str_const VARCHAR(4000)) +BEGIN +DECLARE result VARCHAR(4000); +SET result = check_const_len(str_const); +insert into const_len_bug values(str_const, result, ""); +END | +DELIMITER ;| + +--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB +eval CREATE FUNCTION check_const_len RETURNS string SONAME "$UDF_EXAMPLE_LIB"; + +CALL check_const_len_sp("foo"); + +SELECT * from const_len_bug; + +DROP FUNCTION check_const_len; +DROP PROCEDURE check_const_len_sp; +DROP TRIGGER check_const_len_trigger; +DROP TABLE const_len_bug; + --echo End of 5.0 tests. diff --git a/sql/item_func.cc b/sql/item_func.cc index c70cfa1ce2a..21579763635 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2924,7 +2924,8 @@ udf_handler::fix_fields(THD *thd, Item_result_field *func, String *res= arguments[i]->val_str(&buffers[i]); if (arguments[i]->null_value) continue; - f_args.args[i]= (char*) res->ptr(); + f_args.args[i]= (char*) res->c_ptr(); + f_args.lengths[i]= res->length(); break; } case INT_RESULT: diff --git a/sql/udf_example.c b/sql/udf_example.c index 0f28c2a14b0..df3a69755ad 100644 --- a/sql/udf_example.c +++ b/sql/udf_example.c @@ -1106,4 +1106,39 @@ char * is_const(UDF_INIT *initid, UDF_ARGS *args __attribute__((unused)), } + +my_bool check_const_len_init(UDF_INIT *initid, UDF_ARGS *args, char *message) +{ + if (args->arg_count != 1) + { + strmov(message, "CHECK_CONST_LEN accepts only one argument"); + return 1; + } + if (args->args[0] == 0) + { + initid->ptr= (char*)"Not constant"; + } + else if(strlen(args->args[0]) == args->lengths[0]) + { + initid->ptr= (char*)"Correct length"; + } + else + { + initid->ptr= (char*)"Wrong length"; + } + initid->max_length = 100; + return 0; +} + +char * check_const_len(UDF_INIT *initid, UDF_ARGS *args __attribute__((unused)), + char *result, unsigned long *length, + char *is_null, char *error __attribute__((unused))) +{ + strmov(result, initid->ptr); + *length= strlen(result); + *is_null= 0; + return result; +} + + #endif /* HAVE_DLOPEN */ diff --git a/sql/udf_example.def b/sql/udf_example.def index 7a87147d7b6..3d569941cc8 100644 --- a/sql/udf_example.def +++ b/sql/udf_example.def @@ -23,3 +23,5 @@ EXPORTS avgcost is_const is_const_init + check_const_len + check_const_len_init From 8da409ac16e88ef4fff170521277b3ecb63489c6 Mon Sep 17 00:00:00 2001 From: "kaa@polly.(none)" <> Date: Fri, 7 Sep 2007 11:58:04 +0400 Subject: [PATCH 013/203] This patch is a part of work on bug #5731 "key_buffer_size not properly restricted to 4GB". The patch limits read_buffer_size and read_rnd_buffer_size by 2 GB on all platforms for the following reasons: - I/O code in mysys, code in mf_iocache.c and in some storage engines do not currently work with sizes > 2 GB for those buffers - even if the above had been fixed, Windows POSIX read() and write() calls are not 2GB-safe, so setting those buffer to sizes > 2GB would not work correctly on 64-bit Windows. --- include/my_global.h | 3 --- mysql-test/r/bdb_notembedded.result | 35 ++++++++++++++++++++++++++ mysql-test/t/bdb_notembedded.test | 38 +++++++++++++++++++++++++++++ sql/mysqld.cc | 6 ++--- 4 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 mysql-test/r/bdb_notembedded.result create mode 100644 mysql-test/t/bdb_notembedded.test diff --git a/include/my_global.h b/include/my_global.h index b91ff8a9e5b..7d34549c8b6 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -808,9 +808,6 @@ typedef SOCKET_SIZE_TYPE size_socket; #define DBL_MAX 1.79769313486231470e+308 #define FLT_MAX ((float)3.40282346638528860e+38) #endif -#ifndef SSIZE_MAX -#define SSIZE_MAX ((~((size_t) 0)) / 2) -#endif #if !defined(HAVE_ISINF) && !defined(isinf) #define isinf(X) 0 diff --git a/mysql-test/r/bdb_notembedded.result b/mysql-test/r/bdb_notembedded.result new file mode 100644 index 00000000000..14cb5fad915 --- /dev/null +++ b/mysql-test/r/bdb_notembedded.result @@ -0,0 +1,35 @@ +set autocommit=1; +reset master; +create table bug16206 (a int); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 +f n Query 1 n use `test`; create table bug16206 (a int) +f n Query 1 n use `test`; insert into bug16206 values(1) +f n Query 1 n use `test`; insert into bug16206 values(2) +drop table bug16206; +reset master; +create table bug16206 (a int) engine= bdb; +insert into bug16206 values(0); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +insert into bug16206 values(3); +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 +f n Query 1 n use `test`; create table bug16206 (a int) engine= bdb +f n Query 1 n use `test`; insert into bug16206 values(0) +f n Query 1 n use `test`; insert into bug16206 values(1) +f n Query 1 n use `test`; BEGIN +f n Query 1 n use `test`; insert into bug16206 values(2) +f n Query 1 n use `test`; COMMIT +f n Query 1 n use `test`; insert into bug16206 values(3) +drop table bug16206; +set autocommit=0; +End of 5.0 tests diff --git a/mysql-test/t/bdb_notembedded.test b/mysql-test/t/bdb_notembedded.test new file mode 100644 index 00000000000..24e64ebbfb2 --- /dev/null +++ b/mysql-test/t/bdb_notembedded.test @@ -0,0 +1,38 @@ +-- source include/not_embedded.inc +-- source include/have_bdb.inc + +# +# Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit mode +# +set autocommit=1; + +let $VERSION=`select version()`; + +reset master; +create table bug16206 (a int); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +--replace_result $VERSION VERSION +--replace_column 1 f 2 n 5 n +show binlog events; +drop table bug16206; + +reset master; +create table bug16206 (a int) engine= bdb; +insert into bug16206 values(0); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +insert into bug16206 values(3); +--replace_result $VERSION VERSION +--replace_column 1 f 2 n 5 n +show binlog events; +drop table bug16206; + +set autocommit=0; + + +--echo End of 5.0 tests diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 5a805b586fd..5c6294c2315 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5948,7 +5948,7 @@ The minimum value for this variable is 4096.", "Each thread that does a sequential scan allocates a buffer of this size for each table it scans. If you do many sequential scans, you may want to increase this value.", (gptr*) &global_system_variables.read_buff_size, (gptr*) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG, - 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, SSIZE_MAX, MALLOC_OVERHEAD, IO_SIZE, + 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, INT_MAX32, MALLOC_OVERHEAD, IO_SIZE, 0}, {"read_only", OPT_READONLY, "Make all non-temporary tables read-only, with the exception for replication (slave) threads and users with the SUPER privilege", @@ -5960,12 +5960,12 @@ The minimum value for this variable is 4096.", (gptr*) &global_system_variables.read_rnd_buff_size, (gptr*) &max_system_variables.read_rnd_buff_size, 0, GET_ULONG, REQUIRED_ARG, 256*1024L, IO_SIZE*2+MALLOC_OVERHEAD, - SSIZE_MAX, MALLOC_OVERHEAD, IO_SIZE, 0}, + INT_MAX32, MALLOC_OVERHEAD, IO_SIZE, 0}, {"record_buffer", OPT_RECORD_BUFFER, "Alias for read_buffer_size", (gptr*) &global_system_variables.read_buff_size, (gptr*) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG, - 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, SSIZE_MAX, MALLOC_OVERHEAD, IO_SIZE, 0}, + 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, INT_MAX32, MALLOC_OVERHEAD, IO_SIZE, 0}, #ifdef HAVE_REPLICATION {"relay_log_purge", OPT_RELAY_LOG_PURGE, "0 = do not purge relay logs. 1 = purge them as soon as they are no more needed.", From 18300001c1dbbfddf9a0adcbaeea68956102bdd0 Mon Sep 17 00:00:00 2001 From: "malff@lambda.weblab" <> Date: Mon, 10 Sep 2007 16:10:37 -0600 Subject: [PATCH 014/203] WL#4030 (Deprecate RENAME DATABASE: replace with ALTER DATABASE UPGRADE) Bug 17565 (RENAME DATABASE destroys events) Bug#28360 (RENAME DATABASE destroys routines) Removed the RENAME DATABASE db1 TO db2 statement. Implemented the ALTER DATABASE db UPGRADE DATA DIRECTORY NAME statement, which has the same function. --- client/mysqlcheck.c | 25 +++++-- mysql-test/r/create.result | 8 --- mysql-test/r/query_cache.result | 49 ------------- mysql-test/r/renamedb.result | 43 +++--------- mysql-test/r/sp-code.result | 4 +- mysql-test/r/sp-error.result | 13 ++++ mysql-test/r/upgrade.result | 25 +++++++ mysql-test/t/create.test | 19 ++--- mysql-test/t/query_cache.test | 80 +++++++++++----------- mysql-test/t/renamedb.test | 71 +++++++++++++------ mysql-test/t/sp-error.test | 28 ++++++++ mysql-test/t/upgrade.test | 31 +++++++++ sql/mysql_priv.h | 2 +- sql/sql_db.cc | 118 +++++++++++--------------------- sql/sql_lex.h | 3 +- sql/sql_parse.cc | 26 +++---- sql/sql_prepare.cc | 2 +- sql/sql_yacc.yy | 32 ++++----- 18 files changed, 296 insertions(+), 283 deletions(-) diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 316412d7df9..6d85e30c033 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -539,13 +539,13 @@ static int process_all_tables_in_db(char *database) -static int fix_object_name(const char *obj, const char *name) +static int fix_table_storage_name(const char *name) { char qbuf[100 + NAME_LEN*4]; int rc= 0; if (strncmp(name, "#mysql50#", 9)) return 1; - sprintf(qbuf, "RENAME %s `%s` TO `%s`", obj, name, name + 9); + sprintf(qbuf, "RENAME TABLE `%s` TO `%s`", name, name + 9); if (mysql_query(sock, qbuf)) { fprintf(stderr, "Failed to %s\n", qbuf); @@ -557,6 +557,23 @@ static int fix_object_name(const char *obj, const char *name) return rc; } +static int fix_database_storage_name(const char *name) +{ + char qbuf[100 + NAME_LEN*4]; + int rc= 0; + if (strncmp(name, "#mysql50#", 9)) + return 1; + sprintf(qbuf, "ALTER DATABASE `%s` UPGRADE DATA DIRECTORY NAME", name); + if (mysql_query(sock, qbuf)) + { + fprintf(stderr, "Failed to %s\n", qbuf); + fprintf(stderr, "Error: %s\n", mysql_error(sock)); + rc= 1; + } + if (verbose) + printf("%-50s %s\n", name, rc ? "FAILED" : "OK"); + return rc; +} static int process_one_db(char *database) { @@ -565,7 +582,7 @@ static int process_one_db(char *database) int rc= 0; if (opt_fix_db_names && !strncmp(database,"#mysql50#", 9)) { - rc= fix_object_name("DATABASE", database); + rc= fix_database_storage_name(database); database+= 9; } if (rc || !opt_fix_table_names) @@ -620,7 +637,7 @@ static int handle_request_for_tables(char *tables, uint length) op= (opt_write_binlog) ? "OPTIMIZE" : "OPTIMIZE NO_WRITE_TO_BINLOG"; break; case DO_UPGRADE: - return fix_object_name("TABLE", tables); + return fix_table_storage_name(tables); } if (!(query =(char *) my_malloc((sizeof(char)*(length+110)), MYF(MY_WME)))) diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 84a620336dc..82bcc68f319 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -1588,14 +1588,6 @@ CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ERROR 42000: Incorrect database name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' DROP DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; ERROR 42000: Incorrect database name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' -RENAME DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa TO a; -ERROR 42000: Unknown database 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' -RENAME DATABASE mysqltest TO aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; -ERROR 42000: Incorrect database name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' -create database mysqltest; -RENAME DATABASE mysqltest TO aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; -ERROR 42000: Incorrect database name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' -drop database mysqltest; USE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; ERROR 42000: Incorrect database name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' SHOW CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index 321b08628ee..5a15a87bd3c 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -1684,52 +1684,3 @@ set GLOBAL query_cache_limit=default; set GLOBAL query_cache_min_res_unit=default; set GLOBAL query_cache_size=default; End of 5.0 tests -drop database if exists db1; -drop database if exists db2; -set GLOBAL query_cache_size=15*1024*1024; -create database db1; -use db1; -create table t1(c1 int)engine=myisam; -insert into t1(c1) values (1); -select * from db1.t1 f; -c1 -1 -show status like 'Qcache_queries_in_cache'; -Variable_name Value -Qcache_queries_in_cache 1 -rename schema db1 to db2; -show status like 'Qcache_queries_in_cache'; -Variable_name Value -Qcache_queries_in_cache 0 -drop database db2; -set global query_cache_size=default; -drop database if exists db1; -drop database if exists db3; -set GLOBAL query_cache_size=15*1024*1024; -create database db1; -create database db3; -use db1; -create table t1(c1 int) engine=myisam; -use db3; -create table t1(c1 int) engine=myisam; -use db1; -insert into t1(c1) values (1); -use mysql; -select * from db1.t1; -c1 -1 -select c1+1 from db1.t1; -c1+1 -2 -select * from db3.t1; -c1 -show status like 'Qcache_queries_in_cache'; -Variable_name Value -Qcache_queries_in_cache 3 -rename schema db1 to db2; -show status like 'Qcache_queries_in_cache'; -Variable_name Value -Qcache_queries_in_cache 1 -drop database db2; -drop database db3; -End of 5.1 tests diff --git a/mysql-test/r/renamedb.result b/mysql-test/r/renamedb.result index b22322fbe8d..ff8f89592fc 100644 --- a/mysql-test/r/renamedb.result +++ b/mysql-test/r/renamedb.result @@ -1,33 +1,12 @@ -drop database if exists testdb1; -create database testdb1 default character set latin2; -use testdb1; -create table t1 (a int); -insert into t1 values (1),(2),(3); -show create database testdb1; -Database Create Database -testdb1 CREATE DATABASE `testdb1` /*!40100 DEFAULT CHARACTER SET latin2 */ -show tables; -Tables_in_testdb1 -t1 rename database testdb1 to testdb2; -show create database testdb1; -ERROR 42000: Unknown database 'testdb1' -show create database testdb2; -Database Create Database -testdb2 CREATE DATABASE `testdb2` /*!40100 DEFAULT CHARACTER SET latin2 */ -select database(); -database() -testdb2 -show tables; -Tables_in_testdb2 -t1 -select a from t1 order by a; -a -1 -2 -3 -drop database testdb2; -create database testdb1; -rename database testdb1 to testdb1; -ERROR HY000: Can't create database 'testdb1'; database exists -drop database testdb1; +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 'database testdb1 to testdb2' at line 1 +ALTER DATABASE wrong UPGRADE DATA DIRECTORY NAME; +ERROR HY000: Incorrect usage of ALTER DATABASE UPGRADE DATA DIRECTORY NAME and name +ALTER DATABASE `#mysql41#not-supported` UPGRADE DATA DIRECTORY NAME; +ERROR HY000: Incorrect usage of ALTER DATABASE UPGRADE DATA DIRECTORY NAME and name +ALTER DATABASE `#mysql51#not-yet` UPGRADE DATA DIRECTORY NAME; +ERROR HY000: Incorrect usage of ALTER DATABASE UPGRADE DATA DIRECTORY NAME and name +ALTER DATABASE `#mysql50#` UPGRADE DATA DIRECTORY NAME; +ERROR HY000: Incorrect usage of ALTER DATABASE UPGRADE DATA DIRECTORY NAME and name +ALTER DATABASE `#mysql50#upgrade-me` UPGRADE DATA DIRECTORY NAME; +ERROR 42000: Unknown database '#mysql50#upgrade-me' diff --git a/mysql-test/r/sp-code.result b/mysql-test/r/sp-code.result index b2bcfff0fdb..018173e723d 100644 --- a/mysql-test/r/sp-code.result +++ b/mysql-test/r/sp-code.result @@ -155,11 +155,11 @@ Pos Instruction 0 stmt 9 "drop temporary table if exists sudoku..." 1 stmt 1 "create temporary table sudoku_work ( ..." 2 stmt 1 "create temporary table sudoku_schedul..." -3 stmt 95 "call sudoku_init()" +3 stmt 94 "call sudoku_init()" 4 jump_if_not 7(8) p_naive@0 5 stmt 4 "update sudoku_work set cnt = 0 where ..." 6 jump 8 -7 stmt 95 "call sudoku_count()" +7 stmt 94 "call sudoku_count()" 8 stmt 6 "insert into sudoku_schedule (row,col)..." 9 set v_scounter@2 0 10 set v_i@3 1 diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 2e0d437aeb6..bfcd64e89d3 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -1478,3 +1478,16 @@ end until true end repeat retry; end// ERROR 42000: LEAVE with no matching label: retry +drop procedure if exists proc_28360; +drop function if exists func_28360; +CREATE PROCEDURE proc_28360() +BEGIN +ALTER DATABASE `#mysql50#upgrade-me` UPGRADE DATA DIRECTORY NAME; +END// +ERROR HY000: Can't drop or alter a DATABASE from within another stored routine +CREATE FUNCTION func_28360() RETURNS int +BEGIN +ALTER DATABASE `#mysql50#upgrade-me` UPGRADE DATA DIRECTORY NAME; +RETURN 0; +END// +ERROR HY000: Can't drop or alter a DATABASE from within another stored routine diff --git a/mysql-test/r/upgrade.result b/mysql-test/r/upgrade.result index 76e0359c405..adf81efe8e3 100644 --- a/mysql-test/r/upgrade.result +++ b/mysql-test/r/upgrade.result @@ -59,3 +59,28 @@ drop table `txu@0023p@0023p1`; drop table `txu#p#p1`; truncate t1; drop table t1; +drop database if exists `tabc`; +drop database if exists `a-b-c`; +create database `tabc` default character set latin2; +create table tabc.t1 (a int); +FLUSH TABLES; +show databases like '%a-b-c%'; +Database (%a-b-c%) +#mysql50#a-b-c +ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME; +show databases like '%a-b-c%'; +Database (%a-b-c%) +a-b-c +show create database `a-b-c`; +Database Create Database +a-b-c CREATE DATABASE `a-b-c` /*!40100 DEFAULT CHARACTER SET latin2 */ +show tables in `a-b-c`; +Tables_in_a-b-c +t1 +show create table `a-b-c`.`t1`; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin2 +drop database `a-b-c`; +drop database `tabc`; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index 341c019af6e..d4feeebe4b1 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -1197,14 +1197,17 @@ drop table t1,t2; CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; --error 1102 DROP DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; ---error 1049 -RENAME DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa TO a; ---error 1102 -RENAME DATABASE mysqltest TO aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; -create database mysqltest; ---error 1102 -RENAME DATABASE mysqltest TO aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; -drop database mysqltest; + +# TODO: enable these tests when RENAME DATABASE is implemented. +# --error 1049 +# RENAME DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa TO a; +# --error 1102 +# RENAME DATABASE mysqltest TO aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; +# create database mysqltest; +# --error 1102 +# RENAME DATABASE mysqltest TO aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; +# drop database mysqltest; + --error 1102 USE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; --error 1102 diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test index d06698cdb17..2cfe1ff4ccc 100644 --- a/mysql-test/t/query_cache.test +++ b/mysql-test/t/query_cache.test @@ -1293,44 +1293,42 @@ set GLOBAL query_cache_size=default; # # Bug #28211 RENAME DATABASE and query cache don't play nicely together -# ---disable_warnings -drop database if exists db1; -drop database if exists db2; ---enable_warnings -set GLOBAL query_cache_size=15*1024*1024; -create database db1; -use db1; -create table t1(c1 int)engine=myisam; -insert into t1(c1) values (1); -select * from db1.t1 f; -show status like 'Qcache_queries_in_cache'; -rename schema db1 to db2; -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; ---enable_warnings -set GLOBAL query_cache_size=15*1024*1024; -create database db1; -create database db3; -use db1; -create table t1(c1 int) engine=myisam; -use db3; -create table t1(c1 int) engine=myisam; -use db1; -insert into t1(c1) values (1); -use mysql; -select * from db1.t1; -select c1+1 from db1.t1; -select * from db3.t1; -show status like 'Qcache_queries_in_cache'; -rename schema db1 to db2; -show status like 'Qcache_queries_in_cache'; -drop database db2; -drop database db3; - ---echo End of 5.1 tests +# TODO: enable these tests when RENAME DATABASE is implemented. +# --disable_warnings +# drop database if exists db1; +# drop database if exists db2; +# --enable_warnings +# set GLOBAL query_cache_size=15*1024*1024; +# create database db1; +# use db1; +# create table t1(c1 int)engine=myisam; +# insert into t1(c1) values (1); +# select * from db1.t1 f; +# show status like 'Qcache_queries_in_cache'; +# rename schema db1 to db2; +# 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; +# --enable_warnings +# set GLOBAL query_cache_size=15*1024*1024; +# create database db1; +# create database db3; +# use db1; +# create table t1(c1 int) engine=myisam; +# use db3; +# create table t1(c1 int) engine=myisam; +# use db1; +# insert into t1(c1) values (1); +# use mysql; +# select * from db1.t1; +# select c1+1 from db1.t1; +# select * from db3.t1; +# show status like 'Qcache_queries_in_cache'; +# rename schema db1 to db2; +# show status like 'Qcache_queries_in_cache'; +# drop database db2; +# drop database db3; diff --git a/mysql-test/t/renamedb.test b/mysql-test/t/renamedb.test index 1e71adb3bf3..84315090b7a 100644 --- a/mysql-test/t/renamedb.test +++ b/mysql-test/t/renamedb.test @@ -1,26 +1,53 @@ ---disable_warnings -drop database if exists testdb1; ---enable_warnings - -create database testdb1 default character set latin2; -use testdb1; -create table t1 (a int); -insert into t1 values (1),(2),(3); -show create database testdb1; -show tables; -rename database testdb1 to testdb2; ---error 1049 -show create database testdb1; -show create database testdb2; -select database(); -show tables; -select a from t1 order by a; -drop database testdb2; +# TODO: enable these tests when RENAME DATABASE is implemented. +# +# --disable_warnings +# drop database if exists testdb1; +# --enable_warnings +# +# create database testdb1 default character set latin2; +# use testdb1; +# create table t1 (a int); +# insert into t1 values (1),(2),(3); +# show create database testdb1; +# show tables; +# rename database testdb1 to testdb2; +# --error 1049 +# show create database testdb1; +# show create database testdb2; +# select database(); +# show tables; +# select a from t1 order by a; +# drop database testdb2; +# # # Bug#19392 Rename Database: Crash if case change # -create database testdb1; ---error 1007 -rename database testdb1 to testdb1; -drop database testdb1; +# create database testdb1; +# --error 1007 +# rename database testdb1 to testdb1; +# drop database testdb1; + +# +# WL#4030 (Deprecate RENAME DATABASE: replace with ALTER DATABASE UPGRADE) +# + +--error ER_PARSE_ERROR +rename database testdb1 to testdb2; + +--error ER_WRONG_USAGE +ALTER DATABASE wrong UPGRADE DATA DIRECTORY NAME; + +--error ER_WRONG_USAGE +ALTER DATABASE `#mysql41#not-supported` UPGRADE DATA DIRECTORY NAME; + +--error ER_WRONG_USAGE +ALTER DATABASE `#mysql51#not-yet` UPGRADE DATA DIRECTORY NAME; + +--error ER_WRONG_USAGE +ALTER DATABASE `#mysql50#` UPGRADE DATA DIRECTORY NAME; + +--error ER_BAD_DB_ERROR +ALTER DATABASE `#mysql50#upgrade-me` UPGRADE DATA DIRECTORY NAME; + + diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index 012f2b33225..c9145859405 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -2150,6 +2150,34 @@ end// delimiter ;// + +# +# Bug#28360 (RENAME DATABASE destroys routines) +# + +--disable_warnings +drop procedure if exists proc_28360; +drop function if exists func_28360; +--enable_warnings + +delimiter //; + +--error ER_SP_NO_DROP_SP +CREATE PROCEDURE proc_28360() +BEGIN + ALTER DATABASE `#mysql50#upgrade-me` UPGRADE DATA DIRECTORY NAME; +END// + +--error ER_SP_NO_DROP_SP +CREATE FUNCTION func_28360() RETURNS int +BEGIN + ALTER DATABASE `#mysql50#upgrade-me` UPGRADE DATA DIRECTORY NAME; + RETURN 0; +END// + +delimiter ;// + + # # BUG#NNNN: New bug synopsis # diff --git a/mysql-test/t/upgrade.test b/mysql-test/t/upgrade.test index f517c7787f8..40bd17fc3a5 100644 --- a/mysql-test/t/upgrade.test +++ b/mysql-test/t/upgrade.test @@ -56,3 +56,34 @@ system cp $MYSQL_TEST_DIR/std_data/old_table-323.frm $MYSQLTEST_VARDIR/master-da truncate t1; drop table t1; +# +# Bug#28360 (RENAME DATABASE destroys routines) +# + + +--disable_warnings +drop database if exists `tabc`; +drop database if exists `a-b-c`; +--enable_warnings + +create database `tabc` default character set latin2; +create table tabc.t1 (a int); +FLUSH TABLES; + +# Manually make a 5.0 database from the template +--exec mkdir $MYSQLTEST_VARDIR/master-data/a-b-c +--copy_file $MYSQLTEST_VARDIR/master-data/tabc/db.opt $MYSQLTEST_VARDIR/master-data/a-b-c/db.opt +--copy_file $MYSQLTEST_VARDIR/master-data/tabc/t1.frm $MYSQLTEST_VARDIR/master-data/a-b-c/t1.frm +--copy_file $MYSQLTEST_VARDIR/master-data/tabc/t1.MYD $MYSQLTEST_VARDIR/master-data/a-b-c/t1.MYD +--copy_file $MYSQLTEST_VARDIR/master-data/tabc/t1.MYI $MYSQLTEST_VARDIR/master-data/a-b-c/t1.MYI + +show databases like '%a-b-c%'; +ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME; +# The physical directory name is now a@002db@002dc, the logical name still a-b-c +show databases like '%a-b-c%'; +show create database `a-b-c`; +show tables in `a-b-c`; +show create table `a-b-c`.`t1`; +drop database `a-b-c`; +drop database `tabc`; + diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 47a42354423..6a7e3e00f6f 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -923,7 +923,7 @@ void end_connection(THD *thd); bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create, bool silent); bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create); bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent); -bool mysql_rename_db(THD *thd, LEX_STRING *old_db, LEX_STRING *new_db); +bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db); void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, ushort flags); void mysql_client_binlog_statement(THD *thd); bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists, diff --git a/sql/sql_db.cc b/sql/sql_db.cc index cd7ad048802..abbf2131957 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -1727,41 +1727,21 @@ lock_databases(THD *thd, const char *db1, uint length1, } -/* - Rename database. +/** + Upgrade a 5.0 database. + This function is invoked whenever an ALTER DATABASE UPGRADE query is executed: + ALTER DATABASE 'olddb' UPGRADE DATA DIRECTORY NAME. - SYNOPSIS - mysql_rename_db() - thd Thread handler - olddb Old database name - newdb New database name + If we have managed to rename (move) tables to the new database + but something failed on a later step, then we store the + RENAME DATABASE event in the log. mysql_rename_db() is atomic in + the sense that it will rename all or none of the tables. - DESCRIPTION - This function is invoked whenever a RENAME DATABASE query is executed: - - RENAME DATABASE 'olddb' TO 'newdb'. - - NOTES - - If we have managed to rename (move) tables to the new database - but something failed on a later step, then we store the - RENAME DATABASE event in the log. mysql_rename_db() is atomic in - the sense that it will rename all or none of the tables. - - TODO: - - Better trigger, stored procedure, event, grant handling, - see the comments below. - NOTE: It's probably a good idea to call wait_if_global_read_lock() - once in mysql_rename_db(), instead of locking inside all - the required functions for renaming triggerts, SP, events, grants, etc. - - RETURN VALUES - 0 ok - 1 error + @param thd Current thread + @param old_db 5.0 database name, in #mysql50#name format + @return 0 on success, 1 on error */ - - -bool mysql_rename_db(THD *thd, LEX_STRING *old_db, LEX_STRING *new_db) +bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db) { int error= 0, change_to_newdb= 0; char path[FN_REFLEN+16]; @@ -1770,11 +1750,27 @@ bool mysql_rename_db(THD *thd, LEX_STRING *old_db, LEX_STRING *new_db) MY_DIR *dirp; TABLE_LIST *table_list; SELECT_LEX *sl= thd->lex->current_select; - DBUG_ENTER("mysql_rename_db"); + LEX_STRING new_db; + DBUG_ENTER("mysql_upgrade_db"); + + if ((old_db->length <= MYSQL50_TABLE_NAME_PREFIX_LENGTH) || + (strncmp(old_db->str, + MYSQL50_TABLE_NAME_PREFIX, + MYSQL50_TABLE_NAME_PREFIX_LENGTH) != 0)) + { + my_error(ER_WRONG_USAGE, MYF(0), + "ALTER DATABASE UPGRADE DATA DIRECTORY NAME", + "name"); + DBUG_RETURN(1); + } + + /* `#mysql50#` converted to encoded `` */ + new_db.str= old_db->str + MYSQL50_TABLE_NAME_PREFIX_LENGTH; + new_db.length= old_db->length - MYSQL50_TABLE_NAME_PREFIX_LENGTH; if (lock_databases(thd, old_db->str, old_db->length, - new_db->str, new_db->length)) - return 1; + new_db.str, new_db.length)) + DBUG_RETURN(1); /* Let's remember if we should do "USE newdb" afterwards. @@ -1798,7 +1794,7 @@ bool mysql_rename_db(THD *thd, LEX_STRING *old_db, LEX_STRING *new_db) } /* Step1: Create the new database */ - if ((error= mysql_create_db(thd, new_db->str, &create_info, 1))) + if ((error= mysql_create_db(thd, new_db.str, &create_info, 1))) goto exit; /* Step2: Move tables to the new database */ @@ -1819,12 +1815,12 @@ bool mysql_rename_db(THD *thd, LEX_STRING *old_db, LEX_STRING *new_db) /* A frm file found, add the table info rename list */ *extension= '\0'; - + table_str.length= filename_to_tablename(file->name, tname, sizeof(tname)-1); table_str.str= (char*) sql_memdup(tname, table_str.length + 1); Table_ident *old_ident= new Table_ident(thd, *old_db, table_str, 0); - Table_ident *new_ident= new Table_ident(thd, *new_db, table_str, 0); + Table_ident *new_ident= new Table_ident(thd, new_db, table_str, 0); if (!old_ident || !new_ident || !sl->add_table_to_list(thd, old_ident, NULL, TL_OPTION_UPDATING, TL_IGNORE) || @@ -1854,9 +1850,9 @@ bool mysql_rename_db(THD *thd, LEX_STRING *old_db, LEX_STRING *new_db) It garantees we never loose any tables. */ build_table_filename(path, sizeof(path)-1, - new_db->str,"",MY_DB_OPT_FILE, 0); + new_db.str,"",MY_DB_OPT_FILE, 0); my_delete(path, MYF(MY_WME)); - length= build_table_filename(path, sizeof(path)-1, new_db->str, "", "", 0); + length= build_table_filename(path, sizeof(path)-1, new_db.str, "", "", 0); if (length && path[length-1] == FN_LIBCHAR) path[length-1]=0; // remove ending '\' rmdir(path); @@ -1910,46 +1906,12 @@ bool mysql_rename_db(THD *thd, LEX_STRING *old_db, LEX_STRING *new_db) build_table_filename(oldname, sizeof(oldname)-1, old_db->str, "", file->name, 0); build_table_filename(newname, sizeof(newname)-1, - new_db->str, "", file->name, 0); + new_db.str, "", file->name, 0); my_rename(oldname, newname, MYF(MY_WME)); } - my_dirend(dirp); + my_dirend(dirp); } - /* - Step4: TODO: moving stored procedures in the 'proc' system table - We need a new function: sp_move_db_routines(thd, olddb, newdb) - Which will basically have the same effect with: - UPDATE proc SET db='newdb' WHERE db='olddb' - Note, for 5.0 to 5.1 upgrade purposes we don't really need it. - - The biggest problem here is that we can't have a lock on LOCK_open() while - calling open_table() for 'proc'. - - Two solutions: - - Start by opening the 'event' and 'proc' (and other) tables for write - even before creating the 'to' database. (This will have the nice - effect of blocking another 'rename database' while the lock is active). - - Use the solution "Disable create of new tables during lock table" - - For an example of how to read through all rows, see: - sql_help.cc::search_topics() - */ - - /* - Step5: TODO: moving events in the 'event' system table - We need a new function evex_move_db_events(thd, olddb, newdb) - Which will have the same effect with: - UPDATE event SET db='newdb' WHERE db='olddb' - Note, for 5.0 to 5.1 upgrade purposes we don't really need it. - */ - - /* - Step6: TODO: moving grants in the 'db', 'tables_priv', 'columns_priv'. - Update each grant table, doing the same with: - UPDATE system_table SET db='newdb' WHERE db='olddb' - */ - /* Step7: drop the old database. remove_db_from_cache(olddb) and query_cache_invalidate(olddb) @@ -1968,13 +1930,13 @@ bool mysql_rename_db(THD *thd, LEX_STRING *old_db, LEX_STRING *new_db) /* Step9: Let's do "use newdb" if we renamed the current database */ if (change_to_newdb) - error|= mysql_change_db(thd, new_db, FALSE); + error|= mysql_change_db(thd, & new_db, FALSE); exit: pthread_mutex_lock(&LOCK_lock_db); /* Remove the databases from db lock cache */ lock_db_delete(old_db->str, old_db->length); - lock_db_delete(new_db->str, new_db->length); + lock_db_delete(new_db.str, new_db.length); creating_database--; /* Signal waiting CREATE TABLE's to continue */ pthread_cond_signal(&COND_refresh); diff --git a/sql/sql_lex.h b/sql/sql_lex.h index da0134a7f72..ae689be263e 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -78,7 +78,6 @@ enum enum_sql_command { SQLCOM_LOAD,SQLCOM_SET_OPTION,SQLCOM_LOCK_TABLES,SQLCOM_UNLOCK_TABLES, SQLCOM_GRANT, SQLCOM_CHANGE_DB, SQLCOM_CREATE_DB, SQLCOM_DROP_DB, SQLCOM_ALTER_DB, - SQLCOM_RENAME_DB, SQLCOM_REPAIR, SQLCOM_REPLACE, SQLCOM_REPLACE_SELECT, SQLCOM_CREATE_FUNCTION, SQLCOM_DROP_FUNCTION, SQLCOM_REVOKE,SQLCOM_OPTIMIZE, SQLCOM_CHECK, @@ -117,6 +116,7 @@ enum enum_sql_command { SQLCOM_CREATE_EVENT, SQLCOM_ALTER_EVENT, SQLCOM_DROP_EVENT, SQLCOM_SHOW_CREATE_EVENT, SQLCOM_SHOW_EVENTS, SQLCOM_SHOW_CREATE_TRIGGER, + SQLCOM_ALTER_DB_UPGRADE, /* This should be the last !!! */ @@ -1550,7 +1550,6 @@ typedef struct st_lex : public Query_tables_list required a local context, the parser pops the top-most context. */ List context_stack; - List db_list; SQL_LIST proc_list, auxiliary_table_list, save_list; Create_field *last_field; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index bbd6cb16d11..6002d7545ba 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3175,12 +3175,9 @@ end_with_restore_list: res= mysql_rm_db(thd, lex->name.str, lex->drop_if_exists, 0); break; } - case SQLCOM_RENAME_DB: + case SQLCOM_ALTER_DB_UPGRADE: { - LEX_STRING *olddb, *newdb; - List_iterator db_list(lex->db_list); - olddb= db_list++; - newdb= db_list++; + LEX_STRING *db= & lex->name; if (end_active_trans(thd)) { res= 1; @@ -3188,24 +3185,22 @@ end_with_restore_list: } #ifdef HAVE_REPLICATION if (thd->slave_thread && - (!rpl_filter->db_ok(olddb->str) || - !rpl_filter->db_ok(newdb->str) || - !rpl_filter->db_ok_with_wild_table(olddb->str) || - !rpl_filter->db_ok_with_wild_table(newdb->str))) + (!rpl_filter->db_ok(db->str) || + !rpl_filter->db_ok_with_wild_table(db->str))) { res= 1; my_message(ER_SLAVE_IGNORED_TABLE, ER(ER_SLAVE_IGNORED_TABLE), MYF(0)); break; } #endif - if (check_db_name(newdb)) + if (check_db_name(db)) { - my_error(ER_WRONG_DB_NAME, MYF(0), newdb->str); + my_error(ER_WRONG_DB_NAME, MYF(0), db->str); break; } - if (check_access(thd,ALTER_ACL,olddb->str,0,1,0,is_schema_db(olddb->str)) || - check_access(thd,DROP_ACL,olddb->str,0,1,0,is_schema_db(olddb->str)) || - check_access(thd,CREATE_ACL,newdb->str,0,1,0,is_schema_db(newdb->str))) + if (check_access(thd, ALTER_ACL, db->str, 0, 1, 0, is_schema_db(db->str)) || + check_access(thd, DROP_ACL, db->str, 0, 1, 0, is_schema_db(db->str)) || + check_access(thd, CREATE_ACL, db->str, 0, 1, 0, is_schema_db(db->str))) { res= 1; break; @@ -3217,7 +3212,8 @@ end_with_restore_list: ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0)); goto error; } - res= mysql_rename_db(thd, olddb, newdb); + + res= mysql_upgrade_db(thd, db); if (!res) send_ok(thd); break; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 9337a2aa329..c576a9dba1d 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1799,7 +1799,7 @@ static bool check_prepared_statement(Prepared_statement *stmt, case SQLCOM_UNINSTALL_PLUGIN: case SQLCOM_CREATE_DB: case SQLCOM_DROP_DB: - case SQLCOM_RENAME_DB: + case SQLCOM_ALTER_DB_UPGRADE: case SQLCOM_CHECKSUM: case SQLCOM_CREATE_USER: case SQLCOM_RENAME_USER: diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index efd8c20e6d7..864d838c183 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1260,7 +1260,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); clear_privileges flush_options flush_option equal optional_braces opt_mi_check_type opt_to mi_check_types normal_join - db_to_db table_to_table_list table_to_table opt_table_list opt_as + table_to_table_list table_to_table opt_table_list opt_as handler_rkey_function handler_read_or_scan single_multi table_wild_list table_wild_one opt_wild union_clause union_list @@ -5400,6 +5400,17 @@ alter: lex->copy_db_to(&lex->name.str, &lex->name.length)) MYSQL_YYABORT; } + | ALTER DATABASE ident UPGRADE_SYM DATA_SYM DIRECTORY_SYM NAME_SYM + { + LEX *lex= Lex; + if (lex->sphead) + { + my_error(ER_SP_NO_DROP_SP, MYF(0), "DATABASE"); + MYSQL_YYABORT; + } + lex->sql_command= SQLCOM_ALTER_DB_UPGRADE; + lex->name= $3; + } | ALTER PROCEDURE sp_name { LEX *lex= Lex; @@ -6184,13 +6195,6 @@ rename: } table_to_table_list {} - | RENAME DATABASE - { - Lex->db_list.empty(); - Lex->sql_command= SQLCOM_RENAME_DB; - } - db_to_db - {} | RENAME USER clear_privileges rename_list { Lex->sql_command = SQLCOM_RENAME_USER; @@ -6228,18 +6232,6 @@ table_to_table: } ; -db_to_db: - ident TO_SYM ident - { - LEX *lex=Lex; - if (lex->db_list.push_back((LEX_STRING*) - sql_memdup(&$1, sizeof(LEX_STRING))) || - lex->db_list.push_back((LEX_STRING*) - sql_memdup(&$3, sizeof(LEX_STRING)))) - MYSQL_YYABORT; - } - ; - keycache: CACHE_SYM INDEX_SYM keycache_list IN_SYM key_cache_name { From f26d69e01a6ffbae92c202c800981e1b102e0eda Mon Sep 17 00:00:00 2001 From: "msvensson@pilot.(none)" <> Date: Tue, 11 Sep 2007 15:00:52 +0200 Subject: [PATCH 015/203] Add support for specifying suites not located in mysql-test/suite/ Example otions that will all run binlog_stm_binlog.test in suite/binlog: --suite=binlog binlog.binlog_stm_binlog --suite=binlog binlog_stm_binlog binlog_stm_binlog --suite=suite/binlog binlog.binlog_stm_binlog --suite=suite/binlog binlog_stm_binlog --- mysql-test/lib/mtr_cases.pl | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl index ba7fcb8ce10..9ba7d737b9e 100644 --- a/mysql-test/lib/mtr_cases.pl +++ b/mysql-test/lib/mtr_cases.pl @@ -151,19 +151,16 @@ sub collect_one_suite($$) mtr_verbose("Collecting: $suite"); - my $testdir; - my $resdir; + my $suitedir= "$::glob_mysql_test_dir"; # Default + if ( $suite ne "main" ) + { + $suitedir= mtr_path_exists("$suitedir/suite/$suite", + "$suitedir/$suite"); + mtr_verbose("suitedir: $suitedir"); + } - if ( $suite eq "main" ) - { - $testdir= "$::glob_mysql_test_dir/t"; - $resdir= "$::glob_mysql_test_dir/r"; - } - else - { - $testdir= "$::glob_mysql_test_dir/suite/$suite/t"; - $resdir= "$::glob_mysql_test_dir/suite/$suite/r"; - } + my $testdir= "$suitedir/t"; + my $resdir= "$suitedir/r"; # ---------------------------------------------------------------------- # Build a hash of disabled testcases for this suite @@ -205,7 +202,7 @@ sub collect_one_suite($$) $tname = basename($tname); # Get rid of suite part - $tname =~ s/^$suite\.//; + $tname =~ s/^(.*)\.//; # Check if the extenstion has been specified. @@ -333,7 +330,7 @@ sub collect_one_test_case($$$$$$$$$) { my $tinfo= {}; - $tinfo->{'name'}= "$suite.$tname"; + $tinfo->{'name'}= basename($suite) . ".$tname"; $tinfo->{'result_file'}= "$resdir/$tname.result"; $tinfo->{'component_id'} = $component_id; push(@$cases, $tinfo); From 8b2435c9b50e36ed05769f2063d28804cfbf60ab Mon Sep 17 00:00:00 2001 From: "malff@lambda.weblab" <> Date: Wed, 12 Sep 2007 12:42:02 -0600 Subject: [PATCH 016/203] Cleanup of sql_yacc.yy --- sql/sql_yacc.yy | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index efd8c20e6d7..ce6e06bbc35 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3361,7 +3361,6 @@ change_ts_option: ; tablespace_option_list: - /* empty */ {} tablespace_options ; @@ -3383,7 +3382,6 @@ tablespace_option: ; alter_tablespace_option_list: - /* empty */ {} alter_tablespace_options ; @@ -3402,7 +3400,6 @@ alter_tablespace_option: ; logfile_group_option_list: - /* empty */ {} logfile_group_options ; @@ -3423,7 +3420,6 @@ logfile_group_option: ; alter_logfile_group_option_list: - /* empty */ {} alter_logfile_group_options ; @@ -3668,7 +3664,7 @@ size_number: create2: '(' create2a {} | opt_create_table_options - opt_partitioning {} + opt_partitioning create3 {} | LIKE table_ident { @@ -3692,19 +3688,22 @@ create2: create2a: field_list ')' opt_create_table_options - opt_partitioning {} + opt_partitioning create3 {} - | opt_partitioning {} + | opt_partitioning create_select ')' - { Select->set_braces(1);} union_opt {} + { Select->set_braces(1);} + union_opt {} ; create3: /* empty */ {} | opt_duplicate opt_as create_select - { Select->set_braces(0);} union_clause {} + { Select->set_braces(0);} + union_clause {} | opt_duplicate opt_as '(' create_select ')' - { Select->set_braces(1);} union_opt {} + { Select->set_braces(1);} + union_opt {} ; /* @@ -3786,7 +3785,7 @@ partition_entry: ; partition: - BY part_type_def opt_no_parts {} opt_sub_part {} part_defs + BY part_type_def opt_no_parts opt_sub_part part_defs ; part_type_def: @@ -3987,10 +3986,11 @@ part_definition: part_info->use_default_partitions= FALSE; part_info->use_default_no_partitions= FALSE; } - part_name {} - opt_part_values {} - opt_part_options {} - opt_sub_partition {} + part_name + opt_part_values + opt_part_options + opt_sub_partition + {} ; part_name: From 84a9e656e00c0aca0e3b5a34bd6a758da7d031d9 Mon Sep 17 00:00:00 2001 From: "svoj@mysql.com/june.mysql.com" <> Date: Thu, 13 Sep 2007 15:39:16 +0500 Subject: [PATCH 017/203] BUG#30590 - delete from memory table with composite btree primary key DELETE query against memory table with btree index may remove not all matching rows. This happens only when DELETE uses index read method to find matching rows. E.g. for queries like DELETE FROM t1 WHERE a=1. Fixed by reverting fix for BUG9719 and applying proper solution. --- heap/hp_delete.c | 3 --- heap/hp_rfirst.c | 11 +++++++++++ heap/hp_rnext.c | 29 +++++++++++++++++++++++++++++ mysql-test/r/heap_btree.result | 7 +++++++ mysql-test/t/heap_btree.test | 9 +++++++++ 5 files changed, 56 insertions(+), 3 deletions(-) diff --git a/heap/hp_delete.c b/heap/hp_delete.c index 266a9da6ca3..90e537081d3 100644 --- a/heap/hp_delete.c +++ b/heap/hp_delete.c @@ -73,10 +73,7 @@ int hp_rb_delete_key(HP_INFO *info, register HP_KEYDEF *keyinfo, int res; if (flag) - { info->last_pos= NULL; /* For heap_rnext/heap_rprev */ - info->lastkey_len= 0; - } custom_arg.keyseg= keyinfo->seg; custom_arg.key_length= hp_rb_make_key(keyinfo, info->recbuf, record, recpos); diff --git a/heap/hp_rfirst.c b/heap/hp_rfirst.c index 85548fea212..6e7ee45af5f 100644 --- a/heap/hp_rfirst.c +++ b/heap/hp_rfirst.c @@ -36,6 +36,17 @@ int heap_rfirst(HP_INFO *info, byte *record, int inx) sizeof(byte*)); info->current_ptr = pos; memcpy(record, pos, (size_t)share->reclength); + /* + If we're performing index_first on a table that was taken from + table cache, info->lastkey_len is initialized to previous query. + Thus we set info->lastkey_len to proper value for subsequent + heap_rnext() calls. + This is needed for DELETE queries only, otherwise this variable is + not used. + Note that the same workaround may be needed for heap_rlast(), but + for now heap_rlast() is never used for DELETE queries. + */ + info->lastkey_len= 0; info->update = HA_STATE_AKTIV; } else diff --git a/heap/hp_rnext.c b/heap/hp_rnext.c index a1bc480333e..513e184c743 100644 --- a/heap/hp_rnext.c +++ b/heap/hp_rnext.c @@ -34,11 +34,40 @@ int heap_rnext(HP_INFO *info, byte *record) heap_rb_param custom_arg; if (info->last_pos) + { + /* + We enter this branch for non-DELETE queries after heap_rkey() + or heap_rfirst(). As last key position (info->last_pos) is available, + we only need to climb the tree using tree_search_next(). + */ pos = tree_search_next(&keyinfo->rb_tree, &info->last_pos, offsetof(TREE_ELEMENT, left), offsetof(TREE_ELEMENT, right)); + } + else if (!info->lastkey_len) + { + /* + We enter this branch only for DELETE queries after heap_rfirst(). E.g. + DELETE FROM t1 WHERE a<10. As last key position is not available + (last key is removed by heap_delete()), we must restart search as it + is done in heap_rfirst(). + + It should be safe to handle this situation without this branch. That is + branch below should find smallest element in a tree as lastkey_len is + zero. tree_search_edge() is a kind of optimisation here as it should be + faster than tree_search_key(). + */ + pos= tree_search_edge(&keyinfo->rb_tree, info->parents, + &info->last_pos, offsetof(TREE_ELEMENT, left)); + } else { + /* + We enter this branch only for DELETE queries after heap_rkey(). E.g. + DELETE FROM t1 WHERE a=10. As last key position is not available + (last key is removed by heap_delete()), we must restart search as it + is done in heap_rkey(). + */ custom_arg.keyseg = keyinfo->seg; custom_arg.key_length = info->lastkey_len; custom_arg.search_flag = SEARCH_SAME | SEARCH_FIND; diff --git a/mysql-test/r/heap_btree.result b/mysql-test/r/heap_btree.result index 72be6a3e400..639fe1ff897 100644 --- a/mysql-test/r/heap_btree.result +++ b/mysql-test/r/heap_btree.result @@ -307,4 +307,11 @@ UNIQUE USING BTREE(c1) ) ENGINE= MEMORY DEFAULT CHARSET= utf8; INSERT INTO t1 VALUES('1'), ('2'); DROP TABLE t1; +CREATE TABLE t1 (a INT, KEY USING BTREE(a)) ENGINE=MEMORY; +INSERT INTO t1 VALUES(1),(2),(2); +DELETE FROM t1 WHERE a=2; +SELECT * FROM t1; +a +1 +DROP TABLE t1; End of 4.1 tests diff --git a/mysql-test/t/heap_btree.test b/mysql-test/t/heap_btree.test index f8d6afbad04..849b7e12843 100644 --- a/mysql-test/t/heap_btree.test +++ b/mysql-test/t/heap_btree.test @@ -213,4 +213,13 @@ CREATE TABLE t1 ( INSERT INTO t1 VALUES('1'), ('2'); DROP TABLE t1; +# +# BUG#30590 - delete from memory table with composite btree primary key +# +CREATE TABLE t1 (a INT, KEY USING BTREE(a)) ENGINE=MEMORY; +INSERT INTO t1 VALUES(1),(2),(2); +DELETE FROM t1 WHERE a=2; +SELECT * FROM t1; +DROP TABLE t1; + --echo End of 4.1 tests From ef3bcaf3dd46d6a4bc7a38d7a50924eb970148c1 Mon Sep 17 00:00:00 2001 From: "anozdrin/alik@station." <> Date: Thu, 13 Sep 2007 17:30:44 +0400 Subject: [PATCH 018/203] Bug#16918: Aborted_clients > Connections. The problem was that aborted_threads variable was updated twice when a client connection had been aborted. The fix is to refactor a code to have aborted_threads updated only in one place. --- sql/mysql_priv.h | 1 - sql/sql_parse.cc | 27 +++++++++++++++++---------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 44eb5590a28..24d02ee6948 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -726,7 +726,6 @@ pthread_handler_t handle_bootstrap(void *arg); void end_thread(THD *thd,bool put_in_cache); void flush_thread_cache(); bool mysql_execute_command(THD *thd); -bool do_command(THD *thd); bool dispatch_command(enum enum_server_command command, THD *thd, char* packet, uint packet_length); void log_slow_statement(THD *thd); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 58f5ffc5235..99a61d95619 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -93,6 +93,8 @@ const char *xa_state_names[]={ "NON-EXISTING", "ACTIVE", "IDLE", "PREPARED" }; +static bool do_command(THD *thd); + #ifdef __WIN__ static void test_signal(int sig_ptr) { @@ -1199,23 +1201,28 @@ pthread_handler_t handle_one_connection(void *arg) } if (thd->user_connect) decrease_user_connections(thd->user_connect); + + if (thd->killed || + net->vio && net->error && net->report_error) + { + statistic_increment(aborted_threads, &LOCK_status); + } + if (net->error && net->vio != 0 && net->report_error) { if (!thd->killed && thd->variables.log_warnings > 1) - sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION), + { + sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION), thd->thread_id,(thd->db ? thd->db : "unconnected"), sctx->user ? sctx->user : "unauthenticated", sctx->host_or_ip, (net->last_errno ? ER(net->last_errno) : ER(ER_UNKNOWN_ERROR))); + } + net_send_error(thd, net->last_errno, NullS); - statistic_increment(aborted_threads,&LOCK_status); } - else if (thd->killed) - { - statistic_increment(aborted_threads,&LOCK_status); - } - + end_thread: close_connection(thd, 0, 1); end_thread(thd,1); @@ -1550,12 +1557,12 @@ bool do_command(THD *thd) DBUG_PRINT("info",("Got error %d reading command from socket %s", net->error, vio_description(net->vio))); + /* Check if we can continue without closing the connection */ + if (net->error != 3) - { - statistic_increment(aborted_threads,&LOCK_status); DBUG_RETURN(TRUE); // We have to close it. - } + net_send_error(thd, net->last_errno, NullS); net->error= 0; DBUG_RETURN(FALSE); From 187b01a45f0a7eb26fec38294d9d242b9be2c1d2 Mon Sep 17 00:00:00 2001 From: "svoj@mysql.com/june.mysql.com" <> Date: Thu, 13 Sep 2007 18:33:40 +0500 Subject: [PATCH 019/203] BUG#30583 - Partition on DOUBLE key + INNODB + count(*) == crash Issuing SELECT COUNT(*) against partitioned InnoDB table may cause server crash. Fixed that not all required fields were included into read_set. --- mysql-test/r/partition_innodb.result | 7 +++++++ mysql-test/t/partition_innodb.test | 8 ++++++++ sql/ha_partition.cc | 16 ++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/mysql-test/r/partition_innodb.result b/mysql-test/r/partition_innodb.result index 8282cfc212a..5b755b6bfd5 100644 --- a/mysql-test/r/partition_innodb.result +++ b/mysql-test/r/partition_innodb.result @@ -129,3 +129,10 @@ insert into t1 (time, first_name, last_name) values ('2007-02-07', 'Q', 'Robert' SELECT * FROM t1 WHERE first_name='Andy' OR last_name='Jake'; id time first_name last_name drop table t1; +CREATE TABLE t1 (a DOUBLE NOT NULL, KEY(a)) ENGINE=InnoDB +PARTITION BY KEY(a) PARTITIONS 10; +INSERT INTO t1 VALUES(1),(2); +SELECT COUNT(*) FROM t1; +COUNT(*) +2 +DROP TABLE t1; diff --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test index f4320c5c56a..4a50332b3df 100644 --- a/mysql-test/t/partition_innodb.test +++ b/mysql-test/t/partition_innodb.test @@ -134,3 +134,11 @@ SELECT * FROM t1 WHERE first_name='Andy' OR last_name='Jake'; drop table t1; +# +# BUG#30583 - Partition on DOUBLE key + INNODB + count(*) == crash +# +CREATE TABLE t1 (a DOUBLE NOT NULL, KEY(a)) ENGINE=InnoDB +PARTITION BY KEY(a) PARTITIONS 10; +INSERT INTO t1 VALUES(1),(2); +SELECT COUNT(*) FROM t1; +DROP TABLE t1; diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index d46b3a3bb08..2681498417e 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -3324,6 +3324,22 @@ int ha_partition::index_init(uint inx, bool sorted) */ if (m_lock_type == F_WRLCK) bitmap_union(table->read_set, &m_part_info->full_part_field_set); + else if (sorted && m_table_flags & HA_PARTIAL_COLUMN_READ) + { + /* + An ordered scan is requested and necessary fields aren't in read_set. + This may happen e.g. with SELECT COUNT(*) FROM t1. We must ensure + that all fields of current key are included into read_set, as + partitioning requires them for sorting + (see ha_partition::handle_ordered_index_scan). + + TODO: handle COUNT(*) queries via unordered scan. + */ + uint i; + for (i= 0; i < m_curr_key_info->key_parts; i++) + bitmap_set_bit(table->read_set, + m_curr_key_info->key_part[i].field->field_index); + } file= m_file; do { From 3c6ca8d6edf55764df93a831f61dc3855e82d91c Mon Sep 17 00:00:00 2001 From: "tnurnberg@mysql.com/sin.intern.azundris.com" <> Date: Thu, 13 Sep 2007 16:19:46 +0200 Subject: [PATCH 020/203] Bug #15327: configure: --with-tcp-port option being partially ignored make sure that if builder configured with a non-standard (!= 3306) default TCP port that value actually gets used throughout. if they didn't configure a value, assume "use a sensible default", which will be read from /etc/services or, failing that, from the factory default. That makes the order of preference - command-line option - my.cnf, where applicable - $MYSQL_TCP_PORT environment variable - /etc/services (unless configured --with-tcp-port) - default port (--with-tcp-port=... or factory default) --- client/mysql.cc | 11 +++++++--- client/mysql_upgrade.c | 9 +++++++-- client/mysqladmin.cc | 8 +++++++- client/mysqlbinlog.cc | 11 +++++++--- client/mysqlcheck.c | 8 +++++++- client/mysqldump.c | 8 +++++++- client/mysqlimport.c | 8 +++++++- client/mysqlmanagerc.c | 7 ++++++- client/mysqlshow.c | 8 +++++++- client/mysqltest.c | 8 +++++++- configure.in | 29 ++++++++++++++++++++++++++- include/mysql_version.h.in | 1 + libmysql/libmysql.c | 21 +++++++++++++++---- mysql-test/Makefile.am | 1 + mysql-test/mysql-test-run-shell.sh | 11 +++++++++- netware/mysql_test_run.c | 3 ++- netware/mysqld_safe.c | 2 +- scripts/Makefile.am | 1 + scripts/mysql_config.sh | 7 ++++++- scripts/mysql_fix_privilege_tables.sh | 1 + scripts/mysqld_safe-watch.sh | 2 +- server-tools/instance-manager/priv.h | 2 +- sql/mysqld.cc | 21 ++++++++++++++++++- tests/mysql_client_test.c | 8 +++++++- tests/ssl_test.c | 2 +- tests/thread_test.c | 8 +++++++- 26 files changed, 176 insertions(+), 30 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 368fce30d67..4f045e21cbd 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -673,9 +673,14 @@ static struct my_option my_long_options[] = {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, - (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, - 0}, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", + (gptr*) &opt_mysql_port, + (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"prompt", OPT_PROMPT, "Set the mysql prompt to this value.", (gptr*) ¤t_prompt, (gptr*) ¤t_prompt, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 64de3d19882..f2bd4a3fa35 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -88,8 +88,13 @@ static struct my_option my_long_options[]= {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"port", 'P', "Port number to use for connection.", 0, - 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", + 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index c7033f6914f..54f67c5df2d 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -159,7 +159,13 @@ static struct my_option my_long_options[] = {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"port", 'P', "Port number to use for connection.", (gptr*) &tcp_port, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", + (gptr*) &tcp_port, (gptr*) &tcp_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index a371981e24d..3d06a21c243 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -687,9 +687,14 @@ static struct my_option my_long_options[] = 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', "Password to connect to remote server.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"port", 'P', "Use port to connect to the remote server.", - (gptr*) &port, (gptr*) &port, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, - 0, 0, 0}, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", + (gptr*) &port, (gptr*) &port, 0, GET_INT, REQUIRED_ARG, + 0, 0, 0, 0, 0, 0}, {"position", 'j', "Deprecated. Use --start-position instead.", (gptr*) &start_position, (gptr*) &start_position, 0, GET_ULL, REQUIRED_ARG, BIN_LOG_HEADER_SIZE, BIN_LOG_HEADER_SIZE, diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index b69e9201a28..8205a83fdf4 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -123,7 +123,13 @@ static struct my_option my_long_options[] = {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", + (gptr*) &opt_mysql_port, (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", diff --git a/client/mysqldump.c b/client/mysqldump.c index 1a024a923f5..1a809ca8b6c 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -361,7 +361,13 @@ static struct my_option my_long_options[] = {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", + (gptr*) &opt_mysql_port, (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", diff --git a/client/mysqlimport.c b/client/mysqlimport.c index e7bf1cfd889..066e892f78a 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -119,7 +119,13 @@ static struct my_option my_long_options[] = {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", + (gptr*) &opt_mysql_port, (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", diff --git a/client/mysqlmanagerc.c b/client/mysqlmanagerc.c index 1fdedab97fb..b4cc6320047 100644 --- a/client/mysqlmanagerc.c +++ b/client/mysqlmanagerc.c @@ -49,7 +49,12 @@ static struct my_option my_long_options[] = GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', "Password to use when connecting to server.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"port", 'P', "Port number to use for connection.", (gptr*) &port, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", (gptr*) &port, (gptr*) &port, 0, GET_UINT, REQUIRED_ARG, MYSQL_MANAGER_PORT, 0, 0, 0, 0, 0}, {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, diff --git a/client/mysqlshow.c b/client/mysqlshow.c index 5be01cc5a52..7b1835055f5 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -188,7 +188,13 @@ static struct my_option my_long_options[] = {"password", 'p', "Password to use when connecting to server. If password is not given it's asked from the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", + (gptr*) &opt_mysql_port, (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef __WIN__ diff --git a/client/mysqltest.c b/client/mysqltest.c index d1ec753b54b..ff45f80d914 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -4512,7 +4512,13 @@ static struct my_option my_long_options[] = GET_INT, REQUIRED_ARG, 500, 1, 10000, 0, 0, 0}, {"password", 'p', "Password to use when connecting to server.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"port", 'P', "Port number to use for connection.", (gptr*) &opt_port, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", + (gptr*) &opt_port, (gptr*) &opt_port, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"ps-protocol", OPT_PS_PROTOCOL, "Use prepared statements protocol for communication", (gptr*) &ps_protocol, (gptr*) &ps_protocol, 0, diff --git a/configure.in b/configure.in index 1da39ac1aa3..2e66b5eb333 100644 --- a/configure.in +++ b/configure.in @@ -710,7 +710,34 @@ AC_ARG_WITH(tcp-port, [ --with-tcp-port=port-number Which port to use for MySQL services (default 3306)], [ MYSQL_TCP_PORT=$withval ], - [ MYSQL_TCP_PORT=$MYSQL_TCP_PORT_DEFAULT ] + [ MYSQL_TCP_PORT=$MYSQL_TCP_PORT_DEFAULT + # if we actually defaulted (as opposed to the pathological case of + # --with-tcp-port= which might in theory + # happen if whole batch of servers was built from a script), set + # the default to zero to indicate that; we don't lose information + # that way, because 0 obviously indicates that we can get the + # default value from MYSQL_TCP_PORT. this seems really evil, but + # testing for MYSQL_TCP_PORT==MYSQL_TCP_PORT_DEFAULT would make a + # a port of MYSQL_TCP_PORT_DEFAULT magic even if the builder did not + # intend it to mean "use the default, in fact, look up a good default + # from /etc/services if you can", but really, really meant 3306 when + # they passed in 3306. When they pass in a specific value, let them + # have it; don't second guess user and think we know better, this will + # just make people cross. this makes the the logic work like this + # (which is complicated enough): + # + # - if a port was set during build, use that as a default. + # + # - otherwise, try to look up a port in /etc/services; if that fails, + # use MYSQL_TCP_PORT_DEFAULT (at the time of this writing 3306) + # + # - allow the MYSQL_TCP_PORT environment variable to override that. + # + # - allow command-line parameters to override all of the above. + # + # the top-most MYSQL_TCP_PORT_DEFAULT is read from win/configure.js, + # so don't mess with that. + MYSQL_TCP_PORT_DEFAULT=0 ] ) AC_SUBST(MYSQL_TCP_PORT) # We might want to document the assigned port in the manual. diff --git a/include/mysql_version.h.in b/include/mysql_version.h.in index dac7ca661d1..04a43f2c968 100644 --- a/include/mysql_version.h.in +++ b/include/mysql_version.h.in @@ -15,6 +15,7 @@ #define FRM_VER @DOT_FRM_VERSION@ #define MYSQL_VERSION_ID @MYSQL_VERSION_ID@ #define MYSQL_PORT @MYSQL_TCP_PORT@ +#define MYSQL_PORT_DEFAULT @MYSQL_TCP_PORT_DEFAULT@ #define MYSQL_UNIX_ADDR "@MYSQL_UNIX_ADDR@" #define MYSQL_CONFIG_NAME "my" #define MYSQL_COMPILATION_COMMENT "@COMPILATION_COMMENT@" diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 72bc4445d83..5388aa07b9d 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -133,10 +133,23 @@ int STDCALL mysql_server_init(int argc __attribute__((unused)), { struct servent *serv_ptr; char *env; - if ((serv_ptr = getservbyname("mysql", "tcp"))) - mysql_port = (uint) ntohs((ushort) serv_ptr->s_port); - if ((env = getenv("MYSQL_TCP_PORT"))) - mysql_port =(uint) atoi(env); + + /* + if builder specifically requested a default port, use that + (even if it coincides with our factory default). + only if they didn't do we check /etc/services (and, failing + on that, fall back to the factory default of 3306). + either default can be overridden by the environment variable + MYSQL_TCP_PORT, which in turn can be overridden with command + line options. + */ + +#if MYSQL_PORT_DEFAULT == 0 + if ((serv_ptr = getservbyname("mysql", "tcp"))) + mysql_port = (uint) ntohs((ushort) serv_ptr->s_port); +#endif + if ((env = getenv("MYSQL_TCP_PORT"))) + mysql_port =(uint) atoi(env); } #endif } diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index ebc2bbb83e8..a764d1e851d 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -147,6 +147,7 @@ SUFFIXES = .sh -e 's!@''PERL''@!@PERL@!' \ -e 's!@''VERSION''@!@VERSION@!' \ -e 's!@''MYSQL_TCP_PORT''@!@MYSQL_TCP_PORT@!' \ + -e 's!@''MYSQL_TCP_PORT_DEFAULT''@!@MYSQL_TCP_PORT_DEFAULT@!' \ -e 's!@''MYSQL_BASE_VERSION''@!@MYSQL_BASE_VERSION@!' \ -e 's!@''MYSQL_UNIX_ADDR''@!@MYSQL_UNIX_ADDR@!' \ -e 's!@''MYSQL_TCP_PORT''@!@MYSQL_TCP_PORT@!' \ diff --git a/mysql-test/mysql-test-run-shell.sh b/mysql-test/mysql-test-run-shell.sh index a81a3b8b607..c0ff3d3d88e 100644 --- a/mysql-test/mysql-test-run-shell.sh +++ b/mysql-test/mysql-test-run-shell.sh @@ -17,7 +17,16 @@ USE_MANAGER=0 MY_TZ=GMT-3 TZ=$MY_TZ; export TZ # for UNIX_TIMESTAMP tests to work LOCAL_SOCKET=@MYSQL_UNIX_ADDR@ -MYSQL_TCP_PORT=@MYSQL_TCP_PORT@ + +if [ -z "$MYSQL_TCP_PORT" ]; then + MYSQL_TCP_PORT=@MYSQL_TCP_PORT@ + if [ @MYSQL_TCP_PORT_DEFAULT@ -eq 0 ]; then + ESP=`getent services mysql/tcp` + if [ $? -eq 0 ]; then + MYSQL_TCP_PORT=`echo "$ESP"|sed -e's-^[a-z]*[ ]*\([0-9]*\)/[a-z]*$-\1-g'` + fi + fi +fi umask 022 diff --git a/netware/mysql_test_run.c b/netware/mysql_test_run.c index 6bab2f0149c..a62de9013f9 100644 --- a/netware/mysql_test_run.c +++ b/netware/mysql_test_run.c @@ -1170,7 +1170,8 @@ void setup(char *file) setenv("MYSQL_BINLOG", file_path, 1); setenv("MASTER_MYPORT", "9306", 1); setenv("SLAVE_MYPORT", "9307", 1); - setenv("MYSQL_TCP_PORT", "3306", 1); + snprintf(file_path, PATH_MAX*2, "%d", MYSQL_PORT); + setenv("MYSQL_TCP_PORT", file_path, 1); snprintf(file_path, PATH_MAX*2, "%s/mysql_client_test --no-defaults --testcase--user=root --port=%u ", bin_dir, master_port); setenv("MYSQL_CLIENT_TEST",file_path,1); snprintf(file_path, PATH_MAX*2, "%s/mysql --no-defaults --user=root --port=%u ", bin_dir, master_port); diff --git a/netware/mysqld_safe.c b/netware/mysqld_safe.c index 9db8a441ca3..00e7d1bcd51 100644 --- a/netware/mysqld_safe.c +++ b/netware/mysqld_safe.c @@ -189,7 +189,7 @@ void start_defaults(int argc, char *argv[]) snprintf(address, PATH_MAX, "0.0.0.0"); // port - snprintf(port, PATH_MAX, "3306"); + snprintf(port, PATH_MAX, "%d", MYSQL_PORT); // default option default_option[0]= NULL; diff --git a/scripts/Makefile.am b/scripts/Makefile.am index d4944962884..2b6870717ba 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -174,6 +174,7 @@ SUFFIXES = .sh -e 's!@''MYSQLD_DEFAULT_SWITCHES''@!@MYSQLD_DEFAULT_SWITCHES@!' \ -e 's!@''MYSQL_UNIX_ADDR''@!@MYSQL_UNIX_ADDR@!' \ -e 's!@''MYSQL_TCP_PORT''@!@MYSQL_TCP_PORT@!' \ + -e 's!@''MYSQL_TCP_PORT_DEFAULT''@!@MYSQL_TCP_PORT_DEFAULT@!' \ -e 's!@''TARGET_LINUX''@!@TARGET_LINUX@!' \ -e "s!@""CONF_COMMAND""@!@CONF_COMMAND@!" \ -e 's!@''MYSQLD_USER''@!@MYSQLD_USER@!' \ diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh index f094cb060b7..ab58c512aac 100644 --- a/scripts/mysql_config.sh +++ b/scripts/mysql_config.sh @@ -92,9 +92,14 @@ fix_path pkgincludedir include/mysql include version='@VERSION@' socket='@MYSQL_UNIX_ADDR@' -port='@MYSQL_TCP_PORT@' ldflags='@LDFLAGS@' +if [ @MYSQL_TCP_PORT_DEFAULT@ -eq 0 ]; then + port=0 +else + port=@MYSQL_TCP_PORT@ +fi + # Create options # We intentionally add a space to the beginning and end of lib strings, simplifies replace later libs=" $ldflags -L$pkglibdir -lmysqlclient @ZLIB_DEPS@ @NON_THREADED_LIBS@" diff --git a/scripts/mysql_fix_privilege_tables.sh b/scripts/mysql_fix_privilege_tables.sh index a353273dc28..3b179957932 100644 --- a/scripts/mysql_fix_privilege_tables.sh +++ b/scripts/mysql_fix_privilege_tables.sh @@ -25,6 +25,7 @@ sql_only=0 basedir="@prefix@" verbose=0 args="" +# no elaborate fallback here; with no argument, it will happen in "mysql" port="" socket="" database="mysql" diff --git a/scripts/mysqld_safe-watch.sh b/scripts/mysqld_safe-watch.sh index c837ba9a118..f853741c87b 100644 --- a/scripts/mysqld_safe-watch.sh +++ b/scripts/mysqld_safe-watch.sh @@ -66,7 +66,7 @@ fi echo "Starting mysqld demon with databases from $DATADIR" #Default communication ports -#MYSQL_TCP_PORT=3306 +#MYSQL_TCP_PORT=@MYSQL_TCP_PORT@ if test -z "$MYSQL_UNIX_PORT" then MYSQL_UNIX_PORT="/tmp/mysql.sock" diff --git a/server-tools/instance-manager/priv.h b/server-tools/instance-manager/priv.h index a746288f28b..2e55e0ac8e6 100644 --- a/server-tools/instance-manager/priv.h +++ b/server-tools/instance-manager/priv.h @@ -25,7 +25,7 @@ #include "my_pthread.h" /* IM-wide platform-independent defines */ -#define SERVER_DEFAULT_PORT 3306 +#define SERVER_DEFAULT_PORT MYSQL_PORT #define DEFAULT_MONITORING_INTERVAL 20 #define DEFAULT_PORT 2273 /* three-week timeout should be enough */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 61980fa1887..7e0c8c7e775 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1300,8 +1300,21 @@ static void set_ports() { // Get port if not from commandline struct servent *serv_ptr; mysqld_port= MYSQL_PORT; + + /* + if builder specifically requested a default port, use that + (even if it coincides with our factory default). + only if they didn't do we check /etc/services (and, failing + on that, fall back to the factory default of 3306). + either default can be overridden by the environment variable + MYSQL_TCP_PORT, which in turn can be overridden with command + line options. + */ + +#if MYSQL_PORT_DEFAULT == 0 if ((serv_ptr= getservbyname("mysql", "tcp"))) mysqld_port= ntohs((u_short) serv_ptr->s_port); /* purecov: inspected */ +#endif if ((env = getenv("MYSQL_TCP_PORT"))) mysqld_port= (uint) atoi(env); /* purecov: inspected */ } @@ -5399,7 +5412,13 @@ Disable with --skip-ndbcluster (will save memory).", {"pid-file", OPT_PID_FILE, "Pid file used by safe_mysqld.", (gptr*) &pidfile_name_ptr, (gptr*) &pidfile_name_ptr, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"port", 'P', "Port number to use for connection.", (gptr*) &mysqld_port, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", + (gptr*) &mysqld_port, (gptr*) &mysqld_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"port-open-timeout", OPT_PORT_OPEN_TIMEOUT, "Maximum time in seconds to wait for the port to become free. " diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 75c86902972..4a1941a2cf8 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -15759,7 +15759,13 @@ static struct my_option client_test_long_options[] = {"password", 'p', "Password to use when connecting to server. If password is not given it's asked from the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"port", 'P', "Port number to use for connection", (char **) &opt_port, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", + (char **) &opt_port, (char **) &opt_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"server-arg", 'A', "Send embedded server this as a parameter.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/tests/ssl_test.c b/tests/ssl_test.c index 136f0a83cbe..ad6bc925cc6 100644 --- a/tests/ssl_test.c +++ b/tests/ssl_test.c @@ -44,7 +44,7 @@ int main(int argc, char **argv) "../SSL/MySQL-client-cert.pem", "../SSL/MySQL-ca-cert.pem", 0, 0); #endif - if (!(sock = mysql_real_connect(&mysql,"127.0.0.1",0,0,argv[1],3306,NULL,0))) + if (!(sock = mysql_real_connect(&mysql,"127.0.0.1",0,0,argv[1],MYSQL_PORT,NULL,0))) { fprintf(stderr,"Couldn't connect to engine!\n%s\n\n",mysql_error(&mysql)); perror(""); diff --git a/tests/thread_test.c b/tests/thread_test.c index 0ad446282c2..0ba03694893 100644 --- a/tests/thread_test.c +++ b/tests/thread_test.c @@ -103,7 +103,13 @@ static struct my_option my_long_options[] = (gptr*) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"query", 'Q', "Query to execute in each threads", (gptr*) &query, (gptr*) &query, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"port", 'P', "Port number to use for connection", (gptr*) &tcp_port, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", + (gptr*) &tcp_port, (gptr*) &tcp_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0}, {"socket", 'S', "Socket file to use for connection", (gptr*) &unix_socket, (gptr*) &unix_socket, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, From 2a70d6fa97d40c708b033c8eaee57f1f3ac5ad0d Mon Sep 17 00:00:00 2001 From: "davi@moksha.local" <> Date: Thu, 13 Sep 2007 19:22:08 -0300 Subject: [PATCH 021/203] Bug#30747 Create table with identical constraint names behaves incorrectly MySQL provides what appears to be a non standard extension to the FOREIGN KEY syntax which let users name (label/tag) a foreign key to more easily identify a specific foreign key if any problems show up later during the query parsing or execution. But the foreign key name was not being properly set to the right key, possible leaving the foreign key with no name. --- mysql-test/include/mix1.inc | 34 ++++++++++++++++++++++++++++++ mysql-test/r/innodb_mysql.result | 36 ++++++++++++++++++++++++++++++++ sql/sql_yacc.yy | 5 +++-- 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc index 5e6a535fce5..0e1bdd1e0b8 100644 --- a/mysql-test/include/mix1.inc +++ b/mysql-test/include/mix1.inc @@ -1096,4 +1096,38 @@ select @b:=f2 from t1; select if(@a=@b,"ok","wrong"); drop table t1; +# +# Bug#30747 Create table with identical constraint names behaves incorrectly +# + +if ($test_foreign_keys) +{ + CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY (a,b)) engine=innodb; + --error ER_WRONG_FK_DEF + CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), + CONSTRAINT c2 FOREIGN KEY f2 (c) REFERENCES t1 (a,b) ON UPDATE NO ACTION) engine=innodb; + --error ER_WRONG_FK_DEF + CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), + CONSTRAINT c2 FOREIGN KEY (c) REFERENCES t1 (a,b) ON UPDATE NO ACTION) engine=innodb; + CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), + CONSTRAINT c1 FOREIGN KEY c2 (c) REFERENCES t1 (a) ON DELETE NO ACTION, + CONSTRAINT c2 FOREIGN KEY (c) REFERENCES t1 (a) ON UPDATE NO ACTION) engine=innodb; + ALTER TABLE t2 DROP FOREIGN KEY c2; + DROP TABLE t2; + --error ER_WRONG_FK_DEF + CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), + FOREIGN KEY (c) REFERENCES t1 (a,k) ON UPDATE NO ACTION) engine=innodb; + --error ER_WRONG_FK_DEF + CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), + FOREIGN KEY f1 (c) REFERENCES t1 (a,k) ON UPDATE NO ACTION) engine=innodb; + CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), + CONSTRAINT c1 FOREIGN KEY f1 (c) REFERENCES t1 (a) ON DELETE NO ACTION, + CONSTRAINT c2 FOREIGN KEY (c) REFERENCES t1 (a) ON UPDATE NO ACTION, + FOREIGN KEY f3 (c) REFERENCES t1 (a) ON UPDATE NO ACTION, + FOREIGN KEY (c) REFERENCES t1 (a) ON UPDATE NO ACTION) engine=innodb; + SHOW CREATE TABLE t2; + DROP TABLE t2; + DROP TABLE t1; +} + --echo End of 5.1 tests diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index 32c692501ad..cc1a0cc61ab 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -1273,4 +1273,40 @@ select if(@a=@b,"ok","wrong"); if(@a=@b,"ok","wrong") ok drop table t1; +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY (a,b)) engine=innodb; +CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), +CONSTRAINT c2 FOREIGN KEY f2 (c) REFERENCES t1 (a,b) ON UPDATE NO ACTION) engine=innodb; +ERROR 42000: Incorrect foreign key definition for 'f2': Key reference and table reference don't match +CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), +CONSTRAINT c2 FOREIGN KEY (c) REFERENCES t1 (a,b) ON UPDATE NO ACTION) engine=innodb; +ERROR 42000: Incorrect foreign key definition for 'c2': Key reference and table reference don't match +CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), +CONSTRAINT c1 FOREIGN KEY c2 (c) REFERENCES t1 (a) ON DELETE NO ACTION, +CONSTRAINT c2 FOREIGN KEY (c) REFERENCES t1 (a) ON UPDATE NO ACTION) engine=innodb; +ALTER TABLE t2 DROP FOREIGN KEY c2; +DROP TABLE t2; +CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), +FOREIGN KEY (c) REFERENCES t1 (a,k) ON UPDATE NO ACTION) engine=innodb; +ERROR 42000: Incorrect foreign key definition for 'foreign key without name': Key reference and table reference don't match +CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), +FOREIGN KEY f1 (c) REFERENCES t1 (a,k) ON UPDATE NO ACTION) engine=innodb; +ERROR 42000: Incorrect foreign key definition for 'f1': Key reference and table reference don't match +CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), +CONSTRAINT c1 FOREIGN KEY f1 (c) REFERENCES t1 (a) ON DELETE NO ACTION, +CONSTRAINT c2 FOREIGN KEY (c) REFERENCES t1 (a) ON UPDATE NO ACTION, +FOREIGN KEY f3 (c) REFERENCES t1 (a) ON UPDATE NO ACTION, +FOREIGN KEY (c) REFERENCES t1 (a) ON UPDATE NO ACTION) engine=innodb; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c` int(11) NOT NULL, + `d` int(11) NOT NULL, + PRIMARY KEY (`c`,`d`), + CONSTRAINT `c1` FOREIGN KEY (`c`) REFERENCES `t1` (`a`) ON DELETE NO ACTION, + CONSTRAINT `c2` FOREIGN KEY (`c`) REFERENCES `t1` (`a`) ON UPDATE NO ACTION, + CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`c`) REFERENCES `t1` (`a`) ON UPDATE NO ACTION, + CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`c`) REFERENCES `t1` (`a`) ON UPDATE NO ACTION +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t2; +DROP TABLE t1; End of 5.1 tests diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index b5b451cfe3e..1f6ea170a10 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4656,8 +4656,9 @@ key_def: | opt_constraint FOREIGN KEY_SYM opt_ident '(' key_list ')' references { LEX *lex=Lex; - const char *key_name= $4 ? $4 : $1; - Key *key= new Foreign_key(key_name, lex->col_list, + const char *key_name= $1 ? $1 : $4; + const char *fkey_name = $4 ? $4 : key_name; + Key *key= new Foreign_key(fkey_name, lex->col_list, $8, lex->ref_list, lex->fk_delete_opt, From cc3f0af2e199487c8b2cebd6c7b525168ad5a7a7 Mon Sep 17 00:00:00 2001 From: "tnurnberg@mysql.com/sin.intern.azundris.com" <> Date: Sat, 15 Sep 2007 04:59:46 +0200 Subject: [PATCH 022/203] Bug #15327: configure: --with-tcp-port option being partially ignored after merge fix :-/ --- client/mysqlbinlog.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index f848a98e5a6..2110f27d887 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -762,7 +762,6 @@ static struct my_option my_long_options[] = "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", (uchar**) &port, (uchar**) &port, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - 0, 0, 0}, {"position", 'j', "Deprecated. Use --start-position instead.", (uchar**) &start_position, (uchar**) &start_position, 0, GET_ULL, REQUIRED_ARG, BIN_LOG_HEADER_SIZE, BIN_LOG_HEADER_SIZE, From 2a5d951552c190a0e9b56122d642dff8f92a0c1f Mon Sep 17 00:00:00 2001 From: "gshchepa/uchum@gleb.loc" <> Date: Mon, 17 Sep 2007 21:39:07 +0500 Subject: [PATCH 023/203] Fixed bug #29985. Multiple-result processing is required during the execution of CALL statements for stored procedures, however the mysqlslap client lacked that processing. --- client/mysqlslap.c | 18 +++++++++++------- mysql-test/r/mysqlslap.result | 5 +++++ mysql-test/t/mysqlslap.test | 11 +++++++++++ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/client/mysqlslap.c b/client/mysqlslap.c index 02a0cbd04c5..1c54ba86718 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -140,7 +140,8 @@ static my_bool opt_compress= FALSE, tty_password= FALSE, auto_generate_sql= FALSE; const char *auto_generate_sql_type= "mixed"; -static unsigned long connect_flags= CLIENT_MULTI_RESULTS; +static unsigned long connect_flags= CLIENT_MULTI_RESULTS | + CLIENT_MULTI_STATEMENTS; static int verbose, delimiter_length; static uint commit_rate; @@ -1877,13 +1878,16 @@ limit_not_met: } } - if (mysql_field_count(mysql)) + do { - result= mysql_store_result(mysql); - while ((row = mysql_fetch_row(result))) - counter++; - mysql_free_result(result); - } + if (mysql_field_count(mysql)) + { + result= mysql_store_result(mysql); + while ((row = mysql_fetch_row(result))) + counter++; + mysql_free_result(result); + } + } while(mysql_next_result(mysql) == 0); queries++; if (commit_rate && commit_rate <= trans_counter) diff --git a/mysql-test/r/mysqlslap.result b/mysql-test/r/mysqlslap.result index dfe721d10d2..8b5069bb887 100644 --- a/mysql-test/r/mysqlslap.result +++ b/mysql-test/r/mysqlslap.result @@ -211,3 +211,8 @@ COMMIT; COMMIT; SHOW TABLES; DROP SCHEMA IF EXISTS `mysqlslap`; +# +# Bug #29985: mysqlslap -- improper handling of resultsets in SPROCs +# +DROP PROCEDURE IF EXISTS p1; +CREATE PROCEDURE p1() SELECT 1; diff --git a/mysql-test/t/mysqlslap.test b/mysql-test/t/mysqlslap.test index dffa226d101..92d31ec9082 100644 --- a/mysql-test/t/mysqlslap.test +++ b/mysql-test/t/mysqlslap.test @@ -40,3 +40,14 @@ --exec $MYSQL_SLAP --only-print --delimiter=";" --query="select * from t1;select * from t2" --create="CREATE TABLE t1 (id int, name varchar(64)); create table t2(foo1 varchar(32), foo2 varchar(32)); INSERT INTO t1 VALUES (1, 'This is a test'); insert into t2 values ('test', 'test2')" --engine="heap,myisam" --post-query="SHOW TABLES" --pre-query="SHOW TABLES" --number-of-queries=6 --commit=1; --exec $MYSQL_SLAP --silent --concurrency=5 --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=write --detach=2 + +--echo # +--echo # Bug #29985: mysqlslap -- improper handling of resultsets in SPROCs +--echo # + +--disable_warnings +DROP PROCEDURE IF EXISTS p1; +--enable_warnings +CREATE PROCEDURE p1() SELECT 1; + +--exec $MYSQL_SLAP --create-schema=test --delimiter=";" --query="CALL p1; SELECT 1;" --silent 2>&1 From ef75db8cbac0e0c4dafc94eba8f65dfd1a3cbe7a Mon Sep 17 00:00:00 2001 From: "evgen@sunlight.local" <> Date: Thu, 20 Sep 2007 18:05:09 +0400 Subject: [PATCH 024/203] Bug#29908: A user can gain additional access through the ALTER VIEW. Non-definer of a view was allowed to alter that view. Due to this the alterer can elevate his access rights to access rights of the view definer and thus modify data which he wasn't allowed to modify. A view defined with SQL SECURITY INVOKER can't be used directly for access rights elevation. But a user can first alter the view SQL code and then alter the view to SQL SECURITY DEFINER and thus elevate his access rights. Due to this altering a view with SQL SECURITY INVOKER is also prohibited. Now the mysql_create_view function allows ALTER VIEW only to the view definer or a super user. --- mysql-test/r/view_grant.result | 50 ++++++++++++++++++++++++++++++++-- mysql-test/t/view_grant.test | 49 +++++++++++++++++++++++++++++++-- sql/sql_view.cc | 5 +--- 3 files changed, 95 insertions(+), 9 deletions(-) diff --git a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result index 0f9ce47dec6..ab408e6f175 100644 --- a/mysql-test/r/view_grant.result +++ b/mysql-test/r/view_grant.result @@ -776,15 +776,59 @@ GRANT CREATE VIEW ON db26813.v2 TO u26813@localhost; GRANT DROP, CREATE VIEW ON db26813.v3 TO u26813@localhost; GRANT SELECT ON db26813.t1 TO u26813@localhost; ALTER VIEW v1 AS SELECT f2 FROM t1; -ERROR 42000: CREATE VIEW command denied to user 'u26813'@'localhost' for table 'v1' +ERROR 42000: Access denied; you need the SUPER privilege for this operation ALTER VIEW v2 AS SELECT f2 FROM t1; -ERROR 42000: DROP command denied to user 'u26813'@'localhost' for table 'v2' +ERROR 42000: Access denied; you need the SUPER privilege for this operation ALTER VIEW v3 AS SELECT f2 FROM t1; +ERROR 42000: Access denied; you need the SUPER privilege for this operation SHOW CREATE VIEW v3; View Create View -v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`f2` AS `f2` from `t1` +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`f1` AS `f1` from `t1` DROP USER u26813@localhost; DROP DATABASE db26813; +# +# Bug#29908: A user can gain additional access through the ALTER VIEW. +# +CREATE DATABASE mysqltest_29908; +USE mysqltest_29908; +CREATE TABLE t1(f1 INT, f2 INT); +CREATE USER u29908_1@localhost; +CREATE DEFINER = u29908_1@localhost VIEW v1 AS SELECT f1 FROM t1; +CREATE DEFINER = u29908_1@localhost SQL SECURITY INVOKER VIEW v2 AS +SELECT f1 FROM t1; +GRANT DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v1 TO u29908_1@localhost; +GRANT DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v2 TO u29908_1@localhost; +GRANT SELECT ON mysqltest_29908.t1 TO u29908_1@localhost; +CREATE USER u29908_2@localhost; +GRANT DROP, CREATE VIEW ON mysqltest_29908.v1 TO u29908_2@localhost; +GRANT DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v2 TO u29908_2@localhost; +GRANT SELECT ON mysqltest_29908.t1 TO u29908_2@localhost; +ALTER VIEW v1 AS SELECT f2 FROM t1; +ERROR 42000: Access denied; you need the SUPER privilege for this operation +ALTER VIEW v2 AS SELECT f2 FROM t1; +SHOW CREATE VIEW v2; +View Create View +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f2` AS `f2` from `t1` +ALTER VIEW v1 AS SELECT f2 FROM t1; +SHOW CREATE VIEW v1; +View Create View +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f2` AS `f2` from `t1` +ALTER VIEW v2 AS SELECT f1 FROM t1; +SHOW CREATE VIEW v2; +View Create View +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f1` AS `f1` from `t1` +ALTER VIEW v1 AS SELECT f1 FROM t1; +SHOW CREATE VIEW v1; +View Create View +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f1` AS `f1` from `t1` +ALTER VIEW v2 AS SELECT f2 FROM t1; +SHOW CREATE VIEW v2; +View Create View +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f2` AS `f2` from `t1` +DROP USER u29908_1@localhost; +DROP USER u29908_2@localhost; +DROP DATABASE mysqltest_29908; +####################################################################### DROP DATABASE IF EXISTS mysqltest1; DROP DATABASE IF EXISTS mysqltest2; CREATE DATABASE mysqltest1; diff --git a/mysql-test/t/view_grant.test b/mysql-test/t/view_grant.test index a102f87c4e8..0cad3857dcd 100644 --- a/mysql-test/t/view_grant.test +++ b/mysql-test/t/view_grant.test @@ -1034,10 +1034,11 @@ GRANT SELECT ON db26813.t1 TO u26813@localhost; connect (u1,localhost,u26813,,db26813); connection u1; ---error 1142 +--error ER_SPECIFIC_ACCESS_DENIED_ERROR ALTER VIEW v1 AS SELECT f2 FROM t1; ---error 1142 +--error ER_SPECIFIC_ACCESS_DENIED_ERROR ALTER VIEW v2 AS SELECT f2 FROM t1; +--error ER_SPECIFIC_ACCESS_DENIED_ERROR ALTER VIEW v3 AS SELECT f2 FROM t1; connection root; @@ -1047,6 +1048,50 @@ DROP USER u26813@localhost; DROP DATABASE db26813; disconnect u1; +--echo # +--echo # Bug#29908: A user can gain additional access through the ALTER VIEW. +--echo # +connection root; +CREATE DATABASE mysqltest_29908; +USE mysqltest_29908; +CREATE TABLE t1(f1 INT, f2 INT); +CREATE USER u29908_1@localhost; +CREATE DEFINER = u29908_1@localhost VIEW v1 AS SELECT f1 FROM t1; +CREATE DEFINER = u29908_1@localhost SQL SECURITY INVOKER VIEW v2 AS + SELECT f1 FROM t1; +GRANT DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v1 TO u29908_1@localhost; +GRANT DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v2 TO u29908_1@localhost; +GRANT SELECT ON mysqltest_29908.t1 TO u29908_1@localhost; +CREATE USER u29908_2@localhost; +GRANT DROP, CREATE VIEW ON mysqltest_29908.v1 TO u29908_2@localhost; +GRANT DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v2 TO u29908_2@localhost; +GRANT SELECT ON mysqltest_29908.t1 TO u29908_2@localhost; + +connect (u2,localhost,u29908_2,,mysqltest_29908); +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +ALTER VIEW v1 AS SELECT f2 FROM t1; +ALTER VIEW v2 AS SELECT f2 FROM t1; +SHOW CREATE VIEW v2; + +connect (u1,localhost,u29908_1,,mysqltest_29908); +ALTER VIEW v1 AS SELECT f2 FROM t1; +SHOW CREATE VIEW v1; +ALTER VIEW v2 AS SELECT f1 FROM t1; +SHOW CREATE VIEW v2; + +connection root; +ALTER VIEW v1 AS SELECT f1 FROM t1; +SHOW CREATE VIEW v1; +ALTER VIEW v2 AS SELECT f2 FROM t1; +SHOW CREATE VIEW v2; + +DROP USER u29908_1@localhost; +DROP USER u29908_2@localhost; +DROP DATABASE mysqltest_29908; +disconnect u1; +disconnect u2; +--echo ####################################################################### + # # BUG#24040: Create View don't succed with "all privileges" on a database. # diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 35a97411511..28677cf8a72 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -223,9 +223,6 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, { LEX *lex= thd->lex; bool link_to_local; -#ifndef NO_EMBEDDED_ACCESS_CHECKS - bool definer_check_is_needed= mode != VIEW_ALTER || lex->definer; -#endif /* first table in list is target VIEW name => cut off it */ TABLE_LIST *view= lex->unlink_first_table(&link_to_local); TABLE_LIST *tables= lex->query_tables; @@ -280,7 +277,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, - same as current user - current user has SUPER_ACL */ - if (definer_check_is_needed && + if (lex->definer && (strcmp(lex->definer->user.str, thd->security_ctx->priv_user) != 0 || my_strcasecmp(system_charset_info, lex->definer->host.str, From 9254e8fb01a515b207f3089568004e5b8afd7200 Mon Sep 17 00:00:00 2001 From: "tnurnberg@sin.intern.azundris.com" <> Date: Thu, 20 Sep 2007 18:10:35 +0200 Subject: [PATCH 025/203] Bug#19828: Case sensitivity in hostname leads to inconsistent behavior clean up SHOW GRANTS so it will show host-names with case as entered. make REVOKE and friends case-sensitive to make things more intuitive. Patch by Martin Friebe. --- mysql-test/r/grant.result | 3 + mysql-test/r/grant3.result | 122 +++++++++++++++++++++++++++++++++++++ mysql-test/t/grant.test | 3 + mysql-test/t/grant3.test | 100 ++++++++++++++++++++++++++++++ sql/sql_acl.cc | 41 ++++++++++--- 5 files changed, 259 insertions(+), 10 deletions(-) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index a4c51cca277..855352a2195 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -1121,6 +1121,9 @@ SELECT * FROM test.t1; f1 f2 1 1 2 2 +REVOKE UPDATE (f1) ON `test`.`t1` FROM 'mysqltest_1'@'localhost'; +REVOKE SELECT ON `test`.* FROM 'mysqltest_1'@'localhost'; +REVOKE ALL ON db27878.* FROM 'mysqltest_1'@'localhost'; DROP DATABASE db27878; use test; DROP TABLE t1; diff --git a/mysql-test/r/grant3.result b/mysql-test/r/grant3.result index 6193c4fd49d..cc7f46855b2 100644 --- a/mysql-test/r/grant3.result +++ b/mysql-test/r/grant3.result @@ -16,3 +16,125 @@ delete from mysql.db where user like 'mysqltest\_%'; delete from mysql.tables_priv where user like 'mysqltest\_%'; delete from mysql.columns_priv where user like 'mysqltest\_%'; flush privileges; +grant select on test.* to CUser@localhost; +grant select on test.* to CUser@LOCALHOST; +flush privileges; +SELECT user, host FROM mysql.user where user = 'CUser' order by 1,2; +user host +CUser LOCALHOST +CUser localhost +SELECT user, host, db, select_priv FROM mysql.db where user = 'CUser' order by 1,2; +user host db select_priv +CUser LOCALHOST test Y +CUser localhost test Y +REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'CUser'@'LOCALHOST'; +flush privileges; +SELECT user, host FROM mysql.user where user = 'CUser' order by 1,2; +user host +CUser LOCALHOST +CUser localhost +SELECT user, host, db, select_priv FROM mysql.db where user = 'CUser' order by 1,2; +user host db select_priv +CUser localhost test Y +REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'CUser'@'localhost'; +flush privileges; +SELECT user, host FROM mysql.user where user = 'CUser' order by 1,2; +user host +CUser LOCALHOST +CUser localhost +SELECT user, host, db, select_priv FROM mysql.db where user = 'CUser' order by 1,2; +user host db select_priv +DROP USER CUser@localhost; +DROP USER CUser@LOCALHOST; +create table t1 (a int); +grant select on test.t1 to CUser@localhost; +grant select on test.t1 to CUser@LOCALHOST; +flush privileges; +SELECT user, host FROM mysql.user where user = 'CUser' order by 1,2; +user host +CUser LOCALHOST +CUser localhost +SELECT user, host, db, Table_name, Table_priv, Column_priv FROM mysql.tables_priv where user = 'CUser' order by 1,2; +user host db Table_name Table_priv Column_priv +CUser LOCALHOST test t1 Select +CUser localhost test t1 Select +REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'CUser'@'LOCALHOST'; +flush privileges; +SELECT user, host FROM mysql.user where user = 'CUser' order by 1,2; +user host +CUser LOCALHOST +CUser localhost +SELECT user, host, db, Table_name, Table_priv, Column_priv FROM mysql.tables_priv where user = 'CUser' order by 1,2; +user host db Table_name Table_priv Column_priv +CUser localhost test t1 Select +REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'CUser'@'localhost'; +flush privileges; +SELECT user, host FROM mysql.user where user = 'CUser' order by 1,2; +user host +CUser LOCALHOST +CUser localhost +SELECT user, host, db, Table_name, Table_priv, Column_priv FROM mysql.tables_priv where user = 'CUser' order by 1,2; +user host db Table_name Table_priv Column_priv +DROP USER CUser@localhost; +DROP USER CUser@LOCALHOST; +grant select(a) on test.t1 to CUser@localhost; +grant select(a) on test.t1 to CUser@LOCALHOST; +flush privileges; +SELECT user, host FROM mysql.user where user = 'CUser' order by 1,2; +user host +CUser LOCALHOST +CUser localhost +SELECT user, host, db, Table_name, Table_priv, Column_priv FROM mysql.tables_priv where user = 'CUser' order by 1,2; +user host db Table_name Table_priv Column_priv +CUser LOCALHOST test t1 Select +CUser localhost test t1 Select +REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'CUser'@'LOCALHOST'; +flush privileges; +SELECT user, host FROM mysql.user where user = 'CUser' order by 1,2; +user host +CUser LOCALHOST +CUser localhost +SELECT user, host, db, Table_name, Table_priv, Column_priv FROM mysql.tables_priv where user = 'CUser' order by 1,2; +user host db Table_name Table_priv Column_priv +CUser localhost test t1 Select +REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'CUser'@'localhost'; +flush privileges; +SELECT user, host FROM mysql.user where user = 'CUser' order by 1,2; +user host +CUser LOCALHOST +CUser localhost +SELECT user, host, db, Table_name, Table_priv, Column_priv FROM mysql.tables_priv where user = 'CUser' order by 1,2; +user host db Table_name Table_priv Column_priv +DROP USER CUser@localhost; +DROP USER CUser@LOCALHOST; +drop table t1; +grant select on test.* to CUser2@localhost; +grant select on test.* to CUser2@LOCALHOST; +flush privileges; +SELECT user, host FROM mysql.user where user = 'CUser2' order by 1,2; +user host +CUser2 LOCALHOST +CUser2 localhost +SELECT user, host, db, select_priv FROM mysql.db where user = 'CUser2' order by 1,2; +user host db select_priv +CUser2 LOCALHOST test Y +CUser2 localhost test Y +REVOKE SELECT ON test.* FROM 'CUser2'@'LOCALHOST'; +flush privileges; +SELECT user, host FROM mysql.user where user = 'CUser2' order by 1,2; +user host +CUser2 LOCALHOST +CUser2 localhost +SELECT user, host, db, select_priv FROM mysql.db where user = 'CUser2' order by 1,2; +user host db select_priv +CUser2 localhost test Y +REVOKE SELECT ON test.* FROM 'CUser2'@'localhost'; +flush privileges; +SELECT user, host FROM mysql.user where user = 'CUser2' order by 1,2; +user host +CUser2 LOCALHOST +CUser2 localhost +SELECT user, host, db, select_priv FROM mysql.db where user = 'CUser2' order by 1,2; +user host db select_priv +DROP USER CUser2@localhost; +DROP USER CUser2@LOCALHOST; diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 32eb262fd51..1d11a669811 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -1144,6 +1144,9 @@ UPDATE v1 SET f2 = 4; SELECT * FROM test.t1; disconnect user1; connection default; +REVOKE UPDATE (f1) ON `test`.`t1` FROM 'mysqltest_1'@'localhost'; +REVOKE SELECT ON `test`.* FROM 'mysqltest_1'@'localhost'; +REVOKE ALL ON db27878.* FROM 'mysqltest_1'@'localhost'; DROP DATABASE db27878; use test; DROP TABLE t1; diff --git a/mysql-test/t/grant3.test b/mysql-test/t/grant3.test index 115586e807d..fac577ef0ff 100644 --- a/mysql-test/t/grant3.test +++ b/mysql-test/t/grant3.test @@ -34,3 +34,103 @@ delete from mysql.db where user like 'mysqltest\_%'; delete from mysql.tables_priv where user like 'mysqltest\_%'; delete from mysql.columns_priv where user like 'mysqltest\_%'; flush privileges; + +# +# Bug: #19828 Case sensitivity in Grant/Revoke +# + +grant select on test.* to CUser@localhost; +grant select on test.* to CUser@LOCALHOST; +flush privileges; + +SELECT user, host FROM mysql.user where user = 'CUser' order by 1,2; +SELECT user, host, db, select_priv FROM mysql.db where user = 'CUser' order by 1,2; + +REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'CUser'@'LOCALHOST'; +flush privileges; + +SELECT user, host FROM mysql.user where user = 'CUser' order by 1,2; +SELECT user, host, db, select_priv FROM mysql.db where user = 'CUser' order by 1,2; + +REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'CUser'@'localhost'; +flush privileges; + +SELECT user, host FROM mysql.user where user = 'CUser' order by 1,2; +SELECT user, host, db, select_priv FROM mysql.db where user = 'CUser' order by 1,2; + +DROP USER CUser@localhost; +DROP USER CUser@LOCALHOST; + +#### table grants +create table t1 (a int); +grant select on test.t1 to CUser@localhost; +grant select on test.t1 to CUser@LOCALHOST; +flush privileges; + +SELECT user, host FROM mysql.user where user = 'CUser' order by 1,2; +SELECT user, host, db, Table_name, Table_priv, Column_priv FROM mysql.tables_priv where user = 'CUser' order by 1,2; + +REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'CUser'@'LOCALHOST'; +flush privileges; + +SELECT user, host FROM mysql.user where user = 'CUser' order by 1,2; +SELECT user, host, db, Table_name, Table_priv, Column_priv FROM mysql.tables_priv where user = 'CUser' order by 1,2; + +REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'CUser'@'localhost'; +flush privileges; + +SELECT user, host FROM mysql.user where user = 'CUser' order by 1,2; +SELECT user, host, db, Table_name, Table_priv, Column_priv FROM mysql.tables_priv where user = 'CUser' order by 1,2; + +DROP USER CUser@localhost; +DROP USER CUser@LOCALHOST; + +### column grants + +grant select(a) on test.t1 to CUser@localhost; +grant select(a) on test.t1 to CUser@LOCALHOST; +flush privileges; + +SELECT user, host FROM mysql.user where user = 'CUser' order by 1,2; +SELECT user, host, db, Table_name, Table_priv, Column_priv FROM mysql.tables_priv where user = 'CUser' order by 1,2; + +REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'CUser'@'LOCALHOST'; +flush privileges; + +SELECT user, host FROM mysql.user where user = 'CUser' order by 1,2; +SELECT user, host, db, Table_name, Table_priv, Column_priv FROM mysql.tables_priv where user = 'CUser' order by 1,2; + +REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'CUser'@'localhost'; +flush privileges; + +SELECT user, host FROM mysql.user where user = 'CUser' order by 1,2; +SELECT user, host, db, Table_name, Table_priv, Column_priv FROM mysql.tables_priv where user = 'CUser' order by 1,2; + +DROP USER CUser@localhost; +DROP USER CUser@LOCALHOST; + +drop table t1; + +# revoke on a specific DB only + +grant select on test.* to CUser2@localhost; +grant select on test.* to CUser2@LOCALHOST; +flush privileges; + +SELECT user, host FROM mysql.user where user = 'CUser2' order by 1,2; +SELECT user, host, db, select_priv FROM mysql.db where user = 'CUser2' order by 1,2; + +REVOKE SELECT ON test.* FROM 'CUser2'@'LOCALHOST'; +flush privileges; + +SELECT user, host FROM mysql.user where user = 'CUser2' order by 1,2; +SELECT user, host, db, select_priv FROM mysql.db where user = 'CUser2' order by 1,2; + +REVOKE SELECT ON test.* FROM 'CUser2'@'localhost'; +flush privileges; + +SELECT user, host FROM mysql.user where user = 'CUser2' order by 1,2; +SELECT user, host, db, select_priv FROM mysql.db where user = 'CUser2' order by 1,2; + +DROP USER CUser2@localhost; +DROP USER CUser2@LOCALHOST; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index f9bd2c6ba0d..6bc6cce5e72 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1132,7 +1132,7 @@ static void acl_update_db(const char *user, const char *host, const char *db, { if (!acl_db->host.hostname && !host[0] || acl_db->host.hostname && - !my_strcasecmp(system_charset_info, host, acl_db->host.hostname)) + !strcmp(host, acl_db->host.hostname)) { if (!acl_db->db && !db[0] || acl_db->db && !strcmp(db,acl_db->db)) @@ -4344,6 +4344,13 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user) if (!(host=acl_db->host.hostname)) host= ""; + /* + We do not make SHOW GRANTS case-sensitive here (like REVOKE), + but make it case-insensitive because that's the way they are + actually applied, and showing fewer privileges than are applied + would be wrong from a security point of view. + */ + if (!strcmp(lex_user->user.str,user) && !my_strcasecmp(system_charset_info, lex_user->host.str, host)) { @@ -4379,8 +4386,8 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user) db.append(lex_user->user.str, lex_user->user.length, system_charset_info); db.append (STRING_WITH_LEN("'@'")); - db.append(lex_user->host.str, lex_user->host.length, - system_charset_info); + // host and lex_user->host are equal except for case + db.append(host, strlen(host), system_charset_info); db.append ('\''); if (want_access & GRANT_ACL) db.append(STRING_WITH_LEN(" WITH GRANT OPTION")); @@ -4407,6 +4414,13 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user) if (!(host= grant_table->host.hostname)) host= ""; + /* + We do not make SHOW GRANTS case-sensitive here (like REVOKE), + but make it case-insensitive because that's the way they are + actually applied, and showing fewer privileges than are applied + would be wrong from a security point of view. + */ + if (!strcmp(lex_user->user.str,user) && !my_strcasecmp(system_charset_info, lex_user->host.str, host)) { @@ -4487,8 +4501,8 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user) global.append(lex_user->user.str, lex_user->user.length, system_charset_info); global.append(STRING_WITH_LEN("'@'")); - global.append(lex_user->host.str,lex_user->host.length, - system_charset_info); + // host and lex_user->host are equal except for case + global.append(host, strlen(host), system_charset_info); global.append('\''); if (table_access & GRANT_ACL) global.append(STRING_WITH_LEN(" WITH GRANT OPTION")); @@ -4543,6 +4557,13 @@ static int show_routine_grants(THD* thd, LEX_USER *lex_user, HASH *hash, if (!(host= grant_proc->host.hostname)) host= ""; + /* + We do not make SHOW GRANTS case-sensitive here (like REVOKE), + but make it case-insensitive because that's the way they are + actually applied, and showing fewer privileges than are applied + would be wrong from a security point of view. + */ + if (!strcmp(lex_user->user.str,user) && !my_strcasecmp(system_charset_info, lex_user->host.str, host)) { @@ -4586,8 +4607,8 @@ static int show_routine_grants(THD* thd, LEX_USER *lex_user, HASH *hash, global.append(lex_user->user.str, lex_user->user.length, system_charset_info); global.append(STRING_WITH_LEN("'@'")); - global.append(lex_user->host.str,lex_user->host.length, - system_charset_info); + // host and lex_user->host are equal except for case + global.append(host, strlen(host), system_charset_info); global.append('\''); if (proc_access & GRANT_ACL) global.append(STRING_WITH_LEN(" WITH GRANT OPTION")); @@ -5541,7 +5562,7 @@ bool mysql_revoke_all(THD *thd, List &list) host= ""; if (!strcmp(lex_user->user.str,user) && - !my_strcasecmp(system_charset_info, lex_user->host.str, host)) + !strcmp(lex_user->host.str, host)) { if (!replace_db_table(tables[1].table, acl_db->db, *lex_user, ~(ulong)0, 1)) { @@ -5572,7 +5593,7 @@ bool mysql_revoke_all(THD *thd, List &list) host= ""; if (!strcmp(lex_user->user.str,user) && - !my_strcasecmp(system_charset_info, lex_user->host.str, host)) + !strcmp(lex_user->host.str, host)) { if (replace_table_table(thd,grant_table,tables[2].table,*lex_user, grant_table->db, @@ -5618,7 +5639,7 @@ bool mysql_revoke_all(THD *thd, List &list) host= ""; if (!strcmp(lex_user->user.str,user) && - !my_strcasecmp(system_charset_info, lex_user->host.str, host)) + !strcmp(lex_user->host.str, host)) { if (!replace_routine_table(thd,grant_proc,tables[4].table,*lex_user, grant_proc->db, From e41434fb950e5bd29d400c371b33038cb87b7446 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Fri, 21 Sep 2007 09:48:30 +0200 Subject: [PATCH 026/203] Bug#30843 Bad Test addition to t/archive.test - Add extra insert --- mysql-test/r/archive.result | 4 +++- mysql-test/t/archive.test | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result index b6a313ddf1a..a1c11417bd0 100644 --- a/mysql-test/r/archive.result +++ b/mysql-test/r/archive.result @@ -11124,9 +11124,10 @@ SELECT COUNT(auto) FROM t2; COUNT(auto) 1213 INSERT DELAYED INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily',''); +INSERT INTO t2 VALUES (5,000001,00,'after','delayed','insert',''); SELECT COUNT(auto) FROM t2; COUNT(auto) -1214 +1215 ALTER TABLE t2 DROP COLUMN fld6; SHOW CREATE TABLE t2; Table Create Table @@ -12354,6 +12355,7 @@ auto fld1 companynr fld3 fld4 fld5 3 011402 37 Romans scholastics jarring 4 011403 37 intercepted audiology tinily 4 011403 37 intercepted audiology tinily +5 000001 00 after delayed insert drop table t1, t2, t4; create table t1 (i int) engine=archive; insert into t1 values (1); diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test index 61033fca3f7..d1c45a259c6 100644 --- a/mysql-test/t/archive.test +++ b/mysql-test/t/archive.test @@ -1348,7 +1348,15 @@ SELECT * FROM t2; # Test INSERT DELAYED and wait until the table has one more record SELECT COUNT(auto) FROM t2; INSERT DELAYED INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily',''); -while (`SELECT COUNT(auto)!=1214 FROM t2`) + +# Insert another record since in Archive delayed values are only +# guaranteed to materialize based on either: +# 1) A new row showing up from a normal insert +# 2) A flush table has occurred. +INSERT INTO t2 VALUES (5,000001,00,'after','delayed','insert',''); + +# Wait for the delayed insert to appear +while (`SELECT COUNT(auto)!=1215 FROM t2`) { sleep 0.1; } From bb5cdfb87e897c6855162001e9ab8f4a18fe9fd6 Mon Sep 17 00:00:00 2001 From: "evgen@sunlight.local" <> Date: Fri, 21 Sep 2007 12:09:00 +0400 Subject: [PATCH 027/203] Bug#30384: Having SQL_BUFFER_RESULT option in the CREATE .. KEY(..) .. SELECT led to creating corrupted index. While execution of the CREATE .. SELECT SQL_BUFFER_RESULT statement the engine->start_bulk_insert function was called twice. On the first call On the first call MyISAM disabled all non-unique indexes and on the second call it decides to not re-enable them because all indexes was disabled. Due to this no indexes was actually created during CREATE TABLE thus producing crashed table. Now the select_inset class has is_bulk_insert_mode flag which prevents calling the start_bulk_insert function twice. The flag is set in the select_create::prepare, select_insert::prepare2 functions and the select_insert class constructor. The flag is reset in the select_insert::send_eof function. --- mysql-test/r/insert_select.result | 12 ++++++++++++ mysql-test/t/insert_select.test | 12 ++++++++++++ sql/sql_class.h | 2 +- sql/sql_insert.cc | 12 ++++++++++-- 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result index d16562d97e2..7a37f49125a 100644 --- a/mysql-test/r/insert_select.result +++ b/mysql-test/r/insert_select.result @@ -830,3 +830,15 @@ id prev_id join_id 3 2 0 4 3 0 DROP TABLE t1,t2; +# +# Bug#30384: Having SQL_BUFFER_RESULT option in the +# CREATE .. KEY(..) .. SELECT led to creating corrupted index. +# +create table t1(f1 int); +insert into t1 values(1),(2),(3); +create table t2 (key(f1)) engine=myisam select sql_buffer_result f1 from t1; +check table t2 extended; +Table Op Msg_type Msg_text +test.t2 check status OK +drop table t1,t2; +################################################################## diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test index fcd07a21821..78a903e0d18 100644 --- a/mysql-test/t/insert_select.test +++ b/mysql-test/t/insert_select.test @@ -385,3 +385,15 @@ INSERT INTO t1 (prev_id) SELECT id SELECT * FROM t1; DROP TABLE t1,t2; + +--echo # +--echo # Bug#30384: Having SQL_BUFFER_RESULT option in the +--echo # CREATE .. KEY(..) .. SELECT led to creating corrupted index. +--echo # +create table t1(f1 int); +insert into t1 values(1),(2),(3); +create table t2 (key(f1)) engine=myisam select sql_buffer_result f1 from t1; +check table t2 extended; +drop table t1,t2; +--echo ################################################################## + diff --git a/sql/sql_class.h b/sql/sql_class.h index 4fac86dc405..e6d65f3133a 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2029,7 +2029,7 @@ class select_insert :public select_result_interceptor { ulonglong last_insert_id; COPY_INFO info; bool insert_into_view; - + bool is_bulk_insert_mode; select_insert(TABLE_LIST *table_list_par, TABLE *table_par, List *fields_par, List *update_fields, List *update_values, diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index f07af393070..cf0016198da 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2647,7 +2647,8 @@ select_insert::select_insert(TABLE_LIST *table_list_par, TABLE *table_par, bool ignore_check_option_errors) :table_list(table_list_par), table(table_par), fields(fields_par), last_insert_id(0), - insert_into_view(table_list_par && table_list_par->view != 0) + insert_into_view(table_list_par && table_list_par->view != 0), + is_bulk_insert_mode(FALSE) { bzero((char*) &info,sizeof(info)); info.handle_duplicates= duplic; @@ -2832,8 +2833,11 @@ int select_insert::prepare2(void) { DBUG_ENTER("select_insert::prepare2"); if (thd->lex->current_select->options & OPTION_BUFFER_RESULT && - !thd->prelocked_mode) + !thd->prelocked_mode && !is_bulk_insert_mode) + { table->file->start_bulk_insert((ha_rows) 0); + is_bulk_insert_mode= TRUE; + } DBUG_RETURN(0); } @@ -2939,6 +2943,7 @@ bool select_insert::send_eof() DBUG_ENTER("select_insert::send_eof"); error= (!thd->prelocked_mode) ? table->file->end_bulk_insert():0; + is_bulk_insert_mode= FALSE; table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE); @@ -3271,7 +3276,10 @@ select_create::prepare(List &values, SELECT_LEX_UNIT *u) if (info.handle_duplicates == DUP_UPDATE) table->file->extra(HA_EXTRA_INSERT_WITH_UPDATE); if (!thd->prelocked_mode) + { table->file->start_bulk_insert((ha_rows) 0); + is_bulk_insert_mode= TRUE; + } thd->abort_on_warning= (!info.ignore && (thd->variables.sql_mode & (MODE_STRICT_TRANS_TABLES | From 10816b3a08647abdf4e621e0f707cb674c03cda3 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Fri, 21 Sep 2007 17:10:45 +0200 Subject: [PATCH 028/203] Bug#28359 Intermitted lost connection at 'reading authorization packet' errors - Increase default 'connect_timeout' value to 10 seconds --- sql/mysql_priv.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 44eb5590a28..1d944f196ed 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -245,8 +245,13 @@ MY_LOCALE *my_locale_by_number(uint number); #define PRECISION_FOR_DOUBLE 53 #define PRECISION_FOR_FLOAT 24 +/* + Default time to wait before aborting a new client connection + that does not respond to "initial server greeting" timely +*/ +#define CONNECT_TIMEOUT 10 + /* The following can also be changed from the command line */ -#define CONNECT_TIMEOUT 5 // Do not wait long for connect #define DEFAULT_CONCURRENCY 10 #define DELAYED_LIMIT 100 /* pause after xxx inserts */ #define DELAYED_QUEUE_SIZE 1000 From 9c9c82e04ecd23e4aa5f44ecfb63a86f8f97b9d3 Mon Sep 17 00:00:00 2001 From: "iggy@alf.(none)" <> Date: Fri, 21 Sep 2007 11:38:23 -0400 Subject: [PATCH 029/203] Bug #15327: configure: --with-tcp-port option being partially ignored make sure that if builder configured with a non-standard (!= 3306) default TCP port that value actually gets used throughout. --- win/configure.js | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/win/configure.js b/win/configure.js index a2502d96b80..38ca11f0439 100755 --- a/win/configure.js +++ b/win/configure.js @@ -31,6 +31,7 @@ try configureInTS.Close(); var default_comment = "Source distribution"; var default_port = GetValue(configureIn, "MYSQL_TCP_PORT_DEFAULT"); + var actual_port = 0; var configfile = fso.CreateTextFile("win\\configure.data", true); for (i=0; i < args.Count(); i++) @@ -58,10 +59,41 @@ try default_comment = parts[1]; break; case "MYSQL_TCP_PORT": - default_port = parts[1]; + actual_port = parts[1]; break; } } + if (actual_port == 0) + { + // if we actually defaulted (as opposed to the pathological case of + // --with-tcp-port= which might in theory + // happen if whole batch of servers was built from a script), set + // the default to zero to indicate that; we don't lose information + // that way, because 0 obviously indicates that we can get the + // default value from MYSQL_TCP_PORT. this seems really evil, but + // testing for MYSQL_TCP_PORT==MYSQL_TCP_PORT_DEFAULT would make a + // a port of MYSQL_TCP_PORT_DEFAULT magic even if the builder did not + // intend it to mean "use the default, in fact, look up a good default + // from /etc/services if you can", but really, really meant 3306 when + // they passed in 3306. When they pass in a specific value, let them + // have it; don't second guess user and think we know better, this will + // just make people cross. this makes the the logic work like this + // (which is complicated enough): + // + // - if a port was set during build, use that as a default. + // + // - otherwise, try to look up a port in /etc/services; if that fails, + // use MYSQL_TCP_PORT_DEFAULT (at the time of this writing 3306) + // + // - allow the MYSQL_TCP_PORT environment variable to override that. + // + // - allow command-line parameters to override all of the above. + // + // the top-most MYSQL_TCP_PORT_DEFAULT is read from win/configure.js, + // so don't mess with that. + actual_port = default_port; + default_port = 0; + } configfile.WriteLine("SET (COMPILATION_COMMENT \"" + default_comment + "\")"); @@ -70,7 +102,8 @@ try GetValue(configureIn, "PROTOCOL_VERSION") + "\")"); configfile.WriteLine("SET (DOT_FRM_VERSION \"" + GetValue(configureIn, "DOT_FRM_VERSION") + "\")"); - configfile.WriteLine("SET (MYSQL_TCP_PORT \"" + default_port + "\")"); + configfile.WriteLine("SET (MYSQL_TCP_PORT_DEFAULT \"" + default_port + "\")"); + configfile.WriteLine("SET (MYSQL_TCP_PORT \"" + actual_port + "\")"); configfile.WriteLine("SET (MYSQL_UNIX_ADDR \"" + GetValue(configureIn, "MYSQL_UNIX_ADDR_DEFAULT") + "\")"); var version = GetVersion(configureIn); From ed055965bf2e4f04be61372bb81f67d51231ae33 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Fri, 21 Sep 2007 17:52:02 +0200 Subject: [PATCH 030/203] - Increase default connect_timeout to avoid intermittent disconnects when test servers are put under load --- mysql-test/mysql-test-run.pl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 06447b9e69d..ad507440bb7 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3708,6 +3708,11 @@ sub mysqld_arguments ($$$$) { mtr_add_arg($args, "%s--language=%s", $prefix, $path_language); mtr_add_arg($args, "%s--tmpdir=$opt_tmpdir", $prefix); + # Increase default connect_timeout to avoid intermittent + # disconnects when test servers are put under load + # see BUG#28359 + mtr_add_arg($args, "%s--connect-timeout=60", $prefix); + if ( $opt_valgrind_mysqld ) { mtr_add_arg($args, "%s--skip-safemalloc", $prefix); From ac026cfeb6d8d3ded34db5c222f4d5b6dfb5262b Mon Sep 17 00:00:00 2001 From: "iggy@alf.(none)" <> Date: Fri, 21 Sep 2007 12:05:54 -0400 Subject: [PATCH 031/203] Bug #15327: configure: --with-tcp-port option being partially ignored make sure that if builder configured with a non-standard (!= 3306) default TCP port that value actually gets used throughout. --- win/configure.js | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/win/configure.js b/win/configure.js index 7e10ac34697..c86ec0cf47c 100644 --- a/win/configure.js +++ b/win/configure.js @@ -31,6 +31,7 @@ try configureInTS.Close(); var default_comment = "Source distribution"; var default_port = GetValue(configureIn, "MYSQL_TCP_PORT_DEFAULT"); + var actual_port = 0; var configfile = fso.CreateTextFile("win\\configure.data", true); for (i=0; i < args.Count(); i++) @@ -59,10 +60,41 @@ try default_comment = parts[1]; break; case "MYSQL_TCP_PORT": - default_port = parts[1]; + actual_port = parts[1]; break; } } + if (actual_port == 0) + { + // if we actually defaulted (as opposed to the pathological case of + // --with-tcp-port= which might in theory + // happen if whole batch of servers was built from a script), set + // the default to zero to indicate that; we don't lose information + // that way, because 0 obviously indicates that we can get the + // default value from MYSQL_TCP_PORT. this seems really evil, but + // testing for MYSQL_TCP_PORT==MYSQL_TCP_PORT_DEFAULT would make a + // a port of MYSQL_TCP_PORT_DEFAULT magic even if the builder did not + // intend it to mean "use the default, in fact, look up a good default + // from /etc/services if you can", but really, really meant 3306 when + // they passed in 3306. When they pass in a specific value, let them + // have it; don't second guess user and think we know better, this will + // just make people cross. this makes the the logic work like this + // (which is complicated enough): + // + // - if a port was set during build, use that as a default. + // + // - otherwise, try to look up a port in /etc/services; if that fails, + // use MYSQL_TCP_PORT_DEFAULT (at the time of this writing 3306) + // + // - allow the MYSQL_TCP_PORT environment variable to override that. + // + // - allow command-line parameters to override all of the above. + // + // the top-most MYSQL_TCP_PORT_DEFAULT is read from win/configure.js, + // so don't mess with that. + actual_port = default_port; + default_port = 0; + } configfile.WriteLine("SET (COMPILATION_COMMENT \"" + default_comment + "\")"); @@ -71,7 +103,8 @@ try GetValue(configureIn, "PROTOCOL_VERSION") + "\")"); configfile.WriteLine("SET (DOT_FRM_VERSION \"" + GetValue(configureIn, "DOT_FRM_VERSION") + "\")"); - configfile.WriteLine("SET (MYSQL_TCP_PORT \"" + default_port + "\")"); + configfile.WriteLine("SET (MYSQL_TCP_PORT_DEFAULT \"" + default_port + "\")"); + configfile.WriteLine("SET (MYSQL_TCP_PORT \"" + actual_port + "\")"); configfile.WriteLine("SET (MYSQL_UNIX_ADDR \"" + GetValue(configureIn, "MYSQL_UNIX_ADDR_DEFAULT") + "\")"); var version = GetVersion(configureIn); From 36bf417b40c553f1704528022858293b71942d76 Mon Sep 17 00:00:00 2001 From: "evgen@sunlight.local" <> Date: Sat, 22 Sep 2007 11:49:27 +0400 Subject: [PATCH 032/203] Bug#27216: functions with parameters of different date types may return wrong type of the result. There are several functions that accept parameters of different types. The result field type of such functions was determined based on the aggregated result type of its arguments. As the DATE and the DATETIME types are represented by the STRING type, the result field type of the affected functions was always STRING for DATE/DATETIME arguments. The affected functions are COALESCE, IF, IFNULL, CASE, LEAST/GREATEST, CASE. Now the affected functions aggregate the field types of their arguments rather than their result types and return the result of aggregation as their result field type. The cached_field_type member variable is added to the number of classes to hold the aggregated result field type. The str_to_date() function's result field type now defaults to the MYSQL_TYPE_DATETIME. The agg_field_type() function is added. It aggregates field types with help of the Field::field_type_merge() function. The create_table_from_items() function now uses the item->tmp_table_field_from_field_type() function to get the proper field when the item is a function with a STRING result type. --- libmysql/libmysql.c | 2 + mysql-test/r/date_formats.result | 2 +- mysql-test/r/type_datetime.result | 61 +++++++++++++++++++++++++++++++ mysql-test/t/type_datetime.test | 38 +++++++++++++++++++ sql/item_cmpfunc.cc | 40 ++++++++++++++++++-- sql/item_cmpfunc.h | 8 +++- sql/item_func.cc | 1 + sql/item_func.h | 4 +- sql/item_timefunc.cc | 2 +- sql/mysql_priv.h | 1 + sql/protocol.cc | 1 + sql/sql_insert.cc | 5 ++- 12 files changed, 156 insertions(+), 9 deletions(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 85c56a7ea40..45d68fbbe5c 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -4355,6 +4355,7 @@ static my_bool setup_one_fetch_function(MYSQL_BIND *param, MYSQL_FIELD *field) case MYSQL_TYPE_STRING: case MYSQL_TYPE_DECIMAL: case MYSQL_TYPE_NEWDECIMAL: + case MYSQL_TYPE_NEWDATE: DBUG_ASSERT(param->buffer_length != 0); param->fetch_result= fetch_result_str; break; @@ -4427,6 +4428,7 @@ static my_bool setup_one_fetch_function(MYSQL_BIND *param, MYSQL_FIELD *field) case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_STRING: case MYSQL_TYPE_BIT: + case MYSQL_TYPE_NEWDATE: param->skip_result= skip_result_string; break; default: diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index d62c865bb3c..6833a7f1594 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -481,7 +481,7 @@ str_to_date(a,b) create table t2 select str_to_date(a,b) from t1; describe t2; Field Type Null Key Default Extra -str_to_date(a,b) binary(29) YES NULL +str_to_date(a,b) datetime YES NULL select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f") as f1, str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S") as f2, str_to_date("2003-01-02", "%Y-%m-%d") as f3, diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index 9e47b5da2b6..c58ce3401fb 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -427,3 +427,64 @@ f1 Warnings: Warning 1292 Incorrect datetime value: '2007010100000' for column 'f1' at row 1 drop table t1; +# +# Bug#27216: functions with parameters of different date types may +# return wrong type of the result. +# +create table t1 (f1 date, f2 datetime, f3 varchar(20)); +create table t2 as select coalesce(f1,f1) as f4 from t1; +desc t2; +Field Type Null Key Default Extra +f4 date YES NULL +create table t3 as select coalesce(f1,f2) as f4 from t1; +desc t3; +Field Type Null Key Default Extra +f4 datetime YES NULL +create table t4 as select coalesce(f2,f2) as f4 from t1; +desc t4; +Field Type Null Key Default Extra +f4 datetime YES NULL +create table t5 as select coalesce(f1,f3) as f4 from t1; +desc t5; +Field Type Null Key Default Extra +f4 varbinary(20) YES NULL +create table t6 as select coalesce(f2,f3) as f4 from t1; +desc t6; +Field Type Null Key Default Extra +f4 varbinary(20) YES NULL +create table t7 as select coalesce(makedate(1997,1),f2) as f4 from t1; +desc t7; +Field Type Null Key Default Extra +f4 datetime YES NULL +create table t8 as select coalesce(cast('01-01-01' as datetime),f2) as f4 +from t1; +desc t8; +Field Type Null Key Default Extra +f4 datetime YES NULL +create table t9 as select case when 1 then cast('01-01-01' as date) +when 0 then cast('01-01-01' as date) end as f4 from t1; +desc t9; +Field Type Null Key Default Extra +f4 date YES NULL +create table t10 as select case when 1 then cast('01-01-01' as datetime) +when 0 then cast('01-01-01' as datetime) end as f4 from t1; +desc t10; +Field Type Null Key Default Extra +f4 datetime YES NULL +create table t11 as select if(1, cast('01-01-01' as datetime), +cast('01-01-01' as date)) as f4 from t1; +desc t11; +Field Type Null Key Default Extra +f4 datetime YES NULL +create table t12 as select least(cast('01-01-01' as datetime), +cast('01-01-01' as date)) as f4 from t1; +desc t12; +Field Type Null Key Default Extra +f4 datetime YES NULL +create table t13 as select ifnull(cast('01-01-01' as datetime), +cast('01-01-01' as date)) as f4 from t1; +desc t13; +Field Type Null Key Default Extra +f4 datetime YES NULL +drop tables t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13; +################################################################### diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test index ffda593f320..8d68d11c0d6 100644 --- a/mysql-test/t/type_datetime.test +++ b/mysql-test/t/type_datetime.test @@ -282,3 +282,41 @@ select * from t1 where f1 between 20020101 and 20070101000000; select * from t1 where f1 between 2002010 and 20070101000000; select * from t1 where f1 between 20020101 and 2007010100000; drop table t1; + +--echo # +--echo # Bug#27216: functions with parameters of different date types may +--echo # return wrong type of the result. +--echo # +create table t1 (f1 date, f2 datetime, f3 varchar(20)); +create table t2 as select coalesce(f1,f1) as f4 from t1; +desc t2; +create table t3 as select coalesce(f1,f2) as f4 from t1; +desc t3; +create table t4 as select coalesce(f2,f2) as f4 from t1; +desc t4; +create table t5 as select coalesce(f1,f3) as f4 from t1; +desc t5; +create table t6 as select coalesce(f2,f3) as f4 from t1; +desc t6; +create table t7 as select coalesce(makedate(1997,1),f2) as f4 from t1; +desc t7; +create table t8 as select coalesce(cast('01-01-01' as datetime),f2) as f4 + from t1; +desc t8; +create table t9 as select case when 1 then cast('01-01-01' as date) + when 0 then cast('01-01-01' as date) end as f4 from t1; +desc t9; +create table t10 as select case when 1 then cast('01-01-01' as datetime) + when 0 then cast('01-01-01' as datetime) end as f4 from t1; +desc t10; +create table t11 as select if(1, cast('01-01-01' as datetime), + cast('01-01-01' as date)) as f4 from t1; +desc t11; +create table t12 as select least(cast('01-01-01' as datetime), + cast('01-01-01' as date)) as f4 from t1; +desc t12; +create table t13 as select ifnull(cast('01-01-01' as datetime), + cast('01-01-01' as date)) as f4 from t1; +desc t13; +drop tables t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13; +--echo ################################################################### diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 86eb10d50b0..1599bcc1571 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -147,6 +147,36 @@ static int agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems) } +/** + @brief Aggregates field types from the array of items. + + @param[in] items array of items to aggregate the type from + @paran[in] nitems number of items in the array + + @details This function aggregates field types from the array of items. + Found type is supposed to be used later as the result field type + of a multi-argument function. + Aggregation itself is performed by the Field::field_type_merge() + function. + + @note The term "aggregation" is used here in the sense of inferring the + result type of a function from its argument types. + + @return aggregated field type. +*/ + +enum_field_types agg_field_type(Item **items, uint nitems) +{ + uint i; + if (!nitems || items[0]->result_type() == ROW_RESULT ) + return (enum_field_types)-1; + enum_field_types res= items[0]->field_type(); + for (i= 1 ; i < nitems ; i++) + res= Field::field_type_merge(res, items[i]->field_type()); + return res; +} + + static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, const char *fname) { @@ -2009,9 +2039,7 @@ Item_func_ifnull::fix_length_and_dec() default: DBUG_ASSERT(0); } - cached_field_type= args[0]->field_type(); - if (cached_field_type != args[1]->field_type()) - cached_field_type= Item_func::field_type(); + cached_field_type= agg_field_type(args, 2); } @@ -2159,11 +2187,13 @@ Item_func_if::fix_length_and_dec() { cached_result_type= arg2_type; collation.set(args[2]->collation.collation); + cached_field_type= args[2]->field_type(); } else if (null2) { cached_result_type= arg1_type; collation.set(args[1]->collation.collation); + cached_field_type= args[1]->field_type(); } else { @@ -2177,6 +2207,7 @@ Item_func_if::fix_length_and_dec() { collation.set(&my_charset_bin); // Number } + cached_field_type= agg_field_type(args + 1, 2); } if ((cached_result_type == DECIMAL_RESULT ) @@ -2556,7 +2587,7 @@ void Item_func_case::fix_length_and_dec() agg_arg_charsets(collation, agg, nagg, MY_COLL_ALLOW_CONV, 1)) return; - + cached_field_type= agg_field_type(agg, nagg); /* Aggregate first expression and all THEN expression types and collations when string comparison @@ -2695,6 +2726,7 @@ my_decimal *Item_func_coalesce::decimal_op(my_decimal *decimal_value) void Item_func_coalesce::fix_length_and_dec() { + cached_field_type= agg_field_type(args, arg_count); agg_result_type(&hybrid_type, args, arg_count); switch (hybrid_type) { case STRING_RESULT: diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 8410c66b034..4d3df7aebf9 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -640,6 +640,7 @@ public: class Item_func_coalesce :public Item_func_numhybrid { protected: + enum_field_types cached_field_type; Item_func_coalesce(Item *a, Item *b) :Item_func_numhybrid(a, b) {} public: Item_func_coalesce(List &list) :Item_func_numhybrid(list) {} @@ -652,13 +653,13 @@ public: enum Item_result result_type () const { return hybrid_type; } const char *func_name() const { return "coalesce"; } table_map not_null_tables() const { return 0; } + enum_field_types field_type() const { return cached_field_type; } }; class Item_func_ifnull :public Item_func_coalesce { protected: - enum_field_types cached_field_type; bool field_type_defined; public: Item_func_ifnull(Item *a, Item *b) :Item_func_coalesce(a,b) {} @@ -677,6 +678,7 @@ public: class Item_func_if :public Item_func { enum Item_result cached_result_type; + enum_field_types cached_field_type; public: Item_func_if(Item *a,Item *b,Item *c) :Item_func(a,b,c), cached_result_type(INT_RESULT) @@ -686,6 +688,7 @@ public: String *val_str(String *str); my_decimal *val_decimal(my_decimal *); enum Item_result result_type () const { return cached_result_type; } + enum_field_types field_type() const { return cached_field_type; } bool fix_fields(THD *, Item **); void fix_length_and_dec(); uint decimal_precision() const; @@ -722,6 +725,7 @@ class Item_func_case :public Item_func uint ncases; Item_result cmp_type; DTCollation cmp_collation; + enum_field_types cached_field_type; public: Item_func_case(List &list, Item *first_expr_arg, Item *else_expr_arg) :Item_func(), first_expr_num(-1), else_expr_num(-1), @@ -749,6 +753,7 @@ public: uint decimal_precision() const; table_map not_null_tables() const { return 0; } enum Item_result result_type () const { return cached_result_type; } + enum_field_types field_type() const { return cached_field_type; } const char *func_name() const { return "case"; } void print(String *str); Item *find_item(String *str); @@ -1382,6 +1387,7 @@ public: bool subst_argument_checker(byte **arg) { return TRUE; } Item *compile(Item_analyzer analyzer, byte **arg_p, Item_transformer transformer, byte *arg_t); + enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; } }; diff --git a/sql/item_func.cc b/sql/item_func.cc index d03d497dfd0..f1c519896b4 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2243,6 +2243,7 @@ void Item_func_min_max::fix_length_and_dec() else if ((cmp_type == DECIMAL_RESULT) || (cmp_type == INT_RESULT)) max_length= my_decimal_precision_to_length(max_int_part+decimals, decimals, unsigned_flag); + cached_field_type= agg_field_type(args, arg_count); } diff --git a/sql/item_func.h b/sql/item_func.h index 56b5e75652c..57e33daf0c4 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -692,7 +692,8 @@ class Item_func_min_max :public Item_func /* An item used for issuing warnings while string to DATETIME conversion. */ Item *datetime_item; THD *thd; - +protected: + enum_field_types cached_field_type; public: Item_func_min_max(List &list,int cmp_sign_arg) :Item_func(list), cmp_type(INT_RESULT), cmp_sign(cmp_sign_arg), compare_as_dates(FALSE), @@ -705,6 +706,7 @@ public: enum Item_result result_type () const { return cmp_type; } bool result_as_longlong() { return compare_as_dates; }; uint cmp_datetimes(ulonglong *value); + enum_field_types field_type() const { return cached_field_type; } }; class Item_func_min :public Item_func_min_max diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index ae18e4786d7..b7c9086c127 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -3310,7 +3310,7 @@ void Item_func_str_to_date::fix_length_and_dec() String format_str(format_buff, sizeof(format_buff), &my_charset_bin), *format; maybe_null= 1; decimals=0; - cached_field_type= MYSQL_TYPE_STRING; + cached_field_type= MYSQL_TYPE_DATETIME; max_length= MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; cached_timestamp_type= MYSQL_TIMESTAMP_NONE; format= args[1]->val_str(&format_str); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 44eb5590a28..5bec94857f7 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1220,6 +1220,7 @@ my_bool mysql_rm_tmp_tables(void); /* item_func.cc */ extern bool check_reserved_words(LEX_STRING *name); +extern enum_field_types agg_field_type(Item **items, uint nitems); /* strfunc.cc */ ulonglong find_set(TYPELIB *lib, const char *x, uint length, CHARSET_INFO *cs, diff --git a/sql/protocol.cc b/sql/protocol.cc index ced6d78519a..2bdbe83eea1 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -824,6 +824,7 @@ bool Protocol_simple::store(const char *from, uint length, field_types[field_pos] == MYSQL_TYPE_DECIMAL || field_types[field_pos] == MYSQL_TYPE_BIT || field_types[field_pos] == MYSQL_TYPE_NEWDECIMAL || + field_types[field_pos] == MYSQL_TYPE_NEWDATE || (field_types[field_pos] >= MYSQL_TYPE_ENUM && field_types[field_pos] <= MYSQL_TYPE_GEOMETRY)); field_pos++; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index f07af393070..fc403132240 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3129,7 +3129,10 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, create_field *cr_field; Field *field, *def_field; if (item->type() == Item::FUNC_ITEM) - field= item->tmp_table_field(&tmp_table); + if (item->result_type() != STRING_RESULT) + field= item->tmp_table_field(&tmp_table); + else + field= item->tmp_table_field_from_field_type(&tmp_table); else field= create_tmp_field(thd, &tmp_table, item, item->type(), (Item ***) 0, &tmp_field, &def_field, 0, 0, 0, 0, From d8fd59a42300122a3e4a04ae5db16e63d4b26df4 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Sat, 22 Sep 2007 12:17:14 +0200 Subject: [PATCH 033/203] Bug#30843 Bad Test addition to t/archive.test --- mysql-test/r/archive.result | 9 ++++----- mysql-test/t/archive.test | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result index a1c11417bd0..a0b13b14b17 100644 --- a/mysql-test/r/archive.result +++ b/mysql-test/r/archive.result @@ -11123,8 +11123,8 @@ auto fld1 companynr fld3 fld4 fld5 fld6 SELECT COUNT(auto) FROM t2; COUNT(auto) 1213 -INSERT DELAYED INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily',''); -INSERT INTO t2 VALUES (5,000001,00,'after','delayed','insert',''); +INSERT DELAYED INTO t2 VALUES (99999,011403,37,'the','delayed','insert',''); +INSERT INTO t2 VALUES (100000,000001,00,'after','delayed','insert',''); SELECT COUNT(auto) FROM t2; COUNT(auto) 1215 @@ -11139,7 +11139,7 @@ t2 CREATE TABLE `t2` ( `fld4` char(35) NOT NULL default '', `fld5` char(35) NOT NULL default '' ) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 -SELECT * from t2; +SELECT * from t2 WHERE auto != 100000; auto fld1 companynr fld3 fld4 fld5 1 000001 00 Omaha teethe neat 2 011401 37 breaking dreaded Steinberg @@ -12354,8 +12354,7 @@ auto fld1 companynr fld3 fld4 fld5 2 011401 37 breaking dreaded Steinberg 3 011402 37 Romans scholastics jarring 4 011403 37 intercepted audiology tinily -4 011403 37 intercepted audiology tinily -5 000001 00 after delayed insert +99999 011403 37 the delayed insert drop table t1, t2, t4; create table t1 (i int) engine=archive; insert into t1 values (1); diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test index d1c45a259c6..2d29cab041d 100644 --- a/mysql-test/t/archive.test +++ b/mysql-test/t/archive.test @@ -1347,13 +1347,13 @@ SELECT * FROM t2; # Test INSERT DELAYED and wait until the table has one more record SELECT COUNT(auto) FROM t2; -INSERT DELAYED INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily',''); +INSERT DELAYED INTO t2 VALUES (99999,011403,37,'the','delayed','insert',''); # Insert another record since in Archive delayed values are only # guaranteed to materialize based on either: # 1) A new row showing up from a normal insert # 2) A flush table has occurred. -INSERT INTO t2 VALUES (5,000001,00,'after','delayed','insert',''); +INSERT INTO t2 VALUES (100000,000001,00,'after','delayed','insert',''); # Wait for the delayed insert to appear while (`SELECT COUNT(auto)!=1215 FROM t2`) @@ -1365,7 +1365,7 @@ SELECT COUNT(auto) FROM t2; # Adding test for alter table ALTER TABLE t2 DROP COLUMN fld6; SHOW CREATE TABLE t2; -SELECT * from t2; +SELECT * from t2 WHERE auto != 100000; # # Cleanup, test is over # From d07a83eadf60906e8c9151b678ee9f69634e4ca4 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Mon, 24 Sep 2007 12:42:44 +0200 Subject: [PATCH 034/203] Add test for named pipes on windows Improve test for shm on windows --- mysql-test/include/windows.inc | 9 +- mysql-test/r/named_pipe.result | 2153 ++++++++++++++++ mysql-test/r/shm.result | 2155 +++++++++++++++++ mysql-test/r/windows_shm.result | 2 - mysql-test/t/named_pipe-master.opt | 1 + mysql-test/t/named_pipe.test | 14 + ...{windows_shm-master.opt => shm-master.opt} | 2 +- mysql-test/t/shm.test | 19 + mysql-test/t/windows_shm.test | 9 - 9 files changed, 4348 insertions(+), 16 deletions(-) create mode 100644 mysql-test/r/named_pipe.result create mode 100644 mysql-test/r/shm.result delete mode 100644 mysql-test/r/windows_shm.result create mode 100644 mysql-test/t/named_pipe-master.opt create mode 100644 mysql-test/t/named_pipe.test rename mysql-test/t/{windows_shm-master.opt => shm-master.opt} (73%) create mode 100644 mysql-test/t/shm.test delete mode 100644 mysql-test/t/windows_shm.test diff --git a/mysql-test/include/windows.inc b/mysql-test/include/windows.inc index 05ec7b0e021..88553d8aa59 100644 --- a/mysql-test/include/windows.inc +++ b/mysql-test/include/windows.inc @@ -1,4 +1,5 @@ ---require r/true.require -disable_query_log; -select convert(@@version_compile_os using latin1) IN ("Win32","Win64","Windows") as "TRUE"; -enable_query_log; +if (`select convert(@@version_compile_os using latin1) IN ("Win32","Win64","Windows") = 0`) +{ + skip Need windows; +} + diff --git a/mysql-test/r/named_pipe.result b/mysql-test/r/named_pipe.result new file mode 100644 index 00000000000..5d22fe4a69b --- /dev/null +++ b/mysql-test/r/named_pipe.result @@ -0,0 +1,2153 @@ +drop table if exists t1,t2,t3,t4; +CREATE TABLE t1 ( +Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, +Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL +); +INSERT INTO t1 VALUES (9410,9412); +select period from t1; +period +9410 +select * from t1; +Period Varor_period +9410 9412 +select t1.* from t1; +Period Varor_period +9410 9412 +CREATE TABLE t2 ( +auto int not null auto_increment, +fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL, +companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL, +fld3 char(30) DEFAULT '' NOT NULL, +fld4 char(35) DEFAULT '' NOT NULL, +fld5 char(35) DEFAULT '' NOT NULL, +fld6 char(4) DEFAULT '' NOT NULL, +UNIQUE fld1 (fld1), +KEY fld3 (fld3), +PRIMARY KEY (auto) +); +select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%"; +fld3 +imaginable +select fld3 from t2 where fld3 like "%cultivation" ; +fld3 +cultivation +select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3,companynr from t2 where companynr = 58 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3 from t2 order by fld3 desc limit 10; +fld3 +youthfulness +yelped +Wotan +workers +Witt +witchcraft +Winsett +Willy +willed +wildcats +select fld3 from t2 order by fld3 desc limit 5; +fld3 +youthfulness +yelped +Wotan +workers +Witt +select fld3 from t2 order by fld3 desc limit 5,5; +fld3 +witchcraft +Winsett +Willy +willed +wildcats +select t2.fld3 from t2 where fld3 = 'honeysuckle'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'h%le'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_'; +fld3 +select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; +fld3 +explain select t2.fld3 from t2 where fld3 = 'honeysuckle'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using index +explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using index +explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using index +explain select fld3 from t2 ignore index (fld3,not_used); +ERROR HY000: Key 'not_used' doesn't exist in table 't2' +explain select fld3 from t2 use index (not_used); +ERROR HY000: Key 'not_used' doesn't exist in table 't2' +select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +fld3 +honeysuckle +honoring +explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range fld3 fld3 30 NULL 2 Using where; Using index +select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; +fld1 fld3 +148504 Colombo +068305 Colombo +000000 nondecreasing +select fld1,fld3 from t2 where companynr = 37 and fld3 = 'appendixes'; +fld1 fld3 +232605 appendixes +1232605 appendixes +1232606 appendixes +1232607 appendixes +1232608 appendixes +1232609 appendixes +select fld1 from t2 where fld1=250501 or fld1="250502"; +fld1 +250501 +250502 +explain select fld1 from t2 where fld1=250501 or fld1="250502"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range fld1 fld1 4 NULL 2 Using where; Using index +select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +fld1 +250501 +250502 +250505 +250601 +explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range fld1 fld1 4 NULL 4 Using where; Using index +select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%'; +fld1 fld3 +218401 faithful +018007 fanatic +228311 fated +018017 featherweight +218022 feed +088303 feminine +058004 Fenton +038017 fetched +018054 fetters +208101 fiftieth +238007 filial +013606 fingerings +218008 finishers +038205 firearm +188505 fitting +202301 Fitzpatrick +238008 fixedly +012001 flanking +018103 flint +018104 flopping +188007 flurried +013602 foldout +226205 foothill +232102 forgivably +228306 forthcoming +186002 freakish +208113 freest +231315 freezes +036002 funereal +226209 furnishings +198006 furthermore +select fld3 from t2 where fld3 like "L%" and fld3 = "ok"; +fld3 +select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly"); +fld3 +Chantilly +select fld1,fld3 from t2 where fld1 like "25050%"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select fld1,fld3 from t2 where fld1 like "25050_"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select distinct companynr from t2; +companynr +00 +37 +36 +50 +58 +29 +40 +53 +65 +41 +34 +68 +select distinct companynr from t2 order by companynr; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr desc; +companynr +68 +65 +58 +53 +50 +41 +40 +37 +36 +34 +29 +00 +select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%"; +fld3 period +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +select distinct fld3 from t2 where companynr = 34 order by fld3; +fld3 +absentee +accessed +ahead +alphabetic +Asiaticizations +attitude +aye +bankruptcies +belays +Blythe +bomb +boulevard +bulldozes +cannot +caressing +charcoal +checksumming +chess +clubroom +colorful +cosy +creator +crying +Darius +diffusing +duality +Eiffel +Epiphany +Ernestine +explorers +exterminated +famine +forked +Gershwins +heaving +Hodges +Iraqis +Italianization +Lagos +landslide +libretto +Majorca +mastering +narrowed +occurred +offerers +Palestine +Peruvianizes +pharmaceutic +poisoning +population +Pygmalion +rats +realest +recording +regimented +retransmitting +reviver +rouses +scars +sicker +sleepwalk +stopped +sugars +translatable +uncles +unexpected +uprisings +versatility +vest +select distinct fld3 from t2 limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct fld3 from t2 having fld3 like "A%" limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct substring(fld3,1,3) from t2 where fld3 like "A%"; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +Adl +adm +Ado +ads +adv +aer +aff +afi +afl +afo +agi +ahe +aim +air +Ald +alg +ali +all +alp +alr +ama +ame +amm +ana +and +ane +Ang +ani +Ann +Ant +api +app +aqu +Ara +arc +Arm +arr +Art +Asi +ask +asp +ass +ast +att +aud +Aug +aut +ave +avo +awe +aye +Azt +select distinct substring(fld3,1,3) as a from t2 having a like "A%" order by a limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) from t2 where fld3 like "A%" limit 10; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +create table t3 ( +period int not null, +name char(32) not null, +companynr int not null, +price double(11,0), +price2 double(11,0), +key (period), +key (name) +); +create temporary table tmp engine = myisam select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +alter table t3 add t2nr int not null auto_increment primary key first; +drop table tmp; +SET SQL_BIG_TABLES=1; +select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; +namn +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +SET SQL_BIG_TABLES=0; +select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; +concat(fld3," ",fld3) +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +select distinct fld5 from t2 limit 10; +fld5 +neat +Steinberg +jarring +tinily +balled +persist +attainments +fanatic +measures +rightfulness +select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10; +fld3 count(*) +affixed 1 +and 1 +annoyers 1 +Anthony 1 +assayed 1 +assurers 1 +attendants 1 +bedlam 1 +bedpost 1 +boasted 1 +SET SQL_BIG_TABLES=1; +select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10; +fld3 count(*) +affixed 1 +and 1 +annoyers 1 +Anthony 1 +assayed 1 +assurers 1 +attendants 1 +bedlam 1 +bedpost 1 +boasted 1 +SET SQL_BIG_TABLES=0; +select distinct fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr,fld3 limit 100,10; +fld3 repeat("a",length(fld3)) count(*) +circus aaaaaa 1 +cited aaaaa 1 +Colombo aaaaaaa 1 +congresswoman aaaaaaaaaaaaa 1 +contrition aaaaaaaaaa 1 +corny aaaaa 1 +cultivation aaaaaaaaaaa 1 +definiteness aaaaaaaaaaaa 1 +demultiplex aaaaaaaaaaa 1 +disappointing aaaaaaaaaaaaa 1 +select distinct companynr,rtrim(space(512+companynr)) from t3 order by 1,2; +companynr rtrim(space(512+companynr)) +37 +78 +101 +154 +311 +447 +512 +select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by fld3; +fld3 +explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using temporary; Using filesort +1 SIMPLE t3 ref period period 4 test.t1.period 4181 +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 index period period 4 NULL 41810 +1 SIMPLE t1 ref period period 4 test.t3.period 4181 +explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index period period 4 NULL 41810 +1 SIMPLE t3 ref period period 4 test.t1.period 4181 +select period from t1; +period +9410 +select period from t1 where period=1900; +period +select fld3,period from t1,t2 where fld1 = 011401 order by period; +fld3 period +breaking 9410 +select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001; +fld3 period +breaking 1001 +explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 const fld1 fld1 4 const 1 +1 SIMPLE t3 const PRIMARY,period PRIMARY 4 const 1 +select fld3,period from t2,t1 where companynr*10 = 37*10; +fld3 period +breaking 9410 +Romans 9410 +intercepted 9410 +bewilderingly 9410 +astound 9410 +admonishing 9410 +sumac 9410 +flanking 9410 +combed 9410 +subjective 9410 +scatterbrain 9410 +Eulerian 9410 +Kane 9410 +overlay 9410 +perturb 9410 +goblins 9410 +annihilates 9410 +Wotan 9410 +snatching 9410 +concludes 9410 +laterally 9410 +yelped 9410 +grazing 9410 +Baird 9410 +celery 9410 +misunderstander 9410 +handgun 9410 +foldout 9410 +mystic 9410 +succumbed 9410 +Nabisco 9410 +fingerings 9410 +aging 9410 +afield 9410 +ammonium 9410 +boat 9410 +intelligibility 9410 +Augustine 9410 +teethe 9410 +dreaded 9410 +scholastics 9410 +audiology 9410 +wallet 9410 +parters 9410 +eschew 9410 +quitter 9410 +neat 9410 +Steinberg 9410 +jarring 9410 +tinily 9410 +balled 9410 +persist 9410 +attainments 9410 +fanatic 9410 +measures 9410 +rightfulness 9410 +capably 9410 +impulsive 9410 +starlet 9410 +terminators 9410 +untying 9410 +announces 9410 +featherweight 9410 +pessimist 9410 +daughter 9410 +decliner 9410 +lawgiver 9410 +stated 9410 +readable 9410 +attrition 9410 +cascade 9410 +motors 9410 +interrogate 9410 +pests 9410 +stairway 9410 +dopers 9410 +testicle 9410 +Parsifal 9410 +leavings 9410 +postulation 9410 +squeaking 9410 +contrasted 9410 +leftover 9410 +whiteners 9410 +erases 9410 +Punjab 9410 +Merritt 9410 +Quixotism 9410 +sweetish 9410 +dogging 9410 +scornfully 9410 +bellow 9410 +bills 9410 +cupboard 9410 +sureties 9410 +puddings 9410 +fetters 9410 +bivalves 9410 +incurring 9410 +Adolph 9410 +pithed 9410 +Miles 9410 +trimmings 9410 +tragedies 9410 +skulking 9410 +flint 9410 +flopping 9410 +relaxing 9410 +offload 9410 +suites 9410 +lists 9410 +animized 9410 +multilayer 9410 +standardizes 9410 +Judas 9410 +vacuuming 9410 +dentally 9410 +humanness 9410 +inch 9410 +Weissmuller 9410 +irresponsibly 9410 +luckily 9410 +culled 9410 +medical 9410 +bloodbath 9410 +subschema 9410 +animals 9410 +Micronesia 9410 +repetitions 9410 +Antares 9410 +ventilate 9410 +pityingly 9410 +interdependent 9410 +Graves 9410 +neonatal 9410 +chafe 9410 +honoring 9410 +realtor 9410 +elite 9410 +funereal 9410 +abrogating 9410 +sorters 9410 +Conley 9410 +lectured 9410 +Abraham 9410 +Hawaii 9410 +cage 9410 +hushes 9410 +Simla 9410 +reporters 9410 +Dutchman 9410 +descendants 9410 +groupings 9410 +dissociate 9410 +coexist 9410 +Beebe 9410 +Taoism 9410 +Connally 9410 +fetched 9410 +checkpoints 9410 +rusting 9410 +galling 9410 +obliterates 9410 +traitor 9410 +resumes 9410 +analyzable 9410 +terminator 9410 +gritty 9410 +firearm 9410 +minima 9410 +Selfridge 9410 +disable 9410 +witchcraft 9410 +betroth 9410 +Manhattanize 9410 +imprint 9410 +peeked 9410 +swelling 9410 +interrelationships 9410 +riser 9410 +Gandhian 9410 +peacock 9410 +bee 9410 +kanji 9410 +dental 9410 +scarf 9410 +chasm 9410 +insolence 9410 +syndicate 9410 +alike 9410 +imperial 9410 +convulsion 9410 +railway 9410 +validate 9410 +normalizes 9410 +comprehensive 9410 +chewing 9410 +denizen 9410 +schemer 9410 +chronicle 9410 +Kline 9410 +Anatole 9410 +partridges 9410 +brunch 9410 +recruited 9410 +dimensions 9410 +Chicana 9410 +announced 9410 +praised 9410 +employing 9410 +linear 9410 +quagmire 9410 +western 9410 +relishing 9410 +serving 9410 +scheduling 9410 +lore 9410 +eventful 9410 +arteriole 9410 +disentangle 9410 +cured 9410 +Fenton 9410 +avoidable 9410 +drains 9410 +detectably 9410 +husky 9410 +impelling 9410 +undoes 9410 +evened 9410 +squeezes 9410 +destroyer 9410 +rudeness 9410 +beaner 9410 +boorish 9410 +Everhart 9410 +encompass 9410 +mushrooms 9410 +Alison 9410 +externally 9410 +pellagra 9410 +cult 9410 +creek 9410 +Huffman 9410 +Majorca 9410 +governing 9410 +gadfly 9410 +reassigned 9410 +intentness 9410 +craziness 9410 +psychic 9410 +squabbled 9410 +burlesque 9410 +capped 9410 +extracted 9410 +DiMaggio 9410 +exclamation 9410 +subdirectory 9410 +Gothicism 9410 +feminine 9410 +metaphysically 9410 +sanding 9410 +Miltonism 9410 +freakish 9410 +index 9410 +straight 9410 +flurried 9410 +denotative 9410 +coming 9410 +commencements 9410 +gentleman 9410 +gifted 9410 +Shanghais 9410 +sportswriting 9410 +sloping 9410 +navies 9410 +leaflet 9410 +shooter 9410 +Joplin 9410 +babies 9410 +assails 9410 +admiring 9410 +swaying 9410 +Goldstine 9410 +fitting 9410 +Norwalk 9410 +analogy 9410 +deludes 9410 +cokes 9410 +Clayton 9410 +exhausts 9410 +causality 9410 +sating 9410 +icon 9410 +throttles 9410 +communicants 9410 +dehydrate 9410 +priceless 9410 +publicly 9410 +incidentals 9410 +commonplace 9410 +mumbles 9410 +furthermore 9410 +cautioned 9410 +parametrized 9410 +registration 9410 +sadly 9410 +positioning 9410 +babysitting 9410 +eternal 9410 +hoarder 9410 +congregates 9410 +rains 9410 +workers 9410 +sags 9410 +unplug 9410 +garage 9410 +boulder 9410 +specifics 9410 +Teresa 9410 +Winsett 9410 +convenient 9410 +buckboards 9410 +amenities 9410 +resplendent 9410 +sews 9410 +participated 9410 +Simon 9410 +certificates 9410 +Fitzpatrick 9410 +Evanston 9410 +misted 9410 +textures 9410 +save 9410 +count 9410 +rightful 9410 +chaperone 9410 +Lizzy 9410 +clenched 9410 +effortlessly 9410 +accessed 9410 +beaters 9410 +Hornblower 9410 +vests 9410 +indulgences 9410 +infallibly 9410 +unwilling 9410 +excrete 9410 +spools 9410 +crunches 9410 +overestimating 9410 +ineffective 9410 +humiliation 9410 +sophomore 9410 +star 9410 +rifles 9410 +dialysis 9410 +arriving 9410 +indulge 9410 +clockers 9410 +languages 9410 +Antarctica 9410 +percentage 9410 +ceiling 9410 +specification 9410 +regimented 9410 +ciphers 9410 +pictures 9410 +serpents 9410 +allot 9410 +realized 9410 +mayoral 9410 +opaquely 9410 +hostess 9410 +fiftieth 9410 +incorrectly 9410 +decomposition 9410 +stranglings 9410 +mixture 9410 +electroencephalography 9410 +similarities 9410 +charges 9410 +freest 9410 +Greenberg 9410 +tinting 9410 +expelled 9410 +warm 9410 +smoothed 9410 +deductions 9410 +Romano 9410 +bitterroot 9410 +corset 9410 +securing 9410 +environing 9410 +cute 9410 +Crays 9410 +heiress 9410 +inform 9410 +avenge 9410 +universals 9410 +Kinsey 9410 +ravines 9410 +bestseller 9410 +equilibrium 9410 +extents 9410 +relatively 9410 +pressure 9410 +critiques 9410 +befouled 9410 +rightfully 9410 +mechanizing 9410 +Latinizes 9410 +timesharing 9410 +Aden 9410 +embassies 9410 +males 9410 +shapelessly 9410 +mastering 9410 +Newtonian 9410 +finishers 9410 +abates 9410 +teem 9410 +kiting 9410 +stodgy 9410 +feed 9410 +guitars 9410 +airships 9410 +store 9410 +denounces 9410 +Pyle 9410 +Saxony 9410 +serializations 9410 +Peruvian 9410 +taxonomically 9410 +kingdom 9410 +stint 9410 +Sault 9410 +faithful 9410 +Ganymede 9410 +tidiness 9410 +gainful 9410 +contrary 9410 +Tipperary 9410 +tropics 9410 +theorizers 9410 +renew 9410 +already 9410 +terminal 9410 +Hegelian 9410 +hypothesizer 9410 +warningly 9410 +journalizing 9410 +nested 9410 +Lars 9410 +saplings 9410 +foothill 9410 +labeled 9410 +imperiously 9410 +reporters 9410 +furnishings 9410 +precipitable 9410 +discounts 9410 +excises 9410 +Stalin 9410 +despot 9410 +ripeness 9410 +Arabia 9410 +unruly 9410 +mournfulness 9410 +boom 9410 +slaughter 9410 +Sabine 9410 +handy 9410 +rural 9410 +organizer 9410 +shipyard 9410 +civics 9410 +inaccuracy 9410 +rules 9410 +juveniles 9410 +comprised 9410 +investigations 9410 +stabilizes 9410 +seminaries 9410 +Hunter 9410 +sporty 9410 +test 9410 +weasels 9410 +CERN 9410 +tempering 9410 +afore 9410 +Galatean 9410 +techniques 9410 +error 9410 +veranda 9410 +severely 9410 +Cassites 9410 +forthcoming 9410 +guides 9410 +vanish 9410 +lied 9410 +sawtooth 9410 +fated 9410 +gradually 9410 +widens 9410 +preclude 9410 +evenhandedly 9410 +percentage 9410 +disobedience 9410 +humility 9410 +gleaning 9410 +petted 9410 +bloater 9410 +minion 9410 +marginal 9410 +apiary 9410 +measures 9410 +precaution 9410 +repelled 9410 +primary 9410 +coverings 9410 +Artemia 9410 +navigate 9410 +spatial 9410 +Gurkha 9410 +meanwhile 9410 +Melinda 9410 +Butterfield 9410 +Aldrich 9410 +previewing 9410 +glut 9410 +unaffected 9410 +inmate 9410 +mineral 9410 +impending 9410 +meditation 9410 +ideas 9410 +miniaturizes 9410 +lewdly 9410 +title 9410 +youthfulness 9410 +creak 9410 +Chippewa 9410 +clamored 9410 +freezes 9410 +forgivably 9410 +reduce 9410 +McGovern 9410 +Nazis 9410 +epistle 9410 +socializes 9410 +conceptions 9410 +Kevin 9410 +uncovering 9410 +chews 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +raining 9410 +infest 9410 +compartment 9410 +minting 9410 +ducks 9410 +roped 9410 +waltz 9410 +Lillian 9410 +repressions 9410 +chillingly 9410 +noncritical 9410 +lithograph 9410 +spongers 9410 +parenthood 9410 +posed 9410 +instruments 9410 +filial 9410 +fixedly 9410 +relives 9410 +Pandora 9410 +watering 9410 +ungrateful 9410 +secures 9410 +poison 9410 +dusted 9410 +encompasses 9410 +presentation 9410 +Kantian 9410 +select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +fld3 period price price2 +admonishing 1002 28357832 8723648 +analyzable 1002 28357832 8723648 +annihilates 1001 5987435 234724 +Antares 1002 28357832 8723648 +astound 1001 5987435 234724 +audiology 1001 5987435 234724 +Augustine 1002 28357832 8723648 +Baird 1002 28357832 8723648 +bewilderingly 1001 5987435 234724 +breaking 1001 5987435 234724 +Conley 1001 5987435 234724 +dentally 1002 28357832 8723648 +dissociate 1002 28357832 8723648 +elite 1001 5987435 234724 +eschew 1001 5987435 234724 +Eulerian 1001 5987435 234724 +flanking 1001 5987435 234724 +foldout 1002 28357832 8723648 +funereal 1002 28357832 8723648 +galling 1002 28357832 8723648 +Graves 1001 5987435 234724 +grazing 1001 5987435 234724 +groupings 1001 5987435 234724 +handgun 1001 5987435 234724 +humility 1002 28357832 8723648 +impulsive 1002 28357832 8723648 +inch 1001 5987435 234724 +intelligibility 1001 5987435 234724 +jarring 1001 5987435 234724 +lawgiver 1001 5987435 234724 +lectured 1002 28357832 8723648 +Merritt 1002 28357832 8723648 +neonatal 1001 5987435 234724 +offload 1002 28357832 8723648 +parters 1002 28357832 8723648 +pityingly 1002 28357832 8723648 +puddings 1002 28357832 8723648 +Punjab 1001 5987435 234724 +quitter 1002 28357832 8723648 +realtor 1001 5987435 234724 +relaxing 1001 5987435 234724 +repetitions 1001 5987435 234724 +resumes 1001 5987435 234724 +Romans 1002 28357832 8723648 +rusting 1001 5987435 234724 +scholastics 1001 5987435 234724 +skulking 1002 28357832 8723648 +stated 1002 28357832 8723648 +suites 1002 28357832 8723648 +sureties 1001 5987435 234724 +testicle 1002 28357832 8723648 +tinily 1002 28357832 8723648 +tragedies 1001 5987435 234724 +trimmings 1001 5987435 234724 +vacuuming 1001 5987435 234724 +ventilate 1001 5987435 234724 +wallet 1001 5987435 234724 +Weissmuller 1002 28357832 8723648 +Wotan 1002 28357832 8723648 +select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37; +fld1 fld3 period price price2 +018201 relaxing 1001 5987435 234724 +018601 vacuuming 1001 5987435 234724 +018801 inch 1001 5987435 234724 +018811 repetitions 1001 5987435 234724 +create table t4 ( +companynr tinyint(2) unsigned zerofill NOT NULL default '00', +companyname char(30) NOT NULL default '', +PRIMARY KEY (companynr), +UNIQUE KEY companyname(companyname) +) ENGINE=MyISAM MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; +select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select SQL_SMALL_RESULT t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select * from t1,t1 t12; +Period Varor_period Period Varor_period +9410 9412 9410 9412 +select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505; +fld1 fld1 +250501 250501 +250502 250501 +250503 250501 +250504 250501 +250505 250501 +250501 250502 +250502 250502 +250503 250502 +250504 250502 +250505 250502 +250501 250503 +250502 250503 +250503 250503 +250504 250503 +250505 250503 +250501 250504 +250502 250504 +250503 250504 +250504 250504 +250505 250504 +250501 250505 +250502 250505 +250503 250505 +250504 250505 +250505 250505 +insert into t2 (fld1, companynr) values (999999,99); +select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +companynr companyname +99 NULL +select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null; +count(*) +1199 +explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 +1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 Using where; Not exists +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL NULL NULL NULL NULL 12 +1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 Using where; Not exists +select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +companynr companyname +select count(*) from t2 left join t4 using (companynr) where companynr is not null; +count(*) +1200 +explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +delete from t2 where fld1=999999; +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL NULL NULL NULL NULL 12 +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL NULL NULL NULL NULL 12 +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 +explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 +select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +companynr companynr +37 36 +41 40 +explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909); +period +9410 +select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6))); +period +9410 +select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1; +fld1 +250501 +250502 +250503 +250505 +select fld1 from t2 where fld1 in (250502,98005,98006,250503,250605,250606) and fld1 >=250502 and fld1 not in (250605,250606); +fld1 +250502 +250503 +select fld1 from t2 where fld1 between 250502 and 250504; +fld1 +250502 +250503 +250504 +select fld3 from t2 where (((fld3 like "_%L%" ) or (fld3 like "%ok%")) and ( fld3 like "L%" or fld3 like "G%")) and fld3 like "L%" ; +fld3 +label +labeled +labeled +landslide +laterally +leaflet +lewdly +Lillian +luckily +select count(*) from t1; +count(*) +1 +select companynr,count(*),sum(fld1) from t2 group by companynr; +companynr count(*) sum(fld1) +00 82 10355753 +29 95 14473298 +34 70 17788966 +36 215 22786296 +37 588 83602098 +40 37 6618386 +41 52 12816335 +50 11 1595438 +53 4 793210 +58 23 2254293 +65 10 2284055 +68 12 3097288 +select companynr,count(*) from t2 group by companynr order by companynr desc limit 5; +companynr count(*) +68 12 +65 10 +58 23 +53 4 +50 11 +select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +70 absentee vest 17788966 254128.0857 3272.5940 10709871.3069 +explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +Warnings: +Note 1003 select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> _latin1'')) +select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3; +companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +00 82 Anthony windmills 10355753 126289.6707 115550.9757 13352027981.7087 +29 95 abut wetness 14473298 152350.5053 8368.5480 70032594.9026 +34 70 absentee vest 17788966 254128.0857 3272.5940 10709871.3069 +select companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select /*! SQL_SMALL_RESULT */ companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr ; +companynr count(price) sum(price) min(price) max(price) avg(price) +37 12543 309394878010 5987435 39654943 24666736.6667 +78 8362 414611089292 726498 98439034 49582766.0000 +101 4181 3489454238 834598 834598 834598.0000 +154 4181 4112197254950 983543950 983543950 983543950.0000 +311 4181 979599938 234298 234298 234298.0000 +447 4181 9929180954 2374834 2374834 2374834.0000 +512 4181 3288532102 786542 786542 786542.0000 +select distinct mod(companynr,10) from t4 group by companynr; +mod(companynr,10) +0 +9 +4 +6 +7 +1 +3 +8 +5 +select distinct 1 from t4 group by companynr; +1 +1 +select count(distinct fld1) from t2; +count(distinct fld1) +1199 +select companynr,count(distinct fld1) from t2 group by companynr; +companynr count(distinct fld1) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(*) from t2 group by companynr; +companynr count(*) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,1000))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,1000))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,200))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,200))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct floor(fld1/100)) from t2 group by companynr; +companynr count(distinct floor(fld1/100)) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select companynr,count(distinct concat(repeat(65,1000),floor(fld1/100))) from t2 group by companynr; +companynr count(distinct concat(repeat(65,1000),floor(fld1/100))) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select sum(fld1),fld3 from t2 where fld3="Romans" group by fld1 limit 10; +sum(fld1) fld3 +11402 Romans +select name,count(*) from t3 where name='cloakroom' group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name='cloakroom' and price>10 group by name; +name count(*) +cloakroom 4181 +select count(*) from t3 where name='cloakroom' and price2=823742; +count(*) +4181 +select name,count(*) from t3 where name='cloakroom' and price2=823742 group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name >= "extramarital" and price <= 39654943 group by name; +name count(*) +extramarital 4181 +gazer 4181 +gems 4181 +Iranizes 4181 +spates 4181 +tucked 4181 +violinist 4181 +select t2.fld3,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld3 count(*) +spates 4181 +select companynr|0,companyname from t4 group by 1; +companynr|0 companyname +0 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by t2.companynr order by companyname; +companynr companyname count(*) +29 company 1 95 +68 company 10 12 +50 company 11 11 +34 company 2 70 +36 company 3 215 +37 company 4 588 +40 company 5 37 +41 company 6 52 +53 company 7 4 +58 company 8 23 +65 company 9 10 +00 Unknown 82 +select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld1 count(*) +158402 4181 +select sum(Period)/count(*) from t1; +sum(Period)/count(*) +9410.0000 +select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr; +companynr count sum diff func +37 12543 309394878010 0.0000 464091 +78 8362 414611089292 0.0000 652236 +101 4181 3489454238 0.0000 422281 +154 4181 4112197254950 0.0000 643874 +311 4181 979599938 0.0000 1300291 +447 4181 9929180954 0.0000 1868907 +512 4181 3288532102 0.0000 2140672 +select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg; +companynr avg +154 983543950.0000 +select companynr,count(*) from t2 group by companynr order by 2 desc; +companynr count(*) +37 588 +36 215 +29 95 +00 82 +34 70 +41 52 +40 37 +58 23 +68 12 +50 11 +65 10 +53 4 +select companynr,count(*) from t2 where companynr > 40 group by companynr order by 2 desc; +companynr count(*) +41 52 +58 23 +68 12 +50 11 +65 10 +53 4 +select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) from t3,t2 where t3.companynr = 37 and t2.fld1 = t3.t2nr group by fld1,t2.fld4; +fld4 fld1 count(price) sum(price) min(price) max(price) avg(price) +teethe 000001 1 5987435 5987435 5987435 5987435.0000 +dreaded 011401 1 5987435 5987435 5987435 5987435.0000 +scholastics 011402 1 28357832 28357832 28357832 28357832.0000 +audiology 011403 1 39654943 39654943 39654943 39654943.0000 +wallet 011501 1 5987435 5987435 5987435 5987435.0000 +parters 011701 1 5987435 5987435 5987435 5987435.0000 +eschew 011702 1 28357832 28357832 28357832 28357832.0000 +quitter 011703 1 39654943 39654943 39654943 39654943.0000 +neat 012001 1 5987435 5987435 5987435 5987435.0000 +Steinberg 012003 1 39654943 39654943 39654943 39654943.0000 +balled 012301 1 5987435 5987435 5987435 5987435.0000 +persist 012302 1 28357832 28357832 28357832 28357832.0000 +attainments 012303 1 39654943 39654943 39654943 39654943.0000 +capably 012501 1 5987435 5987435 5987435 5987435.0000 +impulsive 012602 1 28357832 28357832 28357832 28357832.0000 +starlet 012603 1 39654943 39654943 39654943 39654943.0000 +featherweight 012701 1 5987435 5987435 5987435 5987435.0000 +pessimist 012702 1 28357832 28357832 28357832 28357832.0000 +daughter 012703 1 39654943 39654943 39654943 39654943.0000 +lawgiver 013601 1 5987435 5987435 5987435 5987435.0000 +stated 013602 1 28357832 28357832 28357832 28357832.0000 +readable 013603 1 39654943 39654943 39654943 39654943.0000 +testicle 013801 1 5987435 5987435 5987435 5987435.0000 +Parsifal 013802 1 28357832 28357832 28357832 28357832.0000 +leavings 013803 1 39654943 39654943 39654943 39654943.0000 +squeaking 013901 1 5987435 5987435 5987435 5987435.0000 +contrasted 016001 1 5987435 5987435 5987435 5987435.0000 +leftover 016201 1 5987435 5987435 5987435 5987435.0000 +whiteners 016202 1 28357832 28357832 28357832 28357832.0000 +erases 016301 1 5987435 5987435 5987435 5987435.0000 +Punjab 016302 1 28357832 28357832 28357832 28357832.0000 +Merritt 016303 1 39654943 39654943 39654943 39654943.0000 +sweetish 018001 1 5987435 5987435 5987435 5987435.0000 +dogging 018002 1 28357832 28357832 28357832 28357832.0000 +scornfully 018003 1 39654943 39654943 39654943 39654943.0000 +fetters 018012 1 28357832 28357832 28357832 28357832.0000 +bivalves 018013 1 39654943 39654943 39654943 39654943.0000 +skulking 018021 1 5987435 5987435 5987435 5987435.0000 +flint 018022 1 28357832 28357832 28357832 28357832.0000 +flopping 018023 1 39654943 39654943 39654943 39654943.0000 +Judas 018032 1 28357832 28357832 28357832 28357832.0000 +vacuuming 018033 1 39654943 39654943 39654943 39654943.0000 +medical 018041 1 5987435 5987435 5987435 5987435.0000 +bloodbath 018042 1 28357832 28357832 28357832 28357832.0000 +subschema 018043 1 39654943 39654943 39654943 39654943.0000 +interdependent 018051 1 5987435 5987435 5987435 5987435.0000 +Graves 018052 1 28357832 28357832 28357832 28357832.0000 +neonatal 018053 1 39654943 39654943 39654943 39654943.0000 +sorters 018061 1 5987435 5987435 5987435 5987435.0000 +epistle 018062 1 28357832 28357832 28357832 28357832.0000 +Conley 018101 1 5987435 5987435 5987435 5987435.0000 +lectured 018102 1 28357832 28357832 28357832 28357832.0000 +Abraham 018103 1 39654943 39654943 39654943 39654943.0000 +cage 018201 1 5987435 5987435 5987435 5987435.0000 +hushes 018202 1 28357832 28357832 28357832 28357832.0000 +Simla 018402 1 28357832 28357832 28357832 28357832.0000 +reporters 018403 1 39654943 39654943 39654943 39654943.0000 +coexist 018601 1 5987435 5987435 5987435 5987435.0000 +Beebe 018602 1 28357832 28357832 28357832 28357832.0000 +Taoism 018603 1 39654943 39654943 39654943 39654943.0000 +Connally 018801 1 5987435 5987435 5987435 5987435.0000 +fetched 018802 1 28357832 28357832 28357832 28357832.0000 +checkpoints 018803 1 39654943 39654943 39654943 39654943.0000 +gritty 018811 1 5987435 5987435 5987435 5987435.0000 +firearm 018812 1 28357832 28357832 28357832 28357832.0000 +minima 019101 1 5987435 5987435 5987435 5987435.0000 +Selfridge 019102 1 28357832 28357832 28357832 28357832.0000 +disable 019103 1 39654943 39654943 39654943 39654943.0000 +witchcraft 019201 1 5987435 5987435 5987435 5987435.0000 +betroth 030501 1 5987435 5987435 5987435 5987435.0000 +Manhattanize 030502 1 28357832 28357832 28357832 28357832.0000 +imprint 030503 1 39654943 39654943 39654943 39654943.0000 +swelling 031901 1 5987435 5987435 5987435 5987435.0000 +interrelationships 036001 1 5987435 5987435 5987435 5987435.0000 +riser 036002 1 28357832 28357832 28357832 28357832.0000 +bee 038001 1 5987435 5987435 5987435 5987435.0000 +kanji 038002 1 28357832 28357832 28357832 28357832.0000 +dental 038003 1 39654943 39654943 39654943 39654943.0000 +railway 038011 1 5987435 5987435 5987435 5987435.0000 +validate 038012 1 28357832 28357832 28357832 28357832.0000 +normalizes 038013 1 39654943 39654943 39654943 39654943.0000 +Kline 038101 1 5987435 5987435 5987435 5987435.0000 +Anatole 038102 1 28357832 28357832 28357832 28357832.0000 +partridges 038103 1 39654943 39654943 39654943 39654943.0000 +recruited 038201 1 5987435 5987435 5987435 5987435.0000 +dimensions 038202 1 28357832 28357832 28357832 28357832.0000 +Chicana 038203 1 39654943 39654943 39654943 39654943.0000 +select t3.companynr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 group by companynr,fld3; +companynr fld3 sum(price) +512 boat 786542 +512 capably 786542 +512 cupboard 786542 +512 decliner 786542 +512 descendants 786542 +512 dopers 786542 +512 erases 786542 +512 Micronesia 786542 +512 Miles 786542 +512 skies 786542 +select t2.companynr,count(*),min(fld3),max(fld3),sum(price),avg(price) from t2,t3 where t3.companynr >= 30 and t3.companynr <= 58 and t3.t2nr = t2.fld1 and 1+1=2 group by t2.companynr; +companynr count(*) min(fld3) max(fld3) sum(price) avg(price) +00 1 Omaha Omaha 5987435 5987435.0000 +36 1 dubbed dubbed 28357832 28357832.0000 +37 83 Abraham Wotan 1908978016 22999735.1325 +50 2 scribbled tapestry 68012775 34006387.5000 +select t3.companynr+0,t3.t2nr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 37 group by 1,t3.t2nr,fld3,fld3,fld3,fld3,fld3 order by fld1; +t3.companynr+0 t2nr fld3 sum(price) +37 1 Omaha 5987435 +37 11401 breaking 5987435 +37 11402 Romans 28357832 +37 11403 intercepted 39654943 +37 11501 bewilderingly 5987435 +37 11701 astound 5987435 +37 11702 admonishing 28357832 +37 11703 sumac 39654943 +37 12001 flanking 5987435 +37 12003 combed 39654943 +37 12301 Eulerian 5987435 +37 12302 dubbed 28357832 +37 12303 Kane 39654943 +37 12501 annihilates 5987435 +37 12602 Wotan 28357832 +37 12603 snatching 39654943 +37 12701 grazing 5987435 +37 12702 Baird 28357832 +37 12703 celery 39654943 +37 13601 handgun 5987435 +37 13602 foldout 28357832 +37 13603 mystic 39654943 +37 13801 intelligibility 5987435 +37 13802 Augustine 28357832 +37 13803 teethe 39654943 +37 13901 scholastics 5987435 +37 16001 audiology 5987435 +37 16201 wallet 5987435 +37 16202 parters 28357832 +37 16301 eschew 5987435 +37 16302 quitter 28357832 +37 16303 neat 39654943 +37 18001 jarring 5987435 +37 18002 tinily 28357832 +37 18003 balled 39654943 +37 18012 impulsive 28357832 +37 18013 starlet 39654943 +37 18021 lawgiver 5987435 +37 18022 stated 28357832 +37 18023 readable 39654943 +37 18032 testicle 28357832 +37 18033 Parsifal 39654943 +37 18041 Punjab 5987435 +37 18042 Merritt 28357832 +37 18043 Quixotism 39654943 +37 18051 sureties 5987435 +37 18052 puddings 28357832 +37 18053 tapestry 39654943 +37 18061 trimmings 5987435 +37 18062 humility 28357832 +37 18101 tragedies 5987435 +37 18102 skulking 28357832 +37 18103 flint 39654943 +37 18201 relaxing 5987435 +37 18202 offload 28357832 +37 18402 suites 28357832 +37 18403 lists 39654943 +37 18601 vacuuming 5987435 +37 18602 dentally 28357832 +37 18603 humanness 39654943 +37 18801 inch 5987435 +37 18802 Weissmuller 28357832 +37 18803 irresponsibly 39654943 +37 18811 repetitions 5987435 +37 18812 Antares 28357832 +37 19101 ventilate 5987435 +37 19102 pityingly 28357832 +37 19103 interdependent 39654943 +37 19201 Graves 5987435 +37 30501 neonatal 5987435 +37 30502 scribbled 28357832 +37 30503 chafe 39654943 +37 31901 realtor 5987435 +37 36001 elite 5987435 +37 36002 funereal 28357832 +37 38001 Conley 5987435 +37 38002 lectured 28357832 +37 38003 Abraham 39654943 +37 38011 groupings 5987435 +37 38012 dissociate 28357832 +37 38013 coexist 39654943 +37 38101 rusting 5987435 +37 38102 galling 28357832 +37 38103 obliterates 39654943 +37 38201 resumes 5987435 +37 38202 analyzable 28357832 +37 38203 terminator 39654943 +select sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1= t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008; +sum(price) +234298 +select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1 = t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008 or t3.t2nr = t2.fld1 and t2.fld1 = 38008 group by t2.fld1; +fld1 sum(price) +038008 234298 +explain select fld3 from t2 where 1>2 or 2>3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +explain select fld3 from t2 where fld1=fld1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 +select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,fld1 from t2 WHERE fld1>=250501 HAVING fld1<=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,count(*) as count,sum(fld1) as sum from t2 group by companynr having count > 40 and sum/count >= 120000; +companynr count sum +00 82 10355753 +29 95 14473298 +34 70 17788966 +37 588 83602098 +41 52 12816335 +select companynr from t2 group by companynr having count(*) > 40 and sum(fld1)/count(*) >= 120000 ; +companynr +00 +29 +34 +37 +41 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by companyname having t2.companynr >= 40; +companynr companyname count(*) +68 company 10 12 +50 company 11 11 +40 company 5 37 +41 company 6 52 +53 company 7 4 +58 company 8 23 +65 company 9 10 +select count(*) from t2; +count(*) +1199 +select count(*) from t2 where fld1 < 098024; +count(*) +387 +select min(fld1) from t2 where fld1>= 098024; +min(fld1) +98024 +select max(fld1) from t2 where fld1>= 098024; +max(fld1) +1232609 +select count(*) from t3 where price2=76234234; +count(*) +4181 +select count(*) from t3 where companynr=512 and price2=76234234; +count(*) +4181 +explain select min(fld1),max(fld1),count(*) from t2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select min(fld1),max(fld1),count(*) from t2; +min(fld1) max(fld1) count(*) +0 1232609 1199 +select min(t2nr),max(t2nr) from t3 where t2nr=2115 and price2=823742; +min(t2nr) max(t2nr) +2115 2115 +select count(*),min(t2nr),max(t2nr) from t3 where name='spates' and companynr=78; +count(*) min(t2nr) max(t2nr) +4181 4 41804 +select t2nr,count(*) from t3 where name='gems' group by t2nr limit 20; +t2nr count(*) +9 1 +19 1 +29 1 +39 1 +49 1 +59 1 +69 1 +79 1 +89 1 +99 1 +109 1 +119 1 +129 1 +139 1 +149 1 +159 1 +169 1 +179 1 +189 1 +199 1 +select max(t2nr) from t3 where price=983543950; +max(t2nr) +41807 +select t1.period from t3 = t1 limit 1; +period +1001 +select t1.period from t1 as t1 limit 1; +period +9410 +select t1.period as "Nuvarande period" from t1 as t1 limit 1; +Nuvarande period +9410 +select period as ok_period from t1 limit 1; +ok_period +9410 +select period as ok_period from t1 group by ok_period limit 1; +ok_period +9410 +select 1+1 as summa from t1 group by summa limit 1; +summa +2 +select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1; +Nuvarande period +9410 +show tables; +Tables_in_test +t1 +t2 +t3 +t4 +show tables from test like "s%"; +Tables_in_test (s%) +show tables from test like "t?"; +Tables_in_test (t?) +show full columns from t2; +Field Type Collation Null Key Default Extra Privileges Comment +auto int(11) NULL NO PRI NULL auto_increment # +fld1 int(6) unsigned zerofill NULL NO UNI 000000 # +companynr tinyint(2) unsigned zerofill NULL NO 00 # +fld3 char(30) latin1_swedish_ci NO MUL # +fld4 char(35) latin1_swedish_ci NO # +fld5 char(35) latin1_swedish_ci NO # +fld6 char(4) latin1_swedish_ci NO # +show full columns from t2 from test like 'f%'; +Field Type Collation Null Key Default Extra Privileges Comment +fld1 int(6) unsigned zerofill NULL NO UNI 000000 # +fld3 char(30) latin1_swedish_ci NO MUL # +fld4 char(35) latin1_swedish_ci NO # +fld5 char(35) latin1_swedish_ci NO # +fld6 char(4) latin1_swedish_ci NO # +show full columns from t2 from test like 's%'; +Field Type Collation Null Key Default Extra Privileges Comment +show keys from t2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE +t2 1 fld3 1 fld3 A NULL NULL NULL BTREE +drop table t4, t3, t2, t1; +CREATE TABLE t1 ( +cont_nr int(11) NOT NULL auto_increment, +ver_nr int(11) NOT NULL default '0', +aufnr int(11) NOT NULL default '0', +username varchar(50) NOT NULL default '', +hdl_nr int(11) NOT NULL default '0', +eintrag date NOT NULL default '0000-00-00', +st_klasse varchar(40) NOT NULL default '', +st_wert varchar(40) NOT NULL default '', +st_zusatz varchar(40) NOT NULL default '', +st_bemerkung varchar(255) NOT NULL default '', +kunden_art varchar(40) NOT NULL default '', +mcbs_knr int(11) default NULL, +mcbs_aufnr int(11) NOT NULL default '0', +schufa_status char(1) default '?', +bemerkung text, +wirknetz text, +wf_igz int(11) NOT NULL default '0', +tarifcode varchar(80) default NULL, +recycle char(1) default NULL, +sim varchar(30) default NULL, +mcbs_tpl varchar(30) default NULL, +emp_nr int(11) NOT NULL default '0', +laufzeit int(11) default NULL, +hdl_name varchar(30) default NULL, +prov_hdl_nr int(11) NOT NULL default '0', +auto_wirknetz varchar(50) default NULL, +auto_billing varchar(50) default NULL, +touch timestamp NOT NULL, +kategorie varchar(50) default NULL, +kundentyp varchar(20) NOT NULL default '', +sammel_rech_msisdn varchar(30) NOT NULL default '', +p_nr varchar(9) NOT NULL default '', +suffix char(3) NOT NULL default '', +PRIMARY KEY (cont_nr), +KEY idx_aufnr(aufnr), +KEY idx_hdl_nr(hdl_nr), +KEY idx_st_klasse(st_klasse), +KEY ver_nr(ver_nr), +KEY eintrag_idx(eintrag), +KEY emp_nr_idx(emp_nr), +KEY wf_igz(wf_igz), +KEY touch(touch), +KEY hdl_tag(eintrag,hdl_nr), +KEY prov_hdl_nr(prov_hdl_nr), +KEY mcbs_aufnr(mcbs_aufnr), +KEY kundentyp(kundentyp), +KEY p_nr(p_nr,suffix) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES (3359356,405,3359356,'Mustermann Musterfrau',52500,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1485525,2122316,'+','','N',1909160,'MobilComSuper92000D2',NULL,NULL,'MS9ND2',3,24,'MobilCom Shop Koeln',52500,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359357,468,3359357,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1503580,2139699,'+','','P',1909171,'MobilComSuper9D1T10SFreisprech(Akquise)',NULL,NULL,'MS9NS1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359358,407,3359358,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1501358,2137473,'N','','N',1909159,'MobilComSuper92000D2',NULL,NULL,'MS9ND2',325,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359359,468,3359359,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1507831,2143894,'+','','P',1909162,'MobilComSuper9D1T10SFreisprech(Akquise)',NULL,NULL,'MS9NS1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359360,0,0,'Mustermann Musterfrau',29674907,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1900169997,2414578,'+',NULL,'N',1909148,'',NULL,NULL,'RV99066_2',20,NULL,'POS',29674907,NULL,NULL,20010202105916,'Mobilfunk','','','97317481','007'); +INSERT INTO t1 VALUES (3359361,406,3359361,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag storniert','','(7001-84):Storno, Kd. möchte nicht mehr','privat',NULL,0,'+','','P',1909150,'MobilComSuper92000D1(Akquise)',NULL,NULL,'MS9ND1',325,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359362,406,3359362,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1509984,2145874,'+','','P',1909154,'MobilComSuper92000D1(Akquise)',NULL,NULL,'MS9ND1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +SELECT ELT(FIELD(kundentyp,'PP','PPA','PG','PGA','FK','FKA','FP','FPA','K','KA','V','VA',''), 'Privat (Private Nutzung)','Privat (Private Nutzung) Sitz im Ausland','Privat (geschaeftliche Nutzung)','Privat (geschaeftliche Nutzung) Sitz im Ausland','Firma (Kapitalgesellschaft)','Firma (Kapitalgesellschaft) Sitz im Ausland','Firma (Personengesellschaft)','Firma (Personengesellschaft) Sitz im Ausland','oeff. rechtl. Koerperschaft','oeff. rechtl. Koerperschaft Sitz im Ausland','Eingetragener Verein','Eingetragener Verein Sitz im Ausland','Typ unbekannt') AS Kundentyp ,kategorie FROM t1 WHERE hdl_nr < 2000000 AND kategorie IN ('Prepaid','Mobilfunk') AND st_klasse = 'Workflow' GROUP BY kundentyp ORDER BY kategorie; +Kundentyp kategorie +Privat (Private Nutzung) Mobilfunk +Warnings: +Warning 1052 Column 'kundentyp' in group statement is ambiguous +drop table t1; diff --git a/mysql-test/r/shm.result b/mysql-test/r/shm.result new file mode 100644 index 00000000000..09adebad10f --- /dev/null +++ b/mysql-test/r/shm.result @@ -0,0 +1,2155 @@ +drop table if exists t1,t2,t3,t4; +CREATE TABLE t1 ( +Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, +Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL +); +INSERT INTO t1 VALUES (9410,9412); +select period from t1; +period +9410 +select * from t1; +Period Varor_period +9410 9412 +select t1.* from t1; +Period Varor_period +9410 9412 +CREATE TABLE t2 ( +auto int not null auto_increment, +fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL, +companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL, +fld3 char(30) DEFAULT '' NOT NULL, +fld4 char(35) DEFAULT '' NOT NULL, +fld5 char(35) DEFAULT '' NOT NULL, +fld6 char(4) DEFAULT '' NOT NULL, +UNIQUE fld1 (fld1), +KEY fld3 (fld3), +PRIMARY KEY (auto) +); +select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%"; +fld3 +imaginable +select fld3 from t2 where fld3 like "%cultivation" ; +fld3 +cultivation +select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3,companynr from t2 where companynr = 58 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3 from t2 order by fld3 desc limit 10; +fld3 +youthfulness +yelped +Wotan +workers +Witt +witchcraft +Winsett +Willy +willed +wildcats +select fld3 from t2 order by fld3 desc limit 5; +fld3 +youthfulness +yelped +Wotan +workers +Witt +select fld3 from t2 order by fld3 desc limit 5,5; +fld3 +witchcraft +Winsett +Willy +willed +wildcats +select t2.fld3 from t2 where fld3 = 'honeysuckle'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'h%le'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_'; +fld3 +select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; +fld3 +explain select t2.fld3 from t2 where fld3 = 'honeysuckle'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using index +explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using index +explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using index +explain select fld3 from t2 ignore index (fld3,not_used); +ERROR HY000: Key 'not_used' doesn't exist in table 't2' +explain select fld3 from t2 use index (not_used); +ERROR HY000: Key 'not_used' doesn't exist in table 't2' +select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +fld3 +honeysuckle +honoring +explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range fld3 fld3 30 NULL 2 Using where; Using index +select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; +fld1 fld3 +148504 Colombo +068305 Colombo +000000 nondecreasing +select fld1,fld3 from t2 where companynr = 37 and fld3 = 'appendixes'; +fld1 fld3 +232605 appendixes +1232605 appendixes +1232606 appendixes +1232607 appendixes +1232608 appendixes +1232609 appendixes +select fld1 from t2 where fld1=250501 or fld1="250502"; +fld1 +250501 +250502 +explain select fld1 from t2 where fld1=250501 or fld1="250502"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range fld1 fld1 4 NULL 2 Using where; Using index +select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +fld1 +250501 +250502 +250505 +250601 +explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range fld1 fld1 4 NULL 4 Using where; Using index +select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%'; +fld1 fld3 +218401 faithful +018007 fanatic +228311 fated +018017 featherweight +218022 feed +088303 feminine +058004 Fenton +038017 fetched +018054 fetters +208101 fiftieth +238007 filial +013606 fingerings +218008 finishers +038205 firearm +188505 fitting +202301 Fitzpatrick +238008 fixedly +012001 flanking +018103 flint +018104 flopping +188007 flurried +013602 foldout +226205 foothill +232102 forgivably +228306 forthcoming +186002 freakish +208113 freest +231315 freezes +036002 funereal +226209 furnishings +198006 furthermore +select fld3 from t2 where fld3 like "L%" and fld3 = "ok"; +fld3 +select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly"); +fld3 +Chantilly +select fld1,fld3 from t2 where fld1 like "25050%"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select fld1,fld3 from t2 where fld1 like "25050_"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select distinct companynr from t2; +companynr +00 +37 +36 +50 +58 +29 +40 +53 +65 +41 +34 +68 +select distinct companynr from t2 order by companynr; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr desc; +companynr +68 +65 +58 +53 +50 +41 +40 +37 +36 +34 +29 +00 +select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%"; +fld3 period +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +select distinct fld3 from t2 where companynr = 34 order by fld3; +fld3 +absentee +accessed +ahead +alphabetic +Asiaticizations +attitude +aye +bankruptcies +belays +Blythe +bomb +boulevard +bulldozes +cannot +caressing +charcoal +checksumming +chess +clubroom +colorful +cosy +creator +crying +Darius +diffusing +duality +Eiffel +Epiphany +Ernestine +explorers +exterminated +famine +forked +Gershwins +heaving +Hodges +Iraqis +Italianization +Lagos +landslide +libretto +Majorca +mastering +narrowed +occurred +offerers +Palestine +Peruvianizes +pharmaceutic +poisoning +population +Pygmalion +rats +realest +recording +regimented +retransmitting +reviver +rouses +scars +sicker +sleepwalk +stopped +sugars +translatable +uncles +unexpected +uprisings +versatility +vest +select distinct fld3 from t2 limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct fld3 from t2 having fld3 like "A%" limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct substring(fld3,1,3) from t2 where fld3 like "A%"; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +Adl +adm +Ado +ads +adv +aer +aff +afi +afl +afo +agi +ahe +aim +air +Ald +alg +ali +all +alp +alr +ama +ame +amm +ana +and +ane +Ang +ani +Ann +Ant +api +app +aqu +Ara +arc +Arm +arr +Art +Asi +ask +asp +ass +ast +att +aud +Aug +aut +ave +avo +awe +aye +Azt +select distinct substring(fld3,1,3) as a from t2 having a like "A%" order by a limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) from t2 where fld3 like "A%" limit 10; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +create table t3 ( +period int not null, +name char(32) not null, +companynr int not null, +price double(11,0), +price2 double(11,0), +key (period), +key (name) +); +create temporary table tmp engine = myisam select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +alter table t3 add t2nr int not null auto_increment primary key first; +drop table tmp; +SET SQL_BIG_TABLES=1; +select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; +namn +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +SET SQL_BIG_TABLES=0; +select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; +concat(fld3," ",fld3) +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +select distinct fld5 from t2 limit 10; +fld5 +neat +Steinberg +jarring +tinily +balled +persist +attainments +fanatic +measures +rightfulness +select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10; +fld3 count(*) +affixed 1 +and 1 +annoyers 1 +Anthony 1 +assayed 1 +assurers 1 +attendants 1 +bedlam 1 +bedpost 1 +boasted 1 +SET SQL_BIG_TABLES=1; +select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10; +fld3 count(*) +affixed 1 +and 1 +annoyers 1 +Anthony 1 +assayed 1 +assurers 1 +attendants 1 +bedlam 1 +bedpost 1 +boasted 1 +SET SQL_BIG_TABLES=0; +select distinct fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr,fld3 limit 100,10; +fld3 repeat("a",length(fld3)) count(*) +circus aaaaaa 1 +cited aaaaa 1 +Colombo aaaaaaa 1 +congresswoman aaaaaaaaaaaaa 1 +contrition aaaaaaaaaa 1 +corny aaaaa 1 +cultivation aaaaaaaaaaa 1 +definiteness aaaaaaaaaaaa 1 +demultiplex aaaaaaaaaaa 1 +disappointing aaaaaaaaaaaaa 1 +select distinct companynr,rtrim(space(512+companynr)) from t3 order by 1,2; +companynr rtrim(space(512+companynr)) +37 +78 +101 +154 +311 +447 +512 +select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by fld3; +fld3 +explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using temporary; Using filesort +1 SIMPLE t3 ref period period 4 test.t1.period 4181 +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 index period period 4 NULL 41810 +1 SIMPLE t1 ref period period 4 test.t3.period 4181 +explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index period period 4 NULL 41810 +1 SIMPLE t3 ref period period 4 test.t1.period 4181 +select period from t1; +period +9410 +select period from t1 where period=1900; +period +select fld3,period from t1,t2 where fld1 = 011401 order by period; +fld3 period +breaking 9410 +select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001; +fld3 period +breaking 1001 +explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 const fld1 fld1 4 const 1 +1 SIMPLE t3 const PRIMARY,period PRIMARY 4 const 1 +select fld3,period from t2,t1 where companynr*10 = 37*10; +fld3 period +breaking 9410 +Romans 9410 +intercepted 9410 +bewilderingly 9410 +astound 9410 +admonishing 9410 +sumac 9410 +flanking 9410 +combed 9410 +subjective 9410 +scatterbrain 9410 +Eulerian 9410 +Kane 9410 +overlay 9410 +perturb 9410 +goblins 9410 +annihilates 9410 +Wotan 9410 +snatching 9410 +concludes 9410 +laterally 9410 +yelped 9410 +grazing 9410 +Baird 9410 +celery 9410 +misunderstander 9410 +handgun 9410 +foldout 9410 +mystic 9410 +succumbed 9410 +Nabisco 9410 +fingerings 9410 +aging 9410 +afield 9410 +ammonium 9410 +boat 9410 +intelligibility 9410 +Augustine 9410 +teethe 9410 +dreaded 9410 +scholastics 9410 +audiology 9410 +wallet 9410 +parters 9410 +eschew 9410 +quitter 9410 +neat 9410 +Steinberg 9410 +jarring 9410 +tinily 9410 +balled 9410 +persist 9410 +attainments 9410 +fanatic 9410 +measures 9410 +rightfulness 9410 +capably 9410 +impulsive 9410 +starlet 9410 +terminators 9410 +untying 9410 +announces 9410 +featherweight 9410 +pessimist 9410 +daughter 9410 +decliner 9410 +lawgiver 9410 +stated 9410 +readable 9410 +attrition 9410 +cascade 9410 +motors 9410 +interrogate 9410 +pests 9410 +stairway 9410 +dopers 9410 +testicle 9410 +Parsifal 9410 +leavings 9410 +postulation 9410 +squeaking 9410 +contrasted 9410 +leftover 9410 +whiteners 9410 +erases 9410 +Punjab 9410 +Merritt 9410 +Quixotism 9410 +sweetish 9410 +dogging 9410 +scornfully 9410 +bellow 9410 +bills 9410 +cupboard 9410 +sureties 9410 +puddings 9410 +fetters 9410 +bivalves 9410 +incurring 9410 +Adolph 9410 +pithed 9410 +Miles 9410 +trimmings 9410 +tragedies 9410 +skulking 9410 +flint 9410 +flopping 9410 +relaxing 9410 +offload 9410 +suites 9410 +lists 9410 +animized 9410 +multilayer 9410 +standardizes 9410 +Judas 9410 +vacuuming 9410 +dentally 9410 +humanness 9410 +inch 9410 +Weissmuller 9410 +irresponsibly 9410 +luckily 9410 +culled 9410 +medical 9410 +bloodbath 9410 +subschema 9410 +animals 9410 +Micronesia 9410 +repetitions 9410 +Antares 9410 +ventilate 9410 +pityingly 9410 +interdependent 9410 +Graves 9410 +neonatal 9410 +chafe 9410 +honoring 9410 +realtor 9410 +elite 9410 +funereal 9410 +abrogating 9410 +sorters 9410 +Conley 9410 +lectured 9410 +Abraham 9410 +Hawaii 9410 +cage 9410 +hushes 9410 +Simla 9410 +reporters 9410 +Dutchman 9410 +descendants 9410 +groupings 9410 +dissociate 9410 +coexist 9410 +Beebe 9410 +Taoism 9410 +Connally 9410 +fetched 9410 +checkpoints 9410 +rusting 9410 +galling 9410 +obliterates 9410 +traitor 9410 +resumes 9410 +analyzable 9410 +terminator 9410 +gritty 9410 +firearm 9410 +minima 9410 +Selfridge 9410 +disable 9410 +witchcraft 9410 +betroth 9410 +Manhattanize 9410 +imprint 9410 +peeked 9410 +swelling 9410 +interrelationships 9410 +riser 9410 +Gandhian 9410 +peacock 9410 +bee 9410 +kanji 9410 +dental 9410 +scarf 9410 +chasm 9410 +insolence 9410 +syndicate 9410 +alike 9410 +imperial 9410 +convulsion 9410 +railway 9410 +validate 9410 +normalizes 9410 +comprehensive 9410 +chewing 9410 +denizen 9410 +schemer 9410 +chronicle 9410 +Kline 9410 +Anatole 9410 +partridges 9410 +brunch 9410 +recruited 9410 +dimensions 9410 +Chicana 9410 +announced 9410 +praised 9410 +employing 9410 +linear 9410 +quagmire 9410 +western 9410 +relishing 9410 +serving 9410 +scheduling 9410 +lore 9410 +eventful 9410 +arteriole 9410 +disentangle 9410 +cured 9410 +Fenton 9410 +avoidable 9410 +drains 9410 +detectably 9410 +husky 9410 +impelling 9410 +undoes 9410 +evened 9410 +squeezes 9410 +destroyer 9410 +rudeness 9410 +beaner 9410 +boorish 9410 +Everhart 9410 +encompass 9410 +mushrooms 9410 +Alison 9410 +externally 9410 +pellagra 9410 +cult 9410 +creek 9410 +Huffman 9410 +Majorca 9410 +governing 9410 +gadfly 9410 +reassigned 9410 +intentness 9410 +craziness 9410 +psychic 9410 +squabbled 9410 +burlesque 9410 +capped 9410 +extracted 9410 +DiMaggio 9410 +exclamation 9410 +subdirectory 9410 +Gothicism 9410 +feminine 9410 +metaphysically 9410 +sanding 9410 +Miltonism 9410 +freakish 9410 +index 9410 +straight 9410 +flurried 9410 +denotative 9410 +coming 9410 +commencements 9410 +gentleman 9410 +gifted 9410 +Shanghais 9410 +sportswriting 9410 +sloping 9410 +navies 9410 +leaflet 9410 +shooter 9410 +Joplin 9410 +babies 9410 +assails 9410 +admiring 9410 +swaying 9410 +Goldstine 9410 +fitting 9410 +Norwalk 9410 +analogy 9410 +deludes 9410 +cokes 9410 +Clayton 9410 +exhausts 9410 +causality 9410 +sating 9410 +icon 9410 +throttles 9410 +communicants 9410 +dehydrate 9410 +priceless 9410 +publicly 9410 +incidentals 9410 +commonplace 9410 +mumbles 9410 +furthermore 9410 +cautioned 9410 +parametrized 9410 +registration 9410 +sadly 9410 +positioning 9410 +babysitting 9410 +eternal 9410 +hoarder 9410 +congregates 9410 +rains 9410 +workers 9410 +sags 9410 +unplug 9410 +garage 9410 +boulder 9410 +specifics 9410 +Teresa 9410 +Winsett 9410 +convenient 9410 +buckboards 9410 +amenities 9410 +resplendent 9410 +sews 9410 +participated 9410 +Simon 9410 +certificates 9410 +Fitzpatrick 9410 +Evanston 9410 +misted 9410 +textures 9410 +save 9410 +count 9410 +rightful 9410 +chaperone 9410 +Lizzy 9410 +clenched 9410 +effortlessly 9410 +accessed 9410 +beaters 9410 +Hornblower 9410 +vests 9410 +indulgences 9410 +infallibly 9410 +unwilling 9410 +excrete 9410 +spools 9410 +crunches 9410 +overestimating 9410 +ineffective 9410 +humiliation 9410 +sophomore 9410 +star 9410 +rifles 9410 +dialysis 9410 +arriving 9410 +indulge 9410 +clockers 9410 +languages 9410 +Antarctica 9410 +percentage 9410 +ceiling 9410 +specification 9410 +regimented 9410 +ciphers 9410 +pictures 9410 +serpents 9410 +allot 9410 +realized 9410 +mayoral 9410 +opaquely 9410 +hostess 9410 +fiftieth 9410 +incorrectly 9410 +decomposition 9410 +stranglings 9410 +mixture 9410 +electroencephalography 9410 +similarities 9410 +charges 9410 +freest 9410 +Greenberg 9410 +tinting 9410 +expelled 9410 +warm 9410 +smoothed 9410 +deductions 9410 +Romano 9410 +bitterroot 9410 +corset 9410 +securing 9410 +environing 9410 +cute 9410 +Crays 9410 +heiress 9410 +inform 9410 +avenge 9410 +universals 9410 +Kinsey 9410 +ravines 9410 +bestseller 9410 +equilibrium 9410 +extents 9410 +relatively 9410 +pressure 9410 +critiques 9410 +befouled 9410 +rightfully 9410 +mechanizing 9410 +Latinizes 9410 +timesharing 9410 +Aden 9410 +embassies 9410 +males 9410 +shapelessly 9410 +mastering 9410 +Newtonian 9410 +finishers 9410 +abates 9410 +teem 9410 +kiting 9410 +stodgy 9410 +feed 9410 +guitars 9410 +airships 9410 +store 9410 +denounces 9410 +Pyle 9410 +Saxony 9410 +serializations 9410 +Peruvian 9410 +taxonomically 9410 +kingdom 9410 +stint 9410 +Sault 9410 +faithful 9410 +Ganymede 9410 +tidiness 9410 +gainful 9410 +contrary 9410 +Tipperary 9410 +tropics 9410 +theorizers 9410 +renew 9410 +already 9410 +terminal 9410 +Hegelian 9410 +hypothesizer 9410 +warningly 9410 +journalizing 9410 +nested 9410 +Lars 9410 +saplings 9410 +foothill 9410 +labeled 9410 +imperiously 9410 +reporters 9410 +furnishings 9410 +precipitable 9410 +discounts 9410 +excises 9410 +Stalin 9410 +despot 9410 +ripeness 9410 +Arabia 9410 +unruly 9410 +mournfulness 9410 +boom 9410 +slaughter 9410 +Sabine 9410 +handy 9410 +rural 9410 +organizer 9410 +shipyard 9410 +civics 9410 +inaccuracy 9410 +rules 9410 +juveniles 9410 +comprised 9410 +investigations 9410 +stabilizes 9410 +seminaries 9410 +Hunter 9410 +sporty 9410 +test 9410 +weasels 9410 +CERN 9410 +tempering 9410 +afore 9410 +Galatean 9410 +techniques 9410 +error 9410 +veranda 9410 +severely 9410 +Cassites 9410 +forthcoming 9410 +guides 9410 +vanish 9410 +lied 9410 +sawtooth 9410 +fated 9410 +gradually 9410 +widens 9410 +preclude 9410 +evenhandedly 9410 +percentage 9410 +disobedience 9410 +humility 9410 +gleaning 9410 +petted 9410 +bloater 9410 +minion 9410 +marginal 9410 +apiary 9410 +measures 9410 +precaution 9410 +repelled 9410 +primary 9410 +coverings 9410 +Artemia 9410 +navigate 9410 +spatial 9410 +Gurkha 9410 +meanwhile 9410 +Melinda 9410 +Butterfield 9410 +Aldrich 9410 +previewing 9410 +glut 9410 +unaffected 9410 +inmate 9410 +mineral 9410 +impending 9410 +meditation 9410 +ideas 9410 +miniaturizes 9410 +lewdly 9410 +title 9410 +youthfulness 9410 +creak 9410 +Chippewa 9410 +clamored 9410 +freezes 9410 +forgivably 9410 +reduce 9410 +McGovern 9410 +Nazis 9410 +epistle 9410 +socializes 9410 +conceptions 9410 +Kevin 9410 +uncovering 9410 +chews 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +raining 9410 +infest 9410 +compartment 9410 +minting 9410 +ducks 9410 +roped 9410 +waltz 9410 +Lillian 9410 +repressions 9410 +chillingly 9410 +noncritical 9410 +lithograph 9410 +spongers 9410 +parenthood 9410 +posed 9410 +instruments 9410 +filial 9410 +fixedly 9410 +relives 9410 +Pandora 9410 +watering 9410 +ungrateful 9410 +secures 9410 +poison 9410 +dusted 9410 +encompasses 9410 +presentation 9410 +Kantian 9410 +select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +fld3 period price price2 +admonishing 1002 28357832 8723648 +analyzable 1002 28357832 8723648 +annihilates 1001 5987435 234724 +Antares 1002 28357832 8723648 +astound 1001 5987435 234724 +audiology 1001 5987435 234724 +Augustine 1002 28357832 8723648 +Baird 1002 28357832 8723648 +bewilderingly 1001 5987435 234724 +breaking 1001 5987435 234724 +Conley 1001 5987435 234724 +dentally 1002 28357832 8723648 +dissociate 1002 28357832 8723648 +elite 1001 5987435 234724 +eschew 1001 5987435 234724 +Eulerian 1001 5987435 234724 +flanking 1001 5987435 234724 +foldout 1002 28357832 8723648 +funereal 1002 28357832 8723648 +galling 1002 28357832 8723648 +Graves 1001 5987435 234724 +grazing 1001 5987435 234724 +groupings 1001 5987435 234724 +handgun 1001 5987435 234724 +humility 1002 28357832 8723648 +impulsive 1002 28357832 8723648 +inch 1001 5987435 234724 +intelligibility 1001 5987435 234724 +jarring 1001 5987435 234724 +lawgiver 1001 5987435 234724 +lectured 1002 28357832 8723648 +Merritt 1002 28357832 8723648 +neonatal 1001 5987435 234724 +offload 1002 28357832 8723648 +parters 1002 28357832 8723648 +pityingly 1002 28357832 8723648 +puddings 1002 28357832 8723648 +Punjab 1001 5987435 234724 +quitter 1002 28357832 8723648 +realtor 1001 5987435 234724 +relaxing 1001 5987435 234724 +repetitions 1001 5987435 234724 +resumes 1001 5987435 234724 +Romans 1002 28357832 8723648 +rusting 1001 5987435 234724 +scholastics 1001 5987435 234724 +skulking 1002 28357832 8723648 +stated 1002 28357832 8723648 +suites 1002 28357832 8723648 +sureties 1001 5987435 234724 +testicle 1002 28357832 8723648 +tinily 1002 28357832 8723648 +tragedies 1001 5987435 234724 +trimmings 1001 5987435 234724 +vacuuming 1001 5987435 234724 +ventilate 1001 5987435 234724 +wallet 1001 5987435 234724 +Weissmuller 1002 28357832 8723648 +Wotan 1002 28357832 8723648 +select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37; +fld1 fld3 period price price2 +018201 relaxing 1001 5987435 234724 +018601 vacuuming 1001 5987435 234724 +018801 inch 1001 5987435 234724 +018811 repetitions 1001 5987435 234724 +create table t4 ( +companynr tinyint(2) unsigned zerofill NOT NULL default '00', +companyname char(30) NOT NULL default '', +PRIMARY KEY (companynr), +UNIQUE KEY companyname(companyname) +) ENGINE=MyISAM MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; +select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select SQL_SMALL_RESULT t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select * from t1,t1 t12; +Period Varor_period Period Varor_period +9410 9412 9410 9412 +select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505; +fld1 fld1 +250501 250501 +250502 250501 +250503 250501 +250504 250501 +250505 250501 +250501 250502 +250502 250502 +250503 250502 +250504 250502 +250505 250502 +250501 250503 +250502 250503 +250503 250503 +250504 250503 +250505 250503 +250501 250504 +250502 250504 +250503 250504 +250504 250504 +250505 250504 +250501 250505 +250502 250505 +250503 250505 +250504 250505 +250505 250505 +insert into t2 (fld1, companynr) values (999999,99); +select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +companynr companyname +99 NULL +select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null; +count(*) +1199 +explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 +1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 Using where; Not exists +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL NULL NULL NULL NULL 12 +1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 Using where; Not exists +select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +companynr companyname +select count(*) from t2 left join t4 using (companynr) where companynr is not null; +count(*) +1200 +explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +delete from t2 where fld1=999999; +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL NULL NULL NULL NULL 12 +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL NULL NULL NULL NULL 12 +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 +explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 +select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +companynr companynr +37 36 +41 40 +explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909); +period +9410 +select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6))); +period +9410 +select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1; +fld1 +250501 +250502 +250503 +250505 +select fld1 from t2 where fld1 in (250502,98005,98006,250503,250605,250606) and fld1 >=250502 and fld1 not in (250605,250606); +fld1 +250502 +250503 +select fld1 from t2 where fld1 between 250502 and 250504; +fld1 +250502 +250503 +250504 +select fld3 from t2 where (((fld3 like "_%L%" ) or (fld3 like "%ok%")) and ( fld3 like "L%" or fld3 like "G%")) and fld3 like "L%" ; +fld3 +label +labeled +labeled +landslide +laterally +leaflet +lewdly +Lillian +luckily +select count(*) from t1; +count(*) +1 +select companynr,count(*),sum(fld1) from t2 group by companynr; +companynr count(*) sum(fld1) +00 82 10355753 +29 95 14473298 +34 70 17788966 +36 215 22786296 +37 588 83602098 +40 37 6618386 +41 52 12816335 +50 11 1595438 +53 4 793210 +58 23 2254293 +65 10 2284055 +68 12 3097288 +select companynr,count(*) from t2 group by companynr order by companynr desc limit 5; +companynr count(*) +68 12 +65 10 +58 23 +53 4 +50 11 +select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +70 absentee vest 17788966 254128.0857 3272.5940 10709871.3069 +explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +Warnings: +Note 1003 select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> _latin1'')) +select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3; +companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +00 82 Anthony windmills 10355753 126289.6707 115550.9757 13352027981.7087 +29 95 abut wetness 14473298 152350.5053 8368.5480 70032594.9026 +34 70 absentee vest 17788966 254128.0857 3272.5940 10709871.3069 +select companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select /*! SQL_SMALL_RESULT */ companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr ; +companynr count(price) sum(price) min(price) max(price) avg(price) +37 12543 309394878010 5987435 39654943 24666736.6667 +78 8362 414611089292 726498 98439034 49582766.0000 +101 4181 3489454238 834598 834598 834598.0000 +154 4181 4112197254950 983543950 983543950 983543950.0000 +311 4181 979599938 234298 234298 234298.0000 +447 4181 9929180954 2374834 2374834 2374834.0000 +512 4181 3288532102 786542 786542 786542.0000 +select distinct mod(companynr,10) from t4 group by companynr; +mod(companynr,10) +0 +9 +4 +6 +7 +1 +3 +8 +5 +select distinct 1 from t4 group by companynr; +1 +1 +select count(distinct fld1) from t2; +count(distinct fld1) +1199 +select companynr,count(distinct fld1) from t2 group by companynr; +companynr count(distinct fld1) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(*) from t2 group by companynr; +companynr count(*) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,1000))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,1000))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,200))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,200))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct floor(fld1/100)) from t2 group by companynr; +companynr count(distinct floor(fld1/100)) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select companynr,count(distinct concat(repeat(65,1000),floor(fld1/100))) from t2 group by companynr; +companynr count(distinct concat(repeat(65,1000),floor(fld1/100))) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select sum(fld1),fld3 from t2 where fld3="Romans" group by fld1 limit 10; +sum(fld1) fld3 +11402 Romans +select name,count(*) from t3 where name='cloakroom' group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name='cloakroom' and price>10 group by name; +name count(*) +cloakroom 4181 +select count(*) from t3 where name='cloakroom' and price2=823742; +count(*) +4181 +select name,count(*) from t3 where name='cloakroom' and price2=823742 group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name >= "extramarital" and price <= 39654943 group by name; +name count(*) +extramarital 4181 +gazer 4181 +gems 4181 +Iranizes 4181 +spates 4181 +tucked 4181 +violinist 4181 +select t2.fld3,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld3 count(*) +spates 4181 +select companynr|0,companyname from t4 group by 1; +companynr|0 companyname +0 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by t2.companynr order by companyname; +companynr companyname count(*) +29 company 1 95 +68 company 10 12 +50 company 11 11 +34 company 2 70 +36 company 3 215 +37 company 4 588 +40 company 5 37 +41 company 6 52 +53 company 7 4 +58 company 8 23 +65 company 9 10 +00 Unknown 82 +select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld1 count(*) +158402 4181 +select sum(Period)/count(*) from t1; +sum(Period)/count(*) +9410.0000 +select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr; +companynr count sum diff func +37 12543 309394878010 0.0000 464091 +78 8362 414611089292 0.0000 652236 +101 4181 3489454238 0.0000 422281 +154 4181 4112197254950 0.0000 643874 +311 4181 979599938 0.0000 1300291 +447 4181 9929180954 0.0000 1868907 +512 4181 3288532102 0.0000 2140672 +select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg; +companynr avg +154 983543950.0000 +select companynr,count(*) from t2 group by companynr order by 2 desc; +companynr count(*) +37 588 +36 215 +29 95 +00 82 +34 70 +41 52 +40 37 +58 23 +68 12 +50 11 +65 10 +53 4 +select companynr,count(*) from t2 where companynr > 40 group by companynr order by 2 desc; +companynr count(*) +41 52 +58 23 +68 12 +50 11 +65 10 +53 4 +select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) from t3,t2 where t3.companynr = 37 and t2.fld1 = t3.t2nr group by fld1,t2.fld4; +fld4 fld1 count(price) sum(price) min(price) max(price) avg(price) +teethe 000001 1 5987435 5987435 5987435 5987435.0000 +dreaded 011401 1 5987435 5987435 5987435 5987435.0000 +scholastics 011402 1 28357832 28357832 28357832 28357832.0000 +audiology 011403 1 39654943 39654943 39654943 39654943.0000 +wallet 011501 1 5987435 5987435 5987435 5987435.0000 +parters 011701 1 5987435 5987435 5987435 5987435.0000 +eschew 011702 1 28357832 28357832 28357832 28357832.0000 +quitter 011703 1 39654943 39654943 39654943 39654943.0000 +neat 012001 1 5987435 5987435 5987435 5987435.0000 +Steinberg 012003 1 39654943 39654943 39654943 39654943.0000 +balled 012301 1 5987435 5987435 5987435 5987435.0000 +persist 012302 1 28357832 28357832 28357832 28357832.0000 +attainments 012303 1 39654943 39654943 39654943 39654943.0000 +capably 012501 1 5987435 5987435 5987435 5987435.0000 +impulsive 012602 1 28357832 28357832 28357832 28357832.0000 +starlet 012603 1 39654943 39654943 39654943 39654943.0000 +featherweight 012701 1 5987435 5987435 5987435 5987435.0000 +pessimist 012702 1 28357832 28357832 28357832 28357832.0000 +daughter 012703 1 39654943 39654943 39654943 39654943.0000 +lawgiver 013601 1 5987435 5987435 5987435 5987435.0000 +stated 013602 1 28357832 28357832 28357832 28357832.0000 +readable 013603 1 39654943 39654943 39654943 39654943.0000 +testicle 013801 1 5987435 5987435 5987435 5987435.0000 +Parsifal 013802 1 28357832 28357832 28357832 28357832.0000 +leavings 013803 1 39654943 39654943 39654943 39654943.0000 +squeaking 013901 1 5987435 5987435 5987435 5987435.0000 +contrasted 016001 1 5987435 5987435 5987435 5987435.0000 +leftover 016201 1 5987435 5987435 5987435 5987435.0000 +whiteners 016202 1 28357832 28357832 28357832 28357832.0000 +erases 016301 1 5987435 5987435 5987435 5987435.0000 +Punjab 016302 1 28357832 28357832 28357832 28357832.0000 +Merritt 016303 1 39654943 39654943 39654943 39654943.0000 +sweetish 018001 1 5987435 5987435 5987435 5987435.0000 +dogging 018002 1 28357832 28357832 28357832 28357832.0000 +scornfully 018003 1 39654943 39654943 39654943 39654943.0000 +fetters 018012 1 28357832 28357832 28357832 28357832.0000 +bivalves 018013 1 39654943 39654943 39654943 39654943.0000 +skulking 018021 1 5987435 5987435 5987435 5987435.0000 +flint 018022 1 28357832 28357832 28357832 28357832.0000 +flopping 018023 1 39654943 39654943 39654943 39654943.0000 +Judas 018032 1 28357832 28357832 28357832 28357832.0000 +vacuuming 018033 1 39654943 39654943 39654943 39654943.0000 +medical 018041 1 5987435 5987435 5987435 5987435.0000 +bloodbath 018042 1 28357832 28357832 28357832 28357832.0000 +subschema 018043 1 39654943 39654943 39654943 39654943.0000 +interdependent 018051 1 5987435 5987435 5987435 5987435.0000 +Graves 018052 1 28357832 28357832 28357832 28357832.0000 +neonatal 018053 1 39654943 39654943 39654943 39654943.0000 +sorters 018061 1 5987435 5987435 5987435 5987435.0000 +epistle 018062 1 28357832 28357832 28357832 28357832.0000 +Conley 018101 1 5987435 5987435 5987435 5987435.0000 +lectured 018102 1 28357832 28357832 28357832 28357832.0000 +Abraham 018103 1 39654943 39654943 39654943 39654943.0000 +cage 018201 1 5987435 5987435 5987435 5987435.0000 +hushes 018202 1 28357832 28357832 28357832 28357832.0000 +Simla 018402 1 28357832 28357832 28357832 28357832.0000 +reporters 018403 1 39654943 39654943 39654943 39654943.0000 +coexist 018601 1 5987435 5987435 5987435 5987435.0000 +Beebe 018602 1 28357832 28357832 28357832 28357832.0000 +Taoism 018603 1 39654943 39654943 39654943 39654943.0000 +Connally 018801 1 5987435 5987435 5987435 5987435.0000 +fetched 018802 1 28357832 28357832 28357832 28357832.0000 +checkpoints 018803 1 39654943 39654943 39654943 39654943.0000 +gritty 018811 1 5987435 5987435 5987435 5987435.0000 +firearm 018812 1 28357832 28357832 28357832 28357832.0000 +minima 019101 1 5987435 5987435 5987435 5987435.0000 +Selfridge 019102 1 28357832 28357832 28357832 28357832.0000 +disable 019103 1 39654943 39654943 39654943 39654943.0000 +witchcraft 019201 1 5987435 5987435 5987435 5987435.0000 +betroth 030501 1 5987435 5987435 5987435 5987435.0000 +Manhattanize 030502 1 28357832 28357832 28357832 28357832.0000 +imprint 030503 1 39654943 39654943 39654943 39654943.0000 +swelling 031901 1 5987435 5987435 5987435 5987435.0000 +interrelationships 036001 1 5987435 5987435 5987435 5987435.0000 +riser 036002 1 28357832 28357832 28357832 28357832.0000 +bee 038001 1 5987435 5987435 5987435 5987435.0000 +kanji 038002 1 28357832 28357832 28357832 28357832.0000 +dental 038003 1 39654943 39654943 39654943 39654943.0000 +railway 038011 1 5987435 5987435 5987435 5987435.0000 +validate 038012 1 28357832 28357832 28357832 28357832.0000 +normalizes 038013 1 39654943 39654943 39654943 39654943.0000 +Kline 038101 1 5987435 5987435 5987435 5987435.0000 +Anatole 038102 1 28357832 28357832 28357832 28357832.0000 +partridges 038103 1 39654943 39654943 39654943 39654943.0000 +recruited 038201 1 5987435 5987435 5987435 5987435.0000 +dimensions 038202 1 28357832 28357832 28357832 28357832.0000 +Chicana 038203 1 39654943 39654943 39654943 39654943.0000 +select t3.companynr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 group by companynr,fld3; +companynr fld3 sum(price) +512 boat 786542 +512 capably 786542 +512 cupboard 786542 +512 decliner 786542 +512 descendants 786542 +512 dopers 786542 +512 erases 786542 +512 Micronesia 786542 +512 Miles 786542 +512 skies 786542 +select t2.companynr,count(*),min(fld3),max(fld3),sum(price),avg(price) from t2,t3 where t3.companynr >= 30 and t3.companynr <= 58 and t3.t2nr = t2.fld1 and 1+1=2 group by t2.companynr; +companynr count(*) min(fld3) max(fld3) sum(price) avg(price) +00 1 Omaha Omaha 5987435 5987435.0000 +36 1 dubbed dubbed 28357832 28357832.0000 +37 83 Abraham Wotan 1908978016 22999735.1325 +50 2 scribbled tapestry 68012775 34006387.5000 +select t3.companynr+0,t3.t2nr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 37 group by 1,t3.t2nr,fld3,fld3,fld3,fld3,fld3 order by fld1; +t3.companynr+0 t2nr fld3 sum(price) +37 1 Omaha 5987435 +37 11401 breaking 5987435 +37 11402 Romans 28357832 +37 11403 intercepted 39654943 +37 11501 bewilderingly 5987435 +37 11701 astound 5987435 +37 11702 admonishing 28357832 +37 11703 sumac 39654943 +37 12001 flanking 5987435 +37 12003 combed 39654943 +37 12301 Eulerian 5987435 +37 12302 dubbed 28357832 +37 12303 Kane 39654943 +37 12501 annihilates 5987435 +37 12602 Wotan 28357832 +37 12603 snatching 39654943 +37 12701 grazing 5987435 +37 12702 Baird 28357832 +37 12703 celery 39654943 +37 13601 handgun 5987435 +37 13602 foldout 28357832 +37 13603 mystic 39654943 +37 13801 intelligibility 5987435 +37 13802 Augustine 28357832 +37 13803 teethe 39654943 +37 13901 scholastics 5987435 +37 16001 audiology 5987435 +37 16201 wallet 5987435 +37 16202 parters 28357832 +37 16301 eschew 5987435 +37 16302 quitter 28357832 +37 16303 neat 39654943 +37 18001 jarring 5987435 +37 18002 tinily 28357832 +37 18003 balled 39654943 +37 18012 impulsive 28357832 +37 18013 starlet 39654943 +37 18021 lawgiver 5987435 +37 18022 stated 28357832 +37 18023 readable 39654943 +37 18032 testicle 28357832 +37 18033 Parsifal 39654943 +37 18041 Punjab 5987435 +37 18042 Merritt 28357832 +37 18043 Quixotism 39654943 +37 18051 sureties 5987435 +37 18052 puddings 28357832 +37 18053 tapestry 39654943 +37 18061 trimmings 5987435 +37 18062 humility 28357832 +37 18101 tragedies 5987435 +37 18102 skulking 28357832 +37 18103 flint 39654943 +37 18201 relaxing 5987435 +37 18202 offload 28357832 +37 18402 suites 28357832 +37 18403 lists 39654943 +37 18601 vacuuming 5987435 +37 18602 dentally 28357832 +37 18603 humanness 39654943 +37 18801 inch 5987435 +37 18802 Weissmuller 28357832 +37 18803 irresponsibly 39654943 +37 18811 repetitions 5987435 +37 18812 Antares 28357832 +37 19101 ventilate 5987435 +37 19102 pityingly 28357832 +37 19103 interdependent 39654943 +37 19201 Graves 5987435 +37 30501 neonatal 5987435 +37 30502 scribbled 28357832 +37 30503 chafe 39654943 +37 31901 realtor 5987435 +37 36001 elite 5987435 +37 36002 funereal 28357832 +37 38001 Conley 5987435 +37 38002 lectured 28357832 +37 38003 Abraham 39654943 +37 38011 groupings 5987435 +37 38012 dissociate 28357832 +37 38013 coexist 39654943 +37 38101 rusting 5987435 +37 38102 galling 28357832 +37 38103 obliterates 39654943 +37 38201 resumes 5987435 +37 38202 analyzable 28357832 +37 38203 terminator 39654943 +select sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1= t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008; +sum(price) +234298 +select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1 = t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008 or t3.t2nr = t2.fld1 and t2.fld1 = 38008 group by t2.fld1; +fld1 sum(price) +038008 234298 +explain select fld3 from t2 where 1>2 or 2>3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +explain select fld3 from t2 where fld1=fld1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 +select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,fld1 from t2 WHERE fld1>=250501 HAVING fld1<=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,count(*) as count,sum(fld1) as sum from t2 group by companynr having count > 40 and sum/count >= 120000; +companynr count sum +00 82 10355753 +29 95 14473298 +34 70 17788966 +37 588 83602098 +41 52 12816335 +select companynr from t2 group by companynr having count(*) > 40 and sum(fld1)/count(*) >= 120000 ; +companynr +00 +29 +34 +37 +41 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by companyname having t2.companynr >= 40; +companynr companyname count(*) +68 company 10 12 +50 company 11 11 +40 company 5 37 +41 company 6 52 +53 company 7 4 +58 company 8 23 +65 company 9 10 +select count(*) from t2; +count(*) +1199 +select count(*) from t2 where fld1 < 098024; +count(*) +387 +select min(fld1) from t2 where fld1>= 098024; +min(fld1) +98024 +select max(fld1) from t2 where fld1>= 098024; +max(fld1) +1232609 +select count(*) from t3 where price2=76234234; +count(*) +4181 +select count(*) from t3 where companynr=512 and price2=76234234; +count(*) +4181 +explain select min(fld1),max(fld1),count(*) from t2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select min(fld1),max(fld1),count(*) from t2; +min(fld1) max(fld1) count(*) +0 1232609 1199 +select min(t2nr),max(t2nr) from t3 where t2nr=2115 and price2=823742; +min(t2nr) max(t2nr) +2115 2115 +select count(*),min(t2nr),max(t2nr) from t3 where name='spates' and companynr=78; +count(*) min(t2nr) max(t2nr) +4181 4 41804 +select t2nr,count(*) from t3 where name='gems' group by t2nr limit 20; +t2nr count(*) +9 1 +19 1 +29 1 +39 1 +49 1 +59 1 +69 1 +79 1 +89 1 +99 1 +109 1 +119 1 +129 1 +139 1 +149 1 +159 1 +169 1 +179 1 +189 1 +199 1 +select max(t2nr) from t3 where price=983543950; +max(t2nr) +41807 +select t1.period from t3 = t1 limit 1; +period +1001 +select t1.period from t1 as t1 limit 1; +period +9410 +select t1.period as "Nuvarande period" from t1 as t1 limit 1; +Nuvarande period +9410 +select period as ok_period from t1 limit 1; +ok_period +9410 +select period as ok_period from t1 group by ok_period limit 1; +ok_period +9410 +select 1+1 as summa from t1 group by summa limit 1; +summa +2 +select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1; +Nuvarande period +9410 +show tables; +Tables_in_test +t1 +t2 +t3 +t4 +show tables from test like "s%"; +Tables_in_test (s%) +show tables from test like "t?"; +Tables_in_test (t?) +show full columns from t2; +Field Type Collation Null Key Default Extra Privileges Comment +auto int(11) NULL NO PRI NULL auto_increment # +fld1 int(6) unsigned zerofill NULL NO UNI 000000 # +companynr tinyint(2) unsigned zerofill NULL NO 00 # +fld3 char(30) latin1_swedish_ci NO MUL # +fld4 char(35) latin1_swedish_ci NO # +fld5 char(35) latin1_swedish_ci NO # +fld6 char(4) latin1_swedish_ci NO # +show full columns from t2 from test like 'f%'; +Field Type Collation Null Key Default Extra Privileges Comment +fld1 int(6) unsigned zerofill NULL NO UNI 000000 # +fld3 char(30) latin1_swedish_ci NO MUL # +fld4 char(35) latin1_swedish_ci NO # +fld5 char(35) latin1_swedish_ci NO # +fld6 char(4) latin1_swedish_ci NO # +show full columns from t2 from test like 's%'; +Field Type Collation Null Key Default Extra Privileges Comment +show keys from t2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE +t2 1 fld3 1 fld3 A NULL NULL NULL BTREE +drop table t4, t3, t2, t1; +CREATE TABLE t1 ( +cont_nr int(11) NOT NULL auto_increment, +ver_nr int(11) NOT NULL default '0', +aufnr int(11) NOT NULL default '0', +username varchar(50) NOT NULL default '', +hdl_nr int(11) NOT NULL default '0', +eintrag date NOT NULL default '0000-00-00', +st_klasse varchar(40) NOT NULL default '', +st_wert varchar(40) NOT NULL default '', +st_zusatz varchar(40) NOT NULL default '', +st_bemerkung varchar(255) NOT NULL default '', +kunden_art varchar(40) NOT NULL default '', +mcbs_knr int(11) default NULL, +mcbs_aufnr int(11) NOT NULL default '0', +schufa_status char(1) default '?', +bemerkung text, +wirknetz text, +wf_igz int(11) NOT NULL default '0', +tarifcode varchar(80) default NULL, +recycle char(1) default NULL, +sim varchar(30) default NULL, +mcbs_tpl varchar(30) default NULL, +emp_nr int(11) NOT NULL default '0', +laufzeit int(11) default NULL, +hdl_name varchar(30) default NULL, +prov_hdl_nr int(11) NOT NULL default '0', +auto_wirknetz varchar(50) default NULL, +auto_billing varchar(50) default NULL, +touch timestamp NOT NULL, +kategorie varchar(50) default NULL, +kundentyp varchar(20) NOT NULL default '', +sammel_rech_msisdn varchar(30) NOT NULL default '', +p_nr varchar(9) NOT NULL default '', +suffix char(3) NOT NULL default '', +PRIMARY KEY (cont_nr), +KEY idx_aufnr(aufnr), +KEY idx_hdl_nr(hdl_nr), +KEY idx_st_klasse(st_klasse), +KEY ver_nr(ver_nr), +KEY eintrag_idx(eintrag), +KEY emp_nr_idx(emp_nr), +KEY wf_igz(wf_igz), +KEY touch(touch), +KEY hdl_tag(eintrag,hdl_nr), +KEY prov_hdl_nr(prov_hdl_nr), +KEY mcbs_aufnr(mcbs_aufnr), +KEY kundentyp(kundentyp), +KEY p_nr(p_nr,suffix) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES (3359356,405,3359356,'Mustermann Musterfrau',52500,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1485525,2122316,'+','','N',1909160,'MobilComSuper92000D2',NULL,NULL,'MS9ND2',3,24,'MobilCom Shop Koeln',52500,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359357,468,3359357,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1503580,2139699,'+','','P',1909171,'MobilComSuper9D1T10SFreisprech(Akquise)',NULL,NULL,'MS9NS1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359358,407,3359358,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1501358,2137473,'N','','N',1909159,'MobilComSuper92000D2',NULL,NULL,'MS9ND2',325,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359359,468,3359359,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1507831,2143894,'+','','P',1909162,'MobilComSuper9D1T10SFreisprech(Akquise)',NULL,NULL,'MS9NS1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359360,0,0,'Mustermann Musterfrau',29674907,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1900169997,2414578,'+',NULL,'N',1909148,'',NULL,NULL,'RV99066_2',20,NULL,'POS',29674907,NULL,NULL,20010202105916,'Mobilfunk','','','97317481','007'); +INSERT INTO t1 VALUES (3359361,406,3359361,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag storniert','','(7001-84):Storno, Kd. möchte nicht mehr','privat',NULL,0,'+','','P',1909150,'MobilComSuper92000D1(Akquise)',NULL,NULL,'MS9ND1',325,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359362,406,3359362,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1509984,2145874,'+','','P',1909154,'MobilComSuper92000D1(Akquise)',NULL,NULL,'MS9ND1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +SELECT ELT(FIELD(kundentyp,'PP','PPA','PG','PGA','FK','FKA','FP','FPA','K','KA','V','VA',''), 'Privat (Private Nutzung)','Privat (Private Nutzung) Sitz im Ausland','Privat (geschaeftliche Nutzung)','Privat (geschaeftliche Nutzung) Sitz im Ausland','Firma (Kapitalgesellschaft)','Firma (Kapitalgesellschaft) Sitz im Ausland','Firma (Personengesellschaft)','Firma (Personengesellschaft) Sitz im Ausland','oeff. rechtl. Koerperschaft','oeff. rechtl. Koerperschaft Sitz im Ausland','Eingetragener Verein','Eingetragener Verein Sitz im Ausland','Typ unbekannt') AS Kundentyp ,kategorie FROM t1 WHERE hdl_nr < 2000000 AND kategorie IN ('Prepaid','Mobilfunk') AND st_klasse = 'Workflow' GROUP BY kundentyp ORDER BY kategorie; +Kundentyp kategorie +Privat (Private Nutzung) Mobilfunk +Warnings: +Warning 1052 Column 'kundentyp' in group statement is ambiguous +drop table t1; +mysqld is alive +End of 5.0 tests. diff --git a/mysql-test/r/windows_shm.result b/mysql-test/r/windows_shm.result deleted file mode 100644 index c60049bece8..00000000000 --- a/mysql-test/r/windows_shm.result +++ /dev/null @@ -1,2 +0,0 @@ -mysqld is alive -End of 5.0 tests. diff --git a/mysql-test/t/named_pipe-master.opt b/mysql-test/t/named_pipe-master.opt new file mode 100644 index 00000000000..e534ae1eae5 --- /dev/null +++ b/mysql-test/t/named_pipe-master.opt @@ -0,0 +1 @@ +--loose-enable-named-pipe diff --git a/mysql-test/t/named_pipe.test b/mysql-test/t/named_pipe.test new file mode 100644 index 00000000000..e3dfd24bb52 --- /dev/null +++ b/mysql-test/t/named_pipe.test @@ -0,0 +1,14 @@ +# We currently only have named pipe support on windows, so +# in order to optimize things we skip this test on all +# other platforms +--source include/windows.inc + +# Only run this test if named pipe is avaliable +let $nmp= query_get_value("SHOW VARIABLES LIKE 'named_pipe'", Value, 1); +if (`SELECT '$nmp' != 'ON'`){ + skip No named pipe support; +} + +# Source select test case +-- source include/common-tests.inc + diff --git a/mysql-test/t/windows_shm-master.opt b/mysql-test/t/shm-master.opt similarity index 73% rename from mysql-test/t/windows_shm-master.opt rename to mysql-test/t/shm-master.opt index 4476ea16360..d71395213b1 100644 --- a/mysql-test/t/windows_shm-master.opt +++ b/mysql-test/t/shm-master.opt @@ -1 +1 @@ ---skip-grant-tables --loose-shared-memory-base-name=HeyMrBaseNameXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --loose-shared-memory=1 +--skip-grant-tables --loose-shared-memory-base-name=HeyMrBaseNameXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX$MTR_BUILD_THREAD --loose-shared-memory=1 diff --git a/mysql-test/t/shm.test b/mysql-test/t/shm.test new file mode 100644 index 00000000000..380607d8ebf --- /dev/null +++ b/mysql-test/t/shm.test @@ -0,0 +1,19 @@ +# We currently only have shm support on windows, so in order +# to optimize things we skip this test on all other platforms +--source include/windows.inc + +# Only run this test if shared memory is avaliable +let $shm= query_get_value("SHOW VARIABLES LIKE 'shared_memory'", Value, 1); +if (`SELECT '$shm' != 'ON'`){ + skip No shm support; +} + +# Source select test case +-- source include/common-tests.inc + +# +# Bug #24924: shared-memory-base-name that is too long causes buffer overflow +# +--exec $MYSQLADMIN --no-defaults --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --shared-memory-base-name=HeyMrBaseNameXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ping + +--echo End of 5.0 tests. diff --git a/mysql-test/t/windows_shm.test b/mysql-test/t/windows_shm.test deleted file mode 100644 index 1c6f05f2da0..00000000000 --- a/mysql-test/t/windows_shm.test +++ /dev/null @@ -1,9 +0,0 @@ -# Windows-specific tests ---source include/windows.inc - -# -# Bug #24924: shared-memory-base-name that is too long causes buffer overflow -# ---exec $MYSQLADMIN --no-defaults --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --shared-memory-base-name=HeyMrBaseNameXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ping - ---echo End of 5.0 tests. From fae74579e41c609b1997b549f29489855a84d537 Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@macbook.local" <> Date: Mon, 24 Sep 2007 13:02:59 +0200 Subject: [PATCH 035/203] merging bug 28701 to 5.1-opt --- mysql-test/r/view.result | 8 ++++---- sql/sql_view.cc | 7 ++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 23a40367cd9..03ed22115bc 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -625,7 +625,7 @@ drop table t1; create table t1 (a int, b int); create view v1 as select a, sum(b) from t1 group by a; select b from v1 use index (some_index) where b=1; -ERROR 42000: Incorrect usage of USE INDEX and VIEW +ERROR HY000: Incorrect usage of index hints and VIEW drop view v1; drop table t1; create table t1 (col1 char(5),col2 char(5)); @@ -3563,11 +3563,11 @@ CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (1),(2); CREATE VIEW v1 AS SELECT * FROM t1; SELECT * FROM v1 USE KEY(non_existant); -ERROR HY000: Incorrect usage of USE INDEX and VIEW +ERROR HY000: Incorrect usage of index hints and VIEW SELECT * FROM v1 FORCE KEY(non_existant); -ERROR HY000: Incorrect usage of FORCE INDEX and VIEW +ERROR HY000: Incorrect usage of index hints and VIEW SELECT * FROM v1 IGNORE KEY(non_existant); -ERROR HY000: Incorrect usage of IGNORE INDEX and VIEW +ERROR HY000: Incorrect usage of index hints and VIEW DROP VIEW v1; DROP TABLE t1; End of 5.0 tests. diff --git a/sql/sql_view.cc b/sql/sql_view.cc index c1149ab63b9..9e16a5e31ee 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -953,12 +953,9 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table, DBUG_RETURN(0); } - if (table->use_index || table->ignore_index) + if (table->index_hints && table->index_hints->elements) { - my_error(ER_WRONG_USAGE, MYF(0), - table->ignore_index ? "IGNORE INDEX" : - (table->force_index ? "FORCE INDEX" : "USE INDEX"), - "VIEW"); + my_error(ER_WRONG_USAGE, MYF(0), "index hints", "VIEW"); DBUG_RETURN(TRUE); } From 4cd18bde81fc0c2f4ccbe8cfdd52ee9f7c2e2e7c Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Mon, 24 Sep 2007 15:34:10 +0300 Subject: [PATCH 036/203] Bug #28702: VIEWs defined with USE/FORCE KEY ignore that request When storing the VIEW the CREATE VIEW command is reconstructed from the parse tree. While constructing the command string the index hints specified should also be printed. Fixed by adding code to print the index hints when printing a table in the FROM clause. --- mysql-test/r/view.result | 28 ++++++++++++++++++++++ mysql-test/t/view.test | 21 ++++++++++++++++ sql/sql_select.cc | 52 ++++++++++++++++++++++++++++++++++++++++ sql/table.h | 2 ++ 4 files changed, 103 insertions(+) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 1f57964bf65..0ba911f2853 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -3573,4 +3573,32 @@ SELECT * FROM v1 IGNORE KEY(non_existant); ERROR HY000: Incorrect usage of IGNORE INDEX and VIEW DROP VIEW v1; DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, b INT NOT NULL DEFAULT 0, +PRIMARY KEY(a), KEY (b)); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +CREATE VIEW v1 AS SELECT * FROM t1 FORCE KEY (PRIMARY,b) ORDER BY a; +SHOW CREATE VIEW v1; +View Create View +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` FORCE INDEX (PRIMARY,`b`) order by `t1`.`a` +EXPLAIN SELECT * FROM v1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 4 NULL 15 +CREATE VIEW v2 AS SELECT * FROM t1 USE KEY () ORDER BY a; +SHOW CREATE VIEW v2; +View Create View +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` USE INDEX () order by `t1`.`a` +EXPLAIN SELECT * FROM v2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 15 Using filesort +CREATE VIEW v3 AS SELECT * FROM t1 IGNORE KEY (b) ORDER BY a; +SHOW CREATE VIEW v3; +View Create View +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` IGNORE INDEX (`b`) order by `t1`.`a` +EXPLAIN SELECT * FROM v3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 15 Using filesort +DROP VIEW v1; +DROP VIEW v2; +DROP VIEW v3; +DROP TABLE t1; End of 5.0 tests. diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index e972ae06a63..e6c3a03c645 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -3434,5 +3434,26 @@ DROP VIEW v1; DROP TABLE t1; +# +# Bug #28702: VIEWs defined with USE/FORCE KEY ignore that request +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, b INT NOT NULL DEFAULT 0, + PRIMARY KEY(a), KEY (b)); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +CREATE VIEW v1 AS SELECT * FROM t1 FORCE KEY (PRIMARY,b) ORDER BY a; +SHOW CREATE VIEW v1; +EXPLAIN SELECT * FROM v1; +CREATE VIEW v2 AS SELECT * FROM t1 USE KEY () ORDER BY a; +SHOW CREATE VIEW v2; +EXPLAIN SELECT * FROM v2; +CREATE VIEW v3 AS SELECT * FROM t1 IGNORE KEY (b) ORDER BY a; +SHOW CREATE VIEW v3; +EXPLAIN SELECT * FROM v3; + +DROP VIEW v1; +DROP VIEW v2; +DROP VIEW v3; +DROP TABLE t1; + --echo End of 5.0 tests. diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 453bf7c3b63..47510c15dcd 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -15469,6 +15469,47 @@ static void print_join(THD *thd, String *str, List *tables) } +/** + @brief Print an index hint for a table + + @details Prints out the USE|FORCE|IGNORE index hints for a table. + + @param thd the current thread + @param[out] str appends the index hint here + @param hint what the hint is (as string : "USE INDEX"| + "FORCE INDEX"|"IGNORE INDEX") + @param hint_length the length of the string in 'hint' + @param indexes a list of index names for the hint +*/ + +void +TABLE_LIST::print_index_hint(THD *thd, String *str, + const char *hint, uint32 hint_length, + List indexes) +{ + List_iterator_fast li(indexes); + String *idx; + bool first= 1; + + str->append (' '); + str->append (hint, hint_length); + str->append (STRING_WITH_LEN(" (")); + while ((idx = li++)) + { + if (first) + first= 0; + else + str->append(','); + if (!my_strcasecmp (system_charset_info, idx->c_ptr_safe(), + primary_key_name)) + str->append(primary_key_name); + else + append_identifier (thd, str, idx->ptr(), idx->length()); + } + str->append(')'); +} + + /* Print table as it should be in join list @@ -15536,6 +15577,17 @@ void TABLE_LIST::print(THD *thd, String *str) str->append(' '); append_identifier(thd, str, alias, strlen(alias)); } + + if (use_index) + { + if (force_index) + print_index_hint(thd, str, STRING_WITH_LEN("FORCE INDEX"), *use_index); + else + print_index_hint(thd, str, STRING_WITH_LEN("USE INDEX"), *use_index); + } + if (ignore_index) + print_index_hint (thd, str, STRING_WITH_LEN("IGNORE INDEX"), *ignore_index); + } } diff --git a/sql/table.h b/sql/table.h index f411ce489c4..cff4be630e4 100644 --- a/sql/table.h +++ b/sql/table.h @@ -773,6 +773,8 @@ struct TABLE_LIST private: bool prep_check_option(THD *thd, uint8 check_opt_type); bool prep_where(THD *thd, Item **conds, bool no_where_clause); + void print_index_hint(THD *thd, String *str, const char *hint, + uint32 hint_length, List); /* Cleanup for re-execution in a prepared statement or a stored procedure. From 7f0e9065f822300b2ef5a392497f85614c1f5373 Mon Sep 17 00:00:00 2001 From: "gshchepa@devsrv-b.mysql.com" <> Date: Wed, 26 Sep 2007 12:45:08 +0200 Subject: [PATCH 037/203] Fixed bug #31075. The `SELECT col FROM t WHERE col NOT IN (col, ...) GROUP BY col' crashed in the range optimizer. The get_func_mm_tree function has been modified to check the Item_func_in::array field for the NULL value before using of that value. --- mysql-test/r/func_in.result | 5 +++++ mysql-test/t/func_in.test | 8 ++++++++ sql/opt_range.cc | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result index 4f64d39ccc0..80fa8f17a2a 100644 --- a/mysql-test/r/func_in.result +++ b/mysql-test/r/func_in.result @@ -564,4 +564,9 @@ explain select f2 from t2 where f2 in (1,'b'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index drop table t1, t2; +create table t1 (a time, key(a)); +insert into t1 values (),(),(),(),(),(),(),(),(),(); +select a from t1 where a not in (a,a,a) group by a; +a +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 2c5ed6a22d3..d8b0c89532e 100644 --- a/mysql-test/t/func_in.test +++ b/mysql-test/t/func_in.test @@ -408,5 +408,13 @@ select f2 from t2 where f2 in (1,'b'); explain select f2 from t2 where f2 in (1,'b'); drop table t1, t2; +# +# Bug #31075: crash in get_func_mm_tree +# + +create table t1 (a time, key(a)); +insert into t1 values (),(),(),(),(),(),(),(),(),(); +select a from t1 where a not in (a,a,a) group by a; +drop table t1; --echo End of 5.1 tests diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 5a772501e48..99c28be36b0 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -5053,7 +5053,7 @@ static SEL_TREE *get_func_mm_tree(RANGE_OPT_PARAM *param, Item_func *cond_func, if (inv) { - if (func->array->result_type() != ROW_RESULT) + if (func->array && func->array->result_type() != ROW_RESULT) { /* We get here for conditions in form "t.key NOT IN (c1, c2, ...)", From e068e99cd0f7cc64c999c81f546daa9337402a8e Mon Sep 17 00:00:00 2001 From: "msvensson@pilot.(none)" <> Date: Wed, 26 Sep 2007 17:04:41 +0200 Subject: [PATCH 038/203] Bug#31167 Introduction of @@hostname breaks replication in a ring - Use a local uservariable to avoid @@hostname in binlog --- scripts/mysql_system_tables_data.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/mysql_system_tables_data.sql b/scripts/mysql_system_tables_data.sql index 5f0289ab197..8399ae796ef 100644 --- a/scripts/mysql_system_tables_data.sql +++ b/scripts/mysql_system_tables_data.sql @@ -15,7 +15,8 @@ DROP TABLE tmp_db; -- from local machine if "users" table didn't exist before CREATE TEMPORARY TABLE tmp_user LIKE user; INSERT INTO tmp_user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0); -REPLACE INTO tmp_user VALUES (@@hostname,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0); +set @hostname= @@hostname; +REPLACE INTO tmp_user VALUES (@hostname,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0); REPLACE INTO tmp_user VALUES ('127.0.0.1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0); INSERT INTO user SELECT * FROM tmp_user WHERE @had_user_table=0; DROP TABLE tmp_user; From c22a4a71f633d3308e0b13d1884b7b4b08875542 Mon Sep 17 00:00:00 2001 From: "msvensson@pilot.(none)" <> Date: Wed, 26 Sep 2007 17:28:20 +0200 Subject: [PATCH 039/203] Update result file(s) for 5.1 --- mysql-test/r/named_pipe.result | 14 +++++++------- mysql-test/r/shm.result | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/mysql-test/r/named_pipe.result b/mysql-test/r/named_pipe.result index 5d22fe4a69b..588b7570d8f 100644 --- a/mysql-test/r/named_pipe.result +++ b/mysql-test/r/named_pipe.result @@ -142,9 +142,9 @@ explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using index explain select fld3 from t2 ignore index (fld3,not_used); -ERROR HY000: Key 'not_used' doesn't exist in table 't2' +ERROR 42000: Key 'not_used' doesn't exist in table 't2' explain select fld3 from t2 use index (not_used); -ERROR HY000: Key 'not_used' doesn't exist in table 't2' +ERROR 42000: Key 'not_used' doesn't exist in table 't2' select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; fld3 honeysuckle @@ -605,11 +605,11 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 ref period period 4 test.t1.period 4181 explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 index period period 4 NULL 41810 +1 SIMPLE t3 ALL period NULL NULL NULL 41810 Using filesort 1 SIMPLE t1 ref period period 4 test.t3.period 4181 explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index period period 4 NULL 41810 +1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort 1 SIMPLE t3 ref period period 4 test.t1.period 4181 select period from t1; period @@ -1429,7 +1429,7 @@ companynr companynr explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary -1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Using join buffer select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; fld1 companynr fld3 period 038008 37 reporters 1008 @@ -1502,8 +1502,8 @@ select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) 70 absentee vest 17788966 254128.0857 3272.5940 10709871.3069 explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 100.00 Using where Warnings: Note 1003 select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> _latin1'')) select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3; diff --git a/mysql-test/r/shm.result b/mysql-test/r/shm.result index 09adebad10f..a99a8b0df5d 100644 --- a/mysql-test/r/shm.result +++ b/mysql-test/r/shm.result @@ -142,9 +142,9 @@ explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using index explain select fld3 from t2 ignore index (fld3,not_used); -ERROR HY000: Key 'not_used' doesn't exist in table 't2' +ERROR 42000: Key 'not_used' doesn't exist in table 't2' explain select fld3 from t2 use index (not_used); -ERROR HY000: Key 'not_used' doesn't exist in table 't2' +ERROR 42000: Key 'not_used' doesn't exist in table 't2' select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; fld3 honeysuckle @@ -605,11 +605,11 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 ref period period 4 test.t1.period 4181 explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 index period period 4 NULL 41810 +1 SIMPLE t3 ALL period NULL NULL NULL 41810 Using filesort 1 SIMPLE t1 ref period period 4 test.t3.period 4181 explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index period period 4 NULL 41810 +1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort 1 SIMPLE t3 ref period period 4 test.t1.period 4181 select period from t1; period @@ -1429,7 +1429,7 @@ companynr companynr explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary -1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Using join buffer select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; fld1 companynr fld3 period 038008 37 reporters 1008 @@ -1502,8 +1502,8 @@ select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) 70 absentee vest 17788966 254128.0857 3272.5940 10709871.3069 explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 100.00 Using where Warnings: Note 1003 select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> _latin1'')) select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3; From d0b796bf14ab6535f7aac54eb33cabf5d38452af Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Wed, 26 Sep 2007 19:06:54 +0300 Subject: [PATCH 040/203] merge of the fix for bug 27802 & 27216 to 5.1-opt --- mysql-test/r/view.result | 12 ++++----- sql/item_cmpfunc.h | 2 ++ sql/sql_insert.cc | 2 +- sql/sql_lex.h | 2 ++ sql/sql_select.cc | 53 +++++++++++++++++++--------------------- sql/table.h | 2 -- 6 files changed, 36 insertions(+), 37 deletions(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 3fe42a0ff80..93b91370d86 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -3575,22 +3575,22 @@ PRIMARY KEY(a), KEY (b)); INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(); CREATE VIEW v1 AS SELECT * FROM t1 FORCE KEY (PRIMARY,b) ORDER BY a; SHOW CREATE VIEW v1; -View Create View -v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` FORCE INDEX (PRIMARY,`b`) order by `t1`.`a` +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` FORCE INDEX (PRIMARY) FORCE INDEX (`b`) order by `t1`.`a` latin1 latin1_swedish_ci EXPLAIN SELECT * FROM v1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL PRIMARY 4 NULL 15 CREATE VIEW v2 AS SELECT * FROM t1 USE KEY () ORDER BY a; SHOW CREATE VIEW v2; -View Create View -v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` USE INDEX () order by `t1`.`a` +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` USE INDEX () order by `t1`.`a` latin1 latin1_swedish_ci EXPLAIN SELECT * FROM v2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 15 Using filesort CREATE VIEW v3 AS SELECT * FROM t1 IGNORE KEY (b) ORDER BY a; SHOW CREATE VIEW v3; -View Create View -v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` IGNORE INDEX (`b`) order by `t1`.`a` +View Create View character_set_client collation_connection +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` IGNORE INDEX (`b`) order by `t1`.`a` latin1 latin1_swedish_ci EXPLAIN SELECT * FROM v3; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 15 Using filesort diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 1a64f9c4211..e9aeef7fc3e 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -1108,6 +1108,7 @@ class Item_func_case :public Item_func uint ncases; Item_result cmp_type; DTCollation cmp_collation; + enum_field_types cached_field_type; cmp_item *cmp_items[5]; /* For all result types */ cmp_item *case_item; public: @@ -1138,6 +1139,7 @@ public: uint decimal_precision() const; table_map not_null_tables() const { return 0; } enum Item_result result_type () const { return cached_result_type; } + enum_field_types field_type() const { return cached_field_type; } const char *func_name() const { return "case"; } void print(String *str); Item *find_item(String *str); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 4bac5f9c9da..459eefbf760 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3315,7 +3315,7 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, if (item->result_type() != STRING_RESULT) field= item->tmp_table_field(&tmp_table); else - field= item->tmp_table_field_from_field_type(&tmp_table); + field= item->tmp_table_field_from_field_type(&tmp_table, 0); else field= create_tmp_field(thd, &tmp_table, item, item->type(), (Item ***) 0, &tmp_field, &def_field, 0, 0, 0, 0, diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 08104769704..d866dde50ef 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -259,6 +259,8 @@ public: key_name.str= str; key_name.length= length; } + + void print(THD *thd, String *str); }; /* diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 83eb597041a..eccd44f2654 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -16044,9 +16044,9 @@ static void print_join(THD *thd, String *str, List *tables) /** - @brief Print an index hint for a table + @brief Print an index hint - @details Prints out the USE|FORCE|IGNORE index hints for a table. + @details Prints out the USE|FORCE|IGNORE index hint. @param thd the current thread @param[out] str appends the index hint here @@ -16057,28 +16057,24 @@ static void print_join(THD *thd, String *str, List *tables) */ void -TABLE_LIST::print_index_hint(THD *thd, String *str, - const char *hint, uint32 hint_length, - List indexes) +Index_hint::print(THD *thd, String *str) { - List_iterator_fast li(indexes); - String *idx; - bool first= 1; - - str->append (' '); - str->append (hint, hint_length); - str->append (STRING_WITH_LEN(" (")); - while ((idx = li++)) + switch (type) { - if (first) - first= 0; - else - str->append(','); - if (!my_strcasecmp (system_charset_info, idx->c_ptr_safe(), - primary_key_name)) + case INDEX_HINT_IGNORE: str->append(STRING_WITH_LEN("IGNORE INDEX")); break; + case INDEX_HINT_USE: str->append(STRING_WITH_LEN("USE INDEX")); break; + case INDEX_HINT_FORCE: str->append(STRING_WITH_LEN("FORCE INDEX")); break; + } + str->append (STRING_WITH_LEN(" (")); + if (key_name.length) + { + if (thd && !my_strnncoll(system_charset_info, + (const uchar *)key_name.str, key_name.length, + (const uchar *)primary_key_name, + strlen(primary_key_name))) str->append(primary_key_name); else - append_identifier (thd, str, idx->ptr(), idx->length()); + append_identifier(thd, str, key_name.str, key_name.length); } str->append(')'); } @@ -16152,16 +16148,17 @@ void TABLE_LIST::print(THD *thd, String *str) append_identifier(thd, str, alias, strlen(alias)); } - if (use_index) + if (index_hints) { - if (force_index) - print_index_hint(thd, str, STRING_WITH_LEN("FORCE INDEX"), *use_index); - else - print_index_hint(thd, str, STRING_WITH_LEN("USE INDEX"), *use_index); - } - if (ignore_index) - print_index_hint (thd, str, STRING_WITH_LEN("IGNORE INDEX"), *ignore_index); + List_iterator it(*index_hints); + Index_hint *hint; + while ((hint= it++)) + { + str->append (STRING_WITH_LEN(" ")); + hint->print (thd, str); + } + } } } diff --git a/sql/table.h b/sql/table.h index 89d92b1be13..6554b6ed578 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1161,8 +1161,6 @@ struct TABLE_LIST private: bool prep_check_option(THD *thd, uint8 check_opt_type); bool prep_where(THD *thd, Item **conds, bool no_where_clause); - void print_index_hint(THD *thd, String *str, const char *hint, - uint32 hint_length, List); /* Cleanup for re-execution in a prepared statement or a stored procedure. From e21bb2640aad40e766328b2016d7c68496113559 Mon Sep 17 00:00:00 2001 From: "msvensson@pilot.(none)" <> Date: Thu, 27 Sep 2007 08:48:39 +0200 Subject: [PATCH 041/203] Move DBUG_ENTER to begining of function to avoid build failure with debug on windows --- libmysql/libmysql.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 85c56a7ea40..14b1a682b49 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -4681,14 +4681,14 @@ int cli_read_binary_rows(MYSQL_STMT *stmt) MYSQL_ROWS *cur, **prev_ptr= &result->data; NET *net; + DBUG_ENTER("cli_read_binary_rows"); + if (!mysql) { set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate); return 1; } - DBUG_ENTER("cli_read_binary_rows"); - net = &mysql->net; mysql= mysql->last_used_con; From 1d12cdfcc4623cbd7856c7ec5d8cdeb5e6d59767 Mon Sep 17 00:00:00 2001 From: "gshchepa/uchum@gleb.loc" <> Date: Thu, 27 Sep 2007 13:15:15 +0500 Subject: [PATCH 042/203] mysqlslap.result, mysqlslap.test: Post-commit fix. --- mysql-test/r/mysqlslap.result | 1 + mysql-test/t/mysqlslap.test | 2 ++ 2 files changed, 3 insertions(+) diff --git a/mysql-test/r/mysqlslap.result b/mysql-test/r/mysqlslap.result index 8b5069bb887..9207dd48d0e 100644 --- a/mysql-test/r/mysqlslap.result +++ b/mysql-test/r/mysqlslap.result @@ -216,3 +216,4 @@ DROP SCHEMA IF EXISTS `mysqlslap`; # DROP PROCEDURE IF EXISTS p1; CREATE PROCEDURE p1() SELECT 1; +DROP PROCEDURE p1; diff --git a/mysql-test/t/mysqlslap.test b/mysql-test/t/mysqlslap.test index 92d31ec9082..28042f62fe6 100644 --- a/mysql-test/t/mysqlslap.test +++ b/mysql-test/t/mysqlslap.test @@ -51,3 +51,5 @@ DROP PROCEDURE IF EXISTS p1; CREATE PROCEDURE p1() SELECT 1; --exec $MYSQL_SLAP --create-schema=test --delimiter=";" --query="CALL p1; SELECT 1;" --silent 2>&1 + +DROP PROCEDURE p1; From fb3b12176dc9af603284eaeb210e89c301934a98 Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Thu, 27 Sep 2007 12:15:19 +0300 Subject: [PATCH 043/203] Bug #30468: column level privileges not respected when joining tables When expanding a * in a USING/NATURAL join the check for table access for both tables in the join was done using the grant information of the first one. Fixed by getting the grant information for the current table while iterating through the columns of the join. --- mysql-test/r/grant2.result | 18 +++++++ mysql-test/t/grant2.test | 32 +++++++++++ sql/sql_acl.cc | 105 ++++++++++++++++++++++++------------- sql/sql_acl.h | 5 +- sql/sql_base.cc | 5 +- sql/sql_insert.cc | 8 ++- 6 files changed, 124 insertions(+), 49 deletions(-) diff --git a/mysql-test/r/grant2.result b/mysql-test/r/grant2.result index 6de9a83aeed..e3c92ecc7c8 100644 --- a/mysql-test/r/grant2.result +++ b/mysql-test/r/grant2.result @@ -421,4 +421,22 @@ revoke all privileges, grant option from mysqltest_1@localhost; revoke all privileges, grant option from mysqltest_2@localhost; drop user mysqltest_1@localhost; drop user mysqltest_2@localhost; +CREATE DATABASE db1; +USE db1; +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1),(2,2); +CREATE TABLE t2 (b INT, c INT); +INSERT INTO t2 VALUES (1,100),(2,200); +GRANT SELECT ON t1 TO mysqltest1@localhost; +GRANT SELECT (b) ON t2 TO mysqltest1@localhost; +USE db1; +SELECT c FROM t2; +ERROR 42000: SELECT command denied to user 'mysqltest1'@'localhost' for column 'c' in table 't2' +SELECT * FROM t2; +ERROR 42000: SELECT command denied to user 'mysqltest1'@'localhost' for column 'c' in table 't2' +SELECT * FROM t1 JOIN t2 USING (b); +ERROR 42000: SELECT command denied to user 'mysqltest1'@'localhost' for column 'c' in table 't2' +DROP TABLE db1.t1, db1.t2; +DROP USER mysqltest1@localhost; +DROP DATABASE db1; End of 5.0 tests diff --git a/mysql-test/t/grant2.test b/mysql-test/t/grant2.test index a3a8e2d5d53..e2d92ee58d4 100644 --- a/mysql-test/t/grant2.test +++ b/mysql-test/t/grant2.test @@ -585,5 +585,37 @@ drop user mysqltest_1@localhost; drop user mysqltest_2@localhost; +# +# Bug #30468: column level privileges not respected when joining tables +# +CREATE DATABASE db1; + +USE db1; +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1),(2,2); + +CREATE TABLE t2 (b INT, c INT); +INSERT INTO t2 VALUES (1,100),(2,200); + +GRANT SELECT ON t1 TO mysqltest1@localhost; +GRANT SELECT (b) ON t2 TO mysqltest1@localhost; + +connect (conn1,localhost,mysqltest1,,); +connection conn1; +USE db1; +--error ER_COLUMNACCESS_DENIED_ERROR +SELECT c FROM t2; +--error ER_COLUMNACCESS_DENIED_ERROR +SELECT * FROM t2; +--error ER_COLUMNACCESS_DENIED_ERROR +SELECT * FROM t1 JOIN t2 USING (b); + +connection default; +disconnect conn1; +DROP TABLE db1.t1, db1.t2; +DROP USER mysqltest1@localhost; +DROP DATABASE db1; + + --echo End of 5.0 tests diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index f9bd2c6ba0d..708c298daa3 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -3835,50 +3835,81 @@ bool check_column_grant_in_table_ref(THD *thd, TABLE_LIST * table_ref, } -bool check_grant_all_columns(THD *thd, ulong want_access, GRANT_INFO *grant, - const char* db_name, const char *table_name, - Field_iterator *fields) +/** + @brief check if a query can access a set of columns + + @param thd the current thread + @param want_access_arg the privileges requested + @param fields an iterator over the fields of a table reference. + @return Operation status + @retval 0 Success + @retval 1 Falure + @details This function walks over the columns of a table reference + The columns may originate from different tables, depending on the kind of + table reference, e.g. join. + For each table it will retrieve the grant information and will use it + to check the required access privileges for the fields requested from it. +*/ +bool check_grant_all_columns(THD *thd, ulong want_access_arg, + Field_iterator_table_ref *fields) { Security_context *sctx= thd->security_ctx; - GRANT_TABLE *grant_table; - GRANT_COLUMN *grant_column; + ulong want_access= want_access_arg; + const char *table_name= NULL; - want_access &= ~grant->privilege; - if (!want_access) - return 0; // Already checked - if (!grant_option) - goto err2; - - rw_rdlock(&LOCK_grant); - - /* reload table if someone has modified any grants */ - - if (grant->version != grant_version) + if (grant_option) { - grant->grant_table= - table_hash_search(sctx->host, sctx->ip, db_name, - sctx->priv_user, - table_name, 0); /* purecov: inspected */ - grant->version= grant_version; /* purecov: inspected */ - } - /* The following should always be true */ - if (!(grant_table= grant->grant_table)) - goto err; /* purecov: inspected */ + const char* db_name; + GRANT_INFO *grant; + GRANT_TABLE *grant_table; - for (; !fields->end_of_fields(); fields->next()) - { - const char *field_name= fields->name(); - grant_column= column_hash_search(grant_table, field_name, - (uint) strlen(field_name)); - if (!grant_column || (~grant_column->rights & want_access)) - goto err; - } - rw_unlock(&LOCK_grant); - return 0; + rw_rdlock(&LOCK_grant); + + for (; !fields->end_of_fields(); fields->next()) + { + const char *field_name= fields->name(); + + if (table_name != fields->table_name()) + { + table_name= fields->table_name(); + db_name= fields->db_name(); + grant= fields->grant(); + /* get a fresh one for each table */ + want_access= want_access_arg & ~grant->privilege; + if (want_access) + { + /* reload table if someone has modified any grants */ + if (grant->version != grant_version) + { + grant->grant_table= + table_hash_search(sctx->host, sctx->ip, db_name, + sctx->priv_user, + table_name, 0); /* purecov: inspected */ + grant->version= grant_version; /* purecov: inspected */ + } + + DBUG_ASSERT ((grant_table= grant->grant_table) != NULL); + } + } + + if (want_access) + { + GRANT_COLUMN *grant_column= + column_hash_search(grant_table, field_name, + (uint) strlen(field_name)); + if (!grant_column || (~grant_column->rights & want_access)) + goto err; + } + } + rw_unlock(&LOCK_grant); + return 0; err: - rw_unlock(&LOCK_grant); -err2: + rw_unlock(&LOCK_grant); + } + else + table_name= fields->table_name(); + char command[128]; get_privilege_desc(command, sizeof(command), want_access); my_error(ER_COLUMNACCESS_DENIED_ERROR, MYF(0), diff --git a/sql/sql_acl.h b/sql/sql_acl.h index d08f2663af5..b2007ccdf47 100644 --- a/sql/sql_acl.h +++ b/sql/sql_acl.h @@ -205,9 +205,8 @@ bool check_grant_column (THD *thd, GRANT_INFO *grant, const char *name, uint length, Security_context *sctx); bool check_column_grant_in_table_ref(THD *thd, TABLE_LIST * table_ref, const char *name, uint length); -bool check_grant_all_columns(THD *thd, ulong want_access, GRANT_INFO *grant, - const char* db_name, const char *table_name, - Field_iterator *fields); +bool check_grant_all_columns(THD *thd, ulong want_access, + Field_iterator_table_ref *fields); bool check_grant_routine(THD *thd, ulong want_access, TABLE_LIST *procs, bool is_proc, bool no_error); bool check_grant_db(THD *thd,const char *db); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 289924ff418..2f8bb35683b 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -5414,10 +5414,7 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name, !any_privileges) { field_iterator.set(tables); - if (check_grant_all_columns(thd, SELECT_ACL, field_iterator.grant(), - field_iterator.db_name(), - field_iterator.table_name(), - &field_iterator)) + if (check_grant_all_columns(thd, SELECT_ACL, &field_iterator)) DBUG_RETURN(TRUE); } #endif diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index bd21d929291..7eb9b078ded 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -189,11 +189,9 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list, #ifndef NO_EMBEDDED_ACCESS_CHECKS if (grant_option) { - Field_iterator_table field_it; - field_it.set_table(table); - if (check_grant_all_columns(thd, INSERT_ACL, &table->grant, - table->s->db, table->s->table_name, - &field_it)) + Field_iterator_table_ref field_it; + field_it.set(table_list); + if (check_grant_all_columns(thd, INSERT_ACL, &field_it)) return -1; } #endif From bebbe4542f5c87320f1d57523e38110821fda12f Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Thu, 27 Sep 2007 14:29:46 +0300 Subject: [PATCH 044/203] separated an assertion from the assignment (bug 30468) --- sql/sql_acl.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 708c298daa3..09c5790881f 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -3888,7 +3888,8 @@ bool check_grant_all_columns(THD *thd, ulong want_access_arg, grant->version= grant_version; /* purecov: inspected */ } - DBUG_ASSERT ((grant_table= grant->grant_table) != NULL); + grant_table= grant->grant_table; + DBUG_ASSERT (grant_table); } } From c41cb794637362bba12b6dd84d219d71692a988a Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Thu, 27 Sep 2007 17:56:50 +0300 Subject: [PATCH 045/203] Fixed a warning cased by the fix for bug 30468 --- sql/sql_acl.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 09c5790881f..ecefabaced3 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -3861,7 +3861,8 @@ bool check_grant_all_columns(THD *thd, ulong want_access_arg, { const char* db_name; GRANT_INFO *grant; - GRANT_TABLE *grant_table; + /* Initialized only to make gcc happy */ + GRANT_TABLE *grant_table= NULL; rw_rdlock(&LOCK_grant); From ab73b25d5bc3b65cea1fe389845769faa607a3ff Mon Sep 17 00:00:00 2001 From: "mhansson/martin@linux-st28.site" <> Date: Fri, 28 Sep 2007 09:36:05 +0200 Subject: [PATCH 046/203] Bug#30665: Inconsistent optimization of IGNORE INDEX FOR {ORDER BY|GROUP BY} The optimizer takes different execution paths during EXPLAIN than SELECT, this fix relates only to EXPLAIN, hence no behavior changes. The test of sort keys for ORDER BY was prohibited from considering keys that were mentioned in IGNORE KEYS FOR ORDER BY. This led to two inconsistencies: One was that IGNORE INDEX FOR GROUP BY and IGNORE INDEX FOR ORDER BY gave apparently different EXPLAINs; the latter erroneously claimed to do filesort. The second inconsistency is that the test of sort keys is called twice, finding a sort key the first time but not the second time, leading to the mentioned filesort. Fixed by making the test of sort keys consider all enabled keys on the table. This test rejects keys that are not covering, and for covering keys the hint should be ignored anyway. --- mysql-test/r/group_by.result | 148 +++++++++++++++++- mysql-test/r/order_by.result | 285 +++++++++++++++++++++++++++++++++++ mysql-test/t/group_by.test | 1 + mysql-test/t/order_by.test | 57 +++++++ sql/sql_select.cc | 4 +- 5 files changed, 493 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 2faf7832aca..0b38cc2290e 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -1096,7 +1096,153 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index; Using filesort EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index; Using filesort +1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index +SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a; +a +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) IGNORE INDEX FOR GROUP BY (i2) GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index ff4882d6cd8..3d0f4915d0a 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -1131,3 +1131,288 @@ id c3 186 14 196 14 DROP TABLE t1,t2; +CREATE TABLE t1 ( +a INT, +b INT, +PRIMARY KEY (a), +KEY ab(a, b) +); +INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4); +INSERT INTO t1 SELECT a + 4, b + 4 FROM t1; +INSERT INTO t1 SELECT a + 8, b + 8 FROM t1; +INSERT INTO t1 SELECT a +16, b +16 FROM t1; +INSERT INTO t1 SELECT a +32, b +32 FROM t1; +INSERT INTO t1 SELECT a +64, b +64 FROM t1; +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (a, ab) GROUP BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range NULL ab 4 NULL 10 Using index for group-by +SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (a, ab) GROUP BY a; +a +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +SELECT @tmp_tables_after = @tmp_tables_before ; +@tmp_tables_after = @tmp_tables_before +1 +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (a, ab) ORDER BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 4 NULL 128 Using index +SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (a, ab) ORDER BY a; +a +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +SELECT @tmp_tables_after = @tmp_tables_before; +@tmp_tables_after = @tmp_tables_before +1 +DROP TABLE t1; diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index ae616df0dfd..2ea7aed6bd2 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -811,6 +811,7 @@ EXPLAIN SELECT a FROM t1 IGNORE INDEX (PRIMARY,i2); EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR JOIN (PRIMARY,i2); EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (PRIMARY,i2) GROUP BY a; EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a; +SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a; EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) IGNORE INDEX FOR GROUP BY (i2) GROUP BY a; EXPLAIN SELECT a FROM t1 IGNORE INDEX (PRIMARY) IGNORE INDEX FOR ORDER BY (i2); diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index 37398616299..71238504d36 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -779,3 +779,60 @@ EXPLAIN SELECT id,c3 FROM t2 WHERE c2 BETWEEN 20 AND 30 ORDER BY c3 LIMIT 4000; SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 20; DROP TABLE t1,t2; + +# +# Bug #30665: Inconsistent optimization of IGNORE INDEX FOR {ORDER BY|GROUP BY} +# +CREATE TABLE t1 ( + a INT, + b INT, + PRIMARY KEY (a), + KEY ab(a, b) +); +INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4); +INSERT INTO t1 SELECT a + 4, b + 4 FROM t1; +INSERT INTO t1 SELECT a + 8, b + 8 FROM t1; +INSERT INTO t1 SELECT a +16, b +16 FROM t1; +INSERT INTO t1 SELECT a +32, b +32 FROM t1; +INSERT INTO t1 SELECT a +64, b +64 FROM t1; + +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (a, ab) GROUP BY a; + +--disable_query_log +--let $q = `show status like 'Created_tmp_tables';` +eval set @tmp_tables_before = + CAST(REPLACE('$q', 'Created_tmp_tables', '') AS UNSIGNED); +--enable_query_log + +SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (a, ab) GROUP BY a; + +# this query creates one temporary table in itself, which we are not +# interested in. + +--disable_query_log +--let $q = `show status like 'Created_tmp_tables';` +eval set @tmp_tables_after = + CAST(REPLACE('$q', 'Created_tmp_tables', '') AS UNSIGNED); +--enable_query_log + +SELECT @tmp_tables_after = @tmp_tables_before ; + +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (a, ab) ORDER BY a; + +--disable_query_log +--let $q = `show status like 'Created_tmp_tables';` +eval set @tmp_tables_before = + CAST(REPLACE('$q', 'Created_tmp_tables', '') AS UNSIGNED); +--enable_query_log + +SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (a, ab) ORDER BY a; + +--disable_query_log +--let $q = `show status like 'Created_tmp_tables';` +eval set @tmp_tables_after = + CAST(REPLACE('$q', 'Created_tmp_tables', '') AS UNSIGNED); +--enable_query_log + +SELECT @tmp_tables_after = @tmp_tables_before; + +DROP TABLE t1; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b77bb719e1e..0b45cd1b12c 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1695,7 +1695,7 @@ JOIN::exec() test_if_skip_sort_order(&join_tab[const_tables], order, select_limit, 0, &join_tab[const_tables].table-> - keys_in_use_for_order_by)))) + keys_in_use_for_query)))) order=0; having= tmp_having; select_describe(this, need_tmp, @@ -12614,6 +12614,8 @@ find_field_in_item_list (Field *field, void *data) If we can use an index, the JOIN_TAB / tab->select struct is changed to use the index. + The index must cover all fields in , or it will not be considered. + Return: 0 We have to use filesort to do the sorting 1 We can use an index. From 44178403c1130445c6f497b8c595ce1eb7b76f6b Mon Sep 17 00:00:00 2001 From: "mhansson@dl145s.mysql.com" <> Date: Fri, 28 Sep 2007 12:30:55 +0200 Subject: [PATCH 047/203] Bug#30665: Post-merge fix --- mysql-test/r/group_by.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 0b38cc2290e..7498267c91d 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -1093,7 +1093,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 144 EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (PRIMARY,i2) GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index; Using filesort +1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index From ccccad7058df3061a6e4a406cb679ce864deb549 Mon Sep 17 00:00:00 2001 From: "gluh@mysql.com/eagle.(none)" <> Date: Fri, 28 Sep 2007 16:02:43 +0500 Subject: [PATCH 048/203] Bug#30689 Wrong content in I_S.VIEWS.VIEW_DEFINITION if VIEW is based on I_S view_body_utf8 attribute type is changed to 'escaped string' --- mysql-test/r/ddl_i18n_koi8r.result | 6 ++++-- mysql-test/r/ddl_i18n_utf8.result | 6 ++++-- mysql-test/r/information_schema.result | 20 ++++++++++++++++---- mysql-test/t/information_schema.test | 10 ++++++++++ sql/sql_view.cc | 2 +- 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/mysql-test/r/ddl_i18n_koi8r.result b/mysql-test/r/ddl_i18n_koi8r.result index 3d38319df21..fbaf2f2fd4a 100644 --- a/mysql-test/r/ddl_i18n_koi8r.result +++ b/mysql-test/r/ddl_i18n_koi8r.result @@ -29,7 +29,8 @@ v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VI SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'| TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION -NULL mysqltest1 v1 SELECT 'ÔÅÓÔ' AS c1, ËÏÌ AS c2 NONE YES root@localhost DEFINER koi8r koi8r_general_ci +NULL mysqltest1 v1 SELECT 'ÔÅÓÔ' AS c1, ËÏÌ AS c2 +FROM t1 NONE YES root@localhost DEFINER koi8r koi8r_general_ci SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'| TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION @@ -68,7 +69,8 @@ v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VI SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'| TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION -NULL mysqltest1 v1 SELECT 'ÔÅÓÔ' AS c1, ËÏÌ AS c2 NONE YES root@localhost DEFINER koi8r koi8r_general_ci +NULL mysqltest1 v1 SELECT 'ÔÅÓÔ' AS c1, ËÏÌ AS c2 +FROM t1 NONE YES root@localhost DEFINER koi8r koi8r_general_ci SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'| TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION diff --git a/mysql-test/r/ddl_i18n_utf8.result b/mysql-test/r/ddl_i18n_utf8.result index b8e690bfeb7..d0f176c1985 100644 --- a/mysql-test/r/ddl_i18n_utf8.result +++ b/mysql-test/r/ddl_i18n_utf8.result @@ -29,7 +29,8 @@ v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VI SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'| TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION -NULL mysqltest1 v1 SELECT 'теÑÑ‚' AS c1, кол AS c2 NONE YES root@localhost DEFINER utf8 utf8_general_ci +NULL mysqltest1 v1 SELECT 'теÑÑ‚' AS c1, кол AS c2 +FROM t1 NONE YES root@localhost DEFINER utf8 utf8_general_ci SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'| TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION @@ -68,7 +69,8 @@ v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VI SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'| TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION -NULL mysqltest1 v1 SELECT 'теÑÑ‚' AS c1, кол AS c2 NONE YES root@localhost DEFINER utf8 utf8_general_ci +NULL mysqltest1 v1 SELECT 'теÑÑ‚' AS c1, кол AS c2 +FROM t1 NONE YES root@localhost DEFINER utf8 utf8_general_ci SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'| TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 885acf5c744..37810e67f2a 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -387,10 +387,14 @@ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_par select * from information_schema.views where TABLE_NAME like "v%"; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION NULL test v0 select schema_name from information_schema.schemata NONE NO root@localhost DEFINER latin1 latin1_swedish_ci -NULL test v1 select table_name from information_schema.tables NONE NO root@localhost DEFINER latin1 latin1_swedish_ci -NULL test v2 select column_name from information_schema.columns NONE NO root@localhost DEFINER latin1 latin1_swedish_ci -NULL test v3 select CHARACTER_SET_NAME from information_schema.character_sets NONE NO root@localhost DEFINER latin1 latin1_swedish_ci -NULL test v4 select COLLATION_NAME from information_schema.collations NONE NO root@localhost DEFINER latin1 latin1_swedish_ci +NULL test v1 select table_name from information_schema.tables +where table_name="v1" NONE NO root@localhost DEFINER latin1 latin1_swedish_ci +NULL test v2 select column_name from information_schema.columns +where table_name="v2" NONE NO root@localhost DEFINER latin1 latin1_swedish_ci +NULL test v3 select CHARACTER_SET_NAME from information_schema.character_sets +where CHARACTER_SET_NAME like "latin1%" NONE NO root@localhost DEFINER latin1 latin1_swedish_ci +NULL test v4 select COLLATION_NAME from information_schema.collations +where COLLATION_NAME like "latin1%" NONE NO root@localhost DEFINER latin1 latin1_swedish_ci drop view v0, v1, v2, v3, v4; create table t1 (a int); grant select,update,insert on t1 to mysqltest_1@localhost; @@ -1540,4 +1544,12 @@ count(*) select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='' AND TABLE_NAME='nonexisting'; count(*) 0 +CREATE VIEW v1 +AS SELECT * +FROM INFORMATION_SCHEMA.TABLES; +SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS where TABLE_NAME = 'v1'; +VIEW_DEFINITION +SELECT * +FROM INFORMATION_SCHEMA.TABLES +DROP VIEW v1; End of 5.1 tests. diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 6bcc14d4e49..90671c4e8fd 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1178,4 +1178,14 @@ select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysql' AND TA select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysql' AND TABLE_NAME=''; select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='' AND TABLE_NAME=''; select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='' AND TABLE_NAME='nonexisting'; + +# +# Bug#30689 Wrong content in I_S.VIEWS.VIEW_DEFINITION if VIEW is based on I_S +# +CREATE VIEW v1 +AS SELECT * +FROM INFORMATION_SCHEMA.TABLES; +SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS where TABLE_NAME = 'v1'; +DROP VIEW v1; + --echo End of 5.1 tests. diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 9e16a5e31ee..00e97ace938 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -672,7 +672,7 @@ static File_option view_parameters[]= FILE_OPTIONS_STRING}, {{(char*) STRING_WITH_LEN("view_body_utf8")}, my_offsetof(TABLE_LIST, view_body_utf8), - FILE_OPTIONS_STRING}, + FILE_OPTIONS_ESTRING}, {{NullS, 0}, 0, FILE_OPTIONS_STRING} }; From e452c06438f82dbf8e0f6366dddf8e7dd26fa774 Mon Sep 17 00:00:00 2001 From: "anozdrin/alik@station." <> Date: Fri, 28 Sep 2007 15:42:37 +0400 Subject: [PATCH 049/203] Prerequisite patch for BUG#30472: libmysql doesn't reset charset, insert_id after succ. mysql_change_user() call. Supply a correct packet length to dispatch command. --- sql/sp_head.cc | 2 +- sql/sql_parse.cc | 112 ++++++++++++--------- sql/sql_prepare.cc | 11 ++- tests/mysql_client_test.c | 201 +++++++++++++++++++++++++++++++++++++- 4 files changed, 272 insertions(+), 54 deletions(-) diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 828517011d5..7de230bba78 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -2699,7 +2699,7 @@ sp_instr_stmt::execute(THD *thd, uint *nextp) query= thd->query; query_length= thd->query_length; - if (!(res= alloc_query(thd, m_query.str, m_query.length+1)) && + if (!(res= alloc_query(thd, m_query.str, m_query.length)) && !(res=subst_spvars(thd, this, &m_query))) { /* diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 6002d7545ba..3dbcfe6d2bc 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -321,8 +321,6 @@ void execute_init_command(THD *thd, sys_var_str *init_command_var, values of init_command_var can't be changed */ rw_rdlock(var_mutex); - thd->query= init_command_var->value; - thd->query_length= init_command_var->value_length; save_client_capabilities= thd->client_capabilities; thd->client_capabilities|= CLIENT_MULTI_QUERIES; /* @@ -332,7 +330,9 @@ void execute_init_command(THD *thd, sys_var_str *init_command_var, save_vio= thd->net.vio; thd->net.vio= 0; thd->net.no_send_error= 0; - dispatch_command(COM_QUERY, thd, thd->query, thd->query_length+1); + dispatch_command(COM_QUERY, thd, + init_command_var->value, + init_command_var->value_length); rw_unlock(var_mutex); thd->client_capabilities= save_client_capabilities; thd->net.vio= save_vio; @@ -691,30 +691,39 @@ bool do_command(THD *thd) net->error= 0; DBUG_RETURN(FALSE); } - else + + packet= (char*) net->read_pos; + /* + 'packet_length' contains length of data, as it was stored in packet + header. In case of malformed header, my_net_read returns zero. + If packet_length is not zero, my_net_read ensures that the returned + number of bytes was actually read from network. + There is also an extra safety measure in my_net_read: + it sets packet[packet_length]= 0, but only for non-zero packets. + */ + if (packet_length == 0) /* safety */ { - packet=(char*) net->read_pos; - command = (enum enum_server_command) (uchar) packet[0]; - if (command >= COM_END) - command= COM_END; // Wrong command - DBUG_PRINT("info",("Command on %s = %d (%s)", - vio_description(net->vio), command, - command_name[command].str)); + /* Initialize with COM_SLEEP packet */ + packet[0]= (uchar) COM_SLEEP; + packet_length= 1; } + /* Do not rely on my_net_read, extra safety against programming errors. */ + packet[packet_length]= '\0'; /* safety */ + + command= (enum enum_server_command) (uchar) packet[0]; + + if (command >= COM_END) + command= COM_END; // Wrong command + + DBUG_PRINT("info",("Command on %s = %d (%s)", + vio_description(net->vio), command, + command_name[command].str)); /* Restore read timeout value */ my_net_set_read_timeout(net, thd->variables.net_read_timeout); - /* - packet_length contains length of data, as it was stored in packet - header. In case of malformed header, packet_length can be zero. - If packet_length is not zero, my_net_read ensures that this number - of bytes was actually read from network. Additionally my_net_read - sets packet[packet_length]= 0 (thus if packet_length == 0, - command == packet[0] == COM_SLEEP). - In dispatch_command packet[packet_length] points beyond the end of packet. - */ - DBUG_RETURN(dispatch_command(command,thd, packet+1, (uint) packet_length)); + DBUG_ASSERT(packet_length); + DBUG_RETURN(dispatch_command(command, thd, packet+1, (uint) (packet_length-1))); } #endif /* EMBEDDED_LIBRARY */ @@ -727,9 +736,7 @@ bool do_command(THD *thd) thd connection handle command type of command to perform packet data for the command, packet is always null-terminated - packet_length length of packet + 1 (to show that data is - null-terminated) except for COM_SLEEP, where it - can be zero. + packet_length length of packet. Can be zero, e.g. in case of COM_SLEEP. RETURN VALUE 0 ok 1 request of thread shutdown, i. e. if command is @@ -773,7 +780,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, LEX_STRING tmp; status_var_increment(thd->status_var.com_stat[SQLCOM_CHANGE_DB]); thd->convert_string(&tmp, system_charset_info, - packet, packet_length-1, thd->charset()); + packet, packet_length, thd->charset()); if (!mysql_change_db(thd, &tmp, FALSE)) { general_log_print(thd, command, "%s",thd->db); @@ -793,14 +800,16 @@ bool dispatch_command(enum enum_server_command command, THD *thd, { char *tbl_name; LEX_STRING db; + /* Safe because there is always a trailing \0 at the end of the packet */ uint db_len= *(uchar*) packet; - if (db_len >= packet_length || db_len > NAME_LEN) + if (db_len + 1 > packet_length || db_len > NAME_LEN) { my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0)); break; } + /* Safe because there is always a trailing \0 at the end of the packet */ uint tbl_len= *(uchar*) (packet + db_len + 1); - if (db_len+tbl_len+2 > packet_length || tbl_len > NAME_LEN) + if (db_len + tbl_len + 2 > packet_length || tbl_len > NAME_LEN) { my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0)); break; @@ -823,7 +832,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd, case COM_CHANGE_USER: { status_var_increment(thd->status_var.com_other); - char *user= (char*) packet, *packet_end= packet+ packet_length; + char *user= (char*) packet, *packet_end= packet + packet_length; + /* Safe because there is always a trailing \0 at the end of the packet */ char *passwd= strend(user)+1; thd->change_user(); @@ -840,6 +850,15 @@ bool dispatch_command(enum enum_server_command command, THD *thd, char db_buff[NAME_LEN+1]; // buffer to store db in utf8 char *db= passwd; char *save_db; + /* + If there is no password supplied, the packet must contain '\0', + in any type of handshake (4.1 or pre-4.1). + */ + if (passwd >= packet_end) + { + my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0)); + break; + } uint passwd_len= (thd->client_capabilities & CLIENT_SECURE_CONNECTION ? (uchar)(*passwd++) : strlen(passwd)); uint dummy_errors, save_db_length, db_length; @@ -848,22 +867,17 @@ bool dispatch_command(enum enum_server_command command, THD *thd, USER_CONN *save_user_connect; db+= passwd_len + 1; -#ifndef EMBEDDED_LIBRARY - /* Small check for incoming packet */ - if ((uint) ((uchar*) db - net->read_pos) > packet_length) + /* + Database name is always NUL-terminated, so in case of empty database + the packet must contain at least the trailing '\0'. + */ + if (db >= packet_end) { my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0)); break; } -#endif + db_length= packet_end - db - 1; /* do not count the trailing '\0' */ /* Convert database name to utf8 */ - /* - Handle problem with old bug in client protocol where db had an extra - \0 - */ - db_length= (packet_end - db); - if (db_length > 0 && db[db_length-1] == 0) - db_length--; db_buff[copy_and_convert(db_buff, sizeof(db_buff)-1, system_charset_info, db, db_length, thd->charset(), &dummy_errors)]= 0; @@ -999,7 +1013,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, break; #else { - char *fields, *packet_end= packet + packet_length - 1, *arg_end; + char *fields, *packet_end= packet + packet_length, *arg_end; /* Locked closure of all tables */ TABLE_LIST table_list; LEX_STRING conv_name; @@ -1074,7 +1088,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, HA_CREATE_INFO create_info; status_var_increment(thd->status_var.com_stat[SQLCOM_CREATE_DB]); - if (thd->make_lex_string(&db, packet, packet_length - 1, FALSE) || + if (thd->make_lex_string(&db, packet, packet_length, FALSE) || thd->make_lex_string(&alias, db.str, db.length, FALSE) || check_db_name(&db)) { @@ -1095,7 +1109,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, status_var_increment(thd->status_var.com_stat[SQLCOM_DROP_DB]); LEX_STRING db; - if (thd->make_lex_string(&db, packet, packet_length - 1, FALSE) || + if (thd->make_lex_string(&db, packet, packet_length, FALSE) || check_db_name(&db)) { my_error(ER_WRONG_DB_NAME, MYF(0), db.str ? db.str : "NULL"); @@ -1164,7 +1178,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, break; /* purecov: inspected */ /* If the client is < 4.1.3, it is going to send us no argument; then - packet_length is 1, packet[0] is the end 0 of the packet. Note that + packet_length is 0, packet[0] is the end 0 of the packet. Note that SHUTDOWN_DEFAULT is 0. If client is >= 4.1.3, the shutdown level is in packet[0]. */ @@ -1522,9 +1536,8 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident, bool alloc_query(THD *thd, const char *packet, uint packet_length) { - packet_length--; // Remove end null /* Remove garbage at start and end of query */ - while (my_isspace(thd->charset(),packet[0]) && packet_length > 0) + while (packet_length > 0 && my_isspace(thd->charset(), packet[0])) { packet++; packet_length--; @@ -7238,7 +7251,12 @@ bool parse_sql(THD *thd, /* Parse the query. */ - bool err_status= MYSQLparse(thd) != 0 || thd->is_fatal_error; + bool mysql_parse_status= MYSQLparse(thd) != 0; + + /* Check that if MYSQLparse() failed, thd->net.report_error is set. */ + + DBUG_ASSERT(!mysql_parse_status || + mysql_parse_status && thd->net.report_error); /* Reset Lex_input_stream. */ @@ -7251,7 +7269,7 @@ bool parse_sql(THD *thd, /* That's it. */ - return err_status; + return mysql_parse_status || thd->is_fatal_error; } /** diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index c576a9dba1d..05743b6dfe3 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -2107,7 +2107,7 @@ void mysql_sql_stmt_prepare(THD *thd) DBUG_VOID_RETURN; } - if (stmt->prepare(query, query_len+1)) + if (stmt->prepare(query, query_len)) { /* Statement map deletes the statement on erase */ thd->stmt_map.erase(stmt); @@ -2270,7 +2270,7 @@ void mysql_stmt_execute(THD *thd, char *packet_arg, uint packet_length) /* Query text for binary, general or slow log, if any of them is open */ String expanded_query; #ifndef EMBEDDED_LIBRARY - uchar *packet_end= packet + packet_length - 1; + uchar *packet_end= packet + packet_length; #endif Prepared_statement *stmt; bool error; @@ -2585,14 +2585,14 @@ void mysql_stmt_get_longdata(THD *thd, char *packet, ulong packet_length) Prepared_statement *stmt; Item_param *param; #ifndef EMBEDDED_LIBRARY - char *packet_end= packet + packet_length - 1; + char *packet_end= packet + packet_length; #endif DBUG_ENTER("mysql_stmt_get_longdata"); status_var_increment(thd->status_var.com_stmt_send_long_data); #ifndef EMBEDDED_LIBRARY /* Minimal size of long data packet is 6 bytes */ - if (packet_length <= MYSQL_LONG_DATA_HEADER) + if (packet_length < MYSQL_LONG_DATA_HEADER) { my_error(ER_WRONG_ARGUMENTS, MYF(0), "mysql_stmt_send_long_data"); DBUG_VOID_RETURN; @@ -2866,6 +2866,7 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len) error= parse_sql(thd, &lip, NULL) || thd->net.report_error || init_param_array(this); + lex->set_trg_event_type_for_tables(); /* Remember the current database. */ @@ -3059,7 +3060,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) if (expanded_query->length() && alloc_query(thd, (char*) expanded_query->ptr(), - expanded_query->length()+1)) + expanded_query->length())) { my_error(ER_OUTOFMEMORY, 0, expanded_query->length()); goto error; diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 7f0289d93db..93a85f44919 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -13534,7 +13534,7 @@ static void test_bug9478() { char buff[8]; - /* Fill in the fethc packet */ + /* Fill in the fetch packet */ int4store(buff, stmt->stmt_id); buff[4]= 1; /* prefetch rows */ rc= ((*mysql->methods->advanced_command)(mysql, COM_STMT_FETCH, @@ -16214,6 +16214,204 @@ static void test_bug28934() myquery(mysql_query(mysql, "drop table t1")); } +/* + Test mysql_change_user() C API and COM_CHANGE_USER +*/ + +static void test_change_user() +{ + char buff[256]; + const char *user_pw= "mysqltest_pw"; + const char *user_no_pw= "mysqltest_no_pw"; + const char *pw= "password"; + const char *db= "mysqltest_user_test_database"; + int rc; + + DBUG_ENTER("test_change_user"); + myheader("test_change_user"); + + /* Prepare environment */ + sprintf(buff, "drop database if exists %s", db); + rc= mysql_query(mysql, buff); + myquery(rc); + + sprintf(buff, "create database %s", db); + rc= mysql_query(mysql, buff); + myquery(rc); + + sprintf(buff, + "grant select on %s.* to %s@'%%' identified by '%s'", + db, + user_pw, + pw); + rc= mysql_query(mysql, buff); + myquery(rc); + + sprintf(buff, + "grant select on %s.* to %s@'%%'", + db, + user_no_pw); + rc= mysql_query(mysql, buff); + myquery(rc); + + + /* Try some combinations */ + rc= mysql_change_user(mysql, NULL, NULL, NULL); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + + rc= mysql_change_user(mysql, "", NULL, NULL); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, "", "", NULL); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, "", "", ""); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, NULL, "", ""); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + + rc= mysql_change_user(mysql, NULL, NULL, ""); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, "", NULL, ""); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, user_pw, NULL, ""); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, user_pw, "", ""); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, user_pw, "", NULL); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, user_pw, NULL, NULL); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, user_pw, "", db); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, user_pw, NULL, db); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, user_pw, pw, db); + myquery(rc); + + rc= mysql_change_user(mysql, user_pw, pw, NULL); + myquery(rc); + + rc= mysql_change_user(mysql, user_pw, pw, ""); + myquery(rc); + + rc= mysql_change_user(mysql, user_no_pw, pw, db); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, user_no_pw, pw, ""); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, user_no_pw, pw, NULL); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, user_no_pw, "", NULL); + myquery(rc); + + rc= mysql_change_user(mysql, user_no_pw, "", ""); + myquery(rc); + + rc= mysql_change_user(mysql, user_no_pw, "", db); + myquery(rc); + + rc= mysql_change_user(mysql, user_no_pw, NULL, db); + myquery(rc); + + rc= mysql_change_user(mysql, "", pw, db); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, "", pw, ""); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, "", pw, NULL); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, NULL, pw, NULL); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, NULL, NULL, db); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, NULL, "", db); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, "", "", db); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + /* Cleanup the environment */ + + mysql_change_user(mysql, opt_user, opt_password, current_db); + + sprintf(buff, "drop database %s", db); + rc= mysql_query(mysql, buff); + myquery(rc); + + sprintf(buff, "drop user %s@'%%'", user_pw); + rc= mysql_query(mysql, buff); + myquery(rc); + + sprintf(buff, "drop user %s@'%%'", user_no_pw); + rc= mysql_query(mysql, buff); + myquery(rc); + + DBUG_VOID_RETURN; +} /* Bug#27592 (stack overrun when storing datetime value using prepared statements) @@ -16744,6 +16942,7 @@ static struct my_tests_st my_tests[]= { { "test_bug29687", test_bug29687 }, { "test_bug29692", test_bug29692 }, { "test_bug29306", test_bug29306 }, + { "test_change_user", test_change_user }, { 0, 0 } }; From 1494eabc85f8677de7eb8ed58b59c1097b169b14 Mon Sep 17 00:00:00 2001 From: "gluh@mysql.com/eagle.(none)" <> Date: Fri, 28 Sep 2007 17:33:30 +0500 Subject: [PATCH 050/203] Bug#30795 Query on INFORMATION_SCHEMA.SCHEMATA, wrong result skip the check of directory presence for 'information_schema' name --- mysql-test/r/information_schema.result | 4 ++++ mysql-test/t/information_schema.test | 6 ++++++ sql/sql_show.cc | 3 ++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 37810e67f2a..cd0f9a7a172 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1552,4 +1552,8 @@ VIEW_DEFINITION SELECT * FROM INFORMATION_SCHEMA.TABLES DROP VIEW v1; +SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA +WHERE SCHEMA_NAME ='information_schema'; +SCHEMA_NAME +information_schema End of 5.1 tests. diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 90671c4e8fd..c2c0f79d66b 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1188,4 +1188,10 @@ FROM INFORMATION_SCHEMA.TABLES; SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS where TABLE_NAME = 'v1'; DROP VIEW v1; +# +# Bug#30795 Query on INFORMATION_SCHEMA.SCHEMATA, wrong result +# +SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA +WHERE SCHEMA_NAME ='information_schema'; + --echo End of 5.1 tests. diff --git a/sql/sql_show.cc b/sql/sql_show.cc index f7813b73089..cc0cda42321 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -3339,7 +3339,8 @@ int fill_schema_schemata(THD *thd, TABLE_LIST *tables, COND *cond) /* If we have lookup db value we should check that the database exists */ - if(lookup_field_vals.db_value.str && !lookup_field_vals.wild_db_value) + if(lookup_field_vals.db_value.str && !lookup_field_vals.wild_db_value && + !with_i_schema) { char path[FN_REFLEN+16]; uint path_len; From aa2d545de2bc47b7a09d677b9240376ef7dc453b Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@macbook.gmz" <> Date: Fri, 28 Sep 2007 16:46:05 +0300 Subject: [PATCH 051/203] Bug #30587: mysql crashes when trying to group by TIME div NUMBER When calculating the result length of an integer DIV function the number of decimals was used without checking the result type first. Thus an uninitialized number of decimals was used for some types. This caused an excessive amount of memory to be allocated for the field's buffer and crashed the server. Fixed by using the number of decimals only for data types that can have decimals and thus have valid decimals number. --- mysql-test/r/func_math.result | 46 +++++++++++++++++++++++++++++++++++ mysql-test/t/func_math.test | 27 ++++++++++++++++++++ sql/item_func.cc | 6 ++++- 3 files changed, 78 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index ace94217fdc..5ef528812e5 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -322,4 +322,50 @@ mod(5, cast(-2 as unsigned)) mod(5, 18446744073709551614) mod(5, -2) select pow(cast(-2 as unsigned), 5), pow(18446744073709551614, 5), pow(-2, 5); pow(cast(-2 as unsigned), 5) pow(18446744073709551614, 5) pow(-2, 5) 2.1359870359209e+96 2.1359870359209e+96 -32 +CREATE TABLE t1 (a timestamp, b varchar(20), c bit(1)); +INSERT INTO t1 VALUES('1998-09-23', 'str1', 1), ('2003-03-25', 'str2', 0); +SELECT a DIV 900 y FROM t1 GROUP BY y; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def y y 8 19 11 Y 32800 0 63 +y +22201025555 +22255916666 +SELECT DISTINCT a DIV 900 y FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def y y 8 19 11 Y 32800 0 63 +y +22201025555 +22255916666 +SELECT b DIV 900 y FROM t1 GROUP BY y; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def y y 8 20 1 Y 32768 0 63 +y +0 +SELECT c DIV 900 y FROM t1 GROUP BY y; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def y y 3 1 1 Y 32800 0 63 +y +0 +DROP TABLE t1; +CREATE TABLE t1(a LONGBLOB); +INSERT INTO t1 VALUES('1'),('2'),('3'); +SELECT DISTINCT (a DIV 254576881) FROM t1; +(a DIV 254576881) +0 +SELECT (a DIV 254576881) FROM t1 UNION ALL +SELECT (a DIV 254576881) FROM t1; +(a DIV 254576881) +0 +0 +0 +0 +0 +0 +DROP TABLE t1; +CREATE TABLE t1(a SET('a','b','c')); +INSERT INTO t1 VALUES ('a'); +SELECT a DIV 2 FROM t1 UNION SELECT a DIV 2 FROM t1; +a DIV 2 +0 +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index 2ba07dfc581..1f46415741f 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -205,4 +205,31 @@ select mod(cast(-2 as unsigned), 3), mod(18446744073709551614, 3), mod(-2, 3); select mod(5, cast(-2 as unsigned)), mod(5, 18446744073709551614), mod(5, -2); select pow(cast(-2 as unsigned), 5), pow(18446744073709551614, 5), pow(-2, 5); +# +# Bug #30587: mysql crashes when trying to group by TIME div NUMBER +# + +CREATE TABLE t1 (a timestamp, b varchar(20), c bit(1)); +INSERT INTO t1 VALUES('1998-09-23', 'str1', 1), ('2003-03-25', 'str2', 0); +--enable_metadata +SELECT a DIV 900 y FROM t1 GROUP BY y; +SELECT DISTINCT a DIV 900 y FROM t1; +SELECT b DIV 900 y FROM t1 GROUP BY y; +SELECT c DIV 900 y FROM t1 GROUP BY y; +--disable_metadata +DROP TABLE t1; + +CREATE TABLE t1(a LONGBLOB); +INSERT INTO t1 VALUES('1'),('2'),('3'); +SELECT DISTINCT (a DIV 254576881) FROM t1; +SELECT (a DIV 254576881) FROM t1 UNION ALL + SELECT (a DIV 254576881) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1(a SET('a','b','c')); +INSERT INTO t1 VALUES ('a'); +SELECT a DIV 2 FROM t1 UNION SELECT a DIV 2 FROM t1; +DROP TABLE t1; + + --echo End of 5.0 tests diff --git a/sql/item_func.cc b/sql/item_func.cc index d03d497dfd0..a90cc721ca9 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1380,7 +1380,11 @@ longlong Item_func_int_div::val_int() void Item_func_int_div::fix_length_and_dec() { - max_length=args[0]->max_length - args[0]->decimals; + Item_result argtype= args[0]->result_type(); + /* use precision ony for the data type it is applicable for and valid */ + max_length=args[0]->max_length - + (argtype == DECIMAL_RESULT || argtype == INT_RESULT ? + args[0]->decimals : 0); maybe_null=1; unsigned_flag=args[0]->unsigned_flag | args[1]->unsigned_flag; } From 397da9d9b7cd686bb86bd36956e7da3863b21379 Mon Sep 17 00:00:00 2001 From: "mhansson/martin@linux-st28.site" <> Date: Fri, 28 Sep 2007 18:05:23 +0200 Subject: [PATCH 052/203] Bug #30832: Assertion + crash with select name_const('test', now()); The NAME_CONST function is required to work correctly with constants only. When executed with functions that return types other than those returned by Item::field_type (string, int, decimal, or real), the result gets cast to one of those types. This cannot happen for constants. Fixed by only allowing constants as arguments to NAME_CONST. --- mysql-test/r/func_misc.result | 16 ++++++++++++++++ mysql-test/t/func_misc.test | 14 ++++++++++++++ sql/item.h | 2 ++ 3 files changed, 32 insertions(+) diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index 35101e26ff6..bb6f4127a2a 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -185,4 +185,20 @@ ERROR 21000: Operand should contain 1 column(s) drop table table_26093; drop function func_26093_a; drop function func_26093_b; +SELECT NAME_CONST('test', NOW()); +ERROR HY000: Incorrect arguments to NAME_CONST +SELECT NAME_CONST('test', UPPER('test')); +ERROR HY000: Incorrect arguments to NAME_CONST +SELECT NAME_CONST('test', NULL); +test +NULL +SELECT NAME_CONST('test', 1); +test +1 +SELECT NAME_CONST('test', 1.0); +test +1.0 +SELECT NAME_CONST('test', 'test'); +test +test End of 5.0 tests diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index 8ff62f68e45..c93e411e691 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -189,4 +189,18 @@ drop table table_26093; drop function func_26093_a; drop function func_26093_b; +# +# Bug #30832: Assertion + crash with select name_const('test',now()); +# +--error ER_WRONG_ARGUMENTS +SELECT NAME_CONST('test', NOW()); +--error ER_WRONG_ARGUMENTS +SELECT NAME_CONST('test', UPPER('test')); + +SELECT NAME_CONST('test', NULL); +SELECT NAME_CONST('test', 1); +SELECT NAME_CONST('test', 1.0); +SELECT NAME_CONST('test', 'test'); + --echo End of 5.0 tests + diff --git a/sql/item.h b/sql/item.h index 3c699c0eda3..cd0be343a62 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1112,6 +1112,8 @@ public: Item_name_const(Item *name_arg, Item *val): value_item(val), name_item(name_arg) { + if(!value_item->basic_const_item()) + my_error(ER_WRONG_ARGUMENTS, MYF(0), "NAME_CONST"); Item::maybe_null= TRUE; } From 8051b7568db48a845e1af8fa924c809ef4ca9641 Mon Sep 17 00:00:00 2001 From: "anozdrin/alik@station." <> Date: Fri, 28 Sep 2007 23:30:54 +0400 Subject: [PATCH 053/203] Patch for BUG#30472: libmysql doesn't reset charset, insert_id after succ. mysql_change_user() call. See also WL 4066. This bug reveals two problems: - the problem on the client side which was described originally; - the problem in protocol / the server side: connection context on client and server should be like after mysql_real_connect() and be consistent. The server however just resets character set variables to the global defaults. The fix seems to be as follows: - extend the protocol so that the client be able to send character set information in COM_CHANGE_USER command; - change the server so that it understands client character set in the command; - change the client: - reset character set to the default value (which has been read from the configuration); - send character set in COM_CHANGE_USER command. --- client/client_priv.h | 4 + libmysql/libmysql.c | 26 +++- mysql-test/t/mysql_client_test.test | 4 +- sql/sql_parse.cc | 14 ++- tests/mysql_client_test.c | 176 +++++++++++++++++++++++++++- 5 files changed, 218 insertions(+), 6 deletions(-) diff --git a/client/client_priv.h b/client/client_priv.h index a2f61b9e9ca..4bc275e6630 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -82,3 +82,7 @@ enum options_client OPT_DEBUG_INFO, OPT_DEBUG_CHECK, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE, OPT_WRITE_BINLOG, OPT_MAX_CLIENT_OPTION }; + +C_MODE_START +extern int mysql_init_character_set(MYSQL *mysql); +C_MODE_END diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index c8e2d48873f..e2e481fdd21 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -685,14 +685,25 @@ int cli_read_change_user_result(MYSQL *mysql, char *buff, const char *passwd) return 0; } - my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, const char *passwd, const char *db) { char buff[512],*end=buff; int rc; + CHARSET_INFO *saved_cs= mysql->charset; + DBUG_ENTER("mysql_change_user"); + /* Get the connection-default character set. */ + + if (mysql_init_character_set(mysql)) + { + mysql->charset= saved_cs; + DBUG_RETURN(TRUE); + } + + /* Use an empty string instead of NULL. */ + if (!user) user=""; if (!passwd) @@ -721,6 +732,14 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, /* Add database if needed */ end= strmov(end, db ? db : "") + 1; + /* Add character set number. */ + + if (mysql->server_capabilities & CLIENT_SECURE_CONNECTION) + { + *end= (uchar) mysql->charset->number; + ++end; + } + /* Write authentication package */ simple_command(mysql,COM_CHANGE_USER, (uchar*) buff, (ulong) (end-buff), 1); @@ -743,6 +762,11 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, mysql->passwd=my_strdup(passwd,MYF(MY_WME)); mysql->db= db ? my_strdup(db,MYF(MY_WME)) : 0; } + else + { + mysql->charset= saved_cs; + } + DBUG_RETURN(rc); } diff --git a/mysql-test/t/mysql_client_test.test b/mysql-test/t/mysql_client_test.test index 66a27abd61a..7667522feaf 100644 --- a/mysql-test/t/mysql_client_test.test +++ b/mysql-test/t/mysql_client_test.test @@ -8,8 +8,8 @@ # server or run mysql-test-run --debug mysql_client_test and check # var/log/mysql_client_test.trace ---exec echo "$MYSQL_CLIENT_TEST" > $MYSQLTEST_VARDIR/log/mysql_client_test.log 2>&1 ---exec $MYSQL_CLIENT_TEST --getopt-ll-test=25600M >> $MYSQLTEST_VARDIR/log/mysql_client_test.log 2>&1 +--exec echo "$MYSQL_CLIENT_TEST" > $MYSQLTEST_VARDIR/log/mysql_client_test.out.log 2>&1 +--exec $MYSQL_CLIENT_TEST --getopt-ll-test=25600M >> $MYSQLTEST_VARDIR/log/mysql_client_test.out.log 2>&1 # End of 4.1 tests echo ok; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 3dbcfe6d2bc..923fd1b2bfe 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -876,7 +876,13 @@ bool dispatch_command(enum enum_server_command command, THD *thd, my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0)); break; } - db_length= packet_end - db - 1; /* do not count the trailing '\0' */ + db_length= strlen(db); + + uint cs_number= 0; + + if (db + db_length < packet_end) + cs_number= (uchar) *(db + db_length + 1); + /* Convert database name to utf8 */ db_buff[copy_and_convert(db_buff, sizeof(db_buff)-1, system_charset_info, db, db_length, @@ -921,6 +927,12 @@ bool dispatch_command(enum enum_server_command command, THD *thd, #endif /* NO_EMBEDDED_ACCESS_CHECKS */ x_free((uchar*) save_db); x_free((uchar*) save_security_ctx.user); + + if (cs_number) + { + thd_init_client_charset(thd, cs_number); + thd->update_charset(); + } } break; } diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 93a85f44919..eff8df8109a 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -119,6 +119,8 @@ static void client_disconnect(void); #define DIE_UNLESS(expr) \ ((void) ((expr) ? 0 : (die(__FILE__, __LINE__, #expr), 0))) +#define DIE_IF(expr) \ + ((void) ((expr) ? (die(__FILE__, __LINE__, #expr), 0) : 0)) #define DIE(expr) \ die(__FILE__, __LINE__, #expr) @@ -177,8 +179,8 @@ if (stmt == 0) \ DIE_UNLESS(stmt == 0);\ } -#define mytest(x) if (!x) {myerror(NULL);DIE_UNLESS(FALSE);} -#define mytest_r(x) if (x) {myerror(NULL);DIE_UNLESS(FALSE);} +#define mytest(x) if (!(x)) {myerror(NULL);DIE_UNLESS(FALSE);} +#define mytest_r(x) if ((x)) {myerror(NULL);DIE_UNLESS(FALSE);} /* A workaround for Sun Forte 5.6 on Solaris x86 */ @@ -16649,6 +16651,175 @@ static void test_bug29306() DBUG_VOID_RETURN; } +/* + Bug#30472: libmysql doesn't reset charset, insert_id after succ. + mysql_change_user() call row insertions. +*/ + +static void bug30472_retrieve_charset_info(MYSQL *con, + char *character_set_name, + char *character_set_client, + char *character_set_results, + char *collation_connection) +{ + MYSQL_RES *rs; + MYSQL_ROW row; + + /* Get the cached client character set name. */ + + strcpy(character_set_name, mysql_character_set_name(con)); + + /* Retrieve server character set information. */ + + DIE_IF(mysql_query(con, "SHOW VARIABLES LIKE 'character_set_client'")); + DIE_UNLESS(rs= mysql_store_result(con)); + DIE_UNLESS(row= mysql_fetch_row(rs)); + strcpy(character_set_client, row[1]); + mysql_free_result(rs); + + DIE_IF(mysql_query(con, "SHOW VARIABLES LIKE 'character_set_results'")); + DIE_UNLESS(rs= mysql_store_result(con)); + DIE_UNLESS(row= mysql_fetch_row(rs)); + strcpy(character_set_results, row[1]); + mysql_free_result(rs); + + DIE_IF(mysql_query(con, "SHOW VARIABLES LIKE 'collation_connection'")); + DIE_UNLESS(rs= mysql_store_result(con)); + DIE_UNLESS(row= mysql_fetch_row(rs)); + strcpy(collation_connection, row[1]); + mysql_free_result(rs); +} + +static void test_bug30472() +{ + MYSQL con; + + char character_set_name_1[MY_CS_NAME_SIZE]; + char character_set_client_1[MY_CS_NAME_SIZE]; + char character_set_results_1[MY_CS_NAME_SIZE]; + char collation_connnection_1[MY_CS_NAME_SIZE]; + + char character_set_name_2[MY_CS_NAME_SIZE]; + char character_set_client_2[MY_CS_NAME_SIZE]; + char character_set_results_2[MY_CS_NAME_SIZE]; + char collation_connnection_2[MY_CS_NAME_SIZE]; + + char character_set_name_3[MY_CS_NAME_SIZE]; + char character_set_client_3[MY_CS_NAME_SIZE]; + char character_set_results_3[MY_CS_NAME_SIZE]; + char collation_connnection_3[MY_CS_NAME_SIZE]; + + char character_set_name_4[MY_CS_NAME_SIZE]; + char character_set_client_4[MY_CS_NAME_SIZE]; + char character_set_results_4[MY_CS_NAME_SIZE]; + char collation_connnection_4[MY_CS_NAME_SIZE]; + + /* Create a new connection. */ + + DIE_UNLESS(mysql_init(&con)); + + DIE_UNLESS(mysql_real_connect(&con, + opt_host, + opt_user, + opt_password, + opt_db ? opt_db : "test", + opt_port, + opt_unix_socket, + CLIENT_FOUND_ROWS)); + + /* Retrieve character set information. */ + + bug30472_retrieve_charset_info(&con, + character_set_name_1, + character_set_client_1, + character_set_results_1, + collation_connnection_1); + + /* Switch client character set. */ + + DIE_IF(mysql_set_character_set(&con, "utf8")); + + /* Retrieve character set information. */ + + bug30472_retrieve_charset_info(&con, + character_set_name_2, + character_set_client_2, + character_set_results_2, + collation_connnection_2); + + /* + Check that + 1) character set has been switched and + 2) new character set is different from the original one. + */ + + DIE_UNLESS(strcmp(character_set_name_2, "utf8") == 0); + DIE_UNLESS(strcmp(character_set_client_2, "utf8") == 0); + DIE_UNLESS(strcmp(character_set_results_2, "utf8") == 0); + DIE_UNLESS(strcmp(collation_connnection_2, "utf8_general_ci") == 0); + + DIE_UNLESS(strcmp(character_set_name_1, character_set_name_2) != 0); + DIE_UNLESS(strcmp(character_set_client_1, character_set_client_2) != 0); + DIE_UNLESS(strcmp(character_set_results_1, character_set_results_2) != 0); + DIE_UNLESS(strcmp(collation_connnection_1, collation_connnection_2) != 0); + + /* Call mysql_change_user() with the same username, password, database. */ + + DIE_IF(mysql_change_user(&con, + opt_user, + opt_password, + opt_db ? opt_db : "test")); + + /* Retrieve character set information. */ + + bug30472_retrieve_charset_info(&con, + character_set_name_3, + character_set_client_3, + character_set_results_3, + collation_connnection_3); + + /* Check that character set information has been reset. */ + + DIE_UNLESS(strcmp(character_set_name_1, character_set_name_3) == 0); + DIE_UNLESS(strcmp(character_set_client_1, character_set_client_3) == 0); + DIE_UNLESS(strcmp(character_set_results_1, character_set_results_3) == 0); + DIE_UNLESS(strcmp(collation_connnection_1, collation_connnection_3) == 0); + + /* Change connection-default character set in the client. */ + + con.options.charset_name= my_strdup("utf8", MYF(MY_FAE)); + + /* + Call mysql_change_user() in order to check that new connection will + have UTF8 character set on the client and on the server. + */ + + DIE_IF(mysql_change_user(&con, + opt_user, + opt_password, + opt_db ? opt_db : "test")); + + /* Retrieve character set information. */ + + bug30472_retrieve_charset_info(&con, + character_set_name_4, + character_set_client_4, + character_set_results_4, + collation_connnection_4); + + /* Check that we have UTF8 on the server and on the client. */ + + DIE_UNLESS(strcmp(character_set_name_4, "utf8") == 0); + DIE_UNLESS(strcmp(character_set_client_4, "utf8") == 0); + DIE_UNLESS(strcmp(character_set_results_4, "utf8") == 0); + DIE_UNLESS(strcmp(collation_connnection_4, "utf8_general_ci") == 0); + + /* That's it. Cleanup. */ + + mysql_close(&con); +} + + /* Read and parse arguments and MySQL options from my.cnf */ @@ -16943,6 +17114,7 @@ static struct my_tests_st my_tests[]= { { "test_bug29692", test_bug29692 }, { "test_bug29306", test_bug29306 }, { "test_change_user", test_change_user }, + { "test_bug30472", test_bug30472 }, { 0, 0 } }; From 040e520d55598170fa80d53936812f14a5d9f4fd Mon Sep 17 00:00:00 2001 From: "dkatz@damien-katzs-computer.local" <> Date: Fri, 28 Sep 2007 17:10:14 -0400 Subject: [PATCH 054/203] Bug #29772 Error compiling with option --without-geometry Added #ifdef HAVE_SPATIAL around geometry related code. --- sql/item.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sql/item.cc b/sql/item.cc index 66379d5dcf9..b44927f8da6 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4357,12 +4357,14 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table) return new Field_blob(max_length, maybe_null, name, table, collation.collation); break; // Blob handled outside of case +#ifdef HAVE_SPATIAL case MYSQL_TYPE_GEOMETRY: return new Field_geom(max_length, maybe_null, name, table, (Field::geometry_type) ((type() == Item::TYPE_HOLDER) ? ((Item_type_holder *)this)->get_geometry_type() : ((Item_geometry_func *)this)->get_geometry_type())); +#endif /* HAVE_SPATIAL */ } } @@ -6482,10 +6484,12 @@ Item_type_holder::Item_type_holder(THD *thd, Item *item) if (Field::result_merge_type(fld_type) == INT_RESULT) decimals= 0; prev_decimal_int_part= item->decimal_int_part(); +#ifdef HAVE_SPATIAL if (item->field_type() == MYSQL_TYPE_GEOMETRY) geometry_type= (item->type() == Item::FIELD_ITEM) ? ((Item_field *)item)->get_geometry_type() : (Field::geometry_type)((Item_geometry_func *)item)->get_geometry_type(); +#endif /* HAVE_SPATIAL */ } From 93fd4e200ce1541d20afa711693a626549577274 Mon Sep 17 00:00:00 2001 From: "dkatz@damien-katzs-computer.local" <> Date: Fri, 28 Sep 2007 17:13:35 -0400 Subject: [PATCH 055/203] Bug #29589 sys_innodb_max_purge_lag is defined twice in sys_variables Removed duplicate innodb variable from sys_variables array. --- sql/set_var.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/sql/set_var.cc b/sql/set_var.cc index e1246617d84..305370e6569 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -784,7 +784,6 @@ sys_var *sys_variables[]= &sys_innodb_max_purge_lag, &sys_innodb_table_locks, &sys_innodb_support_xa, - &sys_innodb_max_purge_lag, &sys_innodb_autoextend_increment, &sys_innodb_sync_spin_loops, &sys_innodb_concurrency_tickets, From ae079ec427c2a5d50940b7c20f45e0c92f01e450 Mon Sep 17 00:00:00 2001 From: "davi@moksha.local" <> Date: Fri, 28 Sep 2007 18:25:47 -0300 Subject: [PATCH 056/203] Bug#21136 CREATE TABLE SELECT within CREATE TABLE SELECT causes server crash When CREATE TEMPORARY TABLE .. SELECT is invoked from a stored function which in turn is called from CREATE TABLE SELECT causes a memory leak because the inner create temporary table overrides the outter extra_lock reference when locking the table. The solution is to simply not overrride the extra_lock by only using the extra_lock for a non-temporary table lock. --- mysql-test/r/create.result | 14 ++++++++++++++ mysql-test/t/create.test | 25 +++++++++++++++++++++++++ sql/sql_insert.cc | 27 ++++++++++++++++++++------- 3 files changed, 59 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 82bcc68f319..800a3f9cece 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -1691,4 +1691,18 @@ ERROR 42000: Identifier name 'очень_очень_очень_очень_оче drop view имÑ_вью_кодировке_утф8_длиной_больше_чем_42; drop table имÑ_таблицы_в_кодировке_утф8_длиной_больше_чем_48; set names default; +drop table if exists t1,t2,t3; +drop function if exists f1; +create function f1() returns int +begin +declare res int; +create temporary table t3 select 1 i; +set res:= (select count(*) from t1); +drop temporary table t3; +return res; +end| +create table t1 as select 1; +create table t2 as select f1() from t1; +drop table t1,t2; +drop function f1; End of 5.1 tests diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index d4feeebe4b1..023e55ea418 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -1303,4 +1303,29 @@ return 0; drop view имÑ_вью_кодировке_утф8_длиной_больше_чем_42; drop table имÑ_таблицы_в_кодировке_утф8_длиной_больше_чем_48; set names default; + +# +# Bug#21136 CREATE TABLE SELECT within CREATE TABLE SELECT causes server crash +# + +--disable_warnings +drop table if exists t1,t2,t3; +drop function if exists f1; +--enable_warnings + +--delimiter | +create function f1() returns int +begin + declare res int; + create temporary table t3 select 1 i; + set res:= (select count(*) from t1); + drop temporary table t3; + return res; +end| +--delimiter ; +create table t1 as select 1; +create table t2 as select f1() from t1; +drop table t1,t2; +drop function f1; + --echo End of 5.1 tests diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 7679401b459..fedda29c249 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3427,6 +3427,7 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, int select_create::prepare(List &values, SELECT_LEX_UNIT *u) { + MYSQL_LOCK *extra_lock= NULL; DBUG_ENTER("select_create::prepare"); TABLEOP_HOOKS *hook_ptr= NULL; @@ -3496,9 +3497,21 @@ select_create::prepare(List &values, SELECT_LEX_UNIT *u) if (!(table= create_table_from_items(thd, create_info, create_table, alter_info, &values, - &thd->extra_lock, hook_ptr))) + &extra_lock, hook_ptr))) DBUG_RETURN(-1); // abort() deletes table + if (extra_lock) + { + DBUG_ASSERT(m_plock == NULL); + + if (create_info->options & HA_LEX_CREATE_TMP_TABLE) + m_plock= &m_lock; + else + m_plock= &thd->extra_lock; + + *m_plock= extra_lock; + } + if (table->s->fields < values.elements) { my_error(ER_WRONG_VALUE_COUNT_ON_ROW, MYF(0), 1); @@ -3637,10 +3650,10 @@ bool select_create::send_eof() table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE); - if (thd->extra_lock) + if (m_plock) { - mysql_unlock_tables(thd, thd->extra_lock); - thd->extra_lock=0; + mysql_unlock_tables(thd, *m_plock); + m_plock= 0; } } return tmp; @@ -3675,10 +3688,10 @@ void select_create::abort() if (thd->current_stmt_binlog_row_based) ha_rollback_stmt(thd); - if (thd->extra_lock) + if (m_plock) { - mysql_unlock_tables(thd, thd->extra_lock); - thd->extra_lock=0; + mysql_unlock_tables(thd, *m_plock); + m_plock= 0; } if (table) From 9c6d75e85d8249c3d853aab3a1b6a4e2cbbd1f98 Mon Sep 17 00:00:00 2001 From: "davi@moksha.local" <> Date: Fri, 28 Sep 2007 19:11:26 -0300 Subject: [PATCH 057/203] Post-merge fix for Bug 21136, initial merge missed the modifications for the sql_class.h file. --- sql/sql_class.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sql/sql_class.h b/sql/sql_class.h index 7875870bd1a..97a63ed9448 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2133,6 +2133,10 @@ class select_create: public select_insert { TABLE_LIST *select_tables; Alter_info *alter_info; Field **field; + /* lock data for tmp table */ + MYSQL_LOCK *m_lock; + /* m_lock or thd->extra_lock */ + MYSQL_LOCK **m_plock; public: select_create (TABLE_LIST *table_arg, HA_CREATE_INFO *create_info_par, @@ -2143,7 +2147,8 @@ public: create_table(table_arg), create_info(create_info_par), select_tables(select_tables_arg), - alter_info(alter_info_arg) + alter_info(alter_info_arg), + m_plock(NULL) {} int prepare(List &list, SELECT_LEX_UNIT *u); From b9e81c2ae3f838194f181b8fb1b389dd42334211 Mon Sep 17 00:00:00 2001 From: "evgen@moonbone.local" <> Date: Fri, 28 Sep 2007 23:24:40 +0000 Subject: [PATCH 058/203] Bug#27990: Wrong info in MYSQL_FIELD struct members when a tmp table was used. The change_to_use_tmp_fields function leaves the orig_table member of an expression's tmp table field filled for the new Item_field being created. Later orig_table is used by the Field::make_field function to provide some info about original table and field name to a user. This is ok for a field but for an expression it should be empty. The change_to_use_tmp_fields function now resets orig_table member of an expression's tmp table field to prevent providing a wrong info to a user. The Field::make_field function now resets the table_name and the org_col_name variables when the orig_table is set to 0. --- mysql-test/r/bdb_notembedded.result | 35 +++++++++++++++++++++ mysql-test/t/bdb_notembedded.test | 38 ++++++++++++++++++++++ sql/field.cc | 16 ++++++++-- sql/sql_select.cc | 3 ++ tests/mysql_client_test.c | 49 ++++++++++++++++------------- 5 files changed, 117 insertions(+), 24 deletions(-) create mode 100644 mysql-test/r/bdb_notembedded.result create mode 100644 mysql-test/t/bdb_notembedded.test diff --git a/mysql-test/r/bdb_notembedded.result b/mysql-test/r/bdb_notembedded.result new file mode 100644 index 00000000000..14cb5fad915 --- /dev/null +++ b/mysql-test/r/bdb_notembedded.result @@ -0,0 +1,35 @@ +set autocommit=1; +reset master; +create table bug16206 (a int); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 +f n Query 1 n use `test`; create table bug16206 (a int) +f n Query 1 n use `test`; insert into bug16206 values(1) +f n Query 1 n use `test`; insert into bug16206 values(2) +drop table bug16206; +reset master; +create table bug16206 (a int) engine= bdb; +insert into bug16206 values(0); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +insert into bug16206 values(3); +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 +f n Query 1 n use `test`; create table bug16206 (a int) engine= bdb +f n Query 1 n use `test`; insert into bug16206 values(0) +f n Query 1 n use `test`; insert into bug16206 values(1) +f n Query 1 n use `test`; BEGIN +f n Query 1 n use `test`; insert into bug16206 values(2) +f n Query 1 n use `test`; COMMIT +f n Query 1 n use `test`; insert into bug16206 values(3) +drop table bug16206; +set autocommit=0; +End of 5.0 tests diff --git a/mysql-test/t/bdb_notembedded.test b/mysql-test/t/bdb_notembedded.test new file mode 100644 index 00000000000..24e64ebbfb2 --- /dev/null +++ b/mysql-test/t/bdb_notembedded.test @@ -0,0 +1,38 @@ +-- source include/not_embedded.inc +-- source include/have_bdb.inc + +# +# Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit mode +# +set autocommit=1; + +let $VERSION=`select version()`; + +reset master; +create table bug16206 (a int); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +--replace_result $VERSION VERSION +--replace_column 1 f 2 n 5 n +show binlog events; +drop table bug16206; + +reset master; +create table bug16206 (a int) engine= bdb; +insert into bug16206 values(0); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +insert into bug16206 values(3); +--replace_result $VERSION VERSION +--replace_column 1 f 2 n 5 n +show binlog events; +drop table bug16206; + +set autocommit=0; + + +--echo End of 5.0 tests diff --git a/sql/field.cc b/sql/field.cc index 152c1bdc364..763448202ae 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1282,15 +1282,25 @@ void Field_num::add_zerofill_and_unsigned(String &res) const void Field::make_field(Send_field *field) { - if (orig_table->s->table_cache_key && *(orig_table->s->table_cache_key)) + if (orig_table && orig_table->s->table_cache_key && + *(orig_table->s->table_cache_key)) { field->org_table_name= orig_table->s->table_name; field->db_name= orig_table->s->table_cache_key; } else field->org_table_name= field->db_name= ""; - field->table_name= orig_table->alias; - field->col_name= field->org_col_name= field_name; + if (orig_table) + { + field->table_name= orig_table->alias; + field->org_col_name= field_name; + } + else + { + field->table_name= ""; + field->org_col_name= ""; + } + field->col_name= field_name; field->charsetnr= charset()->number; field->length=field_length; field->type=type(); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 08780efbedb..cc6184c6206 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -14119,6 +14119,9 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array, item_field= (Item*) new Item_field(field); if (!item_field) DBUG_RETURN(TRUE); // Fatal error + + if (item->real_item()->type() != Item::FIELD_ITEM) + field->orig_table= 0; item_field->name= item->name; #ifndef DBUG_OFF if (_db_on_ && !item_field->name) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index d64ec08a71d..3e50e1ede84 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -15486,7 +15486,7 @@ static void test_bug21635() char *query_end; MYSQL_RES *result; MYSQL_FIELD *field; - unsigned int field_count, i; + unsigned int field_count, i, j; int rc; DBUG_ENTER("test_bug21635"); @@ -15502,28 +15502,35 @@ static void test_bug21635() myquery(rc); rc= mysql_query(mysql, "CREATE TABLE t1 (i INT)"); myquery(rc); - rc= mysql_query(mysql, "INSERT INTO t1 VALUES (1)"); - myquery(rc); - - rc= mysql_real_query(mysql, query, query_end - query); - myquery(rc); - - result= mysql_use_result(mysql); - DIE_UNLESS(result); - - field_count= mysql_field_count(mysql); - for (i= 0; i < field_count; ++i) + /* + We need this loop to ensure correct behavior with both constant and + non-constant tables. + */ + for (j= 0; j < 2 ; j++) { - field= mysql_fetch_field_direct(result, i); - printf("%s -> %s ... ", expr[i * 2], field->name); - fflush(stdout); - DIE_UNLESS(field->db[0] == 0 && field->org_table[0] == 0 && - field->table[0] == 0 && field->org_name[0] == 0); - DIE_UNLESS(strcmp(field->name, expr[i * 2 + 1]) == 0); - puts("OK"); - } + rc= mysql_query(mysql, "INSERT INTO t1 VALUES (1)"); + myquery(rc); - mysql_free_result(result); + rc= mysql_real_query(mysql, query, query_end - query); + myquery(rc); + + result= mysql_use_result(mysql); + DIE_UNLESS(result); + + field_count= mysql_field_count(mysql); + for (i= 0; i < field_count; ++i) + { + field= mysql_fetch_field_direct(result, i); + printf("%s -> %s ... ", expr[i * 2], field->name); + fflush(stdout); + DIE_UNLESS(field->db[0] == 0 && field->org_table[0] == 0 && + field->table[0] == 0 && field->org_name[0] == 0); + DIE_UNLESS(strcmp(field->name, expr[i * 2 + 1]) == 0); + puts("OK"); + } + + mysql_free_result(result); + } rc= mysql_query(mysql, "DROP TABLE t1"); myquery(rc); From 59b311baee1c4eb72ae78c273da05236d4106e2d Mon Sep 17 00:00:00 2001 From: "evgen@moonbone.local" <> Date: Sat, 29 Sep 2007 01:07:29 +0000 Subject: [PATCH 059/203] view_grant.result, view_grant.test: Corrected test case for the bug#29908. --- mysql-test/r/view_grant.result | 19 ++++++++++--------- mysql-test/t/view_grant.test | 5 +++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result index ab408e6f175..eef61c65fb8 100644 --- a/mysql-test/r/view_grant.result +++ b/mysql-test/r/view_grant.result @@ -806,25 +806,26 @@ GRANT SELECT ON mysqltest_29908.t1 TO u29908_2@localhost; ALTER VIEW v1 AS SELECT f2 FROM t1; ERROR 42000: Access denied; you need the SUPER privilege for this operation ALTER VIEW v2 AS SELECT f2 FROM t1; +ERROR 42000: Access denied; you need the SUPER privilege for this operation SHOW CREATE VIEW v2; View Create View -v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f2` AS `f2` from `t1` +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f1` AS `f1` from `t1` ALTER VIEW v1 AS SELECT f2 FROM t1; SHOW CREATE VIEW v1; View Create View v1 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f2` AS `f2` from `t1` -ALTER VIEW v2 AS SELECT f1 FROM t1; -SHOW CREATE VIEW v2; -View Create View -v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f1` AS `f1` from `t1` -ALTER VIEW v1 AS SELECT f1 FROM t1; -SHOW CREATE VIEW v1; -View Create View -v1 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f1` AS `f1` from `t1` ALTER VIEW v2 AS SELECT f2 FROM t1; SHOW CREATE VIEW v2; View Create View v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f2` AS `f2` from `t1` +ALTER VIEW v1 AS SELECT f1 FROM t1; +SHOW CREATE VIEW v1; +View Create View +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f1` AS `f1` from `t1` +ALTER VIEW v2 AS SELECT f1 FROM t1; +SHOW CREATE VIEW v2; +View Create View +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f1` AS `f1` from `t1` DROP USER u29908_1@localhost; DROP USER u29908_2@localhost; DROP DATABASE mysqltest_29908; diff --git a/mysql-test/t/view_grant.test b/mysql-test/t/view_grant.test index 0cad3857dcd..7f9eb4e1cff 100644 --- a/mysql-test/t/view_grant.test +++ b/mysql-test/t/view_grant.test @@ -1070,19 +1070,20 @@ GRANT SELECT ON mysqltest_29908.t1 TO u29908_2@localhost; connect (u2,localhost,u29908_2,,mysqltest_29908); --error ER_SPECIFIC_ACCESS_DENIED_ERROR ALTER VIEW v1 AS SELECT f2 FROM t1; +--error ER_SPECIFIC_ACCESS_DENIED_ERROR ALTER VIEW v2 AS SELECT f2 FROM t1; SHOW CREATE VIEW v2; connect (u1,localhost,u29908_1,,mysqltest_29908); ALTER VIEW v1 AS SELECT f2 FROM t1; SHOW CREATE VIEW v1; -ALTER VIEW v2 AS SELECT f1 FROM t1; +ALTER VIEW v2 AS SELECT f2 FROM t1; SHOW CREATE VIEW v2; connection root; ALTER VIEW v1 AS SELECT f1 FROM t1; SHOW CREATE VIEW v1; -ALTER VIEW v2 AS SELECT f2 FROM t1; +ALTER VIEW v2 AS SELECT f1 FROM t1; SHOW CREATE VIEW v2; DROP USER u29908_1@localhost; From f3b6d56fb2eb8ff2b0c98336339ceeffdfc6c26e Mon Sep 17 00:00:00 2001 From: "davi@moksha.local" <> Date: Sat, 29 Sep 2007 16:04:31 -0300 Subject: [PATCH 060/203] The fix for BUG 21136 (ChangeSet@1.2611.1.1) introduced a regression that caused a few tests to fail because the thd->extra_lock wasn't being set to NULL after the table was unlocked. This poses a serious problem because later attempts to access thd->extra_lock (now a dangling pointer) will probably result in a crash (undefined behavior) -- and that's what actually happens in some test cases. The solution is to set the select_create::m_plock pointee to NULL, which means that thd->extra_lock is set to NULL when the lock data is not for a temporary table. --- sql/sql_insert.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index fedda29c249..b4f2d8c65f2 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3653,7 +3653,8 @@ bool select_create::send_eof() if (m_plock) { mysql_unlock_tables(thd, *m_plock); - m_plock= 0; + *m_plock= NULL; + m_plock= NULL; } } return tmp; @@ -3691,7 +3692,8 @@ void select_create::abort() if (m_plock) { mysql_unlock_tables(thd, *m_plock); - m_plock= 0; + *m_plock= NULL; + m_plock= NULL; } if (table) From 95e01d44536bf6bbee869b063c8c0cabbfff54b9 Mon Sep 17 00:00:00 2001 From: "anozdrin/alik@station." <> Date: Sat, 29 Sep 2007 23:31:08 +0400 Subject: [PATCH 061/203] Fix compile warnings. --- client/client_priv.h | 4 ---- client/mysqltest.c | 10 ++++++---- libmysql/client_settings.h | 4 ++++ libmysql/libmysql.c | 6 +++--- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/client/client_priv.h b/client/client_priv.h index 4bc275e6630..a2f61b9e9ca 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -82,7 +82,3 @@ enum options_client OPT_DEBUG_INFO, OPT_DEBUG_CHECK, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE, OPT_WRITE_BINLOG, OPT_MAX_CLIENT_OPTION }; - -C_MODE_START -extern int mysql_init_character_set(MYSQL *mysql); -C_MODE_END diff --git a/client/mysqltest.c b/client/mysqltest.c index 979c8de3656..0e45b2ac1d8 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1507,7 +1507,7 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname) die("Failed to create temporary file for ds"); /* Write ds to temporary file and set file pos to beginning*/ - if (my_write(fd, ds->str, ds->length, + if (my_write(fd, (uchar *) ds->str, ds->length, MYF(MY_FNABP | MY_WME)) || my_seek(fd, 0, SEEK_SET, MYF(0)) == MY_FILEPOS_ERROR) { @@ -1984,9 +1984,11 @@ void var_set_query_get_value(struct st_command *command, VAR *var) static DYNAMIC_STRING ds_col; static DYNAMIC_STRING ds_row; const struct command_arg query_get_value_args[] = { - "query", ARG_STRING, TRUE, &ds_query, "Query to run", - "column name", ARG_STRING, TRUE, &ds_col, "Name of column", - "row number", ARG_STRING, TRUE, &ds_row, "Number for row", + { + "query", ARG_STRING, TRUE, &ds_query, "Query to run", + "column name", ARG_STRING, TRUE, &ds_col, "Name of column", + "row number", ARG_STRING, TRUE, &ds_row, "Number for row" + } }; DBUG_ENTER("var_set_query_get_value"); diff --git a/libmysql/client_settings.h b/libmysql/client_settings.h index a803ff8372f..f87e625771f 100644 --- a/libmysql/client_settings.h +++ b/libmysql/client_settings.h @@ -63,3 +63,7 @@ int cli_read_change_user_result(MYSQL *mysql, char *buff, const char *passwd); int init_embedded_server(int argc, char **argv, char **groups); void end_embedded_server(); #endif /*EMBEDDED_LIBRARY*/ + +C_MODE_START +extern int mysql_init_character_set(MYSQL *mysql); +C_MODE_END diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index e2e481fdd21..adac6c7cd48 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2526,7 +2526,7 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length) 5 /* execution flags */]; my_bool res; DBUG_ENTER("execute"); - DBUG_DUMP("packet", packet, length); + DBUG_DUMP("packet", (uchar *) packet, length); mysql->last_used_con= mysql; int4store(buff, stmt->stmt_id); /* Send stmt id to server */ @@ -4702,14 +4702,14 @@ int cli_read_binary_rows(MYSQL_STMT *stmt) MYSQL_ROWS *cur, **prev_ptr= &result->data; NET *net; + DBUG_ENTER("cli_read_binary_rows"); + if (!mysql) { set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate); return 1; } - DBUG_ENTER("cli_read_binary_rows"); - net = &mysql->net; mysql= mysql->last_used_con; From 0635a75f4a1deabd18d30e3b4873da62b4082c9b Mon Sep 17 00:00:00 2001 From: "anozdrin/alik@station." <> Date: Mon, 1 Oct 2007 00:16:50 +0400 Subject: [PATCH 062/203] Fix compilation warnings. --- client/mysqltest.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 0e45b2ac1d8..702eab0078f 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1984,11 +1984,9 @@ void var_set_query_get_value(struct st_command *command, VAR *var) static DYNAMIC_STRING ds_col; static DYNAMIC_STRING ds_row; const struct command_arg query_get_value_args[] = { - { - "query", ARG_STRING, TRUE, &ds_query, "Query to run", - "column name", ARG_STRING, TRUE, &ds_col, "Name of column", - "row number", ARG_STRING, TRUE, &ds_row, "Number for row" - } + "query", ARG_STRING, TRUE, &ds_query, "Query to run", + "column name", ARG_STRING, TRUE, &ds_col, "Name of column", + "row number", ARG_STRING, TRUE, &ds_row, "Number for row" }; DBUG_ENTER("var_set_query_get_value"); From 72a0ad79822ce2bfc76cf3c437087c0880c1c734 Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Mon, 1 Oct 2007 11:32:29 +0300 Subject: [PATCH 063/203] fixed pb problem with the fix for bug 30587 --- mysql-test/r/func_math.result | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index 5ef528812e5..d294de93cd8 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -326,24 +326,24 @@ CREATE TABLE t1 (a timestamp, b varchar(20), c bit(1)); INSERT INTO t1 VALUES('1998-09-23', 'str1', 1), ('2003-03-25', 'str2', 0); SELECT a DIV 900 y FROM t1 GROUP BY y; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def y y 8 19 11 Y 32800 0 63 +def y 8 19 11 Y 32800 0 63 y 22201025555 22255916666 SELECT DISTINCT a DIV 900 y FROM t1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def y y 8 19 11 Y 32800 0 63 +def y 8 19 11 Y 32800 0 63 y 22201025555 22255916666 SELECT b DIV 900 y FROM t1 GROUP BY y; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def y y 8 20 1 Y 32768 0 63 +def y 8 20 1 Y 32768 0 63 y 0 SELECT c DIV 900 y FROM t1 GROUP BY y; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def y y 3 1 1 Y 32800 0 63 +def y 3 1 1 Y 32800 0 63 y 0 DROP TABLE t1; From 93d44a183d1cf6e45a6076600ba475977d506109 Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Mon, 1 Oct 2007 12:51:59 +0300 Subject: [PATCH 064/203] removed undeterministic test result from the fux for bug 30587 --- mysql-test/r/func_math.result | 8 -------- mysql-test/t/func_math.test | 2 -- 2 files changed, 10 deletions(-) diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index d294de93cd8..150b6003dbe 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -325,25 +325,17 @@ pow(cast(-2 as unsigned), 5) pow(18446744073709551614, 5) pow(-2, 5) CREATE TABLE t1 (a timestamp, b varchar(20), c bit(1)); INSERT INTO t1 VALUES('1998-09-23', 'str1', 1), ('2003-03-25', 'str2', 0); SELECT a DIV 900 y FROM t1 GROUP BY y; -Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def y 8 19 11 Y 32800 0 63 y 22201025555 22255916666 SELECT DISTINCT a DIV 900 y FROM t1; -Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def y 8 19 11 Y 32800 0 63 y 22201025555 22255916666 SELECT b DIV 900 y FROM t1 GROUP BY y; -Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def y 8 20 1 Y 32768 0 63 y 0 SELECT c DIV 900 y FROM t1 GROUP BY y; -Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def y 3 1 1 Y 32800 0 63 y 0 DROP TABLE t1; diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index 1f46415741f..9f12fdd696e 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -211,12 +211,10 @@ select pow(cast(-2 as unsigned), 5), pow(18446744073709551614, 5), pow(-2, 5); CREATE TABLE t1 (a timestamp, b varchar(20), c bit(1)); INSERT INTO t1 VALUES('1998-09-23', 'str1', 1), ('2003-03-25', 'str2', 0); ---enable_metadata SELECT a DIV 900 y FROM t1 GROUP BY y; SELECT DISTINCT a DIV 900 y FROM t1; SELECT b DIV 900 y FROM t1 GROUP BY y; SELECT c DIV 900 y FROM t1 GROUP BY y; ---disable_metadata DROP TABLE t1; CREATE TABLE t1(a LONGBLOB); From 7f554deb956f645982fe3b1ba0d505a002f11cb2 Mon Sep 17 00:00:00 2001 From: "anozdrin/alik@station." <> Date: Mon, 1 Oct 2007 15:41:18 +0400 Subject: [PATCH 065/203] BUG#30472: libmysql doesn't reset charset, insert_id after succ. mysql_change_user() call. Use 2 bytes for character set number. --- libmysql/libmysql.c | 4 ++-- sql/sql_parse.cc | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index adac6c7cd48..f2c16eb85de 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -736,8 +736,8 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, if (mysql->server_capabilities & CLIENT_SECURE_CONNECTION) { - *end= (uchar) mysql->charset->number; - ++end; + int2store(end, (ushort) mysql->charset->number); + end+= 2; } /* Write authentication package */ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 923fd1b2bfe..ab9cace7a17 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -878,10 +878,19 @@ bool dispatch_command(enum enum_server_command command, THD *thd, } db_length= strlen(db); + char *ptr= db + db_length + 1; uint cs_number= 0; - if (db + db_length < packet_end) - cs_number= (uchar) *(db + db_length + 1); + if (ptr < packet_end) + { + if (ptr + 2 > packet_end) + { + my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0)); + break; + } + + cs_number= uint2korr(ptr); + } /* Convert database name to utf8 */ db_buff[copy_and_convert(db_buff, sizeof(db_buff)-1, From 5dad55cd24e8a82ae8e4b2e63186af57204ef571 Mon Sep 17 00:00:00 2001 From: "mats@kindahl-laptop.dnsalias.net" <> Date: Mon, 1 Oct 2007 15:11:15 +0200 Subject: [PATCH 066/203] BUG#30992 (Wrong implementation of pthread_mutex_trylock()): Adding support for correct handling of pthread_mutex_trylock() on Win32 systems as well as when using the safe mutexes. --- include/my_pthread.h | 9 ++++---- mysys/my_winthread.c | 25 ++++++++++++++++++++++ mysys/thr_mutex.c | 49 +++++++++++++++++++++++++++++++++++++------- 3 files changed, 72 insertions(+), 11 deletions(-) diff --git a/include/my_pthread.h b/include/my_pthread.h index d64b5348666..e28bb9df1f3 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -135,6 +135,7 @@ struct timespec { void win_pthread_init(void); int win_pthread_setspecific(void *A,void *B,uint length); +int win_pthread_mutex_trylock(pthread_mutex_t *mutex); int pthread_create(pthread_t *,pthread_attr_t *,pthread_handler,void *); int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr); int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex); @@ -195,7 +196,7 @@ extern int pthread_mutex_destroy (pthread_mutex_t *); #else #define pthread_mutex_init(A,B) (InitializeCriticalSection(A),0) #define pthread_mutex_lock(A) (EnterCriticalSection(A),0) -#define pthread_mutex_trylock(A) (WaitForSingleObject((A), 0) == WAIT_TIMEOUT) +#define pthread_mutex_trylock(A) win_pthread_mutex_trylock((A)) #define pthread_mutex_unlock(A) LeaveCriticalSection(A) #define pthread_mutex_destroy(A) DeleteCriticalSection(A) #define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B)) @@ -593,7 +594,7 @@ typedef struct st_safe_mutex_info_t int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr, const char *file, uint line); -int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line); +int safe_mutex_lock(safe_mutex_t *mp, my_bool try_lock, const char *file, uint line); int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line); int safe_mutex_destroy(safe_mutex_t *mp,const char *file, uint line); int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp,const char *file, @@ -616,12 +617,12 @@ void safe_mutex_end(FILE *file); #undef pthread_cond_timedwait #undef pthread_mutex_trylock #define pthread_mutex_init(A,B) safe_mutex_init((A),(B),__FILE__,__LINE__) -#define pthread_mutex_lock(A) safe_mutex_lock((A),__FILE__,__LINE__) +#define pthread_mutex_lock(A) safe_mutex_lock((A), FALSE, __FILE__, __LINE__) #define pthread_mutex_unlock(A) safe_mutex_unlock((A),__FILE__,__LINE__) #define pthread_mutex_destroy(A) safe_mutex_destroy((A),__FILE__,__LINE__) #define pthread_cond_wait(A,B) safe_cond_wait((A),(B),__FILE__,__LINE__) #define pthread_cond_timedwait(A,B,C) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__) -#define pthread_mutex_trylock(A) pthread_mutex_lock(A) +#define pthread_mutex_trylock(A) safe_mutex_lock((A), TRUE, __FILE__, __LINE__) #define pthread_mutex_t safe_mutex_t #define safe_mutex_assert_owner(mp) \ DBUG_ASSERT((mp)->count > 0 && \ diff --git a/mysys/my_winthread.c b/mysys/my_winthread.c index 27ccaef4f23..e9fface0521 100644 --- a/mysys/my_winthread.c +++ b/mysys/my_winthread.c @@ -40,6 +40,31 @@ void win_pthread_init(void) pthread_mutex_init(&THR_LOCK_thread,MY_MUTEX_INIT_FAST); } +/** + Adapter to @c pthread_mutex_trylock() + + @retval 0 Mutex was acquired + @retval EBUSY Mutex was already locked by a thread + @retval EINVAL Mutex could not be acquired due to other error + */ +int +win_pthread_mutex_trylock(pthread_mutex_t *mutex) +{ + switch (WaitForSingleObject(mutex, 0)) { + case WAIT_TIMEOUT: + return EBUSY; + + default: + case WAIT_FAILURE: + return EINVAL; + + case WAIT_OBJECT_0: + case WAIT_ABANDONED: /* The mutex was acquired because it was + * abandoned */ + return 0; + } +} + /* ** We have tried to use '_beginthreadex' instead of '_beginthread' here ** but in this case the program leaks about 512 characters for each diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c index 425e5fce459..53ee907e0a3 100644 --- a/mysys/thr_mutex.c +++ b/mysys/thr_mutex.c @@ -91,7 +91,7 @@ int safe_mutex_init(safe_mutex_t *mp, } -int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line) +int safe_mutex_lock(safe_mutex_t *mp, my_bool try_lock, const char *file, uint line) { int error; if (!mp->file) @@ -104,15 +104,50 @@ int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line) } pthread_mutex_lock(&mp->global); - if (mp->count > 0 && pthread_equal(pthread_self(),mp->thread)) + if (mp->count > 0) { - fprintf(stderr,"safe_mutex: Trying to lock mutex at %s, line %d, when the mutex was already locked at %s, line %d in thread %s\n", - file,line,mp->file, mp->line, my_thread_name()); - fflush(stderr); - abort(); + if (try_lock) + { + pthread_mutex_unlock(&mp->global); + return EBUSY; + } + else if (pthread_equal(pthread_self(),mp->thread)) + { + fprintf(stderr, + "safe_mutex: Trying to lock mutex at %s, line %d, when the" + " mutex was already locked at %s, line %d in thread %s\n", + file,line,mp->file, mp->line, my_thread_name()); + fflush(stderr); + abort(); + } } pthread_mutex_unlock(&mp->global); - error=pthread_mutex_lock(&mp->mutex); + + /* + If we are imitating trylock(), we need to take special + precautions. + + - We cannot use pthread_mutex_lock() only since another thread can + overtake this thread and take the lock before this thread + causing pthread_mutex_trylock() to hang. In this case, we should + just return EBUSY. Hence, we use pthread_mutex_trylock() to be + able to return immediately. + + - We cannot just use trylock() and continue execution below, since + this would generate an error and abort execution if the thread + was overtaken and trylock() returned EBUSY . In this case, we + instead just return EBUSY, since this is the expected behaviour + of trylock(). + */ + if (try_lock) + { + error= pthread_mutex_trylock(&mp->mutex); + if (error == EBUSY) + return error; + } + else + error= pthread_mutex_lock(&mp->mutex); + if (error || (error=pthread_mutex_lock(&mp->global))) { fprintf(stderr,"Got error %d when trying to lock mutex at %s, line %d\n", From 0ba77db972f4cf65ff36bf0d52f843500ff708a8 Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Mon, 1 Oct 2007 17:37:48 +0300 Subject: [PATCH 067/203] merge 5.0-opt -> 5.1-opt --- mysql-test/r/view_grant.result | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result index 8b4aa894130..c301953f508 100644 --- a/mysql-test/r/view_grant.result +++ b/mysql-test/r/view_grant.result @@ -785,7 +785,7 @@ ALTER VIEW v3 AS SELECT f2 FROM t1; ERROR 42000: Access denied; you need the SUPER privilege for this operation SHOW CREATE VIEW v3; View Create View character_set_client collation_connection -v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`f2` AS `f2` from `t1` latin1 latin1_swedish_ci +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`f1` AS `f1` from `t1` latin1 latin1_swedish_ci DROP USER u26813@localhost; DROP DATABASE db26813; # @@ -810,24 +810,24 @@ ERROR 42000: Access denied; you need the SUPER privilege for this operation ALTER VIEW v2 AS SELECT f2 FROM t1; ERROR 42000: Access denied; you need the SUPER privilege for this operation SHOW CREATE VIEW v2; -View Create View -v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f1` AS `f1` from `t1` +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f1` AS `f1` from `t1` latin1 latin1_swedish_ci ALTER VIEW v1 AS SELECT f2 FROM t1; SHOW CREATE VIEW v1; -View Create View -v1 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f2` AS `f2` from `t1` +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f2` AS `f2` from `t1` latin1 latin1_swedish_ci ALTER VIEW v2 AS SELECT f2 FROM t1; SHOW CREATE VIEW v2; -View Create View -v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f2` AS `f2` from `t1` +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f2` AS `f2` from `t1` latin1 latin1_swedish_ci ALTER VIEW v1 AS SELECT f1 FROM t1; SHOW CREATE VIEW v1; -View Create View -v1 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f1` AS `f1` from `t1` +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f1` AS `f1` from `t1` latin1 latin1_swedish_ci ALTER VIEW v2 AS SELECT f1 FROM t1; SHOW CREATE VIEW v2; -View Create View -v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f1` AS `f1` from `t1` +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f1` AS `f1` from `t1` latin1 latin1_swedish_ci DROP USER u29908_1@localhost; DROP USER u29908_2@localhost; DROP DATABASE mysqltest_29908; @@ -938,6 +938,8 @@ v1 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such`@`user_1` SQL SECURITY DEFINER VI Warnings: Warning 1356 View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them ALTER ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1; +Warnings: +Note 1449 There is no 'no_such'@'user_1' registered SHOW CREATE VIEW v1; View Create View character_set_client collation_connection v1 CREATE ALGORITHM=MERGE DEFINER=`no_such`@`user_1` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci From 5fc81ee88e37656f83dd0231a96b08f73b69523c Mon Sep 17 00:00:00 2001 From: "gshchepa/uchum@gleb.loc" <> Date: Mon, 1 Oct 2007 20:35:51 +0500 Subject: [PATCH 068/203] Fixed bug #31077. mysqldump adds the "-- Dump completed on YYYY-MM-DD hh:mm:ss" string to the end of output if the --comments switch is on. The only way to suppress this line is to use --skip-comments/--compact switch. New switch has been added to the mysqldump client command line: --dump-date. For the compatibility with previous releases, by default the --dump-date is on. The --dump-date switch forces mysqldump to add date to the "-- Dump completed on ..." string at the end of output. The --skip-dump-date switch supresses the output of date string and uses short form of that commentary: "-- Dump completed". --skip-comments or --compact switches disable the whole commentary as usual. --- client/client_priv.h | 2 +- client/mysqldump.c | 18 +++++++++++++----- mysql-test/r/mysqldump.result | 10 ++++++++++ mysql-test/t/mysqldump.test | 14 ++++++++++++++ 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/client/client_priv.h b/client/client_priv.h index 418bf86f2c8..8f509fa0763 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -51,5 +51,5 @@ enum options_client OPT_TRIGGERS, OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_SHOW_WARNINGS,OPT_DROP_DATABASE, OPT_TZ_UTC, OPT_AUTO_CLOSE, OPT_SSL_VERIFY_SERVER_CERT, - OPT_DEBUG_INFO, OPT_ERROR_LOG_FILE + OPT_DEBUG_INFO, OPT_ERROR_LOG_FILE, OPT_DUMP_DATE }; diff --git a/client/mysqldump.c b/client/mysqldump.c index cc8458c7a8e..fb28647a120 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -89,7 +89,7 @@ static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0, opt_drop=1,opt_keywords=0,opt_lock=1,opt_compress=0, opt_delayed=0,create_options=1,opt_quoted=0,opt_databases=0, opt_alldbs=0,opt_create_db=0,opt_lock_all_tables=0, - opt_set_charset=0, + opt_set_charset=0, opt_dump_date=1, opt_autocommit=0,opt_disable_keys=1,opt_xml=0, opt_delete_master_logs=0, tty_password=0, opt_single_transaction=0, opt_comments= 0, opt_compact= 0, @@ -402,6 +402,9 @@ static struct my_option my_long_options[] = "automatically turns off --lock-tables.", (gptr*) &opt_single_transaction, (gptr*) &opt_single_transaction, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"dump-date", OPT_DUMP_DATE, "Put a dump date to the end of the output.", + (gptr*) &opt_dump_date, (gptr*) &opt_dump_date, 0, + GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"skip-opt", OPT_SKIP_OPTIMIZATION, "Disable --opt. Disables --add-drop-table, --add-locks, --create-options, --quick, --extended-insert, --lock-tables, --set-charset, and --disable-keys.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -623,10 +626,15 @@ static void write_footer(FILE *sql_file) fputs("\n", sql_file); if (opt_comments) { - char time_str[20]; - get_date(time_str, GETDATE_DATE_TIME, 0); - fprintf(sql_file, "-- Dump completed on %s\n", - time_str); + if (opt_dump_date) + { + char time_str[20]; + get_date(time_str, GETDATE_DATE_TIME, 0); + fprintf(sql_file, "-- Dump completed on %s\n", + time_str); + } + else + fprintf(sql_file, "-- Dump completed"); } check_io(sql_file); } diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 42c437857b7..06bbab3285e 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -3544,5 +3544,15 @@ c1 2 DROP TABLE t1,t2; # +# Bug#29815: new option for suppressing last line of mysqldump: +# "Dump completed on" +# +# --skip-dump-date: +-- Dump completed +# --dump-date: +-- Dump completed on -- :: +# --dump-date (default): +-- Dump completed on -- :: +# # End of 5.0 tests # diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 3c62577e781..5eb5370f779 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -1576,6 +1576,20 @@ SELECT * FROM t2; DROP TABLE t1,t2; +--echo # +--echo # Bug#29815: new option for suppressing last line of mysqldump: +--echo # "Dump completed on" +--echo # + +--echo # --skip-dump-date: +--exec $MYSQL_DUMP --skip-dump-date test | grep 'Dump completed' + +--echo # --dump-date: +--exec $MYSQL_DUMP --dump-date test | grep 'Dump completed' | tr -d '[0-9]' + +--echo # --dump-date (default): +--exec $MYSQL_DUMP test | grep 'Dump completed' | tr -d '[0-9]' + --echo # --echo # End of 5.0 tests --echo # From 49af76ac8a42f6f971a115ee36a5ff6c56bc6dba Mon Sep 17 00:00:00 2001 From: "evgen@moonbone.local" <> Date: Mon, 1 Oct 2007 20:03:50 +0000 Subject: [PATCH 069/203] Bug#31095: Unexpected NULL constant caused server crash. The Item_func_rollup_const class is used for wrapping constants to avoid wrong result for ROLLUP queries with DISTINCT and a constant in the select list. This class is also used to wrap up a NULL constant but its null_value wasn't set accordingly. This led to a server crash. Now the null_value of an object of the Item_func_rollup_const class is set by its fix_length_and_dec member function. --- mysql-test/r/olap.result | 11 +++++++++++ mysql-test/t/olap.test | 9 +++++++++ sql/item_func.h | 2 ++ 3 files changed, 22 insertions(+) diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result index 4a54b17316d..a1d66b11f58 100644 --- a/mysql-test/r/olap.result +++ b/mysql-test/r/olap.result @@ -715,3 +715,14 @@ a SUM(a) 4 4 NULL 14 DROP TABLE t1; +# +# Bug#31095: Unexpected NULL constant caused server crash. +# +create table t1(a int); +insert into t1 values (1),(2),(3); +select count(a) from t1 group by null with rollup; +count(a) +3 +3 +drop table t1; +############################################################## diff --git a/mysql-test/t/olap.test b/mysql-test/t/olap.test index 05934bff492..1ac99d9c39f 100644 --- a/mysql-test/t/olap.test +++ b/mysql-test/t/olap.test @@ -358,3 +358,12 @@ SELECT * FROM (SELECT a, SUM(a) FROM t1 GROUP BY a WITH ROLLUP) as t; DROP TABLE t1; +--echo # +--echo # Bug#31095: Unexpected NULL constant caused server crash. +--echo # +create table t1(a int); +insert into t1 values (1),(2),(3); +select count(a) from t1 group by null with rollup; +drop table t1; +--echo ############################################################## + diff --git a/sql/item_func.h b/sql/item_func.h index 57e33daf0c4..87c9e016df2 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -749,6 +749,8 @@ public: collation= args[0]->collation; max_length= args[0]->max_length; decimals=args[0]->decimals; + /* The item could be a NULL constant. */ + null_value= args[0]->null_value; } }; From 6c8627de497e642ea75f09c259aadd580cb1a094 Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Tue, 2 Oct 2007 15:36:07 +0300 Subject: [PATCH 070/203] Fixed a valgrind warning with the fix for bug 28702. --- sql/sql_select.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 699c0be4c5b..e5c0b994ecb 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -15493,6 +15493,7 @@ TABLE_LIST::print_index_hint(THD *thd, String *str, List_iterator_fast li(indexes); String *idx; bool first= 1; + int find_length= strlen(primary_key_name); str->append (' '); str->append (hint, hint_length); @@ -15503,8 +15504,15 @@ TABLE_LIST::print_index_hint(THD *thd, String *str, first= 0; else str->append(','); - if (!my_strcasecmp (system_charset_info, idx->c_ptr_safe(), - primary_key_name)) + /* + It's safe to use ptr() here because we compare the length first + and we rely that my_strcasecmp will not access more than length() + chars from the string. See test_if_string_in_list() for similar + implementation. + */ + if (find_length == idx->length() && + !my_strcasecmp (system_charset_info, primary_key_name, + idx->ptr())) str->append(primary_key_name); else append_identifier (thd, str, idx->ptr(), idx->length()); From c6e974226e5de1496437c345e5da716c3602b7f3 Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Tue, 2 Oct 2007 17:45:49 +0300 Subject: [PATCH 071/203] fixed a warning in the fix for bug 28702 --- sql/sql_select.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index e5c0b994ecb..3529de1c28a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -15493,7 +15493,7 @@ TABLE_LIST::print_index_hint(THD *thd, String *str, List_iterator_fast li(indexes); String *idx; bool first= 1; - int find_length= strlen(primary_key_name); + size_t find_length= strlen(primary_key_name); str->append (' '); str->append (hint, hint_length); From e4d7e2168353270b04d5c0ba6221db6459f43519 Mon Sep 17 00:00:00 2001 From: "msvensson@pilot.mysql.com" <> Date: Tue, 2 Oct 2007 20:44:37 +0200 Subject: [PATCH 072/203] Bug#27597 mysqld-debug broken - "on" -> "restore" to avoid warning in MSVC when compiling with debug --- mysys/my_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysys/my_init.c b/mysys/my_init.c index 32d3f07fd31..8154a5fce51 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -286,7 +286,7 @@ int handle_rtc_failure(int err_type, const char *file, int line, return 0; /* Error is handled */ } -#pragma runtime_checks("", on) +#pragma runtime_checks("", restore) #endif From c81751adba96086ed2b6eb1ea31fa9cb1abc4fa8 Mon Sep 17 00:00:00 2001 From: "gshchepa/uchum@gleb.loc" <> Date: Wed, 3 Oct 2007 02:50:38 +0500 Subject: [PATCH 073/203] mysqldump.c, mysqldump.test, mysqldump.result: Bug #31077: post-commit fix. --- client/mysqldump.c | 2 +- mysql-test/r/mysqldump.result | 16 ++++++++++++++-- mysql-test/t/mysqldump.test | 9 ++++++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index fb28647a120..cc7b7689169 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -634,7 +634,7 @@ static void write_footer(FILE *sql_file) time_str); } else - fprintf(sql_file, "-- Dump completed"); + fprintf(sql_file, "-- Dump completed\n"); } check_io(sql_file); } diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 06bbab3285e..e49d3070e9a 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -3548,11 +3548,23 @@ DROP TABLE t1,t2; # "Dump completed on" # # --skip-dump-date: +-- + + + -- Dump completed # --dump-date: --- Dump completed on -- :: +-- + + + +-- Dump completed on x-x-x x:x:x # --dump-date (default): --- Dump completed on -- :: +-- + + + +-- Dump completed on x-x-x x:x:x # # End of 5.0 tests # diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 5eb5370f779..cecb3ecf3a4 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -1582,13 +1582,16 @@ DROP TABLE t1,t2; --echo # --echo # --skip-dump-date: ---exec $MYSQL_DUMP --skip-dump-date test | grep 'Dump completed' +--replace_regex /-- [^D][^u][^m][^p].*// /\/\*!.*// +--exec $MYSQL_DUMP --skip-dump-date test --echo # --dump-date: ---exec $MYSQL_DUMP --dump-date test | grep 'Dump completed' | tr -d '[0-9]' +--replace_regex /-- [^D][^u][^m][^p].*// /\/\*!.*// /[0-9]+/x/ +--exec $MYSQL_DUMP --dump-date test --echo # --dump-date (default): ---exec $MYSQL_DUMP test | grep 'Dump completed' | tr -d '[0-9]' +--replace_regex /-- [^D][^u][^m][^p].*// /\/\*!.*// /[0-9]+/x/ +--exec $MYSQL_DUMP test --echo # --echo # End of 5.0 tests From 0111438b450bd08ac98eaab2b780815a28a6c7ea Mon Sep 17 00:00:00 2001 From: "tsmith@sita.local" <> Date: Tue, 2 Oct 2007 23:47:30 -0600 Subject: [PATCH 074/203] Bug #20358: InnoDB hang on the adaptive hash index latch in btr0sea.c Add --skip-innodb-adaptive-hash-index option, which is a way to work around the bug (by disabling the adaptive hash feature entirely). This may be useful even once the bug is fixed, for benchmarking purposes. There are some workloads for which the adaptive hash index is not effective. --- sql/ha_innodb.cc | 3 +++ sql/ha_innodb.h | 3 ++- sql/mysqld.cc | 9 ++++++++- sql/set_var.cc | 1 + 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 2d47c42cf1d..86d3e930122 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -174,6 +174,7 @@ my_bool innobase_file_per_table = FALSE; my_bool innobase_locks_unsafe_for_binlog = FALSE; my_bool innobase_rollback_on_timeout = FALSE; my_bool innobase_create_status_file = FALSE; +my_bool innobase_adaptive_hash_index = TRUE; static char *internal_innobase_data_file_path = NULL; @@ -1376,6 +1377,8 @@ innobase_init(void) srv_use_doublewrite_buf = (ibool) innobase_use_doublewrite; srv_use_checksums = (ibool) innobase_use_checksums; + srv_use_adaptive_hash_indexes = (ibool) innobase_adaptive_hash_index; + os_use_large_pages = (ibool) innobase_use_large_pages; os_large_page_size = (ulint) innobase_large_page_size; diff --git a/sql/ha_innodb.h b/sql/ha_innodb.h index 585bc75fa36..3db983901b3 100644 --- a/sql/ha_innodb.h +++ b/sql/ha_innodb.h @@ -217,7 +217,8 @@ extern my_bool innobase_log_archive, innobase_use_native_aio, innobase_file_per_table, innobase_locks_unsafe_for_binlog, innobase_rollback_on_timeout, - innobase_create_status_file; + innobase_create_status_file, + innobase_adaptive_hash_index; extern my_bool innobase_very_fast_shutdown; /* set this to 1 just before calling innobase_end() if you want InnoDB to shut down without diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 08c2b60fa79..a6c9eeec65a 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4829,7 +4829,8 @@ enum options_mysqld OPT_MERGE, OPT_INNODB_ROLLBACK_ON_TIMEOUT, OPT_SECURE_FILE_PRIV, - OPT_KEEP_FILES_ON_CREATE + OPT_KEEP_FILES_ON_CREATE, + OPT_INNODB_ADAPTIVE_HASH_INDEX }; @@ -5057,6 +5058,12 @@ Disable with --skip-innodb-checksums.", (gptr*) &innobase_use_checksums, "The common part for InnoDB table spaces.", (gptr*) &innobase_data_home_dir, (gptr*) &innobase_data_home_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"innodb_adaptive_hash_index", OPT_INNODB_ADAPTIVE_HASH_INDEX, + "Enable InnoDB adaptive hash index (enabled by default). " + "Disable with --skip-innodb-adaptive-hash-index.", + (gptr*) &innobase_adaptive_hash_index, + (gptr*) &innobase_adaptive_hash_index, + 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"innodb_doublewrite", OPT_INNODB_DOUBLEWRITE, "Enable InnoDB doublewrite buffer (enabled by default). \ Disable with --skip-innodb-doublewrite.", (gptr*) &innobase_use_doublewrite, (gptr*) &innobase_use_doublewrite, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, diff --git a/sql/set_var.cc b/sql/set_var.cc index e1246617d84..268c82c2be2 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -901,6 +901,7 @@ struct show_var_st init_vars[]= { {sys_innodb_concurrency_tickets.name, (char*) &sys_innodb_concurrency_tickets, SHOW_SYS}, {"innodb_data_file_path", (char*) &innobase_data_file_path, SHOW_CHAR_PTR}, {"innodb_data_home_dir", (char*) &innobase_data_home_dir, SHOW_CHAR_PTR}, + {"innodb_adaptive_hash_index", (char*) &innobase_adaptive_hash_index, SHOW_MY_BOOL}, {"innodb_doublewrite", (char*) &innobase_use_doublewrite, SHOW_MY_BOOL}, {sys_innodb_fast_shutdown.name,(char*) &sys_innodb_fast_shutdown, SHOW_SYS}, {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG }, From a6b5121b4001b6e5a3bfa1f76cf8a40c52f8ef8b Mon Sep 17 00:00:00 2001 From: "gshchepa/uchum@gleb.loc" <> Date: Wed, 3 Oct 2007 11:36:42 +0500 Subject: [PATCH 075/203] mysqldump.test, mysqldump.result: Bug #31077: post-commit fix. --- mysql-test/r/mysqldump.result | 4 ++-- mysql-test/t/mysqldump.test | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index e49d3070e9a..ca0aa399a56 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -3558,13 +3558,13 @@ DROP TABLE t1,t2; --- Dump completed on x-x-x x:x:x +-- Dump completed on DATE # --dump-date (default): -- --- Dump completed on x-x-x x:x:x +-- Dump completed on DATE # # End of 5.0 tests # diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index cecb3ecf3a4..6dba0a590d0 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -1586,11 +1586,11 @@ DROP TABLE t1,t2; --exec $MYSQL_DUMP --skip-dump-date test --echo # --dump-date: ---replace_regex /-- [^D][^u][^m][^p].*// /\/\*!.*// /[0-9]+/x/ +--replace_regex /-- [^D][^u][^m][^p].*// /\/\*!.*// / on [0-9 :-]+/ on DATE/ --exec $MYSQL_DUMP --dump-date test --echo # --dump-date (default): ---replace_regex /-- [^D][^u][^m][^p].*// /\/\*!.*// /[0-9]+/x/ +--replace_regex /-- [^D][^u][^m][^p].*// /\/\*!.*// / on [0-9 :-]+/ on DATE/ --exec $MYSQL_DUMP test --echo # From a7a6c6eb08f9713027a06473c96a4c6ed1494398 Mon Sep 17 00:00:00 2001 From: "holyfoot/hf@mysql.com/hfmain.(none)" <> Date: Wed, 3 Oct 2007 13:35:35 +0500 Subject: [PATCH 076/203] Bug #30955 geomfromtext() crasher. end-of-line check missed in Gis_read_stream::get_next_word, what can lead to crashes (expecially with NULL strings). End-of-line check added --- mysql-test/r/gis.result | 6 ++++++ mysql-test/t/gis.test | 8 ++++++++ sql/gstream.cc | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index 643a3d6b434..55f70e59fcf 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -724,4 +724,10 @@ SELECT * FROM t1; a NULL DROP TABLE t1; +CREATE TABLE `t1` ( `col9` set('a'), `col89` date); +INSERT INTO `t1` VALUES ('','0000-00-00'); +select geomfromtext(col9,col89) as a from t1; +a +NULL +DROP TABLE t1; End of 4.1 tests diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index 7182e040d46..cf5c3b31bc1 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -419,4 +419,12 @@ INSERT INTO t1 VALUES (NULL); SELECT * FROM t1; DROP TABLE t1; +# +# Bug #30955 geomfromtext() crasher +# +CREATE TABLE `t1` ( `col9` set('a'), `col89` date); +INSERT INTO `t1` VALUES ('','0000-00-00'); +select geomfromtext(col9,col89) as a from t1; +DROP TABLE t1; + --echo End of 4.1 tests diff --git a/sql/gstream.cc b/sql/gstream.cc index f7d11d76b0c..f986d9dc7f3 100644 --- a/sql/gstream.cc +++ b/sql/gstream.cc @@ -45,7 +45,7 @@ bool Gis_read_stream::get_next_word(LEX_STRING *res) skip_space(); res->str= (char*) m_cur; /* The following will also test for \0 */ - if (!my_isvar_start(&my_charset_bin, *m_cur)) + if ((m_cur >= m_limit) || !my_isvar_start(&my_charset_bin, *m_cur)) return 1; /* From 009d8b609e7841c7a970676b94685e20ebe34582 Mon Sep 17 00:00:00 2001 From: "gshchepa/uchum@gleb.loc" <> Date: Wed, 3 Oct 2007 15:49:51 +0500 Subject: [PATCH 077/203] mysqldump.c: Post-merge fix. --- client/mysqldump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 03265fbf5a3..2b463552dd5 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -425,7 +425,7 @@ static struct my_option my_long_options[] = (uchar**) &opt_single_transaction, (uchar**) &opt_single_transaction, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"dump-date", OPT_DUMP_DATE, "Put a dump date to the end of the output.", - (gptr*) &opt_dump_date, (gptr*) &opt_dump_date, 0, + (uchar**) &opt_dump_date, (uchar**) &opt_dump_date, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"skip-opt", OPT_SKIP_OPTIMIZATION, "Disable --opt. Disables --add-drop-table, --add-locks, --create-options, --quick, --extended-insert, --lock-tables, --set-charset, and --disable-keys.", From 18c6118911f1f98c80a9a06af50a8c5ed02aef32 Mon Sep 17 00:00:00 2001 From: "msvensson@pilot.mysql.com" <> Date: Wed, 3 Oct 2007 21:38:32 +0200 Subject: [PATCH 078/203] Bug#30992 Wrong implementation of pthread_mutex_trylock() It's not possible to use WaitForSingleObject to wait on a CRITICAL_SECTION, instead use the TryEnterCriticalSection function. - if "mutex" was already taken => return EBUSY - if "mutex" was aquired => return 0 --- include/config-win.h | 3 +++ mysys/my_winthread.c | 22 ++++++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/include/config-win.h b/include/config-win.h index 279be7aa5e4..f0804a368bc 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -19,6 +19,9 @@ /* We have to do this define before including windows.h to get the AWE API functions */ #define _WIN32_WINNT 0x0500 +#else +/* Get NT 4.0 functions */ +#define _WIN32_WINNT 0x0400 #endif #if defined(_MSC_VER) && _MSC_VER >= 1400 diff --git a/mysys/my_winthread.c b/mysys/my_winthread.c index e9fface0521..e94369bec32 100644 --- a/mysys/my_winthread.c +++ b/mysys/my_winthread.c @@ -40,31 +40,29 @@ void win_pthread_init(void) pthread_mutex_init(&THR_LOCK_thread,MY_MUTEX_INIT_FAST); } + /** Adapter to @c pthread_mutex_trylock() @retval 0 Mutex was acquired @retval EBUSY Mutex was already locked by a thread - @retval EINVAL Mutex could not be acquired due to other error */ int win_pthread_mutex_trylock(pthread_mutex_t *mutex) { - switch (WaitForSingleObject(mutex, 0)) { - case WAIT_TIMEOUT: - return EBUSY; - - default: - case WAIT_FAILURE: - return EINVAL; - - case WAIT_OBJECT_0: - case WAIT_ABANDONED: /* The mutex was acquired because it was - * abandoned */ + if (TryEnterCriticalSection(mutex)) + { + /* Don't allow recursive lock */ + if (mutex->RecursionCount > 1){ + LeaveCriticalSection(mutex); + return EBUSY; + } return 0; } + return EBUSY; } + /* ** We have tried to use '_beginthreadex' instead of '_beginthread' here ** but in this case the program leaks about 512 characters for each From bc9b4834e1f95f02008e41b8e5ce62968befd53a Mon Sep 17 00:00:00 2001 From: "ramil/ram@mysql.com/ramil.myoffice.izhnet.ru" <> Date: Thu, 4 Oct 2007 10:20:00 +0500 Subject: [PATCH 079/203] Fix for bug #31069: crash in 'sounds like' and for bug #31070: crash during conversion of charsets Problem: passing a 0 byte length string to some my_mb_wc_XXX() functions leads to server crash due to improper argument check. Fix: properly check arguments passed to my_mb_wc_XXX() functions. --- mysql-test/include/ctype_common.inc | 9 +++++++++ mysql-test/r/ctype_big5.result | 11 +++++++++++ mysql-test/r/ctype_euckr.result | 11 +++++++++++ mysql-test/r/ctype_gb2312.result | 11 +++++++++++ mysql-test/r/ctype_gbk.result | 11 +++++++++++ mysql-test/r/ctype_uca.result | 11 +++++++++++ strings/ctype-big5.c | 4 ++-- strings/ctype-cp932.c | 4 ++-- strings/ctype-euc_kr.c | 4 ++-- strings/ctype-gb2312.c | 4 +--- strings/ctype-sjis.c | 4 ++-- 11 files changed, 73 insertions(+), 11 deletions(-) diff --git a/mysql-test/include/ctype_common.inc b/mysql-test/include/ctype_common.inc index 202c508a9c9..9ee0a40c8ce 100644 --- a/mysql-test/include/ctype_common.inc +++ b/mysql-test/include/ctype_common.inc @@ -51,6 +51,15 @@ SELECT c1 as want1result from t1 where c1 like 'locatio%'; SELECT c1 as want1result from t1 where c1 like 'location%'; DROP TABLE t1; +# +# Bug #31070: crash during conversion of charsets +# +create table t1 (a set('a') not null); +insert into t1 values (),(); +select cast(a as char(1)) from t1; +select a sounds like a from t1; +drop table t1; + DROP DATABASE d1; # Restore settings USE test; diff --git a/mysql-test/r/ctype_big5.result b/mysql-test/r/ctype_big5.result index 6574908101c..a2651db6308 100644 --- a/mysql-test/r/ctype_big5.result +++ b/mysql-test/r/ctype_big5.result @@ -52,6 +52,17 @@ SELECT c1 as want1result from t1 where c1 like 'location%'; want1result location DROP TABLE t1; +create table t1 (a set('a') not null); +insert into t1 values (),(); +select cast(a as char(1)) from t1; +cast(a as char(1)) + + +select a sounds like a from t1; +a sounds like a +1 +1 +drop table t1; DROP DATABASE d1; USE test; SET character_set_server= @safe_character_set_server; diff --git a/mysql-test/r/ctype_euckr.result b/mysql-test/r/ctype_euckr.result index 6017bc07763..2d9f8d217e6 100644 --- a/mysql-test/r/ctype_euckr.result +++ b/mysql-test/r/ctype_euckr.result @@ -52,6 +52,17 @@ SELECT c1 as want1result from t1 where c1 like 'location%'; want1result location DROP TABLE t1; +create table t1 (a set('a') not null); +insert into t1 values (),(); +select cast(a as char(1)) from t1; +cast(a as char(1)) + + +select a sounds like a from t1; +a sounds like a +1 +1 +drop table t1; DROP DATABASE d1; USE test; SET character_set_server= @safe_character_set_server; diff --git a/mysql-test/r/ctype_gb2312.result b/mysql-test/r/ctype_gb2312.result index 314c336bab9..04c318e83a8 100644 --- a/mysql-test/r/ctype_gb2312.result +++ b/mysql-test/r/ctype_gb2312.result @@ -52,6 +52,17 @@ SELECT c1 as want1result from t1 where c1 like 'location%'; want1result location DROP TABLE t1; +create table t1 (a set('a') not null); +insert into t1 values (),(); +select cast(a as char(1)) from t1; +cast(a as char(1)) + + +select a sounds like a from t1; +a sounds like a +1 +1 +drop table t1; DROP DATABASE d1; USE test; SET character_set_server= @safe_character_set_server; diff --git a/mysql-test/r/ctype_gbk.result b/mysql-test/r/ctype_gbk.result index 241539ecf42..064c0bc2acf 100644 --- a/mysql-test/r/ctype_gbk.result +++ b/mysql-test/r/ctype_gbk.result @@ -52,6 +52,17 @@ SELECT c1 as want1result from t1 where c1 like 'location%'; want1result location DROP TABLE t1; +create table t1 (a set('a') not null); +insert into t1 values (),(); +select cast(a as char(1)) from t1; +cast(a as char(1)) + + +select a sounds like a from t1; +a sounds like a +1 +1 +drop table t1; DROP DATABASE d1; USE test; SET character_set_server= @safe_character_set_server; diff --git a/mysql-test/r/ctype_uca.result b/mysql-test/r/ctype_uca.result index 91ee427efb4..3d8bd33fb19 100644 --- a/mysql-test/r/ctype_uca.result +++ b/mysql-test/r/ctype_uca.result @@ -2371,6 +2371,17 @@ SELECT c1 as want1result from t1 where c1 like 'location%'; want1result location DROP TABLE t1; +create table t1 (a set('a') not null); +insert into t1 values (),(); +select cast(a as char(1)) from t1; +cast(a as char(1)) + + +select a sounds like a from t1; +a sounds like a +1 +1 +drop table t1; DROP DATABASE d1; USE test; SET character_set_server= @safe_character_set_server; diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index 89a40b15288..90917229769 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -6256,12 +6256,12 @@ my_mb_wc_big5(CHARSET_INFO *cs __attribute__((unused)), my_wc_t *pwc,const uchar *s,const uchar *e) { - int hi=s[0]; + int hi; if (s >= e) return MY_CS_TOOSMALL; - if (hi<0x80) + if ((hi= s[0]) < 0x80) { pwc[0]=hi; return 1; diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c index e8c62b0315e..3752b2e4118 100644 --- a/strings/ctype-cp932.c +++ b/strings/ctype-cp932.c @@ -5352,12 +5352,12 @@ my_wc_mb_cp932(CHARSET_INFO *cs __attribute__((unused)), static int my_mb_wc_cp932(CHARSET_INFO *cs __attribute__((unused)), my_wc_t *pwc, const uchar *s, const uchar *e){ - int hi=s[0]; + int hi; if (s >= e) return MY_CS_TOOSMALL; - if (hi < 0x80) + if ((hi= s[0]) < 0x80) { pwc[0]=hi; return 1; diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c index 25ac416ac60..50300f3c140 100644 --- a/strings/ctype-euc_kr.c +++ b/strings/ctype-euc_kr.c @@ -8614,12 +8614,12 @@ my_mb_wc_euc_kr(CHARSET_INFO *cs __attribute__((unused)), my_wc_t *pwc, const uchar *s, const uchar *e) { - int hi=s[0]; + int hi; if (s >= e) return MY_CS_TOOSMALL; - if (hi<0x80) + if ((hi= s[0]) < 0x80) { pwc[0]=hi; return 1; diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c index 556f485945b..e81f9d3cf0c 100644 --- a/strings/ctype-gb2312.c +++ b/strings/ctype-gb2312.c @@ -5665,12 +5665,10 @@ my_mb_wc_gb2312(CHARSET_INFO *cs __attribute__((unused)), my_wc_t *pwc, const uchar *s, const uchar *e){ int hi; - hi=(int) s[0]; - if (s >= e) return MY_CS_TOOSMALL; - if (hi<0x80) + if ((hi= s[0]) < 0x80) { pwc[0]=hi; return 1; diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index 38a9c9a6428..92d6b4dc2ae 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -4512,12 +4512,12 @@ mb: static int my_mb_wc_sjis(CHARSET_INFO *cs __attribute__((unused)), my_wc_t *pwc, const uchar *s, const uchar *e){ - int hi=s[0]; + int hi; if (s >= e) return MY_CS_TOOSMALL; - if (hi < 0x80) + if ((hi= s[0]) < 0x80) { pwc[0]=hi; return 1; From c623e73e8f8479c0d921025c7fcae1eb8ebd8b27 Mon Sep 17 00:00:00 2001 From: "tnurnberg@sin.intern.azundris.com" <> Date: Thu, 4 Oct 2007 08:27:03 +0200 Subject: [PATCH 080/203] Bug #30444: 5.0 mysqldump silently allows wrong backup to be taken against a 4.0 database The combination of --single-transaction and --master-data requires START TRANSACTION WITH CONSISTENT SNAPSHOT which is available from mysqld 4.1 on. When trying this against an older server, print diagnostic, then, if --force is not given, abort. No test-case given since it would require a mysqld < 4.1. --- client/mysqldump.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/client/mysqldump.c b/client/mysqldump.c index 3bf9fff1b86..a2a03334ba3 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -2428,6 +2428,18 @@ static int start_transaction(MYSQL *mysql_con) need the REPEATABLE READ level (not anything lower, for example READ COMMITTED would give one new consistent read per dumped table). */ + if ((mysql_get_server_version(mysql_con) < 40100) && opt_master_data) + { + fprintf(stderr, "-- %s: the combination of --single-transaction and " + "--master-data requires a MySQL server version of at least 4.1 " + "(current server's version is %s). %s\n", + ignore_errors ? "Warning" : "Error", + mysql_con->server_version ? mysql_con->server_version : "unknown", + ignore_errors ? "Continuing due to --force, backup may not be consistent across all tables!" : "Aborting."); + if (!ignore_errors) + exit(EX_MYSQLERR); + } + return (mysql_query_with_error_report(mysql_con, 0, "SET SESSION TRANSACTION ISOLATION " "LEVEL REPEATABLE READ") || From 16db036d82eba4bbfced502fe271ce863a354c60 Mon Sep 17 00:00:00 2001 From: "holyfoot/hf@mysql.com/hfmain.(none)" <> Date: Thu, 4 Oct 2007 12:01:28 +0500 Subject: [PATCH 081/203] Bug #31155 gis types in union'd select cause crash. We use get_geometry_type() call to decide the exact type of a geometry field to be created (POINT, POLYGON etc) Though this function was only implemented for few items. In the bug's case we need to call this function for the Item_sum instance, where it was not implemented, what is the reason of the crash. Fixed by implementing virtual Item::get_geometry_type(), so it can be called for any Item. --- sql/item.cc | 11 +++-------- sql/item.h | 6 ++++-- sql/item_geofunc.cc | 18 +++++++----------- sql/item_geofunc.h | 7 +++---- 4 files changed, 17 insertions(+), 25 deletions(-) diff --git a/sql/item.cc b/sql/item.cc index e9b2904e3da..997ad0972db 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4364,11 +4364,8 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table) collation.collation); break; // Blob handled outside of case case MYSQL_TYPE_GEOMETRY: - return new Field_geom(max_length, maybe_null, name, table, - (Field::geometry_type) - ((type() == Item::TYPE_HOLDER) ? - ((Item_type_holder *)this)->get_geometry_type() : - ((Item_geometry_func *)this)->get_geometry_type())); + return new Field_geom(max_length, maybe_null, + name, table, get_geometry_type()); } } @@ -6489,9 +6486,7 @@ Item_type_holder::Item_type_holder(THD *thd, Item *item) decimals= 0; prev_decimal_int_part= item->decimal_int_part(); if (item->field_type() == MYSQL_TYPE_GEOMETRY) - geometry_type= (item->type() == Item::FIELD_ITEM) ? - ((Item_field *)item)->get_geometry_type() : - (Field::geometry_type)((Item_geometry_func *)item)->get_geometry_type(); + geometry_type= item->get_geometry_type(); } diff --git a/sql/item.h b/sql/item.h index 3c699c0eda3..3b2df48801b 100644 --- a/sql/item.h +++ b/sql/item.h @@ -870,6 +870,8 @@ public: */ virtual bool result_as_longlong() { return FALSE; } bool is_datetime(); + virtual Field::geometry_type get_geometry_type() const + { return Field::GEOM_GEOMETRY; }; }; @@ -1335,7 +1337,7 @@ public: int fix_outer_field(THD *thd, Field **field, Item **reference); virtual Item *update_value_transformer(byte *select_arg); void print(String *str); - Field::geometry_type get_geometry_type() + Field::geometry_type get_geometry_type() const { DBUG_ASSERT(field_type() == MYSQL_TYPE_GEOMETRY); return field->get_geometry_type(); @@ -2637,7 +2639,7 @@ public: Field *make_field_by_type(TABLE *table); static uint32 display_length(Item *item); static enum_field_types get_real_type(Item *); - Field::geometry_type get_geometry_type() { return geometry_type; }; + Field::geometry_type get_geometry_type() const { return geometry_type; }; }; diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index 6c012277888..966cefea9fe 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -27,7 +27,7 @@ Field *Item_geometry_func::tmp_table_field(TABLE *t_arg) { return new Field_geom(max_length, maybe_null, name, t_arg, - (Field::geometry_type) get_geometry_type()); + get_geometry_type()); } void Item_geometry_func::fix_length_and_dec() @@ -38,10 +38,6 @@ void Item_geometry_func::fix_length_and_dec() maybe_null= 1; } -int Item_geometry_func::get_geometry_type() const -{ - return (int)Field::GEOM_GEOMETRY; -} String *Item_func_geometry_from_text::val_str(String *str) { @@ -160,9 +156,9 @@ String *Item_func_geometry_type::val_str(String *str) } -int Item_func_envelope::get_geometry_type() const +Field::geometry_type Item_func_envelope::get_geometry_type() const { - return (int) Field::GEOM_POLYGON; + return Field::GEOM_POLYGON; } @@ -190,9 +186,9 @@ String *Item_func_envelope::val_str(String *str) } -int Item_func_centroid::get_geometry_type() const +Field::geometry_type Item_func_centroid::get_geometry_type() const { - return (int) Field::GEOM_POINT; + return Field::GEOM_POINT; } @@ -330,9 +326,9 @@ err: */ -int Item_func_point::get_geometry_type() const +Field::geometry_type Item_func_point::get_geometry_type() const { - return (int) Field::GEOM_POINT; + return Field::GEOM_POINT; } diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h index 9c7970f9e53..e99510f762f 100644 --- a/sql/item_geofunc.h +++ b/sql/item_geofunc.h @@ -33,7 +33,6 @@ public: void fix_length_and_dec(); enum_field_types field_type() const { return MYSQL_TYPE_GEOMETRY; } Field *tmp_table_field(TABLE *t_arg); - virtual int get_geometry_type() const; bool is_null() { (void) val_int(); return null_value; } }; @@ -92,7 +91,7 @@ public: Item_func_centroid(Item *a): Item_geometry_func(a) {} const char *func_name() const { return "centroid"; } String *val_str(String *); - int get_geometry_type() const; + Field::geometry_type get_geometry_type() const; }; class Item_func_envelope: public Item_geometry_func @@ -101,7 +100,7 @@ public: Item_func_envelope(Item *a): Item_geometry_func(a) {} const char *func_name() const { return "envelope"; } String *val_str(String *); - int get_geometry_type() const; + Field::geometry_type get_geometry_type() const; }; class Item_func_point: public Item_geometry_func @@ -111,7 +110,7 @@ public: Item_func_point(Item *a, Item *b, Item *srid): Item_geometry_func(a, b, srid) {} const char *func_name() const { return "point"; } String *val_str(String *); - int get_geometry_type() const; + Field::geometry_type get_geometry_type() const; }; class Item_func_spatial_decomp: public Item_geometry_func From 6e6727d24480effb2fe401bab970ad12f80ca7fe Mon Sep 17 00:00:00 2001 From: "ramil/ram@mysql.com/ramil.myoffice.izhnet.ru" <> Date: Thu, 4 Oct 2007 12:09:22 +0500 Subject: [PATCH 082/203] merging: results adjusted --- mysql-test/r/ctype_big5.result | 2 ++ mysql-test/r/ctype_euckr.result | 2 ++ mysql-test/r/ctype_gb2312.result | 2 ++ mysql-test/r/ctype_gbk.result | 2 ++ mysql-test/r/ctype_uca.result | 2 ++ 5 files changed, 10 insertions(+) diff --git a/mysql-test/r/ctype_big5.result b/mysql-test/r/ctype_big5.result index 485b6ec00ae..b190273cc64 100644 --- a/mysql-test/r/ctype_big5.result +++ b/mysql-test/r/ctype_big5.result @@ -54,6 +54,8 @@ location DROP TABLE t1; create table t1 (a set('a') not null); insert into t1 values (),(); +Warnings: +Warning 1364 Field 'a' doesn't have a default value select cast(a as char(1)) from t1; cast(a as char(1)) diff --git a/mysql-test/r/ctype_euckr.result b/mysql-test/r/ctype_euckr.result index 2d9f8d217e6..b9619370d4c 100644 --- a/mysql-test/r/ctype_euckr.result +++ b/mysql-test/r/ctype_euckr.result @@ -54,6 +54,8 @@ location DROP TABLE t1; create table t1 (a set('a') not null); insert into t1 values (),(); +Warnings: +Warning 1364 Field 'a' doesn't have a default value select cast(a as char(1)) from t1; cast(a as char(1)) diff --git a/mysql-test/r/ctype_gb2312.result b/mysql-test/r/ctype_gb2312.result index 04c318e83a8..90c94c3b299 100644 --- a/mysql-test/r/ctype_gb2312.result +++ b/mysql-test/r/ctype_gb2312.result @@ -54,6 +54,8 @@ location DROP TABLE t1; create table t1 (a set('a') not null); insert into t1 values (),(); +Warnings: +Warning 1364 Field 'a' doesn't have a default value select cast(a as char(1)) from t1; cast(a as char(1)) diff --git a/mysql-test/r/ctype_gbk.result b/mysql-test/r/ctype_gbk.result index bc717736e3e..fe90c7bff29 100644 --- a/mysql-test/r/ctype_gbk.result +++ b/mysql-test/r/ctype_gbk.result @@ -54,6 +54,8 @@ location DROP TABLE t1; create table t1 (a set('a') not null); insert into t1 values (),(); +Warnings: +Warning 1364 Field 'a' doesn't have a default value select cast(a as char(1)) from t1; cast(a as char(1)) diff --git a/mysql-test/r/ctype_uca.result b/mysql-test/r/ctype_uca.result index 8a4f0fd3698..e676d5a5ca0 100644 --- a/mysql-test/r/ctype_uca.result +++ b/mysql-test/r/ctype_uca.result @@ -2589,6 +2589,8 @@ location DROP TABLE t1; create table t1 (a set('a') not null); insert into t1 values (),(); +Warnings: +Warning 1364 Field 'a' doesn't have a default value select cast(a as char(1)) from t1; cast(a as char(1)) From 028992ac694eaef99653f3efe0f74ace22828261 Mon Sep 17 00:00:00 2001 From: "mhansson/martin@linux-st28.site" <> Date: Thu, 4 Oct 2007 09:15:26 +0200 Subject: [PATCH 083/203] Bug #30942: select str_to_date from derived table returns varying results The function str_to_date has a field to say whether it's invoked constant arguments. But this member was not initialized, causing the function to think that it could use a cache of the format type when said cache was in fact not initialized. Fixed by initializing the field to false. --- mysql-test/r/type_date.result | 10 ++++++++++ mysql-test/t/type_date.test | 13 +++++++++++++ sql/item_timefunc.h | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result index 9f51fc0371c..53fe9710eba 100644 --- a/mysql-test/r/type_date.result +++ b/mysql-test/r/type_date.result @@ -136,3 +136,13 @@ d dt ts 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 2001-11-11 2001-11-11 00:00:00 2001-11-11 00:00:00 drop table t1; +CREATE TABLE t1 ( +a INT +); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (NULL); +SELECT str_to_date( '', a ) FROM t1; +str_to_date( '', a ) +0000-00-00 00:00:00 +NULL +DROP TABLE t1; diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test index 02cd07e3c16..aeb88f3acc2 100644 --- a/mysql-test/t/type_date.test +++ b/mysql-test/t/type_date.test @@ -136,3 +136,16 @@ insert into t1 values (9912101,9912101,9912101); insert into t1 values (11111,11111,11111); select * from t1; drop table t1; + +# +# Bug #30942: select str_to_date from derived table returns varying results +# +CREATE TABLE t1 ( + a INT +); + +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (NULL); + +SELECT str_to_date( '', a ) FROM t1; +DROP TABLE t1; diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 8e925a0156f..cb69bd200e6 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -1030,7 +1030,7 @@ class Item_func_str_to_date :public Item_str_func bool const_item; public: Item_func_str_to_date(Item *a, Item *b) - :Item_str_func(a, b) + :Item_str_func(a, b), const_item(false) {} String *val_str(String *str); bool get_date(MYSQL_TIME *ltime, uint fuzzy_date); From 1ba3f4f56b57bcf6266beae20da6a06eda436964 Mon Sep 17 00:00:00 2001 From: "kaa@polly.(none)" <> Date: Thu, 4 Oct 2007 12:34:00 +0400 Subject: [PATCH 084/203] Issue a warning if a user sets an option or a variable to a value that is greater than a defined maximum for the option/variable. This is for bug #29446 "Specifying a myisam_sort_buffer > 4GB on 64 bit machines not possible". Support for myisam_sort_buffer_size > 4 GB on 64-bit Windows will be looked at later in 5.2. --- mysql-test/r/variables.result | 2 ++ mysql-test/t/variables.test | 1 + mysys/my_getopt.c | 16 ++++++++++++++++ sql/set_var.cc | 15 +++++++++++++++ 4 files changed, 34 insertions(+) diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 3d76f8e4a90..9e52fbeac1a 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -218,6 +218,8 @@ show variables like 'net_buffer_length'; Variable_name Value net_buffer_length 1024 set net_buffer_length=2000000000; +Warnings: +Warning 1292 Truncated incorrect net_buffer_length value: '2000000000' show variables like 'net_buffer_length'; Variable_name Value net_buffer_length 1048576 diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 0ad85a32568..ccd487a72ea 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -139,6 +139,7 @@ show global variables like 'net_%'; show session variables like 'net_%'; set net_buffer_length=1; show variables like 'net_buffer_length'; +--warning 1292 set net_buffer_length=2000000000; show variables like 'net_buffer_length'; diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 623c48b2e55..71630e1b4c2 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -19,6 +19,7 @@ #include #include #include +#include static void default_reporter(enum loglevel level, const char *format, ...); my_error_reporter my_getopt_error_reporter= &default_reporter; @@ -693,7 +694,15 @@ static longlong eval_num_suffix (char *argument, int *error, char *option_name) longlong num; *error= 0; + errno= 0; num= strtoll(argument, &endchar, 10); + if (errno == ERANGE) + { + my_getopt_error_reporter(ERROR_LEVEL, + "Incorrect integer value: '%s'", argument); + *error= 1; + return 0; + } if (*endchar == 'k' || *endchar == 'K') num*= 1024L; else if (*endchar == 'm' || *endchar == 'M') @@ -730,7 +739,14 @@ static longlong getopt_ll(char *arg, const struct my_option *optp, int *err) num= eval_num_suffix(arg, err, (char*) optp->name); if (num > 0 && (ulonglong) num > (ulonglong) optp->max_value && optp->max_value) /* if max value is not set -> no upper limit */ + { + char buf[22]; + my_getopt_error_reporter(WARNING_LEVEL, + "Truncated incorrect %s value: '%s'", + optp->name, llstr(num, buf)); + num= (ulonglong) optp->max_value; + } num= ((num - optp->sub_size) / block_size); num= (longlong) (num * block_size); return max(num, optp->min_value); diff --git a/sql/set_var.cc b/sql/set_var.cc index e1246617d84..5c76019efc6 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1532,16 +1532,31 @@ bool sys_var_thd_ulong::check(THD *thd, set_var *var) bool sys_var_thd_ulong::update(THD *thd, set_var *var) { ulonglong tmp= var->save_result.ulonglong_value; + char buf[22]; + bool truncated= false; /* Don't use bigger value than given with --maximum-variable-name=.. */ if ((ulong) tmp > max_system_variables.*offset) + { + truncated= true; + llstr(tmp, buf); tmp= max_system_variables.*offset; + } #if SIZEOF_LONG == 4 /* Avoid overflows on 32 bit systems */ if (tmp > (ulonglong) ~(ulong) 0) + { + truncated= true; + llstr(tmp, buf); tmp= ((ulonglong) ~(ulong) 0); + } #endif + if (truncated) + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_TRUNCATED_WRONG_VALUE, + ER(ER_TRUNCATED_WRONG_VALUE), name, + buf); if (option_limits) tmp= (ulong) getopt_ull_limit_value(tmp, option_limits); From f74d805e16e2bb6c277f6ea7357686dcef77378f Mon Sep 17 00:00:00 2001 From: "kaa@polly.(none)" <> Date: Thu, 4 Oct 2007 14:22:35 +0400 Subject: [PATCH 085/203] Backport of the 5.0 patch to 4.1 Bug#28878: InnoDB tables with UTF8 character set and indexes cause wrong result for DML When making key reference buffers over CHAR fields whitespace (0x20) must be used to fill in the remaining space in the field's buffer. This is what Field_string::store() does. Fixed Field_string::get_key_image() to do the same. --- mysql-test/r/innodb_mysql.result | 36 ++++++++++++++++++++++++++++++++ mysql-test/t/innodb_mysql.test | 32 ++++++++++++++++++++++++++++ sql/field.cc | 3 ++- 3 files changed, 70 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index 029f3768f9b..93b93c6253c 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -182,4 +182,40 @@ t1.a4='UNcT5pIde4I6c2SheTo4gt92OV1jgJCVkXmzyf325R1DwLURkbYHwhydANIZMbKTgdcR5xS'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables DROP TABLE t1; +CREATE TABLE t1 (a CHAR(2), KEY (a)) ENGINE = InnoDB DEFAULT CHARSET=UTF8; +INSERT INTO t1 VALUES ('uk'),('bg'); +SELECT * FROM t1 WHERE a = 'uk'; +a +uk +DELETE FROM t1 WHERE a = 'uk'; +SELECT * FROM t1 WHERE a = 'uk'; +a +UPDATE t1 SET a = 'us' WHERE a = 'uk'; +SELECT * FROM t1 WHERE a = 'uk'; +a +CREATE TABLE t2 (a CHAR(2), KEY (a)) ENGINE = InnoDB; +INSERT INTO t2 VALUES ('uk'),('bg'); +SELECT * FROM t2 WHERE a = 'uk'; +a +uk +DELETE FROM t2 WHERE a = 'uk'; +SELECT * FROM t2 WHERE a = 'uk'; +a +INSERT INTO t2 VALUES ('uk'); +UPDATE t2 SET a = 'us' WHERE a = 'uk'; +SELECT * FROM t2 WHERE a = 'uk'; +a +CREATE TABLE t3 (a CHAR(2), KEY (a)) ENGINE = MyISAM; +INSERT INTO t3 VALUES ('uk'),('bg'); +SELECT * FROM t3 WHERE a = 'uk'; +a +uk +DELETE FROM t3 WHERE a = 'uk'; +SELECT * FROM t3 WHERE a = 'uk'; +a +INSERT INTO t3 VALUES ('uk'); +UPDATE t3 SET a = 'us' WHERE a = 'uk'; +SELECT * FROM t3 WHERE a = 'uk'; +a +DROP TABLE t1,t2,t3; End of 4.1 tests diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test index b5e7fc6e405..4e20535549a 100644 --- a/mysql-test/t/innodb_mysql.test +++ b/mysql-test/t/innodb_mysql.test @@ -216,4 +216,36 @@ t1.a4='UNcT5pIde4I6c2SheTo4gt92OV1jgJCVkXmzyf325R1DwLURkbYHwhydANIZMbKTgdcR5xS'; DROP TABLE t1; +# +# Bug #28878: InnoDB tables with UTF8 character set and indexes cause wrong result for DML +# + +CREATE TABLE t1 (a CHAR(2), KEY (a)) ENGINE = InnoDB DEFAULT CHARSET=UTF8; +INSERT INTO t1 VALUES ('uk'),('bg'); +SELECT * FROM t1 WHERE a = 'uk'; +DELETE FROM t1 WHERE a = 'uk'; +SELECT * FROM t1 WHERE a = 'uk'; +UPDATE t1 SET a = 'us' WHERE a = 'uk'; +SELECT * FROM t1 WHERE a = 'uk'; + +CREATE TABLE t2 (a CHAR(2), KEY (a)) ENGINE = InnoDB; +INSERT INTO t2 VALUES ('uk'),('bg'); +SELECT * FROM t2 WHERE a = 'uk'; +DELETE FROM t2 WHERE a = 'uk'; +SELECT * FROM t2 WHERE a = 'uk'; +INSERT INTO t2 VALUES ('uk'); +UPDATE t2 SET a = 'us' WHERE a = 'uk'; +SELECT * FROM t2 WHERE a = 'uk'; + +CREATE TABLE t3 (a CHAR(2), KEY (a)) ENGINE = MyISAM; +INSERT INTO t3 VALUES ('uk'),('bg'); +SELECT * FROM t3 WHERE a = 'uk'; +DELETE FROM t3 WHERE a = 'uk'; +SELECT * FROM t3 WHERE a = 'uk'; +INSERT INTO t3 VALUES ('uk'); +UPDATE t3 SET a = 'us' WHERE a = 'uk'; +SELECT * FROM t3 WHERE a = 'uk'; + +DROP TABLE t1,t2,t3; + --echo End of 4.1 tests diff --git a/sql/field.cc b/sql/field.cc index 1b27e12e078..5b43b9b1955 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5211,7 +5211,8 @@ uint Field_string::get_key_image(char *buff, uint length, CHARSET_INFO *cs, length / field_charset->mbmaxlen); memcpy(buff, ptr, bytes); if (bytes < length) - bzero(buff + bytes, length - bytes); + field_charset->cset->fill(field_charset, buff + bytes, length - bytes, + ' '); return bytes; } From e2614270c394cd9942dc32bf0021a1b2d9ce3eeb Mon Sep 17 00:00:00 2001 From: "gluh@mysql.com/eagle.(none)" <> Date: Thu, 4 Oct 2007 15:35:45 +0500 Subject: [PATCH 086/203] after merge fix --- client/client_priv.h | 5 +- client/mysqldump.c | 2 +- mysql-test/r/mysqldump.result | 175 ++++++--------------------------- mysql-test/r/view_grant.result | 24 ++--- 4 files changed, 45 insertions(+), 161 deletions(-) diff --git a/client/client_priv.h b/client/client_priv.h index 1414de2aa67..c205d07c34c 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -80,7 +80,6 @@ enum options_client OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT, OPT_SERVER_ID, OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT, OPT_DEBUG_INFO, OPT_DEBUG_CHECK, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE, - OPT_WRITE_BINLOG, OPT_MAX_CLIENT_OPTION, - OPT_TZ_UTC, OPT_AUTO_CLOSE, OPT_SSL_VERIFY_SERVER_CERT, - OPT_DEBUG_INFO, OPT_ERROR_LOG_FILE, OPT_DUMP_DATE + OPT_WRITE_BINLOG, OPT_DUMP_DATE, + OPT_MAX_CLIENT_OPTION }; diff --git a/client/mysqldump.c b/client/mysqldump.c index 03265fbf5a3..2b463552dd5 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -425,7 +425,7 @@ static struct my_option my_long_options[] = (uchar**) &opt_single_transaction, (uchar**) &opt_single_transaction, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"dump-date", OPT_DUMP_DATE, "Put a dump date to the end of the output.", - (gptr*) &opt_dump_date, (gptr*) &opt_dump_date, 0, + (uchar**) &opt_dump_date, (uchar**) &opt_dump_date, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"skip-opt", OPT_SKIP_OPTIMIZATION, "Disable --opt. Disables --add-drop-table, --add-locks, --create-options, --quick, --extended-insert, --lock-tables, --set-charset, and --disable-keys.", diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 522e6cc1442..c0856314ba5 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -516,7 +516,7 @@ drop database mysqldump_test_db; # --default-character-set=xxx. However, we should dump in UTF8 # if it is explicitely set. CREATE TABLE t1 (a CHAR(10)); -INSERT INTO t1 VALUES (_latin1 'ÄÖÜß'); +INSERT INTO t1 VALUES (_latin1 'ÄÖÜß'); /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -574,7 +574,7 @@ SET character_set_client = @saved_cs_client; LOCK TABLES `t1` WRITE; /*!40000 ALTER TABLE `t1` DISABLE KEYS */; -INSERT INTO `t1` VALUES ('Ž™šá'); +INSERT INTO `t1` VALUES ('Ž™šá'); /*!40000 ALTER TABLE `t1` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -600,7 +600,7 @@ SET character_set_client = @saved_cs_client; LOCK TABLES `t1` WRITE; /*!40000 ALTER TABLE `t1` DISABLE KEYS */; -INSERT INTO `t1` VALUES ('Ž™šá'); +INSERT INTO `t1` VALUES ('Ž™šá'); /*!40000 ALTER TABLE `t1` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -1739,11 +1739,11 @@ create table t1 (a text character set utf8, b text character set latin1); insert t1 values (0x4F736E616272C3BC636B, 0x4BF66C6E); select * from t1; a b -Osnabrück Köln +Osnabrück Köln test.t1: Records: 1 Deleted: 0 Skipped: 0 Warnings: 0 select * from t1; a b -Osnabrück Köln +Osnabrück Köln drop table t1; # # BUG#15328 Segmentation fault occured if my.cnf is invalid for escape sequence @@ -3805,6 +3805,28 @@ c1 2 DROP TABLE t1,t2; # +# Bug#29815: new option for suppressing last line of mysqldump: +# "Dump completed on" +# +# --skip-dump-date: +-- + + + +-- Dump completed +# --dump-date: +-- + + + +-- Dump completed on DATE +# --dump-date (default): +-- + + + +-- Dump completed on DATE +# # End of 5.0 tests # drop table if exists t1; @@ -3848,145 +3870,6 @@ UNLOCK TABLES; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; DROP TABLE t1; - `a` int(11) default NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t2`,`t3`); -SET character_set_client = @saved_cs_client; -DROP TABLE IF EXISTS `t2`; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -CREATE TABLE `t2` ( - `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1; -SET character_set_client = @saved_cs_client; - -LOCK TABLES `t2` WRITE; -/*!40000 ALTER TABLE `t2` DISABLE KEYS */; -/*!40000 ALTER TABLE `t2` ENABLE KEYS */; -UNLOCK TABLES; -DROP TABLE IF EXISTS `t3`; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -CREATE TABLE `t3` ( - `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1; -SET character_set_client = @saved_cs_client; - -LOCK TABLES `t3` WRITE; -/*!40000 ALTER TABLE `t3` DISABLE KEYS */; -/*!40000 ALTER TABLE `t3` ENABLE KEYS */; -UNLOCK TABLES; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - -DROP TABLE t1, t2, t3; -# -# Bug #23491: MySQLDump prefix function call in a view by database name -# -create database bug23491_original; -create database bug23491_restore; -use bug23491_original; -create table t1 (c1 int); -create view v1 as select * from t1; -create procedure p1() select 1; -create function f1() returns int return 1; -create view v2 as select f1(); -create function f2() returns int return f1(); -create view v3 as select bug23491_original.f1(); -use bug23491_restore; -show create view bug23491_restore.v2; -View Create View -v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `f1`() AS `f1()` -show create view bug23491_restore.v3; -View Create View -v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `bug23491_original`.`f1`() AS `bug23491_original.f1()` -drop database bug23491_original; -drop database bug23491_restore; -use test; -# -# Bug 27293: mysqldump crashes when dumping routines -# defined by a different user -# -# Bug #22761: mysqldump reports no errors when using -# --routines without mysql.proc privileges -# -create database mysqldump_test_db; -grant all privileges on mysqldump_test_db.* to user1; -grant all privileges on mysqldump_test_db.* to user2; -create procedure mysqldump_test_db.sp1() select 'hello'; - -/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/; -DELIMITER ;; - --- insufficient privileges to SHOW CREATE PROCEDURE `sp1` --- does user2 have permissions on mysql.proc? - -DELIMITER ; - -/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/; -DELIMITER ;; -/*!50003 SET SESSION SQL_MODE=""*/;; -/*!50003 CREATE*/ /*!50020 DEFINER=`user1`@`%`*/ /*!50003 PROCEDURE `sp1`() -select 'hello' */;; -/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;; -DELIMITER ; -drop procedure sp1; -drop user user1; -drop user user2; -drop database mysqldump_test_db; -# -# Bug #28522: buffer overrun by '\0' byte using --hex-blob. -# -CREATE TABLE t1 (c1 INT, c2 LONGBLOB); -INSERT INTO t1 SET c1=11, c2=REPEAT('q',509); -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -CREATE TABLE `t1` ( - `c1` int(11) default NULL, - `c2` longblob -); -SET character_set_client = @saved_cs_client; -INSERT INTO `t1` VALUES (11,0x7171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171); -DROP TABLE t1; -# -# Bug #28524: mysqldump --skip-add-drop-table is not -# compatible with views -# -CREATE VIEW v1 AS SELECT 1; -DROP VIEW v1; -SELECT * FROM v1; -1 -1 -DROP VIEW v1; -# -# Bug #29788: mysqldump discards the NO_AUTO_VALUE_ON_ZERO value of -# the SQL_MODE variable after the dumping of triggers. -# -CREATE TABLE t1 (c1 INT); -CREATE TRIGGER t1bd BEFORE DELETE ON t1 FOR EACH ROW BEGIN END; -CREATE TABLE t2 (c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY); -SET @TMP_SQL_MODE = @@SQL_MODE; -SET SQL_MODE = 'NO_AUTO_VALUE_ON_ZERO'; -INSERT INTO t2 VALUES (0), (1), (2); -SET SQL_MODE = @TMP_SQL_MODE; -SELECT * FROM t2; -c1 -0 -1 -2 -SELECT * FROM t2; -c1 -0 -1 -2 -DROP TABLE t1,t2; -# create table t1 (a text , b text); create table t2 (a text , b text); insert t1 values ("Duck, Duck", "goose"); @@ -4292,8 +4175,8 @@ DROP DATABASE IF EXISTS mysqldump_test_db; # Create objects. CREATE DATABASE mysqldump_test_db; set names koi8r; -CREATE VIEW mysqldump_test_db.v2 AS SELECT 1 AS ËÃÃŒÃÎËÃ1; -CREATE VIEW mysqldump_test_db.v1 AS SELECT ËÃÃŒÃÎËÃ1 FROM mysqldump_test_db.v2; +CREATE VIEW mysqldump_test_db.v2 AS SELECT 1 AS ËÏÌÏÎËÁ1; +CREATE VIEW mysqldump_test_db.v1 AS SELECT ËÏÌÏÎËÁ1 FROM mysqldump_test_db.v2; set names latin1; # Dump mysqldump_test_db to bug30027.sql. diff --git a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result index 8b4aa894130..c301953f508 100644 --- a/mysql-test/r/view_grant.result +++ b/mysql-test/r/view_grant.result @@ -785,7 +785,7 @@ ALTER VIEW v3 AS SELECT f2 FROM t1; ERROR 42000: Access denied; you need the SUPER privilege for this operation SHOW CREATE VIEW v3; View Create View character_set_client collation_connection -v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`f2` AS `f2` from `t1` latin1 latin1_swedish_ci +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`f1` AS `f1` from `t1` latin1 latin1_swedish_ci DROP USER u26813@localhost; DROP DATABASE db26813; # @@ -810,24 +810,24 @@ ERROR 42000: Access denied; you need the SUPER privilege for this operation ALTER VIEW v2 AS SELECT f2 FROM t1; ERROR 42000: Access denied; you need the SUPER privilege for this operation SHOW CREATE VIEW v2; -View Create View -v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f1` AS `f1` from `t1` +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f1` AS `f1` from `t1` latin1 latin1_swedish_ci ALTER VIEW v1 AS SELECT f2 FROM t1; SHOW CREATE VIEW v1; -View Create View -v1 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f2` AS `f2` from `t1` +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f2` AS `f2` from `t1` latin1 latin1_swedish_ci ALTER VIEW v2 AS SELECT f2 FROM t1; SHOW CREATE VIEW v2; -View Create View -v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f2` AS `f2` from `t1` +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f2` AS `f2` from `t1` latin1 latin1_swedish_ci ALTER VIEW v1 AS SELECT f1 FROM t1; SHOW CREATE VIEW v1; -View Create View -v1 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f1` AS `f1` from `t1` +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f1` AS `f1` from `t1` latin1 latin1_swedish_ci ALTER VIEW v2 AS SELECT f1 FROM t1; SHOW CREATE VIEW v2; -View Create View -v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f1` AS `f1` from `t1` +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f1` AS `f1` from `t1` latin1 latin1_swedish_ci DROP USER u29908_1@localhost; DROP USER u29908_2@localhost; DROP DATABASE mysqltest_29908; @@ -938,6 +938,8 @@ v1 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such`@`user_1` SQL SECURITY DEFINER VI Warnings: Warning 1356 View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them ALTER ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1; +Warnings: +Note 1449 There is no 'no_such'@'user_1' registered SHOW CREATE VIEW v1; View Create View character_set_client collation_connection v1 CREATE ALGORITHM=MERGE DEFINER=`no_such`@`user_1` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci From d6e626a61d186e3f7e1b59f8b3d039d667c7a577 Mon Sep 17 00:00:00 2001 From: "gluh@mysql.com/eagle.(none)" <> Date: Thu, 4 Oct 2007 16:20:56 +0500 Subject: [PATCH 087/203] Bug#30079 A check for "hidden" I_S tables is flawed added check for hidden I_S tables for 'show columns|keys' commands --- mysql-test/r/information_schema.result | 4 ++++ mysql-test/t/information_schema.test | 9 +++++++++ sql/sql_parse.cc | 7 ++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index cf82cdd31bd..8c1a1e67443 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1386,3 +1386,7 @@ f7 datetime NO NULL f8 datetime YES 2006-01-01 00:00:00 drop table t1; End of 5.0 tests. +show fields from information_schema.TABLE_NAMES; +ERROR 42S02: Unknown table 'TABLE_NAMES' in information_schema +show keys from information_schema.TABLE_NAMES; +ERROR 42S02: Unknown table 'TABLE_NAMES' in information_schema diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index e9a06c7186e..684deef120e 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1089,3 +1089,12 @@ show columns from t1; drop table t1; --echo End of 5.0 tests. + +# +# Bug#30079 A check for "hidden" I_S tables is flawed +# +--error 1109 +show fields from information_schema.TABLE_NAMES; +--error 1109 +show keys from information_schema.TABLE_NAMES; + diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 084bcfc3c76..52f8fe8615f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -6427,7 +6427,12 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, ST_SCHEMA_TABLE *schema_table= find_schema_table(thd, ptr->table_name); if (!schema_table || (schema_table->hidden && - lex->orig_sql_command == SQLCOM_END)) // not a 'show' command + (lex->orig_sql_command == SQLCOM_END || // not a 'show' command + /* + this check is used for show columns|keys from I_S hidden table + */ + lex->orig_sql_command == SQLCOM_SHOW_FIELDS || + lex->orig_sql_command == SQLCOM_SHOW_KEYS))) { my_error(ER_UNKNOWN_TABLE, MYF(0), ptr->table_name, INFORMATION_SCHEMA_NAME.str); From ce2430bcb6421842be1a5b28509ad70aa51fea1b Mon Sep 17 00:00:00 2001 From: "gluh@mysql.com/eagle.(none)" <> Date: Thu, 4 Oct 2007 17:08:59 +0500 Subject: [PATCH 088/203] after merge fix --- sql/sql_parse.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 011ba463b5b..4204e9ec881 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5770,8 +5770,8 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, /* this check is used for show columns|keys from I_S hidden table */ - lex->orig_sql_command == SQLCOM_SHOW_FIELDS || - lex->orig_sql_command == SQLCOM_SHOW_KEYS))) + lex->sql_command == SQLCOM_SHOW_FIELDS || + lex->sql_command == SQLCOM_SHOW_KEYS))) { my_error(ER_UNKNOWN_TABLE, MYF(0), ptr->table_name, INFORMATION_SCHEMA_NAME.str); From 8edc46ff168ea2e8f8a6b89175554bc1f4de2cb7 Mon Sep 17 00:00:00 2001 From: "mattiasj@mattiasj-laptop.(none)" <> Date: Thu, 4 Oct 2007 14:56:33 +0200 Subject: [PATCH 089/203] Bug #30484: Partitions: crash with self-referencing trigger Two cases in ha_partition::extra() was missing (HA_EXTRA_DELETE_CANNOT_BATCH and HA_EXTRA_UPDATE_CANNOT_BATCH) which only is currently used by NDB (which not uses ha_partition) --- mysql-test/r/partition.result | 4 ++++ mysql-test/t/partition.test | 9 +++++++++ sql/ha_partition.cc | 18 ++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 5d985d053fc..f90f3b07d70 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -1259,6 +1259,10 @@ INSERT INTO t1 SELECT a + 8, b FROM t1; ALTER TABLE t1 ADD PARTITION (PARTITION p1 VALUES LESS THAN (64)); ALTER TABLE t1 DROP PARTITION p1; DROP TABLE t1; +create table t (s1 int) engine=myisam partition by key (s1); +create trigger t_ad after delete on t for each row insert into t values (old.s1); +insert into t values (1); +drop table t; USE mysql; SET GLOBAL general_log = 0; ALTER TABLE general_log ENGINE = MyISAM; diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 42db23dadef..f391237a4db 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -1480,6 +1480,15 @@ ALTER TABLE t1 DROP PARTITION p1; DROP TABLE t1; +# +# Bug #30484: Partitions: crash with self-referencing trigger +# + +create table t (s1 int) engine=myisam partition by key (s1); +create trigger t_ad after delete on t for each row insert into t values (old.s1); +insert into t values (1); +drop table t; + # # Bug #27816: Log tables ran with partitions crashes the server when logging # is enabled. diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 1ea3bb34514..6c1c89c4a04 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -4546,6 +4546,8 @@ void ha_partition::get_dynamic_partition_info(PARTITION_INFO *stat_info, 4) Parameters only used by temporary tables for query processing 5) Parameters only used by MyISAM internally 6) Parameters not used at all + 7) Parameters only used by federated tables for query processing + 8) Parameters only used by NDB The partition handler need to handle category 1), 2) and 3). @@ -4812,6 +4814,15 @@ void ha_partition::get_dynamic_partition_info(PARTITION_INFO *stat_info, HA_EXTRA_INSERT_WITH_UPDATE: Inform handler that an "INSERT...ON DUPLICATE KEY UPDATE" will be executed. This condition is unset by HA_EXTRA_NO_IGNORE_DUP_KEY. + + 8) Parameters only used by NDB + ------------------------------ + HA_EXTRA_DELETE_CANNOT_BATCH: + HA_EXTRA_UPDATE_CANNOT_BATCH: + Inform handler that delete_row()/update_row() cannot batch deletes/updates + and should perform them immediately. This may be needed when table has + AFTER DELETE/UPDATE triggers which access to subject table. + These flags are reset by the handler::extra(HA_EXTRA_RESET) call. */ int ha_partition::extra(enum ha_extra_function operation) @@ -4896,6 +4907,13 @@ int ha_partition::extra(enum ha_extra_function operation) /* Category 7), used by federated handlers */ case HA_EXTRA_INSERT_WITH_UPDATE: DBUG_RETURN(loop_extra(operation)); + /* Category 8) Parameters only used by NDB */ + case HA_EXTRA_DELETE_CANNOT_BATCH: + case HA_EXTRA_UPDATE_CANNOT_BATCH: + { + /* Currently only NDB use the *_CANNOT_BATCH */ + break; + } default: { /* Temporary crash to discover what is wrong */ From 707f067446939f8e00ac22fc1c07d62846737193 Mon Sep 17 00:00:00 2001 From: "anozdrin/alik@station." <> Date: Thu, 4 Oct 2007 17:19:14 +0400 Subject: [PATCH 090/203] Fix for BUG#31035: select from function, group by result crasher. This actually, fix for the patch for bug-27354. The problem with the patch was that Item_func_sp::used_tables() was updated, but Item_func_sp::const_item() was not. So, for Item_func_sp, we had the following inconsistency: - used_tables() returned RAND_TABLE, which means that the item can produce "random" results; - but const_item() returned TRUE, which means that the item is a constant one. The fix is to change Item_func_sp::const_item() behaviour: it must return TRUE (an item is a constant one) only if a stored function is deterministic and each of its arguments (if any) is a constant item. --- mysql-test/r/sp.result | 176 +++++++++++++++++++++++++ mysql-test/t/sp.test | 290 +++++++++++++++++++++++++++++++++++++++++ sql/item_func.cc | 13 +- 3 files changed, 477 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index a6c429a31fb..efc12b402ce 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -6367,4 +6367,180 @@ DROP TABLE t1; DROP PROCEDURE p1; DROP PROCEDURE p2; + +# +# Bug#31035. +# + +# +# - Prepare. +# + +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; +DROP FUNCTION IF EXISTS f3; +DROP FUNCTION IF EXISTS f4; + +# +# - Create required objects. +# + +CREATE TABLE t1(c1 INT); + +INSERT INTO t1 VALUES (1), (2), (3); + +CREATE FUNCTION f1() +RETURNS INT +NOT DETERMINISTIC +RETURN 1; + +CREATE FUNCTION f2(p INT) +RETURNS INT +NOT DETERMINISTIC +RETURN 1; + +CREATE FUNCTION f3() +RETURNS INT +DETERMINISTIC +RETURN 1; + +CREATE FUNCTION f4(p INT) +RETURNS INT +DETERMINISTIC +RETURN 1; + +# +# - Check. +# + +SELECT f1() AS a FROM t1 GROUP BY a; +a +1 + +SELECT f2(@a) AS a FROM t1 GROUP BY a; +a +1 + +SELECT f3() AS a FROM t1 GROUP BY a; +a +1 + +SELECT f4(0) AS a FROM t1 GROUP BY a; +a +1 + +SELECT f4(@a) AS a FROM t1 GROUP BY a; +a +1 + +# +# - Cleanup. +# + +DROP TABLE t1; +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +DROP FUNCTION f4; + +# +# Bug#31191. +# + +# +# - Prepare. +# + +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +DROP FUNCTION IF EXISTS f1; + +# +# - Create required objects. +# + +CREATE TABLE t1 ( +id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +barcode INT(8) UNSIGNED ZEROFILL nOT NULL, +PRIMARY KEY (id), +UNIQUE KEY barcode (barcode) +); + +INSERT INTO t1 (id, barcode) VALUES (1, 12345678); +INSERT INTO t1 (id, barcode) VALUES (2, 12345679); + +CREATE TABLE test.t2 ( +id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +barcode BIGINT(11) UNSIGNED ZEROFILL NOT NULL, +PRIMARY KEY (id) +); + +INSERT INTO test.t2 (id, barcode) VALUES (1, 12345106708); +INSERT INTO test.t2 (id, barcode) VALUES (2, 12345106709); + +CREATE FUNCTION f1(p INT(8)) +RETURNS BIGINT(11) UNSIGNED +READS SQL DATA +RETURN FLOOR(p/1000)*1000000 + 100000 + FLOOR((p MOD 1000)/10)*100 + (p MOD 10); + +# +# - Check. +# + +SELECT DISTINCT t1.barcode, f1(t1.barcode) +FROM t1 +INNER JOIN t2 +ON f1(t1.barcode) = t2.barcode +WHERE t1.barcode=12345678; +barcode f1(t1.barcode) +12345678 12345106708 + +# +# - Cleanup. +# + +DROP TABLE t1; +DROP TABLE t2; +DROP FUNCTION f1; + +# +# Bug#31226. +# + +# +# - Prepare. +# + +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS f1; + +# +# - Create required objects. +# + +CREATE TABLE t1(id INT); + +INSERT INTO t1 VALUES (1), (2), (3); + +CREATE FUNCTION f1() +RETURNS DATETIME +NOT DETERMINISTIC NO SQL +RETURN NOW(); + +# +# - Check. +# + +SELECT f1() FROM t1 GROUP BY 1; +f1() + + +# +# - Cleanup. +# + +DROP TABLE t1; +DROP FUNCTION f1; + End of 5.0 tests diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 8dd99c2b2f1..6413cf2e89d 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -7354,4 +7354,294 @@ DROP TABLE t1; DROP PROCEDURE p1; DROP PROCEDURE p2; +########################################################################### + +# +# Bug#31035: select from function, group by result crasher. +# + +########################################################################### + +--echo + +--echo # +--echo # Bug#31035. +--echo # + +--echo + +--echo # +--echo # - Prepare. +--echo # + +--echo + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; +DROP FUNCTION IF EXISTS f3; +DROP FUNCTION IF EXISTS f4; +--enable_warnings + +--echo + +--echo # +--echo # - Create required objects. +--echo # + +--echo + +CREATE TABLE t1(c1 INT); + +--echo + +INSERT INTO t1 VALUES (1), (2), (3); + +--echo + +CREATE FUNCTION f1() + RETURNS INT + NOT DETERMINISTIC + RETURN 1; + +--echo + +CREATE FUNCTION f2(p INT) + RETURNS INT + NOT DETERMINISTIC + RETURN 1; + +--echo + +CREATE FUNCTION f3() + RETURNS INT + DETERMINISTIC + RETURN 1; + +--echo + +CREATE FUNCTION f4(p INT) + RETURNS INT + DETERMINISTIC + RETURN 1; + +--echo + +--echo # +--echo # - Check. +--echo # + +--echo + +# Not deterministic function, no arguments. + +SELECT f1() AS a FROM t1 GROUP BY a; + +--echo + +# Not deterministic function, non-constant argument. + +SELECT f2(@a) AS a FROM t1 GROUP BY a; + +--echo + +# Deterministic function, no arguments. + +SELECT f3() AS a FROM t1 GROUP BY a; + +--echo + +# Deterministic function, constant argument. + +SELECT f4(0) AS a FROM t1 GROUP BY a; + +--echo + +# Deterministic function, non-constant argument. + +SELECT f4(@a) AS a FROM t1 GROUP BY a; + +--echo + +--echo # +--echo # - Cleanup. +--echo # + +--echo + +DROP TABLE t1; +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +DROP FUNCTION f4; + +--echo + +########################################################################### + +# +# Bug#31191: JOIN in combination with stored function crashes the server. +# + +########################################################################### + +--echo # +--echo # Bug#31191. +--echo # + +--echo + +--echo # +--echo # - Prepare. +--echo # + +--echo + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +DROP FUNCTION IF EXISTS f1; +--enable_warnings + +--echo + +--echo # +--echo # - Create required objects. +--echo # + +--echo + +CREATE TABLE t1 ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + barcode INT(8) UNSIGNED ZEROFILL nOT NULL, + PRIMARY KEY (id), + UNIQUE KEY barcode (barcode) +); + +--echo + +INSERT INTO t1 (id, barcode) VALUES (1, 12345678); +INSERT INTO t1 (id, barcode) VALUES (2, 12345679); + +--echo + +CREATE TABLE test.t2 ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + barcode BIGINT(11) UNSIGNED ZEROFILL NOT NULL, + PRIMARY KEY (id) +); + +--echo + +INSERT INTO test.t2 (id, barcode) VALUES (1, 12345106708); +INSERT INTO test.t2 (id, barcode) VALUES (2, 12345106709); + +--echo + +CREATE FUNCTION f1(p INT(8)) + RETURNS BIGINT(11) UNSIGNED + READS SQL DATA + RETURN FLOOR(p/1000)*1000000 + 100000 + FLOOR((p MOD 1000)/10)*100 + (p MOD 10); + +--echo + +--echo # +--echo # - Check. +--echo # + +--echo + +SELECT DISTINCT t1.barcode, f1(t1.barcode) +FROM t1 +INNER JOIN t2 +ON f1(t1.barcode) = t2.barcode +WHERE t1.barcode=12345678; + +--echo + +--echo # +--echo # - Cleanup. +--echo # + +--echo + +DROP TABLE t1; +DROP TABLE t2; +DROP FUNCTION f1; + +--echo + +########################################################################### + +# +# Bug#31226: Group by function crashes mysql. +# + +########################################################################### + +--echo # +--echo # Bug#31226. +--echo # + +--echo + +--echo # +--echo # - Prepare. +--echo # + +--echo + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS f1; +--enable_warnings + +--echo + +--echo # +--echo # - Create required objects. +--echo # + +--echo + +CREATE TABLE t1(id INT); + +--echo + +INSERT INTO t1 VALUES (1), (2), (3); + +--echo + +CREATE FUNCTION f1() + RETURNS DATETIME + NOT DETERMINISTIC NO SQL + RETURN NOW(); + +--echo + +--echo # +--echo # - Check. +--echo # + +--echo + +--replace_column 1 +SELECT f1() FROM t1 GROUP BY 1; + +--echo + +--echo # +--echo # - Cleanup. +--echo # + +--echo + +DROP TABLE t1; +DROP FUNCTION f1; + +--echo + +########################################################################### + --echo End of 5.0 tests diff --git a/sql/item_func.cc b/sql/item_func.cc index d03d497dfd0..f7103c22581 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -5583,8 +5583,13 @@ Item_func_sp::fix_fields(THD *thd, Item **ref) #endif /* ! NO_EMBEDDED_ACCESS_CHECKS */ } + if (!m_sp->m_chistics->detistic) - used_tables_cache |= RAND_TABLE_BIT; + { + used_tables_cache |= RAND_TABLE_BIT; + const_item_cache= FALSE; + } + DBUG_RETURN(res); } @@ -5592,6 +5597,10 @@ Item_func_sp::fix_fields(THD *thd, Item **ref) void Item_func_sp::update_used_tables() { Item_func::update_used_tables(); + if (!m_sp->m_chistics->detistic) - used_tables_cache |= RAND_TABLE_BIT; + { + used_tables_cache |= RAND_TABLE_BIT; + const_item_cache= FALSE; + } } From 3060f0be8eb3c23ab854beb2da51bc4752a6d62f Mon Sep 17 00:00:00 2001 From: "acurtis/antony@xiphis.org/ltamd64.xiphis.org" <> Date: Thu, 4 Oct 2007 10:55:08 -0700 Subject: [PATCH 091/203] Bug#31382 "Disabled plugin is provoking Valgrind error" If there are any auto-alloced string plug-in options, memory is allocated during the call for handle_options(). We must free this memory if we are not installing the plug-in. --- include/my_getopt.h | 1 + mysys/my_getopt.c | 46 ++++++++++++++++++++++++++++++++++++++++++--- sql/sql_plugin.cc | 10 +++++++--- 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/include/my_getopt.h b/include/my_getopt.h index c74f3ed672e..30c2eb9531a 100644 --- a/include/my_getopt.h +++ b/include/my_getopt.h @@ -68,6 +68,7 @@ extern my_error_reporter my_getopt_error_reporter; extern int handle_options (int *argc, char ***argv, const struct my_option *longopts, my_get_one_option); +extern void my_cleanup_options(const struct my_option *options); extern void my_print_help(const struct my_option *options); extern void my_print_variables(const struct my_option *options); extern void my_getopt_register_get_addr(uchar ** (*func_addr)(const char *, uint, diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 3a5b130e067..6ed03067d60 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -20,6 +20,9 @@ #include #include +typedef void (*init_func_p)(const struct my_option *option, uchar* *variable, + longlong value); + static void default_reporter(enum loglevel level, const char *format, ...); my_error_reporter my_getopt_error_reporter= &default_reporter; @@ -33,7 +36,12 @@ static longlong getopt_ll(char *arg, const struct my_option *optp, int *err); static ulonglong getopt_ull(char *arg, const struct my_option *optp, int *err); static double getopt_double(char *arg, const struct my_option *optp, int *err); -static void init_variables(const struct my_option *options); +static void init_variables(const struct my_option *options, + init_func_p init_one_value); +static void init_one_value(const struct my_option *option, uchar* *variable, + longlong value); +static void fini_one_value(const struct my_option *option, uchar* *variable, + longlong value); static int setval(const struct my_option *opts, uchar* *value, char *argument, my_bool set_maximum_value); static char *check_struct_option(char *cur_arg, char *key_name); @@ -117,7 +125,7 @@ int handle_options(int *argc, char ***argv, DBUG_ASSERT(argv && *argv); (*argc)--; /* Skip the program name */ (*argv)++; /* --- || ---- */ - init_variables(longopts); + init_variables(longopts, init_one_value); for (pos= *argv, pos_end=pos+ *argc; pos != pos_end ; pos++) { @@ -906,6 +914,37 @@ static void init_one_value(const struct my_option *option, uchar* *variable, } +/* + Init one value to it's default values + + SYNOPSIS + init_one_value() + option Option to initialize + value Pointer to variable +*/ + +static void fini_one_value(const struct my_option *option, uchar* *variable, + longlong value __attribute__ ((unused))) +{ + DBUG_ENTER("fini_one_value"); + switch ((option->var_type & GET_TYPE_MASK)) { + case GET_STR_ALLOC: + my_free((*(char**) variable), MYF(MY_ALLOW_ZERO_PTR)); + *((char**) variable)= NULL; + break; + default: /* dummy default to avoid compiler warnings */ + break; + } + DBUG_VOID_RETURN; +} + + +void my_cleanup_options(const struct my_option *options) +{ + init_variables(options, fini_one_value); +} + + /* initialize all variables to their default values @@ -919,7 +958,8 @@ static void init_one_value(const struct my_option *option, uchar* *variable, for a value and initialize. */ -static void init_variables(const struct my_option *options) +static void init_variables(const struct my_option *options, + init_func_p init_one_value) { DBUG_ENTER("init_variables"); for (; options->name; options++) diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 2d33da29b77..2970ce1d11f 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -3092,7 +3092,7 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp, { sql_print_error("Parsing options for plugin '%s' failed.", tmp->name.str); - DBUG_RETURN(error); + goto err; } } @@ -3102,6 +3102,8 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp, *enabled= TRUE; } + error= 1; + if (*enabled) { for (opt= tmp->plugin->system_vars; opt && *opt; opt++) @@ -3140,7 +3142,7 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp, { sql_print_error("Plugin '%s' has conflicting system variables", tmp->name.str); - DBUG_RETURN(1); + goto err; } tmp->system_vars= chain.first; } @@ -3150,7 +3152,9 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp, if (enabled_saved && global_system_variables.log_warnings) sql_print_information("Plugin '%s' disabled by command line option", tmp->name.str); - DBUG_RETURN(1); +err: + my_cleanup_options(opts); + DBUG_RETURN(error); } From 305ebc1e21d72c54a2c3e7714b884b847da06efc Mon Sep 17 00:00:00 2001 From: "davi@moksha.local" <> Date: Thu, 4 Oct 2007 17:34:41 -0300 Subject: [PATCH 092/203] Bug#21587 FLUSH TABLES causes server crash when used with HANDLER statements This bug is a symptom of the way handler's tables are managed. The most different aspect, compared to the conventional behavior, is that the handler's tables are long lived, meaning that their lifetimes are not bounded by the duration of the command that opened them. For this effect the handler code uses its own list (handler_tables instead of open_tables) to hold open handler tables so that the tables won't be closed at the end of the command/statement. Besides the handler_tables list, there is a hash (handler_tables_hash) which is used to associate handler aliases to tables and to refresh the tables upon demand (flush tables). The current implementation doesn't work properly with refreshed tables -- more precisely when flush commands are issued by other initiators. This happens because when a handler open or read statement is being processed, the associated table has to be opened or locked and, for this matter, the open_tables and handler_tables lists are swapped so that the new table being opened is inserted into the handler_tables list. But when opening or locking the table, if the refresh version is different from the thread refresh version then all used tables in the open_tables list (now handler_tables) are refreshed. In the "refreshing" process the handler tables are flushed (closed) without being properly unlinked from the handler hash. The current implementation also fails to properly discard handlers of dropped tables, but this and other problems are going to be addressed in the fixes for bugs 31397 and 31409. The chosen approach tries to properly save and restore the table state so that no table is flushed during the table open and lock operations. The logic is almost the same as before with the list swapping, but with a working glue code. The test case for this bug is going to be committed into 5.1 because it requires a test feature only avaiable in 5.1 (wait_condition). --- sql/sql_handler.cc | 53 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 9aefa71647e..89090c9fa63 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -65,11 +65,6 @@ static enum enum_ha_read_modes rkey_to_rnext[]= { RNEXT_SAME, RNEXT, RPREV, RNEXT, RPREV, RNEXT, RPREV, RPREV }; -#define HANDLER_TABLES_HACK(thd) { \ - TABLE *tmp=thd->open_tables; \ - thd->open_tables=thd->handler_tables; \ - thd->handler_tables=tmp; } - static int mysql_ha_flush_table(THD *thd, TABLE **table_ptr, uint mode_flags); @@ -187,6 +182,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen) char *db, *name, *alias; uint dblen, namelen, aliaslen, counter; int error; + TABLE *backup_open_tables, *backup_handler_tables; DBUG_ENTER("mysql_ha_open"); DBUG_PRINT("enter",("'%s'.'%s' as '%s' reopen: %d", tables->db, tables->table_name, tables->alias, @@ -215,18 +211,31 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen) } } + /* save open_ and handler_ tables state */ + backup_open_tables= thd->open_tables; + backup_handler_tables= thd->handler_tables; + + /* no pre-opened tables */ + thd->open_tables= NULL; + /* to avoid flushes */ + thd->handler_tables= NULL; + /* open_tables() will set 'tables->table' if successful. It must be NULL for a real open when calling open_tables(). */ DBUG_ASSERT(! tables->table); - HANDLER_TABLES_HACK(thd); /* for now HANDLER can be used only for real TABLES */ tables->required_type= FRMTYPE_TABLE; error= open_tables(thd, &tables, &counter, 0); - HANDLER_TABLES_HACK(thd); + /* restore the state and merge the opened table into handler_tables list */ + thd->handler_tables= thd->open_tables ? + thd->open_tables->next= backup_handler_tables, + thd->open_tables : backup_handler_tables; + thd->open_tables= backup_open_tables; + if (error) goto err; @@ -351,7 +360,7 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables, ha_rows select_limit_cnt, ha_rows offset_limit_cnt) { TABLE_LIST *hash_tables; - TABLE *table; + TABLE *table, *backup_open_tables, *backup_handler_tables; MYSQL_LOCK *lock; List list; Protocol *protocol= thd->protocol; @@ -361,7 +370,7 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables, uint num_rows; byte *key; uint key_len; - bool not_used; + bool need_reopen; DBUG_ENTER("mysql_ha_read"); DBUG_PRINT("enter",("'%s'.'%s' as '%s'", tables->db, tables->table_name, tables->alias)); @@ -375,6 +384,7 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables, List_iterator it(list); it++; +retry: if ((hash_tables= (TABLE_LIST*) hash_search(&thd->handler_tables_hash, (byte*) tables->alias, strlen(tables->alias) + 1))) @@ -427,9 +437,28 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables, } tables->table=table; - HANDLER_TABLES_HACK(thd); - lock= mysql_lock_tables(thd, &tables->table, 1, 0, ¬_used); - HANDLER_TABLES_HACK(thd); + /* save open_ and handler_ tables state */ + backup_open_tables= thd->open_tables; + backup_handler_tables= thd->handler_tables; + + /* no pre-opened tables */ + thd->open_tables= NULL; + /* to avoid flushes */ + thd->handler_tables= NULL; + + lock= mysql_lock_tables(thd, &tables->table, 1, + MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN, &need_reopen); + + /* restore previous context */ + thd->handler_tables= backup_handler_tables; + thd->open_tables= backup_open_tables; + + if (need_reopen) + { + mysql_ha_close_table(thd, tables); + hash_tables->table= NULL; + goto retry; + } if (!lock) goto err0; // mysql_lock_tables() printed error message already From 159d5c51f2533bd3bbd7e00a549d6a1c1ea60c1a Mon Sep 17 00:00:00 2001 From: "acurtis/antony@xiphis.org/ltamd64.xiphis.org" <> Date: Thu, 4 Oct 2007 17:34:28 -0700 Subject: [PATCH 093/203] fix undefined variable which can lead to crash --- sql/sql_plugin.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 2970ce1d11f..2af528f6699 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -3053,7 +3053,7 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp, MEM_ROOT *mem_root= alloc_root_inited(&tmp->mem_root) ? &tmp->mem_root : &plugin_mem_root; st_mysql_sys_var **opt; - my_option *opts; + my_option *opts= NULL; char *p, *varname; int error; st_mysql_sys_var *o; @@ -3153,7 +3153,8 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp, sql_print_information("Plugin '%s' disabled by command line option", tmp->name.str); err: - my_cleanup_options(opts); + if (opts) + my_cleanup_options(opts); DBUG_RETURN(error); } From ac8559359c01242196c39ff1c18d41ca87bfa31c Mon Sep 17 00:00:00 2001 From: "gluh@mysql.com/eagle.(none)" <> Date: Fri, 5 Oct 2007 12:29:02 +0500 Subject: [PATCH 094/203] test fix(to satisfy WIN) --- mysql-test/r/information_schema.result | 8 ++++---- mysql-test/t/information_schema.test | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 8c1a1e67443..0c6a1855072 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1386,7 +1386,7 @@ f7 datetime NO NULL f8 datetime YES 2006-01-01 00:00:00 drop table t1; End of 5.0 tests. -show fields from information_schema.TABLE_NAMES; -ERROR 42S02: Unknown table 'TABLE_NAMES' in information_schema -show keys from information_schema.TABLE_NAMES; -ERROR 42S02: Unknown table 'TABLE_NAMES' in information_schema +show fields from information_schema.table_names; +ERROR 42S02: Unknown table 'table_names' in information_schema +show keys from information_schema.table_names; +ERROR 42S02: Unknown table 'table_names' in information_schema diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 684deef120e..04ffd30ec62 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1094,7 +1094,7 @@ drop table t1; # Bug#30079 A check for "hidden" I_S tables is flawed # --error 1109 -show fields from information_schema.TABLE_NAMES; +show fields from information_schema.table_names; --error 1109 -show keys from information_schema.TABLE_NAMES; +show keys from information_schema.table_names; From caaf8f56bd791eb30582ac1abe353f8d399d066b Mon Sep 17 00:00:00 2001 From: "tnurnberg@sin.intern.azundris.com" <> Date: Fri, 5 Oct 2007 09:38:57 +0200 Subject: [PATCH 095/203] Bug#31227: memory overrun with decimal (6,6) and zerofill and group_concat Reserve the space for the leading 0 (before the decimal point) in DECIMAL(a,a) ZEROFILL. --- mysql-test/r/type_decimal.result | 8 +++++++ mysql-test/t/type_decimal.test | 13 ++++++++++- sql/my_decimal.cc | 39 ++++++++++++++++++++++++-------- 3 files changed, 49 insertions(+), 11 deletions(-) diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result index 3cf24529421..65a72e0aa9b 100644 --- a/mysql-test/r/type_decimal.result +++ b/mysql-test/r/type_decimal.result @@ -683,6 +683,7 @@ select * from t1; a b 123.12345 123.1 drop table t1; +End of 4.1 tests CREATE TABLE t1 (EMPNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)); @@ -799,3 +800,10 @@ SELECT ROUND(qty,3), dps, ROUND(qty,dps) FROM t1; ROUND(qty,3) dps ROUND(qty,dps) 1.133 3 1.133 DROP TABLE t1; +create table t1 (f1 decimal(6,6),f2 decimal(6,6) zerofill); +insert into t1 values (-0.123456,0.123456); +select group_concat(f1),group_concat(f2) from t1; +group_concat(f1) group_concat(f2) +-0.123456 0.123456 +drop table t1; +End of 5.0 tests diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test index 5538f19f5f9..458583fca81 100644 --- a/mysql-test/t/type_decimal.test +++ b/mysql-test/t/type_decimal.test @@ -278,7 +278,7 @@ update t1 set b=a; select * from t1; drop table t1; -# End of 4.1 tests +--echo End of 4.1 tests # # Test for BUG#8397: decimal type in subselects (Item_cache_decimal) @@ -408,3 +408,14 @@ INSERT INTO t1 VALUES (1.1325,3); SELECT ROUND(qty,3), dps, ROUND(qty,dps) FROM t1; DROP TABLE t1; + +# +# Bug #31227: memory overrun with decimal (6,6) and zerofill and group_concat +# valgrind will complain about this (the group_concat(f2)) on unpatched mysqld. +# +create table t1 (f1 decimal(6,6),f2 decimal(6,6) zerofill); +insert into t1 values (-0.123456,0.123456); +select group_concat(f1),group_concat(f2) from t1; +drop table t1; + +--echo End of 5.0 tests diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc index 4ef2ae5cf95..31a5b09370a 100644 --- a/sql/my_decimal.cc +++ b/sql/my_decimal.cc @@ -68,24 +68,43 @@ int decimal_operation_results(int result) } -/* - Converting decimal to string +/** + @brief Converting decimal to string - SYNOPSIS - my_decimal2string() + @details Convert given my_decimal to String; allocate buffer as needed. - return - E_DEC_OK - E_DEC_TRUNCATED - E_DEC_OVERFLOW - E_DEC_OOM + @param[in] mask what problems to warn on (mask of E_DEC_* values) + @param[in] d the decimal to print + @param[in] fixed_prec overall number of digits if ZEROFILL, 0 otherwise + @param[in] fixed_dec number of decimal places (if fixed_prec != 0) + @param[in] filler what char to pad with (ZEROFILL et al.) + @param[out] *str where to store the resulting string + + @return error coce + @retval E_DEC_OK + @retval E_DEC_TRUNCATED + @retval E_DEC_OVERFLOW + @retval E_DEC_OOM */ int my_decimal2string(uint mask, const my_decimal *d, uint fixed_prec, uint fixed_dec, char filler, String *str) { - int length= (fixed_prec ? (fixed_prec + 1) : my_decimal_string_length(d)); + /* + Calculate the size of the string: For DECIMAL(a,b), fixed_prec==a + holds true iff the type is also ZEROFILL, which in turn implies + UNSIGNED. Hence the buffer for a ZEROFILLed value is the length + the user requested, plus one for a possible decimal point, plus + one if the user only wanted decimal places, but we force a leading + zero on them. Because the type is implicitly UNSIGNED, we do not + need to reserve a character for the sign. For all other cases, + fixed_prec will be 0, and my_decimal_string_length() will be called + instead to calculate the required size of the buffer. + */ + int length= (fixed_prec + ? (fixed_prec + ((fixed_prec == fixed_dec) ? 1 : 0) + 1) + : my_decimal_string_length(d)); int result; if (str->alloc(length)) return check_result(mask, E_DEC_OOM); From 455c05abcf421415d4d67336d7f01ce41fc47d3c Mon Sep 17 00:00:00 2001 From: "tnurnberg@sin.intern.azundris.com" <> Date: Fri, 5 Oct 2007 12:08:38 +0200 Subject: [PATCH 096/203] Bug #31253: crash comparing datetime to double convert(, datetime) in WHERE caused crash as function returned (void*)NULL, but did not flag SQL NULL. It does now. --- mysql-test/r/type_datetime.result | 9 +++++++++ mysql-test/t/type_datetime.test | 10 ++++++++++ sql/item.cc | 1 + 3 files changed, 20 insertions(+) diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index 9e47b5da2b6..f7009d561ba 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -427,3 +427,12 @@ f1 Warnings: Warning 1292 Incorrect datetime value: '2007010100000' for column 'f1' at row 1 drop table t1; +create table t1 (f1 time); +insert into t1 set f1 = '45:44:44'; +insert into t1 set f1 = '15:44:44'; +select * from t1 where (convert(f1,datetime)) != 1; +f1 +15:44:44 +Warnings: +Warning 1292 Truncated incorrect datetime value: '0000-00-00 45:44:44' +drop table t1; diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test index ffda593f320..880cde40a77 100644 --- a/mysql-test/t/type_datetime.test +++ b/mysql-test/t/type_datetime.test @@ -282,3 +282,13 @@ select * from t1 where f1 between 20020101 and 20070101000000; select * from t1 where f1 between 2002010 and 20070101000000; select * from t1 where f1 between 20020101 and 2007010100000; drop table t1; + +# +# Bug #31253: crash comparing datetime to double +# Should return 1st row only. Crashes if NULL propagation fails. +# +create table t1 (f1 time); +insert into t1 set f1 = '45:44:44'; +insert into t1 set f1 = '15:44:44'; +select * from t1 where (convert(f1,datetime)) != 1; +drop table t1; diff --git a/sql/item.cc b/sql/item.cc index e9b2904e3da..5f73b016e50 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -274,6 +274,7 @@ my_decimal *Item::val_decimal_from_date(my_decimal *decimal_value) if (get_date(<ime, TIME_FUZZY_DATE)) { my_decimal_set_zero(decimal_value); + null_value= 1; // set NULL, stop processing return 0; } return date2my_decimal(<ime, decimal_value); From 54b0cf97b382a0cd9f5e6bd635b9bdd049d91e12 Mon Sep 17 00:00:00 2001 From: "holyfoot/hf@mysql.com/hfmain.(none)" <> Date: Fri, 5 Oct 2007 15:40:32 +0500 Subject: [PATCH 097/203] Bug #30286 spatial index cause corruption and server crash! As the result of DOUBLE claculations can be bigger than DBL_MAX constant we use in code, we shouldn't use this constatn as a biggest possible value. Particularly the rtree_pick_key function set 'min_area= DBL_MAX' relying that any rtree_area_increase result will be less so we return valid key. Though in rtree_area_increase function we calculate the area of the rectangle, so the result can be 'inf' if the rectangle is huge enough, which is bigger than DBL_MAX. Code of the rtree_pick_key modified so we always return a valid key. --- myisam/rt_index.c | 18 +++++------------- myisam/rt_mbr.c | 5 ++++- mysql-test/r/gis-rtree.result | 31 ++++++++++++++++++++++++++++++ mysql-test/t/gis-rtree.test | 36 +++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 14 deletions(-) diff --git a/myisam/rt_index.c b/myisam/rt_index.c index 238432006a4..f19ecacef63 100644 --- a/myisam/rt_index.c +++ b/myisam/rt_index.c @@ -485,15 +485,16 @@ static uchar *rtree_pick_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, uint key_length, uchar *page_buf, uint nod_flag) { double increase; - double best_incr = DBL_MAX; + double best_incr; double area; double best_area; - uchar *best_key; + uchar *best_key= NULL; uchar *k = rt_PAGE_FIRST_KEY(page_buf, nod_flag); uchar *last = rt_PAGE_END(page_buf); LINT_INIT(best_area); LINT_INIT(best_key); + LINT_INIT(best_incr); for (; k < last; k = rt_PAGE_NEXT_KEY(k, key_length, nod_flag)) { @@ -502,22 +503,13 @@ static uchar *rtree_pick_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, &area)) == -1.0) return NULL; /* The following should be safe, even if we compare doubles */ - if (increase < best_incr) + if (!best_key || increase < best_incr || + ((increase == best_incr) && (area < best_area))) { best_key = k; best_area = area; best_incr = increase; } - else - { - /* The following should be safe, even if we compare doubles */ - if ((increase == best_incr) && (area < best_area)) - { - best_key = k; - best_area = area; - best_incr = increase; - } - } } return best_key; } diff --git a/myisam/rt_mbr.c b/myisam/rt_mbr.c index 897862c1c9a..31eaac0ae70 100644 --- a/myisam/rt_mbr.c +++ b/myisam/rt_mbr.c @@ -525,7 +525,10 @@ double rtree_overlapping_area(HA_KEYSEG *keyseg, uchar* a, uchar* b, } /* -Calculates MBR_AREA(a+b) - MBR_AREA(a) + Calculates MBR_AREA(a+b) - MBR_AREA(a) + Note: when 'a' and 'b' objects are far from each other, + the area increase can be really big, so this function + can return 'inf' as a result. */ double rtree_area_increase(HA_KEYSEG *keyseg, uchar* a, uchar* b, uint key_length, double *ab_area) diff --git a/mysql-test/r/gis-rtree.result b/mysql-test/r/gis-rtree.result index 762dda4e501..3df316acd77 100644 --- a/mysql-test/r/gis-rtree.result +++ b/mysql-test/r/gis-rtree.result @@ -1420,3 +1420,34 @@ CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK DROP TABLE t1; +create table t1 (a geometry not null, spatial index(a)); +insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 131072))); +insert into t1 values (PointFromWKB(POINT(9.1248812352444e+192, 2.9740338169556e+284))); +insert into t1 values (PointFromWKB(POINT(4.7783097267365e-299, -0))); +insert into t1 values (PointFromWKB(POINT(1.49166814624e-154, 2.0880974297595e-53))); +insert into t1 values (PointFromWKB(POINT(4.0917382598702e+149, 1.2024538023802e+111))); +insert into t1 values (PointFromWKB(POINT(2.0349165139404e+236, 2.9993936277913e-241))); +insert into t1 values (PointFromWKB(POINT(2.5243548967072e-29, 1.2024538023802e+111))); +insert into t1 values (PointFromWKB(POINT(0, 6.9835074892995e-251))); +insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 3.1050361846014e+231))); +insert into t1 values (PointFromWKB(POINT(2.8728483499323e-188, 2.4600631144627e+260))); +insert into t1 values (PointFromWKB(POINT(3.0517578125e-05, 2.0349165139404e+236))); +insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 1.1818212630766e-125))); +insert into t1 values (PointFromWKB(POINT(2.481040258324e-265, 5.7766220027675e-275))); +insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 2.5243548967072e-29))); +insert into t1 values (PointFromWKB(POINT(5.7766220027675e-275, 9.9464647281957e+86))); +insert into t1 values (PointFromWKB(POINT(2.2181357552967e+130, 3.7857669957337e-270))); +insert into t1 values (PointFromWKB(POINT(4.5767114681874e-246, 3.6893488147419e+19))); +insert into t1 values (PointFromWKB(POINT(4.5767114681874e-246, 3.7537584144024e+255))); +insert into t1 values (PointFromWKB(POINT(3.7857669957337e-270, 1.8033161362863e-130))); +insert into t1 values (PointFromWKB(POINT(0, 5.8774717541114e-39))); +insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 2.2761049594727e-159))); +insert into t1 values (PointFromWKB(POINT(6.243497100632e+144, 3.7857669957337e-270))); +insert into t1 values (PointFromWKB(POINT(3.7857669957337e-270, 2.6355494858076e-82))); +insert into t1 values (PointFromWKB(POINT(2.0349165139404e+236, 3.8518598887745e-34))); +insert into t1 values (PointFromWKB(POINT(4.6566128730774e-10, 2.0880974297595e-53))); +insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 1.8827498946116e-183))); +insert into t1 values (PointFromWKB(POINT(1.8033161362863e-130, 9.1248812352444e+192))); +insert into t1 values (PointFromWKB(POINT(4.7783097267365e-299, 2.2761049594727e-159))); +insert into t1 values (PointFromWKB(POINT(1.94906280228e+289, 1.2338789709327e-178))); +drop table t1; diff --git a/mysql-test/t/gis-rtree.test b/mysql-test/t/gis-rtree.test index f28a718cc11..b7d0f797e37 100644 --- a/mysql-test/t/gis-rtree.test +++ b/mysql-test/t/gis-rtree.test @@ -798,4 +798,40 @@ UPDATE t1 set spatial_point=GeomFromText('POINT(41 46)') where c1 like 'f%'; CHECK TABLE t1 EXTENDED; DROP TABLE t1; +# +# Bug #30286 spatial index cause corruption and server crash! +# + +create table t1 (a geometry not null, spatial index(a)); +insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 131072))); +insert into t1 values (PointFromWKB(POINT(9.1248812352444e+192, 2.9740338169556e+284))); +insert into t1 values (PointFromWKB(POINT(4.7783097267365e-299, -0))); +insert into t1 values (PointFromWKB(POINT(1.49166814624e-154, 2.0880974297595e-53))); +insert into t1 values (PointFromWKB(POINT(4.0917382598702e+149, 1.2024538023802e+111))); +insert into t1 values (PointFromWKB(POINT(2.0349165139404e+236, 2.9993936277913e-241))); +insert into t1 values (PointFromWKB(POINT(2.5243548967072e-29, 1.2024538023802e+111))); +insert into t1 values (PointFromWKB(POINT(0, 6.9835074892995e-251))); +insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 3.1050361846014e+231))); +insert into t1 values (PointFromWKB(POINT(2.8728483499323e-188, 2.4600631144627e+260))); +insert into t1 values (PointFromWKB(POINT(3.0517578125e-05, 2.0349165139404e+236))); +insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 1.1818212630766e-125))); +insert into t1 values (PointFromWKB(POINT(2.481040258324e-265, 5.7766220027675e-275))); +insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 2.5243548967072e-29))); +insert into t1 values (PointFromWKB(POINT(5.7766220027675e-275, 9.9464647281957e+86))); +insert into t1 values (PointFromWKB(POINT(2.2181357552967e+130, 3.7857669957337e-270))); +insert into t1 values (PointFromWKB(POINT(4.5767114681874e-246, 3.6893488147419e+19))); +insert into t1 values (PointFromWKB(POINT(4.5767114681874e-246, 3.7537584144024e+255))); +insert into t1 values (PointFromWKB(POINT(3.7857669957337e-270, 1.8033161362863e-130))); +insert into t1 values (PointFromWKB(POINT(0, 5.8774717541114e-39))); +insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 2.2761049594727e-159))); +insert into t1 values (PointFromWKB(POINT(6.243497100632e+144, 3.7857669957337e-270))); +insert into t1 values (PointFromWKB(POINT(3.7857669957337e-270, 2.6355494858076e-82))); +insert into t1 values (PointFromWKB(POINT(2.0349165139404e+236, 3.8518598887745e-34))); +insert into t1 values (PointFromWKB(POINT(4.6566128730774e-10, 2.0880974297595e-53))); +insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 1.8827498946116e-183))); +insert into t1 values (PointFromWKB(POINT(1.8033161362863e-130, 9.1248812352444e+192))); +insert into t1 values (PointFromWKB(POINT(4.7783097267365e-299, 2.2761049594727e-159))); +insert into t1 values (PointFromWKB(POINT(1.94906280228e+289, 1.2338789709327e-178))); +drop table t1; + # End of 4.1 tests From b4b7cf2a95f96892d5ae14608ca52107528b2b7d Mon Sep 17 00:00:00 2001 From: "ramil/ram@mysql.com/ramil.myoffice.izhnet.ru" <> Date: Fri, 5 Oct 2007 16:33:15 +0500 Subject: [PATCH 098/203] Fix for bug #30885: MEMORY returns incorrect data if BTREE index is used for NULL lookup Problem: creating an rb-tree key we store length (2 bytes) before the actual data for varchar key parts. The fact was missed for NULL key parts, when we set NULL byte and skip the rest. Fix: take into account the length of the varchar key parts for NULLs. --- heap/hp_hash.c | 6 ++++++ mysql-test/r/heap_btree.result | 8 ++++++++ mysql-test/t/heap_btree.test | 9 +++++++++ 3 files changed, 23 insertions(+) diff --git a/heap/hp_hash.c b/heap/hp_hash.c index d8eee9c794c..251be1a3fe2 100644 --- a/heap/hp_hash.c +++ b/heap/hp_hash.c @@ -808,6 +808,12 @@ uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old, if (!(*key++= (char) 1 - *old++)) { k_len-= seg->length; + /* + Take into account length (2 bytes) of varchar key parts + stored before the data. + */ + if (seg->flag & (HA_VAR_LENGTH_PART | HA_BLOB_PART)) + k_len-= 2; continue; } } diff --git a/mysql-test/r/heap_btree.result b/mysql-test/r/heap_btree.result index 91f51a95936..21f5a549529 100644 --- a/mysql-test/r/heap_btree.result +++ b/mysql-test/r/heap_btree.result @@ -321,4 +321,12 @@ DROP TABLE t1; CREATE TABLE t1 (a INT, UNIQUE USING BTREE(a)) ENGINE=MEMORY; INSERT INTO t1 VALUES(NULL),(NULL); DROP TABLE t1; +create table t1(a varchar(255), b varchar(255), +key using btree (a,b)) engine=memory; +insert into t1 values (1, 1), (3, 3), (2, 2), (NULL, 1), (NULL, NULL), (0, 0); +select * from t1 where a is null; +a b +NULL NULL +NULL 1 +drop table t1; End of 5.0 tests diff --git a/mysql-test/t/heap_btree.test b/mysql-test/t/heap_btree.test index d5a4fb7a734..5a238fc32c8 100644 --- a/mysql-test/t/heap_btree.test +++ b/mysql-test/t/heap_btree.test @@ -235,5 +235,14 @@ CREATE TABLE t1 (a INT, UNIQUE USING BTREE(a)) ENGINE=MEMORY; INSERT INTO t1 VALUES(NULL),(NULL); DROP TABLE t1; +# +# Bug #30885: MEMORY returns incorrect data if BTREE index is used for NULL lookup +# +create table t1(a varchar(255), b varchar(255), + key using btree (a,b)) engine=memory; +insert into t1 values (1, 1), (3, 3), (2, 2), (NULL, 1), (NULL, NULL), (0, 0); +select * from t1 where a is null; +drop table t1; + --echo End of 5.0 tests From ac875690f74b52c093d6e3760445598044ef148f Mon Sep 17 00:00:00 2001 From: "anozdrin/alik@station." <> Date: Fri, 5 Oct 2007 16:35:01 +0400 Subject: [PATCH 099/203] Fix for BUG#20550: Stored function: wrong RETURN type metadata when used in a VIEW. The problem was that wrong function (create_tmp_from_item()) was used to create a temporary field for Item_func_sp. The fix is to use create_tmp_from_field(). --- mysql-test/r/sp.result | 50 ++++++++++++++++++++++++- mysql-test/t/sp.test | 84 ++++++++++++++++++++++++++++++++++++++++++ sql/item_func.h | 5 +++ sql/sql_select.cc | 30 +++++++++++++++ 4 files changed, 168 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index fd09701c125..2274a9103e8 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -4914,7 +4914,7 @@ create table t3 as select * from v1| show create table t3| Table Create Table t3 CREATE TABLE `t3` ( - `j` bigint(11) DEFAULT NULL + `j` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 select * from t3| j @@ -6599,3 +6599,51 @@ DROP TABLE t1; DROP PROCEDURE p1; DROP PROCEDURE p2; End of 5.0 tests + +# +# Bug#20550. +# + +# +# - Prepare. +# + +DROP VIEW IF EXISTS v1; +DROP VIEW IF EXISTS v2; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; + +# +# - Create required objects. +# + +CREATE FUNCTION f1() RETURNS VARCHAR(65525) RETURN 'Hello'; + +CREATE FUNCTION f2() RETURNS TINYINT RETURN 1; + +CREATE VIEW v1 AS SELECT f1(); + +CREATE VIEW v2 AS SELECT f2(); + +# +# - Check. +# + +SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'v1'; +DATA_TYPE +varchar + +SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'v2'; +DATA_TYPE +tinyint + +# +# - Cleanup. +# + +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP VIEW v1; +DROP VIEW v2; + +End of 5.1 tests diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 27e559f4463..938bbc27777 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -7549,3 +7549,87 @@ DROP PROCEDURE p1; DROP PROCEDURE p2; --echo End of 5.0 tests + +########################################################################### + +# +# Bug#20550: Stored function: wrong RETURN type metadata when used in a VIEW. +# + +########################################################################### + +--echo + +--echo # +--echo # Bug#20550. +--echo # + +--echo + +--echo # +--echo # - Prepare. +--echo # + +--echo + +--disable_warnings +DROP VIEW IF EXISTS v1; +DROP VIEW IF EXISTS v2; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; +--enable_warnings + +--echo + +--echo # +--echo # - Create required objects. +--echo # + +--echo + +CREATE FUNCTION f1() RETURNS VARCHAR(65525) RETURN 'Hello'; + +--echo + +CREATE FUNCTION f2() RETURNS TINYINT RETURN 1; + +--echo + +CREATE VIEW v1 AS SELECT f1(); + +--echo + +CREATE VIEW v2 AS SELECT f2(); + +--echo + +--echo # +--echo # - Check. +--echo # + +--echo + +SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'v1'; + +--echo + +SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'v2'; + +--echo + +--echo # +--echo # - Cleanup. +--echo # + +--echo + +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP VIEW v1; +DROP VIEW v2; + +--echo + +########################################################################### + +--echo End of 5.1 tests diff --git a/sql/item_func.h b/sql/item_func.h index ea22e35773d..66a417f31fa 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1535,6 +1535,11 @@ public: bool fix_fields(THD *thd, Item **ref); void fix_length_and_dec(void); bool is_expensive() { return 1; } + + inline Field *get_sp_result_field() + { + return sp_result_field; + } }; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index fd3be1aef08..9b79b706438 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -9301,6 +9301,36 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, } /* Fall through */ case Item::FUNC_ITEM: + if (((Item_func *) item)->functype() == Item_func::FUNC_SP) + { + Item_func_sp *item_func_sp= (Item_func_sp *) item; + Field *sp_result_field= item_func_sp->get_sp_result_field(); + + if (make_copy_field) + { + DBUG_ASSERT(item_func_sp->result_field); + *from_field= item_func_sp->result_field; + } + else + { + *((*copy_func)++)= item; + } + + Field *result_field= + create_tmp_field_from_field(thd, + sp_result_field, + item_func_sp->name, + table, + NULL, + convert_blob_length); + + if (modify_item) + item->set_result_field(result_field); + + return result_field; + } + + /* Fall through */ case Item::COND_ITEM: case Item::FIELD_AVG_ITEM: case Item::FIELD_STD_ITEM: From 1e4fac167781af727a7aeb5fef422542dc5163f1 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Fri, 5 Oct 2007 14:42:38 +0200 Subject: [PATCH 100/203] Bug#31400 mysql-test-run inconvenience problems running a certain test - Allow test case names to be specied in various different ways --- mysql-test/lib/mtr_cases.pl | 140 ++++++++++++++++++++---------------- 1 file changed, 80 insertions(+), 60 deletions(-) diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl index 9ba7d737b9e..3622f52940d 100644 --- a/mysql-test/lib/mtr_cases.pl +++ b/mysql-test/lib/mtr_cases.pl @@ -48,13 +48,14 @@ sub collect_test_cases ($) { { # Check that the tests specified was found # in at least one suite - foreach my $tname ( @::opt_cases ) + foreach my $test_name_spec ( @::opt_cases ) { my $found= 0; + my ($sname, $tname, $extension)= split_testname($test_name_spec); foreach my $test ( @$cases ) { - if ( $test->{'name'} eq $tname || - mtr_match_extension($test->{'name'}, $tname) ) + # test->{name} is always in suite.name format + if ( $test->{name} =~ /.*\.$tname/ ) { $found= 1; } @@ -144,6 +145,45 @@ sub collect_test_cases ($) { } +# Valid extensions and their corresonding component id +my %exts = ( 'test' => 'mysqld', + 'imtest' => 'im' + ); + + +# Returns (suitename, testname, extension) +sub split_testname { + my ($test_name)= @_; + + # Get rid of directory part and split name on .'s + my @parts= split(/\./, basename($test_name)); + + if (@parts == 1){ + # Only testname given, ex: alias + return (undef , $parts[0], undef); + } elsif (@parts == 2) { + # Either testname.test or suite.testname given + # Ex. main.alias or alias.test + + if (defined $exts{$parts[1]}) + { + return (undef , $parts[0], $parts[1]); + } + else + { + return ($parts[0], $parts[1], undef); + } + + } elsif (@parts == 3) { + # Fully specified suitename.testname.test + # ex main.alias.test + return ( $parts[0], $parts[1], $parts[2]); + } + + mtr_error("Illegal format of test name: $test_name"); +} + + sub collect_one_suite($$) { my $suite= shift; # Test suite name @@ -189,77 +229,55 @@ sub collect_one_suite($$) if ( @::opt_cases ) { - # Collect in specified order, no sort - foreach my $tname2 ( @::opt_cases ) + # Collect in specified order + foreach my $test_name_spec ( @::opt_cases ) { - my $tname= $tname2; # Don't modify @::opt_cases ! - my $elem= undef; - my $component_id= undef; + my ($sname, $tname, $extension)= split_testname($test_name_spec); - # Get rid of directory part (path). Leave the extension since it is used - # to understand type of the test. + # The test name parts have now been defined + #print " suite_name: $sname\n"; + #print " tname: $tname\n"; + #print " extension: $extension\n"; - $tname = basename($tname); + # Check cirrect suite if suitename is defined + next if (defined $sname and $suite ne $sname); - # Get rid of suite part - $tname =~ s/^(.*)\.//; - - # Check if the extenstion has been specified. - - if ( mtr_match_extension($tname, "test") ) + my $component_id; + if ( defined $extension ) { - $elem= $tname; - $tname=~ s/\.test$//; - $component_id= 'mysqld'; - } - elsif ( mtr_match_extension($tname, "imtest") ) - { - $elem= $tname; - $tname =~ s/\.imtest$//; - $component_id= 'im'; - } - - # If target component is known, check that the specified test case - # exists. - # - # Otherwise, try to guess the target component. - - if ( $component_id ) - { - if ( ! -f "$testdir/$elem") + my $full_name= "$testdir/$tname.$extension"; + # Extension was specified, check if the test exists + if ( ! -f $full_name) { - mtr_error("Test case $tname ($testdir/$elem) is not found"); + # This is only an error if suite was specified, otherwise it + # could exist in another suite + mtr_error("Test '$full_name' was not found in suite '$sname'") + if $sname; + + next; } + $component_id= $exts{$extension}; } else { - my $mysqld_test_exists = -f "$testdir/$tname.test"; - my $im_test_exists = -f "$testdir/$tname.imtest"; + # No extension was specified + my ($ext, $component); + while (($ext, $component)= each %exts) { + my $full_name= "$testdir/$tname.$ext"; - if ( $mysqld_test_exists and $im_test_exists ) - { - mtr_error("Ambiguous test case name ($tname)"); - } - elsif ( ! $mysqld_test_exists and ! $im_test_exists ) - { - # Silently skip, could exist in another suite - next; - } - elsif ( $mysqld_test_exists ) - { - $elem= "$tname.test"; - $component_id= 'mysqld'; - } - elsif ( $im_test_exists ) - { - $elem= "$tname.imtest"; - $component_id= 'im'; - } + if ( ! -f $full_name ) { + next; + } + $component_id= $component; + $extension= $ext; + } + # Test not found here, could exist in other suite + next unless $component_id; } collect_one_test_case($testdir,$resdir,$suite,$tname, - $elem,$cases,\%disabled,$component_id, - $suite_opts); + "$tname.$extension",$cases,\%disabled, + $component_id,$suite_opts); } } else @@ -319,6 +337,8 @@ sub collect_one_test_case($$$$$$$$$) { my $path= "$testdir/$elem"; + + print "collect_one_test_case\n"; # ---------------------------------------------------------------------- # Skip some tests silently # ---------------------------------------------------------------------- From 91455690b555a45f3db131f7c25c575980989b24 Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Fri, 5 Oct 2007 17:28:34 +0300 Subject: [PATCH 101/203] Bug #31094: Forcing index-based sort doesn't work anymore if joins are done A rule was introduced by the 5.1 part of the fix for bug 27531 to prefer filesort over indexed ORDER BY when accessing all of the rows of a table (because it's faster). This new rule was not accounting for the presence of a LIMIT clause. Fixed the condition for this rule so it will prefer filesort over indexed ORDER BY only if no LIMIT. --- mysql-test/r/compress.result | 4 +- mysql-test/r/join.result | 164 +++++++++++++++++++++++++++++++ mysql-test/r/select.result | 4 +- mysql-test/r/ssl.result | 4 +- mysql-test/r/ssl_compress.result | 4 +- mysql-test/t/join.test | 29 ++++++ sql/sql_select.cc | 12 +-- 7 files changed, 207 insertions(+), 14 deletions(-) diff --git a/mysql-test/r/compress.result b/mysql-test/r/compress.result index 68206c0dc0e..a71d840d229 100644 --- a/mysql-test/r/compress.result +++ b/mysql-test/r/compress.result @@ -611,11 +611,11 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 ref period period 4 test.t1.period 4181 explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 ALL period NULL NULL NULL 41810 Using filesort +1 SIMPLE t3 index period period 4 NULL 1 1 SIMPLE t1 ref period period 4 test.t3.period 4181 explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort +1 SIMPLE t1 index period period 4 NULL 1 1 SIMPLE t3 ref period period 4 test.t1.period 4181 select period from t1; period diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result index fcb141a3510..9b799fccf06 100644 --- a/mysql-test/r/join.result +++ b/mysql-test/r/join.result @@ -897,4 +897,168 @@ select '^^: The above should be ~= 20 + cost(select * from t1). Value less than Z ^^: The above should be ~= 20 + cost(select * from t1). Value less than 20 is an error drop table t1, t2; +CREATE TABLE t1 (a INT PRIMARY KEY, b INT); +CREATE TABLE t2 (c INT PRIMARY KEY, d INT); +INSERT INTO t1 VALUES(1,NULL),(2,NULL),(3,NULL),(4,NULL); +INSERT INTO t1 SELECT a + 4, b FROM t1; +INSERT INTO t1 SELECT a + 8, b FROM t1; +INSERT INTO t1 SELECT a + 16, b FROM t1; +INSERT INTO t1 SELECT a + 32, b FROM t1; +INSERT INTO t1 SELECT a + 64, b FROM t1; +INSERT INTO t2 SELECT a, b FROM t1; +EXPLAIN SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a LIMIT 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 +EXPLAIN SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a LIMIT 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 2 +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 +SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a LIMIT 2; +a b c d +SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a LIMIT 2; +a b c d +1 NULL 1 NULL +2 NULL 2 NULL +EXPLAIN SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using filesort +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 +EXPLAIN SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 128 Using filesort +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 +SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a; +a b c d +SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a; +a b c d +1 NULL 1 NULL +2 NULL 2 NULL +3 NULL 3 NULL +4 NULL 4 NULL +5 NULL 5 NULL +6 NULL 6 NULL +7 NULL 7 NULL +8 NULL 8 NULL +9 NULL 9 NULL +10 NULL 10 NULL +11 NULL 11 NULL +12 NULL 12 NULL +13 NULL 13 NULL +14 NULL 14 NULL +15 NULL 15 NULL +16 NULL 16 NULL +17 NULL 17 NULL +18 NULL 18 NULL +19 NULL 19 NULL +20 NULL 20 NULL +21 NULL 21 NULL +22 NULL 22 NULL +23 NULL 23 NULL +24 NULL 24 NULL +25 NULL 25 NULL +26 NULL 26 NULL +27 NULL 27 NULL +28 NULL 28 NULL +29 NULL 29 NULL +30 NULL 30 NULL +31 NULL 31 NULL +32 NULL 32 NULL +33 NULL 33 NULL +34 NULL 34 NULL +35 NULL 35 NULL +36 NULL 36 NULL +37 NULL 37 NULL +38 NULL 38 NULL +39 NULL 39 NULL +40 NULL 40 NULL +41 NULL 41 NULL +42 NULL 42 NULL +43 NULL 43 NULL +44 NULL 44 NULL +45 NULL 45 NULL +46 NULL 46 NULL +47 NULL 47 NULL +48 NULL 48 NULL +49 NULL 49 NULL +50 NULL 50 NULL +51 NULL 51 NULL +52 NULL 52 NULL +53 NULL 53 NULL +54 NULL 54 NULL +55 NULL 55 NULL +56 NULL 56 NULL +57 NULL 57 NULL +58 NULL 58 NULL +59 NULL 59 NULL +60 NULL 60 NULL +61 NULL 61 NULL +62 NULL 62 NULL +63 NULL 63 NULL +64 NULL 64 NULL +65 NULL 65 NULL +66 NULL 66 NULL +67 NULL 67 NULL +68 NULL 68 NULL +69 NULL 69 NULL +70 NULL 70 NULL +71 NULL 71 NULL +72 NULL 72 NULL +73 NULL 73 NULL +74 NULL 74 NULL +75 NULL 75 NULL +76 NULL 76 NULL +77 NULL 77 NULL +78 NULL 78 NULL +79 NULL 79 NULL +80 NULL 80 NULL +81 NULL 81 NULL +82 NULL 82 NULL +83 NULL 83 NULL +84 NULL 84 NULL +85 NULL 85 NULL +86 NULL 86 NULL +87 NULL 87 NULL +88 NULL 88 NULL +89 NULL 89 NULL +90 NULL 90 NULL +91 NULL 91 NULL +92 NULL 92 NULL +93 NULL 93 NULL +94 NULL 94 NULL +95 NULL 95 NULL +96 NULL 96 NULL +97 NULL 97 NULL +98 NULL 98 NULL +99 NULL 99 NULL +100 NULL 100 NULL +101 NULL 101 NULL +102 NULL 102 NULL +103 NULL 103 NULL +104 NULL 104 NULL +105 NULL 105 NULL +106 NULL 106 NULL +107 NULL 107 NULL +108 NULL 108 NULL +109 NULL 109 NULL +110 NULL 110 NULL +111 NULL 111 NULL +112 NULL 112 NULL +113 NULL 113 NULL +114 NULL 114 NULL +115 NULL 115 NULL +116 NULL 116 NULL +117 NULL 117 NULL +118 NULL 118 NULL +119 NULL 119 NULL +120 NULL 120 NULL +121 NULL 121 NULL +122 NULL 122 NULL +123 NULL 123 NULL +124 NULL 124 NULL +125 NULL 125 NULL +126 NULL 126 NULL +127 NULL 127 NULL +128 NULL 128 NULL +DROP TABLE IF EXISTS t1,t2; End of 5.0 tests. diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index ed61cfffa6b..d1d85aef0ec 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -607,11 +607,11 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 ref period period 4 test.t1.period 4181 explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 ALL period NULL NULL NULL 41810 Using filesort +1 SIMPLE t3 index period period 4 NULL 1 1 SIMPLE t1 ref period period 4 test.t3.period 4181 explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort +1 SIMPLE t1 index period period 4 NULL 1 1 SIMPLE t3 ref period period 4 test.t1.period 4181 select period from t1; period diff --git a/mysql-test/r/ssl.result b/mysql-test/r/ssl.result index 1f1a6ec9e22..3622fb51c99 100644 --- a/mysql-test/r/ssl.result +++ b/mysql-test/r/ssl.result @@ -608,11 +608,11 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 ref period period 4 test.t1.period 4181 explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 ALL period NULL NULL NULL 41810 Using filesort +1 SIMPLE t3 index period period 4 NULL 1 1 SIMPLE t1 ref period period 4 test.t3.period 4181 explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort +1 SIMPLE t1 index period period 4 NULL 1 1 SIMPLE t3 ref period period 4 test.t1.period 4181 select period from t1; period diff --git a/mysql-test/r/ssl_compress.result b/mysql-test/r/ssl_compress.result index e77fcefeafd..3018fce5cad 100644 --- a/mysql-test/r/ssl_compress.result +++ b/mysql-test/r/ssl_compress.result @@ -611,11 +611,11 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 ref period period 4 test.t1.period 4181 explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 ALL period NULL NULL NULL 41810 Using filesort +1 SIMPLE t3 index period period 4 NULL 1 1 SIMPLE t1 ref period period 4 test.t3.period 4181 explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort +1 SIMPLE t1 index period period 4 NULL 1 1 SIMPLE t3 ref period period 4 test.t1.period 4181 select period from t1; period diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test index 14c98431970..ed1b84bb5ec 100644 --- a/mysql-test/t/join.test +++ b/mysql-test/t/join.test @@ -698,4 +698,33 @@ select '^^: The above should be ~= 20 + cost(select * from t1). Value less than drop table t1, t2; +# +# Bug #31094: Forcing index-based sort doesn't work anymore if joins are +# done +# + +CREATE TABLE t1 (a INT PRIMARY KEY, b INT); +CREATE TABLE t2 (c INT PRIMARY KEY, d INT); + +INSERT INTO t1 VALUES(1,NULL),(2,NULL),(3,NULL),(4,NULL); +INSERT INTO t1 SELECT a + 4, b FROM t1; +INSERT INTO t1 SELECT a + 8, b FROM t1; +INSERT INTO t1 SELECT a + 16, b FROM t1; +INSERT INTO t1 SELECT a + 32, b FROM t1; +INSERT INTO t1 SELECT a + 64, b FROM t1; +INSERT INTO t2 SELECT a, b FROM t1; + +#expect indexed ORDER BY +EXPLAIN SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a LIMIT 2; +EXPLAIN SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a LIMIT 2; +SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a LIMIT 2; +SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a LIMIT 2; + +#expect filesort +EXPLAIN SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a; +EXPLAIN SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a; +SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a; +SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a; + +DROP TABLE IF EXISTS t1,t2; --echo End of 5.0 tests. diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 008f2f9c70a..5f516f5e21c 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -12775,12 +12775,6 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, LINT_INIT(best_key_direction); LINT_INIT(best_records); - /* - filesort() and join cache are usually faster than reading in - index order and not using join cache - */ - if (tab->type == JT_ALL && tab->join->tables > tab->join->const_tables + 1) - DBUG_RETURN(0); /* If not used with LIMIT, only use keys if the whole query can be resolved with a key; This is because filesort() is usually faster than @@ -12788,6 +12782,12 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, */ if (select_limit >= table_records) { + /* + filesort() and join cache are usually faster than reading in + index order and not using join cache + */ + if (tab->type == JT_ALL && tab->join->tables > tab->join->const_tables + 1) + DBUG_RETURN(0); keys= *table->file->keys_to_use_for_scanning(); keys.merge(table->covering_keys); From 626faeecd9cb741f18e901cee0335ada914ee76f Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Fri, 5 Oct 2007 17:54:19 +0200 Subject: [PATCH 102/203] Bug#31398 problems with mysql-test-run - "mysqld --verbose --help" need to be started in a writable directory --- mysql-test/mysql-test-run.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index ad507440bb7..a835d3bc1a9 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1334,12 +1334,13 @@ sub datadir_list_setup () { sub collect_mysqld_features () { my $found_variable_list_start= 0; + my $tmpdir= tempdir(CLEANUP => 0); # Directory removed by this function # # Execute "mysqld --no-defaults --help --verbose" to get a # list of all features and settings # - my $list= `$exe_mysqld --no-defaults --verbose --help`; + my $list= `$exe_mysqld --no-defaults --datadir=$tmpdir --verbose --help`; foreach my $line (split('\n', $list)) { @@ -1394,7 +1395,7 @@ sub collect_mysqld_features () { } } } - + rmtree($tmpdir); mtr_error("Could not find version of MySQL") unless $mysql_version_id; mtr_error("Could not find variabes list") unless $found_variable_list_start; From 39a069b29622821d4b0723fe2f184e6014a2319c Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Fri, 5 Oct 2007 18:18:50 +0200 Subject: [PATCH 103/203] Bug#31398 problems with mysql-test-run, part2 Write .reject file to r/ if it's writable else use opt_logdir --- client/mysqltest.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index a2412d4b30e..eae3b05f61a 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1580,10 +1580,21 @@ void check_result(DYNAMIC_STRING* ds) and then show the diff */ char reject_file[FN_REFLEN]; - str_to_file(fn_format(reject_file, result_file_name, opt_logdir, ".reject", - *opt_logdir ? MY_REPLACE_DIR | MY_REPLACE_EXT : - MY_REPLACE_EXT), - ds->str, ds->length); + dirname_part(reject_file, result_file_name); + + if (access(reject_file, W_OK) == 0) + { + /* Result file directory is writable, save reject file there */ + fn_format(reject_file, result_file_name, NULL, + ".reject", MY_REPLACE_EXT); + } + else + { + /* Put reject file in opt_logdir */ + fn_format(reject_file, result_file_name, opt_logdir, + ".reject", MY_REPLACE_DIR | MY_REPLACE_EXT); + } + str_to_file(reject_file, ds->str, ds->length); dynstr_set(ds, NULL); /* Don't create a .log file */ From 9571e7ec872249c2a2e17f18da412855f8659bfd Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Fri, 5 Oct 2007 18:22:28 +0200 Subject: [PATCH 104/203] Update for 5.1 format of dirname_part --- client/mysqltest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 4a80ad8d715..335a1590e1b 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1562,8 +1562,8 @@ void check_result(DYNAMIC_STRING* ds) Result mismatched, dump results to .reject file and then show the diff */ - char reject_file[FN_REFLEN]; - dirname_part(reject_file, result_file_name); + char reject_file[FN_REFLEN], reject_length; + dirname_part(reject_file, result_file_name, &reject_length); if (access(reject_file, W_OK) == 0) { From c78ef4128a954b18d17fa901c5d394ba8cbed924 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Fri, 5 Oct 2007 18:24:48 +0200 Subject: [PATCH 105/203] Remove printout --- mysql-test/lib/mtr_cases.pl | 2 -- 1 file changed, 2 deletions(-) diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl index 3622f52940d..a4266ab1931 100644 --- a/mysql-test/lib/mtr_cases.pl +++ b/mysql-test/lib/mtr_cases.pl @@ -337,8 +337,6 @@ sub collect_one_test_case($$$$$$$$$) { my $path= "$testdir/$elem"; - - print "collect_one_test_case\n"; # ---------------------------------------------------------------------- # Skip some tests silently # ---------------------------------------------------------------------- From c86bd100c8de4228a26da6682b4fc2f4125569ca Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Fri, 5 Oct 2007 18:36:23 +0200 Subject: [PATCH 106/203] Bug#30560 Valgrind option to mysql-test-run with spaces in cause strange error --- mysql-test/mysql-test-run.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index a835d3bc1a9..d3f6c771a7c 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -5007,7 +5007,7 @@ sub valgrind_arguments { } # Add valgrind options, can be overriden by user - mtr_add_arg($args, '%s', $_) for (split(' ', $opt_valgrind_options)); + mtr_add_arg($args, '%s', $opt_valgrind_options); mtr_add_arg($args, $$exe); From eedde95a3308f5ab95f886bb3145be8d338264f3 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Fri, 5 Oct 2007 13:16:54 -0400 Subject: [PATCH 107/203] Change URLs. Our web server has been restructured several times, and references to it in our source code has stayed the same. This patch from Paul DuBois updates all URLs to modern semantics. --- debian/po/ca.po | 4 ++-- debian/po/cs.po | 4 ++-- debian/po/da.po | 4 ++-- debian/po/gl.po | 4 ++-- debian/po/ja.po | 4 ++-- debian/po/pt_BR.po | 4 ++-- debian/po/sv.po | 4 ++-- debian/po/tr.po | 4 ++-- mysql-test/lib/mtr_report.pl | 2 +- mysql-test/mysql-test-run-shell.sh | 2 +- ndb/include/ndbapi/Ndb.hpp | 2 +- netware/mysql_test_run.c | 2 +- scripts/mysqld_safe.sh | 2 +- sql/mysqld.cc | 4 ++-- 14 files changed, 23 insertions(+), 23 deletions(-) diff --git a/debian/po/ca.po b/debian/po/ca.po index 9dc1fc0de77..5019f05c909 100644 --- a/debian/po/ca.po +++ b/debian/po/ca.po @@ -162,9 +162,9 @@ msgid "" msgstr "" #, fuzzy -#~ msgid "Please also read http://www.mysql.com/doc/en/Upgrade.html" +#~ msgid "Please also read http://dev.mysql.com/doc/mysql/en/upgrade.html" #~ msgstr "" -#~ "Feu una ullada al document: http://www.mysql.com/doc/en/Upgrade.html" +#~ "Feu una ullada al document: http://dev.mysql.com/doc/mysql/en/upgrade.html" #, fuzzy #~ msgid "" diff --git a/debian/po/cs.po b/debian/po/cs.po index 33e4f213bb2..ada32a3469b 100644 --- a/debian/po/cs.po +++ b/debian/po/cs.po @@ -213,8 +213,8 @@ msgstr "" #~ "se tabulky mohly naruÅ¡it! Tento skript také rozÅ¡iÅ™uje tabulky privilegií, " #~ "ovÅ¡em nemÄ›l by uživatelům pÅ™idat více práv, než mÄ›li dosud." -#~ msgid "Please also read http://www.mysql.com/doc/en/Upgrade.html" -#~ msgstr "Také si pÅ™eÄtÄ›te http://www.mysql.com/doc/en/Upgrade.html" +#~ msgid "Please also read http://dev.mysql.com/doc/mysql/en/upgrade.html" +#~ msgstr "Také si pÅ™eÄtÄ›te http://dev.mysql.com/doc/mysql/en/upgrade.html" #~ msgid "" #~ "MySQL will only install if you have a non-numeric hostname that is " diff --git a/debian/po/da.po b/debian/po/da.po index 5e93e3f7b33..cfaf2705254 100644 --- a/debian/po/da.po +++ b/debian/po/da.po @@ -215,8 +215,8 @@ msgstr "" #~ "kan blive ødelagt! Dette script forbedrer også rettighedstabellerne, men " #~ "burde ikke give nogen bruger flere rettigheder, end han havde tidligere," -#~ msgid "Please also read http://www.mysql.com/doc/en/Upgrade.html" -#~ msgstr "Læs også http://www.mysql.com/doc/en/Upgrade.html" +#~ msgid "Please also read http://dev.mysql.com/doc/mysql/en/upgrade.html" +#~ msgstr "Læs også http://dev.mysql.com/doc/mysql/en/upgrade.html" #~ msgid "Install Hints" #~ msgstr "Installationstips" diff --git a/debian/po/gl.po b/debian/po/gl.po index 44fd58872cc..de5356e24f3 100644 --- a/debian/po/gl.po +++ b/debian/po/gl.po @@ -211,8 +211,8 @@ msgstr "" #~ "privilexios, pero non se supón que vaia dar a ningún usuario máis " #~ "dereitos dos que tiña antes." -#~ msgid "Please also read http://www.mysql.com/doc/en/Upgrade.html" -#~ msgstr "Lea tamén http://www.mysql.com/doc/en/Upgrade.html" +#~ msgid "Please also read http://dev.mysql.com/doc/mysql/en/upgrade.html" +#~ msgstr "Lea tamén http://dev.mysql.com/doc/mysql/en/upgrade.html" #~ msgid "Install Hints" #~ msgstr "Consellos de instalación" diff --git a/debian/po/ja.po b/debian/po/ja.po index 14d97ed977b..5d9151da652 100644 --- a/debian/po/ja.po +++ b/debian/po/ja.po @@ -274,5 +274,5 @@ msgstr "" #~ "ã™ã€‚スクリプトã¯ã€ã©ã®ã‚ˆã†ãªãƒ¦ãƒ¼ã‚¶ã«å¯¾ã—ã¦ã‚‚ã€ä»¥å‰ã«ä¿æŒã—ã¦ã„ãŸä»¥ä¸Šã®æ¨©é™" #~ "を与ãˆã‚‹ã‚ˆã†ã«ã¯ãªã£ã¦ã„ã¾ã›ã‚“。" -#~ msgid "Please also read http://www.mysql.com/doc/en/Upgrade.html" -#~ msgstr "http://www.mysql.com/doc/ja/Upgrade.html ã‚‚å‚ç…§ã—ã¦ãã ã•ã„" +#~ msgid "Please also read http://dev.mysql.com/doc/mysql/en/upgrade.html" +#~ msgstr "http://dev.mysql.com/doc/mysql/ja/upgrade.html ã‚‚å‚ç…§ã—ã¦ãã ã•ã„" diff --git a/debian/po/pt_BR.po b/debian/po/pt_BR.po index 51557b006e6..e7684ae7bd6 100644 --- a/debian/po/pt_BR.po +++ b/debian/po/pt_BR.po @@ -205,8 +205,8 @@ msgstr "" #~ "atribuirá a nenhum usuário mais direitos do que os mesmos já possuíam " #~ "anteriormente." -#~ msgid "Please also read http://www.mysql.com/doc/en/Upgrade.html" -#~ msgstr "Por favor, leia http://www.mysql.com/doc/en/Upgrade.html" +#~ msgid "Please also read http://dev.mysql.com/doc/mysql/en/upgrade.html" +#~ msgstr "Por favor, leia http://dev.mysql.com/doc/mysql/en/upgrade.html" #, fuzzy #~ msgid "Install Hints" diff --git a/debian/po/sv.po b/debian/po/sv.po index 54ef9246236..62f471dea0f 100644 --- a/debian/po/sv.po +++ b/debian/po/sv.po @@ -165,8 +165,8 @@ msgstr "S #~ "tabellerna vara skadade! Detta skript utökar även privilegietabellerna " #~ "men är inte tänkte att ge någon användare mer befogenhet än vad han hade " #~ "tidigare," -#~ msgid "Please also read http://www.mysql.com/doc/en/Upgrade.html" -#~ msgstr "Läs även http://www.mysql.com/doc/en/Upgrade.html" +#~ msgid "Please also read http://dev.mysql.com/doc/mysql/en/upgrade.html" +#~ msgstr "Läs även http://dev.mysql.com/doc/mysql/en/upgrade.html" #~ msgid "Install Hints" #~ msgstr "Installationstips" #~ msgid "" diff --git a/debian/po/tr.po b/debian/po/tr.po index 20b4df45b6e..b81d28957e1 100644 --- a/debian/po/tr.po +++ b/debian/po/tr.po @@ -162,8 +162,8 @@ msgid "" msgstr "" #, fuzzy -#~ msgid "Please also read http://www.mysql.com/doc/en/Upgrade.html" -#~ msgstr "Lütfen http://www.mysql.com/doc/en/Upgrade.html belgesini okuyun" +#~ msgid "Please also read http://dev.mysql.com/doc/mysql/en/upgrade.html" +#~ msgstr "Lütfen http://dev.mysql.com/doc/mysql/en/upgrade.html belgesini okuyun" #, fuzzy #~ msgid "" diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl index ca66138d279..1694ad1cb2e 100644 --- a/mysql-test/lib/mtr_report.pl +++ b/mysql-test/lib/mtr_report.pl @@ -196,7 +196,7 @@ sub mtr_report_stats ($) { "of what went wrong.\n", "If you want to report this error, please read first ", "the documentation at\n", - "http://www.mysql.com/doc/en/MySQL_test_suite.html\n"; + "http://dev.mysql.com/doc/mysql/en/mysql-test-suite.html\n"; } if (!$::opt_extern) { diff --git a/mysql-test/mysql-test-run-shell.sh b/mysql-test/mysql-test-run-shell.sh index c0ff3d3d88e..e0f151904f8 100644 --- a/mysql-test/mysql-test-run-shell.sh +++ b/mysql-test/mysql-test-run-shell.sh @@ -935,7 +935,7 @@ show_failed_diff () $DIFF -c $result_file $reject_file echo "-------------------------------------------------------" echo "Please follow the instructions outlined at" - echo "http://dev.mysql.com/doc/mysql/en/reporting-mysqltest-bugs.html" + echo "http://forge.mysql.com/wiki/MySQL_Internals_Porting#Debugging_a_MySQL_Server" echo "to find the reason to this problem and how to report this." echo "" fi diff --git a/ndb/include/ndbapi/Ndb.hpp b/ndb/include/ndbapi/Ndb.hpp index f83db77739e..dbbf11612ed 100644 --- a/ndb/include/ndbapi/Ndb.hpp +++ b/ndb/include/ndbapi/Ndb.hpp @@ -17,7 +17,7 @@ @mainpage NDB API Programmers' Guide This guide assumes a basic familiarity with MySQL Cluster concepts found - on http://dev.mysql.com/doc/mysql/en/NDBCluster.html . + on http://dev.mysql.com/doc/mysql/en/mysql-cluster.html. Some of the fundamental ones are also described in section @ref secConcepts. The NDB API is a MySQL Cluster application interface diff --git a/netware/mysql_test_run.c b/netware/mysql_test_run.c index a62de9013f9..3bdbc242f9e 100644 --- a/netware/mysql_test_run.c +++ b/netware/mysql_test_run.c @@ -175,7 +175,7 @@ void report_stats() log_msg("\nThe .out and .err files in %s may give you some\n", result_dir); log_msg("hint of what went wrong.\n"); log_msg("\nIf you want to report this error, please first read the documentation\n"); - log_msg("at: http://www.mysql.com/doc/en/MySQL_test_suite.html\n"); + log_msg("at: http://dev.mysql.com/doc/mysql/en/mysql-test-suite.html\n"); } log_msg("\n%.02f total minutes elapsed in the test cases\n\n", total_time / 60); diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 52fe282f916..e6b015e7d16 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -231,7 +231,7 @@ then echo "Please do a cd to the mysql installation directory and restart" echo "this script from there as follows:" echo "./bin/mysqld_safe". - echo "See http://dev.mysql.com/doc/mysql/en/mysqld_safe.html for more" + echo "See http://dev.mysql.com/doc/mysql/en/mysqld-safe.html for more" echo "information" exit 1 fi diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b8c9c1bef37..d8b87b69c4b 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2143,7 +2143,7 @@ bytes of memory\n", ((ulong) dflt_key_cache->key_cache_mem_size + You seem to be running 32-bit Linux and have %d concurrent connections.\n\ If you have not changed STACK_SIZE in LinuxThreads and built the binary \n\ yourself, LinuxThreads is quite likely to steal a part of the global heap for\n\ -the thread stack. Please read http://www.mysql.com/doc/en/Linux.html\n\n", +the thread stack. Please read http://dev.mysql.com/doc/mysql/en/linux.html\n\n", thread_count); } #endif /* HAVE_LINUXTHREADS */ @@ -2163,7 +2163,7 @@ Some pointers may be invalid and cause the dump to abort...\n"); fprintf(stderr, "thd->thread_id=%lu\n", (ulong) thd->thread_id); } fprintf(stderr, "\ -The manual page at http://www.mysql.com/doc/en/Crashing.html contains\n\ +The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains\n\ information that should help you find out what is causing the crash.\n"); fflush(stderr); #endif /* HAVE_STACKTRACE */ From be40fefd738589b26a3d6d3674a4f75165c27905 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Fri, 5 Oct 2007 19:23:44 +0200 Subject: [PATCH 108/203] Bug#27753 enable mysql-test-run.pl to ignore tests based on wildcard --- mysql-test/lib/mtr_cases.pl | 28 +++++++++++++++++++++++++--- mysql-test/mysql-test-run.pl | 8 ++++++-- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl index 5e176dce109..5aabb7f8863 100644 --- a/mysql-test/lib/mtr_cases.pl +++ b/mysql-test/lib/mtr_cases.pl @@ -27,6 +27,26 @@ sub collect_one_test_case ($$$$$$$); sub mtr_options_from_test_file($$); +my $do_test; +my $skip_test; + +sub init_pattern { + my ($from, $what)= @_; + if ( $from =~ /[a-z0-9]/ ) { + # Does not contain any regex, make the pattern match + # beginning of string + $from= "^$from"; + } + else { + # Check that pattern is a valid regex + eval { "" =~/$from/; 1 } or + mtr_error("Invalid regex '$from' passed to $what\nPerl says: $@"); + } + return $from; +} + + + ############################################################################## # # Collect information about test cases we are to run @@ -39,6 +59,9 @@ sub collect_test_cases ($) { my $testdir; my $resdir; + $do_test= init_pattern($::opt_do_test, "--do-test"); + $skip_test= init_pattern($::opt_skip_test, "--skip-test"); + if ( $suite eq "main" ) { $testdir= "$::glob_mysql_test_dir/t"; @@ -162,8 +185,7 @@ sub collect_test_cases ($) { } # Skip tests that does not match the --do-test= filter - next if $::opt_do_test and - ! defined mtr_match_prefix($elem,$::opt_do_test); + next if ($do_test and not $tname =~ /$do_test/o); collect_one_test_case($testdir,$resdir,$tname,$elem,$cases,\%disabled, $component_id); @@ -288,7 +310,7 @@ sub collect_one_test_case($$$$$$$) { # Skip some tests but include in list, just mark them to skip # ---------------------------------------------------------------------- - if ( $::opt_skip_test and defined mtr_match_prefix($tname,$::opt_skip_test) ) + if ( $skip_test and $tname =~ /$skip_test/o ) { $tinfo->{'skip'}= 1; return; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index d3f6c771a7c..29d3265a462 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -5080,12 +5080,16 @@ Options to control what test suites or cases to run skip-ndb[cluster] Skip all tests that need cluster skip-ndb[cluster]-slave Skip all tests that need a slave cluster ndb-extra Run extra tests from ndb directory - do-test=PREFIX Run test cases which name are prefixed with PREFIX + do-test=PREFIX or REGEX + Run test cases which name are prefixed with PREFIX + or fulfills REGEX + skip-test=PREFIX or REGEX + Skip test cases which name are prefixed with PREFIX + or fulfills REGEX start-from=PREFIX Run test cases starting from test prefixed with PREFIX suite=NAME Run the test suite named NAME. The default is "main" skip-rpl Skip the replication test cases. skip-im Don't start IM, and skip the IM test cases - skip-test=PREFIX Skip test cases which name are prefixed with PREFIX big-test Set the environment variable BIG_TEST, which can be checked from test cases. From 6132e8288823eba31322be7b4182b3fe9afa5b17 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Fri, 5 Oct 2007 19:28:09 +0200 Subject: [PATCH 109/203] Update test case to allow the .reject file to be in either var/log or r/ --- mysql-test/t/mysqltest.test | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 8a38972c00f..ec188af0244 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -1435,7 +1435,10 @@ select "this will be executed"; --exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/zero_length_file.result > /dev/null 2>&1 remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.result; +--error 0,1 remove_file $MYSQLTEST_VARDIR/log/zero_length_file.reject; +--error 0,1 +remove_file $MYSQL_TEST_DIR/r/zero_length_file.reject; # # Test that a test file that does not generate any output fails. From 0a07b64d8ac1a4f178d9ef4afc062e473cd574d8 Mon Sep 17 00:00:00 2001 From: "msvensson@pilot.mysql.com" <> Date: Fri, 5 Oct 2007 19:55:00 +0200 Subject: [PATCH 110/203] Fixed Bug #27789 "Wrong permissions of sql/share/language directories" --- extra/comp_err.c | 1 + 1 file changed, 1 insertion(+) diff --git a/extra/comp_err.c b/extra/comp_err.c index 7cc4a0aa43f..79f591e45fb 100644 --- a/extra/comp_err.c +++ b/extra/comp_err.c @@ -167,6 +167,7 @@ int main(int argc, char *argv[]) DBUG_ENTER("main"); charsets_dir= DEFAULT_CHARSET_DIR; + my_umask_dir= 0777; if (get_options(&argc, &argv)) DBUG_RETURN(1); if (!(row_count= parse_input_file(TXTFILE, &error_head, &lang_head))) From d42135724f2cca53b99dbe2c87feb5be58fdf631 Mon Sep 17 00:00:00 2001 From: "tnurnberg@sin.intern.azundris.com" <> Date: Sat, 6 Oct 2007 03:01:30 +0200 Subject: [PATCH 111/203] Bug #31253: crash comparing datetime to double after-merge fixies --- mysql-test/r/type_datetime.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index 1c8af2aa440..2a5d306cb23 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -434,7 +434,7 @@ select * from t1 where (convert(f1,datetime)) != 1; f1 15:44:44 Warnings: -Warning 1292 Truncated incorrect datetime value: '0000-00-00 45:44:44' +Warning 1292 Incorrect datetime value: '0000-00-00 45:44:44' drop table t1; set @org_mode=@@sql_mode; create table t1 (da date default '1962-03-03 23:33:34', dt datetime default '1962-03-03'); From b8b199af45342d9f08282dcc8f533bf08c4b6562 Mon Sep 17 00:00:00 2001 From: "gshchepa/uchum@gleb.loc" <> Date: Mon, 8 Oct 2007 03:48:59 +0500 Subject: [PATCH 112/203] Fixed bug #31019: the MOD() function and the % operator crash the server when a divisor is less than 1 and its fractional part is very long. For example: 1 % .123456789123456789123456789123456789123456789123456789123456789123456789123456789; Stack buffer overflow has been fixed in the do_div_mod function. --- mysql-test/r/type_decimal.result | 6 ++++++ mysql-test/t/type_decimal.test | 8 ++++++++ strings/decimal.c | 3 ++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result index 3cf24529421..72f827f11ed 100644 --- a/mysql-test/r/type_decimal.result +++ b/mysql-test/r/type_decimal.result @@ -799,3 +799,9 @@ SELECT ROUND(qty,3), dps, ROUND(qty,dps) FROM t1; ROUND(qty,3) dps ROUND(qty,dps) 1.133 3 1.133 DROP TABLE t1; +SELECT 1 % .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS '%'; +% +0.012345687012345687012345687012345687012345687012345687012345687012345687000000000 +SELECT MOD(1, .123456789123456789123456789123456789123456789123456789123456789123456789123456789) AS 'MOD()'; +MOD() +0.012345687012345687012345687012345687012345687012345687012345687012345687000000000 diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test index 5538f19f5f9..c154b2685dd 100644 --- a/mysql-test/t/type_decimal.test +++ b/mysql-test/t/type_decimal.test @@ -408,3 +408,11 @@ INSERT INTO t1 VALUES (1.1325,3); SELECT ROUND(qty,3), dps, ROUND(qty,dps) FROM t1; DROP TABLE t1; + +# +# Bug#31019: MOD() function and operator crashes MySQL when +# divisor is very long and < 1 +# + +SELECT 1 % .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS '%'; +SELECT MOD(1, .123456789123456789123456789123456789123456789123456789123456789123456789123456789) AS 'MOD()'; diff --git a/strings/decimal.c b/strings/decimal.c index f1f02f3a071..cbea0e340c6 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -2323,11 +2323,12 @@ static int do_div_mod(decimal_t *from1, decimal_t *from2, } if (unlikely(intg0+frac0 > to->len)) { - stop1-=to->len-frac0-intg0; + stop1-=frac0+intg0-to->len; frac0=to->len-intg0; to->frac=frac0*DIG_PER_DEC1; error=E_DEC_TRUNCATED; } + DBUG_ASSERT(buf0 + (stop1 - start1) <= to->buf + to->len); while (start1 < stop1) *buf0++=*start1++; } From 67302b12f68e94915c89bf824b1984032adccf2f Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Mon, 8 Oct 2007 12:57:43 +0300 Subject: [PATCH 113/203] Bug #31156: mysqld: item_sum.cc:918: virtual bool Item_sum_distinct::setup(THD*): Assertion There was an assertion to detect a bug in ROLLUP implementation. However the assertion is not true when used in a subquery context with non-cacheable statements. Fixed by turning the assertion to accepted case (just like it's done for the other aggregate functions). --- mysql-test/r/func_group.result | 10 ++++++++++ mysql-test/t/func_group.test | 13 +++++++++++++ sql/item_sum.cc | 5 ++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index e5720cc1ee0..3a2cb26910a 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -1377,4 +1377,14 @@ SELECT MIN(a), MIN(b) FROM t5 WHERE a = 1 and b > 1; MIN(a) MIN(b) 1 2 DROP TABLE t1, t2, t3, t4, t5; +CREATE TABLE t1 (a INT); +INSERT INTO t1 values (),(),(); +SELECT (SELECT SLEEP(0) FROM t1 ORDER BY AVG(DISTINCT a) ) as x FROM t1 +GROUP BY x; +x +0 +SELECT 1 FROM t1 GROUP BY (SELECT SLEEP(0) FROM t1 ORDER BY AVG(DISTINCT a) ); +1 +1 +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index 2293ac71454..8c020eb3dc8 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -860,5 +860,18 @@ SELECT MIN(a), MIN(b) FROM t5 WHERE a = 1 and b > 1; DROP TABLE t1, t2, t3, t4, t5; +# +# Bug #31156: mysqld: item_sum.cc:918: +# virtual bool Item_sum_distinct::setup(THD*): Assertion +# + +CREATE TABLE t1 (a INT); +INSERT INTO t1 values (),(),(); +SELECT (SELECT SLEEP(0) FROM t1 ORDER BY AVG(DISTINCT a) ) as x FROM t1 + GROUP BY x; +SELECT 1 FROM t1 GROUP BY (SELECT SLEEP(0) FROM t1 ORDER BY AVG(DISTINCT a) ); + +DROP TABLE t1; + ### --echo End of 5.0 tests diff --git a/sql/item_sum.cc b/sql/item_sum.cc index c20d3fba705..6421f517b21 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -905,7 +905,9 @@ bool Item_sum_distinct::setup(THD *thd) List field_list; create_field field_def; /* field definition */ DBUG_ENTER("Item_sum_distinct::setup"); - DBUG_ASSERT(tree == 0); + /* It's legal to call setup() more than once when in a subquery */ + if (tree) + return FALSE; /* Virtual table and the tree are created anew on each re-execution of @@ -2443,6 +2445,7 @@ bool Item_sum_count_distinct::setup(THD *thd) /* Setup can be called twice for ROLLUP items. This is a bug. Please add DBUG_ASSERT(tree == 0) here when it's fixed. + It's legal to call setup() more than once when in a subquery */ if (tree || table || tmp_table_param) return FALSE; From 29dca6ef333adfc018512d6c8618b706acbdd8f4 Mon Sep 17 00:00:00 2001 From: "ramil/ram@mysql.com/ramil.myoffice.izhnet.ru" <> Date: Mon, 8 Oct 2007 16:52:15 +0500 Subject: [PATCH 114/203] Fix for bug #31438: updatexml still crashes Problem: check missed if the second updatexml() argument is valid. Fix: check it. --- mysql-test/r/xml.result | 11 +++++++++++ mysql-test/t/xml.test | 11 +++++++++++ sql/item_xmlfunc.cc | 3 ++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/xml.result b/mysql-test/r/xml.result index a1f2c80e766..552f4896698 100644 --- a/mysql-test/r/xml.result +++ b/mysql-test/r/xml.result @@ -1012,3 +1012,14 @@ select ExtractValue('a', '/a[@x=@y0123456789_0123456789_0123456789_012345 ERROR HY000: XPATH error: comparison of two nodesets is not supported: '=@y0123456789_0123456789_0123456' select ExtractValue('a', '/a[@x=$y0123456789_0123456789_0123456789_0123456789]'); ERROR HY000: Unknown XPATH variable at: '$y0123456789_0123456789_01234567' +select updatexml(NULL, 1, 1), updatexml(1, NULL, 1), updatexml(1, 1, NULL); +updatexml(NULL, 1, 1) updatexml(1, NULL, 1) updatexml(1, 1, NULL) +NULL NULL NULL +select updatexml(NULL, NULL, 1), updatexml(1, NULL, NULL), +updatexml(NULL, 1, NULL); +updatexml(NULL, NULL, 1) updatexml(1, NULL, NULL) updatexml(NULL, 1, NULL) +NULL NULL NULL +select updatexml(NULL, NULL, NULL); +updatexml(NULL, NULL, NULL) +NULL +End of 5.1 tests diff --git a/mysql-test/t/xml.test b/mysql-test/t/xml.test index 1d16652ab1e..6c7d9af1b63 100644 --- a/mysql-test/t/xml.test +++ b/mysql-test/t/xml.test @@ -533,3 +533,14 @@ select UpdateXML('a',repeat('a b ',1000),''); select ExtractValue('a', '/a[@x=@y0123456789_0123456789_0123456789_0123456789]'); --error 1105 select ExtractValue('a', '/a[@x=$y0123456789_0123456789_0123456789_0123456789]'); + +# +# Bug #31438: updatexml still crashes +# + +select updatexml(NULL, 1, 1), updatexml(1, NULL, 1), updatexml(1, 1, NULL); +select updatexml(NULL, NULL, 1), updatexml(1, NULL, NULL), + updatexml(NULL, 1, NULL); +select updatexml(NULL, NULL, NULL); + +--echo End of 5.1 tests diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index 15be9c97b6e..1a6c15a4d2e 100644 --- a/sql/item_xmlfunc.cc +++ b/sql/item_xmlfunc.cc @@ -2580,7 +2580,8 @@ void Item_xml_str_func::fix_length_and_dec() return; } - xp= args[1]->val_str(&tmp); + if (!(xp= args[1]->val_str(&tmp))) + return; my_xpath_init(&xpath); xpath.cs= collation.collation; xpath.debug= 0; From 128772ba1ffc3ef29cb3dae718b89cc5bf5a1902 Mon Sep 17 00:00:00 2001 From: "anozdrin/alik@station." <> Date: Mon, 8 Oct 2007 17:09:28 +0400 Subject: [PATCH 115/203] Fix compilation warning. --- sql/sql_parse.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 0aa9591e95d..c3565dd9b17 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1527,7 +1527,7 @@ int end_trans(THD *thd, enum enum_mysql_completiontype completion) 1 request of thread shutdown (see dispatch_command() description) */ -bool do_command(THD *thd) +static bool do_command(THD *thd) { char *packet= 0; ulong packet_length; From 2885d0df1556653706ee0dd70e029e6cfdb476ce Mon Sep 17 00:00:00 2001 From: "anozdrin/alik@station." <> Date: Mon, 8 Oct 2007 17:59:23 +0400 Subject: [PATCH 116/203] Get rid of compilation warning. --- sql/sql_parse.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index c3565dd9b17..8c61243e3c5 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -93,7 +93,9 @@ const char *xa_state_names[]={ "NON-EXISTING", "ACTIVE", "IDLE", "PREPARED" }; +#ifndef EMBEDDED_LIBRARY static bool do_command(THD *thd); +#endif // EMBEDDED_LIBRARY #ifdef __WIN__ static void test_signal(int sig_ptr) From 437fdeaa16c42979a79743520a46e311235c604c Mon Sep 17 00:00:00 2001 From: "malff@lambda.hsd1.co.comcast.net." <> Date: Mon, 8 Oct 2007 12:37:57 -0600 Subject: [PATCH 117/203] Test cleanup, the upgrade test script assumes a unix like environment --- mysql-test/t/upgrade.test | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mysql-test/t/upgrade.test b/mysql-test/t/upgrade.test index 40bd17fc3a5..05f430b087b 100644 --- a/mysql-test/t/upgrade.test +++ b/mysql-test/t/upgrade.test @@ -1,5 +1,10 @@ -- source include/not_embedded.inc +# Temporary disabled on windows, +# because of --exec mkdir +# TODO: implement Bug#31004 and remove this limitation +--source include/not_windows.inc + --disable_warnings drop database if exists `mysqltest1`; drop database if exists `mysqltest-1`; @@ -60,7 +65,6 @@ drop table t1; # Bug#28360 (RENAME DATABASE destroys routines) # - --disable_warnings drop database if exists `tabc`; drop database if exists `a-b-c`; From 09f6306ac31854dab52dcf8b5dc043acf82c96e6 Mon Sep 17 00:00:00 2001 From: "gshchepa/uchum@gleb.loc" <> Date: Tue, 9 Oct 2007 01:07:15 +0500 Subject: [PATCH 118/203] Fixed bug #31310. Locked rows of the InnoDB storage was silently skipped in the read-committed isolation level. QUICK_RANGE_SELECT for unique ranges lacks second (blocking) read of the record that was read semi-consistently and just skip it. The handler::read_multi_range_next method has been modified to retry previous unique range if the previous read was semi-consistent. --- mysql-test/include/mix1.inc | 125 +++++++++++++++++++++++++++++++ mysql-test/r/innodb_mysql.result | 80 ++++++++++++++++++++ sql/handler.cc | 8 +- 3 files changed, 210 insertions(+), 3 deletions(-) diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc index e2a22303d9d..b88e3a3cde5 100644 --- a/mysql-test/include/mix1.inc +++ b/mysql-test/include/mix1.inc @@ -29,6 +29,7 @@ eval SET SESSION STORAGE_ENGINE = $engine_type; --disable_warnings drop table if exists t1,t2,t3,t1m,t1i,t2m,t2i,t4; +drop procedure if exists p1; --enable_warnings @@ -1146,4 +1147,128 @@ select @b:=f2 from t1; select if(@a=@b,"ok","wrong"); drop table t1; +# +# Bug #31310: Locked rows silently skipped in read-committed isolation level. +# + +connect (con1,localhost,root,,); +connect (con2,localhost,root,,); +SET SESSION AUTOCOMMIT = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +--echo # Switch to connection con1 +connection con1; + +eval +CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256)) +ENGINE = $engine_type; +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; +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; --echo End of 5.1 tests diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index 0757936a8f7..0b3c1d33536 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -1,5 +1,6 @@ SET SESSION STORAGE_ENGINE = InnoDB; drop table if exists t1,t2,t3,t1m,t1i,t2m,t2i,t4; +drop procedure if exists p1; create table t1 ( c_id int(11) not null default '0', org_id int(11) default null, @@ -1419,4 +1420,83 @@ select if(@a=@b,"ok","wrong"); if(@a=@b,"ok","wrong") ok drop table t1; +SET SESSION AUTOCOMMIT = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +# Switch to connection con1 +CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256)) +ENGINE = InnoDB; +INSERT INTO t1 VALUES (1,2); +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; End of 5.1 tests diff --git a/sql/handler.cc b/sql/handler.cc index 75c3a64bc27..3939873ec7d 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -3145,6 +3145,8 @@ int handler::read_multi_range_next(KEY_MULTI_RANGE **found_range_p) } else { + if (was_semi_consistent_read()) + goto scan_it_again; /* We need to set this for the last range only, but checking this condition is more expensive than just setting the result code. @@ -3152,10 +3154,10 @@ int handler::read_multi_range_next(KEY_MULTI_RANGE **found_range_p) result= HA_ERR_END_OF_FILE; } + multi_range_curr++; +scan_it_again: /* Try the next range(s) until one matches a record. */ - for (multi_range_curr++; - multi_range_curr < multi_range_end; - multi_range_curr++) + for (; multi_range_curr < multi_range_end; multi_range_curr++) { result= read_range_first(multi_range_curr->start_key.keypart_map ? &multi_range_curr->start_key : 0, From 6a7947b8ab0d2f5e2c946052828e6de5f825c378 Mon Sep 17 00:00:00 2001 From: "iggy@alf.(none)" <> Date: Mon, 8 Oct 2007 17:43:32 -0400 Subject: [PATCH 119/203] Bug#28535 mistake in mysqldump error message - Fixed error message. --- client/mysqldump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 582e9e3b3b9..b6efe89be22 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1888,7 +1888,7 @@ static uint dump_events_for_db(char *db) if (create_delimiter(row[3], delimiter, sizeof(delimiter)) == NULL) { fprintf(stderr, "%s: Warning: Can't create delimiter for event '%s'\n", - event_name, my_progname); + my_progname, event_name); DBUG_RETURN(1); } From 19107288e470fed4b01577bc5c0d3a6b71601840 Mon Sep 17 00:00:00 2001 From: "iggy@alf.(none)" <> Date: Mon, 8 Oct 2007 22:30:41 -0400 Subject: [PATCH 120/203] Bug#28774 mysql_upgrade creates tempfiles in root-dir (C:\) and doesn't clean them up - Make sure to cleanup temporary files after use. --- client/mysql_upgrade.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 1646f2baf51..02829cd2178 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -456,7 +456,11 @@ static int run_query(const char *query, DYNAMIC_STRING *ds_res, if (my_write(fd, query, strlen(query), MYF(MY_FNABP | MY_WME))) + { + my_close(fd, MYF(0)); + my_delete(query_file_path, MYF(0)); die("Failed to write to '%s'", query_file_path); + } ret= run_tool(mysql_path, ds_res, From d29146f9f42caa3696ccc540449e4c4dd8732e35 Mon Sep 17 00:00:00 2001 From: "mhansson/martin@linux-st28.site" <> Date: Tue, 9 Oct 2007 11:36:05 +0200 Subject: [PATCH 121/203] Bug#30832:Assertion + crash with select name_const('test',now()); Completion of previous patch. Negative number were denied as the second argument to NAME_CONST. --- mysql-test/r/func_misc.result | 6 ++++++ mysql-test/t/func_misc.test | 2 ++ sql/item_func.h | 1 + 3 files changed, 9 insertions(+) diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index bb6f4127a2a..c941790c35b 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -195,9 +195,15 @@ NULL SELECT NAME_CONST('test', 1); test 1 +SELECT NAME_CONST('test', -1); +test +-1 SELECT NAME_CONST('test', 1.0); test 1.0 +SELECT NAME_CONST('test', -1.0); +test +-1.0 SELECT NAME_CONST('test', 'test'); test test diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index c93e411e691..2c34f77b1ff 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -199,7 +199,9 @@ SELECT NAME_CONST('test', UPPER('test')); SELECT NAME_CONST('test', NULL); SELECT NAME_CONST('test', 1); +SELECT NAME_CONST('test', -1); SELECT NAME_CONST('test', 1.0); +SELECT NAME_CONST('test', -1.0); SELECT NAME_CONST('test', 'test'); --echo End of 5.0 tests diff --git a/sql/item_func.h b/sql/item_func.h index 87c9e016df2..43221a18a5b 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -435,6 +435,7 @@ public: longlong int_op(); my_decimal *decimal_op(my_decimal *); const char *func_name() const { return "-"; } + virtual bool basic_const_item() const { return args[0]->basic_const_item(); } void fix_length_and_dec(); void fix_num_length_and_dec(); uint decimal_precision() const { return args[0]->decimal_precision(); } From 479238517797315c10adc3246c571975f28de51c Mon Sep 17 00:00:00 2001 From: "ramil/ram@mysql.com/ramil.myoffice.izhnet.ru" <> Date: Tue, 9 Oct 2007 14:37:21 +0500 Subject: [PATCH 122/203] Fix for bug #31249: Assertion `!table || (!table->write_set || bitmap_is_set(table->write_set, fiel Problem: creating a temporary table we allocate the group buffer if needed followed by table bitmaps (see create_tmp_table()). Reserving less memory for the group buffer than actually needed (used) for values retrieval may lead to overlapping with followed bitmaps in the memory pool that in turn leads to unpredictable consequences. As we use Item->max_length sometimes to calculate group buffer size, it must be set to proper value. In this particular case Item_datetime_typecast::max_length is too small. Another problem is that we use max_length to calculate the group buffer key length for items represented as DATE/TIME fields which is superfluous. Fix: set Item_datetime_typecast::max_length properly, accurately calculate the group buffer key length for items represented as DATE/TIME fields in the buffer. --- mysql-test/r/type_datetime.result | 14 ++++++++++++++ mysql-test/t/type_datetime.test | 13 +++++++++++++ sql/item_timefunc.h | 4 +++- sql/sql_select.cc | 26 ++++++++++++++++++++++---- 4 files changed, 52 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index 9e47b5da2b6..b96ed330d73 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -427,3 +427,17 @@ f1 Warnings: Warning 1292 Incorrect datetime value: '2007010100000' for column 'f1' at row 1 drop table t1; +create table t1 (a tinyint); +insert into t1 values (), (), (); +select sum(a) from t1 group by convert(a, datetime); +sum(a) +NULL +select convert(a, datetime) from t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def convert(a, datetime) 12 29 0 Y 128 6 63 +convert(a, datetime) +NULL +NULL +NULL +drop table t1; +End of 5.0 tests diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test index ffda593f320..070230bae75 100644 --- a/mysql-test/t/type_datetime.test +++ b/mysql-test/t/type_datetime.test @@ -282,3 +282,16 @@ select * from t1 where f1 between 20020101 and 20070101000000; select * from t1 where f1 between 2002010 and 20070101000000; select * from t1 where f1 between 20020101 and 2007010100000; drop table t1; + +# +# Bug #31249: problem with convert(..., datetime) +# +create table t1 (a tinyint); +insert into t1 values (), (), (); +select sum(a) from t1 group by convert(a, datetime); +--enable_metadata +select convert(a, datetime) from t1; +--disable_metadata +drop table t1; + +--echo End of 5.0 tests diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 8e925a0156f..94bee28bb6b 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -844,7 +844,9 @@ public: enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; } void fix_length_and_dec() { - Item_typecast_maybe_null::fix_length_and_dec(); + collation.set(&my_charset_bin); + maybe_null= 1; + max_length= MAX_DATETIME_FULL_WIDTH * MY_CHARSET_BIN_MB_MAXLEN; decimals= DATETIME_DEC; } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 1d11f23d854..7d4421b2749 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -13902,13 +13902,31 @@ calc_group_buffer(JOIN *join,ORDER *group) group_item->decimals); break; case STRING_RESULT: + { + enum enum_field_types type= group_item->field_type(); /* - Group strings are taken as varstrings and require an length field. - A field is not yet created by create_tmp_field() - and the sizes should match up. + As items represented as DATE/TIME fields in the group buffer + have STRING_RESULT result type, we increase the length + by 8 as maximum pack length of such fields. */ - key_length+= group_item->max_length + HA_KEY_BLOB_LENGTH; + if (type == MYSQL_TYPE_TIME || + type == MYSQL_TYPE_DATE || + type == MYSQL_TYPE_DATETIME || + type == MYSQL_TYPE_TIMESTAMP) + { + key_length+= 8; + } + else + { + /* + Group strings are taken as varstrings and require an length field. + A field is not yet created by create_tmp_field() + and the sizes should match up. + */ + key_length+= group_item->max_length + HA_KEY_BLOB_LENGTH; + } break; + } default: /* This case should never be choosen */ DBUG_ASSERT(0); From 27ee6db9db2128f4b2d34c1ea00da2d88b2748ec Mon Sep 17 00:00:00 2001 From: "anozdrin/alik@station." <> Date: Tue, 9 Oct 2007 14:53:15 +0400 Subject: [PATCH 123/203] Fix merge. --- sql/mysql_priv.h | 1 + sql/sql_connect.cc | 16 ++++++++++++---- sql/sql_parse.cc | 2 -- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 9b1578280e4..6a7e3e00f6f 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -965,6 +965,7 @@ void init_update_queries(void); void free_max_user_conn(void); pthread_handler_t handle_bootstrap(void *arg); bool mysql_execute_command(THD *thd); +bool do_command(THD *thd); bool dispatch_command(enum enum_server_command command, THD *thd, char* packet, uint packet_length); void log_slow_statement(THD *thd); diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 6bb0f62d843..9785b30ea00 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -973,21 +973,29 @@ void end_connection(THD *thd) plugin_thdvar_cleanup(thd); if (thd->user_connect) decrease_user_connections(thd->user_connect); + + if (thd->killed || + net->error && net->vio != 0 && net->report_error) + { + statistic_increment(aborted_threads,&LOCK_status); + } + if (net->error && net->vio != 0 && net->report_error) { - Security_context *sctx= thd->security_ctx; if (!thd->killed && thd->variables.log_warnings > 1) + { + Security_context *sctx= thd->security_ctx; + sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION), thd->thread_id,(thd->db ? thd->db : "unconnected"), sctx->user ? sctx->user : "unauthenticated", sctx->host_or_ip, (net->last_errno ? ER(net->last_errno) : ER(ER_UNKNOWN_ERROR))); + } + net_send_error(thd, net->last_errno, NullS); - statistic_increment(aborted_threads,&LOCK_status); } - else if (thd->killed) - statistic_increment(aborted_threads,&LOCK_status); } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 91eaadb0d9f..695e923e816 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -86,8 +86,6 @@ const char *xa_state_names[]={ "NON-EXISTING", "ACTIVE", "IDLE", "PREPARED" }; -static bool do_command(THD *thd); - static void unlock_locked_tables(THD *thd) { if (thd->locked_tables) From 1285baf608157bd22b42e1e7ee63c935bc4fed83 Mon Sep 17 00:00:00 2001 From: "istruewing@stella.local" <> Date: Tue, 9 Oct 2007 13:10:51 +0200 Subject: [PATCH 124/203] Bug#15522 - create ... select and with merge tables Added test case. The fix for Bug#20662 does also fix this one. --- mysql-test/r/merge.result | 5 +++++ mysql-test/t/merge.test | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index 42669eeb66f..24a56fbf575 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -876,4 +876,9 @@ CHECK TABLE tm1; Table Op Msg_type Msg_text test.tm1 check status OK DROP TABLE tm1, t1, t2; +CREATE TABLE t1(c1 INT); +CREATE TABLE t2 (c1 INT) ENGINE=MERGE UNION=(t1) INSERT_METHOD=FIRST; +CREATE TABLE IF NOT EXISTS t1 SELECT * FROM t2; +ERROR HY000: You can't specify target table 't1' for update in FROM clause +DROP TABLE t1, t2; End of 5.0 tests diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index c3e5cef5e63..b5c1a01fe8e 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -507,4 +507,18 @@ SELECT * FROM tm1; CHECK TABLE tm1; DROP TABLE tm1, t1, t2; +# +# Bug#15522 - create ... select and with merge tables +# +# This was fixed together with Bug#20662 (Infinite loop in CREATE TABLE +# IF NOT EXISTS ... SELECT with locked tables). +# The new behavior for MERGE tables is consistent with the +# CREATE TABLE SELECT behavior for ordinary tables. +# +CREATE TABLE t1(c1 INT); +CREATE TABLE t2 (c1 INT) ENGINE=MERGE UNION=(t1) INSERT_METHOD=FIRST; +--error ER_UPDATE_TABLE_USED +CREATE TABLE IF NOT EXISTS t1 SELECT * FROM t2; +DROP TABLE t1, t2; + --echo End of 5.0 tests From 148ce22add54b3ab10bb568bb47078f01167973a Mon Sep 17 00:00:00 2001 From: "mhansson/martin@linux-st28.site" <> Date: Tue, 9 Oct 2007 14:58:09 +0200 Subject: [PATCH 125/203] Bug#31160: MAKETIME() crashes server when returning NULL in ORDER BY using filesort Even though it returns NULL, the MAKETIME function did not have this property set, causing a failed assertion (designed to catch exactly this). Fixed by setting the nullability property of MAKETIME(). --- mysql-test/r/func_sapdb.result | 2 +- mysql-test/r/func_time.result | 9 +++++++++ mysql-test/t/func_time.test | 10 ++++++++++ sql/item_timefunc.h | 5 ++++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/func_sapdb.result b/mysql-test/r/func_sapdb.result index dbae7e551e5..e2ed9c98adc 100644 --- a/mysql-test/r/func_sapdb.result +++ b/mysql-test/r/func_sapdb.result @@ -196,7 +196,7 @@ f2 datetime YES NULL f3 time YES NULL f4 time YES NULL f5 time YES NULL -f6 time NO 00:00:00 +f6 time YES NULL f7 datetime YES NULL f8 date YES NULL f9 time YES NULL diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index ee8b8c1e908..74859be4d04 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -1027,6 +1027,15 @@ fmtddate field2 Sep-4 12:00AM abcd DROP TABLE testBug8868; SET NAMES DEFAULT; +CREATE TABLE t1 ( +a TIMESTAMP +); +INSERT INTO t1 VALUES (now()), (now()); +SELECT 1 FROM t1 ORDER BY MAKETIME(1, 1, a); +1 +1 +1 +DROP TABLE t1; (select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H) union (select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H); diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 86c848983fa..c0a449ac3f4 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -545,6 +545,16 @@ DROP TABLE testBug8868; SET NAMES DEFAULT; +# +# Bug #31160: MAKETIME() crashes server when returning NULL in ORDER BY using +# filesort +# +CREATE TABLE t1 ( + a TIMESTAMP +); +INSERT INTO t1 VALUES (now()), (now()); +SELECT 1 FROM t1 ORDER BY MAKETIME(1, 1, a); +DROP TABLE t1; # # Bug #19844 time_format in Union truncates values diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 8e925a0156f..3e860017d89 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -962,7 +962,10 @@ class Item_func_maketime :public Item_str_timefunc { public: Item_func_maketime(Item *a, Item *b, Item *c) - :Item_str_timefunc(a, b ,c) {} + :Item_str_timefunc(a, b, c) + { + maybe_null= TRUE; + } String *val_str(String *str); const char *func_name() const { return "maketime"; } }; From e908bb72e5e5dd9b2e022ff9871713bbf753e9b0 Mon Sep 17 00:00:00 2001 From: "ramil/ram@mysql.com/ramil.myoffice.izhnet.ru" <> Date: Tue, 9 Oct 2007 19:16:39 +0500 Subject: [PATCH 126/203] Fix for bug #29444: crash with partition refering to table in create-select Problem: creating a partitioned table during name resolution for the partition function we search for column names in all parts of the CREATE TABLE query. It is superfluous (and wrong) sometimes. Fix: launch name resolution for the partition function against the table we're creating. --- mysql-test/r/partition.result | 20 ++++++++++++++++++++ mysql-test/t/partition.test | 20 ++++++++++++++++++++ sql/item.cc | 4 +++- sql/sql_lex.cc | 1 + sql/sql_lex.h | 8 ++++++++ sql/sql_partition.cc | 7 +++++++ 6 files changed, 59 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 5d985d053fc..7120e3ea9e6 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -1267,4 +1267,24 @@ ALTER TABLE general_log PARTITION BY RANGE (TO_DAYS(event_time)) ERROR HY000: Incorrect usage of PARTITION and log table ALTER TABLE general_log ENGINE = CSV; SET GLOBAL general_log = default; +use test; +create table t2 (b int); +create table t1 (b int) +PARTITION BY RANGE (t2.b) ( +PARTITION p1 VALUES LESS THAN (10), +PARTITION p2 VALUES LESS THAN (20) +) select * from t2; +ERROR 42S22: Unknown column 't2.b' in 'partition function' +create table t1 (a int) +PARTITION BY RANGE (b) ( +PARTITION p1 VALUES LESS THAN (10), +PARTITION p2 VALUES LESS THAN (20) +) select * from t2; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (b) (PARTITION p1 VALUES LESS THAN (10) ENGINE = MyISAM, PARTITION p2 VALUES LESS THAN (20) ENGINE = MyISAM) */ +drop table t1, t2; End of 5.1 tests diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 42db23dadef..2be2ab83c88 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -1493,10 +1493,30 @@ ALTER TABLE general_log PARTITION BY RANGE (TO_DAYS(event_time)) (PARTITION p0 VALUES LESS THAN (733144), PARTITION p1 VALUES LESS THAN (3000000)); ALTER TABLE general_log ENGINE = CSV; SET GLOBAL general_log = default; +use test; # # Bug #27084 partitioning by list seems failing when using case # BUG #18198: Case no longer supported, test case removed # +# +# Bug #29444: crash with partition refering to table in create-select +# + +create table t2 (b int); +--error 1054 +create table t1 (b int) +PARTITION BY RANGE (t2.b) ( + PARTITION p1 VALUES LESS THAN (10), + PARTITION p2 VALUES LESS THAN (20) +) select * from t2; +create table t1 (a int) +PARTITION BY RANGE (b) ( + PARTITION p1 VALUES LESS THAN (10), + PARTITION p2 VALUES LESS THAN (20) +) select * from t2; +show create table t1; +drop table t1, t2; + --echo End of 5.1 tests diff --git a/sql/item.cc b/sql/item.cc index dc94615c6e6..3b592633ad0 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -3860,7 +3860,9 @@ bool Item_field::fix_fields(THD *thd, Item **reference) context->first_name_resolution_table, context->last_name_resolution_table, reference, - IGNORE_EXCEPT_NON_UNIQUE, + thd->lex->use_only_table_context ? + REPORT_ALL_ERRORS : + IGNORE_EXCEPT_NON_UNIQUE, !any_privileges, TRUE)) == not_found_field) diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 0a5f83af400..4ee66cb1e8d 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -338,6 +338,7 @@ void lex_start(THD *thd) lex->query_tables= 0; lex->reset_query_tables_list(FALSE); lex->expr_allows_subselect= TRUE; + lex->use_only_table_context= FALSE; lex->name.str= 0; lex->name.length= 0; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 08104769704..50211f6b3f9 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1693,6 +1693,14 @@ typedef struct st_lex : public Query_tables_list */ const char *fname_start; const char *fname_end; + + /** + During name resolution search only in the table list given by + Name_resolution_context::first_name_resolution_table and + Name_resolution_context::last_name_resolution_table + (see Item_field::fix_fields()). + */ + bool use_only_table_context; LEX_STRING view_body_utf8; diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 8a8a03cb4e4..0cc2cac2a1a 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -902,6 +902,7 @@ bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table, const char *save_where; char* db_name; char db_name_string[FN_REFLEN]; + bool save_use_only_table_context; DBUG_ENTER("fix_fields_part_func"); if (part_info->fixed) @@ -958,8 +959,14 @@ bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table, This is a tricky call to prepare for since it can have a large number of interesting side effects, both desirable and undesirable. */ + + save_use_only_table_context= thd->lex->use_only_table_context; + thd->lex->use_only_table_context= TRUE; + error= func_expr->fix_fields(thd, (Item**)0); + thd->lex->use_only_table_context= save_use_only_table_context; + context->table_list= save_table_list; context->first_name_resolution_table= save_first_table; context->last_name_resolution_table= save_last_table; From 7252cbe1e0e48c8497fac35c99b113294095217e Mon Sep 17 00:00:00 2001 From: "davi@moksha.local" <> Date: Tue, 9 Oct 2007 12:02:59 -0300 Subject: [PATCH 127/203] Bug#31409 RENAME TABLE causes server crash or deadlock when used with HANDLER statements This deadlock occurs when a client issues a HANDLER ... OPEN statement that tries to open a table that has a pending name-lock on it by another client that also needs a name-lock on some other table which is already open and associated to a HANDLER instance owned by the first client. The deadlock happens because the open_table() function will back-off and wait until the name-lock goes away, causing a circular wait if some other name-lock is also pending for one of the open HANDLER tables. Such situation, for example, can be easily repeated by issuing a RENAME TABLE command in such a way that the existing table is already open as a HANDLER table by another client and this client tries to open a HANDLER to the new table name. The solution is to allow handler tables with older versions (marked for flush) to be closed before waiting for the name-lock completion. This is safe because no other name-lock can be issued between the flush and the check for pending name-locks. The test case for this bug is going to be committed into 5.1 because it requires a test feature only avaiable in 5.1 (wait_condition). --- sql/sql_base.cc | 12 +++++++++++- sql/sql_handler.cc | 47 +++++++++++++++++++++++++++------------------- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 289924ff418..905190cb9cd 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1745,7 +1745,13 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, DBUG_RETURN(0); } - /* close handler tables which are marked for flush */ + /* + In order for the back off and re-start process to work properly, + handler tables having old versions (due to FLUSH TABLES or pending + name-lock) MUST be closed. This is specially important if a name-lock + is pending for any table of the handler_tables list, otherwise a + deadlock may occur. + */ if (thd->handler_tables) mysql_ha_flush(thd, (TABLE_LIST*) NULL, MYSQL_HA_REOPEN_ON_USAGE, TRUE); @@ -1810,6 +1816,10 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, table->db_stat == 0 signals wait_for_locked_table_names that the tables in question are not used any more. See table_is_used call for details. + + Notice that HANDLER tables were already taken care of by + the earlier call to mysql_ha_flush() in this same critical + section. */ close_old_data_files(thd,thd->open_tables,0,0); /* diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 89090c9fa63..e87381dd49c 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -182,7 +182,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen) char *db, *name, *alias; uint dblen, namelen, aliaslen, counter; int error; - TABLE *backup_open_tables, *backup_handler_tables; + TABLE *backup_open_tables; DBUG_ENTER("mysql_ha_open"); DBUG_PRINT("enter",("'%s'.'%s' as '%s' reopen: %d", tables->db, tables->table_name, tables->alias, @@ -211,14 +211,20 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen) } } - /* save open_ and handler_ tables state */ - backup_open_tables= thd->open_tables; - backup_handler_tables= thd->handler_tables; + /* + Save and reset the open_tables list so that open_tables() won't + be able to access (or know about) the previous list. And on return + from open_tables(), thd->open_tables will contain only the opened + table. - /* no pre-opened tables */ + The thd->handler_tables list is kept as-is to avoid deadlocks if + open_table(), called by open_tables(), needs to back-off because + of a pending name-lock on the table being opened. + + See open_table() back-off comments for more details. + */ + backup_open_tables= thd->open_tables; thd->open_tables= NULL; - /* to avoid flushes */ - thd->handler_tables= NULL; /* open_tables() will set 'tables->table' if successful. @@ -231,9 +237,12 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen) error= open_tables(thd, &tables, &counter, 0); /* restore the state and merge the opened table into handler_tables list */ - thd->handler_tables= thd->open_tables ? - thd->open_tables->next= backup_handler_tables, - thd->open_tables : backup_handler_tables; + if (thd->open_tables) + { + thd->open_tables->next= thd->handler_tables; + thd->handler_tables= thd->open_tables; + } + thd->open_tables= backup_open_tables; if (error) @@ -360,7 +369,7 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables, ha_rows select_limit_cnt, ha_rows offset_limit_cnt) { TABLE_LIST *hash_tables; - TABLE *table, *backup_open_tables, *backup_handler_tables; + TABLE *table, *backup_open_tables; MYSQL_LOCK *lock; List list; Protocol *protocol= thd->protocol; @@ -437,20 +446,20 @@ retry: } tables->table=table; - /* save open_ and handler_ tables state */ + /* save open_tables state */ backup_open_tables= thd->open_tables; - backup_handler_tables= thd->handler_tables; - - /* no pre-opened tables */ - thd->open_tables= NULL; - /* to avoid flushes */ - thd->handler_tables= NULL; + /* + mysql_lock_tables() needs thd->open_tables to be set correctly to + be able to handle aborts properly. When the abort happens, it's + safe to not protect thd->handler_tables because it won't close any + tables. + */ + thd->open_tables= thd->handler_tables; lock= mysql_lock_tables(thd, &tables->table, 1, MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN, &need_reopen); /* restore previous context */ - thd->handler_tables= backup_handler_tables; thd->open_tables= backup_open_tables; if (need_reopen) From fa5eb277eceb71cc71fd8052cb12692ea4dffe4a Mon Sep 17 00:00:00 2001 From: "ramil/ram@mysql.com/ramil.myoffice.izhnet.ru" <> Date: Tue, 9 Oct 2007 22:40:22 +0500 Subject: [PATCH 128/203] metadata test of bug # 31249: problem with convert(..., datetime) removed as PS protocol gives slightly different metadata. --- mysql-test/r/type_datetime.result | 7 ------- mysql-test/t/type_datetime.test | 3 --- 2 files changed, 10 deletions(-) diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index 5929a315e8d..590e9b7c9e0 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -441,12 +441,5 @@ insert into t1 values (), (), (); select sum(a) from t1 group by convert(a, datetime); sum(a) NULL -select convert(a, datetime) from t1; -Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def convert(a, datetime) 12 29 0 Y 128 6 63 -convert(a, datetime) -NULL -NULL -NULL drop table t1; End of 5.0 tests diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test index b909b4894a3..20733a14d46 100644 --- a/mysql-test/t/type_datetime.test +++ b/mysql-test/t/type_datetime.test @@ -299,9 +299,6 @@ drop table t1; create table t1 (a tinyint); insert into t1 values (), (), (); select sum(a) from t1 group by convert(a, datetime); ---enable_metadata -select convert(a, datetime) from t1; ---disable_metadata drop table t1; --echo End of 5.0 tests From fd3c6b185515bc6a0ea8598e98531c5f8b326502 Mon Sep 17 00:00:00 2001 From: "davi@virtua-cwbas201-21-158-74.ctb.virtua.com.br" <> Date: Tue, 9 Oct 2007 20:46:33 -0300 Subject: [PATCH 129/203] Bug#28318 CREATE FUNCTION (UDF) requires a schema Bug#29816 Syntactically wrong query fails with misleading error message The core problem is that an SQL-invoked function name can be a that contains no , but the mysql parser insists that all stored procedures (function, procedures and triggers) must have a , which is not true for functions. This problem is especially visible when trying to create a function or when a query contains a syntax error after a function call (in the same query), both will fail with a "No database selected" message if the session is not attached to a particular schema, but the first one should succeed and the second fail with a "syntax error" message. Part of the fix is to revamp the sp name handling so that a schema name may be omitted for functions -- this means that the internal function name representation may not have a dot, which represents that the function doesn't have a schema name. The other part is to place schema checks after the type (function, trigger or procedure) of the routine is known. --- mysql-test/r/sp-error.result | 13 +++++++++++++ mysql-test/r/udf.result | 7 +++++++ mysql-test/t/sp-error.test | 20 ++++++++++++++++++++ mysql-test/t/udf.test | 14 ++++++++++++++ sql/sp.cc | 13 +++---------- sql/sp_head.cc | 31 ++++++++++++++++++++++++++++--- sql/sp_head.h | 11 +---------- sql/sql_yacc.yy | 31 ++++++++++++++++++++++++++----- 8 files changed, 112 insertions(+), 28 deletions(-) diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index bd0640b2b14..cc217ecd093 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -1452,3 +1452,16 @@ end until true end repeat retry; end// ERROR 42000: LEAVE with no matching label: retry +DROP DATABASE IF EXISTS mysqltest; +CREATE DATABASE mysqltest; +USE mysqltest; +DROP DATABASE mysqltest; +SELECT inexistent(), 1 + ,; +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 +SELECT inexistent(); +ERROR 42000: FUNCTION inexistent does not exist +SELECT .inexistent(); +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 +SELECT ..inexistent(); +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 '.inexistent()' at line 1 +USE test; diff --git a/mysql-test/r/udf.result b/mysql-test/r/udf.result index 2e9cf217ed6..3e29c780ca8 100644 --- a/mysql-test/r/udf.result +++ b/mysql-test/r/udf.result @@ -296,4 +296,11 @@ Qcache_queries_in_cache 0 drop table t1; drop function metaphon; set GLOBAL query_cache_size=default; +DROP DATABASE IF EXISTS mysqltest; +CREATE DATABASE mysqltest; +USE mysqltest; +DROP DATABASE mysqltest; +CREATE FUNCTION metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB"; +DROP FUNCTION metaphon; +USE test; End of 5.0 tests. diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index 240cda67edc..a1abf4852b0 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -2089,6 +2089,26 @@ end// delimiter ;// +# +# Bug#29816 Syntactically wrong query fails with misleading error message +# + +--disable_warnings +DROP DATABASE IF EXISTS mysqltest; +--enable_warnings +CREATE DATABASE mysqltest; +USE mysqltest; +DROP DATABASE mysqltest; +--error ER_PARSE_ERROR +SELECT inexistent(), 1 + ,; +--error ER_SP_DOES_NOT_EXIST +SELECT inexistent(); +--error ER_PARSE_ERROR +SELECT .inexistent(); +--error ER_PARSE_ERROR +SELECT ..inexistent(); +USE test; + # # BUG#NNNN: New bug synopsis # diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test index 75af1f4be4b..6a516a29534 100644 --- a/mysql-test/t/udf.test +++ b/mysql-test/t/udf.test @@ -311,5 +311,19 @@ drop table t1; drop function metaphon; set GLOBAL query_cache_size=default; +# +# Bug#28318 CREATE FUNCTION (UDF) requires a schema +# + +--disable_warnings +DROP DATABASE IF EXISTS mysqltest; +--enable_warnings +CREATE DATABASE mysqltest; +USE mysqltest; +DROP DATABASE mysqltest; +--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB +eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_LIB"; +DROP FUNCTION metaphon; +USE test; --echo End of 5.0 tests. diff --git a/sql/sp.cc b/sql/sp.cc index 75d6fa4618f..0b84e1ad07f 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -1405,12 +1405,12 @@ static bool add_used_routine(LEX *lex, Query_arena *arena, { Sroutine_hash_entry *rn= (Sroutine_hash_entry *)arena->alloc(sizeof(Sroutine_hash_entry) + - key->length); + key->length + 1); if (!rn) // OOM. Error will be reported using fatal_error(). return FALSE; rn->key.length= key->length; rn->key.str= (char *)rn + sizeof(Sroutine_hash_entry); - memcpy(rn->key.str, key->str, key->length); + memcpy(rn->key.str, key->str, key->length + 1); my_hash_insert(&lex->sroutines, (byte *)rn); lex->sroutines_list.link_in_list((byte *)rn, (byte **)&rn->next); rn->belong_to_view= belong_to_view; @@ -1595,7 +1595,7 @@ sp_cache_routines_and_add_tables_aux(THD *thd, LEX *lex, for (Sroutine_hash_entry *rt= start; rt; rt= rt->next) { - sp_name name(rt->key.str, rt->key.length); + sp_name name(thd, rt->key.str, rt->key.length); int type= rt->key.str[0]; sp_head *sp; @@ -1603,13 +1603,6 @@ sp_cache_routines_and_add_tables_aux(THD *thd, LEX *lex, &thd->sp_func_cache : &thd->sp_proc_cache), &name))) { - name.m_name.str= strchr(name.m_qname.str, '.'); - name.m_db.length= name.m_name.str - name.m_qname.str; - name.m_db.str= strmake_root(thd->mem_root, name.m_qname.str, - name.m_db.length); - name.m_name.str+= 1; - name.m_name.length= name.m_qname.length - name.m_db.length - 1; - switch ((ret= db_find_routine(thd, type, &name, &sp))) { case SP_OK: diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 5ad6625efb8..69dda9ec1e8 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -369,17 +369,42 @@ sp_eval_expr(THD *thd, Field *result_field, Item **expr_item_ptr) * */ +sp_name::sp_name(THD *thd, char *key, uint key_len) +{ + m_sroutines_key.str= key; + m_sroutines_key.length= key_len; + m_qname.str= ++key; + m_qname.length= key_len - 1; + if ((m_name.str= strchr(m_qname.str, '.'))) + { + m_db.length= m_name.str - key; + m_db.str= strmake_root(thd->mem_root, key, m_db.length); + m_name.str++; + m_name.length= m_qname.length - m_db.length - 1; + } + else + { + m_name.str= m_qname.str; + m_name.length= m_qname.length; + m_db.str= 0; + m_db.length= 0; + } + m_explicit_name= false; +} + void sp_name::init_qname(THD *thd) { - m_sroutines_key.length= m_db.length + m_name.length + 2; + const uint dot= !!m_db.length; + /* m_sroutines format: m_type + [database + dot] + name + nul */ + m_sroutines_key.length= 1 + m_db.length + dot + m_name.length; if (!(m_sroutines_key.str= thd->alloc(m_sroutines_key.length + 1))) return; m_qname.length= m_sroutines_key.length - 1; m_qname.str= m_sroutines_key.str + 1; - sprintf(m_qname.str, "%.*s.%.*s", + sprintf(m_qname.str, "%.*s%.*s%.*s", m_db.length, (m_db.length ? m_db.str : ""), - m_name.length, m_name.str); + dot, ".", m_name.length, m_name.str); } diff --git a/sql/sp_head.h b/sql/sp_head.h index ebe40ce9c87..7d042367985 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -72,16 +72,7 @@ public: Creates temporary sp_name object from key, used mainly for SP-cache lookups. */ - sp_name(char *key, uint key_len) - { - m_sroutines_key.str= key; - m_sroutines_key.length= key_len; - m_name.str= m_qname.str= key + 1; - m_name.length= m_qname.length= key_len - 1; - m_db.str= 0; - m_db.length= 0; - m_explicit_name= false; - } + sp_name(THD *thd, char *key, uint key_len); // Init. the qualified name from the db and name. void init_qname(THD *thd); // thd for memroot allocation diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index e0b9ab28594..7e3c11b5122 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1569,13 +1569,15 @@ sp_name: | ident { LEX *lex= Lex; - LEX_STRING db; + LEX_STRING db= {0,0}; + THD *thd= YYTHD; + if (check_routine_name($1)) { my_error(ER_SP_WRONG_NAME, MYF(0), $1.str); MYSQL_YYABORT; } - if (lex->copy_db_to(&db.str, &db.length)) + if (thd->db && thd->copy_db_to(&db.str, &db.length)) MYSQL_YYABORT; $$= new sp_name(db, $1, false); if ($$) @@ -1625,6 +1627,13 @@ create_function_tail: my_error(ER_SP_NO_RECURSIVE_CREATE, MYF(0), "FUNCTION"); MYSQL_YYABORT; } + + if (!lex->spname->m_db.length) + { + my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0)); + MYSQL_YYABORT; + } + /* Order is important here: new - reset - init */ sp= new sp_head(); sp->reset_thd_mem_root(thd); @@ -5194,8 +5203,8 @@ simple_expr: #endif /* HAVE_DLOPEN */ { THD *thd= lex->thd; - LEX_STRING db; - if (lex->copy_db_to(&db.str, &db.length)) + LEX_STRING db= {0,0}; + if (thd->db && thd->copy_db_to(&db.str, &db.length)) MYSQL_YYABORT; sp_name *name= new sp_name(db, $1, false); if (name) @@ -9730,7 +9739,13 @@ trigger_tail: my_error(ER_SP_NO_RECURSIVE_CREATE, MYF(0), "TRIGGER"); MYSQL_YYABORT; } - + + if (!$3->m_db.length) + { + my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0)); + MYSQL_YYABORT; + } + if (!(sp= new sp_head())) MYSQL_YYABORT; sp->reset_thd_mem_root(thd); @@ -9813,6 +9828,12 @@ sp_tail: MYSQL_YYABORT; } + if (!$3->m_db.length) + { + my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0)); + MYSQL_YYABORT; + } + lex->stmt_definition_begin= $2; /* Order is important here: new - reset - init */ From 190bb6bf4c812ca053524565ef2f2cceeedef05d Mon Sep 17 00:00:00 2001 From: "malff@lambda.hsd1.co.comcast.net." <> Date: Tue, 9 Oct 2007 18:12:13 -0600 Subject: [PATCH 130/203] Fixed packet length for embedded tests --- libmysqld/lib_sql.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 9c26febe627..4e525f8447f 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -111,7 +111,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command, } thd->net.no_send_error= 0; - result= dispatch_command(command, thd, (char *) arg, arg_length + 1); + result= dispatch_command(command, thd, (char *) arg, arg_length); thd->cur_data= 0; if (!skip_check) From d207867cf53b9db500e6f93b93b386c1b58cae34 Mon Sep 17 00:00:00 2001 From: "tsmith@ramayana.hindu.god" <> Date: Tue, 9 Oct 2007 18:45:29 -0600 Subject: [PATCH 131/203] Fix compiler warning (use correct data type) --- client/mysqltest.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 335a1590e1b..39fe05e4928 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1562,7 +1562,8 @@ void check_result(DYNAMIC_STRING* ds) Result mismatched, dump results to .reject file and then show the diff */ - char reject_file[FN_REFLEN], reject_length; + char reject_file[FN_REFLEN]; + size_t reject_length; dirname_part(reject_file, result_file_name, &reject_length); if (access(reject_file, W_OK) == 0) From 91a7fbc8bbf0732937d0e9486424de6704df587a Mon Sep 17 00:00:00 2001 From: "gluh@mysql.com/eagle.(none)" <> Date: Wed, 10 Oct 2007 12:16:13 +0500 Subject: [PATCH 132/203] Bug#25359 Test 'view' is dependent on current year to be 2006 removed now() call to make the test to be year independent --- mysql-test/r/view.result | 15 ++++++++------- mysql-test/t/view.test | 13 +++++++------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 0ba911f2853..0e3d650c571 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -2706,18 +2706,19 @@ CREATE TABLE t1( fName varchar(25) NOT NULL, lName varchar(25) NOT NULL, DOB date NOT NULL, +test_date date NOT NULL, uID int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY); -INSERT INTO t1(fName, lName, DOB) VALUES -('Hank', 'Hill', '1964-09-29'), -('Tom', 'Adams', '1908-02-14'), -('Homer', 'Simpson', '1968-03-05'); +INSERT INTO t1(fName, lName, DOB, test_date) VALUES +('Hank', 'Hill', '1964-09-29', '2007-01-01'), +('Tom', 'Adams', '1908-02-14', '2007-01-01'), +('Homer', 'Simpson', '1968-03-05', '2007-01-01'); CREATE VIEW v1 AS -SELECT (year(now())-year(DOB)) AS Age +SELECT (year(test_date)-year(DOB)) AS Age FROM t1 HAVING Age < 75; SHOW CREATE VIEW v1; View Create View -v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (year(now()) - year(`t1`.`DOB`)) AS `Age` from `t1` having (`Age` < 75) -SELECT (year(now())-year(DOB)) AS Age FROM t1 HAVING Age < 75; +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (year(`t1`.`test_date`) - year(`t1`.`DOB`)) AS `Age` from `t1` having (`Age` < 75) +SELECT (year(test_date)-year(DOB)) AS Age FROM t1 HAVING Age < 75; Age 43 39 diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index e6c3a03c645..0faa8e7a785 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -2548,19 +2548,20 @@ CREATE TABLE t1( fName varchar(25) NOT NULL, lName varchar(25) NOT NULL, DOB date NOT NULL, + test_date date NOT NULL, uID int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY); -INSERT INTO t1(fName, lName, DOB) VALUES - ('Hank', 'Hill', '1964-09-29'), - ('Tom', 'Adams', '1908-02-14'), - ('Homer', 'Simpson', '1968-03-05'); +INSERT INTO t1(fName, lName, DOB, test_date) VALUES + ('Hank', 'Hill', '1964-09-29', '2007-01-01'), + ('Tom', 'Adams', '1908-02-14', '2007-01-01'), + ('Homer', 'Simpson', '1968-03-05', '2007-01-01'); CREATE VIEW v1 AS - SELECT (year(now())-year(DOB)) AS Age + SELECT (year(test_date)-year(DOB)) AS Age FROM t1 HAVING Age < 75; SHOW CREATE VIEW v1; -SELECT (year(now())-year(DOB)) AS Age FROM t1 HAVING Age < 75; +SELECT (year(test_date)-year(DOB)) AS Age FROM t1 HAVING Age < 75; SELECT * FROM v1; DROP VIEW v1; From a5e7b726c1840190d5e90854d2a4838fad68729f Mon Sep 17 00:00:00 2001 From: "gluh@mysql.com/eagle.(none)" <> Date: Wed, 10 Oct 2007 12:21:11 +0500 Subject: [PATCH 133/203] Bug#28893 --relay-log variable is not exposed with SHOW VARIABLES added variables relay_log, relay_log_index, relay_log_info_file to init_vars[] to make them visible within SHOW VARIABLES --- mysql-test/r/rpl_flush_log_loop.result | 7 +++++++ mysql-test/t/rpl_flush_log_loop.test | 3 +++ sql/set_var.cc | 3 +++ 3 files changed, 13 insertions(+) diff --git a/mysql-test/r/rpl_flush_log_loop.result b/mysql-test/r/rpl_flush_log_loop.result index f9bd42ec26c..3b1db804da9 100644 --- a/mysql-test/r/rpl_flush_log_loop.result +++ b/mysql-test/r/rpl_flush_log_loop.result @@ -4,6 +4,13 @@ reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; +show variables like 'relay_log%'; +Variable_name Value +relay_log MYSQLTEST_VARDIR/master-data/relay-log +relay_log_index +relay_log_info_file relay-log.info +relay_log_purge ON +relay_log_space_limit 0 stop slave; change master to master_host='127.0.0.1',master_user='root', master_password='',master_port=MASTER_PORT; diff --git a/mysql-test/t/rpl_flush_log_loop.test b/mysql-test/t/rpl_flush_log_loop.test index 6e45047bd30..f0b368c285b 100644 --- a/mysql-test/t/rpl_flush_log_loop.test +++ b/mysql-test/t/rpl_flush_log_loop.test @@ -3,6 +3,9 @@ source include/master-slave.inc; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +show variables like 'relay_log%'; + connection slave; stop slave; --replace_result $MASTER_MYPORT MASTER_PORT diff --git a/sql/set_var.cc b/sql/set_var.cc index e1246617d84..fbfe174434d 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1040,6 +1040,9 @@ struct show_var_st init_vars[]= { {sys_readonly.name, (char*) &sys_readonly, SHOW_SYS}, {sys_read_rnd_buff_size.name,(char*) &sys_read_rnd_buff_size, SHOW_SYS}, #ifdef HAVE_REPLICATION + {"relay_log" , (char*) &opt_relay_logname, SHOW_CHAR_PTR}, + {"relay_log_index", (char*) &opt_relaylog_index_name, SHOW_CHAR_PTR}, + {"relay_log_info_file", (char*) &relay_log_info_file, SHOW_CHAR_PTR}, {sys_relay_log_purge.name, (char*) &sys_relay_log_purge, SHOW_SYS}, {"relay_log_space_limit", (char*) &relay_log_space_limit, SHOW_LONGLONG}, #endif From f71e5825e51a660e9d527727b83d229d8e17426b Mon Sep 17 00:00:00 2001 From: "gluh@mysql.com/eagle.(none)" <> Date: Wed, 10 Oct 2007 14:22:21 +0500 Subject: [PATCH 134/203] after merge fix --- mysql-test/r/view.result | 12 ++++++------ sql/sql_repl.cc | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 7ec3e136c14..60c3ff68e67 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -2711,16 +2711,16 @@ CREATE VIEW v1 AS SELECT (year(test_date)-year(DOB)) AS Age FROM t1 HAVING Age < 75; SHOW CREATE VIEW v1; -v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (year(`t1`.`test_date`) - year(`t1`.`DOB`)) AS `Age` from `t1` having (`Age` < 75) +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (year(`t1`.`test_date`) - year(`t1`.`DOB`)) AS `Age` from `t1` having (`Age` < 75) latin1 latin1_swedish_ci SELECT (year(test_date)-year(DOB)) AS Age FROM t1 HAVING Age < 75; Age -42 -38 -set timestamp=1136066400; +43 +39 SELECT * FROM v1; Age -42 -38 +43 +39 DROP VIEW v1; DROP TABLE t1; CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a char(6) DEFAULT 'xxx'); diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index a6e52c05219..0249af147b0 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1651,6 +1651,9 @@ static int show_slave_skip_errors(THD *thd, SHOW_VAR *var, char *buff); static SHOW_VAR fixed_vars[]= { {"log_slave_updates", (char*) &opt_log_slave_updates, SHOW_MY_BOOL}, + {"relay_log" , (char*) &opt_relay_logname, SHOW_CHAR_PTR}, + {"relay_log_index", (char*) &opt_relaylog_index_name, SHOW_CHAR_PTR}, + {"relay_log_info_file", (char*) &relay_log_info_file, SHOW_CHAR_PTR}, {"relay_log_space_limit", (char*) &relay_log_space_limit, SHOW_LONGLONG}, {"slave_load_tmpdir", (char*) &slave_load_tmpdir, SHOW_CHAR_PTR}, {"slave_skip_errors", (char*) &show_slave_skip_errors, SHOW_FUNC}, From c6c419f91974676fd453d8a412a14e41f886671e Mon Sep 17 00:00:00 2001 From: "anozdrin/alik@station." <> Date: Wed, 10 Oct 2007 13:53:24 +0400 Subject: [PATCH 135/203] Fix automerge. --- mysql-test/r/sp.result | 176 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 176 insertions(+) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 21af61d39f6..4641866bb43 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -6620,6 +6620,182 @@ DROP TABLE t1; DROP PROCEDURE p1; DROP PROCEDURE p2; + +# +# Bug#31035. +# + +# +# - Prepare. +# + +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; +DROP FUNCTION IF EXISTS f3; +DROP FUNCTION IF EXISTS f4; + +# +# - Create required objects. +# + +CREATE TABLE t1(c1 INT); + +INSERT INTO t1 VALUES (1), (2), (3); + +CREATE FUNCTION f1() +RETURNS INT +NOT DETERMINISTIC +RETURN 1; + +CREATE FUNCTION f2(p INT) +RETURNS INT +NOT DETERMINISTIC +RETURN 1; + +CREATE FUNCTION f3() +RETURNS INT +DETERMINISTIC +RETURN 1; + +CREATE FUNCTION f4(p INT) +RETURNS INT +DETERMINISTIC +RETURN 1; + +# +# - Check. +# + +SELECT f1() AS a FROM t1 GROUP BY a; +a +1 + +SELECT f2(@a) AS a FROM t1 GROUP BY a; +a +1 + +SELECT f3() AS a FROM t1 GROUP BY a; +a +1 + +SELECT f4(0) AS a FROM t1 GROUP BY a; +a +1 + +SELECT f4(@a) AS a FROM t1 GROUP BY a; +a +1 + +# +# - Cleanup. +# + +DROP TABLE t1; +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +DROP FUNCTION f4; + +# +# Bug#31191. +# + +# +# - Prepare. +# + +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +DROP FUNCTION IF EXISTS f1; + +# +# - Create required objects. +# + +CREATE TABLE t1 ( +id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +barcode INT(8) UNSIGNED ZEROFILL nOT NULL, +PRIMARY KEY (id), +UNIQUE KEY barcode (barcode) +); + +INSERT INTO t1 (id, barcode) VALUES (1, 12345678); +INSERT INTO t1 (id, barcode) VALUES (2, 12345679); + +CREATE TABLE test.t2 ( +id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +barcode BIGINT(11) UNSIGNED ZEROFILL NOT NULL, +PRIMARY KEY (id) +); + +INSERT INTO test.t2 (id, barcode) VALUES (1, 12345106708); +INSERT INTO test.t2 (id, barcode) VALUES (2, 12345106709); + +CREATE FUNCTION f1(p INT(8)) +RETURNS BIGINT(11) UNSIGNED +READS SQL DATA +RETURN FLOOR(p/1000)*1000000 + 100000 + FLOOR((p MOD 1000)/10)*100 + (p MOD 10); + +# +# - Check. +# + +SELECT DISTINCT t1.barcode, f1(t1.barcode) +FROM t1 +INNER JOIN t2 +ON f1(t1.barcode) = t2.barcode +WHERE t1.barcode=12345678; +barcode f1(t1.barcode) +12345678 12345106708 + +# +# - Cleanup. +# + +DROP TABLE t1; +DROP TABLE t2; +DROP FUNCTION f1; + +# +# Bug#31226. +# + +# +# - Prepare. +# + +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS f1; + +# +# - Create required objects. +# + +CREATE TABLE t1(id INT); + +INSERT INTO t1 VALUES (1), (2), (3); + +CREATE FUNCTION f1() +RETURNS DATETIME +NOT DETERMINISTIC NO SQL +RETURN NOW(); + +# +# - Check. +# + +SELECT f1() FROM t1 GROUP BY 1; +f1() + + +# +# - Cleanup. +# + +DROP TABLE t1; +DROP FUNCTION f1; + End of 5.0 tests # From 05cf10bdf6b803e943a3348af05fa2a5a76362c4 Mon Sep 17 00:00:00 2001 From: "anozdrin/alik@station." <> Date: Wed, 10 Oct 2007 14:42:29 +0400 Subject: [PATCH 136/203] Cleanup sp.test. --- mysql-test/r/sp.result | 6 +++--- mysql-test/t/sp.test | 10 +++------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index b1120a22dfd..ef173b9661f 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -5667,7 +5667,6 @@ t3_id_1 t3_id_2 t4_id DROP PROCEDURE p1| DROP VIEW v1, v2| DROP TABLE t3, t4| -End of 5.0 tests DROP TABLE IF EXISTS bug23760| DROP TABLE IF EXISTS bug23760_log| DROP PROCEDURE IF EXISTS bug23760_update_log| @@ -6145,7 +6144,6 @@ Procedure sql_mode Create Procedure proc_21513 CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_21513`() `my_label`:BEGIN END drop procedure proc_21513| -End of 5.0 tests. drop table t1,t2; CREATE TABLE t1 (a int auto_increment primary key) engine=MyISAM; CREATE TABLE t2 (a int auto_increment primary key, b int) engine=innodb; @@ -6565,4 +6563,6 @@ f1() DROP TABLE t1; DROP FUNCTION f1; -End of 5.0 tests +# ------------------------------------------------------------------ +# -- End of 5.0 tests +# ------------------------------------------------------------------ diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 465585a693e..501d96c842a 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -6642,9 +6642,6 @@ DROP VIEW v1, v2| DROP TABLE t3, t4| ---echo End of 5.0 tests - - # # BUG#23760: ROW_COUNT() and store procedure not owrking together # @@ -7076,9 +7073,6 @@ show create procedure proc_21513| drop procedure proc_21513| -### ---echo End of 5.0 tests. - # # BUG#NNNN: New bug synopsis # @@ -7677,4 +7671,6 @@ DROP FUNCTION f1; ########################################################################### ---echo End of 5.0 tests +--echo # ------------------------------------------------------------------ +--echo # -- End of 5.0 tests +--echo # ------------------------------------------------------------------ From e971b18f0690c723dac547bcdcaaa8ba9ff2850b Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Wed, 10 Oct 2007 16:26:02 +0300 Subject: [PATCH 137/203] Bug #30825: Problems when putting a non-spatial index on a GIS column Fixed the usage of spatial data (and Point in specific) with non-spatial indexes. Several problems : - The length of the Point class was not updated to include the spatial reference system identifier. Fixed by increasing with 4 bytes. - The storage length of the spatial columns was not accounting for the length that is prepended to it. Fixed by treating the spatial data columns as blobs (and thus increasing the storage length) - When creating the key image for comparison in index read wrong key image was created (the one needed for and r-tree search, not the one for b-tree/other search). Fixed by treating the spatial data columns as blobs (and creating the correct kind of image based on the index type). --- mysql-test/include/gis_keys.inc | 46 +++++++++++++++++++++++++++++++++ mysql-test/r/bdb_gis.result | 39 ++++++++++++++++++++++++++++ mysql-test/r/gis-rtree.result | 4 +-- mysql-test/r/gis.result | 39 ++++++++++++++++++++++++++++ mysql-test/r/innodb_gis.result | 39 ++++++++++++++++++++++++++++ mysql-test/t/bdb_gis.test | 1 + mysql-test/t/gis.test | 2 ++ mysql-test/t/innodb_gis.test | 1 + sql/field.cc | 30 --------------------- sql/field.h | 1 - sql/sql_select.h | 8 ++++-- sql/sql_table.cc | 2 +- sql/sql_yacc.yy | 2 +- sql/table.cc | 6 +++-- 14 files changed, 181 insertions(+), 39 deletions(-) create mode 100644 mysql-test/include/gis_keys.inc diff --git a/mysql-test/include/gis_keys.inc b/mysql-test/include/gis_keys.inc new file mode 100644 index 00000000000..295e0c48234 --- /dev/null +++ b/mysql-test/include/gis_keys.inc @@ -0,0 +1,46 @@ +--source include/have_geometry.inc + +# +# Spatial objects with keys +# + +# +# Bug #30825: Problems when putting a non-spatial index on a GIS column +# + +CREATE TABLE t1 (p POINT); +CREATE TABLE t2 (p POINT, INDEX(p)); +INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)')); +INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)')); + +-- no index, returns 1 as expected +SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)'); + +-- with index, returns 1 as expected +-- EXPLAIN shows that the index is not used though +-- due to the "most rows covered anyway, so a scan is more effective" rule +EXPLAIN +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); + +-- adding another row to the table so that +-- the "most rows covered" rule doesn't kick in anymore +-- now EXPLAIN shows the index used on the table +-- and we're getting the wrong result again +INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)')); +INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)')); +EXPLAIN +SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)'); +SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)'); + +EXPLAIN +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); + +EXPLAIN +SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)'); +SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)'); + +DROP TABLE t1, t2; + +--echo End of 5.0 tests diff --git a/mysql-test/r/bdb_gis.result b/mysql-test/r/bdb_gis.result index d48b5a26e1d..6651421b51c 100644 --- a/mysql-test/r/bdb_gis.result +++ b/mysql-test/r/bdb_gis.result @@ -542,3 +542,42 @@ Overlaps(@horiz1, @point2) 0 DROP TABLE t1; End of 5.0 tests +CREATE TABLE t1 (p POINT); +CREATE TABLE t2 (p POINT, INDEX(p)); +INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)')); +INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)')); +SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +1 +EXPLAIN +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref p p 28 const 1 Using where +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +1 +INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)')); +INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)')); +EXPLAIN +SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where +SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +2 +EXPLAIN +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL p NULL NULL NULL 2 Using where +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +2 +EXPLAIN +SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where +SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +2 +DROP TABLE t1, t2; +End of 5.0 tests diff --git a/mysql-test/r/gis-rtree.result b/mysql-test/r/gis-rtree.result index 621402e87a9..99bfede3ee0 100644 --- a/mysql-test/r/gis-rtree.result +++ b/mysql-test/r/gis-rtree.result @@ -167,7 +167,7 @@ count(*) 150 EXPLAIN SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))')); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range g g 32 NULL 8 Using where +1 SIMPLE t1 range g g 34 NULL 8 Using where SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))')); fid AsText(g) 1 LINESTRING(150 150,150 150) @@ -301,7 +301,7 @@ count(*) EXPLAIN SELECT fid, AsText(g) FROM t2 WHERE Within(g, GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))')); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range g g 32 NULL 4 Using where +1 SIMPLE t2 range g g 34 NULL 4 Using where SELECT fid, AsText(g) FROM t2 WHERE Within(g, GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))')); fid AsText(g) diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index 55f42141adb..40c70721347 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -894,4 +894,43 @@ drop table t1, t2; SELECT 1; 1 1 +CREATE TABLE t1 (p POINT); +CREATE TABLE t2 (p POINT, INDEX(p)); +INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)')); +INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)')); +SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +1 +EXPLAIN +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 system p NULL NULL NULL 1 +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +1 +INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)')); +INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)')); +EXPLAIN +SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where +SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +2 +EXPLAIN +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref p p 28 const 1 Using where +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +2 +EXPLAIN +SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where +SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +2 +DROP TABLE t1, t2; +End of 5.0 tests End of 5.0 tests diff --git a/mysql-test/r/innodb_gis.result b/mysql-test/r/innodb_gis.result index 2c62537aa94..bfe8c984b7b 100644 --- a/mysql-test/r/innodb_gis.result +++ b/mysql-test/r/innodb_gis.result @@ -542,3 +542,42 @@ Overlaps(@horiz1, @point2) 0 DROP TABLE t1; End of 5.0 tests +CREATE TABLE t1 (p POINT); +CREATE TABLE t2 (p POINT, INDEX(p)); +INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)')); +INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)')); +SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +1 +EXPLAIN +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref p p 28 const 1 Using where +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +1 +INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)')); +INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)')); +EXPLAIN +SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where +SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +2 +EXPLAIN +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref p p 28 const 1 Using where +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +2 +EXPLAIN +SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where +SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +2 +DROP TABLE t1, t2; +End of 5.0 tests diff --git a/mysql-test/t/bdb_gis.test b/mysql-test/t/bdb_gis.test index 88dcbb7cbe9..cb6d0683874 100644 --- a/mysql-test/t/bdb_gis.test +++ b/mysql-test/t/bdb_gis.test @@ -1,3 +1,4 @@ -- source include/have_bdb.inc SET storage_engine=bdb; --source include/gis_generic.inc +--source include/gis_keys.inc diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index 730f046dd27..b7da7db1d76 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -598,4 +598,6 @@ SELECT AsText(GeometryFromText(CONCAT( --enable_query_log SELECT 1; +-- source include/gis_keys.inc + --echo End of 5.0 tests diff --git a/mysql-test/t/innodb_gis.test b/mysql-test/t/innodb_gis.test index 142b526af92..024d17c5363 100644 --- a/mysql-test/t/innodb_gis.test +++ b/mysql-test/t/innodb_gis.test @@ -1,3 +1,4 @@ --source include/have_innodb.inc SET storage_engine=innodb; --source include/gis_generic.inc +--source include/gis_keys.inc diff --git a/sql/field.cc b/sql/field.cc index e6e4195ba1e..ded31972a7f 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -7416,36 +7416,6 @@ uint Field_blob::max_packed_col_length(uint max_length) #ifdef HAVE_SPATIAL -uint Field_geom::get_key_image(char *buff, uint length, imagetype type) -{ - char *blob; - const char *dummy; - MBR mbr; - ulong blob_length= get_length(ptr); - Geometry_buffer buffer; - Geometry *gobj; - const uint image_length= SIZEOF_STORED_DOUBLE*4; - - if (blob_length < SRID_SIZE) - { - bzero(buff, image_length); - return image_length; - } - get_ptr(&blob); - gobj= Geometry::construct(&buffer, blob, blob_length); - if (!gobj || gobj->get_mbr(&mbr, &dummy)) - bzero(buff, image_length); - else - { - float8store(buff, mbr.xmin); - float8store(buff + 8, mbr.xmax); - float8store(buff + 16, mbr.ymin); - float8store(buff + 24, mbr.ymax); - } - return image_length; -} - - void Field_geom::sql_type(String &res) const { CHARSET_INFO *cs= &my_charset_latin1; diff --git a/sql/field.h b/sql/field.h index 4fcdb50f8c7..8c01931fa21 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1326,7 +1326,6 @@ public: int store(double nr); int store(longlong nr, bool unsigned_val); int store_decimal(const my_decimal *); - uint get_key_image(char *buff,uint length,imagetype type); uint size_of() const { return sizeof(*this); } int reset(void) { return !maybe_null() || Field_blob::reset(); } geometry_type get_geometry_type() { return geom_type; }; diff --git a/sql/sql_select.h b/sql/sql_select.h index d84fbcb8c2d..4fc32e7fdb3 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -521,9 +521,13 @@ public: store_key(THD *thd, Field *field_arg, char *ptr, char *null, uint length) :null_key(0), null_ptr(null), err(0) { - if (field_arg->type() == FIELD_TYPE_BLOB) + if (field_arg->type() == FIELD_TYPE_BLOB + || field_arg->type() == FIELD_TYPE_GEOMETRY) { - /* Key segments are always packed with a 2 byte length prefix */ + /* + Key segments are always packed with a 2 byte length prefix. + See mi_rkey for details. + */ to_field=new Field_varstring(ptr, length, 2, (uchar*) null, 1, Field::NONE, field_arg->field_name, field_arg->table, field_arg->charset()); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 6cbe98fe862..20b8c7a4278 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1287,7 +1287,7 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, } if (f_is_geom(sql_field->pack_flag) && sql_field->geom_type == Field::GEOM_POINT) - column->length= 21; + column->length= 25; if (!column->length) { my_error(ER_BLOB_KEY_WITHOUT_LENGTH, MYF(0), column->field_name); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 553cc6d24d5..3b2709b15b1 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3216,7 +3216,7 @@ type: spatial_type: GEOMETRY_SYM { $$= Field::GEOM_GEOMETRY; } | GEOMETRYCOLLECTION { $$= Field::GEOM_GEOMETRYCOLLECTION; } - | POINT_SYM { Lex->length= (char*)"21"; + | POINT_SYM { Lex->length= (char*)"25"; $$= Field::GEOM_POINT; } | MULTIPOINT { $$= Field::GEOM_MULTIPOINT; } diff --git a/sql/table.cc b/sql/table.cc index a393f1a676b..7fe9aa774f3 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -732,9 +732,11 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, keyinfo->key_length+= HA_KEY_NULL_LENGTH; } if (field->type() == FIELD_TYPE_BLOB || - field->real_type() == MYSQL_TYPE_VARCHAR) + field->real_type() == MYSQL_TYPE_VARCHAR || + field->type() == FIELD_TYPE_GEOMETRY) { - if (field->type() == FIELD_TYPE_BLOB) + if (field->type() == FIELD_TYPE_BLOB || + field->type() == FIELD_TYPE_GEOMETRY) key_part->key_part_flag|= HA_BLOB_PART; else key_part->key_part_flag|= HA_VAR_LENGTH_PART; From ac83b3122c32e84c2ec526760273d3a9b1176b49 Mon Sep 17 00:00:00 2001 From: "anozdrin/alik@station." <> Date: Wed, 10 Oct 2007 17:57:01 +0400 Subject: [PATCH 138/203] Fix for BUG#20023: mysql_change_user() resets the value of SQL_BIG_SELECTS. The bug was that SQL_BIG_SELECTS was not properly set in COM_CHANGE_USER. The fix is to update SQL_BIG_SELECTS properly. --- sql/mysql_priv.h | 1 - sql/sql_class.cc | 6 ++ sql/sql_connect.cc | 4 +- tests/mysql_client_test.c | 171 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 179 insertions(+), 3 deletions(-) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 6a7e3e00f6f..79d4c16f9c1 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -917,7 +917,6 @@ void decrease_user_connections(USER_CONN *uc); void thd_init_client_charset(THD *thd, uint cs_number); bool setup_connection_thread_globals(THD *thd); bool login_connection(THD *thd); -void prepare_new_connection_state(THD* thd); void end_connection(THD *thd); bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create, bool silent); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 66a51d5bb00..490aedad0ef 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -585,6 +585,12 @@ void THD::init(void) if (variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES) server_status|= SERVER_STATUS_NO_BACKSLASH_ESCAPES; options= thd_startup_options; + + if (variables.max_join_size == HA_POS_ERROR) + options |= OPTION_BIG_SELECTS; + else + options &= ~OPTION_BIG_SELECTS; + transaction.all.modified_non_trans_table= transaction.stmt.modified_non_trans_table= FALSE; open_options=ha_open_options; update_lock_default= (variables.low_priority_updates ? diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 9785b30ea00..094bef9324e 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -933,7 +933,7 @@ bool login_connection(THD *thd) NET *net= &thd->net; Security_context *sctx= thd->security_ctx; DBUG_ENTER("login_connection"); - DBUG_PRINT("info", ("handle_one_connection called by thread %lu", + DBUG_PRINT("info", ("login_connection called by thread %lu", thd->thread_id)); net->no_send_error= 0; @@ -1003,7 +1003,7 @@ void end_connection(THD *thd) Initialize THD to handle queries */ -void prepare_new_connection_state(THD* thd) +static void prepare_new_connection_state(THD* thd) { Security_context *sctx= thd->security_ctx; diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index eff8df8109a..9505340c24f 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -16819,6 +16819,176 @@ static void test_bug30472() mysql_close(&con); } +static void bug20023_change_user(MYSQL *con) +{ + DIE_IF(mysql_change_user(con, + opt_user, + opt_password, + opt_db ? opt_db : "test")); +} + +static void bug20023_query_int_variable(MYSQL *con, + const char *var_name, + int *var_value) +{ + MYSQL_RES *rs; + MYSQL_ROW row; + + char query_buffer[MAX_TEST_QUERY_LENGTH]; + + my_snprintf(query_buffer, + sizeof (query_buffer), + "SELECT @@%s", + (const char *) var_name); + + DIE_IF(mysql_query(con, query_buffer)); + DIE_UNLESS(rs= mysql_store_result(con)); + DIE_UNLESS(row= mysql_fetch_row(rs)); + *var_value= atoi(row[0]); + mysql_free_result(rs); +} + +static void test_bug20023() +{ + MYSQL con; + + int sql_big_selects_orig; + int max_join_size_orig; + + int sql_big_selects_2; + int sql_big_selects_3; + int sql_big_selects_4; + int sql_big_selects_5; + + char query_buffer[MAX_TEST_QUERY_LENGTH]; + + /* Create a new connection. */ + + DIE_UNLESS(mysql_init(&con)); + + DIE_UNLESS(mysql_real_connect(&con, + opt_host, + opt_user, + opt_password, + opt_db ? opt_db : "test", + opt_port, + opt_unix_socket, + CLIENT_FOUND_ROWS)); + + /*********************************************************************** + Remember original SQL_BIG_SELECTS, MAX_JOIN_SIZE values. + ***********************************************************************/ + + bug20023_query_int_variable(&con, + "session.sql_big_selects", + &sql_big_selects_orig); + + bug20023_query_int_variable(&con, + "global.max_join_size", + &max_join_size_orig); + + /*********************************************************************** + Test that COM_CHANGE_USER resets the SQL_BIG_SELECTS to the initial value. + ***********************************************************************/ + + /* Issue COM_CHANGE_USER. */ + + bug20023_change_user(&con); + + /* Query SQL_BIG_SELECTS. */ + + bug20023_query_int_variable(&con, + "session.sql_big_selects", + &sql_big_selects_2); + + /* Check that SQL_BIG_SELECTS is reset properly. */ + + DIE_UNLESS(sql_big_selects_orig == sql_big_selects_2); + + /*********************************************************************** + Test that if MAX_JOIN_SIZE set to non-default value, + SQL_BIG_SELECTS will be 0. + ***********************************************************************/ + + /* Set MAX_JOIN_SIZE to some non-default value. */ + + DIE_IF(mysql_query(&con, "SET @@global.max_join_size = 10000")); + DIE_IF(mysql_query(&con, "SET @@session.max_join_size = default")); + + /* Issue COM_CHANGE_USER. */ + + bug20023_change_user(&con); + + /* Query SQL_BIG_SELECTS. */ + + bug20023_query_int_variable(&con, + "session.sql_big_selects", + &sql_big_selects_3); + + /* Check that SQL_BIG_SELECTS is 0. */ + + DIE_UNLESS(sql_big_selects_3 == 0); + + /*********************************************************************** + Test that if MAX_JOIN_SIZE set to default value, + SQL_BIG_SELECTS will be 1. + ***********************************************************************/ + + /* Set MAX_JOIN_SIZE to the default value (-1). */ + + DIE_IF(mysql_query(&con, "SET @@global.max_join_size = -1")); + DIE_IF(mysql_query(&con, "SET @@session.max_join_size = default")); + + /* Issue COM_CHANGE_USER. */ + + bug20023_change_user(&con); + + /* Query SQL_BIG_SELECTS. */ + + bug20023_query_int_variable(&con, + "session.sql_big_selects", + &sql_big_selects_4); + + /* Check that SQL_BIG_SELECTS is 1. */ + + DIE_UNLESS(sql_big_selects_4 == 1); + + /*********************************************************************** + Restore MAX_JOIN_SIZE. + Check that SQL_BIG_SELECTS will be the original one. + ***********************************************************************/ + + /* Restore MAX_JOIN_SIZE. */ + + my_snprintf(query_buffer, + sizeof (query_buffer), + "SET @@global.max_join_size = %d", + (int) max_join_size_orig); + + DIE_IF(mysql_query(&con, query_buffer)); + DIE_IF(mysql_query(&con, "SET @@session.max_join_size = default")); + + /* Issue COM_CHANGE_USER. */ + + bug20023_change_user(&con); + + /* Query SQL_BIG_SELECTS. */ + + bug20023_query_int_variable(&con, + "session.sql_big_selects", + &sql_big_selects_5); + + /* Check that SQL_BIG_SELECTS is 1. */ + + DIE_UNLESS(sql_big_selects_5 == sql_big_selects_orig); + + /*********************************************************************** + That's it. Cleanup. + ***********************************************************************/ + + mysql_close(&con); +} + /* Read and parse arguments and MySQL options from my.cnf @@ -17115,6 +17285,7 @@ static struct my_tests_st my_tests[]= { { "test_bug29306", test_bug29306 }, { "test_change_user", test_change_user }, { "test_bug30472", test_bug30472 }, + { "test_bug20023", test_bug20023 }, { 0, 0 } }; From 356007a8a4573d5f57794e8e627a9632dc703ce0 Mon Sep 17 00:00:00 2001 From: "gshchepa/uchum@gleb.loc" <> Date: Wed, 10 Oct 2007 20:14:29 +0500 Subject: [PATCH 139/203] Fixed bug #31471: decimal_bin_size: Assertion `scale >= 0 && precision > 0 && scale <= precision'. A sign of a resulting item of the IFNULL function was not updated and the maximal length of this result was calculated improperly. Correct algorithm was copy&pasted from the IF function implementation. --- mysql-test/r/create.result | 2 +- mysql-test/r/null.result | 25 ++++++++++++++++++++++++- mysql-test/t/null.test | 27 +++++++++++++++++++++++++-- sql/item_cmpfunc.cc | 18 ++++++++++++++---- 4 files changed, 64 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index ab5d23d6cea..3d7486b6ba2 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -425,7 +425,7 @@ explain t2; Field Type Null Key Default Extra a int(11) YES NULL b bigint(11) NO 0 -c bigint(11) NO 0 +c bigint(11) unsigned NO 0 d date YES NULL e varchar(1) NO f datetime YES NULL diff --git a/mysql-test/r/null.result b/mysql-test/r/null.result index c33adee76b2..090f41baec3 100644 --- a/mysql-test/r/null.result +++ b/mysql-test/r/null.result @@ -1,4 +1,4 @@ -drop table if exists t1; +drop table if exists t1, t2; select null,\N,isnull(null),isnull(1/0),isnull(1/0 = null),ifnull(null,1),ifnull(null,"TRUE"),ifnull("TRUE","ERROR"),1/0 is null,1 is not null; NULL NULL isnull(null) isnull(1/0) isnull(1/0 = null) ifnull(null,1) ifnull(null,"TRUE") ifnull("TRUE","ERROR") 1/0 is null 1 is not null NULL NULL 1 1 1 1 TRUE TRUE 1 1 @@ -320,3 +320,26 @@ bug19145c CREATE TABLE `bug19145c` ( drop table bug19145a; drop table bug19145b; drop table bug19145c; +# End of 4.1 tests +# +# Bug #31471: decimal_bin_size: Assertion `scale >= 0 && +# precision > 0 && scale <= precision' +# +CREATE TABLE t1 (a DECIMAL (1, 0) ZEROFILL, b DECIMAL (1, 0) ZEROFILL); +INSERT INTO t1 (a, b) VALUES (0, 0); +CREATE TABLE t2 SELECT IFNULL(a, b) FROM t1; +DESCRIBE t2; +Field Type Null Key Default Extra +IFNULL(a, b) decimal(1,0) unsigned YES NULL +DROP TABLE t2; +CREATE TABLE t2 SELECT IFNULL(a, NULL) FROM t1; +DESCRIBE t2; +Field Type Null Key Default Extra +IFNULL(a, NULL) decimal(1,0) YES NULL +DROP TABLE t2; +CREATE TABLE t2 SELECT IFNULL(NULL, b) FROM t1; +DESCRIBE t2; +Field Type Null Key Default Extra +IFNULL(NULL, b) decimal(1,0) YES NULL +DROP TABLE t1, t2; +# End of 5.0 tests diff --git a/mysql-test/t/null.test b/mysql-test/t/null.test index 65e09b006ec..2878b54c357 100644 --- a/mysql-test/t/null.test +++ b/mysql-test/t/null.test @@ -1,6 +1,6 @@ # Initialise --disable_warnings -drop table if exists t1; +drop table if exists t1, t2; --enable_warnings # @@ -231,4 +231,27 @@ drop table bug19145a; drop table bug19145b; drop table bug19145c; -# End of 4.1 tests +--echo # End of 4.1 tests + +--echo # +--echo # Bug #31471: decimal_bin_size: Assertion `scale >= 0 && +--echo # precision > 0 && scale <= precision' +--echo # + +CREATE TABLE t1 (a DECIMAL (1, 0) ZEROFILL, b DECIMAL (1, 0) ZEROFILL); +INSERT INTO t1 (a, b) VALUES (0, 0); + +CREATE TABLE t2 SELECT IFNULL(a, b) FROM t1; +DESCRIBE t2; +DROP TABLE t2; + +CREATE TABLE t2 SELECT IFNULL(a, NULL) FROM t1; +DESCRIBE t2; +DROP TABLE t2; + +CREATE TABLE t2 SELECT IFNULL(NULL, b) FROM t1; +DESCRIBE t2; + +DROP TABLE t1, t2; + +--echo # End of 5.0 tests diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 1599bcc1571..789b0f7edc0 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2020,10 +2020,20 @@ 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); - max_length= (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT) ? - (max(args[0]->max_length - args[0]->decimals, - args[1]->max_length - args[1]->decimals) + decimals) : - max(args[0]->max_length, args[1]->max_length); + 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); + } + else + max_length= max(args[0]->max_length, args[1]->max_length); switch (hybrid_type) { case STRING_RESULT: From ced64f85823c7a9dcd6b9f952c136278567fa9f6 Mon Sep 17 00:00:00 2001 From: "tsmith@ramayana.hindu.god" <> Date: Wed, 10 Oct 2007 14:00:57 -0600 Subject: [PATCH 140/203] Bug #31517: Potential crash due to access of NULL thd in mark_transaction_to_rollback() Introduced in mark_transaction_to_rollback(), part of fix for bug 24989; fix is to check thd for NULL before using it. --- sql/sql_class.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index b67f63778dc..4a98a044e25 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2241,8 +2241,11 @@ void THD::restore_sub_statement_state(Sub_statement_state *backup) void mark_transaction_to_rollback(THD *thd, bool all) { - thd->is_fatal_sub_stmt_error= TRUE; - thd->transaction_rollback_request= all; + if (thd) + { + thd->is_fatal_sub_stmt_error= TRUE; + thd->transaction_rollback_request= all; + } } /*************************************************************************** Handling of XA id cacheing From ae462f3e772cb75abc2d64ae83d2f39c88c19fef Mon Sep 17 00:00:00 2001 From: "davi@moksha.com.br" <> Date: Wed, 10 Oct 2007 19:06:53 -0300 Subject: [PATCH 141/203] Post-merge test case for Bug 21587 --- mysql-test/include/handler.inc | 35 ++++++++++++++++++++++++++++++ mysql-test/r/handler_innodb.result | 22 +++++++++++++++++++ mysql-test/r/handler_myisam.result | 22 +++++++++++++++++++ 3 files changed, 79 insertions(+) diff --git a/mysql-test/include/handler.inc b/mysql-test/include/handler.inc index 437dd6ced4d..c957fa81040 100644 --- a/mysql-test/include/handler.inc +++ b/mysql-test/include/handler.inc @@ -498,3 +498,38 @@ handler t1_alias read a next; handler t1_alias READ a next where inexistent > 0; handler t1_alias close; drop table t1; + +# +# Bug#21587 FLUSH TABLES causes server crash when used with HANDLER statements +# + +--disable_warnings +drop table if exists t1,t2; +--enable_warnings +create table t1 (c1 int); +create table t2 (c1 int); +insert into t1 values (1); +insert into t2 values (2); +--echo connection: default +handler t1 open; +handler t1 read first; +connect (flush,localhost,root,,); +connection flush; +--echo connection: flush +--send flush tables; +connection default; +--echo connection: default +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Flushing tables"; +--source include/wait_condition.inc +handler t2 open; +handler t2 read first; +handler t1 read next; +handler t1 close; +handler t2 close; +connection flush; +reap; +connection default; +drop table t1,t2; +disconnect flush; diff --git a/mysql-test/r/handler_innodb.result b/mysql-test/r/handler_innodb.result index 98b8922bc5f..45a6218585d 100644 --- a/mysql-test/r/handler_innodb.result +++ b/mysql-test/r/handler_innodb.result @@ -535,3 +535,25 @@ handler t1_alias READ a next where inexistent > 0; ERROR 42S22: Unknown column 'inexistent' in 'field list' handler t1_alias close; drop table t1; +drop table if exists t1,t2; +create table t1 (c1 int); +create table t2 (c1 int); +insert into t1 values (1); +insert into t2 values (2); +connection: default +handler t1 open; +handler t1 read first; +c1 +1 +connection: flush +flush tables;; +connection: default +handler t2 open; +handler t2 read first; +c1 +2 +handler t1 read next; +c1 +handler t1 close; +handler t2 close; +drop table t1,t2; diff --git a/mysql-test/r/handler_myisam.result b/mysql-test/r/handler_myisam.result index 464b775b795..bc4a8e9081a 100644 --- a/mysql-test/r/handler_myisam.result +++ b/mysql-test/r/handler_myisam.result @@ -535,3 +535,25 @@ handler t1_alias READ a next where inexistent > 0; ERROR 42S22: Unknown column 'inexistent' in 'field list' handler t1_alias close; drop table t1; +drop table if exists t1,t2; +create table t1 (c1 int); +create table t2 (c1 int); +insert into t1 values (1); +insert into t2 values (2); +connection: default +handler t1 open; +handler t1 read first; +c1 +1 +connection: flush +flush tables;; +connection: default +handler t2 open; +handler t2 read first; +c1 +2 +handler t1 read next; +c1 +handler t1 close; +handler t2 close; +drop table t1,t2; From 2f946efda79ce6de0c113a86a39094f641cf7ef0 Mon Sep 17 00:00:00 2001 From: "davi@moksha.com.br" <> Date: Wed, 10 Oct 2007 21:07:23 -0300 Subject: [PATCH 142/203] Mismerge broken 5.1-runtime compilation because do_command was defined static but it's still used by another compilation unit. Remove static qualifier from do_command definition. --- sql/sql_parse.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 3104f77d013..695e923e816 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -650,7 +650,7 @@ int end_trans(THD *thd, enum enum_mysql_completiontype completion) 1 request of thread shutdown (see dispatch_command() description) */ -static bool do_command(THD *thd) +bool do_command(THD *thd) { char *packet= 0; ulong packet_length; From 4515ccf7c074c7044c9ddf681bbc8a70821d46d5 Mon Sep 17 00:00:00 2001 From: "davi@moksha.com.br" <> Date: Wed, 10 Oct 2007 21:39:22 -0300 Subject: [PATCH 143/203] Post-merge test case for Bug 31409 --- mysql-test/include/handler.inc | 33 ++++++++++++++++++++++++++++++ mysql-test/r/handler_innodb.result | 18 ++++++++++++++++ mysql-test/r/handler_myisam.result | 18 ++++++++++++++++ 3 files changed, 69 insertions(+) diff --git a/mysql-test/include/handler.inc b/mysql-test/include/handler.inc index c957fa81040..71647112126 100644 --- a/mysql-test/include/handler.inc +++ b/mysql-test/include/handler.inc @@ -533,3 +533,36 @@ reap; connection default; drop table t1,t2; disconnect flush; + +# +# Bug#31409 RENAME TABLE causes server crash or deadlock when used with HANDLER statements +# + +--disable_warnings +drop table if exists t1,t2; +--enable_warnings +create table t1 (c1 int); +--echo connection: default +handler t1 open; +handler t1 read first; +connect (flush,localhost,root,,); +connection flush; +--echo connection: flush +--send rename table t1 to t2; +connection default; +--echo connection: default +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table" and info = "rename table t1 to t2"; +--source include/wait_condition.inc +handler t2 open; +handler t2 read first; +--error ER_NO_SUCH_TABLE +handler t1 read next; +handler t1 close; +handler t2 close; +connection flush; +reap; +connection default; +drop table t2; +disconnect flush; diff --git a/mysql-test/r/handler_innodb.result b/mysql-test/r/handler_innodb.result index 45a6218585d..e9e5c7dbdd5 100644 --- a/mysql-test/r/handler_innodb.result +++ b/mysql-test/r/handler_innodb.result @@ -554,6 +554,24 @@ c1 2 handler t1 read next; c1 +1 handler t1 close; handler t2 close; drop table t1,t2; +drop table if exists t1,t2; +create table t1 (c1 int); +connection: default +handler t1 open; +handler t1 read first; +c1 +connection: flush +rename table t1 to t2;; +connection: default +handler t2 open; +handler t2 read first; +c1 +handler t1 read next; +ERROR 42S02: Table 'test.t1' doesn't exist +handler t1 close; +handler t2 close; +drop table t2; diff --git a/mysql-test/r/handler_myisam.result b/mysql-test/r/handler_myisam.result index bc4a8e9081a..715e5ab03d6 100644 --- a/mysql-test/r/handler_myisam.result +++ b/mysql-test/r/handler_myisam.result @@ -554,6 +554,24 @@ c1 2 handler t1 read next; c1 +1 handler t1 close; handler t2 close; drop table t1,t2; +drop table if exists t1,t2; +create table t1 (c1 int); +connection: default +handler t1 open; +handler t1 read first; +c1 +connection: flush +rename table t1 to t2;; +connection: default +handler t2 open; +handler t2 read first; +c1 +handler t1 read next; +ERROR 42S02: Table 'test.t1' doesn't exist +handler t1 close; +handler t2 close; +drop table t2; From 99f1606e942985d4a803c2914eb25fe4fc61c338 Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Thu, 11 Oct 2007 11:29:26 +0300 Subject: [PATCH 144/203] Bug #31440: 'select 1 regex null' asserts debug server The special case with NULL as a regular expression was handled at prepare time. But in this special case the item was not marked as fixed. This caused an assertion at execution time. Fixed my marking the item as fixed even when known to return NULL at prepare time. --- mysql-test/r/func_regexp.result | 5 +++++ mysql-test/t/func_regexp.test | 11 ++++++++++- sql/item_cmpfunc.cc | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_regexp.result b/mysql-test/r/func_regexp.result index 584c8a9b820..2366947d2a7 100644 --- a/mysql-test/r/func_regexp.result +++ b/mysql-test/r/func_regexp.result @@ -98,3 +98,8 @@ R2 R3 deallocate prepare stmt1; drop table t1; +End of 4.1 tests +SELECT 1 REGEXP NULL; +1 REGEXP NULL +NULL +End of 5.0 tests diff --git a/mysql-test/t/func_regexp.test b/mysql-test/t/func_regexp.test index 23070c71fe9..5eff404bc0f 100644 --- a/mysql-test/t/func_regexp.test +++ b/mysql-test/t/func_regexp.test @@ -74,4 +74,13 @@ execute stmt1 using @a; deallocate prepare stmt1; drop table t1; -# End of 4.1 tests +--echo End of 4.1 tests + + +# +# Bug #31440: 'select 1 regex null' asserts debug server +# + +SELECT 1 REGEXP NULL; + +--echo End of 5.0 tests diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 1599bcc1571..a5ede9e757c 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -4285,6 +4285,7 @@ Item_func_regex::fix_fields(THD *thd, Item **ref) if (args[1]->null_value) { // Will always return NULL maybe_null=1; + fixed= 1; return FALSE; } int error; From f80541e37045a7f511998718d5b89d5e9942e6a6 Mon Sep 17 00:00:00 2001 From: "kaa@polly.(none)" <> Date: Thu, 11 Oct 2007 14:28:12 +0400 Subject: [PATCH 145/203] Fix for bug #31174: "Repair" command on MyISAM crashes with small myisam_sort_buffer_size. An incorrect length of the sort buffer was used when calculating the maximum number of keys. When myisam_sort_buffer_size is small enough, this could result in the number of keys < number of BUFFPEK structures which in turn led to use of uninitialized BUFFPEKs. Fixed by correcting the buffer length calculation. --- myisam/sort.c | 6 ++++-- mysql-test/r/repair.result | 27 +++++++++++++++++++++++++++ mysql-test/t/repair.test | 31 ++++++++++++++++++++++++++++++- 3 files changed, 61 insertions(+), 3 deletions(-) diff --git a/myisam/sort.c b/myisam/sort.c index b909a16e8e6..728e5b9673e 100644 --- a/myisam/sort.c +++ b/myisam/sort.c @@ -559,9 +559,10 @@ int thr_write_keys(MI_SORT_PARAM *sort_param) if (!mergebuf) { length=param->sort_buffer_length; - while (length >= MIN_SORT_MEMORY && !mergebuf) + while (length >= MIN_SORT_MEMORY) { - mergebuf=my_malloc(length, MYF(0)); + if ((mergebuf= my_malloc(length, MYF(0)))) + break; length=length*3/4; } if (!mergebuf) @@ -897,6 +898,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, count=error=0; maxcount=keys/((uint) (Tb-Fb) +1); + DBUG_ASSERT(maxcount > 0); LINT_INIT(to_start_filepos); if (to_file) to_start_filepos=my_b_tell(to_file); diff --git a/mysql-test/r/repair.result b/mysql-test/r/repair.result index 355a8c25434..80b716131b9 100644 --- a/mysql-test/r/repair.result +++ b/mysql-test/r/repair.result @@ -83,3 +83,30 @@ test.t1 repair status OK SET myisam_repair_threads=@@global.myisam_repair_threads; SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size; DROP TABLE t1; +CREATE TABLE t1(a CHAR(255), KEY(a)); +SET myisam_sort_buffer_size=4196; +INSERT INTO t1 VALUES +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'); +SET myisam_repair_threads=2; +REPAIR TABLE t1; +Table Op Msg_type Msg_text +test.t1 repair status OK +SET myisam_repair_threads=@@global.myisam_repair_threads; +SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size; +DROP TABLE t1; +End of 4.1 tests diff --git a/mysql-test/t/repair.test b/mysql-test/t/repair.test index 35e5e485cb9..e391e3e0076 100644 --- a/mysql-test/t/repair.test +++ b/mysql-test/t/repair.test @@ -83,4 +83,33 @@ SET myisam_repair_threads=@@global.myisam_repair_threads; SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size; DROP TABLE t1; -# End of 4.1 tests +# +# BUG#31174 - "Repair" command on MyISAM crashes with small +# myisam_sort_buffer_size +# +CREATE TABLE t1(a CHAR(255), KEY(a)); +SET myisam_sort_buffer_size=4196; +INSERT INTO t1 VALUES +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'), +('0'),('0'),('0'),('0'),('0'),('0'),('0'); +SET myisam_repair_threads=2; +REPAIR TABLE t1; +SET myisam_repair_threads=@@global.myisam_repair_threads; +SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size; +DROP TABLE t1; + +--echo End of 4.1 tests From db39976a0658d2e17273b4816289ef6093071591 Mon Sep 17 00:00:00 2001 From: "gluh@mysql.com/eagle.(none)" <> Date: Thu, 11 Oct 2007 16:07:10 +0500 Subject: [PATCH 146/203] Bug#30981 CHAR(0x41 USING ucs2) doesn't add leading zero Bug#30982 CHAR(..USING..) can return a not-well-formed string Bug#30986 Character set introducer followed by a HEX string can return bad result check_well_formed_result moved to Item from Item_str_func fixed Item_func_char::val_str for proper ucs symbols converting added check for well formed strings for correct conversion of constants with underscore charset --- mysql-test/r/ctype_ucs.result | 3 ++ mysql-test/r/ctype_utf8.result | 66 ++++++++++++++++++++++++++++++++-- mysql-test/t/ctype_ucs.test | 5 +++ mysql-test/t/ctype_utf8.test | 19 ++++++++++ sql/item.cc | 35 ++++++++++++++++++ sql/item.h | 1 + sql/item_strfunc.cc | 35 ++---------------- sql/item_strfunc.h | 1 - sql/sql_yacc.yy | 22 +++++++++--- 9 files changed, 148 insertions(+), 39 deletions(-) diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index 023267c227c..262055436b8 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -922,4 +922,7 @@ ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (ucs2_gen select * from t1 where a=if(b<10,_ucs2 0x0062,_ucs2 0x00C0); ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (ucs2_general_ci,COERCIBLE) for operation '=' drop table t1; +select hex(char(0x41 using ucs2)); +hex(char(0x41 using ucs2)) +0041 End of 5.0 tests diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 710cac388a5..a86dfbc190d 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -1538,12 +1538,12 @@ char(53647 using utf8) Ñ select char(0xff,0x8f using utf8); char(0xff,0x8f using utf8) -ÿ + Warnings: Warning 1300 Invalid utf8 character string: 'FF8F' select convert(char(0xff,0x8f) using utf8); convert(char(0xff,0x8f) using utf8) -ÿ + Warnings: Warning 1300 Invalid utf8 character string: 'FF8F' set sql_mode=traditional; @@ -1730,3 +1730,65 @@ i 1 н1234567890 DROP TABLE t1, t2; +set sql_mode=traditional; +select hex(char(0xFF using utf8)); +hex(char(0xFF using utf8)) +NULL +Warnings: +Error 1300 Invalid utf8 character string: 'FF' +select hex(convert(0xFF using utf8)); +hex(convert(0xFF using utf8)) +NULL +Warnings: +Error 1300 Invalid utf8 character string: 'FF' +select hex(_utf8 0x616263FF); +hex(_utf8 0x616263FF) +NULL +Warnings: +Error 1300 Invalid utf8 character string: 'FF' +select hex(_utf8 X'616263FF'); +hex(_utf8 X'616263FF') +NULL +Warnings: +Error 1300 Invalid utf8 character string: 'FF' +select hex(_utf8 B'001111111111'); +hex(_utf8 B'001111111111') +NULL +Warnings: +Error 1300 Invalid utf8 character string: 'FF' +select (_utf8 X'616263FF'); +(_utf8 X'616263FF') +NULL +Warnings: +Error 1300 Invalid utf8 character string: 'FF' +set sql_mode=default; +select hex(char(0xFF using utf8)); +hex(char(0xFF using utf8)) + +Warnings: +Warning 1300 Invalid utf8 character string: 'FF' +select hex(convert(0xFF using utf8)); +hex(convert(0xFF using utf8)) + +Warnings: +Warning 1300 Invalid utf8 character string: 'FF' +select hex(_utf8 0x616263FF); +hex(_utf8 0x616263FF) +616263 +Warnings: +Warning 1300 Invalid utf8 character string: 'FF' +select hex(_utf8 X'616263FF'); +hex(_utf8 X'616263FF') +616263 +Warnings: +Warning 1300 Invalid utf8 character string: 'FF' +select hex(_utf8 B'001111111111'); +hex(_utf8 B'001111111111') +03 +Warnings: +Warning 1300 Invalid utf8 character string: 'FF' +select (_utf8 X'616263FF'); +(_utf8 X'616263FF') +abc +Warnings: +Warning 1300 Invalid utf8 character string: 'FF' diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index bca3a9c3a96..5525a5beb6f 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -651,4 +651,9 @@ select * from t1 where a=if(b<10,_ucs2 0x00C0,_ucs2 0x0062); select * from t1 where a=if(b<10,_ucs2 0x0062,_ucs2 0x00C0); drop table t1; +# +# Bug#30981 CHAR(0x41 USING ucs2) doesn't add leading zero +# +select hex(char(0x41 using ucs2)); + --echo End of 5.0 tests diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index f8eed0bae9a..e10fb708f5c 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -1403,3 +1403,22 @@ SELECT b FROM t2 UNION SELECT c FROM t1; SELECT i FROM t2 UNION SELECT c FROM t1; DROP TABLE t1, t2; + +# +# Bug#30982: CHAR(..USING..) can return a not-well-formed string +# Bug #30986: Character set introducer followed by a HEX string can return bad result +# +set sql_mode=traditional; +select hex(char(0xFF using utf8)); +select hex(convert(0xFF using utf8)); +select hex(_utf8 0x616263FF); +select hex(_utf8 X'616263FF'); +select hex(_utf8 B'001111111111'); +select (_utf8 X'616263FF'); +set sql_mode=default; +select hex(char(0xFF using utf8)); +select hex(convert(0xFF using utf8)); +select hex(_utf8 0x616263FF); +select hex(_utf8 X'616263FF'); +select hex(_utf8 B'001111111111'); +select (_utf8 X'616263FF'); diff --git a/sql/item.cc b/sql/item.cc index e9b2904e3da..b4d1e1e2f52 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4247,6 +4247,41 @@ bool Item::is_datetime() } +String *Item::check_well_formed_result(String *str) +{ + /* Check whether we got a well-formed string */ + CHARSET_INFO *cs= str->charset(); + int well_formed_error; + uint wlen= cs->cset->well_formed_len(cs, + str->ptr(), str->ptr() + str->length(), + str->length(), &well_formed_error); + if (wlen < str->length()) + { + THD *thd= current_thd; + char hexbuf[7]; + enum MYSQL_ERROR::enum_warning_level level; + uint diff= str->length() - wlen; + set_if_smaller(diff, 3); + octet2hex(hexbuf, str->ptr() + wlen, diff); + if (thd->variables.sql_mode & + (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)) + { + level= MYSQL_ERROR::WARN_LEVEL_ERROR; + null_value= 1; + str= 0; + } + else + { + level= MYSQL_ERROR::WARN_LEVEL_WARN; + str->length(wlen); + } + push_warning_printf(thd, level, ER_INVALID_CHARACTER_STRING, + ER(ER_INVALID_CHARACTER_STRING), cs->csname, hexbuf); + } + return str; +} + + /* Create a field to hold a string value from an item diff --git a/sql/item.h b/sql/item.h index cd0be343a62..a2a06f7d917 100644 --- a/sql/item.h +++ b/sql/item.h @@ -870,6 +870,7 @@ public: */ virtual bool result_as_longlong() { return FALSE; } bool is_datetime(); + String *check_well_formed_result(String *str); }; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 0c11c9eece8..4e72f117869 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -38,36 +38,6 @@ C_MODE_END String my_empty_string("",default_charset_info); -String *Item_str_func::check_well_formed_result(String *str) -{ - /* Check whether we got a well-formed string */ - CHARSET_INFO *cs= str->charset(); - int well_formed_error; - uint wlen= cs->cset->well_formed_len(cs, - str->ptr(), str->ptr() + str->length(), - str->length(), &well_formed_error); - if (wlen < str->length()) - { - THD *thd= current_thd; - char hexbuf[7]; - enum MYSQL_ERROR::enum_warning_level level; - uint diff= str->length() - wlen; - set_if_smaller(diff, 3); - octet2hex(hexbuf, str->ptr() + wlen, diff); - if (thd->variables.sql_mode & - (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)) - { - level= MYSQL_ERROR::WARN_LEVEL_ERROR; - null_value= 1; - str= 0; - } - else - level= MYSQL_ERROR::WARN_LEVEL_WARN; - push_warning_printf(thd, level, ER_INVALID_CHARACTER_STRING, - ER(ER_INVALID_CHARACTER_STRING), cs->csname, hexbuf); - } - return str; -} bool Item_str_func::fix_fields(THD *thd, Item **ref) @@ -2229,11 +2199,13 @@ String *Item_func_char::val_str(String *str) { DBUG_ASSERT(fixed == 1); str->length(0); + str->set_charset(collation.collation); for (uint i=0 ; i < arg_count ; i++) { int32 num=(int32) args[i]->val_int(); if (!args[i]->null_value) { + char char_num= (char) num; if (num&0xFF000000L) { str->append((char)(num>>24)); goto b2; @@ -2243,10 +2215,9 @@ String *Item_func_char::val_str(String *str) } else if (num&0xFF00L) { b1: str->append((char)(num>>8)); } - str->append((char) num); + str->append(&char_num, 1); } } - str->set_charset(collation.collation); str->realloc(str->length()); // Add end 0 (for Purify) return check_well_formed_result(str); } diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 6ca0b89a22b..ea6229068fe 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -35,7 +35,6 @@ public: my_decimal *val_decimal(my_decimal *); enum Item_result result_type () const { return STRING_RESULT; } void left_right_max_length(); - String *check_well_formed_result(String *str); bool fix_fields(THD *thd, Item **ref); }; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 553cc6d24d5..c651c5b1f64 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -7716,11 +7716,19 @@ literal: String *str= tmp ? tmp->quick_fix_field(), tmp->val_str((String*) 0) : (String*) 0; - $$= new Item_string(str ? str->ptr() : "", + $$= new Item_string(NULL, /* name will be set in select_item */ + str ? str->ptr() : "", str ? str->length() : 0, Lex->underscore_charset); if ($$) + { ((Item_string *) $$)->set_repertoire_from_value(); + if (!$$->check_well_formed_result(&$$->str_value)) + { + $$= new Item_null(); + $$->set_name(NULL, 0, system_charset_info); + } + } } | UNDERSCORE_CHARSET BIN_NUM { @@ -7732,9 +7740,15 @@ literal: String *str= tmp ? tmp->quick_fix_field(), tmp->val_str((String*) 0) : (String*) 0; - $$= new Item_string(str ? str->ptr() : "", - str ? str->length() : 0, - Lex->charset); + $$= new Item_string(NULL, /* name will be set in select_item */ + str ? str->ptr() : "", + str ? str->length() : 0, + Lex->underscore_charset); + if ($$ && !$$->check_well_formed_result(&$$->str_value)) + { + $$= new Item_null(); + $$->set_name(NULL, 0, system_charset_info); + } } | DATE_SYM text_literal { $$ = $2; } | TIME_SYM text_literal { $$ = $2; } From da023efb5d0cbe3485fc784b76be7366b0349c1b Mon Sep 17 00:00:00 2001 From: "gluh@mysql.com/eagle.(none)" <> Date: Thu, 11 Oct 2007 16:41:05 +0500 Subject: [PATCH 147/203] after merge fix --- sql/sql_yacc.yy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 44667a425fe..adf14228e75 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -9958,7 +9958,7 @@ literal: $$= new Item_string(NULL, /* name will be set in select_item */ str ? str->ptr() : "", str ? str->length() : 0, - Lex->underscore_charset); + $1); if ($$ && !$$->check_well_formed_result(&$$->str_value)) { $$= new Item_null(); From 84d1e3f8f045639f1d501dc62092f1a2a162ed67 Mon Sep 17 00:00:00 2001 From: "ramil/ram@mysql.com/ramil.myoffice.izhnet.ru" <> Date: Thu, 11 Oct 2007 17:20:34 +0500 Subject: [PATCH 148/203] Fix for bug #31154: field.h:1649: virtual int Field_bit::cmp(const uchar*, const uchar*): Assertion Problem: GROUP_CONCAT(DISTINCT BIT_FIELD...) uses a tree to store keys; which are constructed using a temporary table fields, see Item_func_group_concat::setup(). As a) we don't store null bits in the tree where the bit fields store parts of their data and b) there's no method to properly compare two table records we've got problem. Fix: convert BIT fields to INT in the temporary table used. --- mysql-test/r/func_gconcat.result | 42 ++++++++++++++++++++++++++++++++ mysql-test/t/func_gconcat.test | 28 +++++++++++++++++++++ sql/item_sum.cc | 31 ++++++++++++++++++----- 3 files changed, 95 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index 35487c25ae3..73f756bc1d2 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -819,4 +819,46 @@ id group_concat(b.name) 1 óra,óra 2 óra,óra drop table t1; +create table t1(a bit not null); +insert into t1 values (), (), (); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +select group_concat(distinct a) from t1; +group_concat(distinct a) +0 +select group_concat(distinct a order by a) from t1; +group_concat(distinct a order by a) +0 +drop table t1; +create table t1(a bit(2) not null); +insert into t1 values (1), (0), (0), (3), (1); +select group_concat(distinct a) from t1; +group_concat(distinct a) +1,0,3 +select group_concat(distinct a order by a) from t1; +group_concat(distinct a order by a) +0,1,3 +select group_concat(distinct a order by a desc) from t1; +group_concat(distinct a order by a desc) +3,1,0 +drop table t1; +create table t1(a bit(2), b varchar(10), c bit); +insert into t1 values (1, 'a', 0), (0, 'b', 1), (0, 'c', 0), (3, 'd', 1), +(1, 'e', 1), (3, 'f', 1), (0, 'g', 1); +select group_concat(distinct a, c) from t1; +group_concat(distinct a, c) +10,01,00,31,11 +select group_concat(distinct a, c order by a) from t1; +group_concat(distinct a, c order by a) +00,01,11,10,31 +select group_concat(distinct a, c) from t1; +group_concat(distinct a, c) +10,01,00,31,11 +select group_concat(distinct a, c order by a, c) from t1; +group_concat(distinct a, c order by a, c) +00,01,10,11,31 +select group_concat(distinct a, c order by a desc, c desc) from t1; +group_concat(distinct a, c order by a desc, c desc) +31,11,10,01,00 +drop table t1; End of 5.0 tests diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index ff3ba951870..c415ca6c6eb 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -562,4 +562,32 @@ insert into t1 (id, name) values (2, " select b.id, group_concat(b.name) from t1 a, t1 b group by b.id; drop table t1; +# +# Bug #31154: group_concat() and bit fields; +# +create table t1(a bit not null); +insert into t1 values (), (), (); +select group_concat(distinct a) from t1; +select group_concat(distinct a order by a) from t1; +drop table t1; + +create table t1(a bit(2) not null); +insert into t1 values (1), (0), (0), (3), (1); +select group_concat(distinct a) from t1; +select group_concat(distinct a order by a) from t1; +select group_concat(distinct a order by a desc) from t1; +drop table t1; + +create table t1(a bit(2), b varchar(10), c bit); +insert into t1 values (1, 'a', 0), (0, 'b', 1), (0, 'c', 0), (3, 'd', 1), +(1, 'e', 1), (3, 'f', 1), (0, 'g', 1); +select group_concat(distinct a, c) from t1; +select group_concat(distinct a, c order by a) from t1; +select group_concat(distinct a, c) from t1; +select group_concat(distinct a, c order by a, c) from t1; +select group_concat(distinct a, c order by a desc, c desc) from t1; + +drop table t1; + + --echo End of 5.0 tests diff --git a/sql/item_sum.cc b/sql/item_sum.cc index c20d3fba705..48ad53fbf75 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -3307,15 +3307,34 @@ bool Item_func_group_concat::setup(THD *thd) count_field_types(select_lex, tmp_table_param, all_fields, 0); tmp_table_param->force_copy_fields= force_copy_fields; DBUG_ASSERT(table == 0); - /* - Currently we have to force conversion of BLOB values to VARCHAR's - if we are to store them in TREE objects used for ORDER BY and - DISTINCT. This leads to truncation if the BLOB's size exceeds - Field_varstring::MAX_SIZE. - */ if (arg_count_order > 0 || distinct) + { + /* + Currently we have to force conversion of BLOB values to VARCHAR's + if we are to store them in TREE objects used for ORDER BY and + DISTINCT. This leads to truncation if the BLOB's size exceeds + Field_varstring::MAX_SIZE. + */ set_if_smaller(tmp_table_param->convert_blob_length, Field_varstring::MAX_SIZE); + + /* + Force the create_tmp_table() to convert BIT columns to INT + as we cannot compare two table records containg BIT fields + stored in the the tree used for distinct/order by. + Moreover we don't even save in the tree record null bits + where BIT fields store parts of their data. + */ + List_iterator_fast li(all_fields); + Item *item; + while ((item= li++)) + { + if (item->type() == Item::FIELD_ITEM && + ((Item_field*) item)->field->type() == FIELD_TYPE_BIT) + item->marker= 4; + } + } + /* We have to create a temporary table to get descriptions of fields (types, sizes and so on). From 7237c31698176cd732923cca811e701391ccd217 Mon Sep 17 00:00:00 2001 From: "anozdrin/alik@station." <> Date: Thu, 11 Oct 2007 17:11:12 +0400 Subject: [PATCH 149/203] A patch for BUG#31418: User locks misfunctioning after mysql_change_user(). The problem was that THD::ull was not reset in THD::cleanup(). The fix is to reset it. --- sql/sql_class.cc | 1 + tests/mysql_client_test.c | 164 +++++++++++++++++++++++++++++++------- 2 files changed, 134 insertions(+), 31 deletions(-) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 490aedad0ef..09c8a79c15e 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -698,6 +698,7 @@ void THD::cleanup(void) pthread_mutex_lock(&LOCK_user_locks); item_user_lock_release(ull); pthread_mutex_unlock(&LOCK_user_locks); + ull= NULL; } cleanup_done=1; diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 9505340c24f..801f2896107 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -16827,25 +16827,34 @@ static void bug20023_change_user(MYSQL *con) opt_db ? opt_db : "test")); } -static void bug20023_query_int_variable(MYSQL *con, - const char *var_name, - int *var_value) +static bool query_int_variable(MYSQL *con, + const char *var_name, + int *var_value) { MYSQL_RES *rs; MYSQL_ROW row; char query_buffer[MAX_TEST_QUERY_LENGTH]; + bool is_null; + my_snprintf(query_buffer, sizeof (query_buffer), - "SELECT @@%s", + "SELECT %s", (const char *) var_name); DIE_IF(mysql_query(con, query_buffer)); DIE_UNLESS(rs= mysql_store_result(con)); DIE_UNLESS(row= mysql_fetch_row(rs)); - *var_value= atoi(row[0]); + + is_null= row[0] == NULL; + + if (!is_null) + *var_value= atoi(row[0]); + mysql_free_result(rs); + + return is_null; } static void test_bug20023() @@ -16876,19 +16885,19 @@ static void test_bug20023() CLIENT_FOUND_ROWS)); /*********************************************************************** - Remember original SQL_BIG_SELECTS, MAX_JOIN_SIZE values. + Remember original SQL_BIG_SELECTS, MAX_JOIN_SIZE values. ***********************************************************************/ - bug20023_query_int_variable(&con, - "session.sql_big_selects", - &sql_big_selects_orig); + query_int_variable(&con, + "@@session.sql_big_selects", + &sql_big_selects_orig); - bug20023_query_int_variable(&con, - "global.max_join_size", - &max_join_size_orig); + query_int_variable(&con, + "@@global.max_join_size", + &max_join_size_orig); /*********************************************************************** - Test that COM_CHANGE_USER resets the SQL_BIG_SELECTS to the initial value. + Test that COM_CHANGE_USER resets the SQL_BIG_SELECTS to the initial value. ***********************************************************************/ /* Issue COM_CHANGE_USER. */ @@ -16897,17 +16906,17 @@ static void test_bug20023() /* Query SQL_BIG_SELECTS. */ - bug20023_query_int_variable(&con, - "session.sql_big_selects", - &sql_big_selects_2); + query_int_variable(&con, + "@@session.sql_big_selects", + &sql_big_selects_2); /* Check that SQL_BIG_SELECTS is reset properly. */ DIE_UNLESS(sql_big_selects_orig == sql_big_selects_2); /*********************************************************************** - Test that if MAX_JOIN_SIZE set to non-default value, - SQL_BIG_SELECTS will be 0. + Test that if MAX_JOIN_SIZE set to non-default value, + SQL_BIG_SELECTS will be 0. ***********************************************************************/ /* Set MAX_JOIN_SIZE to some non-default value. */ @@ -16921,17 +16930,17 @@ static void test_bug20023() /* Query SQL_BIG_SELECTS. */ - bug20023_query_int_variable(&con, - "session.sql_big_selects", - &sql_big_selects_3); + query_int_variable(&con, + "@@session.sql_big_selects", + &sql_big_selects_3); /* Check that SQL_BIG_SELECTS is 0. */ DIE_UNLESS(sql_big_selects_3 == 0); /*********************************************************************** - Test that if MAX_JOIN_SIZE set to default value, - SQL_BIG_SELECTS will be 1. + Test that if MAX_JOIN_SIZE set to default value, + SQL_BIG_SELECTS will be 1. ***********************************************************************/ /* Set MAX_JOIN_SIZE to the default value (-1). */ @@ -16945,17 +16954,17 @@ static void test_bug20023() /* Query SQL_BIG_SELECTS. */ - bug20023_query_int_variable(&con, - "session.sql_big_selects", - &sql_big_selects_4); + query_int_variable(&con, + "@@session.sql_big_selects", + &sql_big_selects_4); /* Check that SQL_BIG_SELECTS is 1. */ DIE_UNLESS(sql_big_selects_4 == 1); /*********************************************************************** - Restore MAX_JOIN_SIZE. - Check that SQL_BIG_SELECTS will be the original one. + Restore MAX_JOIN_SIZE. + Check that SQL_BIG_SELECTS will be the original one. ***********************************************************************/ /* Restore MAX_JOIN_SIZE. */ @@ -16974,14 +16983,95 @@ static void test_bug20023() /* Query SQL_BIG_SELECTS. */ - bug20023_query_int_variable(&con, - "session.sql_big_selects", - &sql_big_selects_5); + query_int_variable(&con, + "@@session.sql_big_selects", + &sql_big_selects_5); /* Check that SQL_BIG_SELECTS is 1. */ DIE_UNLESS(sql_big_selects_5 == sql_big_selects_orig); + /*********************************************************************** + That's it. Cleanup. + ***********************************************************************/ + + mysql_close(&con); +} + +static void bug31418_impl() +{ + MYSQL con; + + bool is_null; + int rc; + + /* Create a new connection. */ + + DIE_UNLESS(mysql_init(&con)); + + DIE_UNLESS(mysql_real_connect(&con, + opt_host, + opt_user, + opt_password, + opt_db ? opt_db : "test", + opt_port, + opt_unix_socket, + CLIENT_FOUND_ROWS)); + + /*********************************************************************** + Check that lock is free: + - IS_FREE_LOCK() should return 1; + - IS_USED_LOCK() should return NULL; + ***********************************************************************/ + + is_null= query_int_variable(&con, + "IS_FREE_LOCK('bug31418')", + &rc); + DIE_UNLESS(!is_null && rc); + + is_null= query_int_variable(&con, + "IS_USED_LOCK('bug31418')", + &rc); + DIE_UNLESS(is_null); + + /*********************************************************************** + Acquire lock and check the lock status (the lock must be in use): + - IS_FREE_LOCK() should return 0; + - IS_USED_LOCK() should return non-zero thread id; + ***********************************************************************/ + + query_int_variable(&con, "GET_LOCK('bug31418', 1)", &rc); + DIE_UNLESS(rc); + + is_null= query_int_variable(&con, + "IS_FREE_LOCK('bug31418')", + &rc); + DIE_UNLESS(!is_null && !rc); + + is_null= query_int_variable(&con, + "IS_USED_LOCK('bug31418')", + &rc); + DIE_UNLESS(!is_null && rc); + + /*********************************************************************** + Issue COM_CHANGE_USER command and check the lock status + (the lock must be free): + - IS_FREE_LOCK() should return 1; + - IS_USED_LOCK() should return NULL; + **********************************************************************/ + + bug20023_change_user(&con); + + is_null= query_int_variable(&con, + "IS_FREE_LOCK('bug31418')", + &rc); + DIE_UNLESS(!is_null && rc); + + is_null= query_int_variable(&con, + "IS_USED_LOCK('bug31418')", + &rc); + DIE_UNLESS(is_null); + /*********************************************************************** That's it. Cleanup. ***********************************************************************/ @@ -16989,6 +17079,17 @@ static void test_bug20023() mysql_close(&con); } +static void test_bug31418() +{ + /* Run test case for BUG#31418 for three different connections. */ + + bug31418_impl(); + + bug31418_impl(); + + bug31418_impl(); +} + /* Read and parse arguments and MySQL options from my.cnf @@ -17286,6 +17387,7 @@ static struct my_tests_st my_tests[]= { { "test_change_user", test_change_user }, { "test_bug30472", test_bug30472 }, { "test_bug20023", test_bug20023 }, + { "test_bug31418", test_bug31418 }, { 0, 0 } }; From 2adf38c12e80b942ef3728d7f68ce044c15d1758 Mon Sep 17 00:00:00 2001 From: "davi@moksha.com.br" <> Date: Thu, 11 Oct 2007 17:38:40 -0300 Subject: [PATCH 150/203] Bug#29223 declare cursor c for SHOW ..... "DECLARE CURSOR FOR SHOW ..." is a syntax that currently appears to work, but is untested for some SHOW commands and does not work for other SHOW commands. Since this is an un-intended feature that leaked as a result of a coding bug (in the parser grammar), the correct fix is to fix the grammar to not accept this construct. In other words, "DECLARE CURSOR FOR SHOW " is not considered a bug, and we will not implement other features to make all the SHOW commands usable inside a cursor just because someone exploited a bug. --- mysql-test/r/sp-error.result | 21 ++++++++++++++++++++- mysql-test/t/information_schema.test | 2 +- mysql-test/t/sp-error.test | 23 ++++++++++++++++++++++- sql/sql_yacc.yy | 18 +++--------------- 4 files changed, 46 insertions(+), 18 deletions(-) diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index bfcd64e89d3..46b8adb85b8 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -142,7 +142,10 @@ declare c cursor for insert into test.t1 values ("foo", 42); open c; close c; end| -ERROR 42000: Cursor statement must be a SELECT +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 'insert into test.t1 values ("foo", 42); +open c; +close c; +end' at line 3 create procedure p() begin declare x int; @@ -1491,3 +1494,19 @@ ALTER DATABASE `#mysql50#upgrade-me` UPGRADE DATA DIRECTORY NAME; RETURN 0; END// ERROR HY000: Can't drop or alter a DATABASE from within another stored routine +DROP PROCEDURE IF EXISTS p1; +CREATE PROCEDURE p1() +BEGIN +DECLARE c char(100); +DECLARE cur1 CURSOR FOR SHOW TABLES; +OPEN cur1; +FETCH cur1 INTO c; +select c; +CLOSE cur1; +END| +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 'SHOW TABLES; +OPEN cur1; +FETCH cur1 INTO c; +select c; +CLOSE cur1; +END' at line 4 diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 6bcc14d4e49..9ad658645bd 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -953,7 +953,7 @@ BEGIN DECLARE col1, col2, col3, col4, col6 CHAR(255); DECLARE default_val VARCHAR(65532); DECLARE done INT DEFAULT 0; - DECLARE cur1 CURSOR FOR SHOW COLUMNS FROM bug23037; + DECLARE cur1 CURSOR FOR SELECT COLUMN_NAME, COLUMN_TYPE, IS_NULLABLE, COLUMN_KEY, COLUMN_DEFAULT, EXTRA FROM INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='bug23037'; DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1; OPEN cur1; FETCH cur1 INTO col1, col2, col3, col4, default_val, col6; diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index c9145859405..ad516f028e6 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -196,7 +196,7 @@ select f(10)| drop function f| ---error 1322 +--error ER_PARSE_ERROR create procedure p() begin declare c cursor for insert into test.t1 values ("foo", 42); @@ -2178,6 +2178,27 @@ END// delimiter ;// +# +# Bug#29223 declare cursor c for SHOW ..... +# + +--disable_warnings +DROP PROCEDURE IF EXISTS p1; +--enable_warnings +--delimiter | +--error ER_PARSE_ERROR +CREATE PROCEDURE p1() +BEGIN + DECLARE c char(100); + DECLARE cur1 CURSOR FOR SHOW TABLES; + + OPEN cur1; + FETCH cur1 INTO c; + select c; + CLOSE cur1; +END| +--delimiter ; + # # BUG#NNNN: New bug synopsis # diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 39175297753..0989e6e6b24 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -2540,25 +2540,13 @@ sp_decl: sp_cursor_stmt: { Lex->sphead->reset_lex(YYTHD); - - /* - We use statement here just be able to get a better - error message. Using 'select' works too, but will then - result in a generic "syntax error" if a non-select - statement is given. - */ } - statement + select { LEX *lex= Lex; - if (lex->sql_command != SQLCOM_SELECT && - !(sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND)) - { - my_message(ER_SP_BAD_CURSOR_QUERY, ER(ER_SP_BAD_CURSOR_QUERY), - MYF(0)); - MYSQL_YYABORT; - } + DBUG_ASSERT(lex->sql_command == SQLCOM_SELECT); + if (lex->result) { my_message(ER_SP_BAD_CURSOR_SELECT, ER(ER_SP_BAD_CURSOR_SELECT), From 6428dacd44c8207ff7941711ef6219ccc64ba52a Mon Sep 17 00:00:00 2001 From: "malff/marcsql@weblab.(none)" <> Date: Thu, 11 Oct 2007 17:55:18 -0600 Subject: [PATCH 151/203] Bug#27858 (Failing to log to a log table doesn't log anything to error log) Before this patch, failures to write to the log tables (mysql.slow_log and mysql.general_log) were improperly printed (the time was printed twice), or not printed at all. With this patch, failures to write to the log tables is reported in the error log, for all cases of failures. --- mysql-test/r/log_tables.result | 4 +++ mysql-test/t/log_tables.test | 56 ++++++++++++++++++++++++++++++++++ sql/log.cc | 43 +++++++++++++------------- 3 files changed, 81 insertions(+), 22 deletions(-) diff --git a/mysql-test/r/log_tables.result b/mysql-test/r/log_tables.result index 9e67d328849..be0555024fa 100644 --- a/mysql-test/r/log_tables.result +++ b/mysql-test/r/log_tables.result @@ -270,6 +270,10 @@ use mysql; lock tables general_log read local, help_category read local; ERROR HY000: You can't use locks with log tables. unlock tables; +drop table if exists mysql.renamed_general_log; +drop table if exists mysql.renamed_slow_log; +drop table if exists mysql.general_log_new; +drop table if exists mysql.slow_log_new; use mysql; RENAME TABLE general_log TO renamed_general_log; ERROR HY000: Cannot rename 'general_log'. When logging enabled, rename to/from log table must rename two tables: the log table to an archive table and another table back to 'general_log' diff --git a/mysql-test/t/log_tables.test b/mysql-test/t/log_tables.test index 89c7c255554..1d65c86295f 100644 --- a/mysql-test/t/log_tables.test +++ b/mysql-test/t/log_tables.test @@ -295,6 +295,13 @@ unlock tables; # Bug #21785 Server crashes after rename of the log table # +--disable_warnings +drop table if exists mysql.renamed_general_log; +drop table if exists mysql.renamed_slow_log; +drop table if exists mysql.general_log_new; +drop table if exists mysql.slow_log_new; +--enable_warnings + use mysql; # Should result in error --error ER_CANT_RENAME_LOG_TABLE @@ -358,6 +365,55 @@ flush logs; drop table renamed_general_log, renamed_slow_log; use test; +# +# Bug#27858 (Failing to log to a log table doesn't log anything to error log) +# +# This test works as expected, it's a negative test. +# The message "[ERROR] Failed to write to mysql.general_log" +# is printed to master.err when writing to the table mysql.general_log +# failed. +# However, this message is picked up by mysql-test-run.pl, +# and reported as a test failure, which is a false negative. +# There is no current way to *selectively* filter out these expected error conditions +# (see mysql-test/lib/mtr_report.pl, mtr_report_stats()). +# Instead of filtering all occurences of "Failed to write to +# mysql.general_log", which could hide bugs when the error is not expected, +# this test case is commented instead. +# TODO: improve filtering of expected errors in master.err in +# mysql-test-run.pl (based on the test name ?), and uncomment this test. + +# --disable_warnings +# drop table if exists mysql.bad_general_log; +# drop table if exists mysql.bad_slow_log; +# drop table if exists mysql.general_log_hide; +# drop table if exists mysql.slow_log_hide; +# --enable_warnings +# +# create table mysql.bad_general_log (a int) engine= CSV; +# create table mysql.bad_slow_log (a int) engine= CSV; +# +# # Rename does not perform checks on the table structure, +# # exploiting this to force a failure to log +# rename table mysql.general_log to mysql.general_log_hide, mysql.bad_general_log TO mysql.general_log; +# rename table mysql.slow_log to mysql.slow_log_hide, mysql.bad_slow_log TO mysql.slow_log; +# +# # The following message should be printed in master.log: +# # [ERROR] Failed to write to mysql.general_log +# # TODO: See how verifying this could be automated +# +# flush tables; +# select "logging this should fail"; +# +# # Restore the log tables +# +# rename table mysql.general_log to mysql.bad_general_log, mysql.general_log_hide TO mysql.general_log; +# rename table mysql.slow_log to mysql.bad_slow_log, mysql.slow_log_hide TO mysql.slow_log; +# +# flush tables; +# +# drop table mysql.bad_general_log; +# drop table mysql.bad_slow_log; + # # Bug #21966 Strange warnings on repair of the log tables # diff --git a/sql/log.cc b/sql/log.cc index 95204e89d0e..9d6f6fa4c9b 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -387,10 +387,15 @@ bool Log_to_csv_event_handler:: if (table->field[1]->store(user_host, user_host_len, client_cs) || table->field[2]->store((longlong) thread_id, TRUE) || table->field[3]->store((longlong) server_id, TRUE) || - table->field[4]->store(command_type, command_type_len, client_cs) || - table->field[5]->store(sql_text, sql_text_len, client_cs)) + table->field[4]->store(command_type, command_type_len, client_cs)) goto err; + /* + A positive return value in store() means truncation. + Still logging a message in the log in this case. + */ + if (table->field[5]->store(sql_text, sql_text_len, client_cs) < 0) + goto err; /* mark all fields as not null */ table->field[1]->set_notnull(); @@ -407,19 +412,14 @@ bool Log_to_csv_event_handler:: /* log table entries are not replicated */ if (table->file->ha_write_row(table->record[0])) - { - struct tm start; - localtime_r(&event_time, &start); - - sql_print_error("%02d%02d%02d %2d:%02d:%02d - Failed to write to mysql.general_log", - start.tm_year % 100, start.tm_mon + 1, - start.tm_mday, start.tm_hour, - start.tm_min, start.tm_sec); - } + goto err; result= FALSE; err: + if (result) + sql_print_error("Failed to write to mysql.general_log"); + if (need_rnd_end) { table->file->ha_rnd_end(); @@ -595,25 +595,24 @@ bool Log_to_csv_event_handler:: goto err; table->field[9]->set_notnull(); - /* sql_text */ - if (table->field[10]->store(sql_text,sql_text_len, client_cs)) + /* + Column sql_text. + A positive return value in store() means truncation. + Still logging a message in the log in this case. + */ + if (table->field[10]->store(sql_text, sql_text_len, client_cs) < 0) goto err; /* log table entries are not replicated */ if (table->file->ha_write_row(table->record[0])) - { - struct tm start; - localtime_r(¤t_time, &start); - - sql_print_error("%02d%02d%02d %2d:%02d:%02d - Failed to write to mysql.slow_log", - start.tm_year % 100, start.tm_mon + 1, - start.tm_mday, start.tm_hour, - start.tm_min, start.tm_sec); - } + goto err; result= FALSE; err: + if (result) + sql_print_error("Failed to write to mysql.slow_log"); + if (need_rnd_end) { table->file->ha_rnd_end(); From 709bb3948c0a23ab430151a01b716baf0d4b6d88 Mon Sep 17 00:00:00 2001 From: "mtaylor@solace.(none)" <> Date: Fri, 12 Oct 2007 02:15:32 -0700 Subject: [PATCH 152/203] Removed debian dir. It was a mistake to embed it in the tree in the first place. --- Makefile.am | 3 +- configure.in | 1 - debian/Makefile.am | 118 - debian/README.Maintainer | 99 - debian/additions/my.cnf | 134 - .../additions/mysql-server.lintian-overrides | 2 - debian/additions/ndb_mgmd.cnf | 35 - debian/changelog | 3275 ----------------- debian/compat | 1 - debian/control.in | 353 -- debian/copyright | 139 - debian/copyright.more | 60 - debian/defs.mk.in | 14 - ...ibmysqlclientSLIB-dev.README.Maintainer.in | 4 - debian/libmysqlclientSLIB-dev.dirs.in | 2 - debian/libmysqlclientSLIB-dev.docs.in | 1 - debian/libmysqlclientSLIB-dev.examples.in | 1 - debian/libmysqlclientSLIB-dev.files.in | 7 - debian/libmysqlclientSLIB-dev.links.in | 2 - debian/libmysqlclientSLIBoff.README.Debian.in | 30 - debian/libmysqlclientSLIBoff.dirs.in | 1 - debian/libmysqlclientSLIBoff.docs.in | 1 - debian/libmysqlclientSLIBoff.files.in | 1 - debian/libmysqlclientSLIBoff.postinst.in | 12 - debian/libndbclientNLIB-dev.dirs.in | 3 - debian/libndbclientNLIB-dev.files.in | 3 - debian/libndbclientNLIB-dev.links.in | 1 - debian/libndbclientNLIB.README.Debian.in | 30 - debian/libndbclientNLIB.dirs.in | 1 - debian/libndbclientNLIB.files.in | 1 - debian/libndbclientNLIB.postinst.in | 12 - debian/mysql-client-BASE.NEWS.in | 6 - debian/mysql-client-BASE.README.Debian.in | 4 - debian/mysql-client-BASE.dirs.in | 2 - debian/mysql-client-BASE.docs.in | 2 - debian/mysql-client-BASE.files.in | 18 - debian/mysql-client-BASE.lintian-overrides.in | 1 - debian/mysql-common.README.Debian.in | 20 - debian/mysql-common.dirs.in | 1 - debian/mysql-common.files.in | 2 - debian/mysql-common.postrm.in | 7 - debian/mysql-common.preinst.in | 215 -- debian/mysql-extra-BASE.dirs.in | 1 - debian/mysql-extra-BASE.files.in | 3 - debian/mysql-management-BASE.dirs.in | 1 - debian/mysql-management-BASE.files.in | 1 - ...l-management-BASE.mysql-management.init.in | 86 - debian/mysql-server-BASE.NEWS.in | 10 - debian/mysql-server-BASE.README.Debian.in | 125 - debian/mysql-server-BASE.config.in | 39 - debian/mysql-server-BASE.dirs.in | 13 - debian/mysql-server-BASE.docs.in | 2 - debian/mysql-server-BASE.files.in | 50 - debian/mysql-server-BASE.links.in | 1 - debian/mysql-server-BASE.lintian-overrides.in | 4 - ...ql-server-BASE.logcheck.ignore.paranoid.in | 10 - ...ysql-server-BASE.logcheck.ignore.server.in | 31 - ...server-BASE.logcheck.ignore.workstation.in | 31 - ...ysql-server-BASE.mysql-server.logrotate.in | 28 - debian/mysql-server-BASE.postinst.in | 276 -- debian/mysql-server-BASE.postrm.in | 92 - debian/mysql-server-BASE.preinst.in | 167 - debian/mysql-server-BASE.prerm.in | 8 - debian/mysql-server-BASE.templates.in | 71 - debian/mysql-server-PREV.preinst.in | 191 - debian/mysql-server.preinst.in | 191 - debian/mysql-storage-BASE.dirs.in | 1 - debian/mysql-storage-BASE.files.in | 1 - .../mysql-storage-BASE.mysql-storage.init.in | 85 - debian/mysql-test-BASE.dirs.in | 2 - debian/mysql-test-BASE.files.in | 6 - debian/mysql-tools-BASE.dirs.in | 2 - debian/mysql-tools-BASE.files.in | 13 - debian/po/POTFILES.in.in | 1 - debian/po/ca.po | 290 -- debian/po/cs.po | 259 -- debian/po/da.po | 283 -- debian/po/de.po | 195 - debian/po/es.po | 288 -- debian/po/eu.po | 163 - debian/po/fr.po | 204 - debian/po/gl.po | 279 -- debian/po/it.po | 184 - debian/po/ja.po | 278 -- debian/po/nb.po | 179 - debian/po/nl.po | 187 - debian/po/pt.po | 198 - debian/po/pt_BR.po | 339 -- debian/po/ro.po | 193 - debian/po/ru.po | 172 - debian/po/sv.po | 225 -- debian/po/templates.pot | 155 - debian/po/tr.po | 290 -- debian/rules | 405 -- debian/source.lintian-overrides.in | 6 - debian/watch | 3 - 96 files changed, 1 insertion(+), 10942 deletions(-) delete mode 100644 debian/Makefile.am delete mode 100644 debian/README.Maintainer delete mode 100644 debian/additions/my.cnf delete mode 100644 debian/additions/mysql-server.lintian-overrides delete mode 100644 debian/additions/ndb_mgmd.cnf delete mode 100644 debian/changelog delete mode 100644 debian/compat delete mode 100644 debian/control.in delete mode 100644 debian/copyright delete mode 100644 debian/copyright.more delete mode 100644 debian/defs.mk.in delete mode 100644 debian/libmysqlclientSLIB-dev.README.Maintainer.in delete mode 100644 debian/libmysqlclientSLIB-dev.dirs.in delete mode 100644 debian/libmysqlclientSLIB-dev.docs.in delete mode 100644 debian/libmysqlclientSLIB-dev.examples.in delete mode 100644 debian/libmysqlclientSLIB-dev.files.in delete mode 100644 debian/libmysqlclientSLIB-dev.links.in delete mode 100644 debian/libmysqlclientSLIBoff.README.Debian.in delete mode 100644 debian/libmysqlclientSLIBoff.dirs.in delete mode 100644 debian/libmysqlclientSLIBoff.docs.in delete mode 100644 debian/libmysqlclientSLIBoff.files.in delete mode 100644 debian/libmysqlclientSLIBoff.postinst.in delete mode 100644 debian/libndbclientNLIB-dev.dirs.in delete mode 100644 debian/libndbclientNLIB-dev.files.in delete mode 100644 debian/libndbclientNLIB-dev.links.in delete mode 100644 debian/libndbclientNLIB.README.Debian.in delete mode 100644 debian/libndbclientNLIB.dirs.in delete mode 100644 debian/libndbclientNLIB.files.in delete mode 100644 debian/libndbclientNLIB.postinst.in delete mode 100644 debian/mysql-client-BASE.NEWS.in delete mode 100644 debian/mysql-client-BASE.README.Debian.in delete mode 100644 debian/mysql-client-BASE.dirs.in delete mode 100644 debian/mysql-client-BASE.docs.in delete mode 100644 debian/mysql-client-BASE.files.in delete mode 100644 debian/mysql-client-BASE.lintian-overrides.in delete mode 100644 debian/mysql-common.README.Debian.in delete mode 100644 debian/mysql-common.dirs.in delete mode 100644 debian/mysql-common.files.in delete mode 100644 debian/mysql-common.postrm.in delete mode 100644 debian/mysql-common.preinst.in delete mode 100644 debian/mysql-extra-BASE.dirs.in delete mode 100644 debian/mysql-extra-BASE.files.in delete mode 100644 debian/mysql-management-BASE.dirs.in delete mode 100644 debian/mysql-management-BASE.files.in delete mode 100644 debian/mysql-management-BASE.mysql-management.init.in delete mode 100644 debian/mysql-server-BASE.NEWS.in delete mode 100644 debian/mysql-server-BASE.README.Debian.in delete mode 100644 debian/mysql-server-BASE.config.in delete mode 100644 debian/mysql-server-BASE.dirs.in delete mode 100644 debian/mysql-server-BASE.docs.in delete mode 100644 debian/mysql-server-BASE.files.in delete mode 100644 debian/mysql-server-BASE.links.in delete mode 100644 debian/mysql-server-BASE.lintian-overrides.in delete mode 100644 debian/mysql-server-BASE.logcheck.ignore.paranoid.in delete mode 100644 debian/mysql-server-BASE.logcheck.ignore.server.in delete mode 100644 debian/mysql-server-BASE.logcheck.ignore.workstation.in delete mode 100644 debian/mysql-server-BASE.mysql-server.logrotate.in delete mode 100644 debian/mysql-server-BASE.postinst.in delete mode 100644 debian/mysql-server-BASE.postrm.in delete mode 100644 debian/mysql-server-BASE.preinst.in delete mode 100644 debian/mysql-server-BASE.prerm.in delete mode 100644 debian/mysql-server-BASE.templates.in delete mode 100644 debian/mysql-server-PREV.preinst.in delete mode 100644 debian/mysql-server.preinst.in delete mode 100644 debian/mysql-storage-BASE.dirs.in delete mode 100644 debian/mysql-storage-BASE.files.in delete mode 100644 debian/mysql-storage-BASE.mysql-storage.init.in delete mode 100644 debian/mysql-test-BASE.dirs.in delete mode 100644 debian/mysql-test-BASE.files.in delete mode 100644 debian/mysql-tools-BASE.dirs.in delete mode 100644 debian/mysql-tools-BASE.files.in delete mode 100644 debian/po/POTFILES.in.in delete mode 100644 debian/po/ca.po delete mode 100644 debian/po/cs.po delete mode 100644 debian/po/da.po delete mode 100644 debian/po/de.po delete mode 100644 debian/po/es.po delete mode 100644 debian/po/eu.po delete mode 100644 debian/po/fr.po delete mode 100644 debian/po/gl.po delete mode 100644 debian/po/it.po delete mode 100644 debian/po/ja.po delete mode 100644 debian/po/nb.po delete mode 100644 debian/po/nl.po delete mode 100644 debian/po/pt.po delete mode 100644 debian/po/pt_BR.po delete mode 100644 debian/po/ro.po delete mode 100644 debian/po/ru.po delete mode 100644 debian/po/sv.po delete mode 100644 debian/po/templates.pot delete mode 100644 debian/po/tr.po delete mode 100755 debian/rules delete mode 100644 debian/source.lintian-overrides.in delete mode 100644 debian/watch diff --git a/Makefile.am b/Makefile.am index 66daff4bd68..c1bdbb22e8e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -33,8 +33,7 @@ DIST_SUBDIRS = . include @docs_dirs@ zlib \ @thread_dirs@ pstack \ @sql_union_dirs@ scripts @man_dirs@ tests SSL\ BUILD netware os2 @libmysqld_dirs@ \ - @bench_dirs@ support-files @tools_dirs@ win \ - debian + @bench_dirs@ support-files @tools_dirs@ win # Run these targets before any others, also make part of clean target, # to make sure we create new links after a clean. diff --git a/configure.in b/configure.in index 0878f0331e4..71d5988480e 100644 --- a/configure.in +++ b/configure.in @@ -3017,7 +3017,6 @@ AC_CONFIG_FILES(Makefile extra/Makefile mysys/Makefile dnl cmd-line-utils/libedit/Makefile dnl win/Makefile dnl zlib/Makefile dnl - debian/Makefile debian/defs.mk debian/control dnl cmd-line-utils/readline/Makefile) AC_CONFIG_COMMANDS([default], , test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h) AC_OUTPUT diff --git a/debian/Makefile.am b/debian/Makefile.am deleted file mode 100644 index 14035865371..00000000000 --- a/debian/Makefile.am +++ /dev/null @@ -1,118 +0,0 @@ -# Copyright (C) 2006 MySQL AB -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -## Process this file with automake to create Makefile.in -EXTRA_DIST = \ - mysql-test-BASE.files.in \ - libndbclientNLIB-dev.files.in \ - mysql-server-BASE.config.in \ - libndbclientNLIB.README.Debian.in \ - mysql-server-BASE.postrm.in \ - mysql-server-BASE.NEWS.in \ - libndbclientNLIB.postinst.in \ - mysql-server-BASE.links.in \ - libndbclientNLIB.files.in \ - source.lintian-overrides.in \ - mysql-server-BASE.docs.in \ - libmysqlclientSLIBoff.files.in \ - mysql-server-BASE.files.in \ - libndbclientNLIB-dev.links.in \ - libmysqlclientSLIBoff.postinst.in \ - mysql-extra-BASE.dirs.in \ - libmysqlclientSLIB-dev.links.in \ - mysql-server-BASE.dirs.in \ - libmysqlclientSLIB-dev.examples.in \ - mysql-client-BASE.lintian-overrides.in \ - copyright.more \ - libndbclientNLIB-dev.dirs.in \ - mysql-server-BASE.README.Debian.in \ - libmysqlclientSLIBoff.docs.in \ - compat \ - mysql-test-BASE.dirs.in \ - libmysqlclientSLIB-dev.files.in \ - libmysqlclientSLIBoff.dirs.in \ - mysql-server-BASE.logcheck.ignore.server.in \ - mysql-storage-BASE.mysql-storage.init.in \ - libmysqlclientSLIBoff.README.Debian.in \ - mysql-client-BASE.README.Debian.in \ - Makefile.am \ - mysql-server-BASE.prerm.in \ - mysql-common.dirs.in \ - defs.mk \ - defs.mk.in \ - mysql-server-BASE.mysql-server.logrotate.in \ - mysql-common.README.Debian.in \ - copyright \ - mysql-storage-BASE.dirs.in \ - mysql-common.preinst.in \ - mysql-client-BASE.files.in \ - mysql-server-BASE.templates.in \ - mysql-tools-BASE.dirs.in \ - mysql-management-BASE.mysql-management.init.in \ - watch \ - mysql-common.postrm.in \ - mysql-server-BASE.preinst.in \ - README.Maintainer \ - mysql-tools-BASE.files.in \ - mysql-client-BASE.NEWS.in \ - mysql-server-BASE.lintian-overrides.in \ - changelog \ - mysql-server-BASE.logcheck.ignore.paranoid.in \ - mysql-common.files.in \ - mysql-server-BASE.logcheck.ignore.workstation.in \ - mysql-extra-BASE.files.in \ - mysql-management-BASE.files.in \ - mysql-client-BASE.docs.in \ - libmysqlclientSLIB-dev.README.Maintainer.in \ - mysql-storage-BASE.files.in \ - additions \ - additions/ndb_mgmd.cnf \ - additions/mysql-server.lintian-overrides \ - additions/my.cnf \ - mysql-server-BASE.postinst.in \ - libndbclientNLIB.dirs.in \ - po \ - po/fr.po \ - po/sv.po \ - po/da.po \ - po/es.po \ - po/ja.po \ - po/tr.po \ - po/nb.po \ - po/POTFILES.in.in \ - po/cs.po \ - po/pt.po \ - po/gl.po \ - po/pt_BR.po \ - po/nl.po \ - po/templates.pot \ - po/de.po \ - po/eu.po \ - po/ro.po \ - po/ru.po \ - po/it.po \ - po/ca.po \ - mysql-client-BASE.dirs.in \ - control.in \ - libmysqlclientSLIB-dev.dirs.in \ - mysql-server-PREV.preinst.in \ - mysql-server.preinst.in \ - mysql-management-BASE.dirs.in \ - rules \ - libmysqlclientSLIB-dev.docs.in - -# Don't update the files from bitkeeper -%::SCCS/s.% - diff --git a/debian/README.Maintainer b/debian/README.Maintainer deleted file mode 100644 index 80b484d7a6c..00000000000 --- a/debian/README.Maintainer +++ /dev/null @@ -1,99 +0,0 @@ -########################################################################### -# Here are some information that are only of interest to the Debiani # -# maintainers of MySQL. # -########################################################################### - -# -# Remarks to dependencies -# -libwrap0-dev (>= 7.6-8.3) - According to bug report 114582 where where build problems on - IA-64/sid with at least two prior versions. -psmisc - /usr/bin/killall in the initscript - -zlib1g in libmysqlclient-dev: - "mysql_config --libs" adds "-lz" - -Build-Dep: - -debhelper (>=4.1.16): - See po-debconf(7). - -autoconf (>= 2.13-20), automake1.7 - Try to get rid of them. - -doxygen, tetex-bin, tetex-extra, gs - for ndb/docs/*tex - -mysql-server-5.0: Pre-Depends: mysql-common - This was necessary as mysql-server-5.0.preinst checks for unmodified - conffiles from mysql-server-4.1 and copies 5.0 ones over them to avoid - unnecessary dpkg questions. As mysql-server-5.0 is not unpacked at its - pre-inst stage, it had to copy those files from a package that is - definetly already unpacked which does not have to be the case with Depends. - -# -# Remarks to the start scripts -# - -## initscripts rely on mysqladmin from a different package -We have the problem that "/etc/init.d/mysql stop" relies on mysqladmin which -is in another package (mysql-client) and a passwordless access that's maybe -only available if the user configured his /root/.my.cnf. Can this be a problem? -* normal mode: not because the user is required to have it. Else: -* purge/remove: not, same as normal mode -* upgrade: not, same as normal mode -* first install: not, it depends on mysql-client which at least is unpacked - so mysqladmin is there (to ping). It is not yet configured - passwordles but if there's a server running then there's a - /root/.my.cnf. Anyways, we simply kill anything that's mysqld. - -## Passwordless access for the maintainer scripts -Another issue is that the scripts needs passwordless access. To ensure this -a debian-sys-maint user is configured which has process and shutdown privs. -The file with the randomly (that's important!) generated password must be -present as long as the databases remain installed because else a new install -would have no access. This file should be used like: - mysqladmin --defaults-file=/etc/mysql/debian.cnf restart -to avoid providing the password in plaintext on a commandline where it would -be visible to any user via the "ps" command. - -## When to start the daemon? -We aim to give the admin full control on when MySQL is running. -Issues to be faced here: -OLD: - 1. Debconf asks whether MySQL should be started on boot so update-rc.d is - only run if the answer has been yes. The admin is likely to forget - this decision but update-rc.d checks for an existing line in - /etc/runlevel.conf and leaves it intact. - 2. On initial install, if the answer is yes, the daemon has to be started. - 3. On upgrades it should only be started if it was already running, everything - else is confusing. Especiall relying on an debconf decision made month ago - is considered suboptimal. See bug #274264 - Implementation so far: - prerm (called on upgrade before stopping the server): - check for a running server and set flag if necessary - preinst (called on initial install and before unpacking when upgrading): - check for the debconf variable and set flag if necessary - postinst (called on initial install and after each upgrade after unpacking): - call update-rc.d if debconf says yes - call invoce-rc.d if the flag has been set - Problems remaining: - dpkg-reconfigure and setting mysql start on boot to yes did not start mysql - (ok "start on boot" literally does not mean "start now" so that might have been ok) -NEW: - 1. --- no debconf anymore for the sake of simplicity. We have runlevel.conf, - the admin should use it - 2. On initial install the server is started. - 3. On upgrades the server is started exactly if it was running before so the - runlevel configuration is irrelevant. It will be preserved by the mean of - update-rc.d's builtin check. - Implementation: - prerm (called on upgrade before stopping the server): - check for a running server and set flag if necessary - preinst (called on initial install and before unpacking when upgrading): - check for $1 beeing (initial) "install" and set flag - postinst (called on initial install and after each upgrade after unpacking): - call update-rc.d - call invoce-rc.d if the flag has been set diff --git a/debian/additions/my.cnf b/debian/additions/my.cnf deleted file mode 100644 index a569c041401..00000000000 --- a/debian/additions/my.cnf +++ /dev/null @@ -1,134 +0,0 @@ -# -# The MySQL database server configuration file. -# -# You can copy this to one of: -# - "/etc/mysql/my.cnf" to set global options, -# - "~/.my.cnf" to set user-specific options. -# -# One can use all long options that the program supports. -# Run program with --help to get a list of available options and with -# --print-defaults to see which it would actually understand and use. -# -# For explanations see -# http://dev.mysql.com/doc/mysql/en/server-system-variables.html - -# This will be passed to all mysql clients -# It has been reported that passwords should be enclosed with ticks/quotes -# escpecially if they contain "#" chars... -# Remember to edit /etc/mysql/debian.cnf when changing the socket location. -[client] -port = 3306 -socket = /var/run/mysqld/mysqld.sock - -# Here is entries for some specific programs -# The following values assume you have at least 32M ram - -# This was formally known as [safe_mysqld]. Both versions are currently parsed. -[mysqld_safe] -socket = /var/run/mysqld/mysqld.sock -nice = 0 - -[mysqld] -# -# * Basic Settings -# -user = mysql -pid-file = /var/run/mysqld/mysqld.pid -socket = /var/run/mysqld/mysqld.sock -port = 3306 -basedir = /usr -datadir = /var/lib/mysql -tmpdir = /tmp -language = /usr/share/mysql/english -skip-external-locking -# -# Instead of skip-networking the default is now to listen only on -# localhost which is more compatible and is not less secure. -bind-address = 127.0.0.1 -# -# * Fine Tuning -# -key_buffer = 16M -max_allowed_packet = 16M -thread_stack = 128K -thread_cache_size = 8 -# -# * Query Cache Configuration -# -query_cache_limit = 1048576 -query_cache_size = 16777216 -query_cache_type = 1 -# -# * Logging and Replication -# -# Both location gets rotated by the cronjob. -# Be aware that this log type is a performance killer. -#log = /var/log/mysql/mysql.log -# -# Error logging goes to syslog. This is a Debian improvement :) -# -# Here you can see queries with especially long duration -#log_slow_queries = /var/log/mysql/mysql-slow.log -# -# The following can be used as easy to replay backup logs or for replication. -#server-id = 1 -log_bin = /var/log/mysql/mysql-bin.log -# WARNING: Using expire_logs_days without bin_log crashes the server! See README.Debian! -expire_logs_days = 10 -max_binlog_size = 100M -#binlog_do_db = include_database_name -#binlog_ignore_db = include_database_name -# -# * BerkeleyDB -# -# Using BerkeleyDB is now discouraged as its support will cease in 5.1.12. -skip-bdb -# -# * InnoDB -# -# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. -# Read the manual for more InnoDB related options. There are many! -# You might want to disable InnoDB to shrink the mysqld process by circa 100MB. -#skip-innodb -# -# * Security Features -# -# Read the manual, too, if you want chroot! -# chroot = /var/lib/mysql/ -# -# For generating SSL certificates I recommend the OpenSSL GUI "tinyca". -# -# ssl-ca=/etc/mysql/cacert.pem -# ssl-cert=/etc/mysql/server-cert.pem -# ssl-key=/etc/mysql/server-key.pem - - - -[mysqldump] -quick -quote-names -max_allowed_packet = 16M - -[mysql] -#no-auto-rehash # faster start of mysql but no tab completition - -[isamchk] -key_buffer = 16M - -# -# * NDB Cluster -# -# See /usr/share/doc/mysql-server-*/README.Debian for more information. -# -# The following configuration is read by the NDB Data Nodes (ndbd processes) -# not from the NDB Management Nodes (ndb_mgmd processes). -# -# [MYSQL_CLUSTER] -# ndb-connectstring=127.0.0.1 - - -# -# * IMPORTANT: Additional settings that can override those from this file! -# -!includedir /etc/mysql/conf.d/ - diff --git a/debian/additions/mysql-server.lintian-overrides b/debian/additions/mysql-server.lintian-overrides deleted file mode 100644 index 9d741cf16e9..00000000000 --- a/debian/additions/mysql-server.lintian-overrides +++ /dev/null @@ -1,2 +0,0 @@ -W: mysql-dfsg source: maintainer-script-lacks-debhelper-token debian/mysql-server.postinst -W: mysql-server: possible-bashism-in-maintainer-script postinst:68 'p{("a".."z","A".."Z",0..9)[int(rand(62))]}' diff --git a/debian/additions/ndb_mgmd.cnf b/debian/additions/ndb_mgmd.cnf deleted file mode 100644 index d94a28ff705..00000000000 --- a/debian/additions/ndb_mgmd.cnf +++ /dev/null @@ -1,35 +0,0 @@ -[NDBD DEFAULT] -NoOfReplicas=2 -DataMemory=10MB -IndexMemory=25MB -MaxNoOfTables=256 -MaxNoOfOrderedIndexes=256 -MaxNoOfUniqueHashIndexes=128 - -[MYSQLD DEFAULT] - -[NDB_MGMD DEFAULT] - -[TCP DEFAULT] - -[NDB_MGMD] -Id=1 # the NDB Management Node (this one) -HostName=127.0.0.1 - -[NDBD] -Id=2 # the first NDB Data Node -HostName=127.0.0.1 -DataDir= /var/lib/mysql-cluster - -[NDBD] -Id=3 # the second NDB Data Node -HostName=127.0.0.1 -DataDir=/var/lib/mysql-cluster - -[MYSQLD] -Id=4 # the first SQL node -HostName=127.0.0.1 - -# [MYSQLD] -# Id=5 # the second SQL node -# HostName=127.0.0.10 diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index 605619b605c..00000000000 --- a/debian/changelog +++ /dev/null @@ -1,3275 +0,0 @@ -mysql-5.0 (5.0.42) UNRELEASED; urgency=low - - * Upgraded to 5.0.42 branch. - - -- Monty Taylor Thu, 19 Apr 2007 22:18:02 +0200 - -mysql-5.0 (5.0.38) UNRELEASED; urgency=low - - * Imported packaging work from Debian. - * Removed debian-start, mysqlreport and echo_stderr to align with official - packages. - - -- Monty Taylor Wed, 7 Mar 2007 07:52:55 +0800 - -mysql-dfsg-5.0 (5.0.32-3etch1) testing-proposed-updates; urgency=high - - * Backported upstream patch for a bug that crashed the server when using - certain join/group/limit combinations. - Users of the Joomla CMS seemed to be affected by this. Closes: #403721 - * The debian-start script that runs on every server start now first upgrades - the system tables (if neccessary) and then check them as it sometimes did - not work the other way around (e.g. for MediaWiki). The script now uses - mysql_update instead of mysql_update_script as recommended. Closes: 409780 - * The old_passwords setting that is set according to a Debconf question is - now written to /etc/mysql/conf.d/old_passwords.cnf instead directly to the - conffile /etc/mysql/my.cnf which would be fobidden by policy (thanks to - Robert Bihlmeyer). Closes: #409750 - * Added bison to build dependencies. - * Synced Debconf translations with 5.0.32-7. - - -- Christian Hammers Sun, 18 Feb 2007 22:33:05 +0100 - -mysql-dfsg-5.0 (5.0.32-3) unstable; urgency=high - - * mysql-server-5.0 pre-depends on adduser now and has --disabled-login - explicitly added to be on the safe side (thanks to the puiparts team). - Closes: #408362 - * Corrections the terminology regarding NDB in the comments of all config - files and init scripts (thanks to Geert Vanderkelen of MySQL). - * Updated Swedish Debconf translation (thanks to Andreas Henriksson). - Closes: #407859 - * Updated Czech Debconf translation (thanks to Miroslav Kure). - Closes: #407809 - - -- Christian Hammers Thu, 11 Jan 2007 11:18:47 +0100 - -mysql-dfsg-5.0 (5.0.32-2) unstable; urgency=high - - * The last upload suffered from a regression that made NDB totally - unusable and caused a dependency to libmysqlclient15-dev in the - mysql-server-5.0 package. The relevant 85_* patch was re-added again. - Closes: #406435 - * Added lintian-overrides for an error that does not affect our packages. - There are now only warnings and not errors left. - - -- Christian Hammers Tue, 9 Jan 2007 23:55:10 +0100 - -mysql-dfsg-5.0 (5.0.32-1) unstable; urgency=high - - * New upstream version. - * SECURITY: mysql_fix_privilege_tables.sql altered the - table_privs.table_priv column to contain too few privileges, causing - loss of the CREATE VIEW and SHOW VIEW privileges. (MySQL Bug#20589) - * SECURITY (DoS): ALTER TABLE statements that performed both RENAME TO - and {ENABLE|DISABLE} KEYS operations caused a server crash. (MySQL - Bug#24089) - * SECURITY (DoS): LAST_DAY('0000-00-00') could cause a server crash. - (MySQL Bug#23653) - * SECURITY (DoS): Using EXPLAIN caused a server crash for queries that - selected from INFORMATION_SCHEMA in a subquery in the FROM clause. - (MySQL Bug#22413) - * SECURITY (DoS): Invalidating the query cache (e.g. when using stored procedures) - caused a server crash for INSERT INTO ... SELECT statements that - selected from a view. (MySQL Bug#20045) - * Using mysql_upgrade with a password crashed the server. Closes: #406229 - * yaSSL crashed on pre-Pentium Intel and Cyrix CPUs. (MySQL Bug#21765) - Closes: #383759 - * Lots of small fixes to the NDB cluster storage engine. - * Updated Japanese Debconf template (thanks to Hideki Yamane). - Closes: #405793 - * Fixed comment regarding "mycheck" in debian-start (thanks to - Enrico Zini). Closes: #405787 - - -- Christian Hammers Sat, 6 Jan 2007 14:26:20 +0100 - -mysql-dfsg-5.0 (5.0.30-3) unstable; urgency=low - - * Updated Brazilian Debconf translation (thanks to Andre Luis Lopes). - Closes: #403821 - * Added Romanian Debconf translation (thanks to Stan Ioan-Eugen). - Closes: #403943 - * Updated Spanish Debconf translation (thanks to Javier Fernandez-Sanguino - Pena). Closes: #404084 - * Updated Galician Debconf translation (thanks to Jacobo Tarrio). - Closes: #404318 - * Updated Dutch Debconf translation (thanks to Vincent Zweije). - Closes: #404566 - * Updated Danish Debconf translation (thanks to Claus Hindsgaul). - Closes: #405018 - - -- Christian Hammers Thu, 21 Dec 2006 21:35:09 +0100 - -mysql-dfsg-5.0 (5.0.30-2) unstable; urgency=high - - * Fixed upstream regression in header files that lead to FTBFS for - mysql-admin, mysql-query-browser and probably other pacakges. - (thanks to Andreas Henriksson). Closes: #403081, #403082 - * Fixed some upstream scripts by replacing /etc by /etc/mysql (thanks to - Julien Antony). Closes: #401083 - * Updated French Debconf translation (thanks to Christian Perrier). - Closes: #401434 - * Added Spanish Debconf translation (thanks to Javier Fernandez-Sanguino - Pena). Closes: #401953 - * Marked a Debconf question that is just a dummy and only internally - used as not-needing-translation. Closes: #403163 - * Fixed mysqlslowdump patch to not remove the usage() function (thanks - to Monty Tailor). - - -- Christian Hammers Sun, 3 Dec 2006 19:20:10 +0100 - -mysql-dfsg-5.0 (5.0.30-1) unstable; urgency=low - - * New upstream version (switch to the MySQL Enterprise branch). - * Upstream bugfix for the Innodb performance bug: - "Very poor performance with multiple queries running - concurrently (Bug#15815)". - * Upstream bugfix for a possible server crash: - "Selecting from a MERGE table could result in a server crash if the - underlying tables had fewer indexes than the MERGE table itself - (Bug#22937)" - * Upstream bugfies for *lot* of NDB problems. - * Upstream bugfix for Innodb optimizer bug. Closes: #397597 - * Updated Italian Debconf translation (thanks to Luca Monducci). - Closes: #401305 - * Updated debian/watch file to MySQL Enterprise branch. - - -- Christian Hammers Sat, 2 Dec 2006 16:36:38 +0100 - -mysql-dfsg-5.0 (5.0.27-2) unstable; urgency=medium - - * Disabled YaSSL x86 assembler as it was reported to crash applications - like pam-mysql or proftpd-mysql which are linked against libmysqlclient - on i486 and Cyrix (i586) CPUs. Closes: #385147 - * Adjusted mysql-server-4.1 priority to extra and section to oldlibs - according to the ftp masters overrides. - * Updated German Debconf translation (thanks to Alwin Meschede). - Closes: #400809 - - -- Christian Hammers Wed, 22 Nov 2006 13:36:31 +0100 - -mysql-dfsg-5.0 (5.0.27-1) unstable; urgency=medium - - * New upstream version (but no codechange, the only difference to 5.0.26 - was a patch to the ABI change which Debian already included. - * When dist-upgrading from mysql-server-4.1/sarge dpkg does not longer - ask unnecessary "config file has changed" questions regarding - /etc/init.d/mysql, /etc/logrotate.d/mysql-server and - /etc/mysql/debian-start just because these files previously belonged - to mysql-server-4.1 and not to mysql-server-5.0. - To archive this mysql-server-5.0 now pre-depends on mysql-common which - provides current versions of those files. - * The automatic run mysql_upgrade now works with non-standard datadir - settings, too (thanks to Benjami Villoslada). Closes: #394607 - * Debconf now asks if the old_passwords option is really needed. - * Improved explanations of the old_passwords variable in my.cnf. - * Removed possibly leftover cron script from MySQL-4.1 (thanks to - Mario Oyorzabal Salgado). Closes: #390889 - * Postrm ignores failed "userdel mysql". - * Updated Danish Debconf translation (thanks to Claus Hindsgaul). - Closes: #398784 - * Added Euskarian Debconf translation (thanks to Piarres Beobide). - Closes: #399045 - * Updated Japanese Debconf translation (thanks to Hideki Yamane). - Closes: #399074 - * Updated German Debconf translation (thanks to Alwin Meschede). - Closes: #399087 - * New Portuguese debconf translations from Miguel Figueiredo. - Closes: #398186 - - -- Christian Hammers Tue, 7 Nov 2006 21:26:25 +0100 - -mysql-dfsg-5.0 (5.0.26-3) unstable; urgency=high - - [sean finney] - * Fix for the deadly ISAM trap. Now during upgrades we will do our - very best to convert pre-existing ISAM format tables using the - binaries from the previous package. Success is not guaranteed, but - this is probably as good as it gets. Note that this also necessitates - re-introducing an (empty transitional) mysql-server-4.1 package. - Closes: #354544, #354850 - * Remove a couple spurious and wrongly placed WARNING statements from - 45_warn-CLI-passwords.dpatch. thanks to Dan Jacobsen for pointing these - out. Closes: #394262 - - -- sean finney Fri, 03 Nov 2006 18:34:46 +0100 - -mysql-dfsg-5.0 (5.0.26-2) unstable; urgency=high - - * Fixed FTBFS for Alpha by applying an upstream patch (thanks to Falk - Hueffner). Closes: #395921 - - -- Christian Hammers Sat, 28 Oct 2006 20:13:46 +0200 - -mysql-dfsg-5.0 (5.0.26-1) unstable; urgency=high - - * SECURITY: - This combined release of 5.0.25 and 5.0.26 fixes lot of possible server - crashs so it should get into Etch. Quoting the changelog (bug numbers are - bugs.mysql.com ones): - - character_set_results can be NULL to signify no conversion, but some - code did not check for NULL, resulting in a server crash. (Bug#21913) - - Using cursors with READ COMMITTED isolation level could cause InnoDB to - crash. (Bug#19834) - - Some prepared statements caused a server crash when executed a second - time. (Bug#21166) - - When DROP DATABASE or SHOW OPEN TABLES was issued while concurrently - issuing DROP TABLE (or RENAME TABLE, CREATE TABLE LIKE or any other - statement that required a name lock) in another connection, the server - crashed. (Bug#21216) - - Use of zero-length variable names caused a server crash. (Bug#20908) - - For InnoDB tables, the server could crash when executing NOT IN () - subqueries. (Bug#21077) - - Repeated DROP TABLE statements in a stored procedure could sometimes - cause the server to crash. (Bug#19399) - - Performing an INSERT on a view that was defined using a SELECT that - specified a collation and a column alias caused the server to crash - (Bug#21086). - - A query of the form shown here caused the server to crash. (Bug#21007) - - NDB Cluster: Some queries involving joins on very large NDB tables could - crash the MySQL server. (Bug#21059) - - The character set was not being properly initialized for CAST() with a - type like CHAR(2) BINARY, which resulted in incorrect results or even a - server crash. (Bug#17903) - - For certain queries, the server incorrectly resolved a reference to an - aggregate function and crashed. (Bug#20868) - - The server crashed when using the range access method to execut a - subquery with a ORDER BY DESC clause. (Bug#20869) - - Triggers on tables in the mysql database caused a server crash. Triggers - for tables in this database now are disallowed. (Bug#18361) - - Using SELECT on a corrupt MyISAM table using the dynamic record format - could cause a server crash. (Bug#19835) - - Use of MIN() or MAX() with GROUP BY on a ucs2 column could cause a - server crash. (Bug#20076) - - Selecting from a MERGE table could result in a server crash if the - underlying tables had fewer indexes than the MERGE table itself. - (Bug#21617, Bug#22937) - - * New upstream release. - - This bug would cause trouble for Sarge->Etch upgrades, it was supposed to - have been fixed in 5.0.16 but that apparently did not fix the whole - problem: - Using tables from MySQL 4.x in MySQL 5.x, in particular those with VARCHAR - fields and using INSERT DELAYED to update data in the table would result in - either data corruption or a server crash. (Bug#16611, Bug#16218, Bug#17294) - Closes: #386337 - - Fixes data corruption as an automatic client reconnect used to set - the wrong character set. Closes: #365050 - - Fixes an undefined ulong type in an include file. Closes: #389102 - - Fixes wrong output format when using Unicode characters. Closes: #355302 - - Fixes mysql_upgrade when using a password. Closes: #371841 - - [Christian Hammers] - * Removed --sysconfdir from debian/rules as it puts /etc/mysql/ at the - end of the my.cnf search patch thus overriding $HOME/my.cnf - (thanks to Christoph Biedl). Closes: #394992 - * The provided patch from bug #385947 was wrong, the variable is called - BLOCKSIZE not BLOCK_SIZE according to "strings `which df`" (thanks to - Bruno Muller). Closes: #385947 - - [sean finney] - * new dutch debconf translations from Vincent Zweije (closes: #392809). - * new japanese debconf translations from Hideki Yamane (closes: #391625). - * new italian debconf translations from Luca Monducci (closes: #391741). - * new french debconf translations from Christian Perrier (closes: #393334). - * ran debconf-updatepo to merge the fuzzies into svn. - * massage the following patches so they continue to apply cleanly: - - 44_scripts__mysql_config__libs.dpatch to cleanly apply. - - 45_warn-CLI-passwords.dpatch - - 96_TEMP__libmysqlclient_ssl_symbols.dpatch (note, this patch might - no longer be needed, but is retained "just in case" after massaging it) - * the following patches have been incorporated upstream: - - 70_kfreebsd.dpatch - - 80_hurd_mach.dpatch - - 87_ps_Hurd.dpatch - - 90_TEMP__client__mysql_upgrade__O_EXEC.dpatch - - 91_TEMP__client__mysql_upgrade__password.dpatch - - 92_TEMP__client__mysql_upgrade__defaultgroups.dpatch - - 94_TEMP__CVE-2006-4227.dpatch - - 95_TEMP__CVE-2006-4226.dpatch - * the udf_example.cc has disappeared from the source code, but there's - a udf_example.c which seems to be a good example to use instead :) - * update documentation in the configuration to no longer reference - using my.cnf in the DATADIR, as it's never been the recommended - method for debian systems and hasn't worked since 5.0 was released - anyway (closes: #393868). - - -- Christian Hammers Wed, 25 Oct 2006 19:54:04 +0200 - -mysql-dfsg-5.0 (5.0.24a-9) unstable; urgency=medium - - * Having expire_logs_days enabled but log-bin not crashes the server. Using - both or none of those options is safe. To prevent this happening during the - nightly log rotation via /etc/logrotate.d/mysql the initscript checks for - malicious combination of options. See: #368547 - * The Sarge package "mysql-server" which used to include the mysqld daemon - may still be in unselected-configured state (i.e. after a remove but not - purge) in which case its now obsolete cronscript has to be moved away - (thanks to Charles Lepple). Closes: #385669 - * Updated Danish Debconf translation (thanks to Claus Hindsgaul). - Closes: #390315 - * Updated Frensh Debconf translation (thanks to Christian Perrier). - Closes: #390980 - - -- Christian Hammers Tue, 3 Oct 2006 14:55:31 +0200 - -mysql-dfsg-5.0 (5.0.24a-8) unstable; urgency=low - - * (broken upload) - - -- Christian Hammers Tue, 3 Oct 2006 14:55:31 +0200 - -mysql-dfsg-5.0 (5.0.24a-7) unstable; urgency=low - - * Stopped mysql_config from announcing unnecessary library dependencies - which until now cause "NEEDED" dependencies in the "readelf -d" output - of libraries who only depend on libmysqlclient.so (thanks to Michal - Cihar). Closes: #390692 - - -- Christian Hammers Sun, 1 Oct 2006 23:59:43 +0200 - -mysql-dfsg-5.0 (5.0.24a-6) unstable; urgency=low - - [sean finney] - * finally add support for setting a root password at install. - while this is not a random password as requested in one bug - report, we believe it is the best solution and provides a - means to set a random password via preseeding if it's really - desired (Closes: #316127, #298295). - - -- sean finney Sun, 01 Oct 2006 23:34:30 +0200 - -mysql-dfsg-5.0 (5.0.24a-5) unstable; urgency=low - - * Added ${shlibs:Depends} to debian/control section libmysqlclient-dev as it - contains the experimental /usr/lib/mysql/libndbclient.so.0.0.0. - * Bumped standards version to 3.7.2. - * Added LSB info section to init scripts. - * Rephrased Debconf templates as suggested by lintian. - * Added benchmark suite in /usr/share/mysql/sql-bench/. - * The mysql.timezone* tables are now filled by the postinst script (thanks - to Mark Sheppard). Closes: #388491 - * Moved Debconf install notes to README.Debian. Displaying them with - medium priority was a bug anyway. Closes: #388941 - * Replaced /usr/bin/mysql_upgrade by /usr/bin/mysql_upgrade_shell in - /etc/mysql/debian-start.sh as it works without errors (thanks to Javier - Kohen). Closes: #389443 - - -- Christian Hammers Wed, 20 Sep 2006 15:01:42 +0200 - -mysql-dfsg-5.0 (5.0.24a-4) unstable; urgency=high - - * libmysqlclient.so.15 from 5.0.24 accidentaly exports some symbols that are - historically exported by OpenSSL's libcrypto.so. This bug was supposed to - be fixed in 5.0.24a bug according to the mysql bug tracking system will - only be fixed in 5.0.25 so I backported the patch. People already reported - crashing apps due to this (thanks to Duncan Simpson). See also: #385348 - Closes: #388262 - * Fixed BLOCKSIZE to BLOCK_SIZE in initscript (thanks to Bruno Muller). - Closes: #385947 - * Added hint to "--extended-insert=0" to mysqldump manpage (thanks to Martin - Schulze). - * Documented the meaning of "NDB" in README.Debian (thanks to Dan Jacobson). - Closes: #386274 - * Added patch to build on hurd-i386 (thanks to Cyril Brulebois). Closes: #387369 - * Fixed debian-start script to work together with the recend LSB modifications in - the initscript (thanks to wens). Closes: #387481 - * Reverted tmpdir change in my.cnf back to /tmp to comply with FHS (thanks - to Alessandro Valente). Closes: #382778 - * Added logcheck filter rule (thanks to Paul Wise). Closes: #381043 - * I will definetly not disable InnoDB but added a note to the default my.cnf - that disabling it saves about 100MB virtual memory (thanks to Olivier - Berger). Closes: #384399 - * Added thread_cache_size=8 to default my.cnf as this variable seems to have - a negligible memory footprint but can improve performance when lots of - threads connect simultaneously as often seen on web servers. - - -- Christian Hammers Mon, 4 Sep 2006 00:21:50 +0200 - -mysql-dfsg-5.0 (5.0.24a-3) unstable; urgency=low - - * Fixed potential tempfile problem in the newly added mysqlreport script. - - -- Christian Hammers Sun, 3 Sep 2006 23:17:24 +0200 - -mysql-dfsg-5.0 (5.0.24a-2) unstable; urgency=low - - * Added "mysqlreport" (GPL'ed) from hackmysql.com. - * Temporarily disabled expire_days option as it causes the server - to crash. See #368547 - * Made output of init scripts LSB compliant (thanks to David Haerdeman). - Closes: #385874 - - -- Christian Hammers Sun, 3 Sep 2006 19:06:53 +0200 - -mysql-dfsg-5.0 (5.0.24a-1) unstable; urgency=high - - * New upstream version. - * The shared library in the 5.0.24 upstream release accidently exported - some symbols that are also exported by the OpenSSL libraries (notably - BN_bin2bn) causing unexpected behaviour in applications using these - functions (thanks to Peter Cernak). Closes: #385348 - * Added note about possible crash on certain i486 clone CPUs. - * Made recipient address of startup mysqlcheck output configurable - (thanks to Mattias Guns). Closes: #385119 - - -- Christian Hammers Mon, 28 Aug 2006 01:22:12 +0200 - -mysql-dfsg-5.0 (5.0.24-3) unstable; urgency=high - - * SECURITY: - CVE-2006-4226: - When run on case-sensitive filesystems, MySQL allows remote - authenticated users to create or access a database when the database - name differs only in case from a database for which they have - permissions. - CVE-2006-4227: - MySQL evaluates arguments of suid routines in the security context of - the routine's definer instead of the routine's caller, which allows - remote authenticated users to gain privileges through a routine that - has been made available using GRANT EXECUTE. - Thanks to Stefan Fritsch for reporting. Closes: #384798 - - -- Christian Hammers Sat, 26 Aug 2006 04:55:17 +0200 - -mysql-dfsg-5.0 (5.0.24-2) unstable; urgency=high - - * 5.0.24-1 introduced an ABI incompatibility, which this patch reverts. - Programs compiled against 5.0.24-1 are not compatible with any other - version and needs a rebuild. - This bug already caused a lot of segfaults and crashes in various - programs. Thanks to Chad MILLER from MySQL for quickly providing a patch. - The shlibdeps version has been increased to 5.0.24-2. - Closes: #384047, #384221, #383700 - - -- Christian Hammers Fri, 25 Aug 2006 21:47:35 +0200 - -mysql-dfsg-5.0 (5.0.24-1) unstable; urgency=high - - * SECURITY: Upstream fixes a security bug which allows a user to continue - accessing a table using a MERGE TABLE after the right to direct access to - the database has been revoked (CVE-2006-4031, MySQL bug #15195). - (Well they did not exactly fixed it, they documented the behaviour and - allow the admin to disable merge table alltogether...). Closes: #380271 - * SECURITY: Applied patch that fixes a possibly insecure filehandling - in the recently added mysql_upgrade binary file (MySQL bug #10320). - * New upstream version. - - Fixes nasty MySQL bug #19618 that leads to crashes when using - "SELECT ... WHERE ... not in (1, -1)" (e.g. vbulletin was affected). - - Fixes upstream bug #16803 so that linking ~/.mysql_history to /dev/null - now has the desired effect of having no history. - * Really fixed the runlevels. Closes: #377651 - * Added patch for broken upstream handling of "host=" to mysql_upgrade.c. - * Adjusted /etc/mysql/debian-start to new mysql_upgrade.c - - -- Christian Hammers Tue, 8 Aug 2006 00:44:13 +0200 - -mysql-dfsg-5.0 (5.0.22-5) unstable; urgency=low - - * Added further line to the logcheck ignore files (thanks to Paul Wise). - Closes: #381038 - - -- Christian Hammers Wed, 2 Aug 2006 00:28:50 +0200 - -mysql-dfsg-5.0 (5.0.22-4) unstable; urgency=low - - * Upstream fixes a bug in the (never released) version 5.0.23 which could - maybe used to crash the server if the mysqlmanager daemon is in use - which is not yet the default in Debian. (CVE-2006-3486 *DISPUTED*) - * Changed runlevel priority of mysqld from 20 to 19 so that it gets started - before apache and proftpd etc. which might depend on an already running - database server (thanks to Martin Gruner). Closes: #377651 - * Added patch which sets PATH_MAX in ndb (thanks to Cyril Brulebois). - Closes: #378949 - * Activated YaSSL as licence issues are settled according to: - http://bugs.mysql.com/?id=16755. This also closes the FTBFS bug - regarding OpenSSL as it is discouraged to use now. Closes: #368639 - * Removed SSL-MINI-HOWTO as the official documentation is good enough now. - * mysql_upgrade no longer gives --password on the commandline which would - be insecure (thanks to Dean Gaudet). Closes: #379199 - * Adjusted debian/patches/45* to make consecutive builds in the same source - tree possible (thanks to Bob Tanner). Closes: #368661 - * mysql-server-5.0 is now suggesting tinyca as yaSSL is enabled and tinyca - was found to be really cool :) - * Moved tempdir from /tmp to /var/tmp as it will more likely have enough - free space as /tmp is often on the root partition and /var or at least - /var/tmp is on a bigger one. - - -- Christian Hammers Mon, 10 Jul 2006 23:30:26 +0200 - -mysql-dfsg-5.0 (5.0.22-3) unstable; urgency=low - - * Added patch for MySQL bug #19618: "select x from x - where x not in(1,-1)" may crash the server" (thanks to - Ruben Puettmann). - - -- Christian Hammers Fri, 9 Jun 2006 01:41:44 +0200 - -mysql-dfsg-5.0 (5.0.22-2) unstable; urgency=high - - * Fixed debian-sys-maint related bug in postinst (thanks to - Jean-Christophe Dubacq). Closes: #369970 - * The last upload was a security patch (which I did not know as I - uploaded before the announcement came). I now added the CVE id for - reference and set urgency to high as the last entry did not. - - -- Christian Hammers Wed, 31 May 2006 01:04:11 +0200 - -mysql-dfsg-5.0 (5.0.22-1) unstable; urgency=low - - * SECURITY: This upstream release fixes an SQL-injection with multibyte - encoding problem. (CVE-2006-2753) - * New upstream release. - * Upstream fixes REPAIR TABLE problem. Closes: #354300 - * Upstream fixes problem that empty strings in varchar and text columns - are displayed as NULL. Closes: #368663 - - -- Christian Hammers Tue, 30 May 2006 23:43:24 +0200 - -mysql-dfsg-5.0 (5.0.21-4) unstable; urgency=low - - * Added "BLOCKSIZE=" to the diskfree check (thanks to Farzad FARID). - Closes: #367027, #367083 - * Further fixed mysql_upgrade upstream script (thanks to Andreas Pakulat) - Closes: #366155 - * Adjusted the /proc test in debian/rules from /proc/1 to /proc/self - to make building on grsec systems possible (thanks to K. Rosenegger). - Closes: #366824 - * Updated Russion Debconf translation (thanks to Yuriy Talakan). - Closes: #367141 - * Updated Czech Debconf translation (thanks to Kiroslav Kure). - Closes: #367160 - * Updated Galician Debconf translation (thanks to Jacobo Tarrio). - Closes: #367384 - * Updated Swedish Debconf translation (thanks to Daniel Nylander). - Closes: #368186 - - -- Christian Hammers Wed, 10 May 2006 08:45:42 +0200 - -mysql-dfsg-5.0 (5.0.21-3) unstable; urgency=low - - * Fixed FTBFS problem which was caused by a patch that modifies Makefile.am - as well as Makefile.in and was not deteced because my desktop was fast - enough to patch both files within the same second and so fooled automake. - (thanks to Blars Blarson for notifying me). Closes: #366534 - - -- Christian Hammers Sat, 6 May 2006 19:03:58 +0200 - -mysql-dfsg-5.0 (5.0.21-2) unstable; urgency=low - - * Fixed bug in postinst that did not correctly rewrite - /etc/mysql/debian.cnf (thanks to Daniel Leidert). - Closes: #365433, #366155 - - -- Christian Hammers Thu, 4 May 2006 02:37:03 +0200 - -mysql-dfsg-5.0 (5.0.21-1) unstable; urgency=high - - * SECURITY: New upstream release with some security relevant bugfixes: - * "Buffer over-read in check_connection with usernames lacking a - trailing null byte" (CVE-2006-1516) - * "Anonymous Login Handshake - Information Leakage" (CVE-2006-1517) - * "COM_TABLE_DUMP Information Leakage and Arbitrary command execution" - (CVE-2006-1518) - Closes: #365938, #365939 - * Added diskfree check to the init script (thanks to Tim Baverstock). - Closes: #365460 - * First amd64 upload! - - -- Christian Hammers Sat, 29 Apr 2006 04:31:27 +0200 - -mysql-dfsg-5.0 (5.0.20a-2) unstable; urgency=low - - * The new mysql-upgrade which is started from /etc/mysql/debian-start - does now use the debian-sys-maint user for authentication (thanks to - Philipp). Closes: #364991 - * Wrote patch debian/patches/43* which adds a password option to - mysql_update. See MySQL bug #19400. - * Added "Provides: libmysqlclient-dev" to libmysqlclient15-dev as I saw no - obvious reasons against it (problems should be documented in - debian/README.Maintainer!) (thanks to Olaf van der Spek). Closes: #364899 - * Updated Netherlands debconf translation (thanks to Vincent Zweije) - Closes: #364464 - * Updated French debconf translation (thanks to Christian Perrier) - Closes: #364401 - * Updated Danish debconf translation (thanks to Claus Hindsgaul) - Closes: #365135 - - -- Christian Hammers Wed, 26 Apr 2006 01:14:53 +0200 - -mysql-dfsg-5.0 (5.0.20a-1) unstable; urgency=low - - * New upstream release. - * Added the new mysql_upgrade script and added it to - /etc/mysql/debian-start (thanks to Alessandro Polverini). - The script is currently very noise that is a known bug and will be - fixed in the next release! - Closes: #363458 - * No longer creates the "test" database. This actuallay had been tried - to archive before (at least patches) exists but apparently was not the - case in the last versions (thanks to Olaf van der Spek). Closes: #362126 - * Reformatted libmysqlclient15off.NEWS.Debian to changelog format - (thanks to Peter Palfrader). Closes: #363062 - - -- Christian Hammers Sat, 15 Apr 2006 13:05:22 +0200 - -mysql-dfsg-5.0 (5.0.20-1) unstable; urgency=high - - * Upstream contains a fix for a nasty bug (MySQL#18153) that users - already experienced and that caused corrupted triggers after - REPAIR/OPTIMIZE/ALTER TABLE statements. - (thanks to Jerome Despatis for pointing out) - * Added patch for the "updates on multiple tables is buggy after - upgrading from 4.1 to 5.0" problem which MySQL has been committed - for the upcoming 5.0.21 release. Closes #352704 - * Added Netherlands debconf translation (thanks to Vincent Zweije). - Closes: #360443 - * Added Galician debconf translation (thanks to Jacobo Tarrio). - Closes: #361257 - - -- Christian Hammers Fri, 7 Apr 2006 00:00:43 +0200 - -mysql-dfsg-5.0 (5.0.19-3) unstable; urgency=high - - [ Christian Hammers ] - * Fixed libmysqlclient15.README.Debian regarding package name changes - (thanks to Leppo). - * Moved libheap.a etc. back to /usr/lib/mysql/ as their names are just - too generic. Closes: #353924 - [ Sean Finney ] - * updated danish debconf translation, thanks to Claus Hindsgaul - (closes: #357424). - [ Adam Conrad ] - * Send stderr from 'find' in preinst to /dev/null to tidy up chatter. - * Backport patch for CVE-2006-0903 from the upcoming release to resolve - a log bypass vulnerability when using non-binary logs (closes: #359701) - - -- Adam Conrad Tue, 4 Apr 2006 15:23:18 +1000 - -mysql-dfsg-5.0 (5.0.19-2) unstable; urgency=medium - - * New upstream release. - * Renamed package libmysqlclient15 to libmysqlclient15off due to - binary incompatible changes. - See /usr/share/doc/libmysqlclient15off/README.Debian - * Updated Czech debconf translation (thanks to Miroslav Kure). - Closes: #356503 - * Updated French debconf translation (thanks to Christian Perrier). - Closes: #356332 - * Improved README.Debian (thanks to Olaf van der Spek). Closes: #355702 - * Fixed 5.0.18-8 changelog by saying in which package the NEWS.Debian - file is (thanks to Ross Boylan). Closes: #355978 - - -- Christian Hammers Fri, 17 Mar 2006 02:32:19 +0100 - -mysql-dfsg-5.0 (5.0.19-1) experimental; urgency=medium - - * New upstream release. - * SECURITY: CVE-2006-3081: A bug where str_to_date(1,NULL) lead to a - server crash has been fixed. - (this note has been added subsequently for reference) - * Renamed package libmysqlclient15 to libmysqlclient15off. - See /usr/share/doc/libmysqlclient15off/NEWS.Debian - * Updated Czech debconf translation (thanks to Miroslav Kure). - Closes: #356503 - * Updated French debconf translation (thanks to Christian Perrier). - Closes: #356332 - * Improved README.Debian (thanks to Olaf van der Spek). Closes: #355702 - * Fixed 5.0.18-8 changelog by saying in which package the NEWS.Debian - file is (thanks to Ross Boylan). Closes: #355978 - - -- Christian Hammers Tue, 14 Mar 2006 22:56:13 +0100 - -mysql-dfsg-5.0 (5.0.18-9) unstable; urgency=medium - - [ Christian Hammers ] - * When using apt-get the check for left-over ISAM tables can abort the - installation of mysql-server-5.0 but not prevent the mysql-server-4.1 - package from getting removed. The only thing I can do is reflect this - in the Debconf notice that is shown and suggest to reinstall - mysql-server-4.1 for converting. See: #354850 - * Suggests removing of /etc/cron.daily/mysql-server in last NEWS message - (thanks to Mourad De Clerck). Closes: #354111 - * Added versioned symbols for kfreebsd and Hurd, too (thanks to Aurelien - Jarno and Michael Bank). Closes: #353971 - * Added versioned symbols for kfreebsd, too (thanks to Aurelien Jarno). - Closes: #353971 - [ Adam Conrad ] - * Add 39_scripts__mysqld_safe.sh__port_dir.dpatch to ensure that the - permissions on /var/run/mysqld are always correct, even on a tmpfs. - - -- Christian Hammers Mon, 6 Mar 2006 21:42:13 +0100 - -mysql-dfsg-5.0 (5.0.18-8) unstable; urgency=low - - * The rotation of the binary logs is now configured via - expire-logs-days in /etc/mysql/my.cnf and handled completely - by the server and no longer in configured in debian-log-rotate.conf - and handled by a cron job. Thanks to David Johnson. - See /usr/share/doc/mysql-server-5.0/NEWS.Debian - * Ran aspell over some files in debian/ and learned a lot :) - * debian/rules: Added check if versioned symbols are really there. - * Updated SSL-MINI-HOWTO. - * Updated copyright (removed the parts regarding the now removed - BerkeleyDB table handler and mysql-doc package). - * Relocated a variable in preinst (thanks to Michael Heldebrant). - Closes: #349258, #352587, #351216 - * Updated Danish debconf translation (thanks to Claus Hindsgaul). - Closes: #349013 - * Updated Swedish debconf translation (thanks to Daniel Nylander). - Closes: #349522 - * Updated French debconf translation (thanks to Christian Perrier). - Closes: #349592 - * Fixed typo in README.Debian (thanks to Vincent Ricard). - * Prolonged waiting time for mysqld in the init script. Closes: #352070 - - -- Christian Hammers Mon, 23 Jan 2006 23:13:46 +0100 - -mysql-dfsg-5.0 (5.0.18-7) unstable; urgency=low - - * Made mailx in debian-start.inc.sh optional and changed the dependency on it - on it to a mere recommendation. Closes: #316297 - * the previous FTBFS patches for GNU/Hurd inadvertently led to configure - being regenerating, losing a couple trivial things like our versioned - symbols patch, causing many nasty problems (closes: #348854). - - -- sean finney Fri, 20 Jan 2006 20:59:27 +0100 - -mysql-dfsg-5.0 (5.0.18-6) unstable; urgency=low - - * Added version comment (thanks to Daniel van Eeden). - * Added two patches to build on GNU/Hurd (thanks to Michael Bank). - Closes: #348182 - * Abort upgrade if old and now unsupported ISAM tables are present - (thanks to David Coe). Closes: #345895 - - -- Christian Hammers Tue, 17 Jan 2006 19:25:59 +0100 - -mysql-dfsg-5.0 (5.0.18-5) unstable; urgency=low - - * Bump shlibdeps for libmysqlclient15 to (>= 5.0.15-1), which was - the first non-beta release from upstream, as well as being shortly - after we broke the ABI in Debian by introducing versioned symbols. - - -- Adam Conrad Fri, 13 Jan 2006 13:18:03 +1100 - -mysql-dfsg-5.0 (5.0.18-4) unstable; urgency=low - - * Munge our dependencies further to smooth upgrades even more, noting - that we really need 5.0 to conflict with 4.1, and stealing a page from - the book of mysql-common, it doesn't hurt to hint package managers in - the direction of "hey, this stuff is a complete replacement for 4.1" - * Change the description of mysql-server and mysql-client to remove the - references to it being "transition", and instead point out that it's - the way to get the "current best version" of each package installed. - - -- Adam Conrad Wed, 11 Jan 2006 11:39:45 +1100 - -mysql-dfsg-5.0 (5.0.18-3) unstable; urgency=low - - * Make the mysql-{client,server}-5.0 conflict against mysql-{client,server} - versioned, so they can be installed side-by-side and upgrade properly. - * Add myself to Uploaders; since I have access to the alioth repository. - - -- Adam Conrad Tue, 10 Jan 2006 19:15:48 +1100 - -mysql-dfsg-5.0 (5.0.18-2) unstable; urgency=low - - * Removed the transitional package that forced an upgrade from - mysql-server-4.1 to mysql-server-5.0 as I was convinced that - having a general "mysql-server" package with adjusted dependencies - is enough (thanks to Adam Conrad). - * Updated logcheck.ignore files (thanks to Jamie McCarthy). Closes: #340193 - - -- Christian Hammers Mon, 9 Jan 2006 21:54:53 +0100 - -mysql-dfsg-5.0 (5.0.18-1) unstable; urgency=low - - * New upstream version. - * Added empty transitional packages that force an upgrade from the - server and client packages that have been present in Sarge. - * Fixed SSL-MINI-HOWTO (thanks to Jonas Smedegaard). Closes: #340589 - - -- Christian Hammers Mon, 2 Jan 2006 21:17:51 +0100 - -mysql-dfsg-5.0 (5.0.17-1) unstable; urgency=low - - * Never released as Debian package. - - -- Christian Hammers Thu, 22 Dec 2005 07:49:52 +0100 - -mysql-dfsg-5.0 (5.0.16-1) unstable; urgency=low - - * New upstream version. - * Removed the error logs from the logrotate script as Debian does - not use them anymore. Closes: #339628 - - -- Christian Hammers Tue, 22 Nov 2005 01:19:11 +0100 - -mysql-dfsg-5.0 (5.0.15-2) unstable; urgency=medium - - * Added 14_configure__gcc-atomic.h.diff to fix FTBFS on m68k - (thanks to Stephen R Marenka). Closes: #337082 - * Removed dynamic linking against libstdc++ as it was not really - needed (thanks to Adam Conrad). Closes: #328613 - * Fixed the "/var/lib/mysql is a symlink" workaround that accidently - left a stalled symlink (thanks to Thomas Lamy). Closes: #336759 - * As the init script cannot distinguish between a broken startup and - one that just takes very long the "failed" message now says - "or took more than 6s" (thanks to Olaf van der Spek). Closes: #335547 - - -- Christian Hammers Thu, 3 Nov 2005 22:00:15 +0100 - -mysql-dfsg-5.0 (5.0.15-1) unstable; urgency=low - - * New upstream version. 5.0 has finally been declared STABLE! - * Added small patch to debian/rules that fixed sporadic build errors - where stdout and stderr were piped together, got mixed up and broke - * Added --with-big-tables to ./configure (thanks to tj.trevelyan). - Closes: #333090 - * Added capability to parse "-rc" to debian/watch. - * Fixed cronscript (thanks to Andrew Deason). Closes: #335244 - * Added Swedish debconf translation (thanks to Daniel Nylander). - Closes: #333670 - * Added comment to README.Debian regarding applications that manually - set new-style passwords... Closes: #334444 - * Sean Finney: - - Fix duplicate reference to [-e|--extended-insert]. Closes: #334957 - - Fix default behavior for mysqldumpslow. Closes: #334517 - - Reference documentation issue in mysql manpage. Closes: #335219 - - -- Christian Hammers Fri, 30 Sep 2005 00:10:39 +0200 - -mysql-dfsg-5.0 (5.0.13rc-1) unstable; urgency=low - - * New upstream release. Now "release-candidate"! - * Removed any dynamic link dependencies to libndbclient.so.0 which - is due to its version only distributed as a static library. - * Sean Finney: - - FTBFS fix related to stripping rpath in debian/rules - - -- Christian Hammers Mon, 26 Sep 2005 22:09:26 +0200 - -mysql-dfsg-5.0 (5.0.12beta-5) unstable; urgency=low - - * The recent FTBFS were probably result of a timing bug in the - debian/patches/75_*.dpatch file where Makefile.in got patched just - before the Makefile.shared which it depended on. For that reason - only some of the autobuilders failed. Closes: #330149 - * Fixed chrpath removal (option -k had to be added). - * Corrected debconf dependency as requested by Joey Hess. - - -- Christian Hammers Mon, 26 Sep 2005 18:37:07 +0200 - -mysql-dfsg-5.0 (5.0.12beta-4) unstable; urgency=low - - * Removed experimental shared library libndbclient.so.0.0.0 as it - is doomed to cause trouble as long as it is present in both MySQL 4.1 - and 5.0 without real soname and its own package. We still have - libndbclient.a for developers. (thanks to Adam Conrad and - mediaforest.net). Closes: #329772 - - -- Christian Hammers Fri, 23 Sep 2005 12:36:48 +0200 - -mysql-dfsg-5.0 (5.0.12beta-3) unstable; urgency=medium - - * Symbol versioning support! wooooohoooooo! - (thanks to Steve Langasek) Closes: #236288 - * Moved libndbcclient.so.0 to the -dev package as it is provided by - libmysqlclient14 and -15 which must be installable simultaneously. - * Removed mysql-*-doc suggestions. - - -- Christian Hammers Tue, 20 Sep 2005 00:07:03 +0200 - -mysql-dfsg-5.0 (5.0.12beta-2) unstable; urgency=low - - * Added patch to build on GNU/kFreeBSD (thanks to Aurelien Jarno). - Closes: #327702 - * Added patch that was already been present on the 4.1 branch which - makes the "status" command of the init script more sensible - (thanks to Stephen Gildea). Closes: #311836 - * Added Vietnamese Debconf translation (thanks to Clytie Siddal). - Closes: #313006 - * Updated German Debconf translation (thanks to Jens Seidel). - Closes: #313957 - * Corrected commends in example debian-log-rotate.conf. The default is - unlike the mysql-sever-4.1 package which needed to stay backwards - compatible now 2 to avoid filling up the disk endlessly. - * Fixed watch file to be "-beta" aware. - - -- Christian Hammers Thu, 15 Sep 2005 20:50:19 +0200 - -mysql-dfsg-5.0 (5.0.12beta-1) unstable; urgency=medium - - * Christian Hammers: - - New upstream release. - - Changed build-dep to libreadline5-dev as requested by Matthias Klose. - Closes: #326316 - - Applied fix for changed output format of SHOW MASTER LOGS for - binary log rotation (thanks to Martin Krueger). Closes: #326427, #326427 - - Removed explicit setting of $PATH as I saw no sense in it and - it introduced a bug (thanks to Quim Calpe). Closes: #326769 - - Removed PID file creation from /etc/init.d/mysql-ndb as it does - not work with this daemon (thanks to Quim Calpe). - - Updated French Debconf translation (thanks to Christian Perrier). - Closes: #324805 - - Moved conflicts line in debian/control from libmysqlclient15 to - libmysqlclient15-dev and removed some pre-sarge conflicts as - suggested by Adam Majer. Closes: #324623 - * Sean Finney: - - For posterity, CAN-2005-2558 has been fixed since 5.0.7beta. - - -- Christian Hammers Thu, 15 Sep 2005 19:58:22 +0200 - -mysql-dfsg-5.0 (5.0.11beta-3) unstable; urgency=low - - * Temporarily build only with -O2 to circumvent gcc internal errors - (thanks to Matthias Klose). Related to: #321165 - - -- Christian Hammers Thu, 18 Aug 2005 15:44:04 +0200 - -mysql-dfsg-5.0 (5.0.11beta-2) unstable; urgency=low - - * Fixed README.Debian regarding the status of mysql-doc. - * Added "set +e" around chgrp in mysql-server-5.0.preinst to - not fail on .journal files (thanks to Christophe Nowicki). - Closes: #318435 - - -- Christian Hammers Sun, 14 Aug 2005 18:02:08 +0200 - -mysql-dfsg-5.0 (5.0.11beta-1) unstable; urgency=low - - * New upstream version. - * Added Danish Debconf translations (thanks to Claus Hindsgaul). - Closes: #322384 - * Updated Czech Debconf translations (thanks to Miroslav Kure). - Closes: #321765 - - -- Christian Hammers Sat, 13 Aug 2005 11:56:15 +0000 - -mysql-dfsg-5.0 (5.0.10beta-1) unstable; urgency=low - - * New upstream release. - * Christian Hammers: - - Added check for mounted /proc to debian/rules. - * Sean Finney: - - fix for fix_mysql_privilege_tables/mysql_fix_privilege_tables typo - in mysql-server-5.0's README.Debian (see #319838). - - -- Christian Hammers Sun, 31 Jul 2005 00:30:45 +0200 - -mysql-dfsg-5.0 (5.0.7beta-1) unstable; urgency=low - - * Second try for new upstream release. - * Renamed mysql-common-5.0 to mysql-common as future libmysqlclient16 - from e.g. MySQL-5.1 would else introduce mysql-common-5.1 which makes - a simultanous installation of libmysqlclient14 impossible as that - depends on either mysql-common or mysql-common-5.0 but not on future - versions. Thus we decided to always let the newest MySQL version - provide mysql-common. - * Added ${misc:Depends} as suggested by debhelper manpage. - * Raised standard in control file to 3.6.2. - * Removed DH_COMPAT from rules in faviour of debian/compat. - * Checkes for presence of init script before executing it in preinst. - Referres: 315959 - * Added 60_includes_mysys.h__gcc40.dpatch for GCC-4.0 compatibility. - - -- Christian Hammers Wed, 29 Jun 2005 00:39:05 +0200 - -mysql-dfsg-5.0 (5.0.5beta-1) unstable; urgency=low - - * New major release! Still beta so be carefull... - * Added federated storage engine. - - -- Christian Hammers Wed, 8 Jun 2005 19:29:45 +0200 - -mysql-dfsg-4.1 (4.1.12-1) unstable; urgency=low - - * Christian Hammers: - - New upstream release. - - Disabled BerkeleyDB finally. It has been obsoleted by InnoDB. - * Sean Finney: - - Updated French translation from Christian Perrier (Closes: #310526). - - Updated Japanese translation from Hideki Yamane (Closes: #310263). - - Updated Russian translation from Yuriy Talakan (Closes: #310197). - - -- Christian Hammers Sat, 4 Jun 2005 05:49:11 +0200 - -mysql-dfsg-4.1 (4.1.11a-4) unstable; urgency=high - - * Fixed FTBFS problem which was caused due to the fact that last uploads - BerkeleyDB patch was tried to applied on all architectures and not only - on those where BerkeleyDB is actually beeing built. Closes: #310296 - - -- Christian Hammers Mon, 23 May 2005 00:54:51 +0200 - -mysql-dfsg-4.1 (4.1.11a-3) unstable; urgency=high - - * Added patch from Piotr Roszatycki to compile the bundled db3 library - that is needed for the BerkeleyDB support with versioned symbols so - that mysqld no longer crashes when it gets linked together with the - Debian db3 version which happens when e.g. using libnss-db. - Closes: #308966 - - -- Christian Hammers Thu, 19 May 2005 01:41:14 +0200 - -mysql-dfsg-4.1 (4.1.11a-2) unstable; urgency=high - - * Okay, the hackery with /var/lib/dpkg/info/mysql-server.list will not - stand and is removed from the preinst of mysql-server. - * New workaround for the symlink problem that does not involve mucking - with dpkg's file lists is storing the symlinks in a temporary location - across upgrades. - As this sometimes fails since apt-get does not always call new.preinst - before old.postrm, some remarks were added to README.Debian and the - Debconf installation notes to minimize the inconvinience this causes. - - -- sean finney Sun, 15 May 2005 10:25:31 -0400 - -mysql-dfsg-4.1 (4.1.11a-1) unstable; urgency=high - - * Added the "a" to the version number to be able to upload a new - .orig.tar.gz file which now has the non-free Docs/ directory removed - as this has been forgotten in the 4.1.11 release (thanks to Goeran - Weinholt). Closes: #308691 - * The Woody package listed /var/lib/mysql and /var/log/mysql in its - /var/lib/dpkg/info/mysql-server.list. These directories are often - replaced by symlinks to data partitions which triggers a dpkg bug - that causes these symlinks to be removed on upgrades. The new preinst - prevents this by removing the two lines from the .list file - (thanks to Andreas Barth and Jamin W. Collins). See dpkg bug #287978. - * Updated French Debconf translation (thanks to Christian Perrier). - Closes: #308353 - - -- Christian Hammers Thu, 12 May 2005 21:52:46 +0200 - -mysql-dfsg-4.1 (4.1.11-3) unstable; urgency=high - - * The "do you want to remove /var/lib/mysql when purging the package" flag - from old versions is removed once this package is beeing installed so - that purging an old Woody mysql-server package while having a - mysql-server-4.1 package installed can no longer lead to the removal of - all databases. Additionaly clarified the wording of this versions Debconf - template and added a check that skips this purge in the postrm script - if another mysql-server* package has /usr/sbin/mysqld installed. - (thanks to Adrian Bunk for spotting that problem) Closes: #307473 - * Cronfile was not beeing installed as the filename was not in the - correct format for "dh_installcron --name" (thanks to Tomislav - Gountchev). Closes: #302712 - - -- Christian Hammers Sat, 23 Apr 2005 22:55:15 +0200 - -mysql-dfsg-4.1 (4.1.11-2) unstable; urgency=low - - * Sean Finney: - - don't freak out if we can't remove /etc/mysql during purge. - - debian/rules clean works again. - * Christian Hammers: - - Fixed typo in README.Debian (thanks to Joerg Rieger). Closes: #304897 - - Completely removed the passwordless test user as it was not only - insecure but also lead to irritations as MySQL checks first the - permissions of this user and then those of a password having one. - See bug report from Hilko Bengen for details. Closes: #301741 - - -- Christian Hammers Sat, 16 Apr 2005 15:55:00 +0200 - -mysql-dfsg-4.1 (4.1.11-1) unstable; urgency=low - - * New upstream version. - * Upstream fix for charset/collation problem. Closes: #282256 - * Upstream fix for subselect crash. Closes: #297687 - * Corrected minor issue in Debconf template regarding skip-networking - (thanks to Isaac Clerencia). Closes: #303417 - * Made dependency to gawk unnecessary (thanks to Zoran Dzelajlija). - Closes: #302284 - * Removed obsolete 50_innodb_mixlen.dpatch. - * Removed obsolete 51_CAN-2004-0957_db_grant_underscore.dpatch. - - -- Christian Hammers Fri, 8 Apr 2005 00:23:53 +0200 - -mysql-dfsg-4.1 (4.1.10a-7) unstable; urgency=low - - * Sean Finney: - - fix for the mysteriously disappeared cronjob. thanks to - Peter Palfrader for pointing out this omission. - (closes: #302712). - - -- sean finney Sat, 02 Apr 2005 16:54:13 -0500 - -mysql-dfsg-4.1 (4.1.10a-6) unstable; urgency=high - - * Sean Finney: - - the previous upload did not completely address the issue. this one - should do so. d'oh. - - -- sean finney Thu, 31 Mar 2005 03:35:50 +0000 - -mysql-dfsg-4.1 (4.1.10a-5) unstable; urgency=high - - * Sean Finney: - - the following security issue is addressed in this upload: - CAN-2004-0957 (grant privilege escalation on tables with underscores) - thanks to sergei at mysql for all his help with this. - - -- sean finney Wed, 30 Mar 2005 21:19:26 -0500 - -mysql-dfsg-4.1 (4.1.10a-4) unstable; urgency=low - - * Sean Finney: - - FTBFS fix for amd64/gcc-4.0. Thanks to Andreas Jochens - for reporting this (closes: #301807). - - ANSI-compatible quoting fix in daily cron job. thanks to - Karl Hammar for pointing out the problem in - the 4.0 branch. - - Added myself as a co-maintainer in the control file (closes: #295312). - - -- sean finney Tue, 29 Mar 2005 18:54:42 -0500 - -mysql-dfsg-4.1 (4.1.10a-3) unstable; urgency=low - - * BerkeleyDB is now disabled by default as its use is discouraged by MySQL. - * Added embedded server libraries as they finally do compile. - They are currently in libmysqlclient-dev as they are still - experimental and only available as .a library (thanks to Keith Packard). - Closes: #297062 - * Fixed obsolete "tail" syntax (thanks to Sven Mueller). Closes: #301413 - * Added CAN numbers for the latest security bugfix upload. - * Updated manpage of mysqlmanager (thanks to Justin Pryzby). Closes: #299844 - * Added comments to default configuration. - - -- Christian Hammers Sun, 20 Mar 2005 17:40:18 +0100 - -mysql-dfsg-4.1 (4.1.10a-2) unstable; urgency=low - - * Disabled "--with-mysqld-ldflags=-all-static" as it causes sig11 crashes - if LDAP is used for groups in /etc/nsswitch.conf. Confirmed by Sean Finney - and Daniel Dehennin. Closes: #299382 - - -- Christian Hammers Mon, 14 Mar 2005 03:01:03 +0100 - -mysql-dfsg-4.1 (4.1.10a-1) unstable; urgency=high - - * SECURITY: - - The following security related updates are addressed: - CAN-2005-0711 (temporary file creation with "CREATE TEMPORARY TABLE") - CAN-2005-0709 (arbitrary library injection in udf_init()) - CAN-2005-0710 (arbitrary code execution via "CREATE FUNCTION") - Closes: #299029, #299031, #299065 - * New Upstream Release. - - Fixes some server crash conditions. - - Upstream includes fix for TMPDIR overriding my.cnf tmpdir setting - Closes: #294347 - - Fixes InnoDB error message. Closes: #298875 - - Fixes resouce limiting. Closes: #285044 - * Improved checking whether or not the server is alive in the init script - which should make it possible to run several mysqld instances in - different chroot environments. Closes: #297772 - * Fixed cron script name as dots are not allowed (thanks to Michel - v/d Ven). Closes: #298447 - * Added -O3 and --with-mysqld-ldflags=-all-static as MySQL recommends to - build the server binary statically in order to gain about 13% more - performance (thanks to Marcin Kowalski). - * Added patch to let mysqld_safe react to signals (thanks to Erich - Schubert). Closes: #208364 - * (Thanks to Sean Finney for doing a great share of work for this release!) - - -- Christian Hammers Thu, 3 Mar 2005 02:36:39 +0100 - -mysql-dfsg-4.1 (4.1.10-4) unstable; urgency=medium - - * Fixed bug that prevented MySQL from starting after upgrades. - Closes: #297198, #296403 - * Added comment about logging to syslog to the default my.cnf - and the logrotate script (thanks to Ryszard Lach). Closes: #295507 - - -- Christian Hammers Thu, 3 Mar 2005 00:28:02 +0100 - -mysql-dfsg-4.1 (4.1.10-3) unstable; urgency=low - - * Sean Finney: Cronjobs now exit silently when the server package - has been removed but not purged (thanks to Vineet Kumar). - Closes: #297404 - * Fixed comments of /etc/mysql/debian-log-rotate.conf (thanks to - Philip Ross). Closes: #297467 - * Made mysqld_safe reacting sane on signals (thanks to Erich Schubert). - Closes: #208364 - - -- Christian Hammers Tue, 1 Mar 2005 19:44:34 +0100 - -mysql-dfsg-4.1 (4.1.10-2) unstable; urgency=low - - * Converted to dpatch. - * debian/ is now maintained via Subversion on svn.debian.org. - - -- Christian Hammers Tue, 1 Mar 2005 02:16:36 +0100 - -mysql-dfsg-4.1 (4.1.10-1) unstable; urgency=low - - * New upstream version. - * Upstream fixed memleak bug. Closes: #205587 - * Added debian/copyright.more for personal reference. - * Lowered default query cache size as suggested by Arjen from MySQL. - * Switched from log to log-bin as suggested by Arjen from MySQL. - * Fixed typo in my.cnf (thanks to Sebastian Feltel). Closes: #295247 - * Replaced --defaults-extra-file by --defaults-file in Debian scripts - as former lets password/host etc be overwriteable by /root/.my.cnf. - Added socket to /etc/mysql/debian.cnf to let it work. (thanks to - SATOH Fumiyasu). Closes: #295170 - - -- Christian Hammers Tue, 15 Feb 2005 23:47:02 +0100 - -mysql-dfsg-4.1 (4.1.9-4) unstable; urgency=low - - * Improved the way mysqld is started and registered with update-rc.d - in cases where the admin modifies the runlevel configuration. - Most notably removed the debconf question whether or not mysql should - start on when booting. Closes: #274264 - * Renamed configuration option old-passwords to the more preferred - naming convention old_passwords. Same for some others (thanks to - Patrice Pawlak). Closes: #293983 - - -- Christian Hammers Tue, 8 Feb 2005 02:21:18 +0100 - -mysql-dfsg-4.1 (4.1.9-3) unstable; urgency=low - - * Renamed ca_ES.po to ca.po to reach a broader audience (thanks to - Christian Perrier). Closes: #293786 - * Expicitly disabled mysqlfs support as it has never been enabled by - configure during the autodetection but fails due to broken upstream - code when users try to build the package theirselves while having - liborbit-dev installed which triggers the mysqlfs autodetection - (thanks to Max Kellermann). Closes: #293431 - * Added dependencies to gawk as one script does not work with original-awk - (thanks to Petr Ferschmann). Closes: #291634 - - -- Christian Hammers Sun, 6 Feb 2005 23:33:11 +0100 - -mysql-dfsg-4.1 (4.1.9-2) unstable; urgency=high - - * SECURITY: - For historical reasons /usr/share/mysql/ was owned and writable by - the user "mysql". This is a security problem as some scripts that - are run by root are in this directory and could be modified and used - by a malicious user who already has mysql privileges to gain full root - rights (thanks to Matt Brubeck). Closes: #293345 - * Changed "skip-networking" to "bind-address 127.0.0.1" which is more - compatible and not less secure but maybe even more, as less people enable - networking for all interfaces (thanks to Arjen Lentz). - * Enabled InnoDB by default as recommended by Arjen Lentz from MySQL. - * Added remarks about hosts.allow to README.Debian (thanks to David - Chappell). Closes: #291300 - * mysql-server-4.1 now provides mysql-server (thanks to Paul van den Berg). - Closes: #287735 - - -- Christian Hammers Wed, 2 Feb 2005 23:31:55 +0100 - -mysql-dfsg-4.1 (4.1.9-1) unstable; urgency=low - - * New upstream version. - * mysql-client-4.1 now provides "mysql-client" so that packages depending - on mysql-client (ca. 40) can now be used with MySQL-4.1, too. - - -- Christian Hammers Sun, 23 Jan 2005 22:52:48 +0100 - -mysql-dfsg-4.1 (4.1.8a-6) unstable; urgency=high - - * SECURITY: - Javier Fernandez-Sanguino Pena from the Debian Security Audit Project - discovered a temporary file vulnerability in the mysqlaccess script of - MySQL that could allow an unprivileged user to let root overwrite - arbitrary files via a symlink attack and could also could unveil the - contents of a temporary file which might contain sensitive information. - (CAN-2005-0004, http://lists.mysql.com/internals/20600) Closes: #291122 - - -- Christian Hammers Tue, 18 Jan 2005 23:11:48 +0100 - -mysql-dfsg-4.1 (4.1.8a-5) unstable; urgency=medium - - * Fixed important upstream bug that causes from_unixtime(0) to return - NULL instead of "1970-01-01 00:00:00" which fails on NOT NULL columns. - Closes: #287792 - * Fixes upstream bug in mysql_list_fields() . Closes: #282486 - * Fixes bug that lead to double rotated logfiles when mysql-server 4.0 - was previously installed (thanks to Olaf van der Spek). Closes: #289851 - * Fixed typo in README.Debian (thanks to Mark Nipper). Closes: #289131 - * Changed max_allowed_packet in my.cnf to 16M as in 4.0.x (thanks to - Olaf van der Spek). Closes: #289840 - * Updated French debconf translation (thanks to Christian Perrier). - Closes: #287955 - - -- Christian Hammers Thu, 13 Jan 2005 01:29:05 +0100 - -mysql-dfsg-4.1 (4.1.8a-4) unstable; urgency=low - - * Broken patch again :-( - - -- Christian Hammers Sun, 9 Jan 2005 23:47:55 +0100 - -mysql-dfsg-4.1 (4.1.8a-3) unstable; urgency=low - - * The mutex patch was a bit too x86 centric. This broke the alpha build. - - -- Christian Hammers Sun, 9 Jan 2005 14:18:49 +0100 - -mysql-dfsg-4.1 (4.1.8a-2) unstable; urgency=medium - - * Some Makefiles that were patched by me got overwritten by the GNU - autotools, probably because I also patched ./configure. Fixed now, - the critical mutex patch is now back in again. Closes: #286961 - * Added patch to make MySQL compile on ARM (thanks to Adam Majer). - Closes: #285071 - - -- Christian Hammers Thu, 6 Jan 2005 09:30:13 +0100 - -mysql-dfsg-4.1 (4.1.8a-1) unstable; urgency=medium - - * Upstream 4.1.8 had some problems in their GNU Autotools files so they - released 4.1.8a. Debian's 4.1.8 was fixed by running autoreconf but this - again overwrote MySQL changes to ltmain.sh which are supposed to fix some - problems on uncommon architectures (maybe the FTBFS on alpha, arm, m68k - and sparc?). - * libmysqlclient_r.so.14 from 4.1.8-3 also missed a link dependency to - libz which lead to unresolved symbols visible with "ldd -r" (thanks - to Laurent Bonnaud). Closes: #287573 - - -- Christian Hammers Wed, 29 Dec 2004 14:26:33 +0100 - -mysql-dfsg-4.1 (4.1.8-3) unstable; urgency=low - - * Fixed checking for error messages by forcing english language - output by adding LC_ALL=C to debian-start (thanks to Rene - Konasz) Closes: #285709 - * Fixed bashisms in Debian scripts. Closes: #286863 - * Updated Japanese Debconf translation (thanks to Hideki Yamane). - Closes: #287003 - * Improved 4.0 to 4.1 upgrade if /var/lib/mysql is a symlink - (thanks to Thomas Lamy). Closes: #286560 - * Added patch for FTBFS problem where no LinuxThreads can be found. - I don't know if this still applies but it should not hurt. - The patch is debian/patches/configure__AMD64-LinuxThreads-vs-NPTL.diff - - -- Christian Hammers Sun, 26 Dec 2004 14:04:20 +0100 - -mysql-dfsg-4.1 (4.1.8-2) unstable; urgency=low - - * If /var/lib/mysql is a symlink then it is kept as such. - * Added the old-passwords option to the default my.cnf to stay - compatible to clients that are still compiled to libmysqlclient10 - and libmysqlclient12 for licence reasons. - * Adjusted tetex build-deps to ease backporting (thanks to Norbert - Tretkowski from backports.org). - - -- Christian Hammers Tue, 21 Dec 2004 01:00:27 +0100 - -mysql-dfsg-4.1 (4.1.8-1) unstable; urgency=medium - - * New upstream version. Closes: #286175 - * Added conflict to libmysqlclient-dev (thanks to Adam Majer). - Closes: #286538 - * Added debconf-updatepo to debian/rules:clean. - * Updated Japanese Debconf translation (thanks to Hideki Yamane). - Closes: #285107 - * Updated French Debconf translation (thanks to Christian Perrier). - Closes: #285977 - * Renamed cz.po to cs.po (thanks to Miroslav Kure). Closes: #285438 - * Aplied patch for changed server notice to debian-start (thanks to - Adam Majer). Closes: #286035 - * Changed nice value in default my.cnf as nohup changed its behaviour - (thanks to Dariush Pietrzak). Closes: #285446 - * Increased verbosity of preinst script in cases where it cannot stop - a running server (thanks to Jan Minar). Closes: #285982 - * Splitted the code parts of /etc/mysql/debian-start to - /usr/share/mysql/debian-start.inc.sh (thanks to Jan Minar). - Closes: #285988 - - -- Christian Hammers Mon, 20 Dec 2004 00:33:21 +0100 - -mysql-dfsg-4.1 (4.1.7-4) unstable; urgency=medium - - * Removed OpenSSL support. - After a short discussion with MySQL, I decided to drop OpenSSL support as - 1. MySQL started shipping their binaries without it, too and do not - seem to support it in favour of using a different library somewhen. - 2. MySQL did not adjust their licence to grant permission to link - against OpenSSL. - 3. Even if they did, third parties who use libmysqlclient.so often - do not realise licencing problems or even do not want OpenSSL. - (thanks to Jordi Mallach and the responders to MySQL bug #6924) - Closes: #283786 - * debian/control: Improved depends and conflicts to mysql-4.0. - - -- Christian Hammers Thu, 2 Dec 2004 22:02:28 +0100 - -mysql-dfsg-4.1 (4.1.7-3) unstable; urgency=low - - * Raised version to make it higher as the one in experimental. - - -- Christian Hammers Wed, 1 Dec 2004 21:09:20 +0100 - -mysql-dfsg-4.1 (4.1.7-2) unstable; urgency=low - - * Patched scripts/mysql_install_db so that it no longer creates a - passwordless test database during installation (thanks to Patrick - Schnorbus). Closes: #281158 - * Added Czech debconf translation (thanks to Miroslav Kure). - Closes: #283222 - - -- Christian Hammers Wed, 1 Dec 2004 01:29:31 +0100 - -mysql-dfsg-4.1 (4.1.7-1) unstable; urgency=low - - * New upstream branch! - * Adjusted debian/control to make this package suitable to get parallel - to version 4.0.x into unstable and sarge. The package names are - different so that "mysql-server" still defaults to the rock-stable - 4.0 instead to this announced-to-be-stable 4.1. - * Added --with-mutex=i86/gcc-assemler to the Berkeley-DB configure - to prevent the use of NPLT threads when compiling under kernel 2.6 - because the binaries are else not runable on kernel 2.4 hosts. - Closes: #278638, #274598 - - -- Christian Hammers Sun, 31 Oct 2004 20:15:03 +0100 - -mysql-dfsg (4.1.6-1) experimental; urgency=low - - * New upstream version. - * Fixed symlinks in libmysqlclient-dev package. Closes: #277028 - * This time I did not update the libtool files as they were pretty - up to date and I want to have a shorter diff file. - - -- Christian Hammers Wed, 20 Oct 2004 00:07:58 +0200 - -mysql-dfsg (4.1.5-3) experimental; urgency=low - - * debian/postinst: mysql_install_db changed parameter from --IN-RPM - to --rpm which caused problems during installs. Closes: #276320 - - -- Christian Hammers Sat, 16 Oct 2004 20:36:46 +0200 - -mysql-dfsg (4.1.5-2) experimental; urgency=low - - * Activated support for ndb clustering (thanks to Kevin M. Rosenberg). - Closes: #275109 - - -- Christian Hammers Wed, 6 Oct 2004 01:58:00 +0200 - -mysql-dfsg (4.1.5-1) experimental; urgency=low - - * WARNING: - The upstream branch 4.1 is still considered BETA. - The Debian packages for 4.1 were done without big testing. If you miss - a new functionality or binary, contact me and I check add the relevant - configure option or include the program. - * New MAJOR upstream version. - Thanks to the great demand here's now the first MySQL 4.1 experimental - release. FEEDBACK IS WELCOME. - * 4.0->4.1 notes: - - debian/patches/alpha.diff could not be applied, I fix that later - - debian/patches/scripts__mysql_install_db.sh.diff was obsolete - - debian/patches/scripts__Makefile.in was neccessary due to a dependency - to the removed non-free Docs/ directory. Upstream has been contacted. - - Build-Deps: += automake1.7 - - debian/rules: embedded servers examples did not compile, removed - - -- Christian Hammers Sun, 26 Sep 2004 19:46:47 +0200 - -mysql-dfsg (4.0.21-3) unstable; urgency=low - - * Upstream tried to fix a security bug in mysqlhotcopy and broke it :-) - Applied a patch (see debian/patches) from Martin Pitt. Closes: #271632 - * Between 4.0.20 and 4.0.21 the Debian specific changes in - /usr/bin/mysqld_safe that piped the error log to syslog got lost - and are now back again. - * Fixed capitalization in debconf headings. - * Changed wording of the initscript status message to make heartbeat - happier. Closes: #271591 - - -- Christian Hammers Fri, 17 Sep 2004 18:42:25 +0200 - -mysql-dfsg (4.0.21-2) unstable; urgency=medium - - * The dependencies between mysql-client and libmysqlclient12 were - too loose, when upgrading only the client this can lead to non working - binaries due to relocation errors (thanks to Dominic Cleal). - Closes: #271803 - * Fixed typo in mysqldump.1 manpage (thanks to Nicolas Francois). - Closes: #271334 - - -- Christian Hammers Wed, 15 Sep 2004 15:38:11 +0200 - -mysql-dfsg (4.0.21-1) unstable; urgency=high - - * SECURITY: - This upstream version fixes some security problems that might at least - allow a DoS attack on the server. - * Fixed an old bug in concurrent accesses to `MERGE' tables (even - one `MERGE' table and `MyISAM' tables), that could've resulted in - a crash or hang of the server. (Bug #2408) - * Fixed bug in privilege checking where, under some conditions, one - was able to grant privileges on the database, he has no privileges - on. (Bug #3933) - * Fixed crash in `MATCH ... AGAINST()' on a phrase search operator - with a missing closing double quote. (Bug #3870) - * Fixed potential memory overrun in `mysql_real_connect()' (which - required a compromised DNS server and certain operating systems). - (Bug #4017) - * New upstream version. - * Fixes bug that made x="foo" in WHERE sometimes the same as x="foo ". - Closes: #211618 - * Updated Japanese Debconf translation (thanks to Hideki Yamane). - Closes: #271097 - - -- Christian Hammers Sat, 11 Sep 2004 23:15:44 +0200 - -mysql-dfsg (4.0.20-14) unstable; urgency=low - - * Dave Rolsky spottet that -DBIG_JOINS was not properly enabled. - It allowes joining 64 instead of an 32 tables to join. - - -- Christian Hammers Thu, 9 Sep 2004 20:24:02 +0200 - -mysql-dfsg (4.0.20-13) unstable; urgency=medium - - * Fixed a bug in the initscript which caused the check for not properly - closed i.e. corrupt tables that is executed when the server starts - not to run in background as supposed. - Although the check does not repair anything on servers with several - thousand tables the script was reported to take some minutes which - is quite annoying. (Thanks to Jakob Goldbach). Closes: #270800 - - -- Christian Hammers Thu, 9 Sep 2004 17:11:05 +0200 - -mysql-dfsg (4.0.20-12) unstable; urgency=medium - - * Filter messages regarding table handles that do not support CHECK TABLE - in the script that checks for corrupted tables on every start which lead - to unnecessary mails (thanks to David Everly). Closes: #269811 - * Added a note to the corrupt-table-check mail which notes that a - false-positive is reported in the case that immediately after starting - the server a client starts using a table (thanks to Uwe Kappe). - Closes: #269985 - * Added "quote-names" as default to the [mysqldump] section in - /etc/mysql/my.cnf as too many users stumble over dump files that - could not be read in again due to the valid use of reserved words - as table names. This has also be done by upstream in 4.1.1 and has - no known drawbacks. Closes: #269865 - * Binary logs can now be rotated as well. Defaults to off, though, for - compatibilty reasons (thanks to Mark Ferlatte). Closes: #94230, #269110 - * The mysql user "debian-sys-maint" now gets all possible rights which - makes binary logging possible and helps other package maintainer who - wants to use it to create package specific databases and users. - * Added example how to change daemon nice level via /etc/mysql/my.cnf - * Updated French debconf translations (thanks to Christian Perrier). - Closes: #265811 - * Renamed options in the default config file that still had old names - (thanks to Yves Kreis). Closes: #266445 - * Fixed spelling in debconf note. - * Added -l and -L to dh_shlibdeps. - - -- Christian Hammers Fri, 3 Sep 2004 20:10:46 +0200 - -mysql-dfsg (4.0.20-11) unstable; urgency=high - - * SECURITY - This version fixes a security flaw in mysqlhotcopy which created - temporary files in /tmp which had predictable filenames and such - could be used for a tempfile run attack. - The issue has been recorded as CAN-2004-0457. - - -- Christian Hammers Sat, 14 Aug 2004 18:27:19 +0200 - -mysql-dfsg (4.0.20-10) unstable; urgency=low - - * MySQL finally updated their copyright page and installed v1.5 of - the "Free/Libre and Open Source Software License (FLOSS) - Exception" - which will hopefully end the license hell they created by putting the - client libraries under GPL instead of LGPL which conflicts with PHP and - other software that used to link against MySQL. - The license text is not yet in any release MySQL version but visible - on their web site and copied into the debian/copyright file. - Special thanks to Zak Greant and the debian-legal list - for helping to solve this release critical problem. - Closes: #242449 - * Updated Brazil debconf translation (thanks to Andre Luis Lopes). - Closes: #264233 - * Updated Japanese debconf translation (thanks to Hideki Yamane). - Closes: #264620 - * Fixed minor typo in debconf description (thanks to TROJETTE Mohammed - Adnene). Closes: #264840 - * Improved init and preinst script which now detects stalled servers which - do no longer communicate but are present in the process list (thanks to - Henrik Johansson). Closes: #263215 - - -- Christian Hammers Mon, 9 Aug 2004 19:44:28 +0200 - -mysql-dfsg (4.0.20-9) unstable; urgency=medium - - * Partly reverted the last patch which gave the mysql-user - "debian-sys-maint" more rights as there are old versions of MySQL which - have fewer privlige columns. Now only those are set (thanks to Alan Tam). - Closes: #263111 - - -- Christian Hammers Tue, 3 Aug 2004 13:03:02 +0200 - -mysql-dfsg (4.0.20-8) unstable; urgency=low - - * The mysqlcheck that is started from the initscript will now be - backgrounded because it might else prevent the boot process to continue. - It also now notifies root by mail and syslog if a table is corrupt. - * The "debian-sys-maint" MySQL user now has almost full rights so that other - packages might use this account to create databases and user (thanks to - Andreas Barth). Closes: #262541 - * Added paranoid rules for logcheck. - - -- Christian Hammers Sun, 1 Aug 2004 21:00:55 +0200 - -mysql-dfsg (4.0.20-8) unstable; urgency=low - - * Upload stalled. Not released. - - -- Christian Hammers Sun, 1 Aug 2004 20:27:55 +0200 - -mysql-dfsg (4.0.20-7) unstable; urgency=medium - - * Solved the upstream bug that error messages of the server are written - in a file that is then rotated away leaving mysqld logging effectively - to /dev/null. It now logs to a /usr/bin/logger process which puts the - messages into the syslog. - Modified files: /etc/init.d/mysql, /usr/bin/mysqld_safe and the - logchecker files. Closes: #254070 - * The initscript does no longer call mysqlcheck directly but via - /etc/mysql/debian-start which is a user customizable config script. - * Splitted the debconf "install and update notes" and only show them - when it is appropriate (thanks to Steve Langasek). Closes: #240515 - * Added NEWS.Debian. - * Added hint to -DBIG_ROWS, which is currently not used, to README.Debian. - * Corrected typo in myisampack manpage (thanks to Marc Lehmann). - Closes: #207090 - * Added Catalan debconf translation (thanks to Aleix Badia i Bosch). - Closes: #236651 - - -- Christian Hammers Wed, 28 Jul 2004 01:41:51 +0200 - -mysql-dfsg (4.0.20-6) unstable; urgency=low - - * The build arch detected by configure was "pc-linux-gnu (i686)" - instead of "pc-linux-gnu (i386)". Was no problem AFAIK but - Adam Majer asked me to explicitly change it to i386. Closes: #261382 - * Removed some unused shell scripts from /usr/share/mysql. - * Added lintian overrides. - * Removed rpath by using chrpath. - - -- Christian Hammers Mon, 26 Jul 2004 00:17:12 +0200 - -mysql-dfsg (4.0.20-5) unstable; urgency=medium - - * The mysqlcheck in the init script is only called when the server - is really alive. Also, the mysql-user 'debian-sys-maint' now has - global select rights (thanks to Nathan Poznick). Closes: #261130 - * Moved the debconf question whether to remove the databases or not - from mysql-server.config to mysql-server.postrm so that it shows - up on purge time and not months earlier (thanks to Wouter Verhelst). - Closes: #251838 - - -- Christian Hammers Fri, 23 Jul 2004 22:41:13 +0200 - -mysql-dfsg (4.0.20-4) unstable; urgency=low - - * Added a "mysqlcheck -A --fast" to the 'start' section of the - init script to help admins detect corrupt tables after a server crash. - Currently it exists with an error message but leaves the server - running. Feedback appreciated! - * Made postinst script more robust by calling db_stop earlier and - so prevent pipe-deadlocks. - * Fixed minor typos in initscript (thanks to "C.Y.M."). Closes: 259518 - * Added the undocumented "-DBIG_JOINS" that MySQL apparently uses in - their MAX binaries. It enables 62 instead of 30 tables in a "join". - (thanks to Dave Rolsky). Closes: #260843 - * Added a "df --portability /var/lib/mysql/." check to the preinst - script as users experienced hard to kill hanging mysqlds in such - a situation (thanks to Vaidas Pilkauskas). Closes: #260306 - - -- Christian Hammers Fri, 23 Jul 2004 00:51:32 +0200 - -mysql-dfsg (4.0.20-3) unstable; urgency=low - - * Improved tolerance if the init script has been deleted (thanks to - Leonid Shulov for spotting the problem). - * Minor wording changes to README.Debian generalizing /root/ by $HOME - (thanks to Santiago Vila). Closes: #257725 - * Added Japanese debconf translation (thanks to Hideki Yamane). - Closes: #256485 - * Fixed commend in my.cnf regarding logfile directory (thanks to Jayen - Ashar). Closes: #253434 - * Correted "ease to" by "ease of" in package description (thanks to - Johannes Berg). Closes: #253510 - - -- Christian Hammers Fri, 9 Jul 2004 00:57:42 +0200 - -mysql-dfsg (4.0.20-2) unstable; urgency=low - - * Removed RPM .spec file from the included documentation as it is pretty - useless (thanks to Loic Minier). - * Added turkish debconf translation (thanks to Recai Oktas). Closes: #252802 - - -- Christian Hammers Sun, 6 Jun 2004 14:48:26 +0200 - -mysql-dfsg (4.0.20-1) unstable; urgency=low - - * New upstream version. - - -- Christian Hammers Mon, 31 May 2004 23:36:39 +0200 - -mysql-dfsg (4.0.18-8) unstable; urgency=low - - * Updated french translation (thanks to Christian Perrier). Closes: #246789 - - -- Christian Hammers Tue, 4 May 2004 23:26:54 +0200 - -mysql-dfsg (4.0.18-7) unstable; urgency=low - - * Added CVE ids for the recent security fixes. - 4.0.18-4 is CAN-2004-0381 (mysqlbug) and - 4.0.18-6 is CAN-2004-0388 (mysql_multi) - - -- Christian Hammers Mon, 19 Apr 2004 18:32:03 +0200 - -mysql-dfsg (4.0.18-6) unstable; urgency=medium - - * SECURITY: - Fixed minor tempfile-run security problem in mysqld_multi. - Unprivileged users could create symlinks to files which were then - unknowingly overwritten by run when this script gets executed. - Upstream informed. Thanks to Martin Schulze for finding this. - - -- Christian Hammers Wed, 7 Apr 2004 01:28:22 +0200 - -mysql-dfsg (4.0.18-5) unstable; urgency=low - - * Little improvements in debian scripts for last upload. - * Added check to logrotate script for the case that a mysql - server is running but not be accessible with the username and - password from /etc/mysql/debian.conf (thanks to Jeffrey W. Baker). - Closes: 239421 - - -- Christian Hammers Sun, 4 Apr 2004 15:27:40 +0200 - -mysql-dfsg (4.0.18-4) unstable; urgency=medium - - * SECURITY: - Aplied fix for unprobable tempfile-symlink security problem in - mysqlbug reported by Shaun Colley on bugtraq on 2004-03-24. - * Updated french debconf translation (thanks to Christian Perrier). - Closes: #236878 - * Updated portugesian debconf translation (thanks to Nuno Senica). - Closes: #239168 - * Updated german debconf translation (thanks to Alwin Meschede). - Closes: #241749 - * Improved debconf template regarding fix_privileges_tables (thanks - to Matt Zimmermann for suggestions). Closes: #219400 - * Improved README.Debian regarding to password settings (thanks to - Yann Dirson). Closes: #241328 - - -- Christian Hammers Sat, 3 Apr 2004 19:52:15 +0200 - -mysql-dfsg (4.0.18-3) unstable; urgency=medium - - * Added Build-Depend to po-debconf to let it build everywhere. - - -- Christian Hammers Wed, 31 Mar 2004 23:43:33 +0200 - -mysql-dfsg (4.0.18-2) unstable; urgency=low - - * Added a "2>/dev/null" to a "which" command as there are two - "which" versions in Debian of which one needs it. Closes: #235363 - - -- Christian Hammers Tue, 2 Mar 2004 23:31:28 +0100 - -mysql-dfsg (4.0.18-1) unstable; urgency=low - - * New upstream version. - * Should now compile and run on ia64 (thanks to Thorsten Werner and - David Mosberger-Tang). Closes: #226863 #228834 - * Converted init scripts to invoce-rc.d (thanks to Erich Schubert). - Closes: 232118 - * Secondlast upload changed logfile location. Closes: #182655 - * Updated Brasilian translation (thanks to Andre Luis Lopes). Closes: - #219847 - - -- Christian Hammers Tue, 17 Feb 2004 23:44:58 +0100 - -mysql-dfsg (4.0.17-2) unstable; urgency=low - - * Improved manpage for mysqldumpslow.1 (thanks to Anthony DeRobertis). - Closes: #231039 - * Improved stopping of crashed daemons in init script (thanks to - Matthias Urlichs). Closes: #230327 - - -- Christian Hammers Mon, 9 Feb 2004 21:54:29 +0100 - -mysql-dfsg (4.0.17-1) unstable; urgency=low - - * Made logging into /var/log/mysql/ the default. Closes: #225206 - - * New upstream version. Closes: #225028 - * Turned on a 25MB query cache by default (thanks to Cyril Bouthors). - Closes: #226789 - * Updated russian translation (thanks to Ilgiz Kalmetev). Closes: #219263 - * Upstream fixes the problem that AND was not commutative (thanks for - Iain D Broadfoot for mentioning). Closes: #227927 - * Fixed minor typo in my.cnf comments (thanks to James Renken). - Closes: #221496 - * Better documents regex. Closes: #214952 - * Fixed minor germanism in debconf template (thanks to Marc Haber). - Closes: #224148 - * Added explaining comment to my.cnf regarding quoted passwords - (Thanks to Patrick von der Hagen). Closes: #224906 - * Changed "find -exec" to "find -print0 | xargs -0" in preinst to - speed it up. Thanks to Cyril Bouthors. Closes: #220229 - - -- Christian Hammers Sun, 18 Jan 2004 16:16:25 +0100 - -mysql-dfsg (4.0.16-2) unstable; urgency=low - - * Tried to repair undefined weak symbols by adding a little Makefile - patch. Closes: #215973 - - -- Christian Hammers Mon, 27 Oct 2003 22:52:10 +0100 - -mysql-dfsg (4.0.16-1) unstable; urgency=low - - * New upstream release. - (Mostly little memory problems and other bugfixes it seems) - * Replaced "." by ":" in chown calls to comply with the env setting - "_POSIX2_VERSION=2000112" (thanks to Robert Luberda). Closes: #217399 - * Adjusted syntax in my.cnf to 4.x standard (thanks to Guillaume Plessis). - Closes: #217273 - * Improved README.Debian password instructions (thanks to Levi Waldron). - Closes: #215046 - * Improved NIS warning debconf-template (thanks to Jeff Breidenbach). - Closes: #215791 - * Explicitly added libssl-dev to the libmysqlclient-dev package as it - is needed for mysql_config and the libmysqlclient package only depends - on libssl which has no unnumbered .so version (thanks to Simon Peter - and Davor Ocelic). Closes: #214436, #216162 - * Added "-lwrap" to "mysql_config --libmysqld-libs" and filed it as - upstream bug #1650 (thanks to Noah Levitt). Closes: #214636 - - -- Christian Hammers Sat, 25 Oct 2003 01:09:27 +0200 - -mysql-dfsg (4.0.15a-1) unstable; urgency=low - - * Same package as 4.0.15-2 but I could not convince the Debian - installer to move the packages out of incoming. - - -- Christian Hammers Tue, 7 Oct 2003 15:10:26 +0200 - -mysql-dfsg (4.0.15-2) unstable; urgency=low - - * Updated package description (thanks to Adrian Bunk). Closes: #210988 - * Fixed small typos in manpages (thanks to Nicolas Francois). - Closes: #211983 - * More updates to package description (thanks to Matthias Lutz/ddtp). - Closes: #213456 - * Updated standards to 3.6.1. - * Closes "new 4.0.15 available" bug. Closes: #213349 - * Updated README.Debian with notes regarding the MySQL manual section - "2.4 Post-installation Setup and Testing" (thanks to Daniel B.). - Closes: #210841 - - -- Christian Hammers Fri, 3 Oct 2003 15:59:39 +0200 - -mysql-dfsg (4.0.15-1) unstable; urgency=high - - * SECURITY: - Users who are able to use the "ALTER TABLE" command on the "mysql" - database may be able to exploit this vulnerability to gain a shell with - the privileges of the mysql server (usually running as the 'mysql' user). - Closes: #210403 - * Fixes small description typos (thanks to Oscar Jarkvik). - * Updated Brazilian Portuguese debconf translation. (thanks to Andre Luis - Lopes). Closes: 208030 - * Replaced depricated '.' by ':' in chown (thanks to Matt Zimmerman). - * Fixed manpage typo (thanks to Marc Lehmann). Closes: #207090 - - -- Christian Hammers Fri, 3 Oct 2003 15:59:35 +0200 - -mysql-dfsg (4.0.14-1) unstable; urgency=low - - * New upstream version. - - -- Christian Hammers Sun, 24 Aug 2003 16:40:36 +0200 - -mysql-dfsg (4.0.13-3) unstable; urgency=low - - * Now start mysqld as default unless you choose not when configurig - with debconf priority low. So packages depending on the server when - installing can access it. Thanks Matt Zimmermann (Closes: #200277) - * Made mysql-server de-installable if the config and database files were - removed by hand before. Thanks to Ard van Breemen (Closes: #200304) - - -- Christian Hammers Tue, 8 Jul 2003 22:30:40 +0200 - -mysql-dfsg (4.0.13-2) unstable; urgency=low - - * Added "nice" option for mysqld_safe to give mysqld a different priority. - Submitted to upstream as MySQL Bug #627. Closes: #192087 - * Fixed possible unbound variable in init script. Closes: #194621 - * Fixed french debconf translation (thx Christian Perrier) Closes: #194739 - * Get rid of automake1.5 (for Eric Dorland). - - -- Christian Hammers Wed, 11 Jun 2003 18:58:32 +0200 - -mysql-dfsg (4.0.13-1) unstable; urgency=medium - - * New upstream version. - !!! Fixes a very bad natural join bug which justifies the urgency=medium. - !!! http://bugs.mysql.com/bug.php?id=291 - * Fixed mysql_fix_privileges manpage (Frederic Briere) Closes: #191776 - * preinst: "which" is more chatty normal executable than as builtin. - (Thanks to David B Harris). Closes: #188659 - - -- Christian Hammers Tue, 6 May 2003 22:03:45 +0200 - -mysql-dfsg (4.0.12-3) unstable; urgency=medium - - * Reincluded new way of creating my debian-sys-maint user from - an old release from experimental. Now works again with old - and new privilege table format. (Thanks to Vincent Danjean - for spotting the problem) Closes: #188201 - * Reincluded hurd build dependency fix from 3.23 branch. - (Thanks to Robert Millan). Closes: #185929 - * Fixed soname in libmysqlclient-dev. Closes: #188160 - * Remove /var/log/mysql/ when purging the package. Closes: #188064 - * Removed /usr/share/doc/mysql/ from mysql-server. Closes: #188066 - * Let group "adm" be able to read logfiles. Closes: #188067 - * Do not call usermod on every upgrade. Closes: #188248 - (Thanks to Philippe Troin for the last three) - * Fixed mysql-server.preinst so that it works on shells where - which is a builtin, too. (Thanks to Erich Schubert) Closes: #181525 - - -- Christian Hammers Fri, 11 Apr 2003 11:32:45 +0200 - -mysql-dfsg (4.0.12-2) unstable; urgency=low - - * - * NEW MAJOR UPSTREAM RELEASE: - * - MySQL 4 has finally been declared as 'stable'. Hurray! Read changelogs. - Thanks to all testers, esp. Jose Luis Tallon, of the versions - that were in the "experimental" section before. - * Modified postinst script to run mysql_fix_privileges on every update. - IMPORTANT: Please report if this breaks anything, it is not supposed to. - * Wrote a SSL-MINI-HOWTO.txt! - * Added zlib1g-dev to libmysqlclient12-dev. Closes: 186656 - * Changed section of libmysqlclient12-dev to libdevel. - * Added even more selfwritten manpages. - * Fixed typos. - - -- Christian Hammers Sun, 6 Apr 2003 13:47:32 +0200 - -mysql-dfsg (4.0.10.gamma-1) experimental; urgency=low - - * New upstream version. - * They merged some of my patches from debian/patches. Whoa! - * This release should fix the error-logfile problem where mysqld - keeps the error.log open while logrotate removes it. - - -- Christian Hammers Wed, 12 Feb 2003 22:39:48 +0100 - -mysql-dfsg (4.0.9.gamma-1) experimental; urgency=low - - * New upstream version. - * Updated the GNU autoconf files to make building on MIPS work. - See bug #176829. - - -- Christian Hammers Wed, 29 Jan 2003 22:07:44 +0100 - -mysql-dfsg (4.0.8.gamma-1) experimental; urgency=low - - * New upstream release. - * Improved logging of init script. Closes: #174790 - * We have now libmysqlclient.so.12 instead of .11. - - -- Christian Hammers Thu, 9 Jan 2003 20:14:11 +0100 - -mysql-dfsg (4.0.7.gamma-1) experimental; urgency=high - - * SECURITY: This version fixes an upstream security release that is only - present in the 4.x branch which is currently only in the - experimental distribution and therefore will not get a DSA. - * New upstream release. - - -- Christian Hammers Sat, 28 Dec 2002 15:51:39 +0100 - -mysql-dfsg (4.0.6.gamma-2) experimental; urgency=low - - * Added --system to addgroup. Closes: #173866 - - -- Christian Hammers Sat, 21 Dec 2002 15:28:26 +0100 - -mysql-dfsg (4.0.6.gamma-1) experimental; urgency=low - - * New upstream version. Now Gamma! - * There are no longer changes to the .orig.tar.gz neccessary to make diff - happy. docs/ has still to be deleted, although, as it is non-free. - * Incorporated patches from unstable. - * Added mysqlmanager and a couple of other new scripts. - * Enabled libmysqld embedded server library. - * Enabled SSL and Virtual-IO support. - (CORBA based MySQL-FS seems to be not existing..) - - -- Christian Hammers Fri, 20 Dec 2002 22:30:51 +0100 - -mysql-dfsg (4.0.5a.beta-3) experimental; urgency=low - - * Modified postinst to work with old and new mysql.user table format - and fixed spelling typo in postinst. Thanks to Roger Aich. - * Updated config.{guess,sub} to make the mipsel porters happy. - Thanks to Ryan Murray. Closes: #173553 - - -- Christian Hammers Wed, 18 Dec 2002 15:56:34 +0100 - -mysql-dfsg (4.0.5a.beta-2) experimental; urgency=low - - * Upstream removed option "--skip-gemini". So did I. Closes: 173142 - - -- Christian Hammers Tue, 17 Dec 2002 10:35:49 +0100 - -mysql-dfsg (4.0.5a.beta-1) experimental; urgency=low - - * First 4.x experimental package due to continuous user requests :-) - Please test and report! - * upstream: safe_mysqld has been renamed to mysqld_safe - * upstream: new library soname version libmysqlclient.so.11 - * Renamed libmysqlclientXX-dev to libmysqlclient-dev as I don't plan to - support more than one development environment and this makes the - dependencies easier. - * FIXME: Skipped parts of the debian/patches/alpha patch as the global.h - is not existing. - * FIXME: How to get rid this? Old ltconfig patch already applied. - "lintian: binary-or-shlib-defines-rpath ./usr/bin/mysql /usr/lib/mysql" - - -- Christian Hammers Sun, 1 Dec 2002 18:32:32 +0100 - -mysql-dfsg (3.23.53-4) unstable; urgency=medium - - * Fixed errno.h problem. Closes: #168533, #168535 - - -- Christian Hammers Sun, 10 Nov 2002 18:32:08 +0100 - -mysql-dfsg (3.23.53-3) unstable; urgency=medium - - * Changed automake build-dep to unversioned automake1.4. Closes: #166391 - * Fixed description. Closes: #167270 - (Thanks to Soren Boll Overgaard) - - -- Christian Hammers Tue, 5 Nov 2002 01:25:01 +0100 - -mysql-dfsg (3.23.53-2) unstable; urgency=low - - * Reverted user creation in init scripts. Closes: #166432 - (Thanks to Birzan George Cristian) - - -- Christian Hammers Thu, 31 Oct 2002 15:36:25 +0100 - -mysql-dfsg (3.23.53-1) unstable; urgency=low - - * New upstream release. - - -- Christian Hammers Thu, 24 Oct 2002 23:04:16 +0200 - -mysql-dfsg (3.23.52-3) unstable; urgency=low - - * Substituted the first-install 'debian-sys-maint' user creation by - something ANSI SQL compliant. Closes: #163497 - (Thanks to Karl Hammar) - * Tightend dependency to debhelper (>= 4.0.12) to be sure that - debconf-utils gets installed, too, as I use dh_installdebconf. - * Fixed upstream manpage bug in mysqldump.1. Closes: #159779 - (Thanks to Colin Watson) - * Added comment about MIN_WORD_LEN to mysql-server.README.Debian - (Thanks to Philipp Dreimann) - * Added a dependency for zlib1g-dev to libmysqlclient10-dev. - (Thanks to Jordi Mallach) - - -- Christian Hammers Sun, 15 Sep 2002 17:14:44 +0200 - -mysql-dfsg (3.23.52-2) unstable; urgency=low - - * Fixed typo in preinst scripts. - * Removed bashism in init script. - * Fixed ambiguous debconf example. Closes: #158884 - - -- Christian Hammers Fri, 30 Aug 2002 00:51:29 +0200 - -mysql-dfsg (3.23.52-1) unstable; urgency=low - - * New upstream version. Closes: #157731 - * Clearified the meaning of the debian-sys-maint special user in the - README.Debian file. Closes: #153702 - * Wrote some words regarding the skip-networking in README.Debian. - Closes: #157038 - * Added dependency to passwd. - * Fixes typo and unnecessarily complication in is_mysql_alive(). - * Added check for /etc/mysql/my.cnf in init script. - - -- Christian Hammers Tue, 27 Aug 2002 01:53:32 +0200 - -mysql-dfsg (3.23.51-4) unstable; urgency=low - - * Added a compressed "nm mysqld" output to allow people to trace - core dumps with /usr/bin/resolve_stack_dump as suggested in the - INSTALL-SOURCE file. Thanks to atudor@labs.agilent.com for the hint. - - -- Christian Hammers Wed, 24 Jul 2002 20:44:55 +0200 - -mysql-dfsg (3.23.51-3) unstable; urgency=low - - * Corrected copyright file: the MySQL client library is licenced under - the LGPL-2 not the GPL. From version 4.x it actually will be GPL this - is why parts of http://www.mysql.com/ already say so. Closes: #153591 - * Corrected german translation. - Thanks to Roland Rosenfeld . Closes: #151903 - - -- Christian Hammers Thu, 11 Jul 2002 20:32:28 +0200 - -mysql-dfsg (3.23.51-2) unstable; urgency=low - - * Improved NIS tolerance in preinst script. - - -- Christian Hammers Sun, 7 Jul 2002 04:43:28 +0200 - -mysql-dfsg (3.23.51-1) unstable; urgency=medium - - * New upstream version. - * I applied a patch that fixes a binary imcompatibility in - the shared libary libmysqlclient.so.10 between 3.23.50 and - some versions earlier. Upstream has been contacted and asked - for clarification. Closes: #149952 - * Added support for NIS i.e. it shows a warning and fails if the - needed 'mysql' user does not exists but works if it does. - Closes: #143282, #147869 - * Substituted $0 in init scripts by something really weird so that - "./S20mysql restart" works now, too. (BTW: S20? install file-rc!!!) - Closes: #148658 - * Now postinst works even if /etc/init.d/mysql is removed. Closes: #151021 - * Decided to leave "set +x" in postinst but wrote comment. Closes: #151022 - - -- Christian Hammers Sun, 7 Jul 2002 04:43:25 +0200 - -mysql-dfsg (3.23.50-1) unstable; urgency=medium - - * New upstream version. - Fixes a very annoying and important bug that lets all mysql programs - including perl scripts etc. segfault when using the read_default_group() - function. 3.23.50 is currently a pre-release and expected to be released - next week. I plan to propose it for woody as soon as its stability has - been proven. The following bug reports are all regarding this issue. - Closes: #144960, #145322, #136798, #138143, - - -- Christian Hammers Sat, 18 May 2002 21:14:01 +0200 - -mysql-dfsg (3.23.49x-1) unstable; urgency=low - - * I had to split the package to seperate the manual as it is not GPL - like the rest of the software and docs but under a license that - e.g. forbids selling printed versions. - . - The upstream authors were contacted a while ago but did not like to - change the situation. - . - The names of the resulting packages have not changed as the manual - already was in a seperate mysql-doc package due to it's size. - The source packages are now splitted from one "mysql" to - "mysql-dfsg" in main and "mysql-nonfree" in non-free. - * No code change! - The "x" at the end of the version number ist just to be able to - upload a new source package. ("a" was already taken by upstream - for their binary upload correction) - - -- Christian Hammers Wed, 8 May 2002 02:01:41 +0200 - -mysql (3.23.49-8) unstable; urgency=low - - * Substituted $0 in init script to let e.g. "/etc# ./init.d/mysql restart" - works, too. Closes: #141555 - - -- Christian Hammers Sun, 7 Apr 2002 15:00:44 +0200 - -mysql (3.23.49-7) unstable; urgency=low - - * The Makefiles are totally broken for the --enable-local-infile - option. I now patched libmysql/libmysql.c#mysql_init() manually. - Closes: #138347 - - -- Christian Hammers Fri, 29 Mar 2002 23:55:15 +0100 - -mysql (3.23.49-6) unstable; urgency=low - - * Moved mysqlcheck from server to client package. Closes: #139799 - * Added manpage for mysqlhotcopy. Regarding: #87097 - * Added 'sharedscripts' directive to the logrotate script. - * Replaced grep by /usr/bin/getent to let the group/user checking work - on NIS/LDAP systems, too. Closes: #115677, #101529 - - -- Christian Hammers Fri, 22 Mar 2002 22:40:51 +0100 - -mysql (3.23.49-5) unstable; urgency=low - - * Added skip-innodb to default my.cnf. - * Enabled --enable-local-infile, it seems to be a new option that - defaults to disable a formerly enabled feaure. Closes: #137115 - - -- Christian Hammers Sat, 16 Mar 2002 00:29:10 +0100 - -mysql (3.23.49-4) unstable; urgency=medium - - * Recompiled against fixed libz. - - * Enabled --enable-local-infile, it seems to be a new option that - defaults to disable a formerly enabled feaure. Closes: #137115 - * Fixed README.compile_on_potato. Closes: #136529 - * Now a ext3 .jounal file in /var/lib/mysql does not prevent the - installation (happens when creating a jounal on an already mounted - partition). Closes: #137146 - - -- Christian Hammers Wed, 13 Mar 2002 13:34:24 +0100 - -mysql (3.23.49-3) unstable; urgency=low - - * Added Russian translation. Closes: #135846 - * Fixed installation of .info documents. Closes: #135030 - - -- Christian Hammers Wed, 27 Feb 2002 23:36:35 +0100 - -mysql (3.23.49-2) unstable; urgency=low - - * Updated french translation and split template files. Closes: #134754 - * Fixed a small debian.cnf related bug in mysql-server.postinst. - - -- Christian Hammers Tue, 19 Feb 2002 23:13:58 +0100 - -mysql (3.23.49-1) unstable; urgency=low - - * New upstream release. - (Mainly InnoDB related fixes) - * Exported a $HOME variable in the scripts so that /root/.my.cnf - is not read anymore. This will avoid problems when admins put - only passwords but no usernames in this file. Closes: #132048 - * New debian-sys-maint password algorithm (now ~96bit :-)) Closes: #133863 - * Recreating debian-sys-main pwd on every install to help people who - accidently delete user or password files... - * Added /var/log/mysql so that user can put the binary logs in there as - mysql cannot write the .001 etc files itself in /var/log which is - owned by root. - - -- Christian Hammers Thu, 14 Feb 2002 22:17:45 +0100 - -mysql (3.23.47-6) unstable; urgency=low - - * Dropped a sentence about the new debian-sys-maint user in the - debconf note and updated the README.Debian. Related: #132048 - * Added more french translation. Closes: #132390 - - -- Christian Hammers Wed, 6 Feb 2002 09:41:29 +0100 - -mysql (3.23.47-5) unstable; urgency=low - - * Fixed grammar error in template. Closes: #132238 - * Really fixed typo in logrotate script. Closes: #131711 - - -- Christian Hammers Tue, 5 Feb 2002 14:20:08 +0100 - -mysql (3.23.47-4) unstable; urgency=medium - - * Fixes typo in postinst that let init script fail. Closes: #131743 - * Fixed bashism bug that failed on ash. Closes: #131697 - * Fixed typo in logrotate script. Closes: #131711 - - -- Christian Hammers Thu, 31 Jan 2002 23:58:46 +0100 - -mysql (3.23.47-3) unstable; urgency=low - - * Added new Debian specific mysql user called 'debian-sys-maint' which - is used for pinging the server status, flushing the logs or shutting - down the server in maintenance scripts. The credentials of this user - are stored in the UID0-only readable file /etc/mysql/debian.cnf. - Closes: #129887, #130326, #99274 - * Fixed unintended server startup at boottime. Closes: #122676, #130105 - * New upstream fixes command line parsing bug: Closes: #128473 - * Fixed manpage headers to let apropos work: Closes: #119122 - * Added "status" options for /etc/init.d/mysql. Closes: #129020 - - -- Christian Hammers Sun, 27 Jan 2002 19:46:11 +0100 - -mysql (3.23.47-2) unstable; urgency=low - - * Enhanced init scripts by using mysqladmin instead of kill $pid. - Thanks to Aaron Brick. - - -- Christian Hammers Fri, 18 Jan 2002 01:42:23 +0100 - -mysql (3.23.47-1) unstable; urgency=low - - * New upstream release. - * Updated brazilian translation of debconf descriptions. Closes: #123332 - - -- Christian Hammers Sun, 6 Jan 2002 21:11:17 +0100 - -mysql (3.23.46-3) unstable; urgency=low - - * Fixed bug in postinst where a script was accidently called with - "bash -c