diff --git a/go/test/endtoend/vtgate/queries/misc/misc_test.go b/go/test/endtoend/vtgate/queries/misc/misc_test.go index 7ab0fe7ef54..17be4628c56 100644 --- a/go/test/endtoend/vtgate/queries/misc/misc_test.go +++ b/go/test/endtoend/vtgate/queries/misc/misc_test.go @@ -687,3 +687,10 @@ func TestSemiJoin(t *testing.T) { }) } } + +func TestValues(t *testing.T) { + mcmp, closer := start(t) + defer closer() + + mcmp.Exec("VALUES ROW(1, 2, 3), ROW(4, 5, 6)") +} diff --git a/go/vt/sqlparser/ast.go b/go/vt/sqlparser/ast.go index f08ae54021c..a71ce46b51c 100644 --- a/go/vt/sqlparser/ast.go +++ b/go/vt/sqlparser/ast.go @@ -56,7 +56,10 @@ type ( OrderAndLimit interface { AddOrder(*Order) + GetOrderBy() OrderBy + SetOrderBy(OrderBy) SetLimit(*Limit) + GetLimit() *Limit } // SelectStatement any SELECT statement. @@ -64,19 +67,28 @@ type ( Statement InsertRows OrderAndLimit + Commented + Lockable + ReturnsResults + Distinctable iSelectStatement() - GetLock() Lock - SetLock(lock Lock) SetInto(into *SelectInto) SetWith(with *With) - MakeDistinct() + } + + Lockable interface { + GetLock() Lock + SetLock(lock Lock) + } + + ReturnsResults interface { GetColumnCount() int GetColumns() SelectExprs - Commented + } + + Distinctable interface { + MakeDistinct() IsDistinct() bool - GetOrderBy() OrderBy - SetOrderBy(OrderBy) - GetLimit() *Limit } // DDLStatement represents any DDL Statement @@ -3581,7 +3593,6 @@ type Values []ValTuple // ValuesStatement represents a VALUES statement, as in VALUES ROW(1, 2), ROW(3, 4) type ValuesStatement struct { - With *With // One but not both of these fields can be set. Rows Values ListArg ListArg diff --git a/go/vt/sqlparser/ast_funcs.go b/go/vt/sqlparser/ast_funcs.go index 7cc3038fe50..8859f20cf5d 100644 --- a/go/vt/sqlparser/ast_funcs.go +++ b/go/vt/sqlparser/ast_funcs.go @@ -2875,6 +2875,18 @@ func (node *Update) SetLimit(limit *Limit) { node.Limit = limit } +func (node *Update) GetOrderBy() OrderBy { + return node.OrderBy +} + +func (node *Update) SetOrderBy(by OrderBy) { + node.OrderBy = by +} + +func (node *Update) GetLimit() *Limit { + return node.Limit +} + func (node *Delete) AddOrder(order *Order) { node.OrderBy = append(node.OrderBy, order) } @@ -2883,6 +2895,18 @@ func (node *Delete) SetLimit(limit *Limit) { node.Limit = limit } +func (node *Delete) GetOrderBy() OrderBy { + return node.OrderBy +} + +func (node *Delete) SetOrderBy(by OrderBy) { + node.OrderBy = by +} + +func (node *Delete) GetLimit() *Limit { + return node.Limit +} + func (node *Select) GetFrom() []TableExpr { return node.From } @@ -2982,30 +3006,6 @@ func ExtractAllTables(stmt Statement) []string { return tables } -var _ SelectStatement = (*ValuesStatement)(nil) - -func (node *ValuesStatement) GetLock() Lock { - return NoLock -} - -func (node *ValuesStatement) SetLock(lock Lock) { - if lock != NoLock { - panic("cannot set lock on Values statement") - } -} - -func (node *ValuesStatement) SetInto(into *SelectInto) { - panic("cannot set Into on Values statement") -} - -func (node *ValuesStatement) SetWith(with *With) { - node.With = with -} - -func (node *ValuesStatement) MakeDistinct() { - panic("cannot set Distinct on Values statement") -} - func (node *ValuesStatement) GetColumnCount() int { panic("cannot call Column count on Values statement") }