14
14
15
15
package plan
16
16
17
- import "github.com/dolthub/go-mysql-server/sql"
17
+ import (
18
+ "io"
19
+
20
+ "github.com/dolthub/go-mysql-server/sql"
21
+ )
18
22
19
23
func IsEmptyTable (n sql.Node ) bool {
20
24
_ , ok := n .(* EmptyTable )
@@ -26,6 +30,7 @@ func NewEmptyTableWithSchema(schema sql.Schema) sql.Node {
26
30
27
31
var _ sql.Node = (* EmptyTable )(nil )
28
32
var _ sql.CollationCoercible = (* EmptyTable )(nil )
33
+ var _ sql.UpdatableTable = (* EmptyTable )(nil )
29
34
30
35
type EmptyTable struct {
31
36
schema sql.Schema
@@ -37,11 +42,12 @@ func (*EmptyTable) Children() []sql.Node { return nil }
37
42
func (* EmptyTable ) Resolved () bool { return true }
38
43
func (e * EmptyTable ) String () string { return "EmptyTable" }
39
44
45
+ // RowIter implements the sql.Node interface.
40
46
func (* EmptyTable ) RowIter (ctx * sql.Context , row sql.Row ) (sql.RowIter , error ) {
41
47
return sql .RowsToRowIter (), nil
42
48
}
43
49
44
- // WithChildren implements the Node interface.
50
+ // WithChildren implements the sql. Node interface.
45
51
func (e * EmptyTable ) WithChildren (children ... sql.Node ) (sql.Node , error ) {
46
52
if len (children ) != 0 {
47
53
return nil , sql .ErrInvalidChildrenNumber .New (e , len (children ), 0 )
@@ -59,3 +65,78 @@ func (e *EmptyTable) CheckPrivileges(ctx *sql.Context, opChecker sql.PrivilegedO
59
65
func (* EmptyTable ) CollationCoercibility (ctx * sql.Context ) (collation sql.CollationID , coercibility byte ) {
60
66
return sql .Collation_binary , 7
61
67
}
68
+
69
+ // Updater implements the sql.UpdatableTable interface.
70
+ func (e * EmptyTable ) Updater (ctx * sql.Context ) sql.RowUpdater {
71
+ return & emptyTableUpdater {}
72
+ }
73
+
74
+ // Collation implements the sql.UpdatableTable interface.
75
+ func (e * EmptyTable ) Collation () sql.CollationID {
76
+ return sql .Collation_Default
77
+ }
78
+
79
+ // Partitions implements the sql.UpdatableTable interface.
80
+ func (e * EmptyTable ) Partitions (_ * sql.Context ) (sql.PartitionIter , error ) {
81
+ return & emptyTablePartitionIter {}, nil
82
+ }
83
+
84
+ // PartitionRows implements the sql.UpdatableTable interface.
85
+ func (e * EmptyTable ) PartitionRows (_ * sql.Context , _ sql.Partition ) (sql.RowIter , error ) {
86
+ return & emptyTableIter {}, nil
87
+ }
88
+
89
+ type emptyTableUpdater struct {}
90
+
91
+ var _ sql.RowUpdater = (* emptyTableUpdater )(nil )
92
+
93
+ // StatementBegin implements the sql.EditOpenerCloser interface
94
+ func (e * emptyTableUpdater ) StatementBegin (_ * sql.Context ) {}
95
+
96
+ // DiscardChanges implements the sql.EditOpenerCloser interface
97
+ func (e * emptyTableUpdater ) DiscardChanges (_ * sql.Context , _ error ) error {
98
+ return nil
99
+ }
100
+
101
+ // StatementComplete implements the sql.EditOpenerCloser interface
102
+ func (e * emptyTableUpdater ) StatementComplete (_ * sql.Context ) error {
103
+ return nil
104
+ }
105
+
106
+ // Update implements the sql.RowUpdater interface
107
+ func (e * emptyTableUpdater ) Update (_ * sql.Context , _ sql.Row , _ sql.Row ) error {
108
+ return nil
109
+ }
110
+
111
+ // Close implements the sql.Closer interface
112
+ func (e * emptyTableUpdater ) Close (_ * sql.Context ) error {
113
+ return nil
114
+ }
115
+
116
+ type emptyTableIter struct {}
117
+
118
+ var _ sql.RowIter = (* emptyTableIter )(nil )
119
+
120
+ // Next implements the sql.RowIter interface.
121
+ func (e * emptyTableIter ) Next (_ * sql.Context ) (sql.Row , error ) {
122
+ return nil , io .EOF
123
+ }
124
+
125
+ // Close implements the sql.RowIter interface.
126
+ func (e * emptyTableIter ) Close (_ * sql.Context ) error {
127
+ return nil
128
+ }
129
+
130
+ type emptyTablePartitionIter struct {}
131
+
132
+ var _ sql.PartitionIter = (* emptyTablePartitionIter )(nil )
133
+
134
+ // Close implements the sql.PartitionIter interface.
135
+ func (e * emptyTablePartitionIter ) Close (_ * sql.Context ) error {
136
+ return nil
137
+ }
138
+
139
+ // Next implements the sql.PartitionIter interface.
140
+ func (e * emptyTablePartitionIter ) Next (_ * sql.Context ) (sql.Partition , error ) {
141
+ return nil , io .EOF
142
+ }
0 commit comments