Skip to content

Commit

Permalink
parser: mysql start transaction WITH CONSISTENT SNAPSHOT syntax (ping…
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancaiamao authored and shenli committed Sep 8, 2016
1 parent 6b8e1cd commit 9c75a19
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
3 changes: 3 additions & 0 deletions parser/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ var tokenMap = map[string]int{
"CONNECTION": connection,
"CONNECTION_ID": connectionID,
"CONSTRAINT": constraint,
"CONSISTENT": consistent,
"CONVERT": convert,
"COUNT": count,
"CREATE": create,
Expand Down Expand Up @@ -343,6 +344,7 @@ var tokenMap = map[string]int{
"SHOW": show,
"SLEEP": sleep,
"SIGNED": signed,
"SNAPSHOT": snapshot,
"SOME": some,
"SPACE": space,
"START": start,
Expand Down Expand Up @@ -389,6 +391,7 @@ var tokenMap = map[string]int{
"WEEKOFYEAR": weekofyear,
"WHEN": when,
"WHERE": where,
"WITH": with,
"WRITE": write,
"XOR": xor,
"YEARWEEK": yearweek,
Expand Down
22 changes: 15 additions & 7 deletions parser/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ import (
/*yy:token "%c" */ identifier "identifier"
/*yy:token "\"%c\"" */ stringLit "string literal"

with "WITH"

/* the following tokens belong to NotKeywordToken*/
abs "ABS"
addDate "ADDDATE"
Expand Down Expand Up @@ -138,6 +140,7 @@ import (
compressed "COMPRESSED"
compression "COMPRESSION"
connection "CONNECTION"
consistent "CONSISTENT"
data "DATA"
dateType "DATE"
datetimeType "DATETIME"
Expand Down Expand Up @@ -185,6 +188,7 @@ import (
serializable "SERIALIZABLE"
session "SESSION"
signed "SIGNED"
snapshot "SNAPSHOT"
space "SPACE"
sqlCache "SQL_CACHE"
sqlNoCache "SQL_NO_CACHE"
Expand Down Expand Up @@ -882,6 +886,10 @@ BeginTransactionStmt:
{
$$ = &ast.BeginStmt{}
}
| "START" "TRANSACTION" "WITH" "CONSISTENT" "SNAPSHOT"
{
$$ = &ast.BeginStmt{}
}

BinlogStmt:
"BINLOG" stringLit
Expand Down Expand Up @@ -1945,13 +1953,13 @@ identifier | UnReservedKeyword | NotKeywordToken

UnReservedKeyword:
"ACTION" | "ASCII" | "AUTO_INCREMENT" | "AFTER" | "AVG" | "BEGIN" | "BIT" | "BOOL" | "BOOLEAN" | "BTREE" | "CHARSET"
| "COLUMNS" | "COMMIT" | "COMPACT" | "COMPRESSED" | "DATA" | "DATE" | "DATETIME" | "DEALLOCATE" | "DO" | "DYNAMIC"
| "END" | "ENGINE" | "ENGINES" | "ESCAPE" | "EXECUTE" | "FIELDS" | "FIRST" | "FIXED" | "FULL" | "HASH" | "LOCAL"
| "NAMES" | "OFFSET" | "PASSWORD" %prec lowerThanEq | "PREPARE" | "QUICK" | "REDUNDANT" | "ROLLBACK" | "SESSION"
| "SIGNED" | "START" | "STATUS" | "GLOBAL" | "TABLES" | "TEXT" | "TIME" | "TIMESTAMP" | "TRANSACTION" | "TRUNCATE"
| "UNKNOWN" | "VALUE" | "WARNINGS" | "YEAR" | "MODE" | "WEEK" | "ANY" | "SOME" | "USER" | "IDENTIFIED" | "COLLATION"
| "COMMENT" | "AVG_ROW_LENGTH" | "CONNECTION" | "CHECKSUM" | "COMPRESSION" | "KEY_BLOCK_SIZE" | "MAX_ROWS" | "MIN_ROWS"
| "NATIONAL" | "ROW" | "ROW_FORMAT" | "QUARTER" | "GRANTS" | "TRIGGERS" | "DELAY_KEY_WRITE" | "ISOLATION"
| "COLUMNS" | "COMMIT" | "COMPACT" | "COMPRESSED" | "CONSISTENT" | "DATA" | "DATE" | "DATETIME" | "DEALLOCATE" | "DO"
| "DYNAMIC"| "END" | "ENGINE" | "ENGINES" | "ESCAPE" | "EXECUTE" | "FIELDS" | "FIRST" | "FIXED" | "FULL" |"GLOBAL"
| "HASH" | "LOCAL" | "NAMES" | "OFFSET" | "PASSWORD" %prec lowerThanEq | "PREPARE" | "QUICK" | "REDUNDANT" | "ROLLBACK"
| "SESSION" | "SIGNED" | "SNAPSHOT" | "START" | "STATUS" | "TABLES" | "TEXT" | "TIME" | "TIMESTAMP" | "TRANSACTION"
| "TRUNCATE" | "UNKNOWN" | "VALUE" | "WARNINGS" | "YEAR" | "MODE" | "WEEK" | "ANY" | "SOME" | "USER" | "IDENTIFIED"
| "COLLATION" | "COMMENT" | "AVG_ROW_LENGTH" | "CONNECTION" | "CHECKSUM" | "COMPRESSION" | "KEY_BLOCK_SIZE" | "MAX_ROWS"
| "MIN_ROWS" | "NATIONAL" | "ROW" | "ROW_FORMAT" | "QUARTER" | "GRANTS" | "TRIGGERS" | "DELAY_KEY_WRITE" | "ISOLATION"
| "REPEATABLE" | "COMMITTED" | "UNCOMMITTED" | "ONLY" | "SERIALIZABLE" | "LEVEL" | "VARIABLES" | "SQL_CACHE"
| "SQL_NO_CACHE" | "DISABLE" | "ENABLE" | "REVERSE" | "SPACE" | "PRIVILEGES" | "NO" | "BINLOG"

Expand Down
1 change: 1 addition & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,7 @@ func (s *testParserSuite) TestComment(c *C) {
{"create table t (c int) comment 'comment'", true},
{"create table t (c int) comment comment", false},
{"create table t (comment text)", true},
{"START TRANSACTION /*!40108 WITH CONSISTENT SNAPSHOT */", true},
// For comment in query
{"/*comment*/ /*comment*/ select c /* this is a comment */ from t;", true},
}
Expand Down

0 comments on commit 9c75a19

Please sign in to comment.