Loading mysql-test/r/subselect.result +21 −0 Original line number Diff line number Diff line Loading @@ -3183,3 +3183,24 @@ select * from (select min(i) from t1 where j=(select * from (select min(j) from min(i) 1 drop table t1; CREATE TABLE t1 (i BIGINT UNSIGNED); INSERT INTO t1 VALUES (10000000000000000000); INSERT INTO t1 VALUES (1); CREATE TABLE t2 (i BIGINT UNSIGNED); INSERT INTO t2 VALUES (10000000000000000000); INSERT INTO t2 VALUES (1); /* simple test */ SELECT t1.i FROM t1 JOIN t2 ON t1.i = t2.i; i 10000000000000000000 1 /* subquery test */ SELECT t1.i FROM t1 WHERE t1.i = (SELECT MAX(i) FROM t2); i 10000000000000000000 /* subquery test with cast*/ SELECT t1.i FROM t1 WHERE t1.i = CAST((SELECT MAX(i) FROM t2) AS UNSIGNED); i 10000000000000000000 DROP TABLE t1; DROP TABLE t2; mysql-test/t/subselect.test +22 −0 Original line number Diff line number Diff line Loading @@ -2109,3 +2109,25 @@ insert into t1 values (1, 2), (2, 2), (3, 2); select * from (select min(i) from t1 where j=(select * from (select min(j) from t1) t2)) t3; drop table t1; # # Bug#19700: subselect returning BIGINT always returned it as SIGNED # CREATE TABLE t1 (i BIGINT UNSIGNED); INSERT INTO t1 VALUES (10000000000000000000); -- > MAX SIGNED BIGINT 9323372036854775807 INSERT INTO t1 VALUES (1); CREATE TABLE t2 (i BIGINT UNSIGNED); INSERT INTO t2 VALUES (10000000000000000000); -- same as first table INSERT INTO t2 VALUES (1); /* simple test */ SELECT t1.i FROM t1 JOIN t2 ON t1.i = t2.i; /* subquery test */ SELECT t1.i FROM t1 WHERE t1.i = (SELECT MAX(i) FROM t2); /* subquery test with cast*/ SELECT t1.i FROM t1 WHERE t1.i = CAST((SELECT MAX(i) FROM t2) AS UNSIGNED); DROP TABLE t1; DROP TABLE t2; sql/item.h +1 −0 Original line number Diff line number Diff line Loading @@ -2245,6 +2245,7 @@ class Item_cache: public Item max_length= item->max_length; decimals= item->decimals; collation.set(item->collation); unsigned_flag= item->unsigned_flag; return 0; }; virtual void store(Item *)= 0; Loading sql/item_subselect.cc +1 −0 Original line number Diff line number Diff line Loading @@ -404,6 +404,7 @@ void Item_singlerow_subselect::fix_length_and_dec() engine->fix_length_and_dec(row); value= *row; } unsigned_flag= value->unsigned_flag; /* If there are not tables in subquery then ability to have NULL value depends on SELECT list (if single row subquery have tables then it Loading Loading
mysql-test/r/subselect.result +21 −0 Original line number Diff line number Diff line Loading @@ -3183,3 +3183,24 @@ select * from (select min(i) from t1 where j=(select * from (select min(j) from min(i) 1 drop table t1; CREATE TABLE t1 (i BIGINT UNSIGNED); INSERT INTO t1 VALUES (10000000000000000000); INSERT INTO t1 VALUES (1); CREATE TABLE t2 (i BIGINT UNSIGNED); INSERT INTO t2 VALUES (10000000000000000000); INSERT INTO t2 VALUES (1); /* simple test */ SELECT t1.i FROM t1 JOIN t2 ON t1.i = t2.i; i 10000000000000000000 1 /* subquery test */ SELECT t1.i FROM t1 WHERE t1.i = (SELECT MAX(i) FROM t2); i 10000000000000000000 /* subquery test with cast*/ SELECT t1.i FROM t1 WHERE t1.i = CAST((SELECT MAX(i) FROM t2) AS UNSIGNED); i 10000000000000000000 DROP TABLE t1; DROP TABLE t2;
mysql-test/t/subselect.test +22 −0 Original line number Diff line number Diff line Loading @@ -2109,3 +2109,25 @@ insert into t1 values (1, 2), (2, 2), (3, 2); select * from (select min(i) from t1 where j=(select * from (select min(j) from t1) t2)) t3; drop table t1; # # Bug#19700: subselect returning BIGINT always returned it as SIGNED # CREATE TABLE t1 (i BIGINT UNSIGNED); INSERT INTO t1 VALUES (10000000000000000000); -- > MAX SIGNED BIGINT 9323372036854775807 INSERT INTO t1 VALUES (1); CREATE TABLE t2 (i BIGINT UNSIGNED); INSERT INTO t2 VALUES (10000000000000000000); -- same as first table INSERT INTO t2 VALUES (1); /* simple test */ SELECT t1.i FROM t1 JOIN t2 ON t1.i = t2.i; /* subquery test */ SELECT t1.i FROM t1 WHERE t1.i = (SELECT MAX(i) FROM t2); /* subquery test with cast*/ SELECT t1.i FROM t1 WHERE t1.i = CAST((SELECT MAX(i) FROM t2) AS UNSIGNED); DROP TABLE t1; DROP TABLE t2;
sql/item.h +1 −0 Original line number Diff line number Diff line Loading @@ -2245,6 +2245,7 @@ class Item_cache: public Item max_length= item->max_length; decimals= item->decimals; collation.set(item->collation); unsigned_flag= item->unsigned_flag; return 0; }; virtual void store(Item *)= 0; Loading
sql/item_subselect.cc +1 −0 Original line number Diff line number Diff line Loading @@ -404,6 +404,7 @@ void Item_singlerow_subselect::fix_length_and_dec() engine->fix_length_and_dec(row); value= *row; } unsigned_flag= value->unsigned_flag; /* If there are not tables in subquery then ability to have NULL value depends on SELECT list (if single row subquery have tables then it Loading