1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-26698: Incorrect row number upon INSERT .. SELECT from the same

table: rows are counted twice

Analysis: When the table we are trying to insert into and the SELECT table
are same for INSERT ... SELECT, rows from the SELECT table are copied into
internal temporary table and then to the INSERT table. We only want to
count the rows when we start inserting into the table.
Fix: Reset the counter to 1 before starting to copy from internal temporary
table to select table and then increment the counter.
This commit is contained in:
Rucha Deodhar
2021-12-24 14:00:47 +05:30
parent 5d57e04b27
commit 452c9a4d72
10 changed files with 365 additions and 316 deletions

View File

@ -19146,11 +19146,8 @@ evaluate_join_record(JOIN *join, JOIN_TAB *join_tab,
*/
if (shortcut_for_distinct && found_records != join->found_records)
DBUG_RETURN(NESTED_LOOP_NO_MORE_ROWS);
}
else
{
join->thd->get_stmt_da()->inc_current_row_for_warning();
join_tab->read_record.unlock_row(join_tab);
DBUG_RETURN(NESTED_LOOP_OK);
}
}
else
@ -19160,9 +19157,11 @@ evaluate_join_record(JOIN *join, JOIN_TAB *join_tab,
with the beginning coinciding with the current partial join.
*/
join->join_examined_rows++;
join->thd->get_stmt_da()->inc_current_row_for_warning();
join_tab->read_record.unlock_row(join_tab);
}
join->thd->get_stmt_da()->inc_current_row_for_warning();
join_tab->read_record.unlock_row(join_tab);
DBUG_RETURN(NESTED_LOOP_OK);
}
@ -26945,6 +26944,12 @@ AGGR_OP::end_send()
table->reginfo.lock_type= TL_UNLOCK;
bool in_first_read= true;
/*
Reset the counter before copying rows from internal temporary table to
INSERT table.
*/
join_tab->join->thd->get_stmt_da()->reset_current_row_for_warning();
while (rc == NESTED_LOOP_OK)
{
int error;