Hi, Rucha! On Jan 11, Rucha Deodhar wrote:
revision-id: 7a746072a5e (mariadb-10.7.1-26-g7a746072a5e) parent(s): 7dfaded9625 author: Rucha Deodhar committer: Rucha Deodhar timestamp: 2022-01-05 12:05:22 +0530 message:
MDEV-26878: Query failing with syntax error sets ROW_NUMBER to non-zero
Analysis: m_current_row_for_warning counter is set to 0 at the beginning of parsing. Fix: Reset it to 1 and increment it before starting to parse insert values, during SET and SELECT for INSERT...SET statement and INSERT...SELECT respectively.
diff --git a/mysql-test/main/get_diagnostics.result b/mysql-test/main/get_diagnostics.result diff --git a/mysql-test/main/get_diagnostics.test b/mysql-test/main/get_diagnostics.test index e8d81dca1e6..467f624c49c 100644 --- a/mysql-test/main/get_diagnostics.test +++ b/mysql-test/main/get_diagnostics.test @@ -1687,3 +1687,18 @@ GET DIAGNOSTICS CONDITION 3 @n = ROW_NUMBER; SELECT @n;
DROP TABLE t; + +--echo # +--echo # MDEV-26878: Query failing with syntax error sets ROW_NUMBER to +--echo # non-zero +--echo # + +CREATE TABLE t1 (id1 INT); + +--error ER_PARSE_ERROR +INSERT INTO t1 VALUES XXX (1),(2);
please add a test, like, INTO t1 VALUES (1), (ALL); what ROW_NUMBER will it show?
+ +GET DIAGNOSTICS CONDITION 1 @n= ROW_NUMBER; +SELECT @n; + +DROP TABLE t1; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 8ebefbb3d82..47ed3ded4a7 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -8426,6 +8426,8 @@ query_specification_start: { SELECT_LEX *sel; LEX *lex= Lex; + if (lex->sql_command == SQLCOM_INSERT) + thd->get_stmt_da()->inc_current_row_for_warning(); if (!(sel= lex->alloc_select(TRUE)) || lex->push_select(sel)) MYSQL_YYABORT;
better not to have an if() in this rule that's used almost for everything. Regards, Sergei VP of MariaDB Server Engineering and security@mariadb.org