MDEV-26844: DELETE returns ROW_NUMBER=1 for every row upon
ER_TRUNCATED_WRONG_VALUE Part 1: Fix for DELETE without ORDER BY Analysis: m_current_row_for_warning doesn't increment and assumes default value which is then used by ROW_NUMBER. Fix: Increment m_current_row_for_warning for each processed row.
This commit is contained in:
parent
e13dc7d0d0
commit
92f7d008ab
@ -1783,3 +1783,31 @@ SELECT @n;
|
|||||||
@n
|
@n
|
||||||
4
|
4
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
#
|
||||||
|
# MDEV-26844: DELETE returns ROW_NUMBER=1 for every row upon
|
||||||
|
# ER_TRUNCATED_WRONG_VALUE
|
||||||
|
#
|
||||||
|
# without ORDER BY
|
||||||
|
CREATE TABLE t (a VARCHAR(8));
|
||||||
|
INSERT INTO t VALUES ('val1'),('val2'),('100'),('val4');
|
||||||
|
SELECT * FROM t;
|
||||||
|
a
|
||||||
|
val1
|
||||||
|
val2
|
||||||
|
100
|
||||||
|
val4
|
||||||
|
DELETE FROM t WHERE a = 100;
|
||||||
|
Warnings:
|
||||||
|
Warning 1292 Truncated incorrect DOUBLE value: 'val1'
|
||||||
|
Warning 1292 Truncated incorrect DOUBLE value: 'val2'
|
||||||
|
Warning 1292 Truncated incorrect DOUBLE value: 'val4'
|
||||||
|
SHOW WARNINGS;
|
||||||
|
Level Code Message
|
||||||
|
Warning 1292 Truncated incorrect DOUBLE value: 'val1'
|
||||||
|
Warning 1292 Truncated incorrect DOUBLE value: 'val2'
|
||||||
|
Warning 1292 Truncated incorrect DOUBLE value: 'val4'
|
||||||
|
GET DIAGNOSTICS CONDITION 3 @n = ROW_NUMBER;
|
||||||
|
SELECT @n;
|
||||||
|
@n
|
||||||
|
4
|
||||||
|
DROP TABLE t;
|
||||||
|
@ -1667,3 +1667,23 @@ GET DIAGNOSTICS CONDITION 2 @n= ROW_NUMBER;
|
|||||||
SELECT @n;
|
SELECT @n;
|
||||||
|
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-26844: DELETE returns ROW_NUMBER=1 for every row upon
|
||||||
|
--echo # ER_TRUNCATED_WRONG_VALUE
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
--echo # without ORDER BY
|
||||||
|
|
||||||
|
CREATE TABLE t (a VARCHAR(8));
|
||||||
|
|
||||||
|
INSERT INTO t VALUES ('val1'),('val2'),('100'),('val4');
|
||||||
|
SELECT * FROM t;
|
||||||
|
|
||||||
|
DELETE FROM t WHERE a = 100;
|
||||||
|
SHOW WARNINGS;
|
||||||
|
|
||||||
|
GET DIAGNOSTICS CONDITION 3 @n = ROW_NUMBER;
|
||||||
|
SELECT @n;
|
||||||
|
|
||||||
|
DROP TABLE t;
|
||||||
|
@ -795,9 +795,11 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
|
|||||||
THD_STAGE_INFO(thd, stage_updating);
|
THD_STAGE_INFO(thd, stage_updating);
|
||||||
fix_rownum_pointers(thd, thd->lex->current_select, &deleted);
|
fix_rownum_pointers(thd, thd->lex->current_select, &deleted);
|
||||||
|
|
||||||
|
thd->get_stmt_da()->reset_current_row_for_warning(0);
|
||||||
while (likely(!(error=info.read_record())) && likely(!thd->killed) &&
|
while (likely(!(error=info.read_record())) && likely(!thd->killed) &&
|
||||||
likely(!thd->is_error()))
|
likely(!thd->is_error()))
|
||||||
{
|
{
|
||||||
|
thd->get_stmt_da()->inc_current_row_for_warning();
|
||||||
if (delete_while_scanning)
|
if (delete_while_scanning)
|
||||||
delete_record= record_should_be_deleted(thd, table, select, explain,
|
delete_record= record_should_be_deleted(thd, table, select, explain,
|
||||||
delete_history);
|
delete_history);
|
||||||
@ -873,6 +875,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
|
|||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
thd->get_stmt_da()->reset_current_row_for_warning(1);
|
||||||
|
|
||||||
terminate_delete:
|
terminate_delete:
|
||||||
killed_status= thd->killed;
|
killed_status= thd->killed;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user