提交 1b663e78 编写于 作者: martianzhang's avatar martianzhang

update vitess daily

上级 153c0c51
...@@ -1016,68 +1016,68 @@ ...@@ -1016,68 +1016,68 @@
{ {
"checksumSHA1": "w8FCRjH70gM6QttB9QrEh9Y1x64=", "checksumSHA1": "w8FCRjH70gM6QttB9QrEh9Y1x64=",
"path": "vitess.io/vitess", "path": "vitess.io/vitess",
"revision": "edaead80d2579c241ae292c70a69d1f526ceeba8", "revision": "ee89e01fd0f1e8d97911a845a1828cc1ca614c9e",
"revisionTime": "2018-10-29T04:28:01Z" "revisionTime": "2018-10-29T23:21:17Z"
}, },
{ {
"checksumSHA1": "aKn1oKcY74N8TRLm3Ayt7Q4bbI4=", "checksumSHA1": "aKn1oKcY74N8TRLm3Ayt7Q4bbI4=",
"path": "vitess.io/vitess/go/bytes2", "path": "vitess.io/vitess/go/bytes2",
"revision": "edaead80d2579c241ae292c70a69d1f526ceeba8", "revision": "ee89e01fd0f1e8d97911a845a1828cc1ca614c9e",
"revisionTime": "2018-10-29T04:28:01Z" "revisionTime": "2018-10-29T23:21:17Z"
}, },
{ {
"checksumSHA1": "JVCEN4UGRmg3TofIBdzZMZ3G0Ww=", "checksumSHA1": "JVCEN4UGRmg3TofIBdzZMZ3G0Ww=",
"path": "vitess.io/vitess/go/hack", "path": "vitess.io/vitess/go/hack",
"revision": "edaead80d2579c241ae292c70a69d1f526ceeba8", "revision": "ee89e01fd0f1e8d97911a845a1828cc1ca614c9e",
"revisionTime": "2018-10-29T04:28:01Z" "revisionTime": "2018-10-29T23:21:17Z"
}, },
{ {
"checksumSHA1": "yApy/qZmEZrjMB7ksmSgQCVfQCw=", "checksumSHA1": "e1WJ7vCnVrlQQQlc6n/FewCDMso=",
"path": "vitess.io/vitess/go/sqltypes", "path": "vitess.io/vitess/go/sqltypes",
"revision": "edaead80d2579c241ae292c70a69d1f526ceeba8", "revision": "ee89e01fd0f1e8d97911a845a1828cc1ca614c9e",
"revisionTime": "2018-10-29T04:28:01Z" "revisionTime": "2018-10-29T23:21:17Z"
}, },
{ {
"checksumSHA1": "ntFIQYkBS51G6y+FEkjFW40+HOU=", "checksumSHA1": "ntFIQYkBS51G6y+FEkjFW40+HOU=",
"path": "vitess.io/vitess/go/vt/log", "path": "vitess.io/vitess/go/vt/log",
"revision": "edaead80d2579c241ae292c70a69d1f526ceeba8", "revision": "ee89e01fd0f1e8d97911a845a1828cc1ca614c9e",
"revisionTime": "2018-10-29T04:28:01Z" "revisionTime": "2018-10-29T23:21:17Z"
}, },
{ {
"checksumSHA1": "XozR8bmeSR5KTe/nlUJkpJY2HKI=", "checksumSHA1": "XozR8bmeSR5KTe/nlUJkpJY2HKI=",
"path": "vitess.io/vitess/go/vt/proto/query", "path": "vitess.io/vitess/go/vt/proto/query",
"revision": "edaead80d2579c241ae292c70a69d1f526ceeba8", "revision": "ee89e01fd0f1e8d97911a845a1828cc1ca614c9e",
"revisionTime": "2018-10-29T04:28:01Z" "revisionTime": "2018-10-29T23:21:17Z"
}, },
{ {
"checksumSHA1": "OnWsUHLDKcO3spwH0jD55SvKD24=", "checksumSHA1": "OnWsUHLDKcO3spwH0jD55SvKD24=",
"path": "vitess.io/vitess/go/vt/proto/topodata", "path": "vitess.io/vitess/go/vt/proto/topodata",
"revision": "edaead80d2579c241ae292c70a69d1f526ceeba8", "revision": "ee89e01fd0f1e8d97911a845a1828cc1ca614c9e",
"revisionTime": "2018-10-29T04:28:01Z" "revisionTime": "2018-10-29T23:21:17Z"
}, },
{ {
"checksumSHA1": "sBAuZ/itMR8U8qbK4yLHxkP6Cpc=", "checksumSHA1": "sBAuZ/itMR8U8qbK4yLHxkP6Cpc=",
"path": "vitess.io/vitess/go/vt/proto/vtgate", "path": "vitess.io/vitess/go/vt/proto/vtgate",
"revision": "edaead80d2579c241ae292c70a69d1f526ceeba8", "revision": "ee89e01fd0f1e8d97911a845a1828cc1ca614c9e",
"revisionTime": "2018-10-29T04:28:01Z" "revisionTime": "2018-10-29T23:21:17Z"
}, },
{ {
"checksumSHA1": "pLWM+SPGZs3k+IhjktE/cGUlpM0=", "checksumSHA1": "pLWM+SPGZs3k+IhjktE/cGUlpM0=",
"path": "vitess.io/vitess/go/vt/proto/vtrpc", "path": "vitess.io/vitess/go/vt/proto/vtrpc",
"revision": "edaead80d2579c241ae292c70a69d1f526ceeba8", "revision": "ee89e01fd0f1e8d97911a845a1828cc1ca614c9e",
"revisionTime": "2018-10-29T04:28:01Z" "revisionTime": "2018-10-29T23:21:17Z"
}, },
{ {
"checksumSHA1": "az6gvy2kdu4o6RISiA1ox5VDncE=", "checksumSHA1": "re3V8oX+ujxHbNZuB+QEtrcXxE8=",
"path": "vitess.io/vitess/go/vt/sqlparser", "path": "vitess.io/vitess/go/vt/sqlparser",
"revision": "edaead80d2579c241ae292c70a69d1f526ceeba8", "revision": "ee89e01fd0f1e8d97911a845a1828cc1ca614c9e",
"revisionTime": "2018-10-29T04:28:01Z" "revisionTime": "2018-10-29T23:21:17Z"
}, },
{ {
"checksumSHA1": "oF4XzuOzwvj1iduX/lYqNSyY/HM=", "checksumSHA1": "oF4XzuOzwvj1iduX/lYqNSyY/HM=",
"path": "vitess.io/vitess/go/vt/vterrors", "path": "vitess.io/vitess/go/vt/vterrors",
"revision": "edaead80d2579c241ae292c70a69d1f526ceeba8", "revision": "ee89e01fd0f1e8d97911a845a1828cc1ca614c9e",
"revisionTime": "2018-10-29T04:28:01Z" "revisionTime": "2018-10-29T23:21:17Z"
} }
], ],
"rootPath": "github.com/XiaoMi/soar" "rootPath": "github.com/XiaoMi/soar"
......
...@@ -198,7 +198,7 @@ func ToUint64(v Value) (uint64, error) { ...@@ -198,7 +198,7 @@ func ToUint64(v Value) (uint64, error) {
panic("unreachable") panic("unreachable")
} }
// ToInt64 converts Value to uint64. // ToInt64 converts Value to int64.
func ToInt64(v Value) (int64, error) { func ToInt64(v Value) (int64, error) {
num, err := newIntegralNumeric(v) num, err := newIntegralNumeric(v)
if err != nil { if err != nil {
......
...@@ -89,6 +89,9 @@ func Parse(sql string) (Statement, error) { ...@@ -89,6 +89,9 @@ func Parse(sql string) (Statement, error) {
tokenizer := NewStringTokenizer(sql) tokenizer := NewStringTokenizer(sql)
if yyParsePooled(tokenizer) != 0 { if yyParsePooled(tokenizer) != 0 {
if tokenizer.partialDDL != nil { if tokenizer.partialDDL != nil {
if typ, val := tokenizer.Scan(); typ != 0 {
return nil, fmt.Errorf("extra characters encountered after end of DDL: '%s'", string(val))
}
log.Warningf("ignoring error parsing DDL '%s': %v", sql, tokenizer.LastError) log.Warningf("ignoring error parsing DDL '%s': %v", sql, tokenizer.LastError)
tokenizer.ParseTree = tokenizer.partialDDL tokenizer.ParseTree = tokenizer.partialDDL
return tokenizer.ParseTree, nil return tokenizer.ParseTree, nil
......
...@@ -30,11 +30,11 @@ func decNesting(yylex interface{}) { ...@@ -30,11 +30,11 @@ func decNesting(yylex interface{}) {
yylex.(*Tokenizer).nesting-- yylex.(*Tokenizer).nesting--
} }
// forceEOF forces the lexer to end prematurely. Not all SQL statements // skipToEnd forces the lexer to end prematurely. Not all SQL statements
// are supported by the Parser, thus calling forceEOF will make the lexer // are supported by the Parser, thus calling skipToEnd will make the lexer
// return EOF early. // return EOF early.
func forceEOF(yylex interface{}) { func skipToEnd(yylex interface{}) {
yylex.(*Tokenizer).ForceEOF = true yylex.(*Tokenizer).SkipToEnd = true
} }
//line sql.y:53 //line sql.y:53
...@@ -6450,25 +6450,25 @@ yydefault: ...@@ -6450,25 +6450,25 @@ yydefault:
yyDollar = yyS[yypt-0 : yypt+1] yyDollar = yyS[yypt-0 : yypt+1]
//line sql.y:3327 //line sql.y:3327
{ {
forceEOF(yylex) skipToEnd(yylex)
} }
case 832: case 832:
yyDollar = yyS[yypt-0 : yypt+1] yyDollar = yyS[yypt-0 : yypt+1]
//line sql.y:3332 //line sql.y:3332
{ {
forceEOF(yylex) skipToEnd(yylex)
} }
case 833: case 833:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
//line sql.y:3336 //line sql.y:3336
{ {
forceEOF(yylex) skipToEnd(yylex)
} }
case 834: case 834:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
//line sql.y:3340 //line sql.y:3340
{ {
forceEOF(yylex) skipToEnd(yylex)
} }
} }
goto yystack /* stack new state and value */ goto yystack /* stack new state and value */
......
...@@ -41,11 +41,11 @@ func decNesting(yylex interface{}) { ...@@ -41,11 +41,11 @@ func decNesting(yylex interface{}) {
yylex.(*Tokenizer).nesting-- yylex.(*Tokenizer).nesting--
} }
// forceEOF forces the lexer to end prematurely. Not all SQL statements // skipToEnd forces the lexer to end prematurely. Not all SQL statements
// are supported by the Parser, thus calling forceEOF will make the lexer // are supported by the Parser, thus calling skipToEnd will make the lexer
// return EOF early. // return EOF early.
func forceEOF(yylex interface{}) { func skipToEnd(yylex interface{}) {
yylex.(*Tokenizer).ForceEOF = true yylex.(*Tokenizer).SkipToEnd = true
} }
%} %}
...@@ -267,7 +267,7 @@ func forceEOF(yylex interface{}) { ...@@ -267,7 +267,7 @@ func forceEOF(yylex interface{}) {
%type <expr> charset_value %type <expr> charset_value
%type <tableIdent> table_id reserved_table_id table_alias as_opt_id %type <tableIdent> table_id reserved_table_id table_alias as_opt_id
%type <empty> as_opt %type <empty> as_opt
%type <empty> force_eof ddl_force_eof %type <empty> skip_to_end ddl_skip_to_end
%type <str> charset %type <str> charset
%type <str> set_session_or_global show_session_or_global %type <str> set_session_or_global show_session_or_global
%type <convertType> convert_type %type <convertType> convert_type
...@@ -557,16 +557,16 @@ create_statement: ...@@ -557,16 +557,16 @@ create_statement:
$1.OptLike = $2 $1.OptLike = $2
$$ = $1 $$ = $1
} }
| CREATE constraint_opt INDEX ID using_opt ON table_name ddl_force_eof | CREATE constraint_opt INDEX ID using_opt ON table_name ddl_skip_to_end
{ {
// Change this to an alter statement // Change this to an alter statement
$$ = &DDL{Action: AlterStr, Table: $7, NewName:$7} $$ = &DDL{Action: AlterStr, Table: $7, NewName:$7}
} }
| CREATE VIEW table_name ddl_force_eof | CREATE VIEW table_name ddl_skip_to_end
{ {
$$ = &DDL{Action: CreateStr, NewName: $3.ToViewName()} $$ = &DDL{Action: CreateStr, NewName: $3.ToViewName()}
} }
| CREATE OR REPLACE VIEW table_name ddl_force_eof | CREATE OR REPLACE VIEW table_name ddl_skip_to_end
{ {
$$ = &DDL{Action: CreateStr, NewName: $5.ToViewName()} $$ = &DDL{Action: CreateStr, NewName: $5.ToViewName()}
} }
...@@ -578,11 +578,11 @@ create_statement: ...@@ -578,11 +578,11 @@ create_statement:
Params: $5, Params: $5,
}} }}
} }
| CREATE DATABASE not_exists_opt ID ddl_force_eof | CREATE DATABASE not_exists_opt ID ddl_skip_to_end
{ {
$$ = &DBDDL{Action: CreateStr, DBName: string($4)} $$ = &DBDDL{Action: CreateStr, DBName: string($4)}
} }
| CREATE SCHEMA not_exists_opt ID ddl_force_eof | CREATE SCHEMA not_exists_opt ID ddl_skip_to_end
{ {
$$ = &DBDDL{Action: CreateStr, DBName: string($4)} $$ = &DBDDL{Action: CreateStr, DBName: string($4)}
} }
...@@ -1288,15 +1288,15 @@ table_opt_value: ...@@ -1288,15 +1288,15 @@ table_opt_value:
} }
alter_statement: alter_statement:
ALTER ignore_opt TABLE table_name non_add_drop_or_rename_operation force_eof ALTER ignore_opt TABLE table_name non_add_drop_or_rename_operation skip_to_end
{ {
$$ = &DDL{Action: AlterStr, Table: $4, NewName: $4} $$ = &DDL{Action: AlterStr, Table: $4, NewName: $4}
} }
| ALTER ignore_opt TABLE table_name ADD alter_object_type force_eof | ALTER ignore_opt TABLE table_name ADD alter_object_type skip_to_end
{ {
$$ = &DDL{Action: AlterStr, Table: $4, NewName: $4} $$ = &DDL{Action: AlterStr, Table: $4, NewName: $4}
} }
| ALTER ignore_opt TABLE table_name DROP alter_object_type force_eof | ALTER ignore_opt TABLE table_name DROP alter_object_type skip_to_end
{ {
$$ = &DDL{Action: AlterStr, Table: $4, NewName: $4} $$ = &DDL{Action: AlterStr, Table: $4, NewName: $4}
} }
...@@ -1328,12 +1328,12 @@ alter_statement: ...@@ -1328,12 +1328,12 @@ alter_statement:
// Change this to a rename statement // Change this to a rename statement
$$ = &DDL{Action: RenameStr, Table: $4, NewName: $7} $$ = &DDL{Action: RenameStr, Table: $4, NewName: $7}
} }
| ALTER ignore_opt TABLE table_name RENAME index_opt force_eof | ALTER ignore_opt TABLE table_name RENAME index_opt skip_to_end
{ {
// Rename an index can just be an alter // Rename an index can just be an alter
$$ = &DDL{Action: AlterStr, Table: $4, NewName: $4} $$ = &DDL{Action: AlterStr, Table: $4, NewName: $4}
} }
| ALTER VIEW table_name ddl_force_eof | ALTER VIEW table_name ddl_skip_to_end
{ {
$$ = &DDL{Action: AlterStr, Table: $3.ToViewName(), NewName: $3.ToViewName()} $$ = &DDL{Action: AlterStr, Table: $3.ToViewName(), NewName: $3.ToViewName()}
} }
...@@ -1396,12 +1396,12 @@ drop_statement: ...@@ -1396,12 +1396,12 @@ drop_statement:
} }
$$ = &DDL{Action: DropStr, Table: $4, IfExists: exists} $$ = &DDL{Action: DropStr, Table: $4, IfExists: exists}
} }
| DROP INDEX ID ON table_name ddl_force_eof | DROP INDEX ID ON table_name ddl_skip_to_end
{ {
// Change this to an alter statement // Change this to an alter statement
$$ = &DDL{Action: AlterStr, Table: $5, NewName: $5} $$ = &DDL{Action: AlterStr, Table: $5, NewName: $5}
} }
| DROP VIEW exists_opt table_name ddl_force_eof | DROP VIEW exists_opt table_name ddl_skip_to_end
{ {
var exists bool var exists bool
if $3 != 0 { if $3 != 0 {
...@@ -1434,60 +1434,60 @@ analyze_statement: ...@@ -1434,60 +1434,60 @@ analyze_statement:
} }
show_statement: show_statement:
SHOW BINARY ID ddl_force_eof /* SHOW BINARY LOGS */ SHOW BINARY ID ddl_skip_to_end /* SHOW BINARY LOGS */
{ {
$$ = &Show{Type: string($2) + " " + string($3)} $$ = &Show{Type: string($2) + " " + string($3)}
} }
| SHOW CHARACTER SET ddl_force_eof | SHOW CHARACTER SET ddl_skip_to_end
{ {
$$ = &Show{Type: string($2) + " " + string($3)} $$ = &Show{Type: string($2) + " " + string($3)}
} }
| SHOW CREATE DATABASE ddl_force_eof | SHOW CREATE DATABASE ddl_skip_to_end
{ {
$$ = &Show{Type: string($2) + " " + string($3)} $$ = &Show{Type: string($2) + " " + string($3)}
} }
/* Rule to handle SHOW CREATE EVENT, SHOW CREATE FUNCTION, etc. */ /* Rule to handle SHOW CREATE EVENT, SHOW CREATE FUNCTION, etc. */
| SHOW CREATE ID ddl_force_eof | SHOW CREATE ID ddl_skip_to_end
{ {
$$ = &Show{Type: string($2) + " " + string($3)} $$ = &Show{Type: string($2) + " " + string($3)}
} }
| SHOW CREATE PROCEDURE ddl_force_eof | SHOW CREATE PROCEDURE ddl_skip_to_end
{ {
$$ = &Show{Type: string($2) + " " + string($3)} $$ = &Show{Type: string($2) + " " + string($3)}
} }
| SHOW CREATE TABLE ddl_force_eof | SHOW CREATE TABLE ddl_skip_to_end
{ {
$$ = &Show{Type: string($2) + " " + string($3)} $$ = &Show{Type: string($2) + " " + string($3)}
} }
| SHOW CREATE TRIGGER ddl_force_eof | SHOW CREATE TRIGGER ddl_skip_to_end
{ {
$$ = &Show{Type: string($2) + " " + string($3)} $$ = &Show{Type: string($2) + " " + string($3)}
} }
| SHOW CREATE VIEW ddl_force_eof | SHOW CREATE VIEW ddl_skip_to_end
{ {
$$ = &Show{Type: string($2) + " " + string($3)} $$ = &Show{Type: string($2) + " " + string($3)}
} }
| SHOW DATABASES ddl_force_eof | SHOW DATABASES ddl_skip_to_end
{ {
$$ = &Show{Type: string($2)} $$ = &Show{Type: string($2)}
} }
| SHOW INDEX ddl_force_eof | SHOW INDEX ddl_skip_to_end
{ {
$$ = &Show{Type: string($2)} $$ = &Show{Type: string($2)}
} }
| SHOW KEYS ddl_force_eof | SHOW KEYS ddl_skip_to_end
{ {
$$ = &Show{Type: string($2)} $$ = &Show{Type: string($2)}
} }
| SHOW PROCEDURE ddl_force_eof | SHOW PROCEDURE ddl_skip_to_end
{ {
$$ = &Show{Type: string($2)} $$ = &Show{Type: string($2)}
} }
| SHOW show_session_or_global STATUS ddl_force_eof | SHOW show_session_or_global STATUS ddl_skip_to_end
{ {
$$ = &Show{Scope: $2, Type: string($3)} $$ = &Show{Scope: $2, Type: string($3)}
} }
| SHOW TABLE ddl_force_eof | SHOW TABLE ddl_skip_to_end
{ {
$$ = &Show{Type: string($2)} $$ = &Show{Type: string($2)}
} }
...@@ -1506,7 +1506,7 @@ show_statement: ...@@ -1506,7 +1506,7 @@ show_statement:
$$ = &Show{Type: $3, ShowTablesOpt: showTablesOpt} $$ = &Show{Type: $3, ShowTablesOpt: showTablesOpt}
} }
} }
| SHOW show_session_or_global VARIABLES ddl_force_eof | SHOW show_session_or_global VARIABLES ddl_skip_to_end
{ {
$$ = &Show{Scope: $2, Type: string($3)} $$ = &Show{Scope: $2, Type: string($3)}
} }
...@@ -1558,7 +1558,7 @@ show_statement: ...@@ -1558,7 +1558,7 @@ show_statement:
* SHOW BINARY LOGS * SHOW BINARY LOGS
* SHOW INVALID * SHOW INVALID
*/ */
| SHOW ID ddl_force_eof | SHOW ID ddl_skip_to_end
{ {
$$ = &Show{Type: string($2)} $$ = &Show{Type: string($2)}
} }
...@@ -1668,37 +1668,37 @@ rollback_statement: ...@@ -1668,37 +1668,37 @@ rollback_statement:
} }
other_statement: other_statement:
DESC force_eof DESC skip_to_end
{ {
$$ = &OtherRead{} $$ = &OtherRead{}
} }
| DESCRIBE force_eof | DESCRIBE skip_to_end
{ {
$$ = &OtherRead{} $$ = &OtherRead{}
} }
| EXPLAIN force_eof | EXPLAIN skip_to_end
{ {
$$ = &OtherRead{} $$ = &OtherRead{}
} }
| REPAIR force_eof | REPAIR skip_to_end
{ {
$$ = &OtherAdmin{} $$ = &OtherAdmin{}
} }
| OPTIMIZE force_eof | OPTIMIZE skip_to_end
{ {
$$ = &OtherAdmin{} $$ = &OtherAdmin{}
} }
| LOCK TABLES force_eof | LOCK TABLES skip_to_end
{ {
$$ = &OtherAdmin{} $$ = &OtherAdmin{}
} }
| UNLOCK TABLES force_eof | UNLOCK TABLES skip_to_end
{ {
$$ = &OtherAdmin{} $$ = &OtherAdmin{}
} }
flush_statement: flush_statement:
FLUSH force_eof FLUSH skip_to_end
{ {
$$ = &DDL{Action: FlushStr} $$ = &DDL{Action: FlushStr}
} }
...@@ -3323,20 +3323,20 @@ closeb: ...@@ -3323,20 +3323,20 @@ closeb:
decNesting(yylex) decNesting(yylex)
} }
force_eof: skip_to_end:
{ {
forceEOF(yylex) skipToEnd(yylex)
} }
ddl_force_eof: ddl_skip_to_end:
{ {
forceEOF(yylex) skipToEnd(yylex)
} }
| openb | openb
{ {
forceEOF(yylex) skipToEnd(yylex)
} }
| reserved_sql_id | reserved_sql_id
{ {
forceEOF(yylex) skipToEnd(yylex)
} }
...@@ -37,7 +37,7 @@ type Tokenizer struct { ...@@ -37,7 +37,7 @@ type Tokenizer struct {
InStream io.Reader InStream io.Reader
AllowComments bool AllowComments bool
SkipSpecialComments bool SkipSpecialComments bool
ForceEOF bool SkipToEnd bool
lastChar uint16 lastChar uint16
Position int Position int
lastToken []byte lastToken []byte
...@@ -428,6 +428,10 @@ func KeywordString(id int) string { ...@@ -428,6 +428,10 @@ func KeywordString(id int) string {
// Lex returns the next token form the Tokenizer. // Lex returns the next token form the Tokenizer.
// This function is used by go yacc. // This function is used by go yacc.
func (tkn *Tokenizer) Lex(lval *yySymType) int { func (tkn *Tokenizer) Lex(lval *yySymType) int {
if tkn.SkipToEnd {
return tkn.skipStatement()
}
typ, val := tkn.Scan() typ, val := tkn.Scan()
for typ == COMMENT { for typ == COMMENT {
if tkn.AllowComments { if tkn.AllowComments {
...@@ -435,6 +439,13 @@ func (tkn *Tokenizer) Lex(lval *yySymType) int { ...@@ -435,6 +439,13 @@ func (tkn *Tokenizer) Lex(lval *yySymType) int {
} }
typ, val = tkn.Scan() typ, val = tkn.Scan()
} }
if typ == 0 || typ == ';' || typ == LEX_ERROR {
// If encounter end of statement or invalid token,
// we should not accept partially parsed DDLs. They
// should instead result in parser errors. See the
// Parse function to see how this is handled.
tkn.partialDDL = nil
}
lval.bytes = val lval.bytes = val
tkn.lastToken = val tkn.lastToken = val
return typ return typ
...@@ -451,9 +462,7 @@ func (tkn *Tokenizer) Error(err string) { ...@@ -451,9 +462,7 @@ func (tkn *Tokenizer) Error(err string) {
tkn.LastError = errors.New(buf.String()) tkn.LastError = errors.New(buf.String())
// Try and re-sync to the next statement // Try and re-sync to the next statement
if tkn.lastChar != ';' { tkn.skipStatement()
tkn.skipStatement()
}
} }
// Scan scans the tokenizer for the next token and returns // Scan scans the tokenizer for the next token and returns
...@@ -475,11 +484,6 @@ func (tkn *Tokenizer) Scan() (int, []byte) { ...@@ -475,11 +484,6 @@ func (tkn *Tokenizer) Scan() (int, []byte) {
tkn.next() tkn.next()
} }
if tkn.ForceEOF {
tkn.skipStatement()
return 0, nil
}
tkn.skipBlank() tkn.skipBlank()
switch ch := tkn.lastChar; { switch ch := tkn.lastChar; {
case isLetter(ch): case isLetter(ch):
...@@ -505,14 +509,21 @@ func (tkn *Tokenizer) Scan() (int, []byte) { ...@@ -505,14 +509,21 @@ func (tkn *Tokenizer) Scan() (int, []byte) {
return tkn.scanNumber(false) return tkn.scanNumber(false)
case ch == ':': case ch == ':':
return tkn.scanBindVar() return tkn.scanBindVar()
case ch == ';' && tkn.multi: case ch == ';':
if tkn.multi {
// In multi mode, ';' is treated as EOF. So, we don't advance.
// Repeated calls to Scan will keep returning 0 until ParseNext
// forces the advance.
return 0, nil
}
tkn.next()
return ';', nil
case ch == eofChar:
return 0, nil return 0, nil
default: default:
tkn.next() tkn.next()
switch ch { switch ch {
case eofChar: case '=', ',', '(', ')', '+', '*', '%', '^', '~':
return 0, nil
case '=', ',', ';', '(', ')', '+', '*', '%', '^', '~':
return int(ch), nil return int(ch), nil
case '&': case '&':
if tkn.lastChar == '&' { if tkn.lastChar == '&' {
...@@ -613,12 +624,14 @@ func (tkn *Tokenizer) Scan() (int, []byte) { ...@@ -613,12 +624,14 @@ func (tkn *Tokenizer) Scan() (int, []byte) {
} }
} }
// skipStatement scans until the EOF, or end of statement is encountered. // skipStatement scans until end of statement.
func (tkn *Tokenizer) skipStatement() { func (tkn *Tokenizer) skipStatement() int {
ch := tkn.lastChar tkn.SkipToEnd = false
for ch != ';' && ch != eofChar { for {
tkn.next() typ, _ := tkn.Scan()
ch = tkn.lastChar if typ == 0 || typ == ';' || typ == LEX_ERROR {
return typ
}
} }
} }
...@@ -930,7 +943,7 @@ func (tkn *Tokenizer) reset() { ...@@ -930,7 +943,7 @@ func (tkn *Tokenizer) reset() {
tkn.specialComment = nil tkn.specialComment = nil
tkn.posVarIndex = 0 tkn.posVarIndex = 0
tkn.nesting = 0 tkn.nesting = 0
tkn.ForceEOF = false tkn.SkipToEnd = false
} }
func isLetter(ch uint16) bool { func isLetter(ch uint16) bool {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册