From 4eb6fd537b98eabf02b61d4a7979414bf735f784 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 4 Dec 2003 23:57:10 +0200 Subject: [PATCH 01/50] fixed length of current database name if it is dropped (BUG#1986) mysql-test/r/query_cache.result: test of BUG#1986 mysql-test/t/query_cache.test: test of BUG#1986 sql/sql_db.cc: as far as we remove db name we should remove its length --- mysql-test/r/query_cache.result | 8 ++++++++ mysql-test/t/query_cache.test | 13 +++++++++++++ sql/sql_db.cc | 5 +++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index e668b9031cc..54a72fe58c2 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -809,4 +809,12 @@ show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 4 DROP TABLE t1; +CREATE TABLE t1 (a int(1)); +CREATE DATABASE mysqltest; +USE mysqltest; +DROP DATABASE mysqltest; +SELECT * FROM test.t1; +a +USE test; +DROP TABLE t1; SET GLOBAL query_cache_size=0; diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test index 14cbf4c906d..a7f28bfb5b6 100644 --- a/mysql-test/t/query_cache.test +++ b/mysql-test/t/query_cache.test @@ -585,4 +585,17 @@ show status like "Qcache_queries_in_cache"; # Keep things tidy # DROP TABLE t1; + +# +# DROP current database test +# +CREATE TABLE t1 (a int(1)); +CREATE DATABASE mysqltest; +USE mysqltest; +DROP DATABASE mysqltest; +SELECT * FROM test.t1; +USE test; +DROP TABLE t1; + + SET GLOBAL query_cache_size=0; diff --git a/sql/sql_db.cc b/sql/sql_db.cc index c61e6800cfa..6aff95641ba 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -409,7 +409,7 @@ exit: when the slave is replicating a DROP DATABASE: - garbage characters in the error message: "Error 'Can't drop database 'test2'; database doesn't exist' on query - 'h4zI'" + 'h4zI'" - segfault - hang in "free(vio)" (yes!) in the I/O or SQL slave threads (so slave server hangs at shutdown etc). @@ -418,7 +418,8 @@ exit: { if (!(thd->slave_thread)) /* a slave thread will free it itself */ x_free(thd->db); - thd->db= 0; + thd->db= 0; + thd->db_length= 0; } exit2: VOID(pthread_mutex_unlock(&LOCK_mysql_create_db)); From fc75518a78af9dfb68baac2cbf279983fe54b492 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 10 Dec 2003 22:46:14 +0200 Subject: [PATCH 02/50] fixed unlocking tables during subquery execution (BUG#2048) mysql-test/r/subselect_innodb.result: bug 2048 test mysql-test/t/subselect_innodb.test: bug 2048 test sql/item_subselect.cc: do not unlock tables for subqueries sql/sql_derived.cc: derived table tables can be unlocked sql/sql_lex.h: new interface to pass additional options sql/sql_union.cc: new interface to pass additional options do not unlock tables for UNION --- mysql-test/r/subselect_innodb.result | 20 ++++++++++++++++++++ mysql-test/t/subselect_innodb.test | 24 +++++++++++++++++++++++- sql/item_subselect.cc | 5 +++-- sql/sql_derived.cc | 2 +- sql/sql_lex.h | 2 +- sql/sql_union.cc | 7 ++++--- 6 files changed, 52 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/subselect_innodb.result b/mysql-test/r/subselect_innodb.result index 2f5b92fd05d..83ff5209e58 100644 --- a/mysql-test/r/subselect_innodb.result +++ b/mysql-test/r/subselect_innodb.result @@ -63,3 +63,23 @@ processor_id (SELECT y.yod_id FROM t1 p2, t2 y WHERE p2.processor_id = p1.proces 2 1 3 1 drop table t1,t2,t3; +CREATE TABLE t1 ( +id int(11) NOT NULL default '0', +b int(11) default NULL, +c char(3) default NULL, +PRIMARY KEY (id), +KEY t2i1 (b) +) TYPE=innodb DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES (0,0,'GPL'),(1,0,'GPL'),(2,1,'GPL'),(3,2,'GPL'); +CREATE TABLE t2 ( +id int(11) NOT NULL default '0', +b int(11) default NULL, +c char(3) default NULL, +PRIMARY KEY (id), +KEY t2i (b) +) TYPE=innodb DEFAULT CHARSET=latin1; +INSERT INTO t2 VALUES (0,0,'GPL'),(1,0,'GPL'),(2,1,'GPL'),(3,2,'GPL'); +select (select max(id) from t2 where b=1 group by b) as x,b from t1 where b=1; +x b +2 1 +drop table t1,t2; diff --git a/mysql-test/t/subselect_innodb.test b/mysql-test/t/subselect_innodb.test index 5e274ecbd5c..360bedf8972 100644 --- a/mysql-test/t/subselect_innodb.test +++ b/mysql-test/t/subselect_innodb.test @@ -67,4 +67,26 @@ INSERT INTO t1 VALUES (1),(2),(3); INSERT INTO t3 VALUES (1,1),(2,2),(3,3); INSERT INTO t2 VALUES (1,1),(2,2),(3,3); SELECT distinct p1.processor_id, (SELECT y.yod_id FROM t1 p2, t2 y WHERE p2.processor_id = p1.processor_id and p2.processor_id = y.processor_id) FROM t1 p1; -drop table t1,t2,t3; \ No newline at end of file +drop table t1,t2,t3; + +# +# innodb locking +# +CREATE TABLE t1 ( + id int(11) NOT NULL default '0', + b int(11) default NULL, + c char(3) default NULL, + PRIMARY KEY (id), + KEY t2i1 (b) +) TYPE=innodb DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES (0,0,'GPL'),(1,0,'GPL'),(2,1,'GPL'),(3,2,'GPL'); +CREATE TABLE t2 ( + id int(11) NOT NULL default '0', + b int(11) default NULL, + c char(3) default NULL, + PRIMARY KEY (id), + KEY t2i (b) +) TYPE=innodb DEFAULT CHARSET=latin1; +INSERT INTO t2 VALUES (0,0,'GPL'),(1,0,'GPL'),(2,1,'GPL'),(3,2,'GPL'); +select (select max(id) from t2 where b=1 group by b) as x,b from t1 where b=1; +drop table t1,t2; diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 7b401b50d4c..04458a7961a 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -906,7 +906,8 @@ int subselect_single_select_engine::prepare() { if (prepared) return 0; - join= new JOIN(thd, select_lex->item_list, select_lex->options, result); + join= new JOIN(thd, select_lex->item_list, + select_lex->options | SELECT_NO_UNLOCK, result); if (!join || !result) { thd->fatal_error(); //out of memory @@ -933,7 +934,7 @@ int subselect_single_select_engine::prepare() int subselect_union_engine::prepare() { - return unit->prepare(thd, result); + return unit->prepare(thd, result, SELECT_NO_UNLOCK); } int subselect_uniquesubquery_engine::prepare() diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index e8f1c5d87de..10d2254969a 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -114,7 +114,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, DBUG_RETURN(1); // out of memory // st_select_lex_unit::prepare correctly work for single select - if ((res= unit->prepare(thd, derived_result))) + if ((res= unit->prepare(thd, derived_result, 0))) goto exit; /* diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 15da6ca57a3..d8344403097 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -351,7 +351,7 @@ public: void exclude_tree(); /* UNION methods */ - int prepare(THD *thd, select_result *result); + int prepare(THD *thd, select_result *result, ulong additional_options); int exec(); int cleanup(); diff --git a/sql/sql_union.cc b/sql/sql_union.cc index f2470a59944..435354cb4ad 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -29,7 +29,7 @@ int mysql_union(THD *thd, LEX *lex, select_result *result, { DBUG_ENTER("mysql_union"); int res= 0; - if (!(res= unit->prepare(thd, result))) + if (!(res= unit->prepare(thd, result, SELECT_NO_UNLOCK))) res= unit->exec(); res|= unit->cleanup(); DBUG_RETURN(res); @@ -106,7 +106,8 @@ bool select_union::flush() } -int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result) +int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, + ulong additional_options) { SELECT_LEX *lex_select_save= thd_arg->lex.current_select; SELECT_LEX *sl, *first_select; @@ -146,7 +147,7 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result) for (;sl; sl= sl->next_select()) { JOIN *join= new JOIN(thd_arg, sl->item_list, - sl->options | thd_arg->options | SELECT_NO_UNLOCK, + sl->options | thd_arg->options | additional_options, tmp_result); thd_arg->lex.current_select= sl; offset_limit_cnt= sl->offset_limit; From 509d5cf39108724e3bd16264b2867a54c4ae6d3a Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 22 Dec 2003 19:00:51 +0400 Subject: [PATCH 03/50] Fix & test for the bug #2182: lpad returns incorrect result. mysql-test/r/func_str.result: Test for the bug #2182: lpad returns incorrect result mysql-test/t/func_str.test: Test for the bug #2182: lpad returns incorrect result sql/item_strfunc.cc: Fix for the bug #2182: lpad returns incorrect result --- mysql-test/r/func_str.result | 3 +++ mysql-test/t/func_str.test | 6 ++++++ sql/item_strfunc.cc | 5 ++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index c74feccfb7f..f08ae1b1efd 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -605,3 +605,6 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: Note 1003 select high_priority md5(_latin1'hello') AS `md5('hello')`,sha(_latin1'abc') AS `sha('abc')`,sha(_latin1'abc') AS `sha1('abc')`,soundex(_latin1'') AS `soundex('')`,(soundex(_latin1'mood') = soundex(_latin1'mud')) AS `'mood' sounds like 'mud'`,aes_decrypt(aes_encrypt(_latin1'abc',_latin1'1'),_latin1'1') AS `aes_decrypt(aes_encrypt('abc','1'),'1')`,concat(_latin1'*',repeat(_latin1' ',5),_latin1'*') AS `concat('*',space(5),'*')`,reverse(_latin1'abc') AS `reverse('abc')`,rpad(_latin1'a',4,_latin1'1') AS `rpad('a',4,'1')`,lpad(_latin1'a',4,_latin1'1') AS `lpad('a',4,'1')`,concat_ws(_latin1',',_latin1'',NULL,_latin1'a') AS `concat_ws(',','',NULL,'a')`,make_set(255,_latin2'a',_latin2'b',_latin2'c') AS `make_set(255,_latin2'a',_latin2'b',_latin2'c')`,elt(2,1) AS `elt(2,1)`,locate(_latin1'a',_latin1'b',2) AS `locate("a","b",2)`,format(130,10) AS `format(130,10)`,char(0) AS `char(0)`,conv(130,16,10) AS `conv(130,16,10)`,hex(130) AS `hex(130)`,(_latin1'HE' collate _latin1'BINARY') AS `binary 'HE'`,export_set(255,_latin2'y',_latin2'n',_latin2' ') AS `export_set(255,_latin2'y',_latin2'n',_latin2' ')`,field((_latin1'b' collate _latin1'latin1_bin'),_latin1'A',_latin1'B') AS `FIELD('b' COLLATE latin1_bin,'A','B')`,find_in_set(_latin1'B',_latin1'a,b,c,d') AS `FIND_IN_SET(_latin1'B',_latin1'a,b,c,d')`,collation(conv(130,16,10)) AS `collation(conv(130,16,10))`,coercibility(conv(130,16,10)) AS `coercibility(conv(130,16,10))`,length(_latin1'\n \r\0\\_\\%\\') AS `length('\n\t\r\b\0\_\%\\')`,bit_length(_latin1'\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`,bit_length(_latin1'\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`,concat(_latin1'monty',_latin1' was here ',_latin1'again') AS `concat('monty',' was here ','again')`,length(_latin1'hello') AS `length('hello')`,char(ascii(_latin1'h')) AS `char(ascii('h'))`,ord(_latin1'h') AS `ord('h')`,quote((1 / 0)) AS `quote(1/0)`,crc32(_latin1'123') AS `crc32("123")`,replace(_latin1'aaaa',_latin1'a',_latin1'b') AS `replace('aaaa','a','b')`,insert(_latin1'txs',2,1,_latin1'hi') AS `insert('txs',2,1,'hi')`,left(_latin2'a',1) AS `left(_latin2'a',1)`,right(_latin2'a',1) AS `right(_latin2'a',1)`,lcase(_latin2'a') AS `lcase(_latin2'a')`,ucase(_latin2'a') AS `ucase(_latin2'a')`,substr(_latin1'abcdefg',3,2) AS `SUBSTR('abcdefg',3,2)`,substr_index(_latin1'1abcd;2abcd;3abcd;4abcd',_latin1';',2) AS `substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2)`,trim(_latin2' a ') AS `trim(_latin2' a ')`,ltrim(_latin2' a ') AS `ltrim(_latin2' a ')`,rtrim(_latin2' a ') AS `rtrim(_latin2' a ')`,decode(encode(repeat(_latin1'a',100000))) AS `decode(encode(repeat("a",100000),"monty"),"monty")` +SELECT lpad(12345, 5, "#"); +lpad(12345, 5, "#") +12345 diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index ad7b9b21b51..155ed459d1f 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -346,3 +346,9 @@ DROP TABLE t1; select substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2),substring_index("1abcd;2abcd;3abcd;4abcd", ';', -2); explain extended select md5('hello'), sha('abc'), sha1('abc'), soundex(''), 'mood' sounds like 'mud', aes_decrypt(aes_encrypt('abc','1'),'1'),concat('*',space(5),'*'), reverse('abc'), rpad('a',4,'1'), lpad('a',4,'1'), concat_ws(',','',NULL,'a'),make_set(255,_latin2'a',_latin2'b',_latin2'c'),elt(2,1),locate("a","b",2),format(130,10),char(0),conv(130,16,10),hex(130),binary 'HE', export_set(255,_latin2'y',_latin2'n',_latin2' '),FIELD('b' COLLATE latin1_bin,'A','B'),FIND_IN_SET(_latin1'B',_latin1'a,b,c,d'),collation(conv(130,16,10)), coercibility(conv(130,16,10)),length('\n\t\r\b\0\_\%\\'),bit_length('\n\t\r\b\0\_\%\\'),bit_length('\n\t\r\b\0\_\%\\'),concat('monty',' was here ','again'),length('hello'),char(ascii('h')),ord('h'),quote(1/0),crc32("123"),replace('aaaa','a','b'),insert('txs',2,1,'hi'),left(_latin2'a',1),right(_latin2'a',1),lcase(_latin2'a'),ucase(_latin2'a'),SUBSTR('abcdefg',3,2),substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2),trim(_latin2' a '),ltrim(_latin2' a '),rtrim(_latin2' a '), decode(encode(repeat("a",100000),"monty"),"monty"); + +# +# Bug #2182 +# + +SELECT lpad(12345, 5, "#"); diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 3cb03d7ea49..2df81f97be0 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2022,9 +2022,8 @@ String *Item_func_lpad::val_str(String *str) { uint32 res_char_length,pad_char_length; ulong count= (long) args[1]->val_int(), byte_count; - String a1,a3; - String *res= args[0]->val_str(&a1); - String *pad= args[2]->val_str(&a3); + String *res= args[0]->val_str(&tmp_value); + String *pad= args[2]->val_str(&lpad_str); if (!res || args[1]->null_value || !pad) goto err; From 17e54cf40702918c5f9b932a2416619ad88e12e7 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 25 Dec 2003 18:50:22 +0400 Subject: [PATCH 04/50] Fix for the bug #2198: SELECT INTO OUTFILE (with Sub-Select) Problem. Proper Item_cache::setup() method. Code cleanup. (discussed with sanja) sql/item.cc: code cleanup sql/item.h: fix for the bug #2198: SELECT INTO OUTFILE (with Sub-Select) Problem. proper Item_cache::setup() method code cleanup sql/item_subselect.cc: fix for the bug #2198: SELECT INTO OUTFILE (with Sub-Select) Problem. proper Item_cache::setup() method code cleanup --- sql/item.cc | 3 --- sql/item.h | 16 +++++++++------- sql/item_subselect.cc | 15 ++++++--------- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/sql/item.cc b/sql/item.cc index 417f05680cf..37240700c68 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1867,7 +1867,6 @@ void Item_cache_int::store(Item *item) { value= item->val_int_result(); null_value= item->null_value; - collation.set(item->collation); } @@ -1875,7 +1874,6 @@ void Item_cache_real::store(Item *item) { value= item->val_result(); null_value= item->null_value; - collation.set(item->collation); } @@ -1898,7 +1896,6 @@ void Item_cache_str::store(Item *item) value_buff.copy(*value); value= &value_buff; } - collation.set(item->collation); } diff --git a/sql/item.h b/sql/item.h index 5def1e2b710..5917a0dc95e 100644 --- a/sql/item.h +++ b/sql/item.h @@ -878,13 +878,15 @@ public: void set_used_tables(table_map map) { used_table_map= map; } virtual bool allocate(uint i) { return 0; }; - virtual bool setup(Item *item) { example= item; return 0; }; - virtual void store(Item *)= 0; - void set_len_n_dec(uint32 max_len, uint8 dec) + virtual bool setup(Item *item) { - max_length= max_len; - decimals= dec; - } + example= item; + max_length= item->max_length; + decimals= item->decimals; + collation.set(item->collation); + return 0; + }; + virtual void store(Item *)= 0; enum Type type() const { return CACHE_ITEM; } static Item_cache* get_cache(Item_result type); table_map used_tables() const { return used_table_map; } @@ -909,7 +911,7 @@ class Item_cache_real: public Item_cache double value; public: Item_cache_real(): Item_cache() {} - + void store(Item *item); double val() { return value; } longlong val_int() { return (longlong) (value+(value > 0 ? 0.5 : -0.5)); } diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 43775e1c96c..cb729041f22 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -301,8 +301,6 @@ void Item_singlerow_subselect::fix_length_and_dec() if ((max_columns= engine->cols()) == 1) { engine->fix_length_and_dec(row= &value); - if (!(value= Item_cache::get_cache(engine->type()))) - return; } else { @@ -955,13 +953,9 @@ static Item_result set_row(List &item_list, Item *item, res_type= sel_item->result_type(); item->decimals= sel_item->decimals; *maybe_null= sel_item->maybe_null; - if (row) - { - if (!(row[i]= Item_cache::get_cache(res_type))) - return STRING_RESULT; // we should return something - row[i]->set_len_n_dec(sel_item->max_length, sel_item->decimals); - row[i]->collation.set(sel_item->collation); - } + if (!(row[i]= Item_cache::get_cache(res_type))) + return STRING_RESULT; // we should return something + row[i]->setup(sel_item); } if (item_list.elements > 1) res_type= ROW_RESULT; @@ -982,7 +976,10 @@ void subselect_union_engine::fix_length_and_dec(Item_cache **row) DBUG_ASSERT(row || unit->first_select()->item_list.elements==1); if (unit->first_select()->item_list.elements == 1) + { res_type= set_row(unit->types, item, row, &maybe_null); + item->collation.set(row[0]->collation); + } else { bool fake= 0; From a4be3840a37dcb24530f895f7a46080fed570874 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 30 Dec 2003 13:30:21 +0400 Subject: [PATCH 05/50] Fix for the bug #2235: mysqldump --compatible doesn't work correctly. --- client/mysqldump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 018cd43ce87..f0dfefbf0ca 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -830,7 +830,7 @@ static uint getTableStructure(char *table, char* db) char *end; uint i; - sprintf(buff, "/*!41000 SET @@sql_mode=\""); + sprintf(buff, "/*!40100 SET @@sql_mode=\""); end= strend(buff); for (i= 0; opt_compatible_mode; opt_compatible_mode>>= 1, i++) { From b21d8b0eff5b2da2f4b565ab630549ede52ed28a Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 3 Jan 2004 00:12:07 +0200 Subject: [PATCH 06/50] removed droping field->query_id for reinitialization tables for subquery. (BUG#2089) mysql-test/r/subselect_innodb.result: correct results sql/mysql_priv.h: new parameter for setup_tables() sql/sql_base.cc: new parameter for setup_tables() added to avoid dropping query_id of fields during reinitialization subquery sql/sql_class.cc: layout fixed sql/sql_help.cc: new parameter for setup_tables() sql/sql_insert.cc: new parameter for setup_tables() sql/sql_lex.cc: removed incorrect code sql/sql_load.cc: new parameter for setup_tables() sql/sql_olap.cc: new parameter for setup_tables() sql/sql_prepare.cc: new parameter for setup_tables() sql/sql_select.cc: new parameter for setup_tables() sql/sql_update.cc: new parameter for setup_tables() --- mysql-test/r/subselect_innodb.result | 17 +++++++++++++++-- sql/mysql_priv.h | 2 +- sql/sql_base.cc | 27 ++++++++++++++++++++------- sql/sql_class.cc | 2 +- sql/sql_help.cc | 2 +- sql/sql_insert.cc | 4 ++-- sql/sql_lex.cc | 5 ----- sql/sql_load.cc | 2 +- sql/sql_olap.cc | 2 +- sql/sql_prepare.cc | 2 +- sql/sql_select.cc | 4 ++-- sql/sql_update.cc | 2 +- 12 files changed, 46 insertions(+), 25 deletions(-) diff --git a/mysql-test/r/subselect_innodb.result b/mysql-test/r/subselect_innodb.result index 6729916f1c8..972cbdda38f 100644 --- a/mysql-test/r/subselect_innodb.result +++ b/mysql-test/r/subselect_innodb.result @@ -60,6 +60,19 @@ INSERT INTO t2 VALUES (1,1),(2,2),(3,3); SELECT distinct p1.processor_id, (SELECT y.yod_id FROM t1 p2, t2 y WHERE p2.processor_id = p1.processor_id and p2.processor_id = y.processor_id) FROM t1 p1; processor_id (SELECT y.yod_id FROM t1 p2, t2 y WHERE p2.processor_id = p1.processor_id and p2.processor_id = y.processor_id) 1 1 -2 1 -3 1 +2 2 +3 3 drop table t1,t2,t3; +create table t1 (id int not null, value char(255), primary key(id)) engine=innodb; +create table t2 (id int not null, value char(255)) engine=innodb; +insert into t1 values (1,'a'),(2,'b'); +insert into t2 values (1,'z'),(2,'x'); +select t2.id,t2.value,(select t1.value from t1 where t1.id=t2.id) from t2; +id value (select t1.value from t1 where t1.id=t2.id) +1 z a +2 x b +select t2.id,t2.value,(select t1.value from t1 where t1.id=t2.id) from t2; +id value (select t1.value from t1 where t1.id=t2.id) +1 z a +2 x b +drop table t1,t2; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 15a99385285..bba30964a31 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -664,7 +664,7 @@ bool get_key_map_from_key_list(key_map *map, TABLE *table, bool insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name, const char *table_name, List_iterator *it); -bool setup_tables(TABLE_LIST *tables); +bool setup_tables(TABLE_LIST *tables, my_bool reinit); int setup_wild(THD *thd, TABLE_LIST *tables, List &fields, List *sum_func_list, uint wild_num); int setup_fields(THD *thd, Item** ref_pointer_array, TABLE_LIST *tables, diff --git a/sql/sql_base.cc b/sql/sql_base.cc index d7984213fd6..3125c392751 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2039,15 +2039,28 @@ int setup_fields(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, /* - Remap table numbers if INSERT ... SELECT - Check also that the 'used keys' and 'ignored keys' exists and set up the - table structure accordingly + prepare tables - This has to be called for all tables that are used by items, as otherwise - table->map is not set and all Item_field will be regarded as const items. + SYNOPSIS + setup_tables() + tables - tables list + reinit - true if called for table reinitialization before + subquery reexecuting + + RETURN + 0 ok; In this case *map will includes the choosed index + 1 error + + NOTE + Remap table numbers if INSERT ... SELECT + Check also that the 'used keys' and 'ignored keys' exists and set up the + table structure accordingly + + This has to be called for all tables that are used by items, as otherwise + table->map is not set and all Item_field will be regarded as const items. */ -bool setup_tables(TABLE_LIST *tables) +bool setup_tables(TABLE_LIST *tables, my_bool reinit) { DBUG_ENTER("setup_tables"); uint tablenr=0; @@ -2074,7 +2087,7 @@ bool setup_tables(TABLE_LIST *tables) table->keys_in_use_for_query.subtract(map); } table->used_keys.intersect(table->keys_in_use_for_query); - if (table_list->shared || table->clear_query_id) + if ((table_list->shared || table->clear_query_id) && !reinit) { table->clear_query_id= 0; /* Clear query_id that may have been set by previous select */ diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 60220ffc889..2c75c3c5a22 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1037,7 +1037,7 @@ bool select_singlerow_subselect::send_data(List &items) Item_singlerow_subselect *it= (Item_singlerow_subselect *)item; if (it->assigned()) { - my_message(ER_SUBQUERY_NO_1_ROW, ER(ER_SUBQUERY_NO_1_ROW), MYF(0)); + my_message(ER_SUBQUERY_NO_1_ROW, ER(ER_SUBQUERY_NO_1_ROW), MYF(0)); DBUG_RETURN(1); } if (unit->offset_limit_cnt) diff --git a/sql/sql_help.cc b/sql/sql_help.cc index c40133c04a8..a5b7c691ae1 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -686,7 +686,7 @@ int mysqld_help(THD *thd, const char *mask) goto end; } /* Init tables and fields to be usable from items */ - setup_tables(tables); + setup_tables(tables, 0); memcpy((char*) used_fields, (char*) init_used_fields, sizeof(used_fields)); if (init_fields(thd, tables, used_fields, array_elements(used_fields))) { diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index e23e62fb714..c2f3e737daf 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -84,7 +84,7 @@ check_insert_fields(THD *thd,TABLE *table,List &fields, table_list.grant=table->grant; thd->dupp_field=0; - if (setup_tables(&table_list) || + if (setup_tables(&table_list, 0) || setup_fields(thd, 0, &table_list,fields,1,0,0)) return -1; if (thd->dupp_field) @@ -204,7 +204,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, } if (check_insert_fields(thd,table,fields,*values,1) || - setup_tables(insert_table_list) || + setup_tables(insert_table_list, 0) || setup_fields(thd, 0, insert_table_list, *values, 0, 0, 0) || (duplic == DUP_UPDATE && (setup_fields(thd, 0, insert_table_list, update_fields, 0, 0, 0) || diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index de0d6ade618..efb0ce92ad0 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1222,11 +1222,6 @@ void st_select_lex::mark_as_dependent(SELECT_LEX *last) s->uncacheable|= UNCACHEABLE_DEPENDENT; SELECT_LEX_UNIT *munit= s->master_unit(); munit->uncacheable|= UNCACHEABLE_DEPENDENT; - //Tables will be reopened many times - for (TABLE_LIST *tbl= s->get_table_list(); - tbl; - tbl= tbl->next) - tbl->shared= 1; } } diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 0c35e99ed08..175791ef31e 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -123,7 +123,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, else { // Part field list thd->dupp_field=0; - if (setup_tables(table_list) || + if (setup_tables(table_list, 0) || setup_fields(thd, 0, table_list, fields, 1, 0, 0)) DBUG_RETURN(-1); if (thd->dupp_field) diff --git a/sql/sql_olap.cc b/sql/sql_olap.cc index ef7bf013be8..1d16771c1a4 100644 --- a/sql/sql_olap.cc +++ b/sql/sql_olap.cc @@ -164,7 +164,7 @@ int handle_olaps(LEX *lex, SELECT_LEX *select_lex) List all_fields(select_lex->item_list); - if (setup_tables((TABLE_LIST *)select_lex->table_list.first) || + if (setup_tables((TABLE_LIST *)select_lex->table_list.first, 0) || setup_fields(lex->thd, 0, (TABLE_LIST *)select_lex->table_list.first, select_lex->item_list, 1, &all_fields,1) || setup_fields(lex->thd, 0, (TABLE_LIST *)select_lex->table_list.first, diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 5d6ab165641..0a565c00ba7 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -679,7 +679,7 @@ static bool mysql_test_upd_fields(Prepared_statement *stmt, #endif if (open_and_lock_tables(thd, table_list)) DBUG_RETURN(1); - if (setup_tables(table_list) || + if (setup_tables(table_list, 0) || setup_fields(thd, 0, table_list, fields, 1, 0, 0) || setup_conds(thd, table_list, &conds) || thd->net.report_error) DBUG_RETURN(1); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index a1f6abfd53a..fe5b8885810 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -301,7 +301,7 @@ JOIN::prepare(Item ***rref_pointer_array, /* Check that all tables, fields, conds and order are ok */ - if (setup_tables(tables_list) || + if (setup_tables(tables_list, 0) || setup_wild(thd, tables_list, fields_list, &all_fields, wild_num) || select_lex->setup_ref_array(thd, og_num) || setup_fields(thd, (*rref_pointer_array), tables_list, fields_list, 1, @@ -1015,7 +1015,7 @@ JOIN::reinit() if (unit->select_limit_cnt == HA_POS_ERROR) select_lex->options&= ~OPTION_FOUND_ROWS; - if (setup_tables(tables_list)) + if (setup_tables(tables_list, 1)) DBUG_RETURN(1); /* Reset of sum functions */ diff --git a/sql/sql_update.cc b/sql/sql_update.cc index cdea32ad3f6..9fc8d482bfa 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -95,7 +95,7 @@ int mysql_update(THD *thd, tables.table= table; tables.alias= table_list->alias; - if (setup_tables(update_table_list) || + if (setup_tables(update_table_list, 0) || setup_conds(thd,update_table_list,&conds) || thd->lex->select_lex.setup_ref_array(thd, order_num) || setup_order(thd, thd->lex->select_lex.ref_pointer_array, From 5e55cd5d0feba9e276ddc8bc4c2e225f714b3290 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Jan 2004 13:13:04 +0200 Subject: [PATCH 07/50] As far as we cut off derived table branch, we have to close JOINs (BUG#2141) (test case is absend because it is multi-thread and very big) sql/sql_derived.cc: As far as we cut off this branch, we have to close JOINs --- sql/sql_derived.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index e8f1c5d87de..ab3ef8da21a 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -198,7 +198,10 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, } } else + { unit->exclude_tree(); + unit->cleanup(); + } org_table_list->db= (char *)""; // Force read of table stats in the optimizer table->file->info(HA_STATUS_VARIABLE); From d84ee4d503783a174346393436e7a8ecc7b941bd Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Jan 2004 22:28:29 +0200 Subject: [PATCH 08/50] null.result, null.test: Fix for a bug #2219, regarding a bad cast to integer from NULL item_func.h: Fix for a bug #2219, regarding a bad cast to integer from NULL sql_parse.cc: A fix for a bug #2207, with mysql server haning on option setting sql/sql_parse.cc: A fix for a bug #2207, with mysql server haning on option setting sql/item_func.h: Fix for a bug #2219, regarding a bad cast to integer from NULL mysql-test/t/null.test: Fix for a bug #2219, regarding a bad cast to integer from NULL mysql-test/r/null.result: Fix for a bug #2219, regarding a bad cast to integer from NULL --- mysql-test/r/null.result | 3 +++ mysql-test/t/null.test | 1 + sql/item_func.h | 8 ++++---- sql/sql_parse.cc | 2 ++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/null.result b/mysql-test/r/null.result index c4af221e117..aa56bce6453 100644 --- a/mysql-test/r/null.result +++ b/mysql-test/r/null.result @@ -153,3 +153,6 @@ explain select * from t1 where a between 2 and 3 or b is null; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range idx idx 4 NULL 2 Using where drop table t1; +select cast(NULL as signed); +cast(NULL as signed) +NULL diff --git a/mysql-test/t/null.test b/mysql-test/t/null.test index c11ed78253b..9f3b6646e7f 100644 --- a/mysql-test/t/null.test +++ b/mysql-test/t/null.test @@ -97,3 +97,4 @@ insert into t1 values explain select * from t1 where a between 2 and 3; explain select * from t1 where a between 2 and 3 or b is null; drop table t1; +select cast(NULL as signed); diff --git a/sql/item_func.h b/sql/item_func.h index ac67b5a4065..33a4357d26c 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -212,8 +212,8 @@ class Item_func_signed :public Item_int_func { public: Item_func_signed(Item *a) :Item_int_func(a) {} - double val() { return args[0]->val(); } - longlong val_int() { return args[0]->val_int(); } + double val() { null_value=args[0]->null_value; return args[0]->val(); } + longlong val_int() { null_value=args[0]->null_value; return args[0]->val_int(); } void fix_length_and_dec() { max_length=args[0]->max_length; unsigned_flag=0; } void print(String *str); @@ -224,8 +224,8 @@ class Item_func_unsigned :public Item_int_func { public: Item_func_unsigned(Item *a) :Item_int_func(a) {} - double val() { return args[0]->val(); } - longlong val_int() { return args[0]->val_int(); } + double val() { null_value=args[0]->null_value; return args[0]->val(); } + longlong val_int() { null_value=args[0]->null_value; return args[0]->val_int(); } void fix_length_and_dec() { max_length=args[0]->max_length; unsigned_flag=1; } void print(String *str); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 465d840e2b8..3f36b48f5e6 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1624,9 +1624,11 @@ bool dispatch_command(enum enum_server_command command, THD *thd, switch (command) { case MYSQL_OPTION_MULTI_STATEMENTS_ON: thd->client_capabilities|= CLIENT_MULTI_STATEMENTS; + send_eof(thd); break; case MYSQL_OPTION_MULTI_STATEMENTS_OFF: thd->client_capabilities&= ~CLIENT_MULTI_STATEMENTS; + send_eof(thd); break; default: send_error(thd, ER_UNKNOWN_COM_ERROR); From 24f8054460a574660730024690786b877afccfd3 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 11 Jan 2004 18:15:19 +0100 Subject: [PATCH 09/50] Detect unexpected return codes of mysqltest in mysql-test-run. This way, a crash of mysqltest will be visible in the test logs (output of mysql-test-run). mysql-test/mysql-test-run.sh: by design mysqltest returns 0 or 1 or 2 (see the exit()s and the return() of main()). So any greater code is a crash, I guess. On build and on my machine, 139 is segfault and 134 is assertion failure. --- mysql-test/mysql-test-run.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 265ff036998..3f7efd3d6bc 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -603,7 +603,7 @@ error () { error_is () { $ECHO "Errors are (from $TIMEFILE) :" $CAT < $TIMEFILE - $ECHO "(the last line(s) may be the ones that caused the die() in mysqltest)" + $ECHO "(the last lines may be the most important ones)" } prefix_to_8() { @@ -1309,6 +1309,9 @@ run_testcase () skip_inc $ECHO "$RES$RES_SPACE [ skipped ]" else + if [ $res -gt 2 ]; then + $ECHO "mysqltest returned unexpected code $res, it has probably crashed" >> $TIMEFILE + fi total_inc fail_inc $ECHO "$RES$RES_SPACE [ fail ]" From 6c8045d4698240bc20639c4f9631735bbed90fea Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Jan 2004 14:31:04 +0400 Subject: [PATCH 10/50] charset.c: Fixed: client crashed when there are no Index.xml file. mysys/charset.c: Fixed: client crashed when there are no Index.xml file. --- mysys/charset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysys/charset.c b/mysys/charset.c index f8c8237c88b..b911f29627c 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -540,7 +540,7 @@ static CHARSET_INFO *get_internal_charset(uint cs_number, myf flags) strxmov(get_charsets_dir(buf), cs->csname, ".xml", NullS); my_read_charset_file(buf,flags); } - cs= (cs->state & MY_CS_AVAILABLE) ? cs : NULL; + cs= (cs && cs->state & MY_CS_AVAILABLE) ? cs : NULL; pthread_mutex_unlock(&THR_LOCK_charset); return cs; } From 5b8b45f19f144b5dd02879ca25572fab0db6e7be Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Jan 2004 17:43:39 +0100 Subject: [PATCH 11/50] checking 2nd level of FT index destroyed info->lastkey and CHECK TABLE erroneously treated table as corrupted bug#2190 --- myisam/mi_check.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/myisam/mi_check.c b/myisam/mi_check.c index a55929805fa..5687e7d48e3 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -551,7 +551,7 @@ static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, ha_checksum *key_checksum, uint level) { int flag; - uint used_length,comp_flag,nod_flag,key_length,not_used; + uint used_length,comp_flag,nod_flag,key_length=0,not_used; uchar key[MI_MAX_POSSIBLE_KEY_BUFF],*temp_buff,*keypos,*old_keypos,*endpos; my_off_t next_page,record; char llbuff[22]; @@ -586,6 +586,8 @@ static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, } for ( ;; ) { + memcpy((char*) info->lastkey,(char*) key,key_length); + info->lastkey_length=key_length; if (nod_flag) { next_page=_mi_kpos(nod_flag,keypos); @@ -629,8 +631,6 @@ static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, } (*key_checksum)+= mi_byte_checksum((byte*) key, key_length- info->s->rec_reflength); - memcpy((char*) info->lastkey,(char*) key,key_length); - info->lastkey_length=key_length; record= _mi_dpos(info,0,key+key_length); if (keyinfo->flag & HA_FULLTEXT) /* special handling for ft2 */ { @@ -658,7 +658,7 @@ static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, DBUG_PRINT("test",("page: %s record: %s filelength: %s", llstr(page,llbuff),llstr(record,llbuff2), llstr(info->state->data_file_length,llbuff3))); - DBUG_DUMP("key",(byte*) info->lastkey,key_length); + DBUG_DUMP("key",(byte*) key,key_length); DBUG_DUMP("new_in_page",(char*) old_keypos,(uint) (keypos-old_keypos)); goto err; } From e90eb6f43ed987a9f69b8215bb123396ec9394aa Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Jan 2004 21:05:41 +0100 Subject: [PATCH 12/50] Fix for BUG#2333 "ALTER DATABASE on inexistent database hangs the client": mysql_alter_db() now returns -1 in case of error, so that mysql_execute_command() calls send_error(). sql/sql_db.cc: In case of error, return -1 so that mysql_execute_command() understands that it must send_error(). The double (( at the left of 'error' in the 'if' are to avoid a compiler warning. --- sql/sql_db.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 70b1d1d0d3a..08f9ace529d 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -270,11 +270,8 @@ int mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info) VOID(pthread_mutex_lock(&LOCK_mysql_create_db)); // do not alter database if another thread is holding read lock - if (wait_if_global_read_lock(thd,0)) - { - error= -1; + if ((error=wait_if_global_read_lock(thd,0))) goto exit2; - } /* Check directory */ (void)sprintf(path,"%s/%s/%s", mysql_data_home, db, MY_DB_OPT_FILE); @@ -307,7 +304,7 @@ exit: start_waiting_global_read_lock(thd); exit2: VOID(pthread_mutex_unlock(&LOCK_mysql_create_db)); - DBUG_RETURN(error); + DBUG_RETURN(error ? -1 : 0); /* -1 to delegate send_error() */ } From ea854327159c22dc811c9b64131918c694f49ae6 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Jan 2004 04:05:38 +0200 Subject: [PATCH 13/50] row0sel.c: If MySQL tries to do SELECT from an InnoDB table, but has set no table locks at all in ::external_lock(), print a descriptive error message and assert; some subquery bugs were of this type innobase/row/row0sel.c: If MySQL tries to do SELECT from an InnoDB table, but has set no table locks at all in ::external_lock(), print a descriptive error message and assert; some subquery bugs were of this type --- innobase/row/row0sel.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/innobase/row/row0sel.c b/innobase/row/row0sel.c index 2215e3feff8..a13aaa47af2 100644 --- a/innobase/row/row0sel.c +++ b/innobase/row/row0sel.c @@ -2758,6 +2758,7 @@ row_search_for_mysql( ulint cnt = 0; ulint next_offs; mtr_t mtr; + char err_buf[1000]; ut_ad(index && pcur && search_tuple); ut_ad(trx->mysql_thread_id == os_thread_get_curr_id()); @@ -2773,6 +2774,17 @@ row_search_for_mysql( ut_a(0); } + if (trx->n_mysql_tables_in_use == 0) { + + trx_print(err_buf, trx); + + fprintf(stderr, +"InnoDB: Error: MySQL is trying to perform a SELECT\n" +"InnoDB: but it has not locked any tables in ::external_lock()!\n%s\n", + err_buf); + ut_a(0); + } + /* printf("Match mode %lu\n search tuple ", match_mode); dtuple_print(search_tuple); @@ -3072,6 +3084,16 @@ shortcut_fails_too_big_rec: if (!prebuilt->sql_stat_start) { /* No need to set an intention lock or assign a read view */ + if (trx->read_view == NULL + && prebuilt->select_lock_type == LOCK_NONE) { + trx_print(err_buf, trx); + + fprintf(stderr, +"InnoDB: Error: MySQL is trying to perform a consistent read\n" +"InnoDB: but the read view is not assigned!\n%s\n", err_buf); + + ut_a(0); + } } else if (prebuilt->select_lock_type == LOCK_NONE) { /* This is a consistent read */ /* Assign a read view for the query */ From 79a4b2cd49b87da5dd327cd04242deda7188205f Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Jan 2004 04:10:20 +0200 Subject: [PATCH 14/50] row0sel.c: Improve previous push: save 1000 bytes of thread stack in non-error cases innobase/row/row0sel.c: Improve previous push: save 1000 bytes of thread stack in non-error cases --- innobase/row/row0sel.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/innobase/row/row0sel.c b/innobase/row/row0sel.c index a13aaa47af2..5a5da3ba59a 100644 --- a/innobase/row/row0sel.c +++ b/innobase/row/row0sel.c @@ -2758,7 +2758,6 @@ row_search_for_mysql( ulint cnt = 0; ulint next_offs; mtr_t mtr; - char err_buf[1000]; ut_ad(index && pcur && search_tuple); ut_ad(trx->mysql_thread_id == os_thread_get_curr_id()); @@ -2775,7 +2774,8 @@ row_search_for_mysql( } if (trx->n_mysql_tables_in_use == 0) { - + char err_buf[1000]; + trx_print(err_buf, trx); fprintf(stderr, @@ -3086,6 +3086,8 @@ shortcut_fails_too_big_rec: if (trx->read_view == NULL && prebuilt->select_lock_type == LOCK_NONE) { + char err_buf[1000]; + trx_print(err_buf, trx); fprintf(stderr, From 491ab7f72e37ae16531567c21df4be11e9f6a0db Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Jan 2004 01:10:21 -0100 Subject: [PATCH 15/50] Minor Novell supplied changes for 4.1 (inside netware directory) netware/init_db.sql: Add new tables for 4.1 netware/libmysql.imp: Comment out simple_command --- netware/init_db.sql | 4 ++++ netware/libmysql.imp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/netware/init_db.sql b/netware/init_db.sql index 4613e5c0274..063c1815eb1 100644 --- a/netware/init_db.sql +++ b/netware/init_db.sql @@ -24,3 +24,7 @@ CREATE TABLE tables_priv (Host char(60) binary DEFAULT '' NOT NULL, Db char(64) CREATE TABLE columns_priv (Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp(14), Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name)) comment='Column privileges'; +CREATE TABLE help_topic (help_topic_id int unsigned NOT NULL, name varchar(64) NOT NULL, help_category_id smallint unsigned NOT NULL, description text NOT NULL, example text NOT NULL, url varchar(128) NOT NULL, primary key (help_topic_id), unique index (name))comment='help topics'; +CREATE TABLE help_category (help_category_id smallint unsigned NOT NULL, name varchar(64) NOT NULL, parent_category_id smallint unsigned null, url varchar(128) NOT NULL, primary key (help_category_id), unique index (name)) comment='help categories'; +CREATE TABLE help_keyword (help_keyword_id int unsigned NOT NULL, name varchar(64) NOT NULL, primary key (help_keyword_id), unique index (name)) comment='help keywords'; +CREATE TABLE help_relation (help_topic_id int unsigned NOT NULL references help_topic, help_keyword_id int unsigned NOT NULL references help_keyword, primary key (help_keyword_id, help_topic_id)) comment='keyword-topic relation'; diff --git a/netware/libmysql.imp b/netware/libmysql.imp index 75fcc8d1a99..977fb1b0b1f 100644 --- a/netware/libmysql.imp +++ b/netware/libmysql.imp @@ -77,7 +77,7 @@ mysql_thread_init, mysql_thread_safe, mysql_use_result, net_safe_read, -simple_command, +#simple_command, mysql_connect, mysql_create_db, mysql_drop_db, From 21e2c72bfbdccfdb0f72c6cbb61d7987bb7bb576 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Jan 2004 16:18:37 +0400 Subject: [PATCH 16/50] a fix (bug #2361: ALTER TABLE ... DROP PRIMARY KEY drops a non-primary key). --- mysql-test/r/alter_table.result | 9 +++++++++ mysql-test/t/alter_table.test | 9 +++++++++ sql/sql_table.cc | 8 +++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index 7ec12c1b021..33af0b30d1c 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -412,3 +412,12 @@ t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE t1 0 PRIMARY 2 User A 0 NULL NULL BTREE t1 1 Host 1 Host A NULL NULL NULL BTREE disabled DROP TABLE t1; +CREATE TABLE t1 (a int UNIQUE); +ALTER TABLE t1 DROP PRIMARY KEY; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) default NULL, + UNIQUE KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index eab4fd7f5f0..71991973105 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -244,3 +244,12 @@ LOCK TABLES t1 WRITE; ALTER TABLE t1 DISABLE KEYS; SHOW INDEX FROM t1; DROP TABLE t1; + +# +# Bug 2361 +# + +CREATE TABLE t1 (a int UNIQUE); +ALTER TABLE t1 DROP PRIMARY KEY; +SHOW CREATE TABLE t1; +DROP TABLE t1; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index ecd5f9ccb66..be42de34899 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2242,13 +2242,15 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, KEY *key_info=table->key_info; for (uint i=0 ; i < table->keys ; i++,key_info++) { - if (drop_primary && (key_info->flags & HA_NOSAME)) + char *key_name= key_info->name; + + if (drop_primary && !my_strcasecmp(system_charset_info, key_name, + "PRIMARY")) { - drop_primary=0; + drop_primary= 0; continue; } - char *key_name=key_info->name; Alter_drop *drop; drop_it.rewind(); while ((drop=drop_it++)) From bf7e46938b8c79f5f9279adb671b7ab56f694435 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Jan 2004 17:27:21 +0400 Subject: [PATCH 17/50] item_strfunc.cc: Unnesessary code was removed. Comment was added. sql/item_strfunc.cc: Unnesessary code was removed. Comment was added. --- sql/item_strfunc.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index fdacc4ec536..528345beb77 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -975,8 +975,13 @@ String *Item_func_right::val_str(String *str) if (res->length() <= (uint) length) return res; /* purecov: inspected */ + /* + As far "res" contains at least "length" bytes + (according to the above condition and return), + the below statement is safe. res->numchars() can + never return a value less than "length". + */ uint start=res->numchars()-(uint) length; - if (start<=0) return res; start=res->charpos(start); tmp_value.set(*res,start,res->length()-start); return &tmp_value; From 9dfada0cba36d75fc3dc49cecefc8c3f9b5114d2 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Jan 2004 17:13:03 +0200 Subject: [PATCH 18/50] srv0start.c, srv0srv.c: If UNIV_SYNC_DEBUG was switched on, the error monitor thread could reserve a mutex BEFORE the sync debug system was initialized, and that caused a sync debug assertion in startup: move the 2 sec. sleep to a safer place; note that this is only heuristics, and in theory it can assert still innobase/srv/srv0srv.c: If UNIV_SYNC_DEBUG was switched on, the error monitor thread could reserve a mutex BEFORE the sync debug system was initialized, and that caused a sync debug assertion in startup: move the 2 sec. sleep to a safer place; note that this is only heuristics, and in theory it can assert still innobase/srv/srv0start.c: If UNIV_SYNC_DEBUG was switched on, the error monitor thread could reserve a mutex BEFORE the sync debug system was initialized, and that caused a sync debug assertion in startup: move the 2 sec. sleep to a safer place; note that this is only heuristics, and in theory it can assert still --- innobase/srv/srv0srv.c | 4 ++-- innobase/srv/srv0start.c | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c index 027d7c8fb6e..d2368c5341f 100644 --- a/innobase/srv/srv0srv.c +++ b/innobase/srv/srv0srv.c @@ -2739,8 +2739,6 @@ loop: cnt++; - os_thread_sleep(2000000); - /* Try to track a strange bug reported by Harald Fuchs and others, where the lsn seems to decrease at times */ @@ -2782,6 +2780,8 @@ loop: fflush(stderr); fflush(stdout); + os_thread_sleep(2000000); + if (srv_shutdown_state < SRV_SHUTDOWN_LAST_PHASE) { goto loop; diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c index d7a14b8a9ec..e6fdc95fad0 100644 --- a/innobase/srv/srv0start.c +++ b/innobase/srv/srv0start.c @@ -1512,12 +1512,13 @@ NetWare. */ srv_is_being_started = FALSE; #ifdef UNIV_DEBUG - /* Wait a while so that creates threads have time to suspend themselves - before we switch sync debugging on; otherwise a thread may execute - mutex_enter() before the checks are on, and mutex_exit() after the - checks are on. */ + /* Wait a while so that the created threads have time to suspend + themselves before we switch sync debugging on; otherwise a thread may + execute mutex_enter() before the checks are on, and mutex_exit() after + the checks are on, which will cause an assertion failure in sync + debug. */ - os_thread_sleep(2000000); + os_thread_sleep(3000000); #endif sync_order_checks_on = TRUE; From 38a87d0eea0559101c683907db267d5cc1c7ef04 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Jan 2004 19:55:37 +0100 Subject: [PATCH 19/50] - link the mysql client RPM against libreadline instead of libedit (BUG 2289) support-files/mysql.spec.sh: - link the mysql client against libreadline instead of libedit (BUG 2289) --- support-files/mysql.spec.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 5a9fbf64b1c..1ee88096def 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -220,7 +220,8 @@ sh -c "PATH=\"${MYSQL_BUILD_PATH:-$PATH}\" \ --includedir=%{_includedir} \ --mandir=%{_mandir} \ --enable-thread-safe-client \ - --with-comment=\"Official MySQL RPM\"; + --with-comment=\"Official MySQL RPM\" \ + --with-readline ; # Add this for more debugging support # --with-debug # Add this for MyISAM RAID support: @@ -574,6 +575,10 @@ fi # The spec file changelog only includes changes made to the spec file # itself %changelog +* Tue Jan 13 2004 Lenz Grimmer + +- link the mysql client against libreadline instead of libedit (BUG 2289) + * Fri Dec 13 2003 Lenz Grimmer - fixed file permissions (BUG 1672) From 7eea262321ed50eba83fa3369c9071f48a1e4757 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jan 2004 04:58:37 +0200 Subject: [PATCH 20/50] - Added missing documentation to some mysql.cc options. - Fixed Bug#2346 - Fixed Bug#2378 - Fixed bug in pager (no Bug#ID (?)) - Added support for new special situations option type, GET_DISABLED. See handling of --debug in mysql.cc. compiled wihtout debugging, as an example. client/mysql.cc: - Added missing documentation to some options. - Fixed a bug in pager (no Bug#ID found (?)), but reported on internals list with subject "[PATCH] Fix pager problems in mysql client" - Fixed Bug#2346, "unique prefix is enough" option behaviour can be confusing with --debug include/my_getopt.h: Added new option type, GET_DISABLED. include/mysys_err.h: New exit code for my_getopt. mysys/my_getopt.c: - Added handling for GET_DISABLED option type (Fix for Bug#2346) - Fixed Bug#2378, "Problem with option abbreviation" --- client/mysql.cc | 72 +++++++++++++++++++++++++++++++-------------- include/my_getopt.h | 7 +++-- include/mysys_err.h | 1 + mysys/my_getopt.c | 29 ++++++++++++++++-- 4 files changed, 81 insertions(+), 28 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 2ce0d769924..46e15ebbbd3 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -44,7 +44,7 @@ #include #endif -const char *VER= "14.3"; +const char *VER= "14.4"; /* Don't try to make a nice table if the data is too big */ #define MAX_COLUMN_LENGTH 1024 @@ -134,7 +134,8 @@ static my_bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0, vertical=0, line_numbers=1, column_names=1,opt_html=0, opt_xml=0,opt_nopager=1, opt_outfile=0, named_cmds= 0, tty_password= 0, opt_nobeep=0, opt_reconnect=1, - default_charset_used= 0, opt_secure_auth= 0; + default_charset_used= 0, opt_secure_auth= 0, + default_pager_set= 0; static uint verbose=0,opt_silent=0,opt_mysql_port=0, opt_local_infile=0; static my_string opt_mysql_unix_port=0; static int connect_flag=CLIENT_INTERACTIVE; @@ -331,8 +332,11 @@ int main(int argc,char *argv[]) strmov(pager, "stdout"); // the default, if --pager wasn't given { char *tmp=getenv("PAGER"); - if (tmp) - strmov(default_pager,tmp); + if (tmp && strlen(tmp)) + { + default_pager_set= 1; + strmov(default_pager, tmp); + } } if (!isatty(0) || !isatty(1)) { @@ -467,6 +471,8 @@ static struct my_option my_long_options[] = { {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"help", 'I', "Synonym for -?", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, + 0, 0, 0, 0, 0}, {"auto-rehash", OPT_AUTO_REHASH, "Enable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time. Disable with --disable-auto-rehash.", (gptr*) &rehash, (gptr*) &rehash, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, @@ -484,8 +490,12 @@ static struct my_option my_long_options[] = {"compress", 'C', "Use compression in server/client protocol.", (gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, -#ifndef DBUG_OFF - {"debug", '#', "Output debug log.", (gptr*) &default_dbug_option, +#ifdef DBUG_OFF + {"debug", '#', "This is a non-debug version. Catch this and exit", + (gptr*) &default_dbug_option, + (gptr*) &default_dbug_option, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0}, +#else + {"debug", '#', "Output debug log", (gptr*) &default_dbug_option, (gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif {"database", 'D', "Database to use.", (gptr*) ¤t_db, @@ -608,19 +618,27 @@ static struct my_option my_long_options[] = GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"wait", 'w', "Wait and retry if connection is down.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"connect_timeout", OPT_CONNECT_TIMEOUT, "", (gptr*) &opt_connect_timeout, + {"connect_timeout", OPT_CONNECT_TIMEOUT, + "Number of seconds before connection timeout.", + (gptr*) &opt_connect_timeout, (gptr*) &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 3600*12, 0, 0, 1}, - {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, "", + {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, + "Max packet length to send to, or receive from server", (gptr*) &max_allowed_packet, (gptr*) &max_allowed_packet, 0, GET_ULONG, REQUIRED_ARG, 16 *1024L*1024L, 4096, (longlong) 2*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0}, - {"net_buffer_length", OPT_NET_BUFFER_LENGTH, "", + {"net_buffer_length", OPT_NET_BUFFER_LENGTH, + "Buffer for TCP/IP and socket communication", (gptr*) &net_buffer_length, (gptr*) &net_buffer_length, 0, GET_ULONG, REQUIRED_ARG, 16384, 1024, 512*1024*1024L, MALLOC_OVERHEAD, 1024, 0}, - {"select_limit", OPT_SELECT_LIMIT, "", (gptr*) &select_limit, + {"select_limit", OPT_SELECT_LIMIT, + "Automatic limit for SELECT when using --safe-updates", + (gptr*) &select_limit, (gptr*) &select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L, 1, ~0L, 0, 1, 0}, - {"max_join_size", OPT_MAX_JOIN_SIZE, "", (gptr*) &max_join_size, + {"max_join_size", OPT_MAX_JOIN_SIZE, + "Automatic limit for rows in a join when using --safe-updates", + (gptr*) &max_join_size, (gptr*) &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, 1, ~0L, 0, 1, 0}, {"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it" @@ -689,11 +707,16 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), else { opt_nopager= 0; - if (argument) + if (argument && strlen(argument)) + { + default_pager_set= 1; strmov(pager, argument); - else + strmov(default_pager, pager); + } + else if (default_pager_set) strmov(pager, default_pager); - strmov(default_pager, pager); + else + opt_nopager= 1; } break; case OPT_NOPAGER: @@ -814,6 +837,7 @@ static int get_options(int argc, char **argv) strmov(default_pager, "stdout"); strmov(pager, "stdout"); opt_nopager= 1; + default_pager_set= 0; opt_outfile= 0; opt_reconnect= 0; connect_flag= 0; /* Not in interactive mode */ @@ -2163,12 +2187,17 @@ com_pager(String *buffer, char *line __attribute__((unused))) if (status.batch) return 0; - /* Skip space from file name */ - while (my_isspace(charset_info,*line)) + /* Skip spaces in front of the pager command */ + while (my_isspace(charset_info, *line)) line++; - if (!(param= strchr(line, ' '))) // if pager was not given, use the default + /* Skip the pager command */ + param= strchr(line, ' '); + /* Skip the spaces between the command and the argument */ + while (param && my_isspace(charset_info, *param)) + param++; + if (!param || !strlen(param)) // if pager was not given, use the default { - if (!default_pager[0]) + if (!default_pager_set) { tee_fprintf(stdout, "Default pager wasn't set, using stdout.\n"); opt_nopager=1; @@ -2180,9 +2209,7 @@ com_pager(String *buffer, char *line __attribute__((unused))) } else { - while (my_isspace(charset_info,*param)) - param++; - end=strmake(pager_name, param, sizeof(pager_name)-1); + end= strmake(pager_name, param, sizeof(pager_name)-1); while (end > pager_name && (my_isspace(charset_info,end[-1]) || my_iscntrl(charset_info,end[-1]))) end--; @@ -2191,7 +2218,7 @@ com_pager(String *buffer, char *line __attribute__((unused))) strmov(default_pager, pager_name); } opt_nopager=0; - tee_fprintf(stdout, "PAGER set to %s\n", pager); + tee_fprintf(stdout, "PAGER set to '%s'\n", pager); return 0; } @@ -2202,6 +2229,7 @@ com_nopager(String *buffer __attribute__((unused)), { strmov(pager, "stdout"); opt_nopager=1; + PAGER= stdout; tee_fprintf(stdout, "PAGER set to stdout\n"); return 0; } diff --git a/include/my_getopt.h b/include/my_getopt.h index 148238f8d1b..5f4025efa0e 100644 --- a/include/my_getopt.h +++ b/include/my_getopt.h @@ -17,11 +17,12 @@ C_MODE_START enum get_opt_var_type { GET_NO_ARG, GET_BOOL, GET_INT, GET_UINT, GET_LONG, - GET_ULONG, GET_LL, GET_ULL, GET_STR, GET_STR_ALLOC + GET_ULONG, GET_LL, GET_ULL, GET_STR, GET_STR_ALLOC, + GET_DISABLED }; -#define GET_ASK_ADDR 128 -#define GET_TYPE_MASK 127 +#define GET_ASK_ADDR 128 +#define GET_TYPE_MASK 127 enum get_opt_arg_type { NO_ARG, OPT_ARG, REQUIRED_ARG }; diff --git a/include/mysys_err.h b/include/mysys_err.h index 0ee89e91ee4..230be5f4720 100644 --- a/include/mysys_err.h +++ b/include/mysys_err.h @@ -68,6 +68,7 @@ extern const char * NEAR globerrs[]; /* my_error_messages is here */ #define EXIT_UNKNOWN_SUFFIX 9 #define EXIT_NO_PTR_TO_VARIABLE 10 #define EXIT_CANNOT_CONNECT_TO_SERVICE 11 +#define EXIT_OPTION_DISABLED 12 #ifdef __cplusplus diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 76f8f6bf852..b278eaa36e1 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -285,6 +285,19 @@ int handle_options(int *argc, char ***argv, return EXIT_AMBIGUOUS_OPTION; } } + if ((optp->var_type & GET_TYPE_MASK) == GET_DISABLED) + { + if (my_getopt_print_errors) + fprintf(stderr, + "%s: %s: Option '%s' used, but is disabled\n", my_progname, + option_is_loose ? "WARNING" : "ERROR", opt_str); + if (option_is_loose) + { + (*argc)--; + continue; + } + return EXIT_OPTION_DISABLED; + } if (must_be_var && (optp->var_type & GET_TYPE_MASK) == GET_NO_ARG) { if (my_getopt_print_errors) @@ -358,6 +371,14 @@ int handle_options(int *argc, char ***argv, { /* Option recognized. Find next what to do with it */ opt_found= 1; + if ((optp->var_type & GET_TYPE_MASK) == GET_DISABLED) + { + if (my_getopt_print_errors) + fprintf(stderr, + "%s: ERROR: Option '-%c' used, but is disabled\n", + my_progname, optp->id); + return EXIT_OPTION_DISABLED; + } if ((optp->var_type & GET_TYPE_MASK) == GET_BOOL && optp->arg_type == NO_ARG) { @@ -550,7 +571,7 @@ static int findopt(char *optpat, uint length, const struct my_option **opt_res, char **ffname) { - int count; + uint count; struct my_option *opt= (struct my_option *) *opt_res; for (count= 0; opt->name; opt++) @@ -562,7 +583,8 @@ static int findopt(char *optpat, uint length, *ffname= (char *) opt->name; /* We only need to know one prev */ if (!opt->name[length]) /* Exact match */ return 1; - count++; + if (!count || strcmp(*ffname, opt->name)) /* Don't count synonyms */ + count++; } } return count; @@ -882,7 +904,8 @@ void my_print_variables(const struct my_option *options) longlong2str(*((ulonglong*) value), buff, 10); printf("%s\n", buff); break; - default: /* dummy default to avoid compiler warnings */ + default: + printf("(Disabled)\n"); break; } } From c6863b04e0dc05114dcd3b63361e1f114612b121 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jan 2004 14:02:51 +0400 Subject: [PATCH 21/50] item_strfunc.cc: Comment typo fix , sql/item_strfunc.cc: Comment typo fix , --- sql/item_strfunc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 528345beb77..45b2b7455f9 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -979,7 +979,7 @@ String *Item_func_right::val_str(String *str) As far "res" contains at least "length" bytes (according to the above condition and return), the below statement is safe. res->numchars() can - never return a value less than "length". + never return a value more than "length". */ uint start=res->numchars()-(uint) length; start=res->charpos(start); From cbc748899635d8a564fc2c3cce9eee04edc1cd73 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jan 2004 11:52:25 +0100 Subject: [PATCH 22/50] bugs #2280, #2281 - show create table should always return a valid sql statement --- sql/sql_show.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 52f7e6cb9ed..ab761ad761d 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -997,6 +997,19 @@ mysqld_dump_create_info(THD *thd, TABLE *table, int fd) DBUG_RETURN(0); } +/* possible TODO: call find_keyword() from sql_lex.cc here */ +static bool require_quotes(const char *name, uint length) +{ + uint i, d, c; + for (i=0; iident_map[c]) + return 1; + } + return 0; +} void append_identifier(THD *thd, String *packet, const char *name, uint length) @@ -1007,7 +1020,8 @@ append_identifier(THD *thd, String *packet, const char *name, uint length) else qtype= '`'; - if (thd->options & OPTION_QUOTE_SHOW_CREATE) + if ((thd->options & OPTION_QUOTE_SHOW_CREATE) || + require_quotes(name, length)) { packet->append(&qtype, 1); packet->append(name, length, system_charset_info); From fd7d543adc6ee48e6dd79e6da6f3656b5dc13501 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jan 2004 12:29:30 +0100 Subject: [PATCH 23/50] show create tests --- mysql-test/r/show_check.result | 25 +++++++++++++++++++++---- mysql-test/t/show_check.test | 9 +++++++-- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index f39fa3e7576..290f916ae72 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -88,20 +88,37 @@ drop table t2; create table t1 ( test_set set( 'val1', 'val2', 'val3' ) not null default '', name char(20) default 'O''Brien' comment 'O''Brien as default', -c int not null comment 'int column' - ) comment = 'it\'s a table' ; -show create table t1 ; +c int not null comment 'int column', +`c-b` int comment 'name with a space', +`space ` int comment 'name with a space', +) comment = 'it\'s a table' ; +show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `test_set` set('val1','val2','val3') NOT NULL default '', `name` char(20) default 'O''Brien' COMMENT 'O''Brien as default', - `c` int(11) NOT NULL default '0' COMMENT 'int column' + `c` int(11) NOT NULL default '0' COMMENT 'int column', + `c-b` int(11) default NULL COMMENT 'name with a space', + `space ` int(11) default NULL COMMENT 'name with a space' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='it''s a table' +set sql_quote_show_create=0; +show create table t1; +Table Create Table +t1 CREATE TABLE t1 ( + test_set set('val1','val2','val3') NOT NULL default '', + name char(20) default 'O''Brien' COMMENT 'O''Brien as default', + c int(11) NOT NULL default '0' COMMENT 'int column', + `c-b` int(11) default NULL COMMENT 'name with a space', + `space ` int(11) default NULL COMMENT 'name with a space' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='it''s a table' +set sql_quote_show_create=1; show full columns from t1; Field Type Collation Null Key Default Extra Privileges Comment test_set set('val1','val2','val3') latin1_swedish_ci select,insert,update,references name char(20) latin1_swedish_ci YES O'Brien select,insert,update,references O'Brien as default c int(11) NULL 0 select,insert,update,references int column +c-b int(11) NULL YES NULL select,insert,update,references name with a space +space int(11) NULL YES NULL select,insert,update,references name with a space drop table t1; create table t1 (a int not null, unique aa (a)); show create table t1; diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test index 4ab39e3ccbc..d262f02c978 100644 --- a/mysql-test/t/show_check.test +++ b/mysql-test/t/show_check.test @@ -53,9 +53,14 @@ drop table t2; create table t1 ( test_set set( 'val1', 'val2', 'val3' ) not null default '', name char(20) default 'O''Brien' comment 'O''Brien as default', - c int not null comment 'int column' + c int not null comment 'int column', + `c-b` int comment 'name with a space', + `space ` int comment 'name with a space', ) comment = 'it\'s a table' ; -show create table t1 ; +show create table t1; +set sql_quote_show_create=0; +show create table t1; +set sql_quote_show_create=1; show full columns from t1; drop table t1; From 13cf5e6b0ae32d25d4f6d13928ce5766ba0e2f50 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jan 2004 16:01:55 +0400 Subject: [PATCH 24/50] fix for the 2361 bug: ALTER TABLE ... DROP PRIMARY KEY drops a non-primary key "PRIMARY" has been replaced by primary_key_name. sql/mysql_priv.h: "PRIMARY" replaced by primary_key_name. sql/sql_help.cc: "PRIMARY" replaced by primary_key_name. sql/sql_select.cc: "PRIMARY" replaced by primary_key_name. sql/sql_show.cc: "PRIMARY" replaced by primary_key_name. sql/sql_table.cc: fix for the 2361 bug: ALTER TABLE ... DROP PRIMARY KEY drops a non-primary key "PRIMARY" replaced by primary_key_name. sql/table.cc: "PRIMARY" replaced by primary_key_name. --- sql/mysql_priv.h | 1 + sql/sql_help.cc | 4 ++-- sql/sql_select.cc | 8 ++++---- sql/sql_show.cc | 2 +- sql/sql_table.cc | 8 ++++---- sql/table.cc | 4 ++-- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 15a99385285..a277e06301b 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -38,6 +38,7 @@ typedef ulong key_part_map; /* Used for finding key parts */ /* useful constants */ extern const key_map key_map_empty; extern const key_map key_map_full; +extern const char *primary_key_name; #include "mysql_com.h" #include diff --git a/sql/sql_help.cc b/sql/sql_help.cc index c40133c04a8..d5516fe3337 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -274,9 +274,9 @@ int get_topics_for_keyword(THD *thd, TABLE *topics, TABLE *relations, DBUG_ENTER("get_topics_for_keyword"); - if ((iindex_topic= find_type((char*) "PRIMARY", + if ((iindex_topic= find_type((char*) primary_key_name, &topics->keynames, 1+2)-1)<0 || - (iindex_relations= find_type((char*) "PRIMARY", + (iindex_relations= find_type((char*) primary_key_name, &relations->keynames, 1+2)-1)<0) { send_error(thd,ER_CORRUPT_HELP_DB); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index a1f6abfd53a..1b03a70c43d 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -9130,16 +9130,16 @@ int mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result) { res= mysql_explain_select(thd, sl, (((&thd->lex->select_lex)==sl)? - ((thd->lex->all_selects_list != sl)?"PRIMARY": - "SIMPLE"): + ((thd->lex->all_selects_list != sl) ? + primary_key_name : "SIMPLE"): ((sl == first)? ((sl->linkage == DERIVED_TABLE_TYPE) ? "DERIVED": - ((sl->uncacheable & UNCACHEABLE_DEPENDENT)? + ((sl->uncacheable & UNCACHEABLE_DEPENDENT) ? "DEPENDENT SUBQUERY": (sl->uncacheable?"UNCACHEABLE SUBQUERY": "SUBQUERY"))): - ((sl->uncacheable & UNCACHEABLE_DEPENDENT)? + ((sl->uncacheable & UNCACHEABLE_DEPENDENT) ? "DEPENDENT UNION": sl->uncacheable?"UNCACHEABLE UNION": "UNION"))), diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 52f7e6cb9ed..984d57fc354 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1167,7 +1167,7 @@ store_create_info(THD *thd, TABLE *table, String *packet) bool found_primary=0; packet->append(",\n ", 4); - if (i == primary_key && !strcmp(key_info->name,"PRIMARY")) + if (i == primary_key && !strcmp(key_info->name, primary_key_name)) { found_primary=1; packet->append("PRIMARY ", 8); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index be42de34899..413fb77d929 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -29,7 +29,7 @@ #include #endif -static const char *primary_key_name="PRIMARY"; +const char *primary_key_name= "PRIMARY"; static bool check_if_keyname_exists(const char *name,KEY *start, KEY *end); static char *make_unique_key_name(const char *field_name,KEY *start,KEY *end); @@ -2244,8 +2244,8 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, { char *key_name= key_info->name; - if (drop_primary && !my_strcasecmp(system_charset_info, key_name, - "PRIMARY")) + if (drop_primary && (key_info-> flags & HA_NOSAME) && + !my_strcasecmp(system_charset_info, key_name, primary_key_name)) { drop_primary= 0; continue; @@ -2305,7 +2305,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, key_list.push_back(new Key(key_info->flags & HA_SPATIAL ? Key::SPATIAL : (key_info->flags & HA_NOSAME ? (!my_strcasecmp(system_charset_info, - key_name, "PRIMARY") ? + key_name, primary_key_name) ? Key::PRIMARY : Key::UNIQUE) : (key_info->flags & HA_FULLTEXT ? Key::FULLTEXT : Key::MULTIPLE)), diff --git a/sql/table.cc b/sql/table.cc index 912c133e571..1127349db20 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -481,8 +481,8 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, /* Fix key->name and key_part->field */ if (key_parts) { - uint primary_key=(uint) (find_type((char*) "PRIMARY",&outparam->keynames, - 3)-1); + uint primary_key=(uint) (find_type((char*) primary_key_name, + &outparam->keynames, 3) - 1); uint ha_option=outparam->file->table_flags(); keyinfo=outparam->key_info; key_part=keyinfo->key_part; From 6eaa5c3a66adc7cbe152a8791b3ad560c3a936f5 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jan 2004 15:15:42 +0200 Subject: [PATCH 25/50] assigned correct lex->current_select for derived tables (BUG#2349) moved LIMIT initialialization, because it is need only for single select derived table mysql-test/r/derived.result: test suite for BUG#2349 mysql-test/t/derived.test: test suite for BUG#2349 sql/sql_derived.cc: assigned correct lex->current_select (BUG#2349) moved LIMIT initialialization, because it is need only for single select --- mysql-test/r/derived.result | 28 ++++++++++++++++++++++++++++ mysql-test/t/derived.test | 26 ++++++++++++++++++++++++++ sql/sql_derived.cc | 19 +++++++++++-------- 3 files changed, 65 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index bb268cd1094..9b5aa9123a4 100644 --- a/mysql-test/r/derived.result +++ b/mysql-test/r/derived.result @@ -245,3 +245,31 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DERIVED t1 ALL NULL NULL NULL NULL 2 3 UNION t1 ALL NULL NULL NULL NULL 2 drop table t1; +CREATE TABLE t1 ( +OBJECTID int(11) NOT NULL default '0', +SORTORDER int(11) NOT NULL auto_increment, +KEY t1_SortIndex (SORTORDER), +KEY t1_IdIndex (OBJECTID) +) TYPE=MyISAM DEFAULT CHARSET=latin1; +Warnings: +Warning 1286 'TYPE=database_engine' is deprecated. Use 'ENGINE=database_engine' instead. +CREATE TABLE t2 ( +ID int(11) default NULL, +PARID int(11) default NULL, +UNIQUE KEY t2_ID_IDX (ID), +KEY t2_PARID_IDX (PARID) +) TYPE=MyISAM DEFAULT CHARSET=latin1; +Warnings: +Warning 1286 'TYPE=database_engine' is deprecated. Use 'ENGINE=database_engine' instead. +INSERT INTO t2 VALUES (1000,0),(1001,0),(1002,0),(1003,0),(1008,1),(1009,1),(1010,1),(1011,1),(1016,2); +CREATE TABLE t3 ( +ID int(11) default NULL, +DATA decimal(10,2) default NULL, +UNIQUE KEY t3_ID_IDX (ID) +) TYPE=MyISAM DEFAULT CHARSET=latin1; +Warnings: +Warning 1286 'TYPE=database_engine' is deprecated. Use 'ENGINE=database_engine' instead. +INSERT INTO t3 VALUES (1000,0.00),(1001,0.25),(1002,0.50),(1003,0.75),(1008,1.00),(1009,1.25),(1010,1.50),(1011,1.75); +select 497, TMP.ID, NULL from (select 497 as ID, MAX(t3.DATA) as DATA from t1 join t2 on (t1.ObjectID = t2.ID) join t3 on (t1.ObjectID = t3.ID) group by t2.ParID order by DATA DESC) as TMP; +497 ID NULL +drop table t1, t2, t3; diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index caf673d95c1..bb61dab6d74 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -138,3 +138,29 @@ insert into t1 values (1),(2); select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b; explain select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b; drop table t1; + + +# +# correct lex->current_select +# +CREATE TABLE t1 ( + OBJECTID int(11) NOT NULL default '0', + SORTORDER int(11) NOT NULL auto_increment, + KEY t1_SortIndex (SORTORDER), + KEY t1_IdIndex (OBJECTID) +) TYPE=MyISAM DEFAULT CHARSET=latin1; +CREATE TABLE t2 ( + ID int(11) default NULL, + PARID int(11) default NULL, + UNIQUE KEY t2_ID_IDX (ID), + KEY t2_PARID_IDX (PARID) +) TYPE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t2 VALUES (1000,0),(1001,0),(1002,0),(1003,0),(1008,1),(1009,1),(1010,1),(1011,1),(1016,2); +CREATE TABLE t3 ( + ID int(11) default NULL, + DATA decimal(10,2) default NULL, + UNIQUE KEY t3_ID_IDX (ID) +) TYPE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES (1000,0.00),(1001,0.25),(1002,0.50),(1003,0.75),(1008,1.00),(1009,1.25),(1010,1.50),(1011,1.75); +select 497, TMP.ID, NULL from (select 497 as ID, MAX(t3.DATA) as DATA from t1 join t2 on (t1.ObjectID = t2.ID) join t3 on (t1.ObjectID = t3.ID) group by t2.ParID order by DATA DESC) as TMP; +drop table t1, t2, t3; diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index e8f1c5d87de..8c0fcb7f4c3 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -146,17 +146,19 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, } derived_result->set_table(table); - unit->offset_limit_cnt= first_select->offset_limit; - unit->select_limit_cnt= first_select->select_limit+ - first_select->offset_limit; - if (unit->select_limit_cnt < first_select->select_limit) - unit->select_limit_cnt= HA_POS_ERROR; - if (unit->select_limit_cnt == HA_POS_ERROR) - first_select->options&= ~OPTION_FOUND_ROWS; - if (is_union) res= mysql_union(thd, lex, derived_result, unit); else + { + unit->offset_limit_cnt= first_select->offset_limit; + unit->select_limit_cnt= first_select->select_limit+ + first_select->offset_limit; + if (unit->select_limit_cnt < first_select->select_limit) + unit->select_limit_cnt= HA_POS_ERROR; + if (unit->select_limit_cnt == HA_POS_ERROR) + first_select->options&= ~OPTION_FOUND_ROWS; + + lex->current_select= first_select; res= mysql_select(thd, &first_select->ref_pointer_array, (TABLE_LIST*) first_select->table_list.first, first_select->with_wild, @@ -169,6 +171,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, (first_select->options | thd->options | SELECT_NO_UNLOCK), derived_result, unit, first_select); + } if (!res) { From 502a9efbcf4e4d9a4db314fcf305e8cedabd18c4 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jan 2004 17:26:30 +0400 Subject: [PATCH 26/50] item_strfunc.cc: We don't need to copy if start is 0, we can return the original value. sql/item_strfunc.cc: We don't need to copy if start is 0, we can return the original value. --- sql/item_strfunc.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 45b2b7455f9..f810afa3cfa 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -982,6 +982,8 @@ String *Item_func_right::val_str(String *str) never return a value more than "length". */ uint start=res->numchars()-(uint) length; + if (!start) + return res; start=res->charpos(start); tmp_value.set(*res,start,res->length()-start); return &tmp_value; From e9322b891adb41b78d907072776bdd365e6fd54c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jan 2004 16:42:08 +0100 Subject: [PATCH 27/50] compilation error fixed --- client/mysql.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 46e15ebbbd3..59872a83506 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -492,8 +492,7 @@ static struct my_option my_long_options[] = 0, 0, 0}, #ifdef DBUG_OFF {"debug", '#', "This is a non-debug version. Catch this and exit", - (gptr*) &default_dbug_option, - (gptr*) &default_dbug_option, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0}, + 0,0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0}, #else {"debug", '#', "Output debug log", (gptr*) &default_dbug_option, (gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, From 4d53f9961c54ae4e186050a0aa8272a216b7e877 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jan 2004 17:48:38 +0200 Subject: [PATCH 28/50] Fixed a non-debug version compilation error and warning. --- client/mysql.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 46e15ebbbd3..010233b5b6e 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -174,9 +174,7 @@ static CHARSET_INFO *charset_info= &my_charset_latin1; #include "sslopt-vars.h" -#ifndef DBUG_OFF const char *default_dbug_option="d:t:o,/tmp/mysql.trace"; -#endif void tee_fprintf(FILE *file, const char *fmt, ...); void tee_fputs(const char *s, FILE *file); @@ -1559,7 +1557,7 @@ static int com_server_help(String *buffer __attribute__((unused)), init_pager(); char last_char; - int num_name, num_cat; + int num_name= 0, num_cat= 0; LINT_INIT(num_name); LINT_INIT(num_cat); From f9bec44af107fec1ececea47a76f085b5af87464 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Jan 2004 04:00:21 +0200 Subject: [PATCH 29/50] Added handling for ; comment character as there was for #. Bug#2080 --- mysys/default.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysys/default.c b/mysys/default.c index 3a751eb4e29..d9099a9e505 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -461,7 +461,7 @@ static char *remove_end_comment(char *ptr) else if (quote == *ptr) quote= 0; } - if (!quote && *ptr == '#') /* We are not inside a comment */ + if (!quote && (*ptr == '#' || *ptr == ';')) // We are not inside a comment { *ptr= 0; return ptr; From 3ad098661aa69f7f6be36cd0c54ee44ee21cbe74 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Jan 2004 04:26:57 +0200 Subject: [PATCH 30/50] Fixed Bug#2281, --quote is now enabled by default. Can be disabled with --disable-quote Added --compatible=ansi mode. Fixed a non-reported bug in compatible mode; there was a check for /*!41000 */ at this part of the code, while it obviously should have been /*!40100 */. So the mysqldump compatiple mode made for 4.0.1 will not work until 4.10 or later server is released :P Fixed into 4.0.2. client/mysqldump.c: Fixed Bug#2281, --quote is now enabled by default. Can be disabled with --disable-quote Added --compatible=ansi mode. Changed sapdb into maxdb, as this change has been made to server too. Fixed a non-reported bug in compatible mode; there was a check for /*!41000 */ at this part of the code, while it obviously should have been /*!40100 */. So the mysqldump compatiple mode made for 4.1.0 will not work until 4.10.0 or later server is released :P Fixed into 4.1.2. --- client/mysqldump.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 018cd43ce87..921ffbaab5b 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -37,7 +37,7 @@ ** 10 Jun 2003: SET NAMES and --no-set-names by Alexander Barkov */ -#define DUMP_VERSION "10.4" +#define DUMP_VERSION "10.5" #include #include @@ -107,7 +107,8 @@ static CHARSET_INFO *charset_info= &my_charset_latin1; const char *compatible_mode_names[]= { "MYSQL323", "MYSQL40", "POSTGRESQL", "ORACLE", "MSSQL", "DB2", - "SAPDB", "NO_KEY_OPTIONS", "NO_TABLE_OPTIONS", "NO_FIELD_OPTIONS", + "MAXDB", "NO_KEY_OPTIONS", "NO_TABLE_OPTIONS", "NO_FIELD_OPTIONS", + "ANSI", NullS }; TYPELIB compatible_mode_typelib= {array_elements(compatible_mode_names) - 1, @@ -136,7 +137,7 @@ static struct my_option my_long_options[] = "Directory where character sets are.", (gptr*) &charsets_dir, (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"compatible", OPT_COMPATIBLE, - "Change the dump to be compatible with a given mode. By default tables are dumped without any restrictions. Legal modes are: mysql323, mysql40, postgresql, oracle, mssql, db2, sapdb, no_key_options, no_table_options, no_field_options. One can use several modes separated by commas. Note: Requires MySQL server version 4.1.0 or higher. This option does a no operation on earlier server versions.", + "Change the dump to be compatible with a given mode. By default tables are dumped without any restrictions. Legal modes are: ansi, mysql323, mysql40, postgresql, oracle, mssql, db2, maxdb, no_key_options, no_table_options, no_field_options. One can use several modes separated by commas. Note: Requires MySQL server version 4.1.0 or higher. This option does a no operation on earlier server versions.", (gptr*) &opt_compatible_mode_str, (gptr*) &opt_compatible_mode_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"complete-insert", 'c', "Use complete insert statements.", (gptr*) &cFlag, @@ -239,7 +240,7 @@ static struct my_option my_long_options[] = {"quick", 'q', "Don't buffer query, dump directly to stdout.", (gptr*) &quick, (gptr*) &quick, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"quote-names",'Q', "Quote table and column names with backticks (`).", - (gptr*) &opt_quoted, (gptr*) &opt_quoted, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, + (gptr*) &opt_quoted, (gptr*) &opt_quoted, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"result-file", 'r', "Direct output to a given file. This option should be used in MSDOS, because it prevents new line '\\n' from being converted to '\\r\\n' (carriage return + line feed).", @@ -830,7 +831,7 @@ static uint getTableStructure(char *table, char* db) char *end; uint i; - sprintf(buff, "/*!41000 SET @@sql_mode=\""); + sprintf(buff, "/*!40100 SET @@sql_mode=\""); end= strend(buff); for (i= 0; opt_compatible_mode; opt_compatible_mode>>= 1, i++) { From 484cf319c541e3fe49b667dff41099df30a0f947 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Jan 2004 06:48:31 +0200 Subject: [PATCH 31/50] Fixed Bug#2123, mysqld segmentation faulted when it tried to open a file that already existed. The problem was that end_io_cache() was called even if init_io_cache() was not. This affected both OUTFILE and DUMPFILE (both fixed). Sometimes wrongly aligned pointer was freed, sometimes mysqld core dumped. Other problem was that select_dump::send_error removed the dumpfile, even if it was created by an earlier run, or by some other program, if the file permissions just permitted it. Fixed it so that the file will only be deleted, if an error occurred, but the file was created by mysqld just a moment ago, in that thread. On the other hand, select_export did not handle the corresponding garbage file at all. Both fixed. After these fixes, a big part of the select_export::prepare and select_dump::prepare code became identical. Merged the code into a new function called create_file(), which is now called by the two latter functions. Regards, Jani mysys/mf_iocache.c: Fixed a bug in comment. --- mysys/mf_iocache.c | 4 +-- sql/sql_class.cc | 77 +++++++++++++++++++--------------------------- 2 files changed, 34 insertions(+), 47 deletions(-) diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index b5c80d9482f..1dd3108e151 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -1175,8 +1175,8 @@ int _flush_io_cache(IO_CACHE *info, int need_append_buffer_lock) info IO_CACHE Handle to free NOTES - It's currently safe to call this if one has called io_cache_init() - on the 'info' object, even if io_cache_init() failed. + It's currently safe to call this if one has called init_io_cache() + on the 'info' object, even if init_io_cache() failed. This function is also safe to call twice with the same handle. RETURN diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 89b812eb205..696744953dc 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -695,39 +695,53 @@ select_export::~select_export() thd->sent_row_count=row_count; } -int -select_export::prepare(List &list, SELECT_LEX_UNIT *u) + +static int create_file(THD *thd, char *path, sql_exchange *exchange, + File *file, IO_CACHE *cache) { - char path[FN_REFLEN]; - uint option=4; - bool blob_flag=0; - unit= u; + uint option= 4; + #ifdef DONT_ALLOW_FULL_LOAD_DATA_PATHS - option|=1; // Force use of db directory + option|= 1; // Force use of db directory #endif - if ((uint) strlen(exchange->file_name) + NAME_LEN >= FN_REFLEN) - strmake(path,exchange->file_name,FN_REFLEN-1); - (void) fn_format(path,exchange->file_name, thd->db ? thd->db : "", "", + (void) fn_format(path, exchange->file_name, thd->db ? thd->db : "", "", option); - if (!access(path,F_OK)) + if (!access(path, F_OK)) { my_error(ER_FILE_EXISTS_ERROR, MYF(0), exchange->file_name); return 1; } /* Create the file world readable */ - if ((file=my_create(path, 0666, O_WRONLY, MYF(MY_WME))) < 0) + if ((*file= my_create(path, 0666, O_WRONLY, MYF(MY_WME))) < 0) return 1; #ifdef HAVE_FCHMOD - (void) fchmod(file,0666); // Because of umask() + (void) fchmod(*file, 0666); // Because of umask() #else - (void) chmod(path,0666); + (void) chmod(path, 0666); #endif - if (init_io_cache(&cache,file,0L,WRITE_CACHE,0L,1,MYF(MY_WME))) + if (init_io_cache(cache, *file, 0L, WRITE_CACHE, 0L, 1, MYF(MY_WME))) { - my_close(file,MYF(0)); - file= -1; + my_close(*file, MYF(0)); + my_delete(path, MYF(0)); // Delete file on error, it was just created + *file= -1; + end_io_cache(cache); return 1; } + return 0; +} + + +int +select_export::prepare(List &list, SELECT_LEX_UNIT *u) +{ + char path[FN_REFLEN]; + bool blob_flag=0; + unit= u; + if ((uint) strlen(exchange->file_name) + NAME_LEN >= FN_REFLEN) + strmake(path,exchange->file_name,FN_REFLEN-1); + + if (create_file(thd, path, exchange, &file, &cache)) + return 1; /* Check if there is any blobs in data */ { List_iterator_fast li(list); @@ -901,7 +915,6 @@ err: void select_export::send_error(uint errcode, const char *err) { ::send_error(thd,errcode,err); - (void) end_io_cache(&cache); (void) my_close(file,MYF(0)); file= -1; } @@ -938,33 +951,9 @@ int select_dump::prepare(List &list __attribute__((unused)), SELECT_LEX_UNIT *u) { - uint option=4; unit= u; -#ifdef DONT_ALLOW_FULL_LOAD_DATA_PATHS - option|=1; // Force use of db directory -#endif - (void) fn_format(path,exchange->file_name, thd->db ? thd->db : "", "", - option); - if (!access(path,F_OK)) - { - my_error(ER_FILE_EXISTS_ERROR,MYF(0),exchange->file_name); + if (create_file(thd, path, exchange, &file, &cache)) return 1; - } - /* Create the file world readable */ - if ((file=my_create(path, 0666, O_WRONLY, MYF(MY_WME))) < 0) - return 1; -#ifdef HAVE_FCHMOD - (void) fchmod(file,0666); // Because of umask() -#else - (void) chmod(path,0666); -#endif - if (init_io_cache(&cache,file,0L,WRITE_CACHE,0L,1,MYF(MY_WME))) - { - my_close(file,MYF(0)); - my_delete(path,MYF(0)); - file= -1; - return 1; - } return 0; } @@ -1011,9 +1000,7 @@ err: void select_dump::send_error(uint errcode,const char *err) { ::send_error(thd,errcode,err); - (void) end_io_cache(&cache); (void) my_close(file,MYF(0)); - (void) my_delete(path,MYF(0)); // Delete file on error file= -1; } From 4239d4b24f281f9f5c2d21a622b616ac711f9f2e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Jan 2004 12:12:55 +0400 Subject: [PATCH 32/50] item_strfunc.cc: Unnesessary copying was fixed sql/item_strfunc.cc: Unnesessary copying was fixed --- sql/item_strfunc.cc | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index f810afa3cfa..3b67fd371a4 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -975,16 +975,10 @@ String *Item_func_right::val_str(String *str) if (res->length() <= (uint) length) return res; /* purecov: inspected */ - /* - As far "res" contains at least "length" bytes - (according to the above condition and return), - the below statement is safe. res->numchars() can - never return a value more than "length". - */ - uint start=res->numchars()-(uint) length; - if (!start) + uint start=res->numchars(); + if (start <= (uint) length) return res; - start=res->charpos(start); + start=res->charpos(start - (uint) length); tmp_value.set(*res,start,res->length()-start); return &tmp_value; } From fd427c063da5d5b3843120ad76f02cfd823c8d22 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Jan 2004 13:27:20 +0400 Subject: [PATCH 33/50] Fic for Bug 2367: INSERT() behaviour is different for different charsets. --- mysql-test/r/ctype_ucs.result | 6 ++++++ mysql-test/r/ctype_utf8.result | 6 ++++++ mysql-test/t/ctype_ucs.test | 7 ++++++- mysql-test/t/ctype_utf8.test | 6 ++++++ strings/ctype-mb.c | 2 +- 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index 2f6dc0c23ca..58761526150 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -173,6 +173,12 @@ SELECT * FROM t1 WHERE word LIKE _ucs2 x'00630061005F'; word cat DROP TABLE t1; +select insert(_ucs2 0x006100620063,10,2,_ucs2 0x006400650066); +insert(_ucs2 0x006100620063,10,2,_ucs2 0x006400650066) +abc +select insert(_ucs2 0x006100620063,1,2,_ucs2 0x006400650066); +insert(_ucs2 0x006100620063,1,2,_ucs2 0x006400650066) +defc SET NAMES latin1; CREATE TABLE t1 ( word VARCHAR(64), diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 1aef43cd570..16c65619878 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -62,3 +62,9 @@ select 'A' like 'a' collate utf8_bin; select _utf8 0xD0B0D0B1D0B2 like concat(_utf8'%',_utf8 0xD0B1,_utf8 '%'); _utf8 0xD0B0D0B1D0B2 like concat(_utf8'%',_utf8 0xD0B1,_utf8 '%') 1 +select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es'); +insert('txs',2,1,'hi') insert('is ',4,0,'a') insert('txxxxt',2,4,'es') +this is a test +select insert("aa",100,1,"b"),insert("aa",1,3,"b"); +insert("aa",100,1,"b") insert("aa",1,3,"b") +aa b diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index 90b423cd1e0..7eec58563b3 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -93,6 +93,12 @@ SELECT * FROM t1 WHERE word LIKE _ucs2 x'00630025'; SELECT * FROM t1 WHERE word LIKE _ucs2 x'00630061005F'; DROP TABLE t1; +# +# Check that INSERT works fine. +# This invokes charpos() function. +select insert(_ucs2 0x006100620063,10,2,_ucs2 0x006400650066); +select insert(_ucs2 0x006100620063,1,2,_ucs2 0x006400650066); + ###################################################### # @@ -191,4 +197,3 @@ DROP TABLE t1; # END OF Bug 1264 test # ######################################################## - diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 54d934b66db..5c924e82729 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -35,3 +35,9 @@ select _utf8 0xD0B0D0B1D0B2 like concat(_utf8'%',_utf8 0xD0B1,_utf8 '%'); # #select _utf8 0xD0B0D0B1D0B2 like concat(_utf8'%',_utf8 0xD091,_utf8 '%'); # + +# +# Bug 2367: INSERT() behaviour is different for different charsets. +# +select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es'); +select insert("aa",100,1,"b"),insert("aa",1,3,"b"); diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index 271c56b8a0a..b5e8c4598a0 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -271,7 +271,7 @@ uint my_charpos_mb(CHARSET_INFO *cs __attribute__((unused)), b+= (mblen= my_ismbchar(cs,b,e)) ? mblen : 1; pos--; } - return b-b0; + return pos ? e+2-b0 : b-b0; } uint my_instr_mb(CHARSET_INFO *cs, From 5dcab209c2ff1fa64b9aaffb38a622ac841dab39 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Jan 2004 15:58:06 +0400 Subject: [PATCH 34/50] field.cc: http://bugs.mysql.com/bug.php?id=2218 updating utf-8 text field generate nonsense chars Fix for the above bug. sql/field.cc: http://bugs.mysql.com/bug.php?id=2218 updating utf-8 text field generate nonsense chars Fix for the above bug. --- sql/field.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sql/field.cc b/sql/field.cc index a9029b893e3..5602231dd9b 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4567,17 +4567,19 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs) } else { + bool was_conversion; char buff[80]; String tmpstr(buff,sizeof(buff), &my_charset_bin); + /* Convert character set if nesessary */ - if (use_conversion(cs, field_charset)) + if ((was_conversion= use_conversion(cs, field_charset))) { tmpstr.copy(from, length, cs, field_charset); from= tmpstr.ptr(); length= tmpstr.length(); } Field_blob::store_length(length); - if (table->copy_blobs || length <= MAX_FIELD_WIDTH) + if (was_conversion || table->copy_blobs || length <= MAX_FIELD_WIDTH) { // Must make a copy if (from != value.ptr()) // For valgrind { From d372811cb2375b33aa2e1302604ec1722f7a8e7d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Jan 2004 16:10:44 +0400 Subject: [PATCH 35/50] I forgot to add the test in the previous commit :( Blame me! --- mysql-test/r/ctype_recoding.result | 6 ++++++ mysql-test/t/ctype_recoding.test | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/mysql-test/r/ctype_recoding.result b/mysql-test/r/ctype_recoding.result index 571c89ef467..7209c86bb31 100644 --- a/mysql-test/r/ctype_recoding.result +++ b/mysql-test/r/ctype_recoding.result @@ -19,6 +19,12 @@ SELECT HEX(a) FROM t2; HEX(a) D0BFD180D0BED0B1D0B0 DROP TABLE t1, t2; +CREATE TABLE t1 (description text character set cp1250 NOT NULL); +INSERT INTO t1 (description) VALUES (_latin2'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasssssssssssaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddde'); +SELECT description FROM t1; +description +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasssssssssssaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddde +DROP TABLE t1; CREATE TABLE t1 (a TEXT CHARACTER SET cp1251) SELECT _koi8r'' AS a; CREATE TABLE t2 (a TEXT CHARACTER SET utf8); SHOW CREATE TABLE t1; diff --git a/mysql-test/t/ctype_recoding.test b/mysql-test/t/ctype_recoding.test index 0b901009041..40349da8aa9 100644 --- a/mysql-test/t/ctype_recoding.test +++ b/mysql-test/t/ctype_recoding.test @@ -14,6 +14,15 @@ INSERT t2 SELECT * FROM t1; SELECT HEX(a) FROM t2; DROP TABLE t1, t2; + +# +# Check that long strings conversion does not fail (bug#2218) +# +CREATE TABLE t1 (description text character set cp1250 NOT NULL); +INSERT INTO t1 (description) VALUES (_latin2'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasssssssssssaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddde'); +SELECT description FROM t1; +DROP TABLE t1; + # same with TEXT CREATE TABLE t1 (a TEXT CHARACTER SET cp1251) SELECT _koi8r'' AS a; CREATE TABLE t2 (a TEXT CHARACTER SET utf8); @@ -62,3 +71,4 @@ SET NAMES koi8r; SELECT hex(''); SET character_set_connection=cp1251; SELECT hex(''); + From 758f4da316eb38b9c80ba34c27f86c04ebf7ad53 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Jan 2004 13:32:12 +0100 Subject: [PATCH 36/50] - no C++ comments in .c files, please... --- mysys/default.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mysys/default.c b/mysys/default.c index d9099a9e505..81e1fd06374 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -461,7 +461,8 @@ static char *remove_end_comment(char *ptr) else if (quote == *ptr) quote= 0; } - if (!quote && (*ptr == '#' || *ptr == ';')) // We are not inside a comment + /* We are not inside a comment */ + if (!quote && (*ptr == '#' || *ptr == ';')) { *ptr= 0; return ptr; From 070647206ac2ce7c5d0c39eca8a4f89e636d2891 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Jan 2004 17:07:29 +0400 Subject: [PATCH 37/50] charset.c: http://bugs.mysql.com/bug.php?id=2386 Index.xml file larger than 1024*16 Fix for the above bug. mysys/charset.c: http://bugs.mysql.com/bug.php?id=2386 Index.xml file larger than 1024*16 Fix for the above bug. --- mysys/charset.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mysys/charset.c b/mysys/charset.c index b911f29627c..5e9e3c3fcaa 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -357,7 +357,7 @@ static int add_collation(CHARSET_INFO *cs) } -#define MAX_BUF 1024*16 +#define MY_MAX_ALLOWED_BUF 1024*1024 #define MY_CHARSET_INDEX "Index.xml" const char *charsets_dir= NULL; @@ -369,16 +369,19 @@ static my_bool my_read_charset_file(const char *filename, myf myflags) char *buf; int fd; uint len; + MY_STAT stat_info; - if (!(buf= (char *)my_malloc(MAX_BUF,myflags))) - return FALSE; + if (!my_stat(filename, &stat_info, MYF(MY_WME)) || + ((len= (uint)stat_info.st_size) > MY_MAX_ALLOWED_BUF) || + !(buf= (char *)my_malloc(len,myflags))) + return TRUE; if ((fd=my_open(filename,O_RDONLY,myflags)) < 0) { my_free(buf,myflags); return TRUE; } - len=read(fd,buf,MAX_BUF); + len=read(fd,buf,len); my_close(fd,myflags); if (my_parse_charset_xml(buf,len,add_collation)) From 94e6b9be19ecfbb4c541b2f2d49f08ffc351a1ab Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 16 Jan 2004 16:22:59 +0100 Subject: [PATCH 38/50] - Fixed BUG#2297: cmd-line-utils/libedit/makelist used a hard-coded call to /usr/bin/awk - replaced this with the proper autoconf variable instead (makelist is now generated out of makelist.sh during the compile phase) cmd-line-utils/libedit/Makefile.am: - replace @AWK@ with the correct path to the awk binary determined by configure instead of using a hard-coded path (BUG#2297) cmd-line-utils/libedit/makelist.sh: - replace @AWK@ with the correct path to the awk binary determined by configure instead of using a hard-coded path (BUG#2297) --- cmd-line-utils/libedit/Makefile.am | 13 ++++++++++++- cmd-line-utils/libedit/{makelist => makelist.sh} | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) rename cmd-line-utils/libedit/{makelist => makelist.sh} (99%) diff --git a/cmd-line-utils/libedit/Makefile.am b/cmd-line-utils/libedit/Makefile.am index 19171f62ffb..eb6b930c0b2 100644 --- a/cmd-line-utils/libedit/Makefile.am +++ b/cmd-line-utils/libedit/Makefile.am @@ -24,10 +24,21 @@ noinst_HEADERS = chared.h el.h histedit.h key.h \ hist.h map.h prompt.h search.h \ strlcpy.h libedit_term.h tty.h -EXTRA_DIST = makelist +EXTRA_DIST = makelist.sh + +CLEANFILES = makelist DEFS = -DUNDEF_THREADS_HACK -DHAVE_CONFIG_H -DNO_KILL_INTR +SUFFIXES = .sh + +.sh: + @RM@ -f $@ $@-t + @SED@ \ + -e 's!@''AWK''@!@AWK@!' \ + $< > $@-t + @MV@ $@-t $@ + vi.h: vi.c makelist sh ./makelist -h ./vi.c > $@.tmp && \ mv $@.tmp $@ diff --git a/cmd-line-utils/libedit/makelist b/cmd-line-utils/libedit/makelist.sh similarity index 99% rename from cmd-line-utils/libedit/makelist rename to cmd-line-utils/libedit/makelist.sh index 3c3338e9875..13d37512591 100644 --- a/cmd-line-utils/libedit/makelist +++ b/cmd-line-utils/libedit/makelist.sh @@ -39,7 +39,7 @@ # makelist.sh: Automatically generate header files... -AWK=/usr/bin/awk +AWK=@AWK@ USAGE="Usage: $0 -h|-e|-fc|-fh|-bc|-bh|-m " if [ "x$1" = "x" ] From 12e7d6a39d7c71b48f04d62e4bd6bc995441d39b Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 17 Jan 2004 12:03:14 +0200 Subject: [PATCH 39/50] mysqldump results fixed --- mysql-test/r/mysqldump.result | 42 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 04effdfef7c..f51caee39d6 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -21,17 +21,17 @@ DROP TABLE t1; CREATE TABLE t1 (a decimal(240, 20)); INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"), ("0987654321098765432109876543210987654321"); -DROP TABLE IF EXISTS t1; -CREATE TABLE t1 ( - a decimal(240,20) default NULL +DROP TABLE IF EXISTS `t1`; +CREATE TABLE `t1` ( + `a` decimal(240,20) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -/*!40000 ALTER TABLE t1 DISABLE KEYS */; -LOCK TABLES t1 WRITE; -INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890.00000000000000000000"),("0987654321098765432109876543210987654321.00000000000000000000"); +/*!40000 ALTER TABLE `t1` DISABLE KEYS */; +LOCK TABLES `t1` WRITE; +INSERT INTO `t1` VALUES ("1234567890123456789012345678901234567890.00000000000000000000"),("0987654321098765432109876543210987654321.00000000000000000000"); UNLOCK TABLES; -/*!40000 ALTER TABLE t1 ENABLE KEYS */; +/*!40000 ALTER TABLE `t1` ENABLE KEYS */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; @@ -41,17 +41,17 @@ UNLOCK TABLES; DROP TABLE t1; CREATE TABLE t1 (a double); INSERT INTO t1 VALUES (-9e999999); -DROP TABLE IF EXISTS t1; -CREATE TABLE t1 ( - a double default NULL +DROP TABLE IF EXISTS `t1`; +CREATE TABLE `t1` ( + `a` double default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -/*!40000 ALTER TABLE t1 DISABLE KEYS */; -LOCK TABLES t1 WRITE; -INSERT INTO t1 VALUES (RES); +/*!40000 ALTER TABLE `t1` DISABLE KEYS */; +LOCK TABLES `t1` WRITE; +INSERT INTO `t1` VALUES (RES); UNLOCK TABLES; -/*!40000 ALTER TABLE t1 ENABLE KEYS */; +/*!40000 ALTER TABLE `t1` ENABLE KEYS */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; @@ -105,17 +105,17 @@ INSERT INTO t1 VALUES ("1\""), ("\"2"); DROP TABLE t1; CREATE TABLE t1 (a VARCHAR(255)) DEFAULT CHARSET koi8r; INSERT INTO t1 VALUES (_koi8r x'C1C2C3C4C5'); -DROP TABLE IF EXISTS t1; -CREATE TABLE t1 ( - a varchar(255) default NULL +DROP TABLE IF EXISTS `t1`; +CREATE TABLE `t1` ( + `a` varchar(255) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=koi8r; -/*!40000 ALTER TABLE t1 DISABLE KEYS */; -LOCK TABLES t1 WRITE; -INSERT INTO t1 VALUES ('абцде'); +/*!40000 ALTER TABLE `t1` DISABLE KEYS */; +LOCK TABLES `t1` WRITE; +INSERT INTO `t1` VALUES ('абцде'); UNLOCK TABLES; -/*!40000 ALTER TABLE t1 ENABLE KEYS */; +/*!40000 ALTER TABLE `t1` ENABLE KEYS */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; From 2de832dbf99a8796b081419a29cacbeb07cd3871 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 17 Jan 2004 13:00:46 +0200 Subject: [PATCH 40/50] switched to new syntax (TYPE->ENGINE) check of memory allocation operation was added mysql-test/r/subselect_innodb.result: switched to new syntax mysql-test/t/subselect_innodb.test: switched to new syntax sql/sql_select.cc: check of memory allocation operation --- mysql-test/r/subselect_innodb.result | 4 ++-- mysql-test/t/subselect_innodb.test | 4 ++-- sql/sql_select.cc | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/subselect_innodb.result b/mysql-test/r/subselect_innodb.result index 3a2a36475c5..e3528e06546 100644 --- a/mysql-test/r/subselect_innodb.result +++ b/mysql-test/r/subselect_innodb.result @@ -69,7 +69,7 @@ b int(11) default NULL, c char(3) default NULL, PRIMARY KEY (id), KEY t2i1 (b) -) TYPE=innodb DEFAULT CHARSET=latin1; +) ENGINE=innodb DEFAULT CHARSET=latin1; INSERT INTO t1 VALUES (0,0,'GPL'),(1,0,'GPL'),(2,1,'GPL'),(3,2,'GPL'); CREATE TABLE t2 ( id int(11) NOT NULL default '0', @@ -77,7 +77,7 @@ b int(11) default NULL, c char(3) default NULL, PRIMARY KEY (id), KEY t2i (b) -) TYPE=innodb DEFAULT CHARSET=latin1; +) ENGINE=innodb DEFAULT CHARSET=latin1; INSERT INTO t2 VALUES (0,0,'GPL'),(1,0,'GPL'),(2,1,'GPL'),(3,2,'GPL'); select (select max(id) from t2 where b=1 group by b) as x,b from t1 where b=1; x b diff --git a/mysql-test/t/subselect_innodb.test b/mysql-test/t/subselect_innodb.test index c17f3f30e39..affa6301db4 100644 --- a/mysql-test/t/subselect_innodb.test +++ b/mysql-test/t/subselect_innodb.test @@ -78,7 +78,7 @@ CREATE TABLE t1 ( c char(3) default NULL, PRIMARY KEY (id), KEY t2i1 (b) -) TYPE=innodb DEFAULT CHARSET=latin1; +) ENGINE=innodb DEFAULT CHARSET=latin1; INSERT INTO t1 VALUES (0,0,'GPL'),(1,0,'GPL'),(2,1,'GPL'),(3,2,'GPL'); CREATE TABLE t2 ( id int(11) NOT NULL default '0', @@ -86,7 +86,7 @@ CREATE TABLE t2 ( c char(3) default NULL, PRIMARY KEY (id), KEY t2i (b) -) TYPE=innodb DEFAULT CHARSET=latin1; +) ENGINE=innodb DEFAULT CHARSET=latin1; INSERT INTO t2 VALUES (0,0,'GPL'),(1,0,'GPL'),(2,1,'GPL'),(3,2,'GPL'); select (select max(id) from t2 where b=1 group by b) as x,b from t1 where b=1; drop table t1,t2; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 1b03a70c43d..3f9492f1d72 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1586,7 +1586,8 @@ mysql_select(THD *thd, Item ***rref_pointer_array, } else { - join= new JOIN(thd, fields, select_options, result); + if (!(join= new JOIN(thd, fields, select_options, result))) + DBUG_RETURN(-1); thd->proc_info="init"; thd->used_tables=0; // Updated by setup_fields if (join->prepare(rref_pointer_array, tables, wild_num, From 19fe657f4edf5e7f08a91e2c8e20a194ca4f204b Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 17 Jan 2004 13:09:41 +0200 Subject: [PATCH 41/50] commit of forgoten test --- mysql-test/t/subselect_innodb.test | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mysql-test/t/subselect_innodb.test b/mysql-test/t/subselect_innodb.test index 9eb35ffc0fd..e1f26776134 100644 --- a/mysql-test/t/subselect_innodb.test +++ b/mysql-test/t/subselect_innodb.test @@ -67,4 +67,15 @@ INSERT INTO t1 VALUES (1),(2),(3); INSERT INTO t3 VALUES (1,1),(2,2),(3,3); INSERT INTO t2 VALUES (1,1),(2,2),(3,3); SELECT distinct p1.processor_id, (SELECT y.yod_id FROM t1 p2, t2 y WHERE p2.processor_id = p1.processor_id and p2.processor_id = y.processor_id) FROM t1 p1; -drop table t1,t2,t3; \ No newline at end of file +drop table t1,t2,t3; + +# +# reiniting innodb tables +# +create table t1 (id int not null, value char(255), primary key(id)) engine=innodb; +create table t2 (id int not null, value char(255)) engine=innodb; +insert into t1 values (1,'a'),(2,'b'); +insert into t2 values (1,'z'),(2,'x'); +select t2.id,t2.value,(select t1.value from t1 where t1.id=t2.id) from t2; +select t2.id,t2.value,(select t1.value from t1 where t1.id=t2.id) from t2; +drop table t1,t2; From d63d204c07563050d99f16a9ff35e2c1e93a9d05 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 17 Jan 2004 15:28:20 +0200 Subject: [PATCH 42/50] new test added test fixed --- mysql-test/r/derived.result | 12 ++++++------ mysql-test/t/derived.test | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index 9b5aa9123a4..8cf0b45102f 100644 --- a/mysql-test/r/derived.result +++ b/mysql-test/r/derived.result @@ -85,6 +85,10 @@ a b 2 b 3 c 3 c +select * from (select * from t1 union all select * from t1 limit 2) a; +a b +1 a +2 b explain select * from (select * from t1 union select * from t1) a; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY ALL NULL NULL NULL NULL 3 @@ -258,17 +262,13 @@ ID int(11) default NULL, PARID int(11) default NULL, UNIQUE KEY t2_ID_IDX (ID), KEY t2_PARID_IDX (PARID) -) TYPE=MyISAM DEFAULT CHARSET=latin1; -Warnings: -Warning 1286 'TYPE=database_engine' is deprecated. Use 'ENGINE=database_engine' instead. +) engine=MyISAM DEFAULT CHARSET=latin1; INSERT INTO t2 VALUES (1000,0),(1001,0),(1002,0),(1003,0),(1008,1),(1009,1),(1010,1),(1011,1),(1016,2); CREATE TABLE t3 ( ID int(11) default NULL, DATA decimal(10,2) default NULL, UNIQUE KEY t3_ID_IDX (ID) -) TYPE=MyISAM DEFAULT CHARSET=latin1; -Warnings: -Warning 1286 'TYPE=database_engine' is deprecated. Use 'ENGINE=database_engine' instead. +) engine=MyISAM DEFAULT CHARSET=latin1; INSERT INTO t3 VALUES (1000,0.00),(1001,0.25),(1002,0.50),(1003,0.75),(1008,1.00),(1009,1.25),(1010,1.50),(1011,1.75); select 497, TMP.ID, NULL from (select 497 as ID, MAX(t3.DATA) as DATA from t1 join t2 on (t1.ObjectID = t2.ID) join t3 on (t1.ObjectID = t3.ID) group by t2.ParID order by DATA DESC) as TMP; 497 ID NULL diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index bb61dab6d74..8de95b4b600 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -35,6 +35,7 @@ select a from (select 1 as a) as b; select 1 from (select 1) as a; select * from (select * from t1 union select * from t1) a; select * from (select * from t1 union all select * from t1) a; +select * from (select * from t1 union all select * from t1 limit 2) a; explain select * from (select * from t1 union select * from t1) a; explain select * from (select * from t1 union all select * from t1) a; CREATE TABLE t2 (a int not null); @@ -154,13 +155,13 @@ CREATE TABLE t2 ( PARID int(11) default NULL, UNIQUE KEY t2_ID_IDX (ID), KEY t2_PARID_IDX (PARID) -) TYPE=MyISAM DEFAULT CHARSET=latin1; +) engine=MyISAM DEFAULT CHARSET=latin1; INSERT INTO t2 VALUES (1000,0),(1001,0),(1002,0),(1003,0),(1008,1),(1009,1),(1010,1),(1011,1),(1016,2); CREATE TABLE t3 ( ID int(11) default NULL, DATA decimal(10,2) default NULL, UNIQUE KEY t3_ID_IDX (ID) -) TYPE=MyISAM DEFAULT CHARSET=latin1; +) engine=MyISAM DEFAULT CHARSET=latin1; INSERT INTO t3 VALUES (1000,0.00),(1001,0.25),(1002,0.50),(1003,0.75),(1008,1.00),(1009,1.25),(1010,1.50),(1011,1.75); select 497, TMP.ID, NULL from (select 497 as ID, MAX(t3.DATA) as DATA from t1 join t2 on (t1.ObjectID = t2.ID) join t3 on (t1.ObjectID = t3.ID) group by t2.ParID order by DATA DESC) as TMP; drop table t1, t2, t3; From 62e9ab4515bedc12dfefeb7107b8c46e27494126 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 18 Jan 2004 17:29:27 +0100 Subject: [PATCH 43/50] trivial FT2 bug in mi_write fixed (same as ChangeSet@1.1538.36.1, 2003-06-12 12:41:29+02:00, serg@serg.mylan, "FT2 bug in mi_delete fixed") BUG#2417 --- myisam/mi_write.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/myisam/mi_write.c b/myisam/mi_write.c index d13ba6c2c4e..060d4431de6 100644 --- a/myisam/mi_write.c +++ b/myisam/mi_write.c @@ -378,7 +378,7 @@ static int w_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, my_off_t root=info->dupp_key_pos; keyinfo=&info->s->ft2_keyinfo; key+=off; - keypos-=keyinfo->keylength; /* we'll modify key entry 'in vivo' */ + keypos-=keyinfo->keylength+nod_flag; /* we'll modify key entry 'in vivo' */ error=_mi_ck_real_write_btree(info, keyinfo, key, 0, &root, comp_flag); _mi_dpointer(info, keypos+HA_FT_WLEN, root); From cf2b6edaadd9fcd1389803545b3716f1cd258753 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 18 Jan 2004 22:30:35 +0000 Subject: [PATCH 44/50] Fix deprecation warning - database_engine => storage_engine BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 1 + mysql-test/r/derived.result | 2 +- mysql-test/r/symlink.result | 2 +- mysql-test/r/warnings.result | 4 ++-- sql/sql_yacc.yy | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 785ea13b492..a7eb7c81105 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -5,6 +5,7 @@ Administrator@fred. Miguel@light.local Sinisa@sinisa.nasamreza.org WAX@sergbook.mysql.com +acurtis@pcgem.rdg.cyberkinetica.com administrador@light.hegel.local ahlentz@co3064164-a.rochd1.qld.optusnet.com.au akishkin@work.mysql.com diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index 8cf0b45102f..c0d2ce287db 100644 --- a/mysql-test/r/derived.result +++ b/mysql-test/r/derived.result @@ -256,7 +256,7 @@ KEY t1_SortIndex (SORTORDER), KEY t1_IdIndex (OBJECTID) ) TYPE=MyISAM DEFAULT CHARSET=latin1; Warnings: -Warning 1286 'TYPE=database_engine' is deprecated. Use 'ENGINE=database_engine' instead. +Warning 1286 'TYPE=storage_engine' is deprecated. Use 'ENGINE=storage_engine' instead. CREATE TABLE t2 ( ID int(11) default NULL, PARID int(11) default NULL, diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result index 4ba0ca0eac4..6dc48a0a77e 100644 --- a/mysql-test/r/symlink.result +++ b/mysql-test/r/symlink.result @@ -66,7 +66,7 @@ t9 CREATE TABLE `t9` ( drop database mysqltest; create table t1 (a int not null) type=myisam; Warnings: -Warning 1286 'TYPE=database_engine' is deprecated. Use 'ENGINE=database_engine' instead. +Warning 1286 'TYPE=storage_engine' is deprecated. Use 'ENGINE=storage_engine' instead. show create table t1; Table Create Table t1 CREATE TABLE `t1` ( diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result index 5c7c75bac00..c3d9f165fed 100644 --- a/mysql-test/r/warnings.result +++ b/mysql-test/r/warnings.result @@ -128,10 +128,10 @@ Warning 1265 Using storage engine MyISAM for table 't1' drop table t1; create table t1 (id int) type=heap; Warnings: -Warning 1286 'TYPE=database_engine' is deprecated. Use 'ENGINE=database_engine' instead. +Warning 1286 'TYPE=storage_engine' is deprecated. Use 'ENGINE=storage_engine' instead. alter table t1 type=myisam; Warnings: -Warning 1286 'TYPE=database_engine' is deprecated. Use 'ENGINE=database_engine' instead. +Warning 1286 'TYPE=storage_engine' is deprecated. Use 'ENGINE=storage_engine' instead. drop table t1; set table_type=MYISAM; Warnings: diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 310d8a41be2..ab95ba312d8 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1077,7 +1077,7 @@ create_table_options: create_table_option: ENGINE_SYM opt_equal storage_engines { Lex->create_info.db_type= $3; } - | TYPE_SYM opt_equal storage_engines { Lex->create_info.db_type= $3; WARN_DEPRECATED("TYPE=database_engine","ENGINE=database_engine"); } + | TYPE_SYM opt_equal storage_engines { Lex->create_info.db_type= $3; WARN_DEPRECATED("TYPE=storage_engine","ENGINE=storage_engine"); } | MAX_ROWS opt_equal ulonglong_num { Lex->create_info.max_rows= $3; Lex->create_info.used_fields|= HA_CREATE_USED_MAX_ROWS;} | MIN_ROWS opt_equal ulonglong_num { Lex->create_info.min_rows= $3; Lex->create_info.used_fields|= HA_CREATE_USED_MIN_ROWS;} | AVG_ROW_LENGTH opt_equal ULONG_NUM { Lex->create_info.avg_row_length=$3; Lex->create_info.used_fields|= HA_CREATE_USED_AVG_ROW_LENGTH;} From a66924353a9fb4a1c1bfa05ad45aa3cabc34c3b6 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Jan 2004 14:10:05 +0400 Subject: [PATCH 45/50] Test case for the bug #2198: SELECT INTO OUTFILE (with Sub-Select) Problem. --- mysql-test/r/subselect.result | 9 +++++++++ mysql-test/t/subselect.test | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 672a39299dd..ded98265a1c 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -1569,3 +1569,12 @@ INSERT INTO t2 VALUES (100, 200, 'C'); SELECT DISTINCT COLC FROM t1 WHERE COLA = (SELECT COLA FROM t2 WHERE COLB = 200 AND COLC ='C' LIMIT 1); COLC DROP TABLE t1, t2; +create table t1 (a int, b decimal(13, 3)); +insert into t1 values (1, 0.123); +select a, (select max(b) from t1) into outfile "subselect.out.file.1" from t1; +delete from t1; +load data infile "subselect.out.file.1" into table t1; +select * from t1; +a b +1 0.123 +drop table t1; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 95e4f022f2d..37dbc8f24d9 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -1009,3 +1009,15 @@ INSERT INTO t1 VALUES (1,1,'1A3240'), (1,2,'4W2365'); INSERT INTO t2 VALUES (100, 200, 'C'); SELECT DISTINCT COLC FROM t1 WHERE COLA = (SELECT COLA FROM t2 WHERE COLB = 200 AND COLC ='C' LIMIT 1); DROP TABLE t1, t2; + +# +# Bug 2198 +# + +create table t1 (a int, b decimal(13, 3)); +insert into t1 values (1, 0.123); +select a, (select max(b) from t1) into outfile "subselect.out.file.1" from t1; +delete from t1; +load data infile "subselect.out.file.1" into table t1; +select * from t1; +drop table t1; From 06de76aec5f3758bb07bdd66950aa4a8f2d5e4f4 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Jan 2004 14:22:38 +0100 Subject: [PATCH 46/50] field length convertion (bytes->chars) should be done with rounding UP. --- mysql-test/r/ctype_utf8.result | 11 +++++++++++ mysql-test/t/ctype_utf8.test | 12 ++++++++++++ sql/field.cc | 6 +++--- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 16c65619878..7c05b1ea446 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -1,3 +1,4 @@ +drop table if exists t1; set names utf8; select left(_utf8 0xD0B0D0B1D0B2,1); left(_utf8 0xD0B0D0B1D0B2,1) @@ -68,3 +69,13 @@ this is a test select insert("aa",100,1,"b"),insert("aa",1,3,"b"); insert("aa",100,1,"b") insert("aa",1,3,"b") aa b +create table t1 select date_format("2004-01-19 10:10:10", "%Y-%m-%d"); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `date_format("2004-01-19 10:10:10", "%Y-%m-%d")` char(4) character set utf8 default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t1; +date_format("2004-01-19 10:10:10", "%Y-%m-%d") +2004-01-19 +drop table t1; diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 5c924e82729..5e9324dd68f 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -2,6 +2,9 @@ # Tests with the utf8 character set # +--disable_warnings +drop table if exists t1; +--enable_warnings set names utf8; select left(_utf8 0xD0B0D0B1D0B2,1); @@ -41,3 +44,12 @@ select _utf8 0xD0B0D0B1D0B2 like concat(_utf8'%',_utf8 0xD0B1,_utf8 '%'); # select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es'); select insert("aa",100,1,"b"),insert("aa",1,3,"b"); + +# +# CREATE ... SELECT +# +create table t1 select date_format("2004-01-19 10:10:10", "%Y-%m-%d"); +show create table t1; +select * from t1; +drop table t1; + diff --git a/sql/field.cc b/sql/field.cc index 5602231dd9b..1a0716326fe 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5611,16 +5611,16 @@ create_field::create_field(Field *old_field,Field *orig_field) case 3: sql_type= FIELD_TYPE_MEDIUM_BLOB; break; default: sql_type= FIELD_TYPE_LONG_BLOB; break; } - length /= charset->mbmaxlen; // QQ: Probably not needed + length=(length+charset->mbmaxlen-1)/charset->mbmaxlen; // QQ: Probably not needed break; case FIELD_TYPE_STRING: case FIELD_TYPE_VAR_STRING: - length /= charset->mbmaxlen; + length=(length+charset->mbmaxlen-1)/charset->mbmaxlen; break; default: break; } - + decimals= old_field->decimals(); if (sql_type == FIELD_TYPE_STRING) { From 162f1dc5e6f8cd24ec996aa701a50bf20b8f6a36 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Jan 2004 19:16:30 +0400 Subject: [PATCH 47/50] UCS-2 aligning 0xAA -> 0x00AA --- include/m_ctype.h | 3 ++- mysql-test/r/ctype_ucs.result | 48 +++++++++++++++++++++++++++++++++++ mysql-test/t/ctype_ucs.test | 21 +++++++++++++++ mysys/charset.c | 4 ++- sql/item.h | 4 +-- sql/sql_string.cc | 46 +++++++++++++++++++++++++++++++++ sql/sql_string.h | 1 + strings/ctype-big5.c | 2 ++ strings/ctype-bin.c | 1 + strings/ctype-czech.c | 1 + strings/ctype-euc_kr.c | 2 ++ strings/ctype-extra.c | 1 + strings/ctype-gb2312.c | 2 ++ strings/ctype-gbk.c | 2 ++ strings/ctype-latin1.c | 3 +++ strings/ctype-sjis.c | 2 ++ strings/ctype-tis620.c | 2 ++ strings/ctype-ucs2.c | 2 ++ strings/ctype-ujis.c | 2 ++ strings/ctype-utf8.c | 2 ++ strings/ctype-win1250ch.c | 1 + 21 files changed, 148 insertions(+), 4 deletions(-) diff --git a/include/m_ctype.h b/include/m_ctype.h index 0228b359111..4a9415f43f9 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -206,8 +206,9 @@ typedef struct charset_info_st uchar state_map[256]; uchar ident_map[256]; uint strxfrm_multiply; + uint mbminlen; uint mbmaxlen; - char max_sort_char; /* For LIKE optimization */ + char max_sort_char; /* For LIKE optimization */ MY_CHARSET_HANDLER *cset; MY_COLLATION_HANDLER *coll; diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index 58761526150..d6e9cc690a2 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -276,3 +276,51 @@ aardvara aardvark aardvarz DROP TABLE t1; +SELECT HEX(_ucs2 0x0); +HEX(_ucs2 0x0) +0000 +SELECT HEX(_ucs2 0x01); +HEX(_ucs2 0x01) +0001 +SELECT HEX(_ucs2 0x012); +HEX(_ucs2 0x012) +0012 +SELECT HEX(_ucs2 0x0123); +HEX(_ucs2 0x0123) +0123 +SELECT HEX(_ucs2 0x01234); +HEX(_ucs2 0x01234) +00001234 +SELECT HEX(_ucs2 0x012345); +HEX(_ucs2 0x012345) +00012345 +SELECT HEX(_ucs2 0x0123456); +HEX(_ucs2 0x0123456) +00123456 +SELECT HEX(_ucs2 0x01234567); +HEX(_ucs2 0x01234567) +01234567 +SELECT HEX(_ucs2 0x012345678); +HEX(_ucs2 0x012345678) +000012345678 +SELECT HEX(_ucs2 0x0123456789); +HEX(_ucs2 0x0123456789) +000123456789 +SELECT HEX(_ucs2 0x0123456789A); +HEX(_ucs2 0x0123456789A) +00123456789A +SELECT HEX(_ucs2 0x0123456789AB); +HEX(_ucs2 0x0123456789AB) +0123456789AB +SELECT HEX(_ucs2 0x0123456789ABC); +HEX(_ucs2 0x0123456789ABC) +0000123456789ABC +SELECT HEX(_ucs2 0x0123456789ABCD); +HEX(_ucs2 0x0123456789ABCD) +000123456789ABCD +SELECT HEX(_ucs2 0x0123456789ABCDE); +HEX(_ucs2 0x0123456789ABCDE) +00123456789ABCDE +SELECT HEX(_ucs2 0x0123456789ABCDEF); +HEX(_ucs2 0x0123456789ABCDEF) +0123456789ABCDEF diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index 7eec58563b3..fd2a1b1cd7d 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -197,3 +197,24 @@ DROP TABLE t1; # END OF Bug 1264 test # ######################################################## + + +# Bug #2390 +# Check alignment +# +SELECT HEX(_ucs2 0x0); +SELECT HEX(_ucs2 0x01); +SELECT HEX(_ucs2 0x012); +SELECT HEX(_ucs2 0x0123); +SELECT HEX(_ucs2 0x01234); +SELECT HEX(_ucs2 0x012345); +SELECT HEX(_ucs2 0x0123456); +SELECT HEX(_ucs2 0x01234567); +SELECT HEX(_ucs2 0x012345678); +SELECT HEX(_ucs2 0x0123456789); +SELECT HEX(_ucs2 0x0123456789A); +SELECT HEX(_ucs2 0x0123456789AB); +SELECT HEX(_ucs2 0x0123456789ABC); +SELECT HEX(_ucs2 0x0123456789ABCD); +SELECT HEX(_ucs2 0x0123456789ABCDE); +SELECT HEX(_ucs2 0x0123456789ABCDEF); diff --git a/mysys/charset.c b/mysys/charset.c index 5e9e3c3fcaa..40a026f161f 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -131,7 +131,8 @@ static void simple_cs_init_functions(CHARSET_INFO *cs) cs->coll= &my_collation_8bit_simple_ci_handler; cs->cset= &my_charset_8bit_handler; - cs->mbmaxlen = 1; + cs->mbminlen= 1; + cs->mbmaxlen= 1; } @@ -273,6 +274,7 @@ static int simple_cs_copy_data(CHARSET_INFO *to, CHARSET_INFO *from) if (create_fromuni(to)) goto err; } + to->mbminlen= 1; to->mbmaxlen= 1; return 0; diff --git a/sql/item.h b/sql/item.h index 5def1e2b710..e6ed8109534 100644 --- a/sql/item.h +++ b/sql/item.h @@ -477,7 +477,7 @@ public: CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE) { collation.set(cs, dv); - str_value.set(str,length,cs); + str_value.set_or_copy_aligned(str,length,cs); /* We have to have a different max_length than 'length' here to ensure that we get the right length if we do use the item @@ -493,7 +493,7 @@ public: CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE) { collation.set(cs, dv); - str_value.set(str,length,cs); + str_value.set_or_copy_aligned(str,length,cs); max_length= str_value.numchars()*cs->mbmaxlen; set_name(name_par,0,cs); decimals=NOT_FIXED_DEC; diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 89f48607969..9534c5605fe 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -228,6 +228,52 @@ bool String::copy(const char *str,uint32 arg_length, CHARSET_INFO *cs) return FALSE; } +/* +** For real multi-byte, ascii incompatible charactser sets, +** like UCS-2, add leading zeros if we have an incomplete character. +** Thus, +** SELECT _ucs2 0xAA +** will automatically be converted into +** SELECT _ucs2 0x00AA +*/ + +bool String::set_or_copy_aligned(const char *str,uint32 arg_length, + CHARSET_INFO *cs) +{ + /* How many bytes are in incomplete character */ + uint32 offs= (arg_length % cs->mbminlen); + + if (!offs) /* All characters are complete, just copy */ + { + set(str, arg_length, cs); + return FALSE; + } + + offs= cs->mbmaxlen - offs; /* How many zeros we should prepend */ + uint32 aligned_length= arg_length + offs; + if (alloc(aligned_length)) + return TRUE; + + /* + Probably this condition is not really necessary + because if aligned_length is 0 then offs is 0 too + and we'll return after calling set(). + */ + if ((str_length= aligned_length)) + { + /* + Note, this is only safe for little-endian UCS-2. + If we add big-endian UCS-2 sometimes, this code + will be more complicated. But it's OK for now. + */ + bzero((char*)Ptr, offs); + memcpy(Ptr + offs, str, arg_length); + } + Ptr[aligned_length]=0; + str_charset=cs; + return FALSE; +} + /* Copy with charset convertion */ bool String::copy(const char *str, uint32 arg_length, diff --git a/sql/sql_string.h b/sql/sql_string.h index 325611737ca..8817aa8eab8 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -183,6 +183,7 @@ public: bool copy(); // Alloc string if not alloced bool copy(const String &s); // Allocate new string bool copy(const char *s,uint32 arg_length, CHARSET_INFO *cs); // Allocate new string + bool set_or_copy_aligned(const char *s, uint32 arg_length, CHARSET_INFO *cs); bool copy(const char*s,uint32 arg_length, CHARSET_INFO *csfrom, CHARSET_INFO *csto); bool append(const String &s); diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index c5ddc167d0d..8d4081fb2aa 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -6281,6 +6281,7 @@ CHARSET_INFO my_charset_big5_chinese_ci= "", "", 1, /* strxfrm_multiply */ + 1, /* mbminlen */ 2, /* mbmaxlen */ 0, &my_charset_big5_handler, @@ -6304,6 +6305,7 @@ CHARSET_INFO my_charset_big5_bin= "", "", 1, /* strxfrm_multiply */ + 1, /* mbminlen */ 2, /* mbmaxlen */ 0, &my_charset_big5_handler, diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index 6f28c43b2c6..67435b7df6c 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -381,6 +381,7 @@ CHARSET_INFO my_charset_bin = NULL, /* tab_from_uni */ "","", 1, /* strxfrm_multiply */ + 1, /* mbminlen */ 1, /* mbmaxlen */ (char) 255, /* max_sort_char */ &my_charset_handler, diff --git a/strings/ctype-czech.c b/strings/ctype-czech.c index b2e4f1886ed..1a07a5eba7e 100644 --- a/strings/ctype-czech.c +++ b/strings/ctype-czech.c @@ -631,6 +631,7 @@ CHARSET_INFO my_charset_latin2_czech_ci = idx_uni_8859_2, /* tab_from_uni */ "","", 4, /* strxfrm_multiply */ + 1, /* mbminlen */ 1, /* mbmaxlen */ 0, &my_charset_8bit_handler, diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c index addd7803680..366a5d500ed 100644 --- a/strings/ctype-euc_kr.c +++ b/strings/ctype-euc_kr.c @@ -8689,6 +8689,7 @@ CHARSET_INFO my_charset_euckr_korean_ci= "", "", 1, /* strxfrm_multiply */ + 1, /* mbminlen */ 2, /* mbmaxlen */ 0, &my_charset_handler, @@ -8712,6 +8713,7 @@ CHARSET_INFO my_charset_euckr_bin= "", "", 1, /* strxfrm_multiply */ + 1, /* mbminlen */ 2, /* mbmaxlen */ 0, &my_charset_handler, diff --git a/strings/ctype-extra.c b/strings/ctype-extra.c index 55bfa09ea5f..0085d264416 100644 --- a/strings/ctype-extra.c +++ b/strings/ctype-extra.c @@ -34,6 +34,7 @@ CHARSET_INFO compiled_charsets[] = { 0, 0, 0, + 0, NULL, NULL } diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c index b84ddc9081b..44a58b2b906 100644 --- a/strings/ctype-gb2312.c +++ b/strings/ctype-gb2312.c @@ -5740,6 +5740,7 @@ CHARSET_INFO my_charset_gb2312_chinese_ci= "", "", 1, /* strxfrm_multiply */ + 1, /* mbminlen */ 2, /* mbmaxlen */ 0, &my_charset_handler, @@ -5762,6 +5763,7 @@ CHARSET_INFO my_charset_gb2312_bin= "", "", 1, /* strxfrm_multiply */ + 1, /* mbminlen */ 2, /* mbmaxlen */ 0, &my_charset_handler, diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index 585dc66be4c..5475c3bd363 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -9936,6 +9936,7 @@ CHARSET_INFO my_charset_gbk_chinese_ci= "", "", 1, /* strxfrm_multiply */ + 1, /* mbminlen */ 2, /* mbmaxlen */ 0, &my_charset_handler, @@ -9958,6 +9959,7 @@ CHARSET_INFO my_charset_gbk_bin= "", "", 1, /* strxfrm_multiply */ + 1, /* mbminlen */ 2, /* mbmaxlen */ 0, &my_charset_handler, diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c index 15798abb85b..c00ded21575 100644 --- a/strings/ctype-latin1.c +++ b/strings/ctype-latin1.c @@ -215,6 +215,7 @@ CHARSET_INFO my_charset_latin1= NULL, /* tab_from_uni */ "","", 1, /* strxfrm_multiply */ + 1, /* mbminlen */ 1, /* mbmaxlen */ 0, &my_charset_handler, @@ -410,6 +411,7 @@ CHARSET_INFO my_charset_latin1_german2_ci= NULL, /* tab_from_uni */ "","", 2, /* strxfrm_multiply */ + 1, /* mbminlen */ 1, /* mbmaxlen */ 0, &my_charset_handler, @@ -433,6 +435,7 @@ CHARSET_INFO my_charset_latin1_bin= "", "", 1, /* strxfrm_multiply */ + 1, /* mbminlen */ 1, /* mbmaxlen */ 0, &my_charset_handler, diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index a84fbd16e5d..42f32fe739b 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -4525,6 +4525,7 @@ CHARSET_INFO my_charset_sjis_japanese_ci= "", "", 1, /* strxfrm_multiply */ + 1, /* mbminlen */ 2, /* mbmaxlen */ 0, &my_charset_handler, @@ -4547,6 +4548,7 @@ CHARSET_INFO my_charset_sjis_bin= "", "", 1, /* strxfrm_multiply */ + 1, /* mbminlen */ 2, /* mbmaxlen */ 0, &my_charset_handler, diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index 92b2eeb25e0..09552a0dc23 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -956,6 +956,7 @@ CHARSET_INFO my_charset_tis620_thai_ci= "", "", 4, /* strxfrm_multiply */ + 1, /* mbminlen */ 1, /* mbmaxlen */ 0, &my_charset_handler, @@ -978,6 +979,7 @@ CHARSET_INFO my_charset_tis620_bin= "", "", 1, /* strxfrm_multiply */ + 1, /* mbminlen */ 1, /* mbmaxlen */ 0, &my_charset_handler, diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index beb803a69f2..a7a59fc50f7 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1322,6 +1322,7 @@ CHARSET_INFO my_charset_ucs2_general_ci= "", "", 1, /* strxfrm_multiply */ + 2, /* mbminlen */ 2, /* mbmaxlen */ 0, &my_charset_ucs2_handler, @@ -1345,6 +1346,7 @@ CHARSET_INFO my_charset_ucs2_bin= "", "", 1, /* strxfrm_multiply */ + 2, /* mbminlen */ 2, /* mbmaxlen */ 0, &my_charset_ucs2_handler, diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c index 2815b70351b..f6928e9426e 100644 --- a/strings/ctype-ujis.c +++ b/strings/ctype-ujis.c @@ -8480,6 +8480,7 @@ CHARSET_INFO my_charset_ujis_japanese_ci= NULL, /* tab_from_uni */ "","", 1, /* strxfrm_multiply */ + 1, /* mbminlen */ 3, /* mbmaxlen */ 0, &my_charset_handler, @@ -8502,6 +8503,7 @@ CHARSET_INFO my_charset_ujis_bin= NULL, /* tab_from_uni */ "","", 1, /* strxfrm_multiply */ + 1, /* mbminlen */ 3, /* mbmaxlen */ 0, &my_charset_handler, diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index b5716c53ea2..8004fba75b7 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -2006,6 +2006,7 @@ CHARSET_INFO my_charset_utf8_general_ci= "", "", 1, /* strxfrm_multiply */ + 1, /* mbminlen */ 3, /* mbmaxlen */ 0, &my_charset_handler, @@ -2029,6 +2030,7 @@ CHARSET_INFO my_charset_utf8_bin= "", "", 1, /* strxfrm_multiply */ + 1, /* mbminlen */ 3, /* mbmaxlen */ 0, &my_charset_handler, diff --git a/strings/ctype-win1250ch.c b/strings/ctype-win1250ch.c index 60a5737009f..d3b5c9d1796 100644 --- a/strings/ctype-win1250ch.c +++ b/strings/ctype-win1250ch.c @@ -671,6 +671,7 @@ CHARSET_INFO my_charset_cp1250_czech_ci = idx_uni_cp1250, /* tab_from_uni */ "","", 2, /* strxfrm_multiply */ + 1, /* mbminlen */ 1, /* mbmaxlen */ 0, &my_charset_8bit_handler, From 7db61ce021642bb3bbee1c341d94f3539037df80 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Jan 2004 00:32:25 +0400 Subject: [PATCH 48/50] Fixed bug #2310 "INET_ATON handles short-forms addresses incorrectly" mysql-test/r/func_misc.result: added new test for inet_aton (short-forms addresses) mysql-test/t/func_misc.test: added new test for inet_aton (short-forms addresses) sql/item_func.cc: Change Item_func_inet_aton::val_int to parse short-forms addresses correctly --- mysql-test/r/func_misc.result | 11 ++++++++++- mysql-test/t/func_misc.test | 4 ++++ sql/item_func.cc | 9 +++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index d51bea020ed..ec5f76409e7 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -6,10 +6,19 @@ inet_ntoa(inet_aton("255.255.255.255.255.255.255.255")) NULL select inet_aton("255.255.255.255.255"),inet_aton("255.255.1.255"),inet_aton("0.1.255"); inet_aton("255.255.255.255.255") inet_aton("255.255.1.255") inet_aton("0.1.255") -1099511627775 4294902271 511 +1099511627775 4294902271 65791 select inet_ntoa(1099511627775),inet_ntoa(4294902271),inet_ntoa(511); inet_ntoa(1099511627775) inet_ntoa(4294902271) inet_ntoa(511) NULL 255.255.1.255 0.0.1.255 +select hex(inet_aton('127')); +hex(inet_aton('127')) +7F +select hex(inet_aton('127.1')); +hex(inet_aton('127.1')) +7F000001 +select hex(inet_aton('127.1.1')); +hex(inet_aton('127.1.1')) +7F010001 select length(format('nan', 2)) > 0; length(format('nan', 2)) > 0 1 diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index d15c26279ec..9759127b222 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -8,6 +8,10 @@ select inet_ntoa(inet_aton("255.255.255.255.255.255.255.255")); select inet_aton("255.255.255.255.255"),inet_aton("255.255.1.255"),inet_aton("0.1.255"); select inet_ntoa(1099511627775),inet_ntoa(4294902271),inet_ntoa(511); +select hex(inet_aton('127')); +select hex(inet_aton('127.1')); +select hex(inet_aton('127.1.1')); + # # Test for core dump with nan # diff --git a/sql/item_func.cc b/sql/item_func.cc index 5af64ca0be4..802b6dbb8d6 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2618,6 +2618,7 @@ longlong Item_func_inet_aton::val_int() const char *p,* end; char c = '.'; // we mark c to indicate invalid IP in case length is 0 char buff[36]; + int dot_count= 0; String *s,tmp(buff,sizeof(buff),&my_charset_bin); if (!(s = args[0]->val_str(&tmp))) // If null value @@ -2636,6 +2637,7 @@ longlong Item_func_inet_aton::val_int() } else if (c == '.') { + dot_count++; result= (result << 8) + (ulonglong) byte_result; byte_result = 0; } @@ -2643,7 +2645,14 @@ longlong Item_func_inet_aton::val_int() goto err; // Invalid character } if (c != '.') // IP number can't end on '.' + { + switch (dot_count) + { + case 1: result<<= 8; + case 2: result<<= 8; + } return (result << 8) + (ulonglong) byte_result; + } err: null_value=1; From eead0c1b822070aebdaede48930249aea610fc98 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Jan 2004 23:34:39 +0300 Subject: [PATCH 49/50] More comments to THD::lock and THD::locked_tables commented --- sql/sql_class.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sql/sql_class.h b/sql/sql_class.h index 5390e8a4ac4..4bdf5c38a2c 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -624,6 +624,19 @@ public: and are still in use by this thread */ TABLE *open_tables,*temporary_tables, *handler_tables, *derived_tables; + /* + During a MySQL session, one can lock tables in two modes: automatic + or manual. In automatic mode all necessary tables are locked just before + statement execution, and all acquired locks are stored in a 'lock' + member. Unlocking takes place automatically as well, when the + statement ends. + Manual mode comes into play when a user issues a 'LOCK TABLES' + statement. In this mode the user can only use the locked tables. + Trying to use any other tables will give an error. The locked tables are + stored in a 'locked_tables' member. Manual locking is described in + the 'LOCK_TABLES' chapter of the MySQL manual. + See also lock_tables() for details. + */ MYSQL_LOCK *lock; /* Current locks */ MYSQL_LOCK *locked_tables; /* Tables locked with LOCK */ /* From b89abbf8a154376678a3ed8a9fe6ea25b5209aba Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Jan 2004 23:34:40 +0300 Subject: [PATCH 50/50] more clear (grammar mistake) --- sql/sql_class.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_class.h b/sql/sql_class.h index 4bdf5c38a2c..7971137d848 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -627,13 +627,13 @@ public: /* During a MySQL session, one can lock tables in two modes: automatic or manual. In automatic mode all necessary tables are locked just before - statement execution, and all acquired locks are stored in a 'lock' + statement execution, and all acquired locks are stored in 'lock' member. Unlocking takes place automatically as well, when the statement ends. Manual mode comes into play when a user issues a 'LOCK TABLES' statement. In this mode the user can only use the locked tables. Trying to use any other tables will give an error. The locked tables are - stored in a 'locked_tables' member. Manual locking is described in + stored in 'locked_tables' member. Manual locking is described in the 'LOCK_TABLES' chapter of the MySQL manual. See also lock_tables() for details. */