{"record":{"id":"406c3b315d7fdb3d","repo":"bytebase/bytebase","slug":"meet-unsupported-table-statement-with-into","errorCode":null,"errorMessage":"meet unsupported table statement with into","messagePattern":"meet unsupported table statement with into","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/plugin/parser/mysql/query_span_extractor_omni.go","lineNumber":161,"sourceCode":"\t\treturn nil, err\n\t}\n\tq.tableSourceFrom = append(q.tableSourceFrom, fromSources...)\n\n\tresults, err := q.extractOmniTargetList(stmt.TargetList, fromSources)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &base.PseudoTable{\n\t\tColumns: results,\n\t}, nil\n}\n\nfunc (q *omniQuerySpanExtractor) extractOmniTableStmt(stmt *ast.TableStmt) (*base.PseudoTable, error) {\n\tif stmt == nil || stmt.Table == nil {\n\t\treturn &base.PseudoTable{}, nil\n\t}\n\tif stmt.Into != nil {\n\t\treturn nil, errors.New(\"meet unsupported table statement with into\")\n\t}\n\ttableSource, err := q.findTableSchema(stmt.Table.Schema, stmt.Table.Name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &base.PseudoTable{Columns: tableSource.GetQuerySpanResult()}, nil\n}\n\nfunc (q *omniQuerySpanExtractor) extractOmniValuesStmt(stmt *ast.ValuesStmt) (*base.PseudoTable, error) {\n\tif stmt == nil || len(stmt.Rows) == 0 {\n\t\treturn &base.PseudoTable{}, nil\n\t}\n\tvar columns []base.QuerySpanResult\n\tfor _, expr := range stmt.Rows[0] {\n\t\tfield, err := q.extractOmniExpr(expr)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/bytebase/bytebase/blob/1870550677fe08f0d2a78c07acd27541464eb945/backend/plugin/parser/mysql/query_span_extractor_omni.go#L143-L179","documentation":"The MySQL/OMNI query span extractor refuses TABLE ... INTO statements. TABLE statements are a shorthand for SELECT * FROM tbl, and when they carry an INTO clause they write rows to a variable or file, which the extractor cannot model for lineage. It fails closed instead of returning wrong column spans.","triggerScenarios":"Query span extraction encounters a *ast.TableStmt whose Into field is non-nil, e.g. TABLE users INTO @x. Reached from extractOmniSelectRoot or extractOmniSelectStmt when a TABLE statement appears as the query body or inside a set operation.","commonSituations":"Ingesting MySQL 8.0+ TABLE shorthand syntax through lineage tooling, especially scripts written with INTO for variable capture or file dumps.","solutions":["Remove the INTO clause from the TABLE statement","Rewrite TABLE tbl INTO ... as the explicit form SELECT * FROM tbl (without INTO) before extraction","Pre-scan statements for TABLE ... INTO and route them away from span extraction"],"exampleFix":"// before\nTABLE users INTO @rows;\n// after\nSELECT * FROM users;","handlingStrategy":"validation","validationCode":"// reject TABLE ... INTO before extraction\nif /^\\s*TABLE\\s+\\S+\\s+INTO\\b/i.test(stmt) { throw new Error('TABLE ... INTO is not supported for lineage') }","typeGuard":null,"tryCatchPattern":"span, err := extractor.Extract(sql)\nif err != nil {\n    if strings.Contains(err.Error(), \"table statement with into\") {\n        return nil, fmt.Errorf(\"rewrite %q as SELECT * FROM ...\", sql)\n    }\n    return nil, err\n}","preventionTips":["Prefer explicit SELECT * FROM tbl over TABLE shorthand","Filter statements containing TABLE ... INTO before analysis","Validate SQL dialect version assumptions before ingestion"],"tags":["mysql","query-span","lineage","unsupported-sql"],"backgroundTag":"unsupported-operation","analyzedSha":"1870550677fe08f0d2a78c07acd27541464eb945","analyzedAt":"2026-09-06T21:16:13.665Z","contentChangedAt":"2026-09-06T21:16:13.665Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}