1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-26836: ROW_NUMBER differs from the number in the error message upon

ER_WARN_DATA_OUT_OF_RANGE

Analysis: value for row_number is hard coded into push_warning_printf() to 1.
Fix: make push_warning_printf() use m_current_row_for_warning instead of 1.
This commit is contained in:
Rucha Deodhar
2021-10-15 15:52:16 +05:30
parent a6cf8b34a8
commit 9ab0d07e10
8 changed files with 45 additions and 13 deletions

View File

@ -1671,3 +1671,21 @@ SELECT @rnum, @msg, @err;
@rnum @msg @err @rnum @msg @err
3 Data truncated for column 'a' at row 3 1265 3 Data truncated for column 'a' at row 3 1265
DROP TABLE t1; DROP TABLE t1;
#
# ROW_NUMBER differs from the number in the error message upon
# ER_WARN_DATA_OUT_OF_RANGE
#
CREATE TABLE t (a INT);
INSERT INTO t VALUES (1),(2);
SELECT CAST(a AS DECIMAL(2,2)) AS f FROM t;
f
0.99
0.99
Warnings:
Warning 1264 Out of range value for column 'f' at row 1
Warning 1264 Out of range value for column 'f' at row 2
GET DIAGNOSTICS CONDITION 2 @n= ROW_NUMBER, @m = MESSAGE_TEXT;
SELECT @n, @m;
@n @m
2 Out of range value for column 'f' at row 2
DROP TABLE t;

View File

@ -1552,3 +1552,16 @@ GET DIAGNOSTICS CONDITION 2 @rnum = ROW_NUMBER, @msg = MESSAGE_TEXT, @err = MYSQ
SELECT @rnum, @msg, @err; SELECT @rnum, @msg, @err;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # ROW_NUMBER differs from the number in the error message upon
--echo # ER_WARN_DATA_OUT_OF_RANGE
--echo #
CREATE TABLE t (a INT);
INSERT INTO t VALUES (1),(2);
SELECT CAST(a AS DECIMAL(2,2)) AS f FROM t;
GET DIAGNOSTICS CONDITION 2 @n= ROW_NUMBER, @m = MESSAGE_TEXT;
SELECT @n, @m;
DROP TABLE t;

View File

@ -1152,13 +1152,13 @@ CAST(str AS DECIMAL(38,0))
Level Code Message Level Code Message
Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated
Warning 1292 Truncated incorrect DECIMAL value: '1e111111111111111111111' Warning 1292 Truncated incorrect DECIMAL value: '1e111111111111111111111'
Warning 1264 Out of range value for column 'CAST(str AS DECIMAL(38,0))' at row 1 Warning 1264 Out of range value for column 'CAST(str AS DECIMAL(38,0))' at row 2
CAST(CONCAT(str,'garbage') AS DECIMAL(38,0)) CAST(CONCAT(str,'garbage') AS DECIMAL(38,0))
99999999999999999999999999999999999999 99999999999999999999999999999999999999
Level Code Message Level Code Message
Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated
Warning 1292 Truncated incorrect DECIMAL value: '1e111111111111111111111garbage' Warning 1292 Truncated incorrect DECIMAL value: '1e111111111111111111111garbage'
Warning 1264 Out of range value for column 'CAST(CONCAT(str,'garbage') AS DECIMAL(38,0))' at row 1 Warning 1264 Out of range value for column 'CAST(CONCAT(str,'garbage') AS DECIMAL(38,0))' at row 2
DROP TABLE t1; DROP TABLE t1;
# #
# End of 10.2 tests # End of 10.2 tests

View File

@ -1458,8 +1458,8 @@ cast(a as DECIMAL(3,2))
9.99 9.99
Warnings: Warnings:
Warning 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1 Warning 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1
Warning 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1 Warning 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 2
Warning 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1 Warning 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 3
select cast(a as DECIMAL(3,2)), count(*) select cast(a as DECIMAL(3,2)), count(*)
from (select 11.1233 as a from (select 11.1233 as a
UNION select 11.1234 UNION select 11.1234
@ -1470,8 +1470,8 @@ cast(a as DECIMAL(3,2)) count(*)
Warnings: Warnings:
Warning 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1 Warning 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1
Warning 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1 Warning 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1
Warning 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1 Warning 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 2
Warning 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1 Warning 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 3
create table t1 (s varchar(100)); create table t1 (s varchar(100));
insert into t1 values (0.00000000010000000000000000364321973154977415791655470655996396089904010295867919921875); insert into t1 values (0.00000000010000000000000000364321973154977415791655470655996396089904010295867919921875);
drop table t1; drop table t1;

View File

@ -3322,9 +3322,9 @@ NULL NULL 1
-3333.33 -3333.3333 30 -3333.33 -3333.3333 30
Warnings: Warnings:
Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated
Warning 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1 Warning 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 2
Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated
Warning 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1 Warning 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 3
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as decimal(37,2)) AS `CAST(my_double AS DECIMAL(37,2))`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as decimal(37,2)) AS `CAST(my_double AS DECIMAL(37,2))`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci

View File

@ -3323,9 +3323,9 @@ NULL NULL 1
-3333.33 -3333.3333 30 -3333.33 -3333.3333 30
Warnings: Warnings:
Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated
Warning 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1 Warning 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 2
Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated
Warning 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1 Warning 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 3
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as decimal(37,2)) AS `CAST(my_double AS DECIMAL(37,2))`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as decimal(37,2)) AS `CAST(my_double AS DECIMAL(37,2))`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci

View File

@ -3323,9 +3323,9 @@ NULL NULL 1
-3333.33 -3333.3333 30 -3333.33 -3333.3333 30
Warnings: Warnings:
Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated
Warning 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1 Warning 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 2
Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated
Warning 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1 Warning 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 3
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as decimal(37,2)) AS `CAST(my_double AS DECIMAL(37,2))`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as decimal(37,2)) AS `CAST(my_double AS DECIMAL(37,2))`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci

View File

@ -1004,7 +1004,8 @@ err:
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WARN_DATA_OUT_OF_RANGE, ER_WARN_DATA_OUT_OF_RANGE,
ER_THD(thd, ER_WARN_DATA_OUT_OF_RANGE), ER_THD(thd, ER_WARN_DATA_OUT_OF_RANGE),
name.str, 1L); name.str,
thd->get_stmt_da()->current_row_for_warning());
return dec; return dec;
} }