mirror of
https://github.com/MariaDB/server.git
synced 2025-01-27 17:33:44 +01:00
40d72add32
from 5.1 to 5.5 (Former 59405) In this bug, args[0] in an Item_func_find_in_set stored an Item_func_weekday that was constant. In Item_func_find_in_set::fix_length_and_dec(), args[0]->val_str() was called. Later, when Item_func_find_in_set::val_int() was called, args[0]->null_value was checked. However, the Item_func_weekday in args[0] had now been replaced with an Item_cache. No val_*() calls had been made to this Item_cache, thus null_value was incorrectly 'true', resulting in missing rows in the result set. enum_value gets a value in fix_length_and_dec() iff args[0] is both constant and non-null. It is therefore unnecessary to check the null_value of args[0] in val_int(). An alternative fix would be to call args[0]->val_int() inside Item_func_find_in_set::val_int(). This would ensure args[0]->null_value was set correctly (always false in this case), but that would have to be done for every record this const value is checked against.
121 lines
4.7 KiB
Text
121 lines
4.7 KiB
Text
#
|
|
# Testing if SET and similar functions
|
|
#
|
|
|
|
select interval(55,10,20,30,40,50,60,70,80,90,100),interval(3,1,1+1,1+1+1+1),field("IBM","NCA","ICL","SUN","IBM","DIGITAL"),field("A","B","C"),elt(2,"ONE","TWO","THREE"),interval(0,1,2,3,4),elt(1,1,2,3)|0,elt(1,1.1,1.2,1.3)+0;
|
|
explain extended select INTERVAL(55,10,20,30,40,50,60,70,80,90,100),interval(3,1,1+1,1+1+1+1),field("IBM","NCA","ICL","SUN","IBM","DIGITAL"),field("A","B","C"),elt(2,"ONE","TWO","THREE"),interval(0,1,2,3,4),elt(1,1,2,3)|0,elt(1,1.1,1.2,1.3)+0;
|
|
# Test 8 and 9 values (Bug #1561)
|
|
SELECT INTERVAL(13, 7, 14, 21, 28, 35, 42, 49, 56);
|
|
SELECT INTERVAL(13, 7, 14, 21, 28, 35, 42, 49, 56, 77);
|
|
|
|
select find_in_set("b","a,b,c"),find_in_set("c","a,b,c"),find_in_set("dd","a,bbb,dd"),find_in_set("bbb","a,bbb,dd");
|
|
select find_in_set("d","a,b,c"),find_in_set("dd","a,bbb,d"),find_in_set("bb","a,bbb,dd");
|
|
select make_set(0,'a','b','c'),make_set(-1,'a','b','c'),make_set(1,'a','b','c'),make_set(2,'a','b','c'),make_set(1+2,concat('a','b'),'c');
|
|
select make_set(NULL,'a','b','c'),make_set(1|4,'a',NULL,'c'),make_set(1+2,'a',NULL,'c');
|
|
select export_set(9,"Y","N","-",5),export_set(9,"Y","N"),export_set(9,"Y","N","");
|
|
|
|
#
|
|
# Wrong usage of functions
|
|
#
|
|
select elt(2,1),field(NULL,"a","b","c");
|
|
select field("b","a",NULL),field(1,0,NULL)+0,field(1.0,0.0,NULL)+0.0,field(1.0e1,0.0e1,NULL)+0.0e1;
|
|
select field(NULL,"a",NULL),field(NULL,0,NULL)+0,field(NULL,0.0,NULL)+0.0,field(NULL,0.0e1,NULL)+0.0e1;
|
|
select find_in_set("","a,b,c"),find_in_set("","a,b,c,"),find_in_set("",",a,b,c");
|
|
select find_in_set("abc","abc"),find_in_set("ab","abc"),find_in_set("abcd","abc");
|
|
select interval(null, 1, 10, 100);
|
|
|
|
#
|
|
# test for a bug with elt()
|
|
#
|
|
|
|
--disable_warnings
|
|
drop table if exists t1,t2;
|
|
--enable_warnings
|
|
|
|
create table t1 (id int(10) not null unique);
|
|
create table t2 (id int(10) not null primary key, val int(10) not null);
|
|
insert into t1 values (1),(2),(4);
|
|
insert into t2 values (1,1),(2,1),(3,1),(4,2);
|
|
|
|
select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id;
|
|
select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id order by one.id;
|
|
drop table t1,t2;
|
|
|
|
#
|
|
# Bug4340: find_in_set is case insensitive even on binary operators
|
|
#
|
|
|
|
select find_in_set(binary 'a',binary 'A,B,C');
|
|
select find_in_set('a',binary 'A,B,C');
|
|
select find_in_set(binary 'a', 'A,B,C');
|
|
|
|
#
|
|
# Bug5513:FIND_IN_SET fails if set ends with a comma
|
|
#
|
|
select find_in_set('1','3,1,');
|
|
|
|
--echo End of 4.1 tests
|
|
|
|
#
|
|
# Bug #32560: crash with interval function and count(*)
|
|
#
|
|
SELECT INTERVAL(0.0, NULL);
|
|
SELECT INTERVAL(0.0, CAST(NULL AS DECIMAL));
|
|
SELECT INTERVAL(0.0, CAST(DATE(NULL) AS DECIMAL));
|
|
SELECT INTERVAL(0.0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
|
SELECT INTERVAL(0.0, CAST(NULL AS DECIMAL), CAST(NULL AS DECIMAL),
|
|
CAST(NULL AS DECIMAL), CAST(NULL AS DECIMAL), CAST(NULL AS DECIMAL),
|
|
CAST(NULL AS DECIMAL), CAST(NULL AS DECIMAL), CAST(NULL AS DECIMAL));
|
|
SELECT INTERVAL(0.0, CAST(DATE(NULL) AS DECIMAL), CAST(DATE(NULL) AS DECIMAL),
|
|
CAST(DATE(NULL) AS DECIMAL), CAST(DATE(NULL) AS DECIMAL),
|
|
CAST(DATE(NULL) AS DECIMAL), CAST(DATE(NULL) AS DECIMAL),
|
|
CAST(DATE(NULL) AS DECIMAL), CAST(DATE(NULL) AS DECIMAL));
|
|
|
|
--echo End of 5.0 tests
|
|
|
|
#
|
|
# Bug#44367 valgrind warnings with find_in_set() functions
|
|
#
|
|
--disable_warnings
|
|
drop table if exists t1;
|
|
--enable_warnings
|
|
create table t1 (f1 set('test1','test2','test3') character set utf8 default null)
|
|
engine=myisam default charset=latin1;
|
|
insert into t1 values (''),(null),(null),(''),(''),('');
|
|
select find_in_set(f1,f1) as a from t1,(select find_in_set(f1,f1) as b from t1) a;
|
|
drop table t1;
|
|
#
|
|
# Bug#45168: assertion with convert() and empty set value
|
|
#
|
|
CREATE TABLE t1( a SET('a', 'b', 'c') );
|
|
CREATE TABLE t2( a SET('a', 'b', 'c') );
|
|
|
|
INSERT INTO t1 VALUES ('d');
|
|
INSERT INTO t2 VALUES ('');
|
|
|
|
SELECT CONVERT( a USING latin1 ) FROM t1;
|
|
SELECT CONVERT( a USING latin1 ) FROM t2;
|
|
|
|
DROP TABLE t1, t2;
|
|
|
|
--echo #
|
|
--echo # BUG#59405: FIND_IN_SET won't work normaly after upgrade from 5.1 to 5.5
|
|
--echo #
|
|
|
|
CREATE TABLE t1(days set('1','2','3','4','5','6','7'));
|
|
INSERT INTO t1 VALUES('1,2,3,4,5,6,7'), (NULL), ('1,2,3,4,5,6,7');
|
|
|
|
--echo
|
|
SELECT * FROM t1 WHERE FIND_IN_SET(DAYOFWEEK(CURRENT_DATE()), days);
|
|
SELECT * FROM t1 WHERE FIND_IN_SET(DAYOFWEEK(CURRENT_DATE()), days) IS UNKNOWN;
|
|
SELECT * FROM t1 WHERE FIND_IN_SET(DAYOFWEEK(CURRENT_DATE()), NULL);
|
|
SELECT * FROM t1 WHERE FIND_IN_SET(DAYOFWEEK(CURRENT_DATE()), NULL) IS UNKNOWN;
|
|
SELECT * FROM t1 WHERE FIND_IN_SET(7, days);
|
|
SELECT * FROM t1 WHERE FIND_IN_SET(8, days);
|
|
SELECT * FROM t1 WHERE FIND_IN_SET(NULL, days);
|
|
SELECT * FROM t1 WHERE FIND_IN_SET(NULL, days) IS UNKNOWN;
|
|
SELECT * FROM t1 WHERE FIND_IN_SET(NULL, NULL);
|
|
SELECT * FROM t1 WHERE FIND_IN_SET(NULL, NULL) IS UNKNOWN;
|
|
|
|
--echo
|
|
DROP TABLE t1;
|