Commit 635be990 authored by Rucha Deodhar's avatar Rucha Deodhar Committed by Sergei Golubchik

MDEV-26842: ROW_NUMBER is not set and differs from the message upon...

MDEV-26842: ROW_NUMBER is not set and differs from the message upon WARN_DATA_TRUNCATED produced by inplace ALTER

Analysis: When row number is passed as parameter to set_warning() it is only
used for error/warning text but m_current_row_for_warning is not updated.
Hence default value of m_current_row_for_warning is assumed.
Fix: update m_current_row_for_warning when error/warning occurs.
parent 21d03cb0
......@@ -1734,3 +1734,16 @@ SELECT @row_num;
@row_num
105
DROP PROCEDURE resignal_syntax;
#
# MDEV-26842: ROW_NUMBER is not set and differs from the message upon
# WARN_DATA_TRUNCATED produced by inplace ALTER
#
CREATE TABLE t1 (a VARCHAR(64)) ENGINE=InnoDB;
INSERT INTO t1 VALUES ('foo'),(null);
ALTER TABLE t1 ADD PRIMARY KEY(a), ALGORITHM=INPLACE;
ERROR 01000: Data truncated for column 'a' at row 2
GET DIAGNOSTICS CONDITION 1 @n= ROW_NUMBER, @m= MESSAGE_TEXT;
SELECT @n, @m;
@n @m
2 Data truncated for column 'a' at row 2
DROP TABLE t1;
--source include/have_innodb.inc
SET NAMES utf8;
--echo #
......@@ -1614,3 +1616,19 @@ GET DIAGNOSTICS CONDITION 1 @row_num= ROW_NUMBER;
SELECT @row_num;
DROP PROCEDURE resignal_syntax;
--echo #
--echo # MDEV-26842: ROW_NUMBER is not set and differs from the message upon
--echo # WARN_DATA_TRUNCATED produced by inplace ALTER
--echo #
CREATE TABLE t1 (a VARCHAR(64)) ENGINE=InnoDB;
INSERT INTO t1 VALUES ('foo'),(null);
--error WARN_DATA_TRUNCATED
ALTER TABLE t1 ADD PRIMARY KEY(a), ALGORITHM=INPLACE;
GET DIAGNOSTICS CONDITION 1 @n= ROW_NUMBER, @m= MESSAGE_TEXT;
SELECT @n, @m;
DROP TABLE t1;
......@@ -11101,6 +11101,14 @@ Field::set_warning(Sql_condition::enum_warning_level level, uint code,
will have table == NULL.
*/
THD *thd= get_thd();
/*
In INPLACE ALTER, server can't know which row has generated
the warning, so the value of current row is supplied by the engine.
*/
if (current_row)
thd->get_stmt_da()->reset_current_row_for_warning(current_row);
if (thd->count_cuted_fields > CHECK_FIELD_EXPRESSION)
{
thd->cuted_fields+= cut_increment;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment