{"record":{"id":"e6248fb61dd5526f","repo":"vitessio/vitess","slug":"only-the-integer-literal-1-is-supported","errorCode":null,"errorMessage":"only the integer literal 1 is supported","messagePattern":"only the integer literal 1 is supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vttablet/tabletserver/vstreamer/planbuilder.go","lineNumber":909,"sourceCode":"\t\t\tplan.setColumnFuncExpr(field.Name, inner)\n\t\t\treturn ColExpr{\n\t\t\t\tColNum: colnum,\n\t\t\t\tField:  field,\n\t\t\t}, nil\n\t\tdefault:\n\t\t\treturn ColExpr{}, fmt.Errorf(\"unsupported function: %v\", sqlparser.String(inner))\n\t\t}\n\tcase *sqlparser.Literal:\n\t\t// allow only intval 1\n\t\tif inner.Type != sqlparser.IntVal {\n\t\t\treturn ColExpr{}, errors.New(\"only integer literals are supported\")\n\t\t}\n\t\tnum, err := strconv.ParseInt(string(inner.Val), 0, 64)\n\t\tif err != nil {\n\t\t\treturn ColExpr{}, err\n\t\t}\n\t\tif num != 1 {\n\t\t\treturn ColExpr{}, errors.New(\"only the integer literal 1 is supported\")\n\t\t}\n\t\treturn ColExpr{\n\t\t\tField: &querypb.Field{\n\t\t\t\tName:    \"1\",\n\t\t\t\tType:    querypb.Type_INT64,\n\t\t\t\tCharset: collations.CollationBinaryID,\n\t\t\t\tFlags:   uint32(querypb.MySqlFlag_NOT_NULL_FLAG | querypb.MySqlFlag_NUM_FLAG),\n\t\t\t},\n\t\t\tColNum:     -1,\n\t\t\tFixedValue: sqltypes.NewInt64(num),\n\t\t}, nil\n\tcase *sqlparser.ConvertUsingExpr:\n\t\t// Here we find the actual column name in the convert, in case\n\t\t// this is a column rename and the AS is the new column.\n\t\t// For example, in convert(c1 using utf8mb4) as c2, we want to find\n\t\t// c1, because c1 exists in the current table whereas c2 is the renamed column\n\t\t// in the desired table.\n\t\tvar colName sqlparser.IdentifierCI","sourceCodeStart":891,"sourceCodeEnd":927,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vttablet/tabletserver/vstreamer/planbuilder.go#L891-L927","documentation":"After confirming a literal is an integer, analyzeExpr additionally requires its parsed value to be exactly 1. This supports the planbuilder's boolean '1' constant (used for always-true predicates); any other integer (0, 2, 42) in the filter where expression returns \"only the integer literal 1 is supported\".","triggerScenarios":"A VReplication filter where clause containing a constant integer other than 1, e.g. \"where: \"1 = 1\" is fine but \"where: \"0\" or comparisons reducing to a bare non-1 integer literal hit this error.\"","commonSituations":"Hand-written filters using constants like 0 or 2; generated filters where users tried to toggle filtering on/off by changing the literal.","solutions":["Change the constant in the where clause to the integer literal 1 (the only supported constant).","Remove the constant-based predicate and rely on column comparisons or in/keyrange filters.","Consult the planbuilder grammar (go/vt/vttablet/tabletserver/vstreamer/planbuilder.go) for supported filter expressions before writing custom where clauses."],"exampleFix":"// before\nwhere := \"0\" // only 1 is supported\n// after\nwhere := \"1\"","handlingStrategy":"validation","validationCode":"// only bare integer literal 1 is permitted as a constant in filter where clauses\nif lit.Type == sqlparser.IntVal && lit.Val != \"1\" { return errors.New(\"constant must be 1\") }","typeGuard":"func isLiteralOne(lit *sqlparser.Literal) bool {\n  if lit == nil || lit.Type != sqlparser.IntVal { return false }\n  n, err := strconv.ParseInt(string(lit.Val), 0, 64)\n  return err == nil && n == 1\n}","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"only the integer literal 1 is supported\") {\n  return fmt.Errorf(\"invalid constant in VReplication filter: %w\", err)\n}","preventionTips":["Use the literal 1 for always-true predicates in VReplication filters.","Do not encode flags/toggles as other constants in filter where clauses.","Test filter plans with planbuilder unit tests before production use."],"tags":["vitess","vstreamer","planbuilder","filter"],"backgroundTag":"unsupported-expression","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}