{"record":{"id":"8a03d736fdbec1b8","repo":"vitessio/vitess","slug":"vt09004","errorCode":"VT09004","errorMessage":"VT09004: INSERT should contain column list or the table should have authoritative columns in vschema","messagePattern":"VT09004: INSERT should contain column list or the table should have authoritative columns in vschema","errorType":"error_code","errorClass":"VitessError","httpStatus":null,"severity":"error","filePath":"go/vt/vtgate/planbuilder/operators/insert.go","lineNumber":382,"sourceCode":"\t}\n\n\tinsOp := &Insert{\n\t\tVTable: vTbl,\n\t\tAST:    insStmt,\n\t}\n\troute := &Route{\n\t\tunaryOperator: newUnaryOp(insOp),\n\t\tRouting:       routing,\n\t}\n\n\t// Table column list is nil then add all the columns\n\t// If the column list is empty then add only the auto-inc column and\n\t// this happens on calling modifyForAutoinc\n\tif insStmt.Columns == nil && valuesProvided(insStmt.Rows) {\n\t\tif vTbl.ColumnListAuthoritative {\n\t\t\tinsStmt = populateInsertColumnlist(insStmt, vTbl)\n\t\t} else {\n\t\t\tpanic(vterrors.VT09004())\n\t\t}\n\t}\n\n\t// modify column list or values for autoincrement column.\n\tautoIncGen := modifyForAutoinc(ctx, insStmt, vTbl)\n\tinsOp.AutoIncrement = autoIncGen\n\n\t// set insert ignore.\n\tinsOp.Ignore = bool(insStmt.Ignore) || insStmt.OnDup != nil\n\n\tinsOp.ColVindexes = getColVindexes(insOp)\n\tswitch rows := insStmt.Rows.(type) {\n\tcase sqlparser.Values:\n\t\top = route\n\t\troute.Source = insertRowsPlan(ctx, insOp, insStmt, rows)\n\tcase sqlparser.TableStatement:\n\t\top = insertSelectPlan(ctx, insOp, route, insStmt, rows)\n\t}","sourceCodeStart":364,"sourceCodeEnd":400,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtgate/planbuilder/operators/insert.go#L364-L400","documentation":"VT09004 is raised by createInsertOperator in go/vt/vtgate/planbuilder/operators/insert.go:382 when an INSERT omits its column list AND the target table's vschema entry is not marked ColumnListAuthoritative. Without a column list or an authoritative column list, Vitess cannot map each value to a column and cannot populate the insert plan.","triggerScenarios":"Executing `INSERT INTO t VALUES (...)` (no column list, rows provided) where the vschema table definition for t lacks `column_list_authoritative: true`.","commonSituations":"Legacy SQL written without explicit column lists being pointed at Vitess; vschema (JSON) files migrated manually without setting column_list_authoritative; tables whose physical schema can change so authoritative lists were intentionally avoided.","solutions":["Rewrite the INSERT to include an explicit column list: INSERT INTO t (col1, col2) VALUES (...)","Set `column_list_authoritative: true` on the table's vschema definition if the column list is complete and stable","Resync the vschema with the physical table schema before enabling authoritative columns"],"exampleFix":"// before\nINSERT INTO users VALUES (1, 'alice');\n// after\nINSERT INTO users (id, name) VALUES (1, 'alice');","handlingStrategy":"validation","validationCode":"// Require an explicit column list for inserts into Vitess tables\nconst insertRe = /^INSERT\\s+INTO\\s+[`\\w.]+\\s*VALUES/i;\nif (insertRe.test(sql)) {\n  throw new Error('INSERT must include an explicit column list');\n}","typeGuard":"function hasColumnList(insertAst) {\n  return Array.isArray(insertAst.columns) && insertAst.columns.length > 0;\n}","tryCatchPattern":"try {\n  await vtgate.execute(sql, args);\n} catch (e) {\n  if (String(e).includes('VT09004')) {\n    throw new Error('Add a column list to the INSERT or set column_list_authoritative in the vschema: ' + e.message);\n  }\n  throw e;\n}","preventionTips":["Always write INSERTs with explicit column lists","Enable column_list_authoritative in the vschema when the physical schema is stable","Add a lint rule forbidding bare `INSERT INTO t VALUES (...)` in application SQL"],"tags":["insert","vschema","column-list"],"backgroundTag":"missing-column-list","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}