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: check invalid column define option for generated columns #201

Merged
merged 12 commits into from
Apr 26, 2019

Conversation

spongedu
Copy link
Contributor

@spongedu spongedu commented Feb 6, 2019

What problem does this PR solve?

As is described in MySQL Reference, generated column definitions have this syntax below:

col_name data_type [GENERATED ALWAYS] AS (expr)
  [VIRTUAL | STORED] [NOT NULL | NULL]
  [UNIQUE [KEY]] [[PRIMARY] KEY]
  [COMMENT 'string']

some column options such as DEFAULT, AUTO_INCREMENT, ON UPDATE are not supported for generate column definition. A parser error should be raised with these options.

What is changed and how it works?

Add an check in parser when ColumnDef is created for generated columns.

Check List

Tests

  • Unit test
  • Integration test

Code changes

Side effects

Related changes

@spongedu
Copy link
Contributor Author

@kennytm @morgo PTAL

ast/ddl.go Outdated Show resolved Hide resolved
ast/ddl.go Show resolved Hide resolved
ast/ddl.go Outdated Show resolved Hide resolved
parser.y Outdated Show resolved Hide resolved
@spongedu
Copy link
Contributor Author

@kennytm PTAL

@morgo morgo self-requested a review April 26, 2019 14:29
Copy link
Contributor

@morgo morgo 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 added the status/LGT1 LGT1 label Apr 26, 2019
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 added status/LGT2 LGT2 and removed status/LGT1 LGT1 labels Apr 26, 2019
@kennytm
Copy link
Contributor

kennytm commented Apr 26, 2019

@spongedu Thanks for contribution. For the build-integration failure, please file a PR to pingcap/tidb to update the parser dependency, and change this test to test for parse failure. cc @winkyao pingcap/tidb#8620.

@kennytm kennytm merged commit f3ecae0 into pingcap:master Apr 26, 2019
@spongedu
Copy link
Contributor Author

@kennytm ok

tiancaiamao pushed a commit to tiancaiamao/parser that referenced this pull request Apr 27, 2021
…gcap#201)

* parser: add check on column options

* add related tests

* add more tests

* fix ident problems

* fix bug

* Code refine according to reviewer's opinion
lyonzhi pushed a commit to lyonzhi/parser that referenced this pull request Apr 25, 2024
…gcap#201)

* parser: add check on column options

* add related tests

* add more tests

* fix ident problems

* fix bug

* Code refine according to reviewer's opinion
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