Loading mysql-test/r/func_if.result +46 −0 Original line number Diff line number Diff line Loading @@ -131,3 +131,49 @@ drop table t1; select if(0, 18446744073709551610, 18446744073709551610); if(0, 18446744073709551610, 18446744073709551610) 18446744073709551610 CREATE TABLE t1(a DECIMAL(10,3)); SELECT t1.a, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2,0)))))))))))))))))))))))))))))) + 1 FROM t1; a IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((R DROP TABLE t1; End of 5.0 tests mysql-test/r/subselect.result +12 −1 Original line number Diff line number Diff line Loading @@ -4398,4 +4398,15 @@ INSERT INTO t1 VALUES (1), (3); SELECT * FROM t2 WHERE b NOT IN (SELECT max(t.c) FROM t1, t1 t WHERE t.c>10); a b DROP TABLE t1,t2; End of 5.0 tests. CREATE TABLE t1(pk int PRIMARY KEY, a int, INDEX idx(a)); INSERT INTO t1 VALUES (1, 10), (3, 30), (2, 20); CREATE TABLE t2(pk int PRIMARY KEY, a int, b int, INDEX idxa(a)); INSERT INTO t2 VALUES (2, 20, 700), (1, 10, 200), (4, 10, 100); SELECT * FROM t1 WHERE EXISTS (SELECT DISTINCT a FROM t2 WHERE t1.a < t2.a ORDER BY b); pk a 1 10 3 30 2 20 DROP TABLE t1,t2; End of 5.1 tests. mysql-test/t/func_if.test +43 −0 Original line number Diff line number Diff line Loading @@ -108,3 +108,46 @@ drop table t1; select if(0, 18446744073709551610, 18446744073709551610); # # Bug #37662: nested if() inside sum() is parsed in exponential time # CREATE TABLE t1(a DECIMAL(10,3)); # check : should be fast. more than few secs means failure. SELECT t1.a, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2,0)))))))))))))))))))))))))))))) + 1 FROM t1; DROP TABLE t1; --echo End of 5.0 tests mysql-test/t/subselect.test +13 −1 Original line number Diff line number Diff line Loading @@ -3299,4 +3299,16 @@ SELECT * FROM t2 WHERE b NOT IN (SELECT max(t.c) FROM t1, t1 t WHERE t.c>10); DROP TABLE t1,t2; --echo End of 5.0 tests. # # Bug #38191: Server crash with subquery containing DISTINCT and ORDER BY # CREATE TABLE t1(pk int PRIMARY KEY, a int, INDEX idx(a)); INSERT INTO t1 VALUES (1, 10), (3, 30), (2, 20); CREATE TABLE t2(pk int PRIMARY KEY, a int, b int, INDEX idxa(a)); INSERT INTO t2 VALUES (2, 20, 700), (1, 10, 200), (4, 10, 100); SELECT * FROM t1 WHERE EXISTS (SELECT DISTINCT a FROM t2 WHERE t1.a < t2.a ORDER BY b); DROP TABLE t1,t2; --echo End of 5.1 tests. sql/item.cc +8 −4 Original line number Diff line number Diff line Loading @@ -437,8 +437,11 @@ uint Item::decimal_precision() const Item_result restype= result_type(); if ((restype == DECIMAL_RESULT) || (restype == INT_RESULT)) return min(my_decimal_length_to_precision(max_length, decimals, unsigned_flag), DECIMAL_MAX_PRECISION); { uint prec= my_decimal_length_to_precision(max_length, decimals, unsigned_flag); return min(prec, DECIMAL_MAX_PRECISION); } return min(max_length, DECIMAL_MAX_PRECISION); } Loading Loading @@ -6995,8 +6998,9 @@ bool Item_type_holder::join_types(THD *thd, Item *item) if (Field::result_merge_type(fld_type) == DECIMAL_RESULT) { decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE); int precision= min(max(prev_decimal_int_part, item->decimal_int_part()) + decimals, DECIMAL_MAX_PRECISION); int item_int_part= item->decimal_int_part(); int item_prec = max(prev_decimal_int_part, item_int_part) + decimals; int precision= min(item_prec, DECIMAL_MAX_PRECISION); unsigned_flag&= item->unsigned_flag; max_length= my_decimal_precision_to_length(precision, decimals, unsigned_flag); Loading Loading
mysql-test/r/func_if.result +46 −0 Original line number Diff line number Diff line Loading @@ -131,3 +131,49 @@ drop table t1; select if(0, 18446744073709551610, 18446744073709551610); if(0, 18446744073709551610, 18446744073709551610) 18446744073709551610 CREATE TABLE t1(a DECIMAL(10,3)); SELECT t1.a, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2,0)))))))))))))))))))))))))))))) + 1 FROM t1; a IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((R DROP TABLE t1; End of 5.0 tests
mysql-test/r/subselect.result +12 −1 Original line number Diff line number Diff line Loading @@ -4398,4 +4398,15 @@ INSERT INTO t1 VALUES (1), (3); SELECT * FROM t2 WHERE b NOT IN (SELECT max(t.c) FROM t1, t1 t WHERE t.c>10); a b DROP TABLE t1,t2; End of 5.0 tests. CREATE TABLE t1(pk int PRIMARY KEY, a int, INDEX idx(a)); INSERT INTO t1 VALUES (1, 10), (3, 30), (2, 20); CREATE TABLE t2(pk int PRIMARY KEY, a int, b int, INDEX idxa(a)); INSERT INTO t2 VALUES (2, 20, 700), (1, 10, 200), (4, 10, 100); SELECT * FROM t1 WHERE EXISTS (SELECT DISTINCT a FROM t2 WHERE t1.a < t2.a ORDER BY b); pk a 1 10 3 30 2 20 DROP TABLE t1,t2; End of 5.1 tests.
mysql-test/t/func_if.test +43 −0 Original line number Diff line number Diff line Loading @@ -108,3 +108,46 @@ drop table t1; select if(0, 18446744073709551610, 18446744073709551610); # # Bug #37662: nested if() inside sum() is parsed in exponential time # CREATE TABLE t1(a DECIMAL(10,3)); # check : should be fast. more than few secs means failure. SELECT t1.a, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2,0)))))))))))))))))))))))))))))) + 1 FROM t1; DROP TABLE t1; --echo End of 5.0 tests
mysql-test/t/subselect.test +13 −1 Original line number Diff line number Diff line Loading @@ -3299,4 +3299,16 @@ SELECT * FROM t2 WHERE b NOT IN (SELECT max(t.c) FROM t1, t1 t WHERE t.c>10); DROP TABLE t1,t2; --echo End of 5.0 tests. # # Bug #38191: Server crash with subquery containing DISTINCT and ORDER BY # CREATE TABLE t1(pk int PRIMARY KEY, a int, INDEX idx(a)); INSERT INTO t1 VALUES (1, 10), (3, 30), (2, 20); CREATE TABLE t2(pk int PRIMARY KEY, a int, b int, INDEX idxa(a)); INSERT INTO t2 VALUES (2, 20, 700), (1, 10, 200), (4, 10, 100); SELECT * FROM t1 WHERE EXISTS (SELECT DISTINCT a FROM t2 WHERE t1.a < t2.a ORDER BY b); DROP TABLE t1,t2; --echo End of 5.1 tests.
sql/item.cc +8 −4 Original line number Diff line number Diff line Loading @@ -437,8 +437,11 @@ uint Item::decimal_precision() const Item_result restype= result_type(); if ((restype == DECIMAL_RESULT) || (restype == INT_RESULT)) return min(my_decimal_length_to_precision(max_length, decimals, unsigned_flag), DECIMAL_MAX_PRECISION); { uint prec= my_decimal_length_to_precision(max_length, decimals, unsigned_flag); return min(prec, DECIMAL_MAX_PRECISION); } return min(max_length, DECIMAL_MAX_PRECISION); } Loading Loading @@ -6995,8 +6998,9 @@ bool Item_type_holder::join_types(THD *thd, Item *item) if (Field::result_merge_type(fld_type) == DECIMAL_RESULT) { decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE); int precision= min(max(prev_decimal_int_part, item->decimal_int_part()) + decimals, DECIMAL_MAX_PRECISION); int item_int_part= item->decimal_int_part(); int item_prec = max(prev_decimal_int_part, item_int_part) + decimals; int precision= min(item_prec, DECIMAL_MAX_PRECISION); unsigned_flag&= item->unsigned_flag; max_length= my_decimal_precision_to_length(precision, decimals, unsigned_flag); Loading