vitessio/vitess · error
only the integer literal 1 is supported
Error message
only the integer literal 1 is supported
What it means
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".
Source
Thrown at go/vt/vttablet/tabletserver/vstreamer/planbuilder.go:909
plan.setColumnFuncExpr(field.Name, inner)
return ColExpr{
ColNum: colnum,
Field: field,
}, nil
default:
return ColExpr{}, fmt.Errorf("unsupported function: %v", sqlparser.String(inner))
}
case *sqlparser.Literal:
// allow only intval 1
if inner.Type != sqlparser.IntVal {
return ColExpr{}, errors.New("only integer literals are supported")
}
num, err := strconv.ParseInt(string(inner.Val), 0, 64)
if err != nil {
return ColExpr{}, err
}
if num != 1 {
return ColExpr{}, errors.New("only the integer literal 1 is supported")
}
return ColExpr{
Field: &querypb.Field{
Name: "1",
Type: querypb.Type_INT64,
Charset: collations.CollationBinaryID,
Flags: uint32(querypb.MySqlFlag_NOT_NULL_FLAG | querypb.MySqlFlag_NUM_FLAG),
},
ColNum: -1,
FixedValue: sqltypes.NewInt64(num),
}, nil
case *sqlparser.ConvertUsingExpr:
// Here we find the actual column name in the convert, in case
// this is a column rename and the AS is the new column.
// For example, in convert(c1 using utf8mb4) as c2, we want to find
// c1, because c1 exists in the current table whereas c2 is the renamed column
// in the desired table.
var colName sqlparser.IdentifierCIView on GitHub (pinned to 01a25a7d17)
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.
Example fix
// before where := "0" // only 1 is supported // after where := "1"
Defensive patterns
Strategy: validation
Validate before calling
// only bare integer literal 1 is permitted as a constant in filter where clauses
if lit.Type == sqlparser.IntVal && lit.Val != "1" { return errors.New("constant must be 1") } Type guard
func isLiteralOne(lit *sqlparser.Literal) bool {
if lit == nil || lit.Type != sqlparser.IntVal { return false }
n, err := strconv.ParseInt(string(lit.Val), 0, 64)
return err == nil && n == 1
} Try / catch
if err != nil && strings.Contains(err.Error(), "only the integer literal 1 is supported") {
return fmt.Errorf("invalid constant in VReplication filter: %w", err)
} Prevention
- 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.
When it happens
Trigger: 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."
Common situations: Hand-written filters using constants like 0 or 2; generated filters where users tried to toggle filtering on/off by changing the literal.
Related errors
- only integer literals are supported
- unexpected: %v
- unsupported qualifier for column: %v
- VStreamer is not open
- VStreamer is not open
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/e6248fb61dd5526f.
Report an issue: GitHub.