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

sqlparser: column option and table option #615 #628

Merged

Conversation

hustjieke
Copy link
Contributor

[summary]
reference: https://dev.mysql.com/doc/refman/5.7/en/create-table.html

  1. complete more columnn options, add STORAGE DEFAULT which is not descriped on official 5.7 document, but actually mysql support it.
    see: https://github.com/mysql/mysql-server/blob/5.7/sql/sql_yacc.yy#L6953
    and extra option suppored by mysql: ON UPDATE ...
    see: https://github.com/mysql/mysql-server/blob/5.7/sql/sql_yacc.yy#L6888
column_definition:
    data_type [NOT NULL | NULL] [DEFAULT default_value]
      [AUTO_INCREMENT] [UNIQUE [KEY]] [[PRIMARY] KEY]
      [COMMENT 'string']
      [COLLATE collation_name]
      [COLUMN_FORMAT {FIXED | DYNAMIC | DEFAULT}]
      [STORAGE {DISK | MEMORY}]
      [ON UPDATE NOW_SYM]
  | data_type
      [COLLATE collation_name]
      [VIRTUAL | STORED] [NOT NULL | NULL]
      [UNIQUE [KEY]] [[PRIMARY] KEY]
      [COMMENT 'string']

Currently we do not support column option [reference_definition], [GENERATED ALWAYS] AS (expr)
also : some DEFAULT now_or_signed_literal and SERIAL_SYM DEFAULT VALUE_SYM options not in 5.7 document, but acctually mysql support them.
see:
https://github.com/mysql/mysql-server/blob/5.7/sql/sql_yacc.yy#L6897
https://github.com/mysql/mysql-server/blob/5.7/sql/sql_yacc.yy#L6887

  1. complete more table options.
table_option:
    AUTO_INCREMENT [=] value
  | AVG_ROW_LENGTH [=] value
  | [DEFAULT] CHARACTER SET [=] charset_name
  | CHECKSUM [=] {0 | 1}
  | [DEFAULT] COLLATE [=] collation_name
  | COMMENT [=] 'string'
  | COMPRESSION [=] {'ZLIB' | 'LZ4' | 'NONE'}
  | CONNECTION [=] 'connect_string'
  | {DATA | INDEX} DIRECTORY [=] 'absolute path to directory'
  | DELAY_KEY_WRITE [=] {0 | 1}
  | ENCRYPTION [=] {'Y' | 'N'}
  | ENGINE [=] engine_name
  | INSERT_METHOD [=] { NO | FIRST | LAST }
  | KEY_BLOCK_SIZE [=] value
  | MAX_ROWS [=] value
  | MIN_ROWS [=] value
  | PACK_KEYS [=] {0 | 1 | DEFAULT}
  | PASSWORD [=] 'string'
  | ROW_FORMAT [=] {DEFAULT | DYNAMIC | FIXED | COMPRESSED | REDUNDANT | COMPACT | TOKUDB...}
  | STATS_AUTO_RECALC [=] {DEFAULT | 0 | 1}
  | STATS_PERSISTENT [=] {DEFAULT | 0 | 1}
  | STATS_SAMPLE_PAGES [=] value
  | TABLESPACE tablespace_name [STORAGE {DISK | MEMORY}]

Currently we do not support table options:
UNION [=] (tbl_name[,tbl_name]...)
[test case]
sqlparser/parse_test.go
sqlparser/ddl_test.go
proxy/ddl_test.go
[patch codecov]
N/A

@hustjieke hustjieke marked this pull request as draft April 29, 2020 14:53
@hustjieke hustjieke force-pushed the feature_add_options_for_create_table_#615 branch from f003872 to 9d10791 Compare April 29, 2020 14:55
[summary]
reference: https://dev.mysql.com/doc/refman/5.7/en/create-table.html

1. complete more columnn options, add `STORAGE DEFAULT` which is not descriped on official 5.7 document, but actually mysql support it.
see: https://github.com/mysql/mysql-server/blob/5.7/sql/sql_yacc.yy#L6953
and extra option suppored by mysql: `ON UPDATE ...`
see: https://github.com/mysql/mysql-server/blob/5.7/sql/sql_yacc.yy#L6888
```
column_definition:
    data_type [NOT NULL | NULL] [DEFAULT default_value]
      [AUTO_INCREMENT] [UNIQUE [KEY]] [[PRIMARY] KEY]
      [COMMENT 'string']
      [COLLATE collation_name]
      [COLUMN_FORMAT {FIXED | DYNAMIC | DEFAULT}]
      [STORAGE {DISK | MEMORY}]
      [ON UPDATE NOW_SYM]
  | data_type
      [COLLATE collation_name]
      [VIRTUAL | STORED] [NOT NULL | NULL]
      [UNIQUE [KEY]] [[PRIMARY] KEY]
      [COMMENT 'string']
```
Currently we do not support  column option ` [reference_definition]`, ` [GENERATED ALWAYS] AS (expr)`
also : some `DEFAULT now_or_signed_literal` and `SERIAL_SYM DEFAULT VALUE_SYM` options not in 5.7 document, but acctually mysql support them.
see:
https://github.com/mysql/mysql-server/blob/5.7/sql/sql_yacc.yy#L6897
https://github.com/mysql/mysql-server/blob/5.7/sql/sql_yacc.yy#L6887

2. complete more table options.
```
table_option:
    AUTO_INCREMENT [=] value
  | AVG_ROW_LENGTH [=] value
  | [DEFAULT] CHARACTER SET [=] charset_name
  | CHECKSUM [=] {0 | 1}
  | [DEFAULT] COLLATE [=] collation_name
  | COMMENT [=] 'string'
  | COMPRESSION [=] {'ZLIB' | 'LZ4' | 'NONE'}
  | CONNECTION [=] 'connect_string'
  | {DATA | INDEX} DIRECTORY [=] 'absolute path to directory'
  | DELAY_KEY_WRITE [=] {0 | 1}
  | ENCRYPTION [=] {'Y' | 'N'}
  | ENGINE [=] engine_name
  | INSERT_METHOD [=] { NO | FIRST | LAST }
  | KEY_BLOCK_SIZE [=] value
  | MAX_ROWS [=] value
  | MIN_ROWS [=] value
  | PACK_KEYS [=] {0 | 1 | DEFAULT}
  | PASSWORD [=] 'string'
  | ROW_FORMAT [=] {DEFAULT | DYNAMIC | FIXED | COMPRESSED | REDUNDANT | COMPACT | TOKUDB...}
  | STATS_AUTO_RECALC [=] {DEFAULT | 0 | 1}
  | STATS_PERSISTENT [=] {DEFAULT | 0 | 1}
  | STATS_SAMPLE_PAGES [=] value
  | TABLESPACE tablespace_name [STORAGE {DISK | MEMORY}]
```
Currently we do not support  table options:
`UNION [=] (tbl_name[,tbl_name]...)`
[test case]
sqlparser/parse_test.go
sqlparser/ddl_test.go
proxy/ddl_test.go
[patch codecov]
N/A
@hustjieke hustjieke force-pushed the feature_add_options_for_create_table_#615 branch from 9d10791 to eef2752 Compare May 2, 2020 01:35
@codecov
Copy link

codecov bot commented May 2, 2020

Codecov Report

Merging #628 into master will decrease coverage by 0%.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master    #628   +/-   ##
======================================
- Coverage      89%     89%   -1%     
======================================
  Files         128     128           
  Lines       10234   10234           
======================================
- Hits         9183    9179    -4     
- Misses        710     712    +2     
- Partials      341     343    +2     
Impacted Files Coverage Δ
src/router/api.go 89% <0%> (-3%) ⬇️
src/executor/engine/merge_join.go 95% <0%> (-2%) ⬇️

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 b108056...eef2752. Read the comment docs.

@hustjieke hustjieke marked this pull request as ready for review May 6, 2020 07:16
@BohuTANG BohuTANG removed the request for review from zhyass May 6, 2020 07:42
@BohuTANG
Copy link
Contributor

BohuTANG commented May 6, 2020

@andyli029
Ping for review.

@andyli029
Copy link
Contributor

ACK

{
$$ = string($2)
}
| COLUMN_FORMAT DYNAMIC
Copy link
Contributor

Choose a reason for hiding this comment

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

Delete one more space

{
$$ = string($2)
}
| COLUMN_FORMAT DEFAULT
Copy link
Contributor

Choose a reason for hiding this comment

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

Delete one more space

@andyli029
Copy link
Contributor

LGTM

@BohuTANG BohuTANG merged commit 71af3ad into radondb:master May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants