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:
@ -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;
|
||||
|
Reference in New Issue
Block a user