MDEV-26830: Wrong ROW_NUMBER in diagnostics upon INSERT IGNORE with
CHECK violation Analysis: When there is constraint fail we return non-zero value for view_check_option(). So we continue the loop which doesn't increment the counter because it increments at the end of the loop. Fix: Increment m_current_row_for_warning() at the beginning of loop. This will also fix similar bugs if any, about counter not incrementing correctly because of continue.
This commit is contained in:
parent
797bd73cfa
commit
e13dc7d0d0
@ -1765,3 +1765,21 @@ SELECT @n, @m;
|
|||||||
@n @m
|
@n @m
|
||||||
1 Column count doesn't match value count at row 1
|
1 Column count doesn't match value count at row 1
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
#
|
||||||
|
# MDEV-26830: Wrong ROW_NUMBER in diagnostics upon INSERT IGNORE with
|
||||||
|
# CHECK violation
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (a INT, CHECK(a>0));
|
||||||
|
INSERT IGNORE INTO t1 VALUES (1),(0),(2),(0);
|
||||||
|
Warnings:
|
||||||
|
Warning 4025 CONSTRAINT `CONSTRAINT_1` failed for `test`.`t1`
|
||||||
|
Warning 4025 CONSTRAINT `CONSTRAINT_1` failed for `test`.`t1`
|
||||||
|
GET DIAGNOSTICS CONDITION 1 @n= ROW_NUMBER;
|
||||||
|
SELECT @n;
|
||||||
|
@n
|
||||||
|
2
|
||||||
|
GET DIAGNOSTICS CONDITION 2 @n= ROW_NUMBER;
|
||||||
|
SELECT @n;
|
||||||
|
@n
|
||||||
|
4
|
||||||
|
DROP TABLE t1;
|
||||||
|
@ -1653,3 +1653,17 @@ GET DIAGNOSTICS CONDITION 1 @n= ROW_NUMBER, @m= MESSAGE_TEXT;
|
|||||||
SELECT @n, @m;
|
SELECT @n, @m;
|
||||||
|
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-26830: Wrong ROW_NUMBER in diagnostics upon INSERT IGNORE with
|
||||||
|
--echo # CHECK violation
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
CREATE TABLE t1 (a INT, CHECK(a>0));
|
||||||
|
INSERT IGNORE INTO t1 VALUES (1),(0),(2),(0);
|
||||||
|
GET DIAGNOSTICS CONDITION 1 @n= ROW_NUMBER;
|
||||||
|
SELECT @n;
|
||||||
|
GET DIAGNOSTICS CONDITION 2 @n= ROW_NUMBER;
|
||||||
|
SELECT @n;
|
||||||
|
|
||||||
|
DROP TABLE t1;
|
||||||
|
@ -844,7 +844,7 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list,
|
|||||||
switch_to_nullable_trigger_fields(*values, table);
|
switch_to_nullable_trigger_fields(*values, table);
|
||||||
}
|
}
|
||||||
its.rewind ();
|
its.rewind ();
|
||||||
thd->get_stmt_da()->reset_current_row_for_warning(1);
|
thd->get_stmt_da()->reset_current_row_for_warning(0);
|
||||||
|
|
||||||
/* Restore the current context. */
|
/* Restore the current context. */
|
||||||
ctx_state.restore_state(context, table_list);
|
ctx_state.restore_state(context, table_list);
|
||||||
@ -1011,6 +1011,7 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list,
|
|||||||
|
|
||||||
while ((values= its++))
|
while ((values= its++))
|
||||||
{
|
{
|
||||||
|
thd->get_stmt_da()->inc_current_row_for_warning();
|
||||||
if (fields.elements || !value_count)
|
if (fields.elements || !value_count)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -1127,7 +1128,6 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list,
|
|||||||
if (unlikely(error))
|
if (unlikely(error))
|
||||||
break;
|
break;
|
||||||
info.accepted_rows++;
|
info.accepted_rows++;
|
||||||
thd->get_stmt_da()->inc_current_row_for_warning();
|
|
||||||
}
|
}
|
||||||
its.rewind();
|
its.rewind();
|
||||||
iteration++;
|
iteration++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user