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 SQL_TSI_YEAR column type syntax #540

Merged
merged 3 commits into from
Sep 4, 2019

Conversation

hey-kong
Copy link
Contributor

@hey-kong hey-kong commented Sep 3, 2019

What problem does this PR solve?

Fix compatibility problem about SQL_TSI_YEAR column type syntax

Issue: pingcap/parser#537

MySQL Syntax:

type:
...
        | YEAR_SYM opt_field_length field_options
          {
            if ($2)
            {
              errno= 0;
              ulong length= strtoul($2, NULL, 10);
              if (errno != 0 || length != 4)
              {
                /* Only support length is 4 */
                my_error(ER_INVALID_YEAR_COLUMN_LENGTH, MYF(0), "YEAR");
                MYSQL_YYABORT;
              }
            }
            // We can ignore field length and UNSIGNED/ZEROFILL attributes here.
            $$= NEW_PTN PT_year_type;
          }

Bad SQL Case:

CREATE TABLE IF NOT EXISTS table_ident (a SQL_TSI_YEAR(4), b SQL_TSI_YEAR)
CREATE TABLE IF NOT EXISTS table_ident (ident1 BOOL COMMENT "text_string" unique, ident2 SQL_TSI_YEAR(4) ZEROFILL)

Check List

Tests

  • Unit test

@codecov
Copy link

codecov bot commented Sep 3, 2019

Codecov Report

Merging #540 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #540   +/-   ##
=======================================
  Coverage   71.77%   71.77%           
=======================================
  Files          32       32           
  Lines        7802     7802           
=======================================
  Hits         5600     5600           
  Misses       1674     1674           
  Partials      528      528
Impacted Files Coverage Δ
parser.go 70.58% <ø> (ø) ⬆️

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 0daf3f7...d4953ef. Read the comment docs.

Copy link
Contributor

@tangenta tangenta left a comment

Choose a reason for hiding this comment

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

LGTM

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 35a39aa into pingcap:master Sep 4, 2019
@hey-kong hey-kong deleted the compatibility branch September 5, 2019 01:12
tiancaiamao pushed a commit to tiancaiamao/parser that referenced this pull request Apr 27, 2021
* fix SQL_TSI_YEAR column type syntax

* fix SQL_TSI_YEAR column type syntax
lyonzhi pushed a commit to lyonzhi/parser that referenced this pull request Apr 25, 2024
* fix SQL_TSI_YEAR column type syntax

* fix SQL_TSI_YEAR column type syntax
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.

4 participants