From 5cc9cf9a05582307abefd8f3b57548945da86b1a Mon Sep 17 00:00:00 2001 From: Rucha Deodhar Date: Wed, 6 Oct 2021 23:43:16 +0530 Subject: MDEV-26681: ROW_NUMBER is not available within compound statement blocks Fixed after patch MDEV-26606 because root cause was same. Analysis: m_current_row_for_warning is reset to 1 during cleanup phase of stored procedure. When we perform a copy because some statement of procedure created warning, this reset value is passed to push _warning(). Fix: Add a parameter in relevant functions to pass correct value of error index and don't use m_current_row_for_warning directly. --- mysql-test/main/get_diagnostics.result | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'mysql-test/main/get_diagnostics.result') diff --git a/mysql-test/main/get_diagnostics.result b/mysql-test/main/get_diagnostics.result index 280dd671e43..7bd1bde10de 100644 --- a/mysql-test/main/get_diagnostics.result +++ b/mysql-test/main/get_diagnostics.result @@ -1638,3 +1638,36 @@ SELECT @ind, @msg; @ind @msg 0 Invalid condition number DROP TABLE t1; +# +# MDEV-26681: ROW_NUMBER is not available within compound statement blocks +# +CREATE OR REPLACE TABLE t1 (pk INT PRIMARY KEY, a CHAR(3)); +INSERT IGNORE INTO t1 VALUES (1,'foo'),(1,'bar'),(2,'foobar'); +Warnings: +Warning 1062 Duplicate entry '1' for key 'PRIMARY' +Warning 1265 Data truncated for column 'a' at row 3 +BEGIN NOT ATOMIC +DECLARE i INT DEFAULT 0; +DECLARE rnum INT DEFAULT -1; +DECLARE msg VARCHAR(1024) DEFAULT ''; +DECLARE err INT DEFAULT -1; +WHILE i < @@warning_count +DO +SET i = i + 1; +GET DIAGNOSTICS CONDITION i rnum = ROW_NUMBER, msg = MESSAGE_TEXT, err = MYSQL_ERRNO; +SELECT i, rnum, msg, err; +END WHILE; +END | +i rnum msg err +1 2 Duplicate entry '1' for key 'PRIMARY' 1062 +i rnum msg err +2 3 Data truncated for column 'a' at row 3 1265 +GET DIAGNOSTICS CONDITION 1 @rnum = ROW_NUMBER, @msg = MESSAGE_TEXT, @err = MYSQL_ERRNO; +select @rnum, @msg, @err; +@rnum @msg @err +2 Duplicate entry '1' for key 'PRIMARY' 1062 +GET DIAGNOSTICS CONDITION 2 @rnum = ROW_NUMBER, @msg = MESSAGE_TEXT, @err = MYSQL_ERRNO; +SELECT @rnum, @msg, @err; +@rnum @msg @err +3 Data truncated for column 'a' at row 3 1265 +DROP TABLE t1; -- cgit v1.2.1