Skip to content

Commit

Permalink
feat: add a test and fail assignment expressions
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <manan@planetscale.com>
  • Loading branch information
GuptaManan100 committed Feb 12, 2025
1 parent c47f1bd commit 18da991
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion go/vt/sqlparser/normalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ func newNormalizer(
// It handles normalization logic based on node types.
func (nz *normalizer) walkDown(node, _ SQLNode) bool {
switch node := node.(type) {
case *Begin, *Commit, *Rollback, *Savepoint, *SRollback, *Release, *OtherAdmin, *Analyze, *AssignmentExpr,
case *AssignmentExpr:
nz.err = vterrors.VT12001("Assignment expression")
return false
case *Begin, *Commit, *Rollback, *Savepoint, *SRollback, *Release, *OtherAdmin, *Analyze,
*PrepareStmt, *ExecuteStmt, *FramePoint, *ColName, TableName, *ConvertType:
// These statement don't need normalizing
return false
Expand Down
5 changes: 5 additions & 0 deletions go/vt/vtgate/planbuilder/testdata/unsupported_cases.json
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@
"query": "select @val := 42",
"plan": "VT12001: unsupported: Assignment expression"
},
{
"comment": "Assignment expression in on duplicate clause",
"query": "insert into unsharded (id) values (@val := 42)",
"plan": "VT12001: unsupported: Assignment expression"
},
{
"comment": "Assignment expression in union statements",
"query": "select @val := 42 union select 1",
Expand Down

0 comments on commit 18da991

Please sign in to comment.