@@ -57,26 +57,49 @@ type (
57
57
OrderAndLimit interface {
58
58
AddOrder (* Order )
59
59
SetLimit (* Limit )
60
+ GetOrderBy () OrderBy
61
+ SetOrderBy (OrderBy )
62
+ GetLimit () * Limit
63
+ }
64
+
65
+ TableStatement interface {
66
+ iTableStatement ()
67
+
68
+ InsertRows
69
+ Statement
70
+ OrderAndLimit
71
+ Commented
72
+ ColumnResults
73
+ Withable
74
+ }
75
+
76
+ ColumnResults interface {
77
+ GetColumnCount () int
78
+ GetColumns () SelectExprs
79
+ }
80
+
81
+ Withable interface {
82
+ SetWith (with * With )
83
+ }
84
+
85
+ Distinctable interface {
86
+ MakeDistinct ()
87
+ IsDistinct () bool
60
88
}
61
89
62
90
// SelectStatement any SELECT statement.
63
91
SelectStatement interface {
64
92
Statement
65
93
InsertRows
66
94
OrderAndLimit
95
+ Commented
96
+ ColumnResults
97
+ Withable
98
+ Distinctable
67
99
iSelectStatement ()
68
100
GetLock () Lock
69
101
SetLock (lock Lock )
70
102
SetInto (into * SelectInto )
71
- SetWith (with * With )
72
- MakeDistinct ()
73
- GetColumnCount () int
74
- GetColumns () SelectExprs
75
- Commented
76
- IsDistinct () bool
77
- GetOrderBy () OrderBy
78
- SetOrderBy (OrderBy )
79
- GetLimit () * Limit
80
103
}
81
104
82
105
// DDLStatement represents any DDL Statement
@@ -161,7 +184,7 @@ type (
161
184
CommonTableExpr struct {
162
185
ID IdentifierCS
163
186
Columns Columns
164
- Subquery SelectStatement
187
+ Subquery TableStatement
165
188
}
166
189
// ChangeColumn is used to change the column definition, can also rename the column in alter table command
167
190
ChangeColumn struct {
@@ -303,8 +326,8 @@ type (
303
326
// Union represents a UNION statement.
304
327
Union struct {
305
328
With * With
306
- Left SelectStatement
307
- Right SelectStatement
329
+ Left TableStatement
330
+ Right TableStatement
308
331
Distinct bool
309
332
OrderBy OrderBy
310
333
Limit * Limit
@@ -543,7 +566,7 @@ type (
543
566
Definer * Definer
544
567
Security string
545
568
Columns Columns
546
- Select SelectStatement
569
+ Select TableStatement
547
570
CheckOption string
548
571
IsReplace bool
549
572
Comments * ParsedComments
@@ -556,7 +579,7 @@ type (
556
579
Definer * Definer
557
580
Security string
558
581
Columns Columns
559
- Select SelectStatement
582
+ Select TableStatement
560
583
CheckOption string
561
584
Comments * ParsedComments
562
585
}
@@ -727,58 +750,63 @@ type (
727
750
var _ OrderAndLimit = (* Select )(nil )
728
751
var _ OrderAndLimit = (* Update )(nil )
729
752
var _ OrderAndLimit = (* Delete )(nil )
730
-
731
- func (* Union ) iStatement () {}
732
- func (* Select ) iStatement () {}
733
- func (* Stream ) iStatement () {}
734
- func (* VStream ) iStatement () {}
735
- func (* Insert ) iStatement () {}
736
- func (* Update ) iStatement () {}
737
- func (* Delete ) iStatement () {}
738
- func (* Set ) iStatement () {}
739
- func (* DropDatabase ) iStatement () {}
740
- func (* Flush ) iStatement () {}
741
- func (* Show ) iStatement () {}
742
- func (* Use ) iStatement () {}
743
- func (* Begin ) iStatement () {}
744
- func (* Commit ) iStatement () {}
745
- func (* Rollback ) iStatement () {}
746
- func (* SRollback ) iStatement () {}
747
- func (* Savepoint ) iStatement () {}
748
- func (* Release ) iStatement () {}
749
- func (* Analyze ) iStatement () {}
750
- func (* OtherAdmin ) iStatement () {}
751
- func (* CommentOnly ) iStatement () {}
752
- func (* Select ) iSelectStatement () {}
753
- func (* Union ) iSelectStatement () {}
754
- func (* Load ) iStatement () {}
755
- func (* CreateDatabase ) iStatement () {}
756
- func (* AlterDatabase ) iStatement () {}
757
- func (* CreateTable ) iStatement () {}
758
- func (* CreateView ) iStatement () {}
759
- func (* AlterView ) iStatement () {}
760
- func (* LockTables ) iStatement () {}
761
- func (* UnlockTables ) iStatement () {}
762
- func (* AlterTable ) iStatement () {}
763
- func (* AlterVschema ) iStatement () {}
764
- func (* AlterMigration ) iStatement () {}
765
- func (* RevertMigration ) iStatement () {}
766
- func (* ShowMigrationLogs ) iStatement () {}
767
- func (* ShowThrottledApps ) iStatement () {}
768
- func (* ShowThrottlerStatus ) iStatement () {}
769
- func (* DropTable ) iStatement () {}
770
- func (* DropView ) iStatement () {}
771
- func (* TruncateTable ) iStatement () {}
772
- func (* RenameTable ) iStatement () {}
773
- func (* CallProc ) iStatement () {}
774
- func (* ExplainStmt ) iStatement () {}
775
- func (* VExplainStmt ) iStatement () {}
776
- func (* ExplainTab ) iStatement () {}
777
- func (* PrepareStmt ) iStatement () {}
778
- func (* ExecuteStmt ) iStatement () {}
779
- func (* DeallocateStmt ) iStatement () {}
780
- func (* PurgeBinaryLogs ) iStatement () {}
781
- func (* Kill ) iStatement () {}
753
+ var _ OrderAndLimit = (* ValuesStatement )(nil )
754
+
755
+ func (* Union ) iStatement () {}
756
+ func (* Select ) iStatement () {}
757
+ func (* ValuesStatement ) iStatement () {}
758
+ func (* Stream ) iStatement () {}
759
+ func (* VStream ) iStatement () {}
760
+ func (* Insert ) iStatement () {}
761
+ func (* Update ) iStatement () {}
762
+ func (* Delete ) iStatement () {}
763
+ func (* Set ) iStatement () {}
764
+ func (* DropDatabase ) iStatement () {}
765
+ func (* Flush ) iStatement () {}
766
+ func (* Show ) iStatement () {}
767
+ func (* Use ) iStatement () {}
768
+ func (* Begin ) iStatement () {}
769
+ func (* Commit ) iStatement () {}
770
+ func (* Rollback ) iStatement () {}
771
+ func (* SRollback ) iStatement () {}
772
+ func (* Savepoint ) iStatement () {}
773
+ func (* Release ) iStatement () {}
774
+ func (* Analyze ) iStatement () {}
775
+ func (* OtherAdmin ) iStatement () {}
776
+ func (* CommentOnly ) iStatement () {}
777
+ func (* Select ) iSelectStatement () {}
778
+ func (* Select ) iTableStatement () {}
779
+ func (* ValuesStatement ) iSelectStatement () {}
780
+ func (* Union ) iSelectStatement () {}
781
+ func (* Union ) iTableStatement () {}
782
+ func (* Load ) iStatement () {}
783
+ func (* CreateDatabase ) iStatement () {}
784
+ func (* AlterDatabase ) iStatement () {}
785
+ func (* CreateTable ) iStatement () {}
786
+ func (* CreateView ) iStatement () {}
787
+ func (* AlterView ) iStatement () {}
788
+ func (* LockTables ) iStatement () {}
789
+ func (* UnlockTables ) iStatement () {}
790
+ func (* AlterTable ) iStatement () {}
791
+ func (* AlterVschema ) iStatement () {}
792
+ func (* AlterMigration ) iStatement () {}
793
+ func (* RevertMigration ) iStatement () {}
794
+ func (* ShowMigrationLogs ) iStatement () {}
795
+ func (* ShowThrottledApps ) iStatement () {}
796
+ func (* ShowThrottlerStatus ) iStatement () {}
797
+ func (* DropTable ) iStatement () {}
798
+ func (* DropView ) iStatement () {}
799
+ func (* TruncateTable ) iStatement () {}
800
+ func (* RenameTable ) iStatement () {}
801
+ func (* CallProc ) iStatement () {}
802
+ func (* ExplainStmt ) iStatement () {}
803
+ func (* VExplainStmt ) iStatement () {}
804
+ func (* ExplainTab ) iStatement () {}
805
+ func (* PrepareStmt ) iStatement () {}
806
+ func (* ExecuteStmt ) iStatement () {}
807
+ func (* DeallocateStmt ) iStatement () {}
808
+ func (* PurgeBinaryLogs ) iStatement () {}
809
+ func (* Kill ) iStatement () {}
782
810
783
811
func (* CreateView ) iDDLStatement () {}
784
812
func (* AlterView ) iDDLStatement () {}
@@ -1702,9 +1730,10 @@ type InsertRows interface {
1702
1730
SQLNode
1703
1731
}
1704
1732
1705
- func (* Select ) iInsertRows () {}
1706
- func (* Union ) iInsertRows () {}
1707
- func (Values ) iInsertRows () {}
1733
+ func (* Select ) iInsertRows () {}
1734
+ func (* Union ) iInsertRows () {}
1735
+ func (Values ) iInsertRows () {}
1736
+ func (* ValuesStatement ) iInsertRows () {}
1708
1737
1709
1738
// OptLike works for create table xxx like xxx
1710
1739
type OptLike struct {
@@ -2108,13 +2137,13 @@ type (
2108
2137
2109
2138
// Subquery represents a subquery used as an value expression.
2110
2139
Subquery struct {
2111
- Select SelectStatement
2140
+ Select TableStatement
2112
2141
}
2113
2142
2114
2143
// DerivedTable represents a subquery used as a table expression.
2115
2144
DerivedTable struct {
2116
2145
Lateral bool
2117
- Select SelectStatement
2146
+ Select TableStatement
2118
2147
}
2119
2148
)
2120
2149
@@ -3575,6 +3604,18 @@ type Limit struct {
3575
3604
// Values represents a VALUES clause.
3576
3605
type Values []ValTuple
3577
3606
3607
+ // ValuesStatement represents a VALUES statement, as in VALUES ROW(1, 2), ROW(3, 4)
3608
+ type ValuesStatement struct {
3609
+ With * With
3610
+ // One but not both of these fields can be set.
3611
+ Rows Values
3612
+ ListArg ListArg
3613
+
3614
+ Comments * ParsedComments
3615
+ Order OrderBy
3616
+ Limit * Limit
3617
+ }
3618
+
3578
3619
// UpdateExprs represents a list of update expressions.
3579
3620
type UpdateExprs []* UpdateExpr
3580
3621
0 commit comments