mirror of
https://github.com/MariaDB/server.git
synced 2025-01-28 17:54:16 +01:00
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.
This commit is contained in:
parent
21d03cb08a
commit
635be990ca
3 changed files with 39 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
--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;
|
||||
|
|
Loading…
Add table
Reference in a new issue