diff options
author | unknown <istruewing@stella.local> | 2007-12-11 17:09:43 +0100 |
---|---|---|
committer | unknown <istruewing@stella.local> | 2007-12-11 17:09:43 +0100 |
commit | cd34354e6c8d86d19fb397912d98803254bebaaf (patch) | |
tree | 3d24c8f4f0325ffc59ec0c65b251a86363351a4d | |
parent | 9e5ed26076c1999f4437eca4a7ef133962f2e30f (diff) | |
parent | 36486ee86c8ba3eddeaed752e5e0c87498502058 (diff) | |
download | mariadb-git-cd34354e6c8d86d19fb397912d98803254bebaaf.tar.gz |
Merge stella.local:/home2/mydev/mysql-5.0-amain
into stella.local:/home2/mydev/mysql-5.0-axmrg
mysql-test/r/func_misc.result:
Manual merge
mysql-test/t/func_misc.test:
Manual merge
-rw-r--r-- | mysql-test/include/ctype_common.inc | 2 | ||||
-rw-r--r-- | mysql-test/r/ctype_big5.result | 4 | ||||
-rwxr-xr-x | mysql-test/r/ctype_cp932.result | 74 | ||||
-rw-r--r-- | mysql-test/r/ctype_euckr.result | 4 | ||||
-rw-r--r-- | mysql-test/r/ctype_gb2312.result | 4 | ||||
-rw-r--r-- | mysql-test/r/ctype_gbk.result | 4 | ||||
-rw-r--r-- | mysql-test/r/ctype_uca.result | 4 | ||||
-rw-r--r-- | mysql-test/r/delayed.result | 5 | ||||
-rw-r--r-- | mysql-test/r/func_misc.result | 7 | ||||
-rw-r--r-- | mysql-test/t/ctype_cp932.test | 4 | ||||
-rw-r--r-- | mysql-test/t/delayed.test | 9 | ||||
-rw-r--r-- | mysql-test/t/func_misc.test | 12 | ||||
-rw-r--r-- | sql/item.cc | 12 | ||||
-rw-r--r-- | sql/item.h | 4 | ||||
-rw-r--r-- | sql/sql_insert.cc | 4 | ||||
-rw-r--r-- | strings/ctype-cp932.c | 4 |
16 files changed, 150 insertions, 7 deletions
diff --git a/mysql-test/include/ctype_common.inc b/mysql-test/include/ctype_common.inc index 9ee0a40c8ce..89b7ceb0c72 100644 --- a/mysql-test/include/ctype_common.inc +++ b/mysql-test/include/ctype_common.inc @@ -53,11 +53,13 @@ DROP TABLE t1; # # Bug #31070: crash during conversion of charsets +# Bug #32726: crash with cast in order by clause and cp932 charset # create table t1 (a set('a') not null); insert into t1 values (),(); select cast(a as char(1)) from t1; select a sounds like a from t1; +select 1 from t1 order by cast(a as char(1)); drop table t1; DROP DATABASE d1; diff --git a/mysql-test/r/ctype_big5.result b/mysql-test/r/ctype_big5.result index b190273cc64..8103e9b856f 100644 --- a/mysql-test/r/ctype_big5.result +++ b/mysql-test/r/ctype_big5.result @@ -64,6 +64,10 @@ select a sounds like a from t1; a sounds like a 1 1 +select 1 from t1 order by cast(a as char(1)); +1 +1 +1 drop table t1; DROP DATABASE d1; USE test; diff --git a/mysql-test/r/ctype_cp932.result b/mysql-test/r/ctype_cp932.result index e3598f00777..8974a6a8594 100755 --- a/mysql-test/r/ctype_cp932.result +++ b/mysql-test/r/ctype_cp932.result @@ -2,6 +2,80 @@ drop table if exists t1; drop table if exists t2; drop table if exists t3; drop table if exists t4; +SET @test_character_set= 'cp932'; +SET @test_collation= 'cp932_japanese_ci'; +SET @safe_character_set_server= @@character_set_server; +SET @safe_collation_server= @@collation_server; +SET character_set_server= @test_character_set; +SET collation_server= @test_collation; +CREATE DATABASE d1; +USE d1; +CREATE TABLE t1 (c CHAR(10), KEY(c)); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c char(10) cp932_japanese_ci YES MUL NULL +INSERT INTO t1 VALUES ('aaa'),('aaaa'),('aaaaa'); +SELECT c as want3results FROM t1 WHERE c LIKE 'aaa%'; +want3results +aaa +aaaa +aaaaa +DROP TABLE t1; +CREATE TABLE t1 (c1 varchar(15), KEY c1 (c1(2))); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c1 varchar(15) cp932_japanese_ci YES MUL NULL +INSERT INTO t1 VALUES ('location'),('loberge'),('lotre'),('boabab'); +SELECT c1 as want3results from t1 where c1 like 'l%'; +want3results +location +loberge +lotre +SELECT c1 as want3results from t1 where c1 like 'lo%'; +want3results +location +loberge +lotre +SELECT c1 as want1result from t1 where c1 like 'loc%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'loca%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locat%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locati%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locatio%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'location%'; +want1result +location +DROP TABLE t1; +create table t1 (a set('a') not null); +insert into t1 values (),(); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +select cast(a as char(1)) from t1; +cast(a as char(1)) + + +select a sounds like a from t1; +a sounds like a +1 +1 +select 1 from t1 order by cast(a as char(1)); +1 +1 +1 +drop table t1; +DROP DATABASE d1; +USE test; +SET character_set_server= @safe_character_set_server; +SET collation_server= @safe_collation_server; set names cp932; set character_set_database = cp932; CREATE TABLE t1(c1 CHAR(1)) DEFAULT CHARACTER SET = cp932; diff --git a/mysql-test/r/ctype_euckr.result b/mysql-test/r/ctype_euckr.result index ee786202c01..bb1b3f5995b 100644 --- a/mysql-test/r/ctype_euckr.result +++ b/mysql-test/r/ctype_euckr.result @@ -64,6 +64,10 @@ select a sounds like a from t1; a sounds like a 1 1 +select 1 from t1 order by cast(a as char(1)); +1 +1 +1 drop table t1; DROP DATABASE d1; USE test; diff --git a/mysql-test/r/ctype_gb2312.result b/mysql-test/r/ctype_gb2312.result index 90c94c3b299..95246525368 100644 --- a/mysql-test/r/ctype_gb2312.result +++ b/mysql-test/r/ctype_gb2312.result @@ -64,6 +64,10 @@ select a sounds like a from t1; a sounds like a 1 1 +select 1 from t1 order by cast(a as char(1)); +1 +1 +1 drop table t1; DROP DATABASE d1; USE test; diff --git a/mysql-test/r/ctype_gbk.result b/mysql-test/r/ctype_gbk.result index fe90c7bff29..8437e34be1e 100644 --- a/mysql-test/r/ctype_gbk.result +++ b/mysql-test/r/ctype_gbk.result @@ -64,6 +64,10 @@ select a sounds like a from t1; a sounds like a 1 1 +select 1 from t1 order by cast(a as char(1)); +1 +1 +1 drop table t1; DROP DATABASE d1; USE test; diff --git a/mysql-test/r/ctype_uca.result b/mysql-test/r/ctype_uca.result index ae9146fc9db..50be0ca53b2 100644 --- a/mysql-test/r/ctype_uca.result +++ b/mysql-test/r/ctype_uca.result @@ -2599,6 +2599,10 @@ select a sounds like a from t1; a sounds like a 1 1 +select 1 from t1 order by cast(a as char(1)); +1 +1 +1 drop table t1; DROP DATABASE d1; USE test; diff --git a/mysql-test/r/delayed.result b/mysql-test/r/delayed.result index ff333d88fef..9f6ebea7e1b 100644 --- a/mysql-test/r/delayed.result +++ b/mysql-test/r/delayed.result @@ -255,3 +255,8 @@ CREATE TABLE t2(c1 INT) ENGINE=MERGE UNION=(t1); INSERT DELAYED INTO t2 VALUES(1); ERROR HY000: Table storage engine for 't2' doesn't have this option DROP TABLE t1, t2; +CREATE TABLE t1 (a INT); +INSERT DELAYED INTO t1 SET b= b(); +ERROR 42S22: Unknown column 'b' in 'field list' +DROP TABLE t1; +End of 5.0 tests diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index a302ad4769e..c0b666dbc79 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -207,6 +207,13 @@ test SELECT NAME_CONST('test', 'test'); test test +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (), (), (); +SELECT NAME_CONST(a, '1') FROM t1; +ERROR HY000: Incorrect arguments to NAME_CONST +SET INSERT_ID= NAME_CONST(a, a); +ERROR HY000: Incorrect arguments to NAME_CONST +DROP TABLE t1; create table t1 (a int not null); insert into t1 values (-1), (-2); select min(a) from t1 group by inet_ntoa(a); diff --git a/mysql-test/t/ctype_cp932.test b/mysql-test/t/ctype_cp932.test index 633f3af0d2b..3521a6fc91e 100644 --- a/mysql-test/t/ctype_cp932.test +++ b/mysql-test/t/ctype_cp932.test @@ -8,6 +8,10 @@ drop table if exists t3; drop table if exists t4; --enable_warnings +SET @test_character_set= 'cp932'; +SET @test_collation= 'cp932_japanese_ci'; +-- source include/ctype_common.inc + set names cp932; set character_set_database = cp932; diff --git a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test index b09472d3485..db01aade3ca 100644 --- a/mysql-test/t/delayed.test +++ b/mysql-test/t/delayed.test @@ -252,3 +252,12 @@ CREATE TABLE t2(c1 INT) ENGINE=MERGE UNION=(t1); INSERT DELAYED INTO t2 VALUES(1); DROP TABLE t1, t2; +# +# Bug #32676: insert delayed crash with wrong column and function specified +# +CREATE TABLE t1 (a INT); +--error ER_BAD_FIELD_ERROR +INSERT DELAYED INTO t1 SET b= b(); +DROP TABLE t1; + +--echo End of 5.0 tests diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index c8b8f8f2a69..844e60ab7ae 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -205,6 +205,17 @@ SELECT NAME_CONST('test', -1.0); SELECT NAME_CONST('test', 'test'); # +# Bug #32559: connection hangs on query with name_const +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (), (), (); +--error ER_WRONG_ARGUMENTS +SELECT NAME_CONST(a, '1') FROM t1; +--error ER_WRONG_ARGUMENTS +SET INSERT_ID= NAME_CONST(a, a); +DROP TABLE t1; + +# # Bug #31349: ERROR 1062 (23000): Duplicate entry '' for key 'group_key' # create table t1 (a int not null); @@ -213,4 +224,3 @@ select min(a) from t1 group by inet_ntoa(a); drop table t1; --echo End of 5.0 tests - diff --git a/sql/item.cc b/sql/item.cc index 431d82af331..a75d0159848 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1209,7 +1209,17 @@ bool Item_name_const::is_null() Item::Type Item_name_const::type() const { - return value_item->type(); + /* + As + 1. one can try to create the Item_name_const passing non-constant + arguments, although it's incorrect and + 2. the type() method can be called before the fix_fields() to get + type information for a further type cast, e.g. + if (item->type() == FIELD_ITEM) + ((Item_field *) item)->... + we return NULL_ITEM in the case to avoid wrong casting. + */ + return valid_args ? value_item->type() : NULL_ITEM; } diff --git a/sql/item.h b/sql/item.h index a1135c2c725..fbf4b94b276 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1111,11 +1111,13 @@ class Item_name_const : public Item { Item *value_item; Item *name_item; + bool valid_args; public: Item_name_const(Item *name_arg, Item *val): value_item(val), name_item(name_arg) { - if(!value_item->basic_const_item()) + if (!(valid_args= name_item->basic_const_item() & + value_item->basic_const_item())) my_error(ER_WRONG_ARGUMENTS, MYF(0), "NAME_CONST"); Item::maybe_null= TRUE; } diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 65d8bb23706..7273fbf74e3 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -585,7 +585,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, bool log_on= (thd->options & OPTION_BIN_LOG) || (!(thd->security_ctx->master_access & SUPER_ACL)); #endif - thr_lock_type lock_type = table_list->lock_type; + thr_lock_type lock_type; Item *unused_conds= 0; DBUG_ENTER("mysql_insert"); @@ -620,6 +620,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, if (open_and_lock_tables(thd, table_list)) DBUG_RETURN(TRUE); } + lock_type= table_list->lock_type; thd->proc_info="init"; thd->used_tables=0; @@ -637,7 +638,6 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, /* mysql_prepare_insert set table_list->table if it was not set */ table= table_list->table; - lock_type= table_list->lock_type; context= &thd->lex->select_lex.context; /* diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c index 42325648037..48c217921b1 100644 --- a/strings/ctype-cp932.c +++ b/strings/ctype-cp932.c @@ -5359,12 +5359,12 @@ my_wc_mb_cp932(CHARSET_INFO *cs __attribute__((unused)), static int my_mb_wc_cp932(CHARSET_INFO *cs __attribute__((unused)), my_wc_t *pwc, const uchar *s, const uchar *e){ - int hi=s[0]; + int hi; if (s >= e) return MY_CS_TOOSMALL; - if (hi < 0x80) + if ((hi= s[0]) < 0x80) { pwc[0]=hi; return 1; |