← Back to team overview

maria-developers team mailing list archive

Re: 4774601a3cd: MDEV-26698: Incorrect row number upon INSERT .. SELECT from the same table: rows are counted twice

 

Hi, Rucha!

On Dec 29, Rucha Deodhar wrote:
> On Wed, Dec 29, 2021 at 12:50 AM Sergei Golubchik <serg@xxxxxxxxxxx> wrote:
> 
> > Why did put your fix here in a common code path in select, and not
> > in, say, select_insert::send_data() ?
> 
> Yes, the counter can be incremented in select_insert::send_data() too.
> 
> But after writing record to INSERT table, we go back to
> evaluate_join_records() where the counter is incremented
> unconditionally. And CREATE TABLE...SELECT was failing with wrong
> output because it also uses this code.
> 
> I could have incremented counter conditionally so that it doesn't
> increment twice like so:
> 
> increment counter in select_insert::send_data() after record is written
> if (thd->lex->sql_command == SQLCOM_INSERT_SELECT ||
>     thd->lex->sql_command == SQLCOM_CREATE_TABLE)

I'd think you wouldn't need this if(), as select_insert::send_data()
is not used for other sql commands.

> And increment counter in evalaute_join_records() after one nested loop
> iteration ends (end_send())
> if (join->thd->lex->sql_command != SQLCOM_INSERT_SELECT &&
>     join->thd->lex->sql_command != SQLCOM_CREATE_TABLE)

I see. That's not good.

> I had initially implemented it this way but it kinda looked hacky to me.
> So I did a more general solution.
 
Regards,
Sergei
VP of MariaDB Server Engineering
and security@xxxxxxxxxxx


References