Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
systay committed Jan 13, 2025
1 parent e6e8bf3 commit c76009c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 32 deletions.
7 changes: 7 additions & 0 deletions go/test/endtoend/vtgate/queries/misc/misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
}
27 changes: 19 additions & 8 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,39 @@ type (

OrderAndLimit interface {
AddOrder(*Order)
GetOrderBy() OrderBy
SetOrderBy(OrderBy)
SetLimit(*Limit)
GetLimit() *Limit
}

// SelectStatement any SELECT statement.
SelectStatement interface {
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
Expand Down Expand Up @@ -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
Expand Down
48 changes: 24 additions & 24 deletions go/vt/sqlparser/ast_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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")
}
Expand Down

0 comments on commit c76009c

Please sign in to comment.