{"record":{"id":"60bce17089e1d98c","repo":"vitessio/vitess","slug":"unsupported-construct-s","errorCode":null,"errorMessage":"unsupported construct: %s","messagePattern":"unsupported construct: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vttablet/tabletmanager/vreplication/controller_plan.go","lineNumber":157,"sourceCode":"\n// buildControllerPlan parses the input query and returns an appropriate plan.\nfunc buildControllerPlan(query string, parser *sqlparser.Parser) (*controllerPlan, error) {\n\tstmt, err := parser.Parse(query)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar plan *controllerPlan\n\tswitch stmt := stmt.(type) {\n\tcase *sqlparser.Insert:\n\t\tplan, err = buildInsertPlan(stmt)\n\tcase *sqlparser.Update:\n\t\tplan, err = buildUpdatePlan(stmt)\n\tcase *sqlparser.Delete:\n\t\tplan, err = buildDeletePlan(stmt)\n\tcase *sqlparser.Select:\n\t\tplan, err = buildSelectPlan(stmt)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported construct: %s\", sqlparser.String(stmt))\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tplan.query = query\n\treturn plan, nil\n}\n\nfunc buildInsertPlan(ins *sqlparser.Insert) (*controllerPlan, error) {\n\t// This should never happen.\n\tif ins == nil {\n\t\treturn nil, errors.New(\"BUG: invalid nil INSERT statement found when building VReplication plan\")\n\t}\n\ttableName, err := ins.Table.TableName()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif tableName.Qualifier.String() != sidecar.GetName() && tableName.Qualifier.String() != sidecar.DefaultName {","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vttablet/tabletmanager/vreplication/controller_plan.go#L139-L175","documentation":"buildControllerPlan parses a SQL statement issued against the vreplication engine and only supports Update, Insert, Delete and Select statements. Any other construct (DDL, SET, transactions, SHOW, etc.) hits the default branch and returns `unsupported construct: <SQL>`.","triggerScenarios":"Executing a non-DML statement through the vreplication engine's exec path (the code that runs _vt.vreplication queries), e.g. `ALTER TABLE _vt.vreplication ...`, `SET ...`, `BEGIN`, or `TRUNCATE` passed to vexec / UpdateVReplicationWorkflow style APIs.","commonSituations":"Operators running ad-hoc SQL on _vt.vreplication via vtctldclient VExec with DDL; tooling or scripts sending unsupported statements; newer parser statement types (e.g. source-specific syntax) not mapped to a plan builder.","solutions":["Rewrite the statement as one of UPDATE/INSERT/DELETE/SELECT against _vt.vreplication or _vt.resharding_journal.","Use vtctldclient workflow commands instead of raw DDL to mutate vreplication state.","For DDL on the sidecar table, run it directly on the tablet's MySQL, not through the vreplication engine.","If a legitimate new statement type should be supported, file/see an upstream issue to add a plan builder branch."],"exampleFix":"// before\nexec(\"ALTER TABLE _vt.vreplication ADD COLUMN foo INT\")\n// after\n// run DDL directly on tablet MySQL, or use:\nexec(\"update _vt.vreplication set state='Stopped' where id=1\")","handlingStrategy":"validation","validationCode":"// Only send DML to the vreplication engine:\nstmt := strings.TrimSpace(query)\nlower := strings.ToLower(stmt)\nif !(strings.HasPrefix(lower, \"select\") || strings.HasPrefix(lower, \"insert\") ||\n     strings.HasPrefix(lower, \"update\") || strings.HasPrefix(lower, \"delete\")) {\n    return fmt.Errorf(\"vexec only supports SELECT/INSERT/UPDATE/DELETE, got: %s\", stmt)\n}","typeGuard":null,"tryCatchPattern":"plan, err := buildControllerPlan(stmt, query, sidecar)\nif err != nil {\n    if strings.Contains(err.Error(), \"unsupported construct\") {\n        // fall back to running the statement directly on tablet MySQL\n    }\n    return err\n}","preventionTips":["Use vtctldclient workflow commands instead of raw DDL/VExec for stream management.","Restrict scripts to SELECT/INSERT/UPDATE/DELETE against _vt.vreplication.","Never send DDL, SET, or transactional statements through the vreplication engine."],"tags":["sql","vreplication","parser"],"backgroundTag":"unsupported-sql-construct","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}