mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
a1017b09b4
Problem: cast to unsigned limited result to max signed bigint 9223372036854775808, instead of max unsigned bigint 18446744073709551615. Fix: don't use args[0]->val_int() when casting from a floating point number, use val() instead, with range checkings, special to unsigned data type. item_func.cc: Special handling of cast from REAL_RESULT to unsigned int: we cannot execute args[0]->val_int() because it cuts max allowed value to LONGLONG_INT, instead of ULONGLONG_INT required. count_distinct3.test: Getting rid of "Data truncated; out of range ..." warnings. cast.test, cast.result: Adding test case. ps.result: Fixing that cast from 6570515219.6535 to unsigned didn't round to 6570515220, and returned 6570515219 instead. mysql-test/r/cast.result: Adding test case. mysql-test/r/ps.result: Fixing that cast from 6570515219.6535 to unsigned didn't round to 6570515220, and returned 6570515219 instead. mysql-test/t/cast.test: Adding test case. mysql-test/t/count_distinct3.test: Get rid of "wring unsigned value" warnings. sql/item_func.cc: Special handling of cast from REAL)RESULT to unsigned int: we cannot execute args[0]->val_int() because it cuts max allowed value to LONGLONG_INT, instead of ULONGLONG_INT required.
60 lines
2.1 KiB
Text
60 lines
2.1 KiB
Text
#
|
|
# this is a test for error 1032 in count(distinct) + group by, introduced in
|
|
# mysql-4.1
|
|
#
|
|
|
|
--disable_warnings
|
|
DROP TABLE IF EXISTS t1, t2;
|
|
--enable_warnings
|
|
|
|
CREATE TABLE t1 (id INTEGER, grp TINYINT, id_rev INTEGER);
|
|
|
|
--disable_query_log
|
|
SET @rnd_max= 2147483647;
|
|
let $1 = 1000;
|
|
while ($1)
|
|
{
|
|
SET @rnd= RAND();
|
|
SET @id = CAST(@rnd * @rnd_max AS UNSIGNED);
|
|
SET @id_rev= @rnd_max - @id;
|
|
SET @grp= CAST(127.0 * @rnd AS UNSIGNED);
|
|
INSERT INTO t1 (id, grp, id_rev) VALUES (@id, @grp, @id_rev);
|
|
dec $1;
|
|
}
|
|
set @@read_buffer_size=2*1024*1024;
|
|
CREATE TABLE t2 SELECT * FROM t1;
|
|
INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
|
|
INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
|
|
INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
|
|
INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
|
|
INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
|
|
INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
|
|
INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
|
|
INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
|
|
INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
|
|
INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
|
|
INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
|
|
INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
|
|
INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
|
|
INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
|
|
INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
|
|
INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
|
|
INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
|
|
INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
|
|
DROP TABLE t2;
|
|
--enable_query_log
|
|
|
|
SELECT COUNT(*) FROM t1;
|
|
|
|
# As t1 contains random numbers, results are different from test to test.
|
|
# That's okay, because we test only that select doesn't yield an
|
|
# error. Note, that --disable_result_log doesn't suppress error output.
|
|
|
|
--disable_result_log
|
|
SELECT COUNT(DISTINCT id) FROM t1 GROUP BY grp;
|
|
--enable_result_log
|
|
DROP TABLE t1;
|
|
|
|
set @@read_buffer_size=default;
|
|
|
|
# End of 4.1 tests
|