← Back to team overview

maria-developers team mailing list archive

Re: 7a746072a5e: MDEV-26878: Query failing with syntax error sets ROW_NUMBER to non-zero

 

Hi, Rucha!

On Jan 12, Rucha Deodhar wrote:
> On Tue, Jan 11, 2022 at 11:49 PM Sergei Golubchik <serg@xxxxxxxxxxx> wrote:
> > > +--error ER_PARSE_ERROR
> > > +INSERT INTO t1 VALUES XXX (1),(2);
> >
> > > diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
> > > index 8ebefbb3d82..47ed3ded4a7 100644
> > > --- a/sql/sql_yacc.yy
> > > +++ b/sql/sql_yacc.yy
> > > @@ -8426,6 +8426,8 @@ query_specification_start:
> > >            {
> > >              SELECT_LEX *sel;
> > >              LEX *lex= Lex;
> > > +            if (lex->sql_command == SQLCOM_INSERT)
> > > +              thd->get_stmt_da()->inc_current_row_for_warning();
> > >              if (!(sel= lex->alloc_select(TRUE)) || lex->push_select(sel))
> > >                MYSQL_YYABORT;
> >
> > better not to have an if() in this rule that's used almost for
> > everything.
> 
> When we have INSERT...SELECT counter has to be 1 for errors like
> ER_ILLEGAL_VALUE_FOR_TYPE which are caught during parsing.
> Example:
> INSERT INTO t1 SELECT a, b, 1.79769313486232e+308 FROM t2;
> 
> So I added if() to increment the counter if we are parsing INSERT so
> that ROW_NUMBER for statements like the one above gives ROW_NUMBER=1.

I see.

But you put a condition on every query's execution path to fix the case
that, I believe, literally nobody cares about.

I don't think any user ever will check the ROW_NUMBER after the syntax
error :) And if someone will, we can say that in 

  INSERT INTO t1 VALUES XXX (1),(2);

the first row starts after VALUES, so ROW_NUMBER=1 is expected.

Regards,
Sergei
VP of MariaDB Server Engineering
and security@xxxxxxxxxxx


References