diff options
author | Rucha Deodhar <rucha.deodhar@mariadb.com> | 2022-04-26 12:58:48 +0530 |
---|---|---|
committer | Rucha Deodhar <rucha.deodhar@mariadb.com> | 2022-04-26 13:02:15 +0530 |
commit | d45841b9be6fe069383cc05405f747ae36d08362 (patch) | |
tree | f8dec552f81a94ac3b871ffd1fd18d542591aed4 | |
parent | 551e7814ed0cde2d8696ce228c7e9c6ee1a64696 (diff) | |
download | mariadb-git-d45841b9be6fe069383cc05405f747ae36d08362.tar.gz |
MDEV-26695: Number of an invalid row is not calculated for table value
constructor
Analysis: counter does not increment while sending rows for table value
constructor and so row_number assumes the default value (0 in this case).
Fix: Increment the counter to avoid counter using default value.
-rw-r--r-- | mysql-test/main/get_diagnostics.result | 10 | ||||
-rw-r--r-- | mysql-test/main/get_diagnostics.test | 9 | ||||
-rw-r--r-- | sql/sql_tvc.cc | 2 |
3 files changed, 21 insertions, 0 deletions
diff --git a/mysql-test/main/get_diagnostics.result b/mysql-test/main/get_diagnostics.result index 6944103c805..41511d8a521 100644 --- a/mysql-test/main/get_diagnostics.result +++ b/mysql-test/main/get_diagnostics.result @@ -790,3 +790,13 @@ GET DIAGNOSTICS @var1 = NUMBER; SHOW STATUS LIKE 'Com%get_diagnostics'; Variable_name Value Com_get_diagnostics 1 +# +# MDEV-26695: Number of an invalid row is not calculated for table value constructor +# +CREATE TABLE t1 (a CHAR(1)) VALUES ('a'),('b'),('foo'); +Warnings: +Warning 1406 Data too long for column 'a' at row 3 +CREATE TABLE t2 (a char(1)) VALUES ('a'),('b') UNION VALUES ('foo'); +Warnings: +Warning 1406 Data too long for column 'a' at row 3 +DROP TABLE t1, t2; diff --git a/mysql-test/main/get_diagnostics.test b/mysql-test/main/get_diagnostics.test index 1553eb500b7..78ed3ea811b 100644 --- a/mysql-test/main/get_diagnostics.test +++ b/mysql-test/main/get_diagnostics.test @@ -851,3 +851,12 @@ FLUSH STATUS; SHOW STATUS LIKE 'Com%get_diagnostics'; GET DIAGNOSTICS @var1 = NUMBER; SHOW STATUS LIKE 'Com%get_diagnostics'; + +--echo # +--echo # MDEV-26695: Number of an invalid row is not calculated for table value constructor +--echo # + +CREATE TABLE t1 (a CHAR(1)) VALUES ('a'),('b'),('foo'); +CREATE TABLE t2 (a char(1)) VALUES ('a'),('b') UNION VALUES ('foo'); + +DROP TABLE t1, t2; diff --git a/sql/sql_tvc.cc b/sql/sql_tvc.cc index 9a99224b26e..72d53b2307c 100644 --- a/sql/sql_tvc.cc +++ b/sql/sql_tvc.cc @@ -406,9 +406,11 @@ bool table_value_constr::exec(SELECT_LEX *sl) while ((elem= li++)) { + THD *cur_thd= sl->parent_lex->thd; if (send_records >= sl->master_unit()->select_limit_cnt) break; int rc= result->send_data(*elem); + cur_thd->get_stmt_da()->inc_current_row_for_warning(); if (!rc) send_records++; else if (rc > 0) |