Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser: fix SET=DEFAULT syntax (#551) #648

Merged
merged 1 commit into from
Nov 22, 2019

Conversation

Deardrops
Copy link
Contributor

What problem does this PR solve?

Cherry-pick #551

Fix compatibility problem about SET=DEFAULT syntax

Issue: pingcap/parser#549

MySQL Syntax:

insert_stmt:
          ...
        | INSERT_SYM                   /* #1 */
          insert_lock_option           /* #2 */
          opt_ignore                   /* #3 */
          opt_INTO                     /* #4 */
          table_ident                  /* #5 */
          opt_use_partition            /* #6 */
          SET_SYM                      /* #7 */
          update_list                  /* #8 */
          opt_insert_update_list       /* #9 */
          {
            PT_insert_values_list *one_row= NEW_PTN PT_insert_values_list;
            if (one_row == NULL || one_row->push_back(&$8.value_list->value))
              MYSQL_YYABORT; // OOM
            $$= NEW_PTN PT_insert(false, $1, $2, $3, $5, $6,
                                  $8.column_list, one_row,
                                  NULL,
                                  $9.column_list, $9.value_list);
          }
        | ...
        ;
...
replace_stmt:
          ...
        | REPLACE_SYM                   /* #1 */
          replace_lock_option           /* #2 */
          opt_INTO                      /* #3 */
          table_ident                   /* #4 */
          opt_use_partition             /* #5 */
          SET_SYM                       /* #6 */
          update_list                   /* #7 */
          {
            PT_insert_values_list *one_row= NEW_PTN PT_insert_values_list;
            if (one_row == NULL || one_row->push_back(&$7.value_list->value))
              MYSQL_YYABORT; // OOM
            $$= NEW_PTN PT_insert(true, $1, $2, false, $4, $5,
                                  $7.column_list, one_row,
                                  NULL,
                                  NULL, NULL);
          }
        | ...
        ;
...
update_stmt:
          opt_with_clause
          UPDATE_SYM            /* #1 */
          opt_low_priority      /* #2 */
          opt_ignore            /* #3 */
          table_reference_list  /* #4 */
          SET_SYM               /* #5 */
          update_list           /* #6 */
          opt_where_clause      /* #7 */
          opt_order_clause      /* #8 */
          opt_simple_limit      /* #9 */
          {
            $$= NEW_PTN PT_update($1, $2, $3, $4, $5, $7.column_list, $7.value_list,
                                  $8, $9, $10);
          }
        ;
update_list:
          update_list ',' update_elem
          {
            ...
          }
        | update_elem
          {
            ...
          }
        ;

update_elem:
          simple_ident_nospvar equal expr_or_default
          {
            $$.column= $1;
            $$.value= $3;
          }
        ;

Bad SQL Case:

insert into t set a = default;
replace t set a = default;
update t set a = default;

Check List

Tests

  • Unit test

@codecov
Copy link

codecov bot commented Nov 22, 2019

Codecov Report

❗ No coverage uploaded for pull request base (release-3.0@9dc33a6). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@              Coverage Diff               @@
##             release-3.0     #648   +/-   ##
==============================================
  Coverage               ?   63.89%           
==============================================
  Files                  ?       31           
  Lines                  ?    10831           
  Branches               ?        0           
==============================================
  Hits                   ?     6920           
  Misses                 ?     3502           
  Partials               ?      409
Impacted Files Coverage Δ
parser.go 86.4% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9dc33a6...18147ef. Read the comment docs.

Copy link
Member

@bb7133 bb7133 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Deardrops
Copy link
Contributor Author

@kennytm PTAL

Copy link
Contributor

@kennytm kennytm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kennytm kennytm merged commit 62bbf32 into pingcap:release-3.0 Nov 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants