diff --git a/vendor/vendor.json b/vendor/vendor.json index 6608ffabcf8d0ed7ed232f25ea68ba9d69dacd34..51839a9ad500bbf798b31315734cce1c9af32a66 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -1016,68 +1016,68 @@ { "checksumSHA1": "w8FCRjH70gM6QttB9QrEh9Y1x64=", "path": "vitess.io/vitess", - "revision": "edaead80d2579c241ae292c70a69d1f526ceeba8", - "revisionTime": "2018-10-29T04:28:01Z" + "revision": "ee89e01fd0f1e8d97911a845a1828cc1ca614c9e", + "revisionTime": "2018-10-29T23:21:17Z" }, { "checksumSHA1": "aKn1oKcY74N8TRLm3Ayt7Q4bbI4=", "path": "vitess.io/vitess/go/bytes2", - "revision": "edaead80d2579c241ae292c70a69d1f526ceeba8", - "revisionTime": "2018-10-29T04:28:01Z" + "revision": "ee89e01fd0f1e8d97911a845a1828cc1ca614c9e", + "revisionTime": "2018-10-29T23:21:17Z" }, { "checksumSHA1": "JVCEN4UGRmg3TofIBdzZMZ3G0Ww=", "path": "vitess.io/vitess/go/hack", - "revision": "edaead80d2579c241ae292c70a69d1f526ceeba8", - "revisionTime": "2018-10-29T04:28:01Z" + "revision": "ee89e01fd0f1e8d97911a845a1828cc1ca614c9e", + "revisionTime": "2018-10-29T23:21:17Z" }, { - "checksumSHA1": "yApy/qZmEZrjMB7ksmSgQCVfQCw=", + "checksumSHA1": "e1WJ7vCnVrlQQQlc6n/FewCDMso=", "path": "vitess.io/vitess/go/sqltypes", - "revision": "edaead80d2579c241ae292c70a69d1f526ceeba8", - "revisionTime": "2018-10-29T04:28:01Z" + "revision": "ee89e01fd0f1e8d97911a845a1828cc1ca614c9e", + "revisionTime": "2018-10-29T23:21:17Z" }, { "checksumSHA1": "ntFIQYkBS51G6y+FEkjFW40+HOU=", "path": "vitess.io/vitess/go/vt/log", - "revision": "edaead80d2579c241ae292c70a69d1f526ceeba8", - "revisionTime": "2018-10-29T04:28:01Z" + "revision": "ee89e01fd0f1e8d97911a845a1828cc1ca614c9e", + "revisionTime": "2018-10-29T23:21:17Z" }, { "checksumSHA1": "XozR8bmeSR5KTe/nlUJkpJY2HKI=", "path": "vitess.io/vitess/go/vt/proto/query", - "revision": "edaead80d2579c241ae292c70a69d1f526ceeba8", - "revisionTime": "2018-10-29T04:28:01Z" + "revision": "ee89e01fd0f1e8d97911a845a1828cc1ca614c9e", + "revisionTime": "2018-10-29T23:21:17Z" }, { "checksumSHA1": "OnWsUHLDKcO3spwH0jD55SvKD24=", "path": "vitess.io/vitess/go/vt/proto/topodata", - "revision": "edaead80d2579c241ae292c70a69d1f526ceeba8", - "revisionTime": "2018-10-29T04:28:01Z" + "revision": "ee89e01fd0f1e8d97911a845a1828cc1ca614c9e", + "revisionTime": "2018-10-29T23:21:17Z" }, { "checksumSHA1": "sBAuZ/itMR8U8qbK4yLHxkP6Cpc=", "path": "vitess.io/vitess/go/vt/proto/vtgate", - "revision": "edaead80d2579c241ae292c70a69d1f526ceeba8", - "revisionTime": "2018-10-29T04:28:01Z" + "revision": "ee89e01fd0f1e8d97911a845a1828cc1ca614c9e", + "revisionTime": "2018-10-29T23:21:17Z" }, { "checksumSHA1": "pLWM+SPGZs3k+IhjktE/cGUlpM0=", "path": "vitess.io/vitess/go/vt/proto/vtrpc", - "revision": "edaead80d2579c241ae292c70a69d1f526ceeba8", - "revisionTime": "2018-10-29T04:28:01Z" + "revision": "ee89e01fd0f1e8d97911a845a1828cc1ca614c9e", + "revisionTime": "2018-10-29T23:21:17Z" }, { - "checksumSHA1": "az6gvy2kdu4o6RISiA1ox5VDncE=", + "checksumSHA1": "re3V8oX+ujxHbNZuB+QEtrcXxE8=", "path": "vitess.io/vitess/go/vt/sqlparser", - "revision": "edaead80d2579c241ae292c70a69d1f526ceeba8", - "revisionTime": "2018-10-29T04:28:01Z" + "revision": "ee89e01fd0f1e8d97911a845a1828cc1ca614c9e", + "revisionTime": "2018-10-29T23:21:17Z" }, { "checksumSHA1": "oF4XzuOzwvj1iduX/lYqNSyY/HM=", "path": "vitess.io/vitess/go/vt/vterrors", - "revision": "edaead80d2579c241ae292c70a69d1f526ceeba8", - "revisionTime": "2018-10-29T04:28:01Z" + "revision": "ee89e01fd0f1e8d97911a845a1828cc1ca614c9e", + "revisionTime": "2018-10-29T23:21:17Z" } ], "rootPath": "github.com/XiaoMi/soar" diff --git a/vendor/vitess.io/vitess/go/sqltypes/arithmetic.go b/vendor/vitess.io/vitess/go/sqltypes/arithmetic.go index 9b02ec56048af0d3703f043e9bc9b789468e4a12..f0f074ef2dab9dd595ae2f96a8ca1777118820e2 100644 --- a/vendor/vitess.io/vitess/go/sqltypes/arithmetic.go +++ b/vendor/vitess.io/vitess/go/sqltypes/arithmetic.go @@ -198,7 +198,7 @@ func ToUint64(v Value) (uint64, error) { panic("unreachable") } -// ToInt64 converts Value to uint64. +// ToInt64 converts Value to int64. func ToInt64(v Value) (int64, error) { num, err := newIntegralNumeric(v) if err != nil { diff --git a/vendor/vitess.io/vitess/go/vt/sqlparser/ast.go b/vendor/vitess.io/vitess/go/vt/sqlparser/ast.go index e0107dd1cfeadb43ea569749d9baca12f191253c..71120eeaa07410e6d27c5165de41daa8d806d22f 100644 --- a/vendor/vitess.io/vitess/go/vt/sqlparser/ast.go +++ b/vendor/vitess.io/vitess/go/vt/sqlparser/ast.go @@ -89,6 +89,9 @@ func Parse(sql string) (Statement, error) { tokenizer := NewStringTokenizer(sql) if yyParsePooled(tokenizer) != 0 { 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) tokenizer.ParseTree = tokenizer.partialDDL return tokenizer.ParseTree, nil diff --git a/vendor/vitess.io/vitess/go/vt/sqlparser/sql.go b/vendor/vitess.io/vitess/go/vt/sqlparser/sql.go index 7004dd4febaea577f84618be2a83a2b67045e438..663a5b2ba7563db2d3cc85c8522cfd6b0c8fc209 100644 --- a/vendor/vitess.io/vitess/go/vt/sqlparser/sql.go +++ b/vendor/vitess.io/vitess/go/vt/sqlparser/sql.go @@ -30,11 +30,11 @@ func decNesting(yylex interface{}) { yylex.(*Tokenizer).nesting-- } -// forceEOF forces the lexer to end prematurely. Not all SQL statements -// are supported by the Parser, thus calling forceEOF will make the lexer +// skipToEnd forces the lexer to end prematurely. Not all SQL statements +// are supported by the Parser, thus calling skipToEnd will make the lexer // return EOF early. -func forceEOF(yylex interface{}) { - yylex.(*Tokenizer).ForceEOF = true +func skipToEnd(yylex interface{}) { + yylex.(*Tokenizer).SkipToEnd = true } //line sql.y:53 @@ -6450,25 +6450,25 @@ yydefault: yyDollar = yyS[yypt-0 : yypt+1] //line sql.y:3327 { - forceEOF(yylex) + skipToEnd(yylex) } case 832: yyDollar = yyS[yypt-0 : yypt+1] //line sql.y:3332 { - forceEOF(yylex) + skipToEnd(yylex) } case 833: yyDollar = yyS[yypt-1 : yypt+1] //line sql.y:3336 { - forceEOF(yylex) + skipToEnd(yylex) } case 834: yyDollar = yyS[yypt-1 : yypt+1] //line sql.y:3340 { - forceEOF(yylex) + skipToEnd(yylex) } } goto yystack /* stack new state and value */ diff --git a/vendor/vitess.io/vitess/go/vt/sqlparser/sql.y b/vendor/vitess.io/vitess/go/vt/sqlparser/sql.y index a228742861bcdb627479bf7b19bc235346896175..a86a33fb720950f03ca3a05c70994eeaffe3dd02 100644 --- a/vendor/vitess.io/vitess/go/vt/sqlparser/sql.y +++ b/vendor/vitess.io/vitess/go/vt/sqlparser/sql.y @@ -41,11 +41,11 @@ func decNesting(yylex interface{}) { yylex.(*Tokenizer).nesting-- } -// forceEOF forces the lexer to end prematurely. Not all SQL statements -// are supported by the Parser, thus calling forceEOF will make the lexer +// skipToEnd forces the lexer to end prematurely. Not all SQL statements +// are supported by the Parser, thus calling skipToEnd will make the lexer // return EOF early. -func forceEOF(yylex interface{}) { - yylex.(*Tokenizer).ForceEOF = true +func skipToEnd(yylex interface{}) { + yylex.(*Tokenizer).SkipToEnd = true } %} @@ -267,7 +267,7 @@ func forceEOF(yylex interface{}) { %type charset_value %type table_id reserved_table_id table_alias as_opt_id %type as_opt -%type force_eof ddl_force_eof +%type skip_to_end ddl_skip_to_end %type charset %type set_session_or_global show_session_or_global %type convert_type @@ -557,16 +557,16 @@ create_statement: $1.OptLike = $2 $$ = $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 $$ = &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()} } -| 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()} } @@ -578,11 +578,11 @@ create_statement: 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)} } -| 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)} } @@ -1288,15 +1288,15 @@ table_opt_value: } 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} } -| 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} } -| 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} } @@ -1328,12 +1328,12 @@ alter_statement: // Change this to a rename statement $$ = &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 $$ = &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()} } @@ -1396,12 +1396,12 @@ drop_statement: } $$ = &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 $$ = &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 if $3 != 0 { @@ -1434,60 +1434,60 @@ analyze_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 CHARACTER SET ddl_force_eof +| SHOW CHARACTER SET ddl_skip_to_end { $$ = &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)} } /* 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 CREATE PROCEDURE ddl_force_eof +| SHOW CREATE PROCEDURE ddl_skip_to_end { $$ = &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 CREATE TRIGGER ddl_force_eof +| SHOW CREATE TRIGGER ddl_skip_to_end { $$ = &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 DATABASES ddl_force_eof +| SHOW DATABASES ddl_skip_to_end { $$ = &Show{Type: string($2)} } -| SHOW INDEX ddl_force_eof +| SHOW INDEX ddl_skip_to_end { $$ = &Show{Type: string($2)} } -| SHOW KEYS ddl_force_eof +| SHOW KEYS ddl_skip_to_end { $$ = &Show{Type: string($2)} } -| SHOW PROCEDURE ddl_force_eof +| SHOW PROCEDURE ddl_skip_to_end { $$ = &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 TABLE ddl_force_eof +| SHOW TABLE ddl_skip_to_end { $$ = &Show{Type: string($2)} } @@ -1506,7 +1506,7 @@ show_statement: $$ = &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)} } @@ -1558,7 +1558,7 @@ show_statement: * SHOW BINARY LOGS * SHOW INVALID */ -| SHOW ID ddl_force_eof +| SHOW ID ddl_skip_to_end { $$ = &Show{Type: string($2)} } @@ -1668,37 +1668,37 @@ rollback_statement: } other_statement: - DESC force_eof + DESC skip_to_end { $$ = &OtherRead{} } -| DESCRIBE force_eof +| DESCRIBE skip_to_end { $$ = &OtherRead{} } -| EXPLAIN force_eof +| EXPLAIN skip_to_end { $$ = &OtherRead{} } -| REPAIR force_eof +| REPAIR skip_to_end { $$ = &OtherAdmin{} } -| OPTIMIZE force_eof +| OPTIMIZE skip_to_end { $$ = &OtherAdmin{} } -| LOCK TABLES force_eof +| LOCK TABLES skip_to_end { $$ = &OtherAdmin{} } -| UNLOCK TABLES force_eof +| UNLOCK TABLES skip_to_end { $$ = &OtherAdmin{} } flush_statement: - FLUSH force_eof + FLUSH skip_to_end { $$ = &DDL{Action: FlushStr} } @@ -3323,20 +3323,20 @@ closeb: decNesting(yylex) } -force_eof: +skip_to_end: { - forceEOF(yylex) + skipToEnd(yylex) } -ddl_force_eof: +ddl_skip_to_end: { - forceEOF(yylex) + skipToEnd(yylex) } | openb { - forceEOF(yylex) + skipToEnd(yylex) } | reserved_sql_id { - forceEOF(yylex) + skipToEnd(yylex) } diff --git a/vendor/vitess.io/vitess/go/vt/sqlparser/token.go b/vendor/vitess.io/vitess/go/vt/sqlparser/token.go index 2058dcac7abcd082c3edae157ce6b338c9c2eba9..e87e847c8ed292d085b1efa86236455dbbc26f6b 100644 --- a/vendor/vitess.io/vitess/go/vt/sqlparser/token.go +++ b/vendor/vitess.io/vitess/go/vt/sqlparser/token.go @@ -37,7 +37,7 @@ type Tokenizer struct { InStream io.Reader AllowComments bool SkipSpecialComments bool - ForceEOF bool + SkipToEnd bool lastChar uint16 Position int lastToken []byte @@ -428,6 +428,10 @@ func KeywordString(id int) string { // Lex returns the next token form the Tokenizer. // This function is used by go yacc. func (tkn *Tokenizer) Lex(lval *yySymType) int { + if tkn.SkipToEnd { + return tkn.skipStatement() + } + typ, val := tkn.Scan() for typ == COMMENT { if tkn.AllowComments { @@ -435,6 +439,13 @@ func (tkn *Tokenizer) Lex(lval *yySymType) int { } 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 tkn.lastToken = val return typ @@ -451,9 +462,7 @@ func (tkn *Tokenizer) Error(err string) { tkn.LastError = errors.New(buf.String()) // 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 @@ -475,11 +484,6 @@ func (tkn *Tokenizer) Scan() (int, []byte) { tkn.next() } - if tkn.ForceEOF { - tkn.skipStatement() - return 0, nil - } - tkn.skipBlank() switch ch := tkn.lastChar; { case isLetter(ch): @@ -505,14 +509,21 @@ func (tkn *Tokenizer) Scan() (int, []byte) { return tkn.scanNumber(false) case ch == ':': 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 default: tkn.next() switch ch { - case eofChar: - return 0, nil - case '=', ',', ';', '(', ')', '+', '*', '%', '^', '~': + case '=', ',', '(', ')', '+', '*', '%', '^', '~': return int(ch), nil case '&': if tkn.lastChar == '&' { @@ -613,12 +624,14 @@ func (tkn *Tokenizer) Scan() (int, []byte) { } } -// skipStatement scans until the EOF, or end of statement is encountered. -func (tkn *Tokenizer) skipStatement() { - ch := tkn.lastChar - for ch != ';' && ch != eofChar { - tkn.next() - ch = tkn.lastChar +// skipStatement scans until end of statement. +func (tkn *Tokenizer) skipStatement() int { + tkn.SkipToEnd = false + for { + typ, _ := tkn.Scan() + if typ == 0 || typ == ';' || typ == LEX_ERROR { + return typ + } } } @@ -930,7 +943,7 @@ func (tkn *Tokenizer) reset() { tkn.specialComment = nil tkn.posVarIndex = 0 tkn.nesting = 0 - tkn.ForceEOF = false + tkn.SkipToEnd = false } func isLetter(ch uint16) bool {