{"record":{"id":"91072a26319a5d35","repo":"vitessio/vitess","slug":"unsupported-non-select-statement","errorCode":null,"errorMessage":"unsupported non-select statement","messagePattern":"unsupported non-select statement","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vttablet/tabletmanager/vreplication/table_plan_builder.go","lineNumber":396,"sourceCode":"\t\tStats:                   tpb.stats,\n\t\tFieldsToSkip:            fieldsToSkip,\n\t\tHasExtraSourcePkColumns: len(tpb.extraSourcePkCols) > 0,\n\t\tTablePlanBuilder:        tpb,\n\t\tPartialInserts:          make(map[string]*sqlparser.ParsedQuery, 0),\n\t\tPartialUpdates:          make(map[string]*sqlparser.ParsedQuery, 0),\n\t\tCollationEnv:            tpb.collationEnv,\n\t\tWorkflowConfig:          tpb.workflowConfig,\n\t}\n}\n\nfunc analyzeSelectFrom(query string, parser *sqlparser.Parser) (sel *sqlparser.Select, from string, err error) {\n\tstatement, err := parser.Parse(query)\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\tsel, ok := statement.(*sqlparser.Select)\n\tif !ok {\n\t\treturn nil, \"\", errors.New(\"unsupported non-select statement\")\n\t}\n\tif sel.Distinct {\n\t\treturn nil, \"\", errors.New(\"unsupported distinct clause\")\n\t}\n\tif len(sel.From) == 0 {\n\t\treturn nil, \"\", errors.New(\"unsupported select from dual\")\n\t}\n\tif len(sel.From) > 1 {\n\t\treturn nil, \"\", errors.New(\"unsupported multi-table usage\")\n\t}\n\tnode, ok := sel.From[0].(*sqlparser.AliasedTableExpr)\n\tif !ok {\n\t\treturn nil, \"\", fmt.Errorf(\"unsupported from expression (%T)\", sel.From[0])\n\t}\n\tfromTable := sqlparser.GetTableName(node.Expr)\n\tif fromTable.IsEmpty() {\n\t\treturn nil, \"\", fmt.Errorf(\"unsupported from source (%T)\", node.Expr)\n\t}","sourceCodeStart":378,"sourceCodeEnd":414,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vttablet/tabletmanager/vreplication/table_plan_builder.go#L378-L414","documentation":"analyzeSelectFrom only accepts sqlparser.Select statements for vreplication filter rules. Any other statement type (INSERT, UPDATE, SET, SHOW, etc.) cannot define a replication source table and is rejected with this error.","triggerScenarios":"A filter rule query parses into a non-Select AST node, e.g. 'update t set ...', 'set @x=1', 'show tables', or a parenthesized/union construct that is not a plain *sqlparser.Select.","commonSituations":"Misconfigured filter rules accidentally containing DDL/DML; copy-paste of maintenance SQL into filter config; UNION queries that the builder cannot treat as a simple select.","solutions":["Use a simple single SELECT statement as the filter rule (e.g. 'select * from t where ...')","Remove any UPDATE/SET/SHOW/UNION statements from the filter configuration","For filtered rows, express the condition in the SELECT's WHERE clause instead"],"exampleFix":"// before\n\"filter\": \"update t set flag=1\"\n// after\n\"filter\": \"select * from t where flag=1\"","handlingStrategy":"validation","validationCode":"stmt, err := parser.Parse(filterQuery)\nif err != nil { return err }\nif _, ok := stmt.(*sqlparser.Select); !ok {\n    return errors.New(\"filter rule must be a SELECT\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only put single SELECT statements in filter rules","Handle row filtering via WHERE clauses, not DML/DDL","Validate all rule SQL in deployment scripts"],"tags":["vreplication","filter","sql-parsing"],"backgroundTag":"invalid-filter-rule","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}