Skip to content

Commit

Permalink
check variable starts with '@' for select expression assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
jennifersp committed Nov 8, 2023
1 parent 4944d40 commit d01a48a
Show file tree
Hide file tree
Showing 4 changed files with 5,190 additions and 5,154 deletions.
5 changes: 5 additions & 0 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -4745,6 +4745,7 @@ func (*ConvertUsingExpr) iExpr() {}
func (*MatchExpr) iExpr() {}
func (*GroupConcatExpr) iExpr() {}
func (*Default) iExpr() {}
func (*SetVarExpr) iExpr() {}

// ReplaceExpr finds the from expression from root
// and replaces it with to. If from matches root,
Expand Down Expand Up @@ -6661,6 +6662,10 @@ func (node *SetVarExpr) walkSubtree(visit Visit) error {
)
}

func (node *SetVarExpr) replace(from, to Expr) bool {
return false
}

// OnDup represents an ON DUPLICATE KEY clause.
type OnDup AssignmentExprs

Expand Down
6 changes: 6 additions & 0 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3235,6 +3235,9 @@ var (
}, {
input: "ALTER TABLE webhook_events ADD COLUMN event varchar(255) DEFAULT NULL;",
output: "alter table webhook_events add column (\n\t`event` varchar(255) default null\n)",
}, {
input: "select @id := 1",
output: "select @id = 1",
},
// Create Spatial Reference System Statements
{
Expand Down Expand Up @@ -6783,6 +6786,9 @@ var (
}, {
input: "ALTER DEFINER = `newuser`@`localhost` EVENT myevent",
output: "You have an error in your SQL syntax; At least one event field to alter needs to be defined at position 52 near 'myevent'",
}, {
input: "select id := 1",
output: "syntax error at position 15 near '1'",
},
}

Expand Down
Loading

0 comments on commit d01a48a

Please sign in to comment.