summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRucha Deodhar <rucha.deodhar@mariadb.com>2021-10-17 16:24:31 +0530
committerRucha Deodhar <rucha.deodhar@mariadb.com>2021-10-18 11:08:25 +0530
commita1e5bdf87f50cd1f03c889a4be61ecef2da8f526 (patch)
tree324e265663cb83f473208794d82723df00191dfb
parentc27f04ede5a92f37d0b22e5c90523bcccb1af37a (diff)
downloadmariadb-git-bb-10.7-row_number-MDEV-26841.tar.gz
MDEV-26841: ROW_NUMBER is not set and differs from the message uponbb-10.7-row_number-MDEV-26841
ER_WRONG_VALUE_COUNT_ON_ROW for the 1st row Analysis: Current row for warning does not increment for prepare phase Fix: Increment current row for warning if number of fields in the table and row values dont match and number of values in rows is greater than number of fields
-rw-r--r--mysql-test/main/get_diagnostics.result11
-rw-r--r--mysql-test/main/get_diagnostics.test14
-rw-r--r--sql/sql_insert.cc2
3 files changed, 27 insertions, 0 deletions
diff --git a/mysql-test/main/get_diagnostics.result b/mysql-test/main/get_diagnostics.result
index 14137bde36d..5d2b7b4e25b 100644
--- a/mysql-test/main/get_diagnostics.result
+++ b/mysql-test/main/get_diagnostics.result
@@ -1716,3 +1716,14 @@ SELECT @row_num;
@row_num
105
DROP PROCEDURE resignal_syntax;
+#
+#
+#
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1,2),(3);
+ERROR 21S01: Column count doesn't match value count at row 1
+GET DIAGNOSTICS CONDITION 1 @n= ROW_NUMBER, @m= MESSAGE_TEXT;
+SELECT @n, @m;
+@n @m
+1 Column count doesn't match value count at row 1
+DROP TABLE t1;
diff --git a/mysql-test/main/get_diagnostics.test b/mysql-test/main/get_diagnostics.test
index 5c3071b4fe7..107ba205a62 100644
--- a/mysql-test/main/get_diagnostics.test
+++ b/mysql-test/main/get_diagnostics.test
@@ -1601,3 +1601,17 @@ GET DIAGNOSTICS CONDITION 1 @row_num= ROW_NUMBER;
SELECT @row_num;
DROP PROCEDURE resignal_syntax;
+
+--echo #
+--echo #
+--echo #
+
+CREATE TABLE t1 (a INT);
+
+--error ER_WRONG_VALUE_COUNT_ON_ROW
+INSERT INTO t1 VALUES (1,2),(3);
+
+GET DIAGNOSTICS CONDITION 1 @n= ROW_NUMBER, @m= MESSAGE_TEXT;
+SELECT @n, @m;
+
+DROP TABLE t1;
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 3dff6722a3d..d3df63fe0e6 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -229,6 +229,7 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
}
if (values.elements != table->s->visible_fields)
{
+ thd->get_stmt_da()->reset_current_row_for_warning(1);
my_error(ER_WRONG_VALUE_COUNT_ON_ROW, MYF(0), 1L);
DBUG_RETURN(-1);
}
@@ -253,6 +254,7 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
if (fields.elements != values.elements)
{
+ thd->get_stmt_da()->reset_current_row_for_warning(1);
my_error(ER_WRONG_VALUE_COUNT_ON_ROW, MYF(0), 1L);
DBUG_RETURN(-1);
}