diff options
author | Rucha Deodhar <rucha.deodhar@mariadb.com> | 2022-01-23 13:42:41 +0530 |
---|---|---|
committer | Rucha Deodhar <rucha.deodhar@mariadb.com> | 2022-01-23 13:48:18 +0530 |
commit | 1c0731e0544db4d2f5c107473776bbd6d4d3e2f0 (patch) | |
tree | 15834a0b45b2dedc24f24a1a843c3a4cf4f8a922 | |
parent | 5e6fd4e80435ae6d5994abbff6032c7957713410 (diff) | |
download | mariadb-git-bb-10.7-MDEV-26695.tar.gz |
MDEV-26695: Number of an invalid row is not calculated for table valuebb-10.7-MDEV-26695
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 | 11 | ||||
-rw-r--r-- | mysql-test/main/get_diagnostics.test | 11 | ||||
-rw-r--r-- | sql/sql_tvc.cc | 6 |
3 files changed, 26 insertions, 2 deletions
diff --git a/mysql-test/main/get_diagnostics.result b/mysql-test/main/get_diagnostics.result index 2e749fa21d7..4598838c2e7 100644 --- a/mysql-test/main/get_diagnostics.result +++ b/mysql-test/main/get_diagnostics.result @@ -1811,3 +1811,14 @@ SELECT @n; @n 4 DROP TABLE t; +# +# MDEV-26695: Number of an invalid row is not calculated for table value constructor +# +CREATE TABLE t (a CHAR(1)) VALUES ('a'),('b'),('foo'); +Warnings: +Warning 1406 Data too long for column 'a' at row 3 +GET DIAGNOSTICS CONDITION 1 @n= ROW_NUMBER; +SELECT @n; +@n +3 +DROP TABLE t; diff --git a/mysql-test/main/get_diagnostics.test b/mysql-test/main/get_diagnostics.test index e8d81dca1e6..24f407b5e05 100644 --- a/mysql-test/main/get_diagnostics.test +++ b/mysql-test/main/get_diagnostics.test @@ -1687,3 +1687,14 @@ GET DIAGNOSTICS CONDITION 3 @n = ROW_NUMBER; SELECT @n; DROP TABLE t; + +--echo # +--echo # MDEV-26695: Number of an invalid row is not calculated for table value constructor +--echo # + +CREATE TABLE t (a CHAR(1)) VALUES ('a'),('b'),('foo'); + +GET DIAGNOSTICS CONDITION 1 @n= ROW_NUMBER; +SELECT @n; + +DROP TABLE t; diff --git a/sql/sql_tvc.cc b/sql/sql_tvc.cc index bdaf6829fbd..7db0ab217ca 100644 --- a/sql/sql_tvc.cc +++ b/sql/sql_tvc.cc @@ -422,7 +422,9 @@ bool table_value_constr::exec(SELECT_LEX *sl) DBUG_ENTER("table_value_constr::exec"); List_iterator_fast<List_item> li(lists_of_values); List_item *elem; + THD *cur_thd= sl->parent_lex->thd; ha_rows send_records= 0; + int rc=0; if (select_options & SELECT_DESCRIBE) DBUG_RETURN(false); @@ -438,10 +440,10 @@ bool table_value_constr::exec(SELECT_LEX *sl) while ((elem= li++)) { + cur_thd->get_stmt_da()->inc_current_row_for_warning(); if (send_records >= sl->master_unit()->lim.get_select_limit()) break; - int rc= - result->send_data_with_check(*elem, sl->master_unit(), send_records); + rc= result->send_data_with_check(*elem, sl->master_unit(), send_records); if (!rc) send_records++; else if (rc > 0) |