Commit a4823607 authored by unknown's avatar unknown

Merge moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0

into  moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0-bug17047


sql/item_strfunc.cc:
  Auto merged
mysql-test/r/func_str.result:
  Manual merge.
mysql-test/t/func_str.test:
  Manual merge.
parents 541e9c9a af22eb35
...@@ -202,6 +202,14 @@ select count(*) from t1 where id not in (1,2); ...@@ -202,6 +202,14 @@ select count(*) from t1 where id not in (1,2);
count(*) count(*)
1 1
drop table t1; drop table t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 SELECT 1 IN (2, NULL);
SELECT should return NULL.
SELECT * FROM t1;
1 IN (2, NULL)
NULL
DROP TABLE t1;
End of 4.1 tests
CREATE TABLE t1 (a int PRIMARY KEY); CREATE TABLE t1 (a int PRIMARY KEY);
INSERT INTO t1 VALUES (44), (45), (46); INSERT INTO t1 VALUES (44), (45), (46);
SELECT * FROM t1 WHERE a IN (45); SELECT * FROM t1 WHERE a IN (45);
...@@ -343,3 +351,4 @@ some_id ...@@ -343,3 +351,4 @@ some_id
1 1
2 2
drop table t1; drop table t1;
End of 5.0 tests
...@@ -1903,4 +1903,17 @@ Warnings: ...@@ -1903,4 +1903,17 @@ Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1292 Truncated incorrect DECIMAL value: ''
Error 1292 Truncated incorrect DECIMAL value: '' Error 1292 Truncated incorrect DECIMAL value: ''
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
SET @orig_sql_mode = @@SQL_MODE;
SET SQL_MODE=traditional;
SELECT CHAR(0xff,0x8f USING utf8);
CHAR(0xff,0x8f USING utf8)
NULL
Warnings:
Error 1300 Invalid utf8 character string: 'FF8F'
SELECT CHAR(0xff,0x8f USING utf8) IS NULL;
CHAR(0xff,0x8f USING utf8) IS NULL
1
Warnings:
Error 1300 Invalid utf8 character string: 'FF8F'
SET SQL_MODE=@orig_sql_mode;
End of 5.0 tests End of 5.0 tests
...@@ -109,7 +109,28 @@ select count(*) from t1 where id not in (1); ...@@ -109,7 +109,28 @@ select count(*) from t1 where id not in (1);
select count(*) from t1 where id not in (1,2); select count(*) from t1 where id not in (1,2);
drop table t1; drop table t1;
# End of 4.1 tests
#
# BUG#17047: CHAR() and IN() can return NULL without signaling NULL
# result
#
# The problem was in the IN() function that ignored maybe_null flags
# of all arguments except the first (the one _before_ the IN
# keyword, '1' in the test case below).
#
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 SELECT 1 IN (2, NULL);
--echo SELECT should return NULL.
SELECT * FROM t1;
DROP TABLE t1;
--echo End of 4.1 tests
# #
# Bug #11885: WHERE condition with NOT IN (one element) # Bug #11885: WHERE condition with NOT IN (one element)
...@@ -232,3 +253,6 @@ select some_id from t1 where some_id not in(2,-1); ...@@ -232,3 +253,6 @@ select some_id from t1 where some_id not in(2,-1);
select some_id from t1 where some_id not in(-4,-1,-4); select some_id from t1 where some_id not in(-4,-1,-4);
select some_id from t1 where some_id not in(-4,-1,3423534,2342342); select some_id from t1 where some_id not in(-4,-1,3423534,2342342);
drop table t1; drop table t1;
--echo End of 5.0 tests
...@@ -780,6 +780,7 @@ SELECT * FROM t1 INNER JOIN t2 ON code=id ...@@ -780,6 +780,7 @@ SELECT * FROM t1 INNER JOIN t2 ON code=id
DROP TABLE t1,t2; DROP TABLE t1,t2;
# #
# Bug #10963 # Bug #10963
# 4294967296 18446744073709551616 # 4294967296 18446744073709551616
...@@ -969,4 +970,18 @@ select lpad('hello', 18446744073709551616, '1'); ...@@ -969,4 +970,18 @@ select lpad('hello', 18446744073709551616, '1');
select lpad('hello', -18446744073709551617, '1'); select lpad('hello', -18446744073709551617, '1');
select lpad('hello', 18446744073709551617, '1'); select lpad('hello', 18446744073709551617, '1');
#
# BUG#17047: CHAR() and IN() can return NULL without signaling NULL
# result
#
SET @orig_sql_mode = @@SQL_MODE;
SET SQL_MODE=traditional;
SELECT CHAR(0xff,0x8f USING utf8);
SELECT CHAR(0xff,0x8f USING utf8) IS NULL;
SET SQL_MODE=@orig_sql_mode;
--echo End of 5.0 tests --echo End of 5.0 tests
...@@ -2465,7 +2465,6 @@ void Item_func_in::fix_length_and_dec() ...@@ -2465,7 +2465,6 @@ void Item_func_in::fix_length_and_dec()
if (cmp_type == STRING_RESULT) if (cmp_type == STRING_RESULT)
in_item->cmp_charset= cmp_collation.collation; in_item->cmp_charset= cmp_collation.collation;
} }
maybe_null= args[0]->maybe_null;
max_length= 1; max_length= 1;
} }
......
...@@ -80,6 +80,20 @@ String *Item_str_func::check_well_formed_result(String *str) ...@@ -80,6 +80,20 @@ String *Item_str_func::check_well_formed_result(String *str)
} }
bool Item_str_func::fix_fields(THD *thd, Item **ref)
{
bool res= Item_func::fix_fields(thd, ref);
/*
In Item_str_func::check_well_formed_result() we may set null_value
flag on the same condition as in test() below.
*/
maybe_null= (maybe_null ||
test(thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)));
return res;
}
my_decimal *Item_str_func::val_decimal(my_decimal *decimal_value) my_decimal *Item_str_func::val_decimal(my_decimal *decimal_value)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
......
...@@ -37,6 +37,7 @@ public: ...@@ -37,6 +37,7 @@ public:
enum Item_result result_type () const { return STRING_RESULT; } enum Item_result result_type () const { return STRING_RESULT; }
void left_right_max_length(); void left_right_max_length();
String *check_well_formed_result(String *str); String *check_well_formed_result(String *str);
bool fix_fields(THD *thd, Item **ref);
}; };
class Item_func_md5 :public Item_str_func class Item_func_md5 :public Item_str_func
...@@ -526,8 +527,7 @@ public: ...@@ -526,8 +527,7 @@ public:
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec() void fix_length_and_dec()
{ {
maybe_null=0; max_length= arg_count * collation.collation->mbmaxlen;
max_length=arg_count * collation.collation->mbmaxlen;
} }
const char *func_name() const { return "char"; } const char *func_name() const { return "char"; }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment