{"record":{"id":"09adc5945256bb28","repo":"vitessio/vitess","slug":"query-not-supported-by-vexec-s","errorCode":null,"errorMessage":"query not supported by vexec: %s","messagePattern":"query not supported by vexec: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/wrangler/vexec_plan.go","lineNumber":319,"sourceCode":"\tdel.Where = vx.addDefaultWheres(planner, del.Where)\n\n\tbuf := sqlparser.NewTrackedBuffer(nil)\n\tbuf.Myprintf(\"%v\", del)\n\n\treturn &vexecPlan{\n\t\topcode:      deleteQuery,\n\t\tparsedQuery: buf.ParsedQuery(),\n\t}, nil\n}\n\n// buildInsertPlan builds a plan for a INSERT query\nfunc (vx *vexec) buildInsertPlan(ctx context.Context, planner vexecPlanner, ins *sqlparser.Insert) (*vexecPlan, error) {\n\tplannerParams := planner.params()\n\ttemplates := plannerParams.insertTemplates\n\tif len(templates) == 0 {\n\t\t// at this time INSERT is only supported if an insert template exists\n\t\t// Remove this conditional if there's any new case for INSERT\n\t\treturn nil, fmt.Errorf(\"query not supported by vexec: %s\", sqlparser.String(ins))\n\t}\n\tif len(templates) > 0 {\n\t\tmatch, err := vx.wr.env.Parser().QueryMatchesTemplates(vx.query, templates)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif !match {\n\t\t\treturn nil, fmt.Errorf(\"Query must match one of these templates: %s\", strings.Join(templates, \"; \"))\n\t\t}\n\t}\n\n\tbuf := sqlparser.NewTrackedBuffer(nil)\n\tbuf.Myprintf(\"%v\", ins)\n\n\treturn &vexecPlan{\n\t\topcode:      insertQuery,\n\t\tparsedQuery: buf.ParsedQuery(),\n\t}, nil","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/wrangler/vexec_plan.go#L301-L337","documentation":"buildInsertPlan only supports INSERT when the planner has insertTemplates configured for the target table; without a template there is no validated rewrite of the INSERT for sharded execution, so vexec refuses the query outright.","triggerScenarios":"Calling vexec with an INSERT statement while planner.params().insertTemplates is empty for the resolved table/planner — any INSERT hits this when no template exists.","commonSituations":"Using vexec as a generic SQL runner on a table whose planner was configured for UPDATE/DELETE only; new vexec use-cases added before an INSERT template was defined (the code comment even invites removing this conditional when a new INSERT case exists).","solutions":["Configure insertTemplates for the planner/table so the INSERT matches a supported shape","Route INSERTs through VTGate (normal query serving) instead of vexec","If adding a new supported INSERT case to vexec, replace this conditional with the real implementation"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if len(planner.params().insertTemplates) == 0 {\n    return fmt.Errorf(\"vexec INSERT not supported for this table; use VTGate\")\n}","typeGuard":null,"tryCatchPattern":"if err := vexecExec(ctx, insQuery); err != nil {\n    if strings.Contains(err.Error(), \"query not supported by vexec\") {\n        // fall back to VTGate-based insert path\n    }\n    return err\n}","preventionTips":["Only plan INSERTs on tables whose planner defines insertTemplates","Route bulk inserts through VTGate instead of vexec","Check planner params before choosing vexec as execution path"],"tags":["sql","insert","vexec"],"backgroundTag":"unsupported-sql-construct","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}