Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor(parser/mysql): migrate completion to omni parser [BYT-9121] (#19908)
rebelicefe5a65de4f0d
diff --git a/backend/plugin/parser/mysql/completion.go b/backend/plugin/parser/mysql/completion.goindex 2466423cd5..73b2cc00e4 100644--- a/backend/plugin/parser/mysql/completion.go+++ b/backend/plugin/parser/mysql/completion.go@@ -6,33 +6,26 @@ import ("slices""strings""unicode"+ "unicode/utf8"- "github.com/antlr4-go/antlr/v4"- "github.com/bytebase/parser/mysql"+ "github.com/bytebase/omni/mysql/ast"+ mysqlparser "github.com/bytebase/omni/mysql/parser"- "github.com/bytebase/bytebase/backend/generated-go/store"+ storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store/model")-var (- // globalFollowSetsByState is the global follow sets by state.- // It is shared by all MySQL completers.- // The FollowSetsByState is the thread-safe struct.- globalFollowSetsByState = base.NewFollowSetsByState()-)-func init() {- base.RegisterCompleteFunc(store.Engine_MYSQL, Completion)- base.RegisterCompleteFunc(store.Engine_MARIADB, Completion)- base.RegisterCompleteFunc(store.Engine_TIDB, Completion)- base.RegisterCompleteFunc(store.Engine_OCEANBASE, Completion)- base.RegisterCompleteFunc(store.Engine_CLICKHOUSE, Completion)- base.RegisterCompleteFunc(store.Engine_STARROCKS, Completion)- base.RegisterCompleteFunc(store.Engine_DORIS, Completion)+ base.RegisterCompleteFunc(storepb.Engine_MYSQL, Completion)+ base.RegisterCompleteFunc(storepb.Engine_MARIADB, Completion)+ base.RegisterCompleteFunc(storepb.Engine_TIDB, Completion)+ base.RegisterCompleteFunc(storepb.Engine_OCEANBASE, Completion)+ base.RegisterCompleteFunc(storepb.Engine_CLICKHOUSE, Completion)+ base.RegisterCompleteFunc(storepb.Engine_STARROCKS, Completion)+ base.RegisterCompleteFunc(storepb.Engine_DORIS, Completion)}-// Completion is the entry point of MySQL code completion.func Completion(ctx context.Context, cCtx base.CompletionContext, statement string, caretLine int, caretOffset int) ([]base.Candidate, error) {completer := NewStandardCompleter(ctx, cCtx, statement, caretLine, caretOffset)result, err := completer.completion()@@ -47,187 +40,60 @@ func Completion(ctx context.Context, cCtx base.CompletionContext, statement strireturn trickyCompleter.completion()}-func newIgnoredTokens() map[int]bool {- return map[int]bool{- mysql.MySQLParserEOF: true,- mysql.MySQLLexerEQUAL_OPERATOR: true,- mysql.MySQLLexerASSIGN_OPERATOR: true,- mysql.MySQLLexerNULL_SAFE_EQUAL_OPERATOR: true,- mysql.MySQLLexerGREATER_OR_EQUAL_OPERATOR: true,- mysql.MySQLLexerGREATER_THAN_OPERATOR: true,- mysql.MySQLLexerLESS_OR_EQUAL_OPERATOR: true,- mysql.MySQLLexerLESS_THAN_OPERATOR: true,- mysql.MySQLLexerNOT_EQUAL_OPERATOR: true,- mysql.MySQLLexerNOT_EQUAL2_OPERATOR: true,- mysql.MySQLLexerPLUS_OPERATOR: true,- mysql.MySQLLexerMINUS_OPERATOR: true,- mysql.MySQLLexerMULT_OPERATOR: true,- mysql.MySQLLexerDIV_OPERATOR: true,- mysql.MySQLLexerMOD_OPERATOR: true,- mysql.MySQLLexerLOGICAL_NOT_OPERATOR: true,- mysql.MySQLLexerBITWISE_NOT_OPERATOR: true,- mysql.MySQLLexerSHIFT_LEFT_OPERATOR: true,- mysql.MySQLLexerSHIFT_RIGHT_OPERATOR: true,- mysql.MySQLLexerLOGICAL_AND_OPERATOR: true,- mysql.MySQLLexerBITWISE_AND_OPERATOR: true,- mysql.MySQLLexerBITWISE_XOR_OPERATOR: true,- mysql.MySQLLexerLOGICAL_OR_OPERATOR: true,- mysql.MySQLLexerBITWISE_OR_OPERATOR: true,- mysql.MySQLLexerDOT_SYMBOL: true,- mysql.MySQLLexerCOMMA_SYMBOL: true,- mysql.MySQLLexerSEMICOLON_SYMBOL: true,- mysql.MySQLLexerCOLON_SYMBOL: true,- mysql.MySQLLexerOPEN_PAR_SYMBOL: true,- mysql.MySQLLexerCLOSE_PAR_SYMBOL: true,- mysql.MySQLLexerOPEN_CURLY_SYMBOL: true,- mysql.MySQLLexerCLOSE_CURLY_SYMBOL: true,- mysql.MySQLLexerUNDERLINE_SYMBOL: true,- mysql.MySQLLexerAT_SIGN_SYMBOL: true,- mysql.MySQLLexerAT_AT_SIGN_SYMBOL: true,- mysql.MySQLLexerNULL2_SYMBOL: true,- mysql.MySQLLexerPARAM_MARKER: true,- mysql.MySQLLexerCONCAT_PIPES_SYMBOL: true,- mysql.MySQLLexerAT_TEXT_SUFFIX: true,- mysql.MySQLLexerBACK_TICK_QUOTED_ID: true,- mysql.MySQLLexerSINGLE_QUOTED_TEXT: true,- mysql.MySQLLexerDOUBLE_QUOTED_TEXT: true,- mysql.MySQLLexerNCHAR_TEXT: true,- mysql.MySQLLexerUNDERSCORE_CHARSET: true,- mysql.MySQLLexerIDENTIFIER: true,- mysql.MySQLLexerINT_NUMBER: true,- mysql.MySQLLexerLONG_NUMBER: true,- mysql.MySQLLexerULONGLONG_NUMBER: true,- mysql.MySQLLexerDECIMAL_NUMBER: true,- mysql.MySQLLexerBIN_NUMBER: true,- mysql.MySQLLexerHEX_NUMBER: true,- }-}--func newPreferredRules() map[int]bool {- return map[int]bool{- mysql.MySQLParserRULE_schemaRef: true,- mysql.MySQLParserRULE_tableRef: true,- mysql.MySQLParserRULE_tableRefWithWildcard: true,- mysql.MySQLParserRULE_filterTableRef: true,- mysql.MySQLParserRULE_columnRef: true,- mysql.MySQLParserRULE_columnInternalRef: true,- mysql.MySQLParserRULE_tableWild: true,- mysql.MySQLParserRULE_functionRef: true,- mysql.MySQLParserRULE_functionCall: true,- mysql.MySQLParserRULE_runtimeFunctionCall: true,- mysql.MySQLParserRULE_triggerRef: true,- mysql.MySQLParserRULE_viewRef: true,- mysql.MySQLParserRULE_procedureRef: true,- mysql.MySQLParserRULE_logfileGroupRef: true,- mysql.MySQLParserRULE_tablespaceRef: true,- mysql.MySQLParserRULE_engineRef: true,- mysql.MySQLParserRULE_collationName: true,- mysql.MySQLParserRULE_charsetName: true,- mysql.MySQLParserRULE_eventRef: true,- mysql.MySQLParserRULE_serverRef: true,- mysql.MySQLParserRULE_user: true,- mysql.MySQLParserRULE_userVariable: true,- mysql.MySQLParserRULE_systemVariable: true,- mysql.MySQLParserRULE_labelRef: true,- mysql.MySQLParserRULE_setSystemVariable: true,- mysql.MySQLParserRULE_parameterName: true,- mysql.MySQLParserRULE_procedureName: true,- mysql.MySQLParserRULE_identifier: true,- mysql.MySQLParserRULE_labelIdentifier: true,+func computeSQLAndByteOffset(statement string, caretLine int, caretOffset int, tricky bool) (string, int) {+ var sql string+ var newLine, newOffset int+ if tricky {+ sql, newLine, newOffset = skipHeadingSQLs(statement, caretLine, caretOffset)+ sql, newLine, newOffset = skipHeadingSQLWithoutSemicolon(sql, newLine, newOffset)+ } else {+ sql, newLine, newOffset = skipHeadingSQLs(statement, caretLine, caretOffset)}+ return sql, lineColumnToByteOffset(sql, newLine, newOffset)}-func newNoSeparatorRequired() map[int]bool {- return map[int]bool{- mysql.MySQLLexerEQUAL_OPERATOR: true,- mysql.MySQLLexerASSIGN_OPERATOR: true,- mysql.MySQLLexerNULL_SAFE_EQUAL_OPERATOR: true,- mysql.MySQLLexerGREATER_OR_EQUAL_OPERATOR: true,- mysql.MySQLLexerGREATER_THAN_OPERATOR: true,- mysql.MySQLLexerLESS_OR_EQUAL_OPERATOR: true,- mysql.MySQLLexerLESS_THAN_OPERATOR: true,- mysql.MySQLLexerNOT_EQUAL_OPERATOR: true,- mysql.MySQLLexerNOT_EQUAL2_OPERATOR: true,- mysql.MySQLLexerPLUS_OPERATOR: true,- mysql.MySQLLexerMINUS_OPERATOR: true,- mysql.MySQLLexerMULT_OPERATOR: true,- mysql.MySQLLexerDIV_OPERATOR: true,- mysql.MySQLLexerMOD_OPERATOR: true,- mysql.MySQLLexerLOGICAL_NOT_OPERATOR: true,- mysql.MySQLLexerBITWISE_NOT_OPERATOR: true,- mysql.MySQLLexerSHIFT_LEFT_OPERATOR: true,- mysql.MySQLLexerSHIFT_RIGHT_OPERATOR: true,- mysql.MySQLLexerLOGICAL_AND_OPERATOR: true,- mysql.MySQLLexerBITWISE_AND_OPERATOR: true,- mysql.MySQLLexerBITWISE_XOR_OPERATOR: true,- mysql.MySQLLexerLOGICAL_OR_OPERATOR: true,- mysql.MySQLLexerBITWISE_OR_OPERATOR: true,- mysql.MySQLLexerDOT_SYMBOL: true,- mysql.MySQLLexerCOMMA_SYMBOL: true,- mysql.MySQLLexerSEMICOLON_SYMBOL: true,- mysql.MySQLLexerCOLON_SYMBOL: true,- mysql.MySQLLexerOPEN_PAR_SYMBOL: true,- mysql.MySQLLexerCLOSE_PAR_SYMBOL: true,- mysql.MySQLLexerOPEN_CURLY_SYMBOL: true,- mysql.MySQLLexerCLOSE_CURLY_SYMBOL: true,- mysql.MySQLLexerPARAM_MARKER: true,+func lineColumnToByteOffset(sql string, line, column int) int {+ currentLine := 1+ for i := 0; i < len(sql); i++ {+ if currentLine == line {+ pos := i+ for c := 0; c < column && pos < len(sql); c++ {+ _, size := utf8.DecodeRuneInString(sql[pos:])+ pos += size+ }+ if pos > len(sql) {+ return len(sql)+ }+ return pos+ }+ if sql[i] == '\n' {+ currentLine+++ }}+ return len(sql)}-func newSynonyms() map[int][]string {- return map[int][]string{- mysql.MySQLLexerCHAR_SYMBOL: {"CHARACTER"},- mysql.MySQLLexerNOW_SYMBOL: {"CURRENT_TIMESTAMP", "LOCALTIME", "LOCALTIMESTAMP"},- mysql.MySQLLexerDAY_SYMBOL: {"DAYOFMONTH", "SQL_TSI_DAY"},- mysql.MySQLLexerDECIMAL_SYMBOL: {"DEC"},- mysql.MySQLLexerDISTINCT_SYMBOL: {"DISTINCTROW"},- mysql.MySQLLexerCOLUMNS_SYMBOL: {"FIELDS"},- mysql.MySQLLexerFLOAT_SYMBOL: {"FLOAT4"},- mysql.MySQLLexerDOUBLE_SYMBOL: {"FLOAT8"},- mysql.MySQLLexerINT_SYMBOL: {"INTEGER", "INT4"},- mysql.MySQLLexerRELAY_THREAD_SYMBOL: {"IO_THREAD"},- mysql.MySQLLexerSUBSTRING_SYMBOL: {"MID", "SUBSTR"},- mysql.MySQLLexerMID_SYMBOL: {"MEDIUMINT"},- mysql.MySQLLexerMEDIUMINT_SYMBOL: {"MIDDLEINT", "INT3"},- mysql.MySQLLexerNDBCLUSTER_SYMBOL: {"NDB"},- mysql.MySQLLexerREGEXP_SYMBOL: {"RLIKE"},- mysql.MySQLLexerDATABASE_SYMBOL: {"SCHEMA"},- mysql.MySQLLexerDATABASES_SYMBOL: {"SCHEMAS"},- mysql.MySQLLexerUSER_SYMBOL: {"SESSION_USER"},- mysql.MySQLLexerSTD_SYMBOL: {"STDDEV", "STDDEV"},- mysql.MySQLLexerVARCHAR_SYMBOL: {"VARCHARACTER"},- mysql.MySQLLexerVARIANCE_SYMBOL: {"VAR_POP"},- mysql.MySQLLexerTINYINT_SYMBOL: {"INT1"},- mysql.MySQLLexerSMALLINT_SYMBOL: {"INT2"},- mysql.MySQLLexerBIGINT_SYMBOL: {"INT8"},- mysql.MySQLLexerSECOND_SYMBOL: {"SQL_TSI_SECOND"},- mysql.MySQLLexerMINUTE_SYMBOL: {"SQL_TSI_MINUTE"},- mysql.MySQLLexerHOUR_SYMBOL: {"SQL_TSI_HOUR"},- mysql.MySQLLexerWEEK_SYMBOL: {"SQL_TSI_WEEK"},- mysql.MySQLLexerMONTH_SYMBOL: {"SQL_TSI_MONTH"},- mysql.MySQLLexerQUARTER_SYMBOL: {"SQL_TSI_QUARTER"},- mysql.MySQLLexerYEAR_SYMBOL: {"SQL_TSI_YEAR"},+func isNoSeparatorRequired(tokenType int) bool {+ switch tokenType {+ case '.', '(', ')', ',', ';', '=', '<', '>', '+', '-', '*', '/', '%', '^', '~', '!', '@':+ return true}+ return false}type Completer struct {- ctx context.Context- core *base.CodeCompletionCore- scene base.SceneType- parser *mysql.MySQLParser- lexer *mysql.MySQLLexer- scanner *base.Scanner- instanceID string- defaultDatabase string- getMetadata base.GetDatabaseMetadataFunc- listDatabaseNames base.ListDatabaseNamesFunc- metadataCache map[string]*model.DatabaseMetadata- noSeparatorRequired map[int]bool- // referencesStack is a hierarchical stack of table references.- // We'll update the stack when we encounter a new FROM clauses.- referencesStack [][]base.TableReference- // references is the flattened table references.- // It's helpful to look up the table reference.+ ctx context.Context+ scene base.SceneType+ sql string+ cursorByteOffset int+ tokens []mysqlparser.Token+ caretTokenIndex int+ instanceID string+ defaultDatabase string+ getMetadata base.GetDatabaseMetadataFunc+ listDatabaseNames base.ListDatabaseNamesFunc+ metadataCache map[string]*model.DatabaseMetadata+ referencesStack [][]base.TableReferencereferences []base.TableReferencecteCache map[int][]*base.VirtualTableReferencecteTables []*base.VirtualTableReference@@ -235,290 +101,425 @@ type Completer struct {}func NewStandardCompleter(ctx context.Context, cCtx base.CompletionContext, statement string, caretLine int, caretOffset int) *Completer {- parser, lexer, scanner := prepareParserAndScanner(statement, caretLine, caretOffset)- // For all MySQL completers, we use one global follow sets by state.- // The FollowSetsByState is the thread-safe struct.- core := base.NewCodeCompletionCore(- ctx,- parser,- newIgnoredTokens(),- newPreferredRules(),- &globalFollowSetsByState,- mysql.MySQLParserRULE_querySpecification,- mysql.MySQLParserRULE_queryExpression,- mysql.MySQLParserRULE_selectAlias,- mysql.MySQLParserRULE_withClause,- )+ sql, byteOffset := computeSQLAndByteOffset(statement, caretLine, caretOffset, false)+ tokens := mysqlparser.Tokenize(sql)+ caretTokenIndex := findCaretTokenIndex(tokens, byteOffset)return &Completer{- ctx: ctx,- core: core,- scene: cCtx.Scene,- parser: parser,- lexer: lexer,- scanner: scanner,- instanceID: cCtx.InstanceID,- defaultDatabase: cCtx.DefaultDatabase,- getMetadata: cCtx.Metadata,- listDatabaseNames: cCtx.ListDatabaseNames,- metadataCache: make(map[string]*model.DatabaseMetadata),- noSeparatorRequired: newNoSeparatorRequired(),- cteCache: make(map[int][]*base.VirtualTableReference),+ ctx: ctx,+ scene: cCtx.Scene,+ sql: sql,+ cursorByteOffset: byteOffset,+ tokens: tokens,+ caretTokenIndex: caretTokenIndex,+ instanceID: cCtx.InstanceID,+ defaultDatabase: cCtx.DefaultDatabase,+ getMetadata: cCtx.Metadata,+ listDatabaseNames: cCtx.ListDatabaseNames,+ metadataCache: make(map[string]*model.DatabaseMetadata),+ cteCache: make(map[int][]*base.VirtualTableReference),}}func NewTrickyCompleter(ctx context.Context, cCtx base.CompletionContext, statement string, caretLine int, caretOffset int) *Completer {- parser, lexer, scanner := prepareTrickyParserAndScanner(statement, caretLine, caretOffset)- // For all MySQL completers, we use one global follow sets by state.- // The FollowSetsByState is the thread-safe struct.- core := base.NewCodeCompletionCore(- ctx,- parser,- newIgnoredTokens(),- newPreferredRules(),- &globalFollowSetsByState,- mysql.MySQLParserRULE_querySpecification,- mysql.MySQLParserRULE_queryExpression,- mysql.MySQLParserRULE_selectAlias,- mysql.MySQLParserRULE_withClause,- )+ sql, byteOffset := computeSQLAndByteOffset(statement, caretLine, caretOffset, true)+ tokens := mysqlparser.Tokenize(sql)+ caretTokenIndex := findCaretTokenIndex(tokens, byteOffset)return &Completer{- ctx: ctx,- core: core,- scene: cCtx.Scene,- parser: parser,- lexer: lexer,- scanner: scanner,- instanceID: cCtx.InstanceID,- defaultDatabase: cCtx.DefaultDatabase,- getMetadata: cCtx.Metadata,- listDatabaseNames: cCtx.ListDatabaseNames,- metadataCache: make(map[string]*model.DatabaseMetadata),- noSeparatorRequired: newNoSeparatorRequired(),- cteCache: make(map[int][]*base.VirtualTableReference),+ ctx: ctx,+ scene: cCtx.Scene,+ sql: sql,+ cursorByteOffset: byteOffset,+ tokens: tokens,+ caretTokenIndex: caretTokenIndex,+ instanceID: cCtx.InstanceID,+ defaultDatabase: cCtx.DefaultDatabase,+ getMetadata: cCtx.Metadata,+ listDatabaseNames: cCtx.ListDatabaseNames,+ metadataCache: make(map[string]*model.DatabaseMetadata),+ cteCache: make(map[int][]*base.VirtualTableReference),+ }+}++func findCaretTokenIndex(tokens []mysqlparser.Token, byteOffset int) int {+ for i, tok := range tokens {+ if tok.Loc >= byteOffset {+ return i+ }}+ return len(tokens)}func (c *Completer) completion() ([]base.Candidate, error) {- // Check the caret token is quoted or not.- // This check should be done before checking the caret token is a separator or not.- if c.scanner.IsTokenType(mysql.MySQLLexerBACK_TICK_QUOTED_ID) {+ // Check if the caret is inside or at the start of a backtick-quoted identifier.+ // caretTokenIndex points to the first token at or after cursorByteOffset, so+ // the containing token (when the cursor is inside one) is at index-1.+ checkTokenQuoted := func(idx int) bool {+ if idx < 0 || idx >= len(c.tokens) {+ return false+ }+ tok := c.tokens[idx]+ return mysqlparser.IsIdentTokenType(tok.Type) && tok.Loc < len(c.sql) && c.sql[tok.Loc] == '`'+ }+ if checkTokenQuoted(c.caretTokenIndex) {c.caretTokenIsQuoted = true+ } else if c.caretTokenIndex > 0 {+ prev := c.tokens[c.caretTokenIndex-1]+ if prev.End >= c.cursorByteOffset && checkTokenQuoted(c.caretTokenIndex-1) {+ c.caretTokenIsQuoted = true+ }}- caretIndex := c.scanner.GetIndex()- if caretIndex > 0 && !c.noSeparatorRequired[c.scanner.GetPreviousTokenType(false /* skipHidden */)] {+ caretIndex := c.caretTokenIndex+ if caretIndex > 0 && !isNoSeparatorRequired(c.tokens[caretIndex-1].Type) {caretIndex--}c.referencesStack = append([][]base.TableReference{{}}, c.referencesStack...)- c.parser.Reset()- var context antlr.ParserRuleContext- if c.scene == base.SceneTypeQuery {- context = c.parser.SelectStatement()- } else {- context = c.parser.Script()- }- candidates := c.core.CollectCandidates(caretIndex, context)+ candidates := mysqlparser.Collect(c.sql, c.cursorByteOffset)- if len(candidates.Tokens[mysql.MySQLLexerNOT2_SYMBOL]) > 0 {- // For code completion, we don't distinguish NOT and NOT2.- candidates.Tokens[mysql.MySQLLexerNOT_SYMBOL] = candidates.Tokens[mysql.MySQLLexerNOT2_SYMBOL]- delete(candidates.Tokens, mysql.MySQLLexerNOT2_SYMBOL)+ if len(candidates.Rules) == 0 {+ if prefixTok, ok := c.prefixToken(); ok {+ candidates = mysqlparser.Collect(c.sql, prefixTok.Loc)+ }}- for ruleName := range candidates.Rules {- if ruleName == mysql.MySQLParserRULE_columnRef {- c.collectLeadingTableReferences(caretIndex, false /* forTableAlter */)+ for _, rc := range candidates.Rules {+ if rc.Rule == "columnref" {+ c.collectLeadingTableReferences(caretIndex)c.takeReferencesSnapshot()c.collectRemainingTableReferences()c.takeReferencesSnapshot()- c.collectInsertTableReferences(caretIndex)- c.takeReferencesSnapshot()break- } else if ruleName == mysql.MySQLParserRULE_columnInternalRef {- c.collectLeadingTableReferences(caretIndex, true /* forTableAlter */)- c.takeReferencesSnapshot()}}return c.convertCandidates(candidates)}-func (c *Completer) convertCandidates(candidates *base.CandidatesCollection) ([]base.Candidate, error) {- synonyms := newSynonyms()- keywordEntries := make(CompletionMap)- runtimeFunctionEntries := make(CompletionMap)- schemaEntries := make(CompletionMap)- tableEntries := make(CompletionMap)- columnEntries := make(CompletionMap)- viewEntries := make(CompletionMap)+func (c *Completer) prefixToken() (mysqlparser.Token, bool) {+ idx := c.caretTokenIndex+ if idx < len(c.tokens) {+ tok := c.tokens[idx]+ if tok.Loc < c.cursorByteOffset && c.cursorByteOffset <= tok.End && mysqlparser.IsIdentTokenType(tok.Type) {+ return tok, true+ }+ }+ if idx > 0 {+ tok := c.tokens[idx-1]+ if tok.End == c.cursorByteOffset && mysqlparser.IsIdentTokenType(tok.Type) {+ return tok, true+ }+ }+ return mysqlparser.Token{}, false+}- for token, value := range candidates.Tokens {- entry := c.parser.SymbolicNames[token]- if strings.HasSuffix(entry, "_SYMBOL") {- entry = entry[:len(entry)-7]- } else {- entry = unquote(entry)+type CompletionMap map[string]base.Candidate++func (m CompletionMap) Insert(entry base.Candidate) {+ m[entry.String()] = entry+}++func (m CompletionMap) insertFunctions() {+ for _, name := range getMySQLBuiltinFunctions() {+ m.Insert(base.Candidate{+ Type: base.CandidateTypeFunction,+ Text: name + "()",+ })+ }+}++func (m CompletionMap) insertDatabases(c *Completer) {+ for _, database := range c.listAllDatabases() {+ m.Insert(base.Candidate{+ Type: base.CandidateTypeDatabase,+ Text: database,+ })+ }+}++func (m CompletionMap) insertTables(c *Completer, schemas map[string]bool) {+ for schema := range schemas {+ if len(schema) == 0 {+ for _, table := range c.cteTables {+ m.Insert(base.Candidate{+ Type: base.CandidateTypeTable,+ Text: c.quotedIdentifierIfNeeded(table.Table),+ })+ }+ continue+ }+ for _, table := range c.listTables(schema) {+ m.Insert(base.Candidate{+ Type: base.CandidateTypeTable,+ Text: c.quotedIdentifierIfNeeded(table),+ })}+ }+}- list := 0- if len(value) > 0 {- // For function call:- if value[0] == mysql.MySQLLexerOPEN_PAR_SYMBOL {- list = 1- } else {- for _, item := range value {- subEntry := c.parser.SymbolicNames[item]- if strings.HasSuffix(subEntry, "_SYMBOL") {- subEntry = subEntry[:len(subEntry)-7]- } else {- subEntry = unquote(subEntry)+func (m CompletionMap) insertViews(c *Completer, schemas map[string]bool) {+ for schema := range schemas {+ for _, view := range c.listViews(schema) {+ m.Insert(base.Candidate{+ Type: base.CandidateTypeView,+ Text: c.quotedIdentifierIfNeeded(view),+ })+ }+ }+}++func (m CompletionMap) insertColumns(c *Completer, databases, tables map[string]bool) {+ for database := range databases {+ if len(database) == 0 {+ for _, table := range c.cteTables {+ if tables[table.Table] {+ for _, column := range table.Columns {+ m.Insert(base.Candidate{+ Type: base.CandidateTypeColumn,+ Text: c.quotedIdentifierIfNeeded(column),+ })}- entry += " " + subEntry}}+ continue+ }+ if _, exists := c.metadataCache[database]; !exists {+ _, metadata, err := c.getMetadata(c.ctx, c.instanceID, database)+ if err != nil || metadata == nil {+ continue+ }+ c.metadataCache[database] = metadata+ }++ for table := range tables {+ tableMeta := c.metadataCache[database].GetSchemaMetadata("").GetTable(table)+ if tableMeta == nil {+ continue+ }+ for _, column := range tableMeta.GetProto().GetColumns() {+ definition := fmt.Sprintf("%s | %s", table, column.Type)+ if !column.Nullable {+ definition += ", NOT NULL"+ }+ m.Insert(base.Candidate{+ Type: base.CandidateTypeColumn,+ Text: c.quotedIdentifierIfNeeded(column.Name),+ Definition: definition,+ Comment: column.Comment,+ })+ }}+ }+}- switch list {- case 1:- runtimeFunctionEntries.Insert(base.Candidate{- Type: base.CandidateTypeFunction,- Text: strings.ToLower(entry) + "()",- })- default:- keywordEntries.Insert(base.Candidate{- Type: base.CandidateTypeKeyword,- Text: entry,- })+func (m CompletionMap) insertAllColumns(c *Completer) {+ if _, exists := c.metadataCache[c.defaultDatabase]; !exists {+ _, metadata, err := c.getMetadata(c.ctx, c.instanceID, c.defaultDatabase)+ if err != nil || metadata == nil {+ return+ }+ c.metadataCache[c.defaultDatabase] = metadata+ }- // Add also synonyms, if there are any.- if synonyms[token] != nil {- for _, synonym := range synonyms[token] {- keywordEntries.Insert(base.Candidate{- Type: base.CandidateTypeKeyword,- Text: synonym,- })+ metadata := c.metadataCache[c.defaultDatabase]+ for _, schema := range metadata.ListSchemaNames() {+ schemaMeta := metadata.GetSchemaMetadata(schema)+ if schemaMeta == nil {+ continue+ }+ for _, table := range schemaMeta.ListTableNames() {+ tableMeta := schemaMeta.GetTable(table)+ if tableMeta == nil {+ continue+ }+ for _, column := range tableMeta.GetProto().GetColumns() {+ definition := fmt.Sprintf("%s | %s", table, column.Type)+ if !column.Nullable {+ definition += ", NOT NULL"}+ m.Insert(base.Candidate{+ Type: base.CandidateTypeColumn,+ Text: c.quotedIdentifierIfNeeded(column.Name),+ Definition: definition,+ Comment: column.Comment,+ })}}}+}++func (m CompletionMap) toSlice() []base.Candidate {+ var result []base.Candidate+ for _, candidate := range m {+ result = append(result, candidate)+ }+ slices.SortFunc(result, func(a, b base.Candidate) int {+ if a.Type != b.Type {+ if a.Type < b.Type {+ return -1+ }+ return 1+ }+ if a.Text < b.Text {+ return -1+ }+ if a.Text > b.Text {+ return 1+ }+ return 0+ })+ return result+}++func (c *Completer) convertCandidates(candidates *mysqlparser.CandidateSet) ([]base.Candidate, error) {+ keywordEntries := make(CompletionMap)+ runtimeFunctionEntries := make(CompletionMap)+ databaseEntries := make(CompletionMap)+ tableEntries := make(CompletionMap)+ columnEntries := make(CompletionMap)+ viewEntries := make(CompletionMap)- for candidate := range candidates.Rules {- c.scanner.PopAndRestore()- c.scanner.Push()+ // Token candidates → keywords.+ for _, tok := range candidates.Tokens {+ if tok > 0 && tok < 256 {+ continue+ }+ name := mysqlparser.TokenName(tok)+ if name == "" {+ continue+ }+ keywordEntries.Insert(base.Candidate{+ Type: base.CandidateTypeKeyword,+ Text: name,+ })+ }- c.fetchCommonTableExpression(candidates.Rules[candidate])+ for _, rc := range candidates.Rules {+ c.fetchCommonTableExpression(candidates.CTEPositions)- switch candidate {- case mysql.MySQLParserRULE_runtimeFunctionCall:+ switch rc.Rule {+ case "func_name":runtimeFunctionEntries.insertFunctions()- case mysql.MySQLParserRULE_schemaRef:- schemaEntries.insertDatabases(c)- case mysql.MySQLParserRULE_tableRefWithWildcard:- // A special form of table references (id.id.*) used only in multi-table delete.- // Handling is similar as for column references (just that we have table/view objects instead of column refs).- schema, _, flags := c.determineSchemaTableQualifier()- if flags&ObjectFlagsShowSchemas != 0 {- schemaEntries.insertDatabases(c)- }+ case "database_ref":+ databaseEntries.insertDatabases(c)+ case "table_ref":+ qualifier, flags := c.determineQualifier()- schemas := make(map[string]bool)- if len(schema) == 0 {- schemas[c.defaultDatabase] = true- // User didn't specify a schema, so we need to append cte tables.- schemas[""] = true- } else {- schemas[schema] = true+ if flags&ObjectFlagsShowFirst != 0 {+ databaseEntries.insertDatabases(c)}- if flags&ObjectFlagsShowTables != 0 {++ if flags&ObjectFlagsShowSecond != 0 {+ schemas := make(map[string]bool)+ if len(qualifier) == 0 {+ schemas[c.defaultDatabase] = true+ schemas[""] = true // CTE tables+ } else {+ schemas[qualifier] = true+ }tableEntries.insertTables(c, schemas)viewEntries.insertViews(c, schemas)}- case mysql.MySQLParserRULE_tableRef, mysql.MySQLParserRULE_filterTableRef:+ case "view_ref":qualifier, flags := c.determineQualifier()-if flags&ObjectFlagsShowFirst != 0 {- schemaEntries.insertDatabases(c)+ databaseEntries.insertDatabases(c)}-if flags&ObjectFlagsShowSecond != 0 {schemas := make(map[string]bool)if len(qualifier) == 0 {schemas[c.defaultDatabase] = true- schemas[""] = true // User didn't specify a schema, so we need to append cte tables.} else {schemas[qualifier] = true}-- tableEntries.insertTables(c, schemas)viewEntries.insertViews(c, schemas)}- case mysql.MySQLParserRULE_tableWild, mysql.MySQLParserRULE_columnRef:- database, table, flags := c.determineSchemaTableQualifier()+ case "index_ref":+ // Indexes are scoped to tables; without table context just suggest tables.+ qualifier, flags := c.determineQualifier()+ if flags&ObjectFlagsShowFirst != 0 {+ databaseEntries.insertDatabases(c)+ }+ if flags&ObjectFlagsShowSecond != 0 {+ schemas := make(map[string]bool)+ if len(qualifier) == 0 {+ schemas[c.defaultDatabase] = true+ } else {+ schemas[qualifier] = true+ }+ tableEntries.insertTables(c, schemas)+ }+ case "columnref":+ schema, table, flags := c.determineColumnRef()+if flags&ObjectFlagsShowSchemas != 0 {- schemaEntries.insertDatabases(c)+ databaseEntries.insertDatabases(c)}- schemas := make(map[string]bool)- if len(database) != 0 {- schemas[database] = true+ databases := make(map[string]bool)+ if len(schema) != 0 {+ databases[schema] = true} else if len(c.references) > 0 {for _, reference := range c.references {if physicalTable, ok := reference.(*base.PhysicalTableReference); ok {- if len(physicalTable.Database) != 0 {- schemas[physicalTable.Database] = true+ if len(physicalTable.Database) > 0 {+ databases[physicalTable.Database] = true}}}}- if len(schemas) == 0 {- schemas[c.defaultDatabase] = true- // User didn't specify a schema, so we need to append cte tables.- schemas[""] = true+ if len(schema) == 0 {+ // Only fall back to default database when references didn't+ // supply any explicit database. Otherwise we'd mix unrelated+ // tables from default db with cross-database queries.+ if len(databases) == 0 {+ databases[c.defaultDatabase] = true+ }+ databases[""] = true // CTE tables}if flags&ObjectFlagsShowTables != 0 {- tableEntries.insertTables(c, schemas)- if candidate == mysql.MySQLParserRULE_columnRef {- viewEntries.insertViews(c, schemas)+ tableEntries.insertTables(c, databases)+ viewEntries.insertViews(c, databases)- for _, reference := range c.references {- switch reference := reference.(type) {- case *base.PhysicalTableReference:- if (len(database) == 0 && len(reference.Database) == 0) || schemas[reference.Database] {- if len(reference.Alias) == 0 {- tableEntries.Insert(base.Candidate{- Type: base.CandidateTypeTable,- Text: c.quotedIdentifierIfNeeded(reference.Table),- })- } else {- tableEntries.Insert(base.Candidate{- Type: base.CandidateTypeTable,- Text: c.quotedIdentifierIfNeeded(reference.Alias),- })- }- }- case *base.VirtualTableReference:- // User specified a database qualifier, so we don't show virtual tables.- if len(database) > 0 {- continue+ for _, reference := range c.references {+ switch reference := reference.(type) {+ case *base.PhysicalTableReference:+ if len(schema) == 0 && len(reference.Database) == 0 || databases[reference.Database] {+ if len(reference.Alias) == 0 {+ tableEntries.Insert(base.Candidate{+ Type: base.CandidateTypeTable,+ Text: c.quotedIdentifierIfNeeded(reference.Table),+ })+ } else {+ tableEntries.Insert(base.Candidate{+ Type: base.CandidateTypeTable,+ Text: c.quotedIdentifierIfNeeded(reference.Alias),+ })}- tableEntries.Insert(base.Candidate{- Type: base.CandidateTypeTable,- Text: c.quotedIdentifierIfNeeded(reference.Table),- })- default:}+ case *base.VirtualTableReference:+ if len(schema) > 0 {+ continue+ }+ tableEntries.Insert(base.Candidate{+ Type: base.CandidateTypeTable,+ Text: c.quotedIdentifierIfNeeded(reference.Table),+ })+ default:}}}if flags&ObjectFlagsShowColumns != 0 {- if database == table { // Schema and table are equal if it's not clear if we see a schema or table qualifier.- schemas[c.defaultDatabase] = true- // User didn't specify a schema, so we need to append cte tables.- schemas[""] = true+ // determineColumnRef returns schema==table when the user typed+ // "table.col" — we don't yet know if 'table' is actually a table+ // or schema, so search both. (Skip when both are empty — that's+ // the unqualified case.)+ if schema != "" && schema == table {+ databases[c.defaultDatabase] = true+ databases[""] = true}tables := make(map[string]bool)@@ -528,13 +529,11 @@ func (c *Completer) convertCandidates(candidates *base.CandidatesCollection) ([]for _, reference := range c.references {switch reference := reference.(type) {case *base.PhysicalTableReference:- // Could be an aliasif strings.EqualFold(reference.Alias, table) {tables[reference.Table] = true- schemas[reference.Database] = true+ databases[reference.Database] = true}case *base.VirtualTableReference:- // Could be a virtual tableif strings.EqualFold(reference.Table, table) {for _, column := range reference.Columns {columnEntries.Insert(base.Candidate{@@ -546,18 +545,20 @@ func (c *Completer) convertCandidates(candidates *base.CandidatesCollection) ([]default:}}- } else if len(c.references) > 0 && candidate == mysql.MySQLParserRULE_columnRef {- list := c.fetchSelectItemAliases(candidates.Rules[candidate])- for _, alias := range list {- columnEntries.Insert(base.Candidate{- Type: base.CandidateTypeColumn,- Text: c.quotedIdentifierIfNeeded(alias),- })+ } else if len(c.references) > 0 {+ if c.isInAliasAllowedContext() {+ list := c.fetchSelectItemAliases(candidates.SelectAliasPositions)+ for _, alias := range list {+ columnEntries.Insert(base.Candidate{+ Type: base.CandidateTypeColumn,+ Text: c.quotedIdentifierIfNeeded(alias),+ })+ }}for _, reference := range c.references {switch reference := reference.(type) {case *base.PhysicalTableReference:- schemas[""] = true+ databases[reference.Database] = truetables[reference.Table] = truecase *base.VirtualTableReference:for _, column := range reference.Columns {@@ -569,58 +570,33 @@ func (c *Completer) convertCandidates(candidates *base.CandidatesCollection) ([]default:}}- } else if candidate == mysql.MySQLParserRULE_columnRef {- // No specified table, return all columns+ } else {columnEntries.insertAllColumns(c)}if len(tables) > 0 {- columnEntries.insertColumns(c, schemas, tables)- }- }-- // TODO: special handling for triggers.-- case mysql.MySQLParserRULE_viewRef:- schema, _, flags := c.determineSchemaTableQualifier()-- if flags&ObjectFlagsShowFirst != 0 {- schemaEntries.insertDatabases(c)- }-- if flags&ObjectFlagsShowSecond != 0 {- schemas := make(map[string]bool)- if len(schema) != 0 {- schemas[schema] = true- } else {- schemas[c.defaultDatabase] = true+ columnEntries.insertColumns(c, databases, tables)}- viewEntries.insertViews(c, schemas)}default:- // Handle other candidates}}- c.scanner.PopAndRestore()var result []base.Candidate- result = append(result, keywordEntries.toSLice()...)- result = append(result, runtimeFunctionEntries.toSLice()...)- result = append(result, schemaEntries.toSLice()...)- result = append(result, tableEntries.toSLice()...)- result = append(result, columnEntries.toSLice()...)- result = append(result, viewEntries.toSLice()...)+ result = append(result, keywordEntries.toSlice()...)+ result = append(result, runtimeFunctionEntries.toSlice()...)+ result = append(result, databaseEntries.toSlice()...)+ result = append(result, tableEntries.toSlice()...)+ result = append(result, viewEntries.toSlice()...)+ result = append(result, columnEntries.toSlice()...)+return result, nil}-func (c *Completer) fetchCommonTableExpression(ruleStack []*base.RuleContext) {+func (c *Completer) fetchCommonTableExpression(ctePositions []int) {c.cteTables = nil- for _, rule := range ruleStack {- if rule.ID == mysql.MySQLParserRULE_queryExpression {- for _, pos := range rule.CTEList {- c.cteTables = append(c.cteTables, c.extractCTETables(pos)...)- }- }+ for _, pos := range ctePositions {+ c.cteTables = append(c.cteTables, c.extractCTETables(pos)...)}}@@ -628,130 +604,156 @@ func (c *Completer) extractCTETables(pos int) []*base.VirtualTableReference {if metadata, exists := c.cteCache[pos]; exists {return metadata}- followingText := c.scanner.GetFollowingTextAfter(pos)+ if pos >= len(c.sql) {+ return nil+ }+ followingText := c.sql[pos:]if len(followingText) == 0 {return nil}- input := antlr.NewInputStream(followingText)- lexer := mysql.NewMySQLLexer(input)- tokens := antlr.NewCommonTokenStream(lexer, 0)- parser := mysql.NewMySQLParser(tokens)-- parser.BuildParseTrees = true- parser.RemoveErrorListeners()- tree := parser.WithClause()-- listener := &CTETableListener{context: c}- antlr.ParseTreeWalkerDefault.Walk(listener, tree)-- c.cteCache[pos] = listener.tables- return listener.tables-}--type CTETableListener struct {- *mysql.BaseMySQLParserListener-- context *Completer- tables []*base.VirtualTableReference-}+ const suffix = " SELECT 1"+ tokens := mysqlparser.Tokenize(followingText)-func (l *CTETableListener) EnterCommonTableExpression(ctx *mysql.CommonTableExpressionContext) {- table := &base.VirtualTableReference{}- if ctx.Identifier() != nil {- table.Table = unquote(ctx.Identifier().GetText())+ var selStmt *ast.SelectStmt+ var wrappedSQL string+ for end := len(tokens); end > 0; end-- {+ if end < len(tokens) {+ lastTok := tokens[end-1]+ wrappedSQL = followingText[:lastTok.End] + suffix+ } else {+ wrappedSQL = followingText + suffix+ }+ parsed, err := ParseMySQLOmni(wrappedSQL)+ if err != nil || parsed == nil || len(parsed.Items) == 0 {+ continue+ }+ sel, ok := parsed.Items[0].(*ast.SelectStmt)+ if ok && len(sel.CTEs) > 0 {+ selStmt = sel+ break+ }}- if ctx.ColumnInternalRefList() != nil {- for _, column := range ctx.ColumnInternalRefList().AllColumnInternalRef() {- table.Columns = append(table.Columns, unquote(column.Identifier().GetText()))+ if selStmt == nil {+ c.cteCache[pos] = nil+ return nil+ }++ var tables []*base.VirtualTableReference+ for _, cte := range selStmt.CTEs {+ table := &base.VirtualTableReference{+ Table: cte.Name,}- } else {- // User didn't specify the column list, so we need to fetch the column list from the database.- if span, err := GetQuerySpan(- l.context.ctx,- base.GetQuerySpanContext{- InstanceID: l.context.instanceID,- GetDatabaseMetadataFunc: l.context.getMetadata,- ListDatabaseNamesFunc: l.context.listDatabaseNames,- },- base.Statement{Text: fmt.Sprintf("SELECT * FROM %s;", ctx.GetParser().GetTokenStream().GetTextFromRuleContext(ctx.Subquery()))},- l.context.defaultDatabase,- "",- false,- ); err == nil && span.NotFoundError == nil {- for _, column := range span.Results {- table.Columns = append(table.Columns, column.Name)+ if len(cte.Columns) > 0 {+ table.Columns = cte.Columns+ } else if cte.Select != nil {+ // Extract query text from wrappedSQL using Loc.+ loc := cte.Select.Loc+ if loc.Start >= 0 && loc.End > loc.Start && loc.End <= len(wrappedSQL) {+ queryText := wrappedSQL[loc.Start:loc.End]+ if span, err := GetQuerySpan(+ c.ctx,+ base.GetQuerySpanContext{+ InstanceID: c.instanceID,+ GetDatabaseMetadataFunc: c.getMetadata,+ ListDatabaseNamesFunc: c.listDatabaseNames,+ },+ base.Statement{Text: queryText},+ c.defaultDatabase,+ "",+ false,+ ); err == nil && span.NotFoundError == nil {+ for _, column := range span.Results {+ table.Columns = append(table.Columns, column.Name)+ }+ }}}+ tables = append(tables, table)}- l.tables = append(l.tables, table)+ c.cteCache[pos] = tables+ return tables}-func (c *Completer) fetchSelectItemAliases(ruleStack []*base.RuleContext) []string {- canUseAliases := false- for i := len(ruleStack) - 1; i >= 0; i-- {- switch ruleStack[i].ID {- case mysql.MySQLParserRULE_queryExpression, mysql.MySQLParserRULE_querySpecification:- if !canUseAliases {- return nil- }- aliasMap := make(map[string]bool)- for pos := range ruleStack[i].SelectItemAliases {- if aliasText := c.extractAliasText(pos); len(aliasText) > 0 {- aliasMap[aliasText] = true- }- }-- var result []string- for alias := range aliasMap {- result = append(result, alias)+func (c *Completer) isInAliasAllowedContext() bool {+ level := 0+ for i := c.caretTokenIndex - 1; i >= 0; i-- {+ switch c.tokens[i].Type {+ case ')':+ level+++ case '(':+ if level > 0 {+ level--+ } else {+ return false}- slices.Sort(result)- return result- case mysql.MySQLParserRULE_orderClause, mysql.MySQLParserRULE_groupByClause, mysql.MySQLParserRULE_havingClause:- canUseAliases = truedefault:- // Other cases+ }+ if level > 0 {+ continue+ }+ switch c.tokens[i].Type {+ case mysqlparser.ORDER, mysqlparser.GROUP, mysqlparser.HAVING:+ return true+ case mysqlparser.WHERE, mysqlparser.ON, mysqlparser.FROM, mysqlparser.SELECT,+ mysqlparser.LIMIT, mysqlparser.FOR:+ return false}}+ return false+}- return nil+func (c *Completer) fetchSelectItemAliases(aliasPositions []int) []string {+ aliasMap := make(map[string]bool)+ for _, pos := range aliasPositions {+ if aliasText := c.extractAliasText(pos); len(aliasText) > 0 {+ aliasMap[aliasText] = true+ }+ }+ var result []string+ for alias := range aliasMap {+ result = append(result, alias)+ }+ slices.Sort(result)+ return result}func (c *Completer) extractAliasText(pos int) string {- followingText := c.scanner.GetFollowingTextAfter(pos)+ if pos >= len(c.sql) {+ return ""+ }+ followingText := c.sql[pos:]if len(followingText) == 0 {return ""}- input := antlr.NewInputStream(followingText)- lexer := mysql.NewMySQLLexer(input)- tokens := antlr.NewCommonTokenStream(lexer, 0)- parser := mysql.NewMySQLParser(tokens)-- parser.BuildParseTrees = true- parser.RemoveErrorListeners()- tree := parser.SelectAlias()-- listener := &SelectAliasListener{}- antlr.ParseTreeWalkerDefault.Walk(listener, tree)-- return listener.result-}--type SelectAliasListener struct {- *mysql.BaseMySQLParserListener-- result string-}--func (l *SelectAliasListener) EnterSelectAlias(ctx *mysql.SelectAliasContext) {- if ctx.Identifier() != nil {- l.result = unquote(ctx.Identifier().GetText())- } else if ctx.TextStringLiteral() != nil {- l.result = unquote(ctx.TextStringLiteral().GetText())+ tokens := mysqlparser.Tokenize(followingText)+ if len(tokens) == 0 {+ return ""+ }+ idx := 0+ if tokens[0].Type == mysqlparser.AS && len(tokens) > 1 {+ idx = 1+ }+ if idx >= len(tokens) {+ return ""+ }+ tok := tokens[idx]+ // Accept identifier tokens (IDENT, backtick-quoted, non-reserved keyword).+ if mysqlparser.IsIdentTokenType(tok.Type) {+ return unquote(tok.Str)+ }+ // Accept string literal aliases (e.g., AS 'eid' or AS "eid"). The omni+ // tokenizer strips the quotes from Str for string literals; detect by+ // checking the raw source text starts with a quote.+ if tok.Loc < len(followingText) {+ ch := followingText[tok.Loc]+ if ch == '\'' || ch == '"' {+ return tok.Str+ }}+ return ""}type ObjectFlags int@@ -764,147 +766,82 @@ const (ObjectFlagsShowSecond)-func (c *Completer) determineSchemaTableQualifier() (schema, table string, flags ObjectFlags) {- position := c.scanner.GetIndex()- if c.scanner.GetTokenChannel() != 0 {- c.scanner.Forward(true /* skipHidden */) // First skip to the next non-hidden token.- }-- tokenType := c.scanner.GetTokenType()- if tokenType != mysql.MySQLLexerDOT_SYMBOL && !c.lexer.IsIdentifier(c.scanner.GetTokenType()) {- // We are at the end of an incomplete identifier spec. Jump back, so that the other tests succeed.- c.scanner.Backward(true /* skipHidden */)- }-- if position > 0 {- if c.lexer.IsIdentifier(c.scanner.GetTokenType()) && c.scanner.GetPreviousTokenType(false /* skipHidden */) == mysql.MySQLLexerDOT_SYMBOL {- c.scanner.Backward(true /* skipHidden */)- }- if c.scanner.IsTokenType(mysql.MySQLLexerDOT_SYMBOL) && c.lexer.IsIdentifier(c.scanner.GetPreviousTokenType(false /* skipHidden */)) {- c.scanner.Backward(true /* skipHidden */)-- if c.scanner.GetPreviousTokenType(false /* skipHidden */) == mysql.MySQLLexerDOT_SYMBOL {- c.scanner.Backward(true /* skipHidden */)- if c.lexer.IsIdentifier(c.scanner.GetPreviousTokenType(false /* skipHidden */)) {- c.scanner.Backward(true /* skipHidden */)- }- }- }+func (c *Completer) determineQualifier() (string, ObjectFlags) {+ idx := c.caretTokenIndex+ if idx < len(c.tokens) && !mysqlparser.IsIdentTokenType(c.tokens[idx].Type) {+ idx--+ } else if idx >= len(c.tokens) {+ idx = len(c.tokens) - 1}- schema = ""- table = ""- temp := ""- if c.lexer.IsIdentifier(c.scanner.GetTokenType()) {- temp = unquote(c.scanner.GetTokenText())- c.scanner.Forward(true /* skipHidden */)+ if idx < 0 {+ return "", ObjectFlagsShowFirst | ObjectFlagsShowSecond}- if !c.scanner.IsTokenType(mysql.MySQLLexerDOT_SYMBOL) || position <= c.scanner.GetIndex() {- return schema, table, ObjectFlagsShowSchemas | ObjectFlagsShowTables | ObjectFlagsShowColumns+ if idx >= 2 && mysqlparser.IsIdentTokenType(c.tokens[idx].Type) &&+ c.tokens[idx-1].Type == '.' &&+ mysqlparser.IsIdentTokenType(c.tokens[idx-2].Type) {+ qualifier := unquote(c.tokens[idx-2].Str)+ return qualifier, ObjectFlagsShowSecond}- c.scanner.Forward(true /* skipHidden */) // skip dot- table = temp- schema = temp- if c.lexer.IsIdentifier(c.scanner.GetTokenType()) {- temp = unquote(c.scanner.GetTokenText())- c.scanner.Forward(true /* skipHidden */)-- if !c.scanner.IsTokenType(mysql.MySQLLexerDOT_SYMBOL) || position <= c.scanner.GetIndex() {- return schema, table, ObjectFlagsShowTables | ObjectFlagsShowColumns- }-- table = temp- return schema, table, ObjectFlagsShowColumns+ if idx >= 1 && c.tokens[idx].Type == '.' &&+ mysqlparser.IsIdentTokenType(c.tokens[idx-1].Type) {+ qualifier := unquote(c.tokens[idx-1].Str)+ return qualifier, ObjectFlagsShowSecond}- return schema, table, ObjectFlagsShowTables | ObjectFlagsShowColumns+ return "", ObjectFlagsShowFirst | ObjectFlagsShowSecond}-func (c *Completer) determineQualifier() (string, ObjectFlags) {- // Five possible positions here:- // - In the first id (including the position directly after the last char).- // - In the space between first id and a dot.- // - On a dot (visually directly before the dot).- // - In space after the dot, that includes the position directly after the dot.- // - In the second id.- // All parts are optional (though not at the same time). The on-dot position is considered the same- // as in first id as it visually belongs to the first id-- position := c.scanner.GetIndex()- if c.scanner.GetTokenChannel() != 0 {- c.scanner.Forward(true /* skipHidden */) // First skip to the next non-hidden token.+func (c *Completer) determineColumnRef() (schema, table string, flags ObjectFlags) {+ idx := c.caretTokenIndex+ if idx < len(c.tokens) {+ tt := c.tokens[idx].Type+ if tt != '.' && !mysqlparser.IsIdentTokenType(tt) {+ idx--+ }+ } else {+ idx = len(c.tokens) - 1}- if !c.scanner.IsTokenType(mysql.MySQLLexerDOT_SYMBOL) && !c.lexer.IsIdentifier(c.scanner.GetTokenType()) {- // We are at the end of an incomplete identifier spec. Jump back, so that the other tests succeed.- c.scanner.Backward(true /* skipHidden */)+ if idx < 0 {+ return "", "", ObjectFlagsShowSchemas | ObjectFlagsShowTables | ObjectFlagsShowColumns}- // Go left until we find something not related to an id or find at most 1 dot.- if position > 0 {- if c.lexer.IsIdentifier(c.scanner.GetTokenType()) && c.scanner.GetPreviousTokenType(false /* skipHidden */) == mysql.MySQLLexerDOT_SYMBOL {- c.scanner.Backward(true /* skipHidden */)- }- if c.scanner.IsTokenType(mysql.MySQLLexerDOT_SYMBOL) && c.lexer.IsIdentifier(c.scanner.GetPreviousTokenType(false /* skipHidden */)) {- c.scanner.Backward(true /* skipHidden */)- }- }+ parts := []string{}+ pos := idx- // The c.scanner is now on the leading identifier or dot (if there's no leading id).- qualifier := ""- temp := ""- if c.lexer.IsIdentifier(c.scanner.GetTokenType()) {- temp = unquote(c.scanner.GetTokenText())- c.scanner.Forward(true /* skipHidden */)+ if pos >= 0 && mysqlparser.IsIdentTokenType(c.tokens[pos].Type) {+ parts = append(parts, unquote(c.tokens[pos].Str))+ pos--}- if !c.scanner.IsTokenType(mysql.MySQLLexerDOT_SYMBOL) || position <= c.scanner.GetIndex() {- return qualifier, ObjectFlagsShowFirst | ObjectFlagsShowSecond+ for pos >= 1 && c.tokens[pos].Type == '.' && mysqlparser.IsIdentTokenType(c.tokens[pos-1].Type) {+ parts = append(parts, unquote(c.tokens[pos-1].Str))+ pos -= 2}- qualifier = temp- return qualifier, ObjectFlagsShowSecond-}--func (c *Completer) collectRemainingTableReferences() {- c.scanner.Push()-- level := 0- for {- found := c.scanner.GetTokenType() == mysql.MySQLLexerFROM_SYMBOL- for !found {- if !c.scanner.Forward(false /* skipHidden */) {- break- }-- switch c.scanner.GetTokenType() {- case mysql.MySQLLexerOPEN_PAR_SYMBOL:- level++- case mysql.MySQLLexerCLOSE_PAR_SYMBOL:- if level > 0 {- level--- }- case mysql.MySQLLexerFROM_SYMBOL:- // Open and close parentheses don't need to match, if we come from within a subquery.- if level == 0 {- found = true- }- default:- // Other tokens, continue scanning- }- }-- if !found {- c.scanner.PopAndRestore()- return // No more FROM clause found.+ if idx >= 0 && c.tokens[idx].Type == '.' {+ switch len(parts) {+ case 0:+ return "", "", ObjectFlagsShowSchemas | ObjectFlagsShowTables | ObjectFlagsShowColumns+ case 1:+ return parts[0], parts[0], ObjectFlagsShowTables | ObjectFlagsShowColumns+ default:+ return parts[1], parts[0], ObjectFlagsShowColumns}+ }- c.parseTableReferences(c.scanner.GetFollowingText())- if c.scanner.GetTokenType() == mysql.MySQLLexerFROM_SYMBOL {- c.scanner.Forward(false /* skipHidden */)- }+ switch len(parts) {+ case 0:+ return "", "", ObjectFlagsShowSchemas | ObjectFlagsShowTables | ObjectFlagsShowColumns+ case 1:+ return "", "", ObjectFlagsShowSchemas | ObjectFlagsShowTables | ObjectFlagsShowColumns+ case 2:+ return parts[1], parts[1], ObjectFlagsShowTables | ObjectFlagsShowColumns+ default:+ return parts[len(parts)-1], parts[len(parts)-2], ObjectFlagsShowColumns}}@@ -914,353 +851,230 @@ func (c *Completer) takeReferencesSnapshot() {}}-func (c *Completer) collectInsertTableReferences(caretIndex int) {- c.scanner.Push()-- c.scanner.SeekIndex(0)+func (c *Completer) collectRemainingTableReferences() {level := 0- for {- found := c.scanner.GetTokenType() == mysql.MySQLLexerINSERT_SYMBOL || c.scanner.GetTokenType() == mysql.MySQLLexerINTO_SYMBOL- for !found {- if !c.scanner.Forward(false /* skipHidden */) || c.scanner.GetIndex() >= caretIndex {- break- }-- switch c.scanner.GetTokenType() {- case mysql.MySQLLexerOPEN_PAR_SYMBOL:- level++- case mysql.MySQLLexerCLOSE_PAR_SYMBOL:- if level == 0 {- c.scanner.PopAndRestore()- return- }-+ for i := c.caretTokenIndex; i < len(c.tokens); i++ {+ switch c.tokens[i].Type {+ case '(':+ level+++ case ')':+ if level > 0 {level--- case mysql.MySQLLexerINSERT_SYMBOL, mysql.MySQLLexerINTO_SYMBOL:- found = true- default:- // Other tokens, continue scanning}- }-- if !found {- c.scanner.PopAndRestore()- return // No more INSERT clause found.- }-- c.parseInsertTableReferences(c.scanner.GetFollowingText())- if c.scanner.GetTokenType() == mysql.MySQLLexerINSERT_SYMBOL || c.scanner.GetTokenType() == mysql.MySQLLexerINTO_SYMBOL {- c.scanner.Forward(false /* skipHidden */)+ case mysqlparser.FROM:+ if level == 0 {+ c.parseTableReferences(c.sql[c.tokens[i].Loc:])+ }+ default:}}}-func (c *Completer) collectLeadingTableReferences(caretIndex int, forTableAlter bool) {- c.scanner.Push()-- if forTableAlter {- // nolint- for c.scanner.Backward(false /* skipHidden */) && c.scanner.GetTokenType() != mysql.MySQLLexerALTER_SYMBOL {- // Skip all tokens until ALTER- }-- if c.scanner.GetTokenType() == mysql.MySQLLexerALTER_SYMBOL {- c.scanner.SkipTokenSequence([]int{mysql.MySQLLexerALTER_SYMBOL, mysql.MySQLLexerTABLE_SYMBOL})-- var reference base.PhysicalTableReference- reference.Table = unquote(c.scanner.GetTokenText())- if c.scanner.Forward(false /* skipHidden */) && c.scanner.IsTokenType(mysql.MySQLLexerDOT_SYMBOL) {- reference.Database = reference.Table- c.scanner.Forward(false /* skipHidden */)- c.scanner.Forward(false /* skipHidden */)- reference.Table = unquote(c.scanner.GetTokenText())- }- c.referencesStack[0] = append(c.referencesStack[0], &reference)- }- } else {- c.scanner.SeekIndex(0)-- level := 0- for {- found := c.scanner.GetTokenType() == mysql.MySQLLexerFROM_SYMBOL- for !found {- if !c.scanner.Forward(false /* skipHidden */) || c.scanner.GetIndex() >= caretIndex {- break- }-- switch c.scanner.GetTokenType() {- case mysql.MySQLLexerOPEN_PAR_SYMBOL:- level++- c.referencesStack = append([][]base.TableReference{{}}, c.referencesStack...)- case mysql.MySQLLexerCLOSE_PAR_SYMBOL:- if level == 0 {- c.scanner.PopAndRestore()- return // We cannot go above the initial nesting level.- }-- level--- c.referencesStack = c.referencesStack[1:]- case mysql.MySQLLexerFROM_SYMBOL:- found = true- default:- // Other tokens, continue scanning- }- }-- if !found {- c.scanner.PopAndRestore()- return // No more FROM clause found.+func (c *Completer) collectLeadingTableReferences(caretIndex int) {+ level := 0+ for i := 0; i < len(c.tokens) && i < caretIndex; i++ {+ switch c.tokens[i].Type {+ case '(':+ level+++ c.referencesStack = append([][]base.TableReference{{}}, c.referencesStack...)+ case ')':+ if level == 0 {+ return}-- c.parseTableReferences(c.scanner.GetFollowingText())- if c.scanner.GetTokenType() == mysql.MySQLLexerFROM_SYMBOL {- c.scanner.Forward(false /* skipHidden */)+ level--+ c.referencesStack = c.referencesStack[1:]+ case mysqlparser.FROM:+ c.parseTableReferences(c.sql[c.tokens[i].Loc:])+ case mysqlparser.INSERT, mysqlparser.INTO:+ c.parseInsertTableReferences(c.sql[c.tokens[i].Loc:])+ default:+ // ALTER TABLE / TRUNCATE TABLE / DROP TABLE / UPDATE / DELETE FROM+ // — bind the target table for column completion in DDL/DML contexts.+ if name := mysqlparser.TokenName(c.tokens[i].Type); name == "ALTER" || name == "TRUNCATE" {+ c.parseDDLTableReference(i)}}}}-func (c *Completer) parseInsertTableReferences(text string) {- input := antlr.NewInputStream(text)- lexer := mysql.NewMySQLLexer(input)- tokens := antlr.NewCommonTokenStream(lexer, 0)- parser := mysql.NewMySQLParser(tokens)-- parser.BuildParseTrees = true- parser.RemoveErrorListeners()- tree := parser.InsertStatement()-- listener := &insertTableRefListener{- context: c,+// parseDDLTableReference extracts the target table from a DDL statement+// like "ALTER TABLE t1 ..." or "TRUNCATE TABLE t1".+func (c *Completer) parseDDLTableReference(startIdx int) {+ // Skip the ALTER/TRUNCATE keyword.+ idx := startIdx + 1+ // Skip optional TABLE keyword.+ if idx < len(c.tokens) && mysqlparser.TokenName(c.tokens[idx].Type) == "TABLE" {+ idx+++ }+ // Expect the table name (identifier).+ if idx >= len(c.tokens) || !mysqlparser.IsIdentTokenType(c.tokens[idx].Type) {+ return}- antlr.ParseTreeWalkerDefault.Walk(listener, tree)-}--type insertTableRefListener struct {- *mysql.BaseMySQLParserListener-- context *Completer-}--func (l *insertTableRefListener) EnterInsertStatement(ctx *mysql.InsertStatementContext) {- if ctx.TableRef() != nil {- reference := &base.PhysicalTableReference{}- if ctx.TableRef().QualifiedIdentifier() != nil {- reference.Table = unquote(ctx.TableRef().QualifiedIdentifier().Identifier().GetText())- if ctx.TableRef().QualifiedIdentifier().DotIdentifier() != nil {- reference.Database = reference.Table- reference.Table = unquote(ctx.TableRef().QualifiedIdentifier().DotIdentifier().Identifier().GetText())- }- } else {- reference.Table = unquote(ctx.TableRef().DotIdentifier().Identifier().GetText())- }- l.context.referencesStack[0] = append(l.context.referencesStack[0], reference)+ ref := &base.PhysicalTableReference{}+ ref.Table = unquote(c.tokens[idx].Str)+ idx+++ // Check for db.table pattern.+ if idx+1 < len(c.tokens) && c.tokens[idx].Type == '.' && mysqlparser.IsIdentTokenType(c.tokens[idx+1].Type) {+ ref.Database = ref.Table+ ref.Table = unquote(c.tokens[idx+1].Str)}+ if ref.Database == "" {+ ref.Database = c.defaultDatabase+ }+ c.referencesStack[0] = append(c.referencesStack[0], ref)}func (c *Completer) parseTableReferences(fromClause string) {- // We use a local parser just for the FROM clause to avoid messing up tokens on the autocompletion- // parser (which would affect the processing of the found candidates)- input := antlr.NewInputStream(fromClause)- lexer := mysql.NewMySQLLexer(input)- tokens := antlr.NewCommonTokenStream(lexer, 0)- parser := mysql.NewMySQLParser(tokens)-- parser.BuildParseTrees = true- parser.RemoveErrorListeners()- tree := parser.FromClause()-- listener := &TableRefListener{- context: c,- fromClauseMode: true,- }- antlr.ParseTreeWalkerDefault.Walk(listener, tree)-}--type TableRefListener struct {- *mysql.BaseMySQLParserListener-- context *Completer- fromClauseMode bool- done bool- level int-}--func (l *TableRefListener) ExitTableRef(ctx *mysql.TableRefContext) {- if l.done {- return- }-- if !l.fromClauseMode || l.level == 0 {- reference := &base.PhysicalTableReference{}- if ctx.QualifiedIdentifier() != nil {- reference.Table = unquote(ctx.QualifiedIdentifier().Identifier().GetText())- if ctx.QualifiedIdentifier().DotIdentifier() != nil {- reference.Database = reference.Table- reference.Table = unquote(ctx.QualifiedIdentifier().DotIdentifier().Identifier().GetText())- }+ const prefix = "SELECT * "+ tokens := mysqlparser.Tokenize(fromClause)++ var selStmt *ast.SelectStmt+ var wrappedSQL string+ for end := len(tokens); end > 0; end-- {+ if end < len(tokens) {+ lastTok := tokens[end-1]+ wrappedSQL = prefix + fromClause[:lastTok.End]} else {- reference.Table = unquote(ctx.DotIdentifier().Identifier().GetText())+ wrappedSQL = prefix + fromClause+ }+ parsed, err := ParseMySQLOmni(wrappedSQL)+ if err != nil || parsed == nil || len(parsed.Items) == 0 {+ continue+ }+ sel, ok := parsed.Items[0].(*ast.SelectStmt)+ if ok && len(sel.From) > 0 {+ selStmt = sel+ break}- l.context.referencesStack[0] = append(l.context.referencesStack[0], reference)}-}--func (l *TableRefListener) ExitTableAlias(ctx *mysql.TableAliasContext) {- if l.done {+ if selStmt == nil {return}- if l.level == 0 && len(l.context.referencesStack) != 0 && len(l.context.referencesStack[0]) != 0 {- // Appears after a single or derived table.-- if _, ok := ctx.GetParent().(*mysql.DerivedTableContext); ok {- // We are no need to set the alias for the derived table.- // We handle the derived table in the EnterDerivedTable() methods.- return- }-- // We are in the single table.- if physicalTable, ok := l.context.referencesStack[0][len(l.context.referencesStack[0])-1].(*base.PhysicalTableReference); ok {- physicalTable.Alias = unquote(ctx.Identifier().GetText())- }+ for _, item := range selStmt.From {+ c.extractFromItem(item, wrappedSQL)}}-func (l *TableRefListener) EnterDerivedTable(ctx *mysql.DerivedTableContext) {- if l.done {- return- }-- if l.level == 0 && len(l.context.referencesStack) > 0 && ctx.TableAlias() != nil {- reference := &base.VirtualTableReference{- Table: unquote(ctx.TableAlias().Identifier().GetText()),- }+func (c *Completer) parseInsertTableReferences(insertClause string) {+ tokens := mysqlparser.Tokenize(insertClause)+ idx := 0- if ctx.ColumnInternalRefList() != nil {- for _, column := range ctx.ColumnInternalRefList().AllColumnInternalRef() {- reference.Columns = append(reference.Columns, unquote(column.Identifier().GetText()))- }- } else {- // User didn't specify the column list, so we should extract the column list from the select statement.- if span, err := GetQuerySpan(- l.context.ctx,- base.GetQuerySpanContext{- InstanceID: l.context.instanceID,- GetDatabaseMetadataFunc: l.context.getMetadata,- ListDatabaseNamesFunc: l.context.listDatabaseNames,- },- base.Statement{Text: fmt.Sprintf("SELECT * FROM %s;", ctx.GetParser().GetTokenStream().GetTextFromRuleContext(ctx.Subquery()))},- l.context.defaultDatabase,- "",- false,- ); err == nil && span.NotFoundError == nil {- for _, column := range span.Results {- reference.Columns = append(reference.Columns, column.Name)- }- }+ // Skip INSERT or REPLACE keyword.+ if idx < len(tokens) && (tokens[idx].Type == mysqlparser.INSERT || tokens[idx].Type == mysqlparser.REPLACE) {+ idx+++ }+ // Skip optional INSERT modifiers: LOW_PRIORITY, DELAYED, HIGH_PRIORITY, IGNORE.+ for idx < len(tokens) {+ name := mysqlparser.TokenName(tokens[idx].Type)+ if name == "LOW_PRIORITY" || name == "DELAYED" || name == "HIGH_PRIORITY" || name == "IGNORE" {+ idx+++ continue}-- l.context.referencesStack[0] = append(l.context.referencesStack[0], reference)+ break}-}--func (l *TableRefListener) EnterSubquery(_ *mysql.SubqueryContext) {- if l.done {+ // Skip optional INTO keyword.+ if idx < len(tokens) && tokens[idx].Type == mysqlparser.INTO {+ idx+++ }+ if idx >= len(tokens) || !mysqlparser.IsIdentTokenType(tokens[idx].Type) {return}- if l.fromClauseMode {- l.level++- } else {- l.context.referencesStack = append([][]base.TableReference{{}}, l.context.referencesStack...)- }-}+ ref := &base.PhysicalTableReference{}+ ref.Table = unquote(tokens[idx].Str)+ idx++-func (l *TableRefListener) ExitSubquery(_ *mysql.SubqueryContext) {- if l.done {- return+ if idx+1 < len(tokens) && tokens[idx].Type == '.' && mysqlparser.IsIdentTokenType(tokens[idx+1].Type) {+ ref.Database = ref.Table+ ref.Table = unquote(tokens[idx+1].Str)}- if l.fromClauseMode {- l.level--- } else {- l.context.referencesStack = l.context.referencesStack[1:]+ if ref.Database == "" {+ ref.Database = c.defaultDatabase}+ c.referencesStack[0] = append(c.referencesStack[0], ref)}-func prepareParserAndScanner(statement string, caretLine int, caretOffset int) (*mysql.MySQLParser, *mysql.MySQLLexer, *base.Scanner) {- statement, caretLine, caretOffset = skipHeadingSQLs(statement, caretLine, caretOffset)- input := antlr.NewInputStream(statement)- lexer := mysql.NewMySQLLexer(input)- stream := antlr.NewCommonTokenStream(lexer, antlr.TokenDefaultChannel)- parser := mysql.NewMySQLParser(stream)- parser.RemoveErrorListeners()- lexer.RemoveErrorListeners()- scanner := base.NewScanner(stream, true /* fillInput */)- scanner.SeekPosition(caretLine, caretOffset)- scanner.Push()- return parser, lexer, scanner-}+func (c *Completer) extractFromItem(item ast.TableExpr, wrappedSQL string) {+ switch v := item.(type) {+ case *ast.TableRef:+ ref := &base.PhysicalTableReference{+ Database: v.Schema,+ Table: v.Name,+ Alias: v.Alias,+ }+ if ref.Database == "" {+ ref.Database = c.defaultDatabase+ }+ c.referencesStack[0] = append(c.referencesStack[0], ref)-func prepareTrickyParserAndScanner(statement string, caretLine int, caretOffset int) (*mysql.MySQLParser, *mysql.MySQLLexer, *base.Scanner) {- statement, caretLine, caretOffset = skipHeadingSQLs(statement, caretLine, caretOffset)- statement, caretLine, caretOffset = skipHeadingSQLWithoutSemicolon(statement, caretLine, caretOffset)- input := antlr.NewInputStream(statement)- lexer := mysql.NewMySQLLexer(input)- stream := antlr.NewCommonTokenStream(lexer, antlr.TokenDefaultChannel)- parser := mysql.NewMySQLParser(stream)- parser.RemoveErrorListeners()- lexer.RemoveErrorListeners()- scanner := base.NewScanner(stream, true /* fillInput */)- scanner.SeekPosition(caretLine, caretOffset)- scanner.Push()- return parser, lexer, scanner-}+ case *ast.JoinClause:+ if v.Left != nil {+ c.extractFromItem(v.Left, wrappedSQL)+ }+ if v.Right != nil {+ c.extractFromItem(v.Right, wrappedSQL)+ }-func notEmptySQLCount(list []base.Statement) int {- count := 0- for _, sql := range list {- if !sql.Empty {- count+++ case *ast.SubqueryExpr:+ if v.Alias == "" {+ return+ }+ virtualRef := &base.VirtualTableReference{+ Table: v.Alias,+ }+ if len(v.Columns) > 0 {+ virtualRef.Columns = v.Columns+ } else if v.Select != nil {+ loc := v.Select.Loc+ if loc.Start >= 0 && loc.End > loc.Start && loc.End <= len(wrappedSQL) {+ subqueryText := wrappedSQL[loc.Start:loc.End]+ if span, err := GetQuerySpan(+ c.ctx,+ base.GetQuerySpanContext{+ InstanceID: c.instanceID,+ GetDatabaseMetadataFunc: c.getMetadata,+ ListDatabaseNamesFunc: c.listDatabaseNames,+ },+ base.Statement{Text: fmt.Sprintf("SELECT * FROM (%s) AS %s;", subqueryText, v.Alias)},+ c.defaultDatabase,+ "",+ false,+ ); err == nil && span.NotFoundError == nil {+ for _, column := range span.Results {+ virtualRef.Columns = append(virtualRef.Columns, column.Name)+ }+ }+ }}+ c.referencesStack[0] = append(c.referencesStack[0], virtualRef)++ default:}- return count}// caretLine is 1-based and caretOffset is 0-based.func skipHeadingSQLs(statement string, caretLine int, caretOffset int) (string, int, int) {newCaretLine, newCaretOffset := caretLine, caretOffsetlist, err := SplitSQL(statement)- if err != nil || notEmptySQLCount(list) <= 1 {+ if err != nil || len(base.FilterEmptyStatements(list)) <= 1 {return statement, caretLine, caretOffset}start := 0for i, sql := range list {- // Both caretLine and End.Line are 1-based- // End.Column is 1-based exclusive (points after the last character)- // caretOffset is 0-basedsqlEndLine := int(sql.End.GetLine())sqlEndColumn := int(sql.End.GetColumn())- // Use > for End.Column comparison because it's exclusive (points after last char)- // A 0-based offset of N corresponds to 1-based position N+1- // Exclusive End.Column of N means last char is at 1-based position N-1 (0-based N-2)- // So caret is in this statement if: sqlEndColumn > caretOffset+1, i.e., sqlEndColumn > caretOffsetif sqlEndLine > caretLine || (sqlEndLine == caretLine && sqlEndColumn > caretOffset) {start = iif i == 0 {- // The caret is in the first SQL statement, so we don't need to skip any SQL statements.break}previousSQLEndLine := int(list[i-1].End.GetLine())previousSQLEndColumn := int(list[i-1].End.GetColumn())newCaretLine = caretLine - previousSQLEndLine + 1if caretLine == previousSQLEndLine {- // The caret is in the same line as the last line of the previous SQL statement.- // We need to adjust the caret offset.- // previousSQLEndColumn is 1-based exclusive, caretOffset is 0-based- // New offset = caretOffset - (previousSQLEndColumn - 1) = caretOffset - previousSQLEndColumn + 1newCaretOffset = caretOffset - previousSQLEndColumn + 1}break@@ -1279,219 +1093,59 @@ func skipHeadingSQLs(statement string, caretLine int, caretOffset int) (string,// caretLine is 1-based and caretOffset is 0-based.func skipHeadingSQLWithoutSemicolon(statement string, caretLine int, caretOffset int) (string, int, int) {- input := antlr.NewInputStream(statement)- lexer := mysql.NewMySQLLexer(input)- stream := antlr.NewCommonTokenStream(lexer, antlr.TokenDefaultChannel)- lexer.RemoveErrorListeners()- lexerErrorListener := &base.ParseErrorListener{- Statement: statement,- }- lexer.AddErrorListener(lexerErrorListener)-- stream.Fill()- tokens := stream.GetAllTokens()- latestSelect := 0+ tokens := mysqlparser.Tokenize(statement)+ caretByteOff := lineColumnToByteOffset(statement, caretLine, caretOffset)++ latestSelectOffset := -1newCaretLine, newCaretOffset := caretLine, caretOffset- for _, token := range tokens {- if token.GetLine() > caretLine || (token.GetLine() == caretLine && token.GetColumn() >= caretOffset) {++ for _, tok := range tokens {+ if tok.Loc >= caretByteOff {break}- if token.GetTokenType() == mysql.MySQLLexerSELECT_SYMBOL && token.GetColumn() == 0 {- latestSelect = token.GetTokenIndex()- newCaretLine = caretLine - token.GetLine() + 1 // convert to 1-based.- newCaretOffset = caretOffset+ if tok.Type == mysqlparser.SELECT {+ atColumn0 := tok.Loc == 0 || statement[tok.Loc-1] == '\n'+ if atColumn0 {+ latestSelectOffset = tok.Loc+ line := 1+ for j := 0; j < tok.Loc; j++ {+ if statement[j] == '\n' {+ line+++ }+ }+ newCaretLine = caretLine - line + 1+ newCaretOffset = caretOffset+ }}}- if latestSelect == 0 {+ if latestSelectOffset < 0 {return statement, caretLine, caretOffset}- return stream.GetTextFromInterval(antlr.NewInterval(latestSelect, stream.Size())), newCaretLine, newCaretOffset++ return statement[latestSelectOffset:], newCaretLine, newCaretOffset}func unquote(s string) string {if len(s) < 2 {return s}-if (s[0] == '`' || s[0] == '\'' || s[0] == '"') && s[0] == s[len(s)-1] {return s[1 : len(s)-1]}return s}-type CompletionMap map[string]base.Candidate--func (m CompletionMap) toSLice() []base.Candidate {- var result []base.Candidate- for _, candidate := range m {- result = append(result, candidate)- }- slices.SortFunc(result, func(i, j base.Candidate) int {- if i.Type != j.Type {- if i.Type < j.Type {- return -1- }- return 1- }- if i.Text < j.Text {- return -1- }- if i.Text > j.Text {- return 1- }- return 0- })- return result-}--func (m CompletionMap) Insert(entry base.Candidate) {- m[entry.String()] = entry-}--func (m CompletionMap) insertFunctions() {- for _, function := range mysql.GetBuiltinFunctions() {- m.Insert(base.Candidate{- Type: base.CandidateTypeFunction,- Text: function + "()",- })- }-}--func (m CompletionMap) insertDatabases(c *Completer) {- for _, database := range c.listAllDatabases() {- m.Insert(base.Candidate{- Type: base.CandidateTypeDatabase,- Text: database,- })- }-}--func (m CompletionMap) insertTables(c *Completer, schemas map[string]bool) {- for schema := range schemas {- if len(schema) == 0 {- // User didn't specify a schema, so we need to append cte tables.- for _, table := range c.cteTables {- m.Insert(base.Candidate{- Type: base.CandidateTypeTable,- Text: c.quotedIdentifierIfNeeded(table.Table),- })- }- continue- }- for _, table := range c.listTables(schema) {- m.Insert(base.Candidate{- Type: base.CandidateTypeTable,- Text: c.quotedIdentifierIfNeeded(table),- })- }- }-}--func (m CompletionMap) insertViews(c *Completer, schemas map[string]bool) {- for schema := range schemas {- for _, view := range c.listViews(schema) {- m.Insert(base.Candidate{- Type: base.CandidateTypeView,- Text: c.quotedIdentifierIfNeeded(view),- })- }- }-}--func (m CompletionMap) insertColumns(c *Completer, databases, tables map[string]bool) {- for database := range databases {- if len(database) == 0 {- // User didn't specify a schema, so we need to append cte tables.- for _, table := range c.cteTables {- if tables[table.Table] {- for _, column := range table.Columns {- m.Insert(base.Candidate{- Type: base.CandidateTypeColumn,- Text: c.quotedIdentifierIfNeeded(column),- })- }- }- }- continue- }- if _, exists := c.metadataCache[database]; !exists {- _, metadata, err := c.getMetadata(c.ctx, c.instanceID, database)- if err != nil || metadata == nil {- continue- }- c.metadataCache[database] = metadata- }-- for table := range tables {- tableMeta := c.metadataCache[database].GetSchemaMetadata("").GetTable(table)- if tableMeta == nil {- continue- }- for _, column := range tableMeta.GetProto().GetColumns() {- definition := fmt.Sprintf("%s | %s", table, column.Type)- if !column.Nullable {- definition += ", NOT NULL"- }- m.Insert(base.Candidate{- Type: base.CandidateTypeColumn,- Text: c.quotedIdentifierIfNeeded(column.Name),- Definition: definition,- Comment: column.Comment,- })- }- }- }-}--func (m CompletionMap) insertAllColumns(c *Completer) {- if _, exists := c.metadataCache[c.defaultDatabase]; !exists {- _, metadata, err := c.getMetadata(c.ctx, c.instanceID, c.defaultDatabase)- if err != nil || metadata == nil {- return- }- c.metadataCache[c.defaultDatabase] = metadata- }-- metadata := c.metadataCache[c.defaultDatabase]- for _, schema := range metadata.ListSchemaNames() {- schemaMeta := metadata.GetSchemaMetadata(schema)- if schemaMeta == nil {- continue- }- for _, table := range schemaMeta.ListTableNames() {- tableMeta := schemaMeta.GetTable(table)- if tableMeta == nil {- continue- }- for _, column := range tableMeta.GetProto().GetColumns() {- definition := fmt.Sprintf("%s | %s", table, column.Type)- if !column.Nullable {- definition += ", NOT NULL"- }- m.Insert(base.Candidate{- Type: base.CandidateTypeColumn,- Text: c.quotedIdentifierIfNeeded(column.Name),- Definition: definition,- Comment: column.Comment,- })- }- }- }-}-func (c *Completer) listAllDatabases() []string {var result []stringif c.defaultDatabase != "" {result = append(result, c.defaultDatabase)}-for databaseName := range c.metadataCache {if databaseName != c.defaultDatabase {result = append(result, databaseName)}}-return result}@@ -1503,7 +1157,6 @@ func (c *Completer) listTables(database string) []string {}c.metadataCache[database] = metadata}-return c.metadataCache[database].GetSchemaMetadata("").ListTableNames()}@@ -1515,7 +1168,6 @@ func (c *Completer) listViews(database string) []string {}c.metadataCache[database] = metadata}-return c.metadataCache[database].GetSchemaMetadata("").ListViewNames()}@@ -1523,18 +1175,76 @@ func (c *Completer) quotedIdentifierIfNeeded(s string) string {if c.caretTokenIsQuoted {return s}- if c.lexer.IsReservedKeyword(strings.ToUpper(s)) {- return fmt.Sprintf("`%s`", s)- }- for _, r := range s {- if !unicode.IsLetter(r) && !unicode.IsDigit(r) && r != '_' && r != '$' {+ if mysqlparser.IsIdentTokenType(mysqlparser.Tokenize(strings.ToUpper(s))[0].Type) {+ // It's an identifier or non-reserved keyword, check if it needs quoting.+ for _, r := range s {+ if !unicode.IsLetter(r) && !unicode.IsDigit(r) && r != '_' && r != '$' {+ return fmt.Sprintf("`%s`", s)+ }+ }+ if len(s) > 0 && unicode.IsDigit(rune(s[0])) {return fmt.Sprintf("`%s`", s)}+ return s}+ // It's a reserved keyword, quote it.+ return fmt.Sprintf("`%s`", s)+}- if len(s) > 0 && unicode.IsDigit(rune(s[0])) {- return fmt.Sprintf("`%s`", s)+// getMySQLBuiltinFunctions returns a list of MySQL builtin function names.+func getMySQLBuiltinFunctions() []string {+ return []string{+ "ABS", "ACOS", "ADDDATE", "ADDTIME", "AES_DECRYPT", "AES_ENCRYPT",+ "ASCII", "ASIN", "ATAN", "ATAN2", "AVG",+ "BENCHMARK", "BIN", "BIT_AND", "BIT_COUNT", "BIT_LENGTH", "BIT_OR", "BIT_XOR",+ "CAST", "CEIL", "CEILING", "CHAR", "CHAR_LENGTH", "CHARACTER_LENGTH",+ "COALESCE", "COERCIBILITY", "COLLATION", "COMPRESS", "CONCAT", "CONCAT_WS",+ "CONNECTION_ID", "CONV", "CONVERT", "CONVERT_TZ", "COS", "COT", "COUNT",+ "CRC32", "CURDATE", "CURRENT_DATE", "CURRENT_TIME", "CURRENT_TIMESTAMP",+ "CURRENT_USER", "CURTIME",+ "DATABASE", "DATE", "DATE_ADD", "DATE_FORMAT", "DATE_SUB", "DATEDIFF",+ "DAY", "DAYNAME", "DAYOFMONTH", "DAYOFWEEK", "DAYOFYEAR", "DECODE",+ "DEFAULT", "DEGREES", "DES_DECRYPT", "DES_ENCRYPT",+ "ELT", "ENCODE", "ENCRYPT", "EXP", "EXPORT_SET", "EXTRACT",+ "FIELD", "FIND_IN_SET", "FLOOR", "FORMAT", "FOUND_ROWS", "FROM_BASE64",+ "FROM_DAYS", "FROM_UNIXTIME",+ "GET_FORMAT", "GET_LOCK", "GREATEST", "GROUP_CONCAT",+ "HEX", "HOUR",+ "IF", "IFNULL", "IN", "INET_ATON", "INET_NTOA", "INET6_ATON", "INET6_NTOA",+ "INSERT", "INSTR", "IS_FREE_LOCK", "IS_IPV4", "IS_IPV4_COMPAT",+ "IS_IPV4_MAPPED", "IS_IPV6", "IS_USED_LOCK", "ISNULL",+ "JSON_ARRAY", "JSON_ARRAYAGG", "JSON_CONTAINS", "JSON_CONTAINS_PATH",+ "JSON_DEPTH", "JSON_EXTRACT", "JSON_INSERT", "JSON_KEYS", "JSON_LENGTH",+ "JSON_MERGE", "JSON_MERGE_PATCH", "JSON_MERGE_PRESERVE", "JSON_OBJECT",+ "JSON_OBJECTAGG", "JSON_OVERLAPS", "JSON_PRETTY", "JSON_QUOTE",+ "JSON_REMOVE", "JSON_REPLACE", "JSON_SCHEMA_VALID", "JSON_SEARCH",+ "JSON_SET", "JSON_STORAGE_FREE", "JSON_STORAGE_SIZE", "JSON_TABLE",+ "JSON_TYPE", "JSON_UNQUOTE", "JSON_VALID", "JSON_VALUE",+ "LAST_DAY", "LAST_INSERT_ID", "LCASE", "LEAST", "LEFT", "LENGTH",+ "LN", "LOAD_FILE", "LOCALTIME", "LOCALTIMESTAMP", "LOCATE", "LOG",+ "LOG10", "LOG2", "LOWER", "LPAD", "LTRIM",+ "MAKE_SET", "MAKEDATE", "MAKETIME", "MAX", "MD5", "MICROSECOND",+ "MID", "MIN", "MINUTE", "MOD", "MONTH", "MONTHNAME",+ "NOW", "NULLIF",+ "OCT", "OCTET_LENGTH", "ORD",+ "PASSWORD", "PERIOD_ADD", "PERIOD_DIFF", "PI", "POW", "POWER",+ "QUARTER",+ "RADIANS", "RAND", "RANDOM_BYTES", "REGEXP_INSTR", "REGEXP_LIKE",+ "REGEXP_REPLACE", "REGEXP_SUBSTR", "RELEASE_ALL_LOCKS", "RELEASE_LOCK",+ "REPEAT", "REPLACE", "REVERSE", "RIGHT", "ROUND", "ROW_COUNT", "RPAD", "RTRIM",+ "SCHEMA", "SEC_TO_TIME", "SECOND", "SESSION_USER", "SHA1", "SHA2",+ "SIGN", "SIN", "SLEEP", "SOUNDEX", "SPACE", "SQRT",+ "STD", "STDDEV", "STDDEV_POP", "STDDEV_SAMP",+ "STR_TO_DATE", "STRCMP", "SUBDATE", "SUBSTR", "SUBSTRING",+ "SUBSTRING_INDEX", "SUM", "SYSDATE", "SYSTEM_USER",+ "TAN", "TIME", "TIME_FORMAT", "TIME_TO_SEC", "TIMEDIFF", "TIMESTAMP",+ "TIMESTAMPADD", "TIMESTAMPDIFF", "TO_BASE64", "TO_DAYS", "TO_SECONDS",+ "TRIM", "TRUNCATE",+ "UCASE", "UNCOMPRESS", "UNCOMPRESSED_LENGTH", "UNHEX",+ "UNIX_TIMESTAMP", "UPPER", "USER", "UTC_DATE", "UTC_TIME", "UTC_TIMESTAMP",+ "UUID", "UUID_SHORT", "UUID_TO_BIN",+ "VALUES", "VAR_POP", "VAR_SAMP", "VARIANCE", "VERSION",+ "WEEK", "WEEKDAY", "WEEKOFYEAR", "WEIGHT_STRING",+ "YEAR", "YEARWEEK",}-- return s}diff --git a/backend/plugin/parser/mysql/completion_test.go b/backend/plugin/parser/mysql/completion_test.goindex 6c21b51d80..8965a02bbd 100644--- a/backend/plugin/parser/mysql/completion_test.go+++ b/backend/plugin/parser/mysql/completion_test.go@@ -40,13 +40,13 @@ func TestCompletion(t *testing.T) {a.NoError(yaml.Unmarshal(byteValue, &tests))for i, t := range tests {- text, caretOffset := catchCaret(t.Input)+ text, caretLine, caretCol := catchCaretLineColumn(t.Input)result, err := base.Completion(context.Background(), storepb.Engine_MYSQL, base.CompletionContext{Scene: base.SceneTypeAll,DefaultDatabase: "db",Metadata: getMetadataForTest,ListDatabaseNames: listDatabaseNamesForTest,- }, text, 1, caretOffset)+ }, text, caretLine, caretCol)a.NoError(err)var filteredResult []base.Candidatefor _, r := range result {@@ -142,11 +142,24 @@ func getMetadataForTest(_ context.Context, _, databaseName string) (string, *mod}, nil, nil, storepb.Engine_MYSQL, true /* isObjectCaseSensitive */), nil}-func catchCaret(s string) (string, int) {+// catchCaretLineColumn returns the SQL without the caret marker and the+// 1-based line + 0-based column of the caret position. Handles multiline input.+func catchCaretLineColumn(s string) (string, int, int) {for i, c := range s {if c == '|' {- return s[:i] + s[i+1:], i+ text := s[:i] + s[i+1:]+ line := 1+ col := 0+ for _, ch := range s[:i] {+ if ch == '\n' {+ line+++ col = 0+ } else {+ col+++ }+ }+ return text, line, col}}- return s, -1+ return s, 1, -1}diff --git a/backend/plugin/parser/mysql/test-data/test_completion.yaml b/backend/plugin/parser/mysql/test-data/test_completion.yamlindex 7a888976d2..1a956c48f0 100644--- a/backend/plugin/parser/mysql/test-data/test_completion.yaml+++ b/backend/plugin/parser/mysql/test-data/test_completion.yaml@@ -6,323 +6,5248 @@type: DATABASEdefinition: ""comment: ""+ priority: 0- text: t1type: TABLEdefinition: ""comment: ""+ priority: 0- text: t2type: TABLEdefinition: ""comment: ""+ priority: 0- text: v1type: VIEWdefinition: ""comment: ""+ priority: 0- input: INSERT INTO t1(|);want:- text: c1type: COLUMNdefinition: t1 | , NOT NULLcomment: ""+ priority: 0- text: dbtype: DATABASEdefinition: ""comment: ""+ priority: 0- text: t1type: TABLEdefinition: ""comment: ""+ priority: 0- text: t2type: TABLEdefinition: ""comment: ""+ priority: 0- text: v1type: VIEWdefinition: ""comment: ""+ priority: 0- input: INSERT INTO t2(c1, |);want:- text: c1type: COLUMNdefinition: t2 | , NOT NULLcomment: ""+ priority: 0- text: c2type: COLUMNdefinition: t2 | , NOT NULLcomment: ""+ priority: 0- text: dbtype: DATABASEdefinition: ""comment: ""+ priority: 0- text: t1type: TABLEdefinition: ""comment: ""+ priority: 0- text: t2type: TABLEdefinition: ""comment: ""+ priority: 0- text: v1type: VIEWdefinition: ""comment: ""+ priority: 0- input: WITH x(x1, x2) AS (SELECT * FROM t2) SELECT x.| FROM x;want:- text: x1type: COLUMNdefinition: ""comment: ""+ priority: 0- text: x2type: COLUMNdefinition: ""comment: ""+ priority: 0- input: WITH x(x1, x2) AS (SELECT * FROM t2) SELECT | FROM xwant:- text: x1type: COLUMNdefinition: ""comment: ""+ priority: 0- text: x2type: COLUMNdefinition: ""comment: ""+ priority: 0- text: dbtype: DATABASEdefinition: ""comment: ""+ priority: 0- text: t1type: TABLEdefinition: ""comment: ""+ priority: 0- text: t2type: TABLEdefinition: ""comment: ""+ priority: 0- text: xtype: TABLEdefinition: ""comment: ""+ priority: 0- text: v1type: VIEWdefinition: ""comment: ""+ priority: 0- input: SELECT c1 as eid, c2 as xid FROM t2 ORDER BY |want:- text: c1type: COLUMNdefinition: t2 | , NOT NULLcomment: ""+ priority: 0- text: c2type: COLUMNdefinition: t2 | , NOT NULLcomment: ""+ priority: 0- text: eidtype: COLUMNdefinition: ""comment: ""+ priority: 0- text: xidtype: COLUMNdefinition: ""comment: ""+ priority: 0- text: dbtype: DATABASEdefinition: ""comment: ""+ priority: 0- text: t1type: TABLEdefinition: ""comment: ""+ priority: 0- text: t2type: TABLEdefinition: ""comment: ""+ priority: 0- text: v1type: VIEWdefinition: ""comment: ""+ priority: 0- input: SELECT c1 as eid FROM t1 ORDER BY |want:- text: c1type: COLUMNdefinition: t1 | , NOT NULLcomment: ""+ priority: 0- text: eidtype: COLUMNdefinition: ""comment: ""+ priority: 0- text: dbtype: DATABASEdefinition: ""comment: ""+ priority: 0- text: t1type: TABLEdefinition: ""comment: ""+ priority: 0- text: t2type: TABLEdefinition: ""comment: ""+ priority: 0- text: v1type: VIEWdefinition: ""comment: ""+ priority: 0- input: SELECT FROM basdkfjasldf;SELECT | FROM t1want:- text: c1type: COLUMNdefinition: t1 | , NOT NULLcomment: ""+ priority: 0- text: dbtype: DATABASEdefinition: ""comment: ""+ priority: 0- text: t1type: TABLEdefinition: ""comment: ""+ priority: 0- text: t2type: TABLEdefinition: ""comment: ""+ priority: 0- text: v1type: VIEWdefinition: ""comment: ""+ priority: 0- input: SELECT | FROM (SELECT c1 FROM t1) cc1(cc1c1)want:- text: cc1c1type: COLUMNdefinition: ""comment: ""+ priority: 0- text: dbtype: DATABASEdefinition: ""comment: ""+ priority: 0- text: cc1type: TABLEdefinition: ""comment: ""+ priority: 0- text: t1type: TABLEdefinition: ""comment: ""+ priority: 0- text: t2type: TABLEdefinition: ""comment: ""+ priority: 0- text: v1type: VIEWdefinition: ""comment: ""+ priority: 0- input: SELECT | FROM (SELECT c1 FROM t1) cc1want:- text: c1type: COLUMNdefinition: ""comment: ""+ priority: 0- text: dbtype: DATABASEdefinition: ""comment: ""+ priority: 0- text: cc1type: TABLEdefinition: ""comment: ""+ priority: 0- text: t1type: TABLEdefinition: ""comment: ""+ priority: 0- text: t2type: TABLEdefinition: ""comment: ""+ priority: 0- text: v1type: VIEWdefinition: ""comment: ""+ priority: 0+- input: |-+ SELECT+ FROM |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: |-+ SELECT++ FROM |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT FROM |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT FROM t1 WHERE |+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT FROM t1 ORDER BY |+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT FROM t1 GROUP BY |+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT FROM t1 JOIN |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: UPDATE |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: UPDATE t1 SET |+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: DELETE FROM |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: INSERT INTO |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: ALTER TABLE |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: DROP TABLE |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM db.|+ want:+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t1 JOIN |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t1, |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0- input: SELECT * from t1 cc1 JOIN t2 on cc1.|want:- text: c1type: COLUMN- definition: t1 | , NOT NULL+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+- input: SELECT MAX(cc1.|) FROM t2 cc1+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+- input: SELECT * FROM |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT | FROM t1+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT | FROM t2 x+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: x+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT DISTINCT | FROM t2+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT | FROM t2 LIMIT 10+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT c1, | FROM t2+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: |-+ SELECT+ |+ FROM t1+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: |-+ SELECT *+ FROM+ |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM /* comment */ |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: |-+ SELECT * FROM t1 -- comment+ WHERE |+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT | FROM t2 FOR UPDATE+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT t1.| FROM t1+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+- input: SELECT cc1.| FROM t2 cc1+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+- input: SELECT cc1.| FROM t1 cc1 JOIN t2 ON NOT cc1.c1 = t2.c1+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+- input: SELECT db.t2.| FROM t2+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+- input: SELECT a.| FROM t1 a JOIN t1 b ON a.c1 = b.c1+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+- input: SELECT b.| FROM t1 a JOIN t1 b ON a.c1 = b.c1+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+- input: SELECT COUNT(|) FROM t1+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT | FROM t1 JOIN t2 ON t1.c1 = t2.c1+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t1 cc1 JOIN t2 ON cc1.c1 = t2.|+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+- input: SELECT | FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT | FROM t1 RIGHT JOIN t2 ON t1.c1 = t2.c1+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT | FROM t1 CROSS JOIN t2+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT | FROM t1 NATURAL JOIN t2+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT | FROM t1 a JOIN t2 b ON a.c1 = b.c1 JOIN t2 c ON b.c1 = c.c1+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: a+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: b+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: c+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT c.| FROM t1 a JOIN t2 b ON a.c1 = b.c1 JOIN t2 c ON b.c1 = c.c1+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+- input: SELECT * FROM t1 RIGHT JOIN t2 ON t1.c1 = t2.|+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+- input: SELECT * FROM t1 CROSS JOIN t2 WHERE t1.|+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+- input: SELECT * FROM t1 JOIN t2 ON t1.c1 = t2.c1 LEFT JOIN t2 t3 ON t2.c1 = t3.c1 WHERE |+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t3+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT a.| FROM t1 a NATURAL JOIN t2 b+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+- input: SELECT * FROM t1 LEFT JOIN |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT | FROM t1 JOIN t2 ON t1.c1 = t2.c1 LEFT JOIN t2 t3 ON t2.c1 = t3.c1+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t3+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t1 JOIN t2 USING (|)+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT x.| FROM (SELECT * FROM t2) x+ want:+ - text: c1+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+- input: SELECT | FROM (SELECT * FROM (SELECT c1 FROM t1) inner_q) outer_q+ want:+ - text: c1+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: outer_q+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT | FROM (SELECT c1 FROM t1) sub1 JOIN t2 ON sub1.c1 = t2.c1+ want:+ - text: c1+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: sub1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT | FROM (SELECT c1 FROM (SELECT c1 FROM (SELECT c1 FROM t1) a) b) c+ want:+ - text: c1+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: c+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT b.| FROM (SELECT * FROM (SELECT c1 FROM t1) a) b+ want:+ - text: c1+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+- input: (SELECT c1 FROM t1) UNION (SELECT | FROM t2)+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t1 WHERE c1 IN (SELECT | FROM t2)+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t1 WHERE EXISTS (SELECT | FROM t2)+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t1 WHERE c1 = (SELECT MAX(|) FROM t2)+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t1 x WHERE x.c1 IN (SELECT c1 FROM t2 WHERE |)+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: x+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t1 WHERE EXISTS (SELECT 1 FROM t2 WHERE t2.c1 = t1.|)+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+- input: SELECT (SELECT | FROM t1) FROM t2+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: WITH a AS (SELECT c1 FROM t1), b AS (SELECT c1, c2 FROM t2) SELECT | FROM a JOIN b ON a.c1 = b.c1+ want:+ - text: c1+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: a+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: b+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: WITH a AS (SELECT c1 FROM t1), b AS (SELECT c1, c2 FROM t2) SELECT b.| FROM a JOIN b ON a.c1 = b.c1+ want:+ - text: c1+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+- input: WITH x AS (SELECT c1 FROM t1) SELECT | FROM (SELECT * FROM x) sub1+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: sub1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: x+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: With a AS (SELECT c1 FROM t1), b AS (SELECT * FROM a) SELECT | FROM b+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: a+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: b+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: With a AS (SELECT c1 FROM t1), b AS (SELECT a.| FROM a) SELECT * FROM b+ want:+ - text: c1+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+- input: WITH x AS (SELECT c1 FROM t1) SELECT | FROM x, t2+ want:+ - text: c1+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: x+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: WITH x AS (SELECT c1 FROM t1) SELECT x.| FROM x JOIN t2 ON x.c1 = t2.c1+ want:+ - text: c1+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+- input: WITH x(a, b) AS (SELECT c1, c2 FROM t2) SELECT | FROM x JOIN t1 ON x.a = t1.c1+ want:+ - text: a+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+ - text: b+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: x+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: WITH x AS (SELECT * FROM t2) INSERT INTO t1 SELECT | FROM x+ want:+ - text: c1+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: x+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: WITH x AS (SELECT c1, c2 FROM t2) UPDATE t1 SET c1 = (SELECT | FROM x)+ want:+ - text: c1+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: x+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: WITH x AS (SELECT * FROM t2) DELETE FROM t1 WHERE c1 IN (SELECT | FROM x)+ want:+ - text: c1+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: x+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: WITH RECURSIVE x AS (SELECT c1 FROM t1 UNION ALL SELECT c1 FROM x) SELECT | FROM x+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: x+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: WITH x AS (SELECT c1 FROM t1 UNION SELECT c1 FROM t2) SELECT x.| FROM x+ want:+ - text: c1+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t2 WHERE c1 = 1 AND |+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t2 WHERE (c1 = 1 AND |)+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t2 WHERE c1 IS NOT NULL AND |+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t2 WHERE c1 IS NULL OR |+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t2 WHERE NOT |+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t2 WHERE c1 > |+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t2 WHERE c1 + | > 0+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t2 WHERE c1 IN (1, 2) AND |+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t2 WHERE c1 BETWEEN | AND c2+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t2 WHERE c1 BETWEEN c2 AND |+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t2 WHERE c1 LIKE |+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t2 WHERE CASE WHEN c1 > 0 THEN | END = 1+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t1 a JOIN t2 b ON a.c1 = b.c1 WHERE |+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: a+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: b+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t1 a JOIN t2 b ON a.c1 = b.c1 WHERE a.|+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+- input: |-+ SELECT+ FROM t1+ WHERE |+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT c1 as eid FROM t1 WHERE |+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT c1 as eid FROM t1 GROUP BY |+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: eid+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT c1 as eid, c2 as xid FROM t2 HAVING |+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: eid+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+ - text: xid+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT c1 FROM t1 UNION SELECT c1 FROM t2 ORDER BY |+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT c1 FROM t1 UNION ALL SELECT c1 FROM t2 ORDER BY |+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t2 LIMIT |+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t2 ORDER BY c1 LIMIT |+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: INSERT INTO db.|+ want:+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: INSERT INTO t1 SELECT | FROM t2+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: INSERT INTO t1 VALUES (|)+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT 1; INSERT INTO |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: UPDATE | SET c1 = 1+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: UPDATE db.|+ want:+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: UPDATE t1 SET c1 = |+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: UPDATE t1 SET c1 = 1 WHERE |+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: DELETE FROM db.|+ want:+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: DELETE FROM t1 WHERE |+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT 1; UPDATE |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT 1; DELETE FROM |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: DELETE FROM t1 WHERE c1 > 0 AND |+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: ALTER TABLE db.|+ want:+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: ALTER TABLE t1 ADD COLUMN c2 int REFERENCES |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: ALTER TABLE t1 DROP COLUMN |+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: ALTER TABLE t1 RENAME COLUMN | TO new_name+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: ALTER TABLE t1 MODIFY COLUMN |+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: ALTER TABLE t1 ADD CONSTRAINT fk FOREIGN KEY (|) REFERENCES t2+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: ALTER TABLE t1 ADD CONSTRAINT fk FOREIGN KEY (c1) REFERENCES t2(|)+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: DROP TABLE db.|+ want:+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: DROP TABLE IF EXISTS |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: DROP VIEW |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: DROP INDEX |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+- input: TRUNCATE TABLE |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: CREATE TABLE t3 (id int, FOREIGN KEY (id) REFERENCES |)+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: CREATE TABLE t3 (id int REFERENCES t1(|))+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: CREATE INDEX idx ON |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: CREATE INDEX idx ON t1 (|)+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: CREATE INDEX idx ON t2 (c1, |)+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: CREATE VIEW v2 AS SELECT | FROM t1+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: CREATE VIEW v2 AS SELECT * FROM |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: CREATE TABLE t3 AS SELECT | FROM t1+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT c1 FROM t1 UNION SELECT | FROM t2+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT c1 FROM t1 UNION ALL SELECT | FROM t2+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT c1 FROM t1 INTERSECT SELECT | FROM t2+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT c1 FROM t1 EXCEPT SELECT | FROM t2+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT c1 FROM t1 UNION SELECT c1 FROM t1 UNION SELECT | FROM t2+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT c1 FROM t1 EXCEPT ALL SELECT | FROM t2+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT c1 FROM t1 INTERSECT ALL SELECT | FROM t2+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT | FROM t2 UNION SELECT * FROM t1+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM (SELECT c1 FROM t1 UNION SELECT c1 FROM t2) x WHERE x.|+ want:+ - text: c1+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+- input: SELECT | FROM (SELECT c1, c2 FROM t2 UNION SELECT c1, c2 FROM t2) sub+ want:+ - text: c1+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: ""+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: sub+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: INVALID SQL; SELECT * FROM |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t1; SELECT * FROM t2 WHERE |+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT; SELECT | FROM t1+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t1 WHERE; SELECT | FROM t2+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: CREATE TABLE x (id int); SELECT | FROM t1+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT 1; UPDATE |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT 1; DELETE FROM |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t|+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM db.t|+ want:+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT t1.c|+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+- input: INSERT INTO t|+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: UPDATE t|+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: DELETE FROM t|+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t1 JOIN t|+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t1 WHERE t1.c|+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+- input: ALTER TABLE t|+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: DROP TABLE t|+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT | FROM `t1`+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT `t1`.| FROM t1+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+- input: SELECT * FROM `db`.|+ want:+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM `db`.`t1` WHERE |+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: "SELECT\t|\tFROM t1"+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: 'SELECT * FROM t1 WHERE | '+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: |-+ SELECT+ *+ FROM+ t1+ WHERE |+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: /* leading comment */ SELECT * FROM |+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT * FROM t1 WHERE c1 = /* inline */ |+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: INSERT INTO `t1`(|)+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT c1, SUM(c2) OVER (PARTITION BY |) FROM t2+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT c1, SUM(c2) OVER (ORDER BY |) FROM t2+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT c1, ROW_NUMBER() OVER (PARTITION BY | ORDER BY c1) FROM t2+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT COALESCE(|, 0) FROM t2+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULLcomment: ""-- input: SELECT MAX(cc1.|) FROM t2 cc1+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT COALESCE(c1, |) FROM t2want:- text: c1type: COLUMNdefinition: t2 | , NOT NULLcomment: ""+ priority: 0- text: c2type: COLUMNdefinition: t2 | , NOT NULLcomment: ""-- input: SELECT * FROM |+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT NULLIF(|, 0) FROM t2+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT CAST(| AS int) FROM t2want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0- text: dbtype: DATABASEdefinition: ""comment: ""+ priority: 0- text: t1type: TABLEdefinition: ""comment: ""+ priority: 0- text: t2type: TABLEdefinition: ""comment: ""+ priority: 0- text: v1type: VIEWdefinition: ""comment: ""-- input: SELECT | FROM t1+ priority: 0+- input: SELECT IF(|, 1, 0) FROM t2want:- text: c1type: COLUMN- definition: t1 | , NOT NULL+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULLcomment: ""+ priority: 0- text: dbtype: DATABASEdefinition: ""comment: ""+ priority: 0- text: t1type: TABLEdefinition: ""comment: ""+ priority: 0- text: t2type: TABLEdefinition: ""comment: ""+ priority: 0- text: v1type: VIEWdefinition: ""comment: ""-- input: SELECT | FROM t2 x+ priority: 0+- input: SELECT IFNULL(|, 0) FROM t2want:- text: c1type: COLUMNdefinition: t2 | , NOT NULLcomment: ""+ priority: 0- text: c2type: COLUMNdefinition: t2 | , NOT NULLcomment: ""+ priority: 0- text: dbtype: DATABASEdefinition: ""comment: ""+ priority: 0- text: t1type: TABLEdefinition: ""comment: ""+ priority: 0- text: t2type: TABLEdefinition: ""comment: ""- - text: x+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT c1 as 'eid' FROM t1 ORDER BY |+ want:+- input: SELECT c1 as "xid" FROM t1 ORDER BY |+ want:+- input: SELECT * FROM t2 AS Foo WHERE foo.|+ want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ priority: 0+- input: WITH Foo AS (SELECT c1 FROM t1) SELECT foo.| FROM Foo+ want:+- input: ALTER TABLE t1 DROP COLUMN |+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: ALTER TABLE t1 RENAME COLUMN | TO new_name+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: ALTER TABLE db.t1 DROP COLUMN |+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: INSERT IGNORE t1 (|) VALUES (1)+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2type: TABLEdefinition: ""comment: ""+ priority: 0- text: v1type: VIEWdefinition: ""comment: ""+ priority: 0+- input: INSERT IGNORE INTO t1 (|) VALUES (1)+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: REPLACE INTO t1 (|) VALUES (1)+ want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""+ priority: 0+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: DROP VIEW db.|+ want:+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+ priority: 0+- input: SELECT | FROM other_db.t2+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ priority: 0+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ priority: 0diff --git a/docs/plans/SCENARIOS-mysql-completion.md b/docs/plans/SCENARIOS-mysql-completion.mdnew file mode 100644index 0000000000..76e9f0b135--- /dev/null+++ b/docs/plans/SCENARIOS-mysql-completion.md@@ -0,0 +1,290 @@+# MySQL Completion Test Coverage Alignment++> Goal: Align MySQL completion test coverage with PG's 235 test cases+> Verification: `go test -count=1 ./backend/plugin/parser/mysql/ -run ^TestCompletion$`+> Reference: PG completion tests at `backend/plugin/parser/pg/test-data/test_completion.yaml`+> Test file: `backend/plugin/parser/mysql/test-data/test_completion.yaml`+> Test runner: `backend/plugin/parser/mysql/completion_test.go`++Status: [ ] pending, [x] passing, [~] partial++---++## Phase 1: Core SQL Completion++### 1.1 Basic SELECT & FROM (14 scenarios)++- [x] `SELECT * FROM |` — tables, databases, views+- [x] `SELECT * FROM db.|` — tables and views in specific database+- [x] `SELECT | FROM t1` — columns of t1, plus tables/databases/views+- [x] `SELECT | FROM t2 x` — columns of t2 (aliased as x), tables including alias+- [ ] `SELECT DISTINCT | FROM t2` — same as SELECT columns+- [ ] `SELECT | FROM t2 LIMIT 10` — columns despite trailing LIMIT+- [ ] `SELECT c1, | FROM t2` — columns after comma in select list+- [x] `SELECT * FROM t1, |` — second table after comma+- [ ] `SELECT\n |\nFROM t1` — multiline with cursor on empty line before FROM+- [ ] `SELECT *\nFROM\n |` — multiline FROM on separate line+- [ ] `SELECT * FROM |` — extra whitespace+- [ ] `SELECT * FROM /* comment */ |` — inline block comment before cursor+- [ ] `SELECT * FROM t1 -- comment\nWHERE |` — line comment before WHERE+- [ ] `SELECT | FROM t2 FOR UPDATE` — columns despite trailing FOR UPDATE++### 1.2 Table.Column Qualification (10 scenarios)++- [ ] `SELECT t1.| FROM t1` — columns of t1 via direct table name+- [ ] `SELECT cc1.| FROM t2 cc1` — columns of t2 via alias+- [ ] `SELECT cc1.| FROM t1 cc1 JOIN t2 ON NOT cc1.c1 = t2.c1` — alias columns in JOIN context+- [ ] `SELECT db.t2.| FROM t2` — fully qualified database.table.column+- [x] `SELECT * FROM t2 x ORDER BY x.|` — alias columns in ORDER BY+- [x] `SELECT * FROM t2 x GROUP BY x.|` — alias columns in GROUP BY+- [x] `SELECT MAX(cc1.|) FROM t2 cc1` — alias columns inside function call+- [ ] `SELECT a.| FROM t1 a JOIN t1 b ON a.c1 = b.c1` — disambiguate self-join aliases (a)+- [ ] `SELECT b.| FROM t1 a JOIN t1 b ON a.c1 = b.c1` — disambiguate self-join aliases (b)+- [ ] `SELECT COUNT(|) FROM t1` — columns inside aggregate function++### 1.3 JOIN Variants (18 scenarios)++- [ ] `SELECT | FROM t1 JOIN t2 ON t1.c1 = t2.c1` — columns from both joined tables+- [x] `SELECT * FROM t1 cc1 JOIN t2 ON cc1.|` — alias columns in ON clause (left)+- [ ] `SELECT * FROM t1 cc1 JOIN t2 ON cc1.c1 = t2.|` — table columns in ON clause (right)+- [ ] `SELECT | FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1` — LEFT JOIN+- [ ] `SELECT | FROM t1 RIGHT JOIN t2 ON t1.c1 = t2.c1` — RIGHT JOIN+- [ ] `SELECT | FROM t1 CROSS JOIN t2` — CROSS JOIN (no ON)+- [ ] `SELECT | FROM t1 NATURAL JOIN t2` — NATURAL JOIN+- [ ] `SELECT | FROM t1 a JOIN t2 b ON a.c1 = b.c1 JOIN t2 c ON b.c1 = c.c1` — 3-way JOIN+- [ ] `SELECT c.| FROM t1 a JOIN t2 b ON a.c1 = b.c1 JOIN t2 c ON b.c1 = c.c1` — 3rd alias columns+- [ ] `SELECT * FROM t1 RIGHT JOIN t2 ON t1.c1 = t2.|` — columns in RIGHT JOIN ON+- [ ] `SELECT * FROM t1 CROSS JOIN t2 WHERE t1.|` — columns after CROSS JOIN in WHERE+- [ ] `SELECT * FROM t1 JOIN t2 ON t1.c1 = t2.c1 LEFT JOIN t2 t3 ON t2.c1 = t3.c1 WHERE |` — multi-JOIN WHERE+- [ ] `SELECT a.| FROM t1 a NATURAL JOIN t2 b` — alias after NATURAL JOIN+- [x] `SELECT * FROM t1 JOIN |` — table candidates after JOIN keyword+- [ ] `SELECT * FROM t1 LEFT JOIN |` — table candidates after LEFT JOIN+- [x] `SELECT FROM t1 JOIN |` — skeleton: table candidates after JOIN (no select expr)+- [ ] `SELECT | FROM t1 JOIN t2 ON t1.c1 = t2.c1 LEFT JOIN t2 t3 ON t2.c1 = t3.c1` — columns from all 3 tables+- [ ] `SELECT * FROM t1 JOIN t2 USING (|)` — columns for USING clause++### 1.4 Subquery & Derived Tables (14 scenarios)++- [x] `SELECT | FROM (SELECT c1 FROM t1) cc1` — derived table columns (inferred)+- [x] `SELECT | FROM (SELECT c1 FROM t1) cc1(cc1c1)` — derived table columns (explicit alias)+- [ ] `SELECT x.| FROM (SELECT * FROM t2) x` — derived table qualified columns+- [ ] `SELECT | FROM (SELECT * FROM (SELECT c1 FROM t1) inner_q) outer_q` — nested derived tables+- [ ] `SELECT | FROM (SELECT c1 FROM t1) sub1 JOIN t2 ON sub1.c1 = t2.c1` — derived table JOIN+- [ ] `SELECT | FROM (SELECT c1 FROM (SELECT c1 FROM (SELECT c1 FROM t1) a) b) c` — triple nested+- [ ] `SELECT b.| FROM (SELECT * FROM (SELECT c1 FROM t1) a) b` — nested qualified access+- [ ] `(SELECT c1 FROM t1) UNION (SELECT | FROM t2)` — subquery in parenthesized UNION+- [ ] `SELECT * FROM t1 WHERE c1 IN (SELECT | FROM t2)` — subquery in WHERE IN+- [ ] `SELECT * FROM t1 WHERE EXISTS (SELECT | FROM t2)` — subquery in WHERE EXISTS+- [ ] `SELECT * FROM t1 WHERE c1 = (SELECT MAX(|) FROM t2)` — scalar subquery+- [ ] `SELECT * FROM t1 x WHERE x.c1 IN (SELECT c1 FROM t2 WHERE |)` — correlated subquery WHERE+- [ ] `SELECT * FROM t1 WHERE EXISTS (SELECT 1 FROM t2 WHERE t2.c1 = t1.|)` — correlated column ref+- [ ] `SELECT (SELECT | FROM t1) FROM t2` — scalar subquery in SELECT list++### 1.5 CTE (Common Table Expressions) (16 scenarios)++- [x] `WITH x AS (SELECT * FROM t2) SELECT x.| FROM x;` — CTE qualified columns (inferred)+- [x] `WITH x(x1, x2) AS (SELECT * FROM t2) SELECT x.| FROM x;` — CTE with explicit columns+- [x] `WITH x(x1, x2) AS (SELECT * FROM t2) SELECT | FROM x` — CTE unqualified columns+- [ ] `WITH a AS (SELECT c1 FROM t1), b AS (SELECT c1, c2 FROM t2) SELECT | FROM a JOIN b ON a.c1 = b.c1` — multiple CTEs+- [ ] `WITH a AS (SELECT c1 FROM t1), b AS (SELECT c1, c2 FROM t2) SELECT b.| FROM a JOIN b ON a.c1 = b.c1` — multiple CTE qualified+- [ ] `WITH x AS (SELECT c1 FROM t1) SELECT | FROM (SELECT * FROM x) sub1` — CTE used in derived table+- [ ] `WITH a AS (SELECT c1 FROM t1), b AS (SELECT * FROM a) SELECT | FROM b` — CTE referencing CTE+- [ ] `WITH a AS (SELECT c1 FROM t1), b AS (SELECT a.| FROM a) SELECT * FROM b` — CTE qualified in CTE definition+- [ ] `WITH x AS (SELECT c1 FROM t1) SELECT | FROM x, t2` — CTE mixed with regular table+- [ ] `WITH x AS (SELECT c1 FROM t1) SELECT x.| FROM x JOIN t2 ON x.c1 = t2.c1` — CTE in JOIN+- [ ] `WITH x(a, b) AS (SELECT c1, c2 FROM t2) SELECT | FROM x JOIN t1 ON x.a = t1.c1` — CTE explicit cols in JOIN+- [ ] `WITH x AS (SELECT * FROM t2) INSERT INTO t1 SELECT | FROM x` — CTE in INSERT SELECT+- [ ] `WITH x AS (SELECT c1, c2 FROM t2) UPDATE t1 SET c1 = (SELECT | FROM x)` — CTE in UPDATE subquery+- [ ] `WITH x AS (SELECT * FROM t2) DELETE FROM t1 WHERE c1 IN (SELECT | FROM x)` — CTE in DELETE subquery+- [ ] `WITH RECURSIVE x AS (SELECT c1 FROM t1 UNION ALL SELECT c1 FROM x) SELECT | FROM x` — recursive CTE+- [ ] `WITH x AS (SELECT c1 FROM t1 UNION SELECT c1 FROM t2) SELECT x.| FROM x` — CTE with UNION body++### 1.6 WHERE Clause Variants (18 scenarios)++- [x] `SELECT * FROM t1 WHERE |` — basic WHERE+- [ ] `SELECT * FROM t2 WHERE c1 = 1 AND |` — after AND+- [ ] `SELECT * FROM t2 WHERE (c1 = 1 AND |)` — inside parenthesized AND+- [ ] `SELECT * FROM t2 WHERE c1 IS NOT NULL AND |` — after IS NOT NULL AND+- [ ] `SELECT * FROM t2 WHERE c1 IS NULL OR |` — after IS NULL OR+- [ ] `SELECT * FROM t2 WHERE NOT |` — after NOT+- [ ] `SELECT * FROM t2 WHERE c1 > |` — after comparison operator+- [ ] `SELECT * FROM t2 WHERE c1 + | > 0` — in arithmetic expression+- [ ] `SELECT * FROM t2 WHERE c1 IN (1, 2) AND |` — after IN list AND+- [ ] `SELECT * FROM t2 WHERE c1 BETWEEN | AND c2` — BETWEEN left+- [ ] `SELECT * FROM t2 WHERE c1 BETWEEN c2 AND |` — BETWEEN right+- [ ] `SELECT * FROM t2 WHERE c1 LIKE |` — after LIKE+- [ ] `SELECT * FROM t2 WHERE CASE WHEN c1 > 0 THEN | END = 1` — inside CASE THEN+- [ ] `SELECT * FROM t1 a JOIN t2 b ON a.c1 = b.c1 WHERE |` — WHERE after JOIN+- [ ] `SELECT * FROM t1 a JOIN t2 b ON a.c1 = b.c1 WHERE a.|` — qualified column in WHERE after JOIN+- [x] `SELECT FROM t1 WHERE |` — skeleton: WHERE without select expressions+- [ ] `SELECT\nFROM t1\nWHERE |` — skeleton multiline WHERE+- [ ] `SELECT c1 as eid FROM t1 WHERE |` — WHERE with select alias (alias NOT valid in WHERE)++---++## Phase 2: DML & DDL Completion++### 2.1 ORDER BY / GROUP BY / HAVING (10 scenarios)++- [x] `SELECT c1 as eid FROM t1 ORDER BY |` — ORDER BY with alias+- [x] `SELECT c1 as eid, c2 as xid FROM t2 ORDER BY |` — ORDER BY with multiple aliases+- [ ] `SELECT c1 as eid FROM t1 GROUP BY |` — GROUP BY with alias+- [ ] `SELECT c1 as eid, c2 as xid FROM t2 HAVING |` — HAVING with aliases+- [x] `SELECT FROM t1 ORDER BY |` — skeleton ORDER BY+- [x] `SELECT FROM t1 GROUP BY |` — skeleton GROUP BY+- [ ] `SELECT c1 FROM t1 UNION SELECT c1 FROM t2 ORDER BY |` — ORDER BY on UNION result+- [ ] `SELECT c1 FROM t1 UNION ALL SELECT c1 FROM t2 ORDER BY |` — ORDER BY on UNION ALL result+- [ ] `SELECT * FROM t2 LIMIT |` — keywords only in LIMIT position+- [ ] `SELECT * FROM t2 ORDER BY c1 LIMIT |` — LIMIT after ORDER BY++### 2.2 INSERT (8 scenarios)++- [x] `INSERT INTO |` — table candidates+- [ ] `INSERT INTO db.|` — database-qualified table candidates+- [x] `INSERT INTO t1(|);` — column candidates for target table+- [x] `INSERT INTO t2(c1, |);` — remaining columns after comma+- [ ] `INSERT INTO t1 SELECT | FROM t2` — INSERT SELECT columns+- [ ] `INSERT INTO t1 VALUES (|)` — inside VALUES (columns/functions)+- [ ] `SELECT 1; INSERT INTO |` — INSERT after prior statement+- [ ] `UPDATE | SET c1 = 1` — UPDATE with partial context++### 2.3 UPDATE & DELETE (12 scenarios)++- [x] `UPDATE |` — table candidates+- [ ] `UPDATE db.|` — database-qualified table candidates+- [x] `UPDATE t1 SET |` — SET column candidates+- [ ] `UPDATE t1 SET c1 = |` — value position (columns/functions)+- [ ] `UPDATE t1 SET c1 = 1 WHERE |` — UPDATE WHERE+- [x] `DELETE FROM |` — table candidates+- [ ] `DELETE FROM db.|` — database-qualified table candidates+- [ ] `DELETE FROM t1 WHERE |` — DELETE WHERE+- [ ] `SELECT 1; UPDATE |` — UPDATE after prior statement+- [ ] `SELECT 1; DELETE FROM |` — DELETE after prior statement+- [x] `SELECT FROM t1 WHERE |` — skeleton WHERE (already in 1.6, cross-ref)+- [ ] `DELETE FROM t1 WHERE c1 > 0 AND |` — compound DELETE WHERE++### 2.4 ALTER / DROP / CREATE (18 scenarios)++- [x] `ALTER TABLE |` — table candidates+- [ ] `ALTER TABLE db.|` — database-qualified+- [ ] `ALTER TABLE t1 ADD COLUMN c2 int REFERENCES |` — FK reference table+- [ ] `ALTER TABLE t1 DROP COLUMN |` — column candidates+- [ ] `ALTER TABLE t1 RENAME COLUMN | TO new_name` — column candidates+- [ ] `ALTER TABLE t1 MODIFY COLUMN |` — MySQL-specific MODIFY+- [ ] `ALTER TABLE t1 ADD CONSTRAINT fk FOREIGN KEY (|) REFERENCES t2` — FK source columns+- [ ] `ALTER TABLE t1 ADD CONSTRAINT fk FOREIGN KEY (c1) REFERENCES t2(|)` — FK target columns+- [x] `DROP TABLE |` — table candidates+- [ ] `DROP TABLE db.|` — database-qualified+- [ ] `DROP TABLE IF EXISTS |` — table candidates after IF EXISTS+- [ ] `DROP VIEW |` — view candidates+- [ ] `DROP INDEX |` — index candidates (table context)+- [ ] `TRUNCATE TABLE |` — table candidates (MySQL requires TABLE keyword)+- [ ] `CREATE TABLE t3 (id int, FOREIGN KEY (id) REFERENCES |)` — FK reference table+- [ ] `CREATE TABLE t3 (id int REFERENCES t1(|))` — FK reference columns+- [ ] `CREATE INDEX idx ON |` — table candidates+- [ ] `CREATE INDEX idx ON t1 (|)` — column candidates for index+- [ ] `CREATE INDEX idx ON t2 (c1, |)` — second column in compound index+- [ ] `CREATE VIEW v2 AS SELECT | FROM t1` — columns in CREATE VIEW+- [ ] `CREATE VIEW v2 AS SELECT * FROM |` — tables in CREATE VIEW FROM+- [ ] `CREATE TABLE t3 AS SELECT | FROM t1` — CREATE TABLE AS SELECT++---++## Phase 3: Advanced Completion++### 3.1 UNION / INTERSECT / EXCEPT (12 scenarios)++- [ ] `SELECT c1 FROM t1 UNION SELECT | FROM t2` — after UNION SELECT+- [ ] `SELECT c1 FROM t1 UNION ALL SELECT | FROM t2` — after UNION ALL SELECT+- [ ] `SELECT c1 FROM t1 INTERSECT SELECT | FROM t2` — INTERSECT+- [ ] `SELECT c1 FROM t1 EXCEPT SELECT | FROM t2` — EXCEPT+- [ ] `SELECT c1 FROM t1 UNION SELECT c1 FROM t1 UNION SELECT | FROM t2` — triple UNION+- [ ] `SELECT c1 FROM t1 EXCEPT ALL SELECT | FROM t2` — EXCEPT ALL+- [ ] `SELECT c1 FROM t1 INTERSECT ALL SELECT | FROM t2` — INTERSECT ALL+- [ ] `SELECT | FROM t2 UNION SELECT * FROM t1` — first SELECT in UNION+- [ ] `SELECT * FROM (SELECT c1 FROM t1 UNION SELECT c1 FROM t2) x WHERE x.|` — qualified from UNION subquery+- [ ] `WITH x AS (SELECT c1 FROM t1 UNION SELECT c1 FROM t2) SELECT x.| FROM x` — CTE with UNION (dup of 1.5, cross-ref)+- [ ] `SELECT | FROM (SELECT c1, c2 FROM t2 UNION SELECT c1, c2 FROM t2) sub` — derived table from UNION+- [ ] `SELECT c1 FROM t1 UNION ALL SELECT c1 FROM t2 ORDER BY |` — ORDER BY on UNION (dup of 2.1, cross-ref)++### 3.2 Multi-Statement & Error Recovery (14 scenarios)++- [x] `SELECT 1; SELECT * FROM |` — after valid statement (complex variant)+- [x] `SELECT FROM basdkfjasldf; SELECT | FROM t1` — after invalid statement+- [x] `select count(1) from t1 where id 'asdfsadf'; SELECT * FROM |` — after complex invalid (multiline)+- [ ] `INVALID SQL; SELECT * FROM |` — after completely invalid SQL+- [ ] `SELECT * FROM t1; SELECT * FROM t2 WHERE |` — WHERE in second statement+- [ ] `SELECT; SELECT | FROM t1` — after empty SELECT+- [ ] `SELECT * FROM t1 WHERE; SELECT | FROM t2` — after incomplete WHERE+- [ ] `CREATE TABLE x (id int); SELECT | FROM t1` — after DDL+- [x] `SELECT\nFROM |` — skeleton (no select expressions)+- [x] `SELECT\n\nFROM |` — skeleton with blank line+- [x] `SELECT FROM |` — skeleton single line+- [ ] `SELECT\nFROM t1\nWHERE |` — skeleton multiline WHERE (dup of 1.6)+- [ ] `SELECT 1; UPDATE |` — UPDATE after prior statement+- [ ] `SELECT 1; DELETE FROM |` — DELETE after prior statement++### 3.3 Partial Identifiers (10 scenarios)++- [ ] `SELECT * FROM t|` — partial table name+- [ ] `SELECT * FROM db.t|` — partial after database dot+- [ ] `SELECT t1.c|` — partial column name+- [ ] `INSERT INTO t|` — partial in INSERT+- [ ] `UPDATE t|` — partial in UPDATE+- [ ] `DELETE FROM t|` — partial in DELETE+- [ ] `SELECT * FROM t1 JOIN t|` — partial after JOIN+- [ ] `SELECT * FROM t1 WHERE t1.c|` — partial qualified column in WHERE+- [ ] `ALTER TABLE t|` — partial in ALTER+- [ ] `DROP TABLE t|` — partial in DROP++### 3.4 Quoted Identifiers & Formatting (10 scenarios)++- [ ] `` SELECT | FROM `t1` `` — backtick-quoted table+- [ ] `` SELECT `t1`.| FROM t1 `` — backtick-quoted qualifier+- [ ] `` SELECT * FROM `db`.| `` — backtick-quoted database+- [ ] `` SELECT * FROM `db`.`t1` WHERE | `` — fully backtick-quoted table in WHERE+- [ ] `SELECT\t|\tFROM t1` — tab whitespace+- [ ] `SELECT * FROM t1 WHERE | ` — trailing space after cursor+- [ ] `SELECT\n *\n FROM\n t1\n WHERE |` — fully expanded multiline+- [ ] `/* leading comment */ SELECT * FROM |` — leading block comment+- [ ] `SELECT * FROM t1 WHERE c1 = /* inline */ |` — inline comment in expression+- [ ] `` INSERT INTO `t1`(|) `` — backtick-quoted table in INSERT++### 3.5 Window Functions & Expressions (10 scenarios)++- [ ] `SELECT c1, SUM(c2) OVER (PARTITION BY |) FROM t2` — PARTITION BY columns+- [ ] `SELECT c1, SUM(c2) OVER (ORDER BY |) FROM t2` — window ORDER BY columns+- [ ] `SELECT c1, ROW_NUMBER() OVER (PARTITION BY | ORDER BY c1) FROM t2` — PARTITION BY in compound window+- [ ] `SELECT COALESCE(|, 0) FROM t2` — first arg of COALESCE+- [ ] `SELECT COALESCE(c1, |) FROM t2` — second arg of COALESCE+- [ ] `SELECT NULLIF(|, 0) FROM t2` — first arg of NULLIF+- [ ] `SELECT CAST(| AS int) FROM t2` — CAST argument+- [ ] `SELECT IF(|, 1, 0) FROM t2` — MySQL IF function+- [ ] `SELECT IFNULL(|, 0) FROM t2` — MySQL IFNULL function+- [ ] `SELECT * FROM t1 WHERE c1 > (SELECT MAX(|) FROM t2)` — aggregate in scalar subquery (dup of 1.4)++---++## Test Infrastructure++### Metadata Expansion++The current test metadata has: db with t1(c1), t2(c1,c2), v1.++To support database-qualified tests (MySQL equivalent of PG's schema-qualified tests), the test metadata getter needs to handle `db` as database name and return tables/views. No second database needed — MySQL's `db.|` tests verify the database-qualified path works with the default database.++### Verification++Each section is verified by:+1. Adding test cases to `test_completion.yaml`+2. Running `go test -count=1 ./backend/plugin/parser/mysql/ -run ^TestCompletion$`+3. For new scenarios, first run with `record = true` to capture actual output, then verify output is sensible before committing as expected++### Summary++| Phase | Sections | Total | Already Passing | New |+|-------|----------|-------|-----------------|-----|+| Phase 1 | 6 | 90 | 15 | 75 |+| Phase 2 | 4 | 48 | 12 | 36 |+| Phase 3 | 5 | 56 | 4 | 52 |+| **Total** | **15** | **194** | **31** | **163** |diff --git a/go.mod b/go.modindex 2ba9605c0e..a336b718fd 100644--- a/go.mod+++ b/go.mod@@ -34,7 +34,7 @@ require (github.com/bmatcuk/doublestar/v4 v4.10.0github.com/bytebase/gomongo v0.0.0-20260403033636-f6c50d4ab888github.com/bytebase/lsp-protocol v0.0.0-20250324071136-1586d0c10ff0- github.com/bytebase/omni v0.0.0-20260408072050-615fac4c38c5+ github.com/bytebase/omni v0.0.0-20260409065645-1b566706b239github.com/caarlos0/env/v11 v11.4.0github.com/cenkalti/backoff/v5 v5.0.3github.com/cockroachdb/cockroachdb-parser v0.25.2diff --git a/go.sum b/go.sumindex b62ca6e5ec..74ada55c1f 100644--- a/go.sum+++ b/go.sum@@ -253,8 +253,8 @@ github.com/bytebase/gomongo v0.0.0-20260403033636-f6c50d4ab888 h1:E8tz8maxpih/vtgithub.com/bytebase/gomongo v0.0.0-20260403033636-f6c50d4ab888/go.mod h1:IgLUOjyiHehdE0G3C92IjGYu9lJQgkPwf2mdNSvPWq8=github.com/bytebase/lsp-protocol v0.0.0-20250324071136-1586d0c10ff0 h1:bJ8NSf2K+pccl5m/wuu97fiYjDwpJH6IzURAq/3XA2U=github.com/bytebase/lsp-protocol v0.0.0-20250324071136-1586d0c10ff0/go.mod h1:BEWMfiZtqshdmulKJcIsWb45MUaEvDO4CROcgi8dfFg=-github.com/bytebase/omni v0.0.0-20260408072050-615fac4c38c5 h1:1EY5m6ONYnbm8DL/K2oGvA2jEc0oEK45gGNashoJzFc=-github.com/bytebase/omni v0.0.0-20260408072050-615fac4c38c5/go.mod h1:SBAYEmMjJhA9WujfrIVIq76UFmsvNDOa5CekPhFXIis=+github.com/bytebase/omni v0.0.0-20260409065645-1b566706b239 h1:UK4ooauNQTq8nTJInHLNNEHnnDcy5bGav+gTbNhMEC0=+github.com/bytebase/omni v0.0.0-20260409065645-1b566706b239/go.mod h1:SBAYEmMjJhA9WujfrIVIq76UFmsvNDOa5CekPhFXIis=github.com/bytebase/parser v0.0.0-20260324092042-1d52e5412f50 h1:Kq5wlhZ586Rch39y/IQV9MnrEzHob4iiXBG6zrbvSMU=github.com/bytebase/parser v0.0.0-20260324092042-1d52e5412f50/go.mod h1:jeak/EfutSOAuWKvrFIT2IZunhWprM7oTFBRgZ9RCxo=github.com/bytebase/pgx/v5 v5.0.0-20250212161523-96ff8aed8767 h1:YuR5G3LcxpO5ScSTA+Kdirxg9RW4TRc/v1t7N2Hfmbw=