Skip to content

Commit 312762f

Browse files
authored
Merge pull request #3294 from dolthub/zachmu/row-exec
[no-release-notes] Removed unnecessary RowIter implementations (handled by row exec builder
2 parents 7f4380b + 9900acc commit 312762f

21 files changed

+9
-545
lines changed

enginetest/engine_only_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,7 @@ func TestUnlockTables(t *testing.T) {
357357
catalog.LockTable(ctx, "foo")
358358
catalog.LockTable(ctx, "bar")
359359

360-
node := plan.NewUnlockTables()
361-
node.Catalog = catalog
362-
363-
_, err := node.RowIter(ctx, nil)
360+
err := catalog.UnlockTables(ctx, ctx.ID())
364361
require.NoError(err)
365362

366363
require.Equal(1, t1.unlocks)

sql/plan/drop_role.go

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"strings"
2020

2121
"github.com/dolthub/go-mysql-server/sql"
22-
"github.com/dolthub/go-mysql-server/sql/mysql_db"
2322
"github.com/dolthub/go-mysql-server/sql/types"
2423
)
2524

@@ -100,46 +99,3 @@ func (n *DropRole) WithChildren(children ...sql.Node) (sql.Node, error) {
10099
func (*DropRole) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte) {
101100
return sql.Collation_binary, 7
102101
}
103-
104-
// RowIter implements the interface sql.Node.
105-
func (n *DropRole) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) {
106-
mysqlDb, ok := n.MySQLDb.(*mysql_db.MySQLDb)
107-
if !ok {
108-
return nil, sql.ErrDatabaseNotFound.New("mysql")
109-
}
110-
111-
editor := mysqlDb.Editor()
112-
defer editor.Close()
113-
114-
for _, role := range n.Roles {
115-
userPk := mysql_db.UserPrimaryKey{
116-
Host: role.Host,
117-
User: role.Name,
118-
}
119-
if role.AnyHost {
120-
userPk.Host = "%"
121-
}
122-
existingUser, ok := editor.GetUser(userPk)
123-
if !ok {
124-
if n.IfExists {
125-
continue
126-
}
127-
return nil, sql.ErrRoleDeletionFailure.New(role.String("'"))
128-
}
129-
130-
//TODO: if a role is mentioned in the "mandatory_roles" system variable then they cannot be dropped
131-
editor.RemoveUser(userPk)
132-
editor.RemoveRoleEdgesFromKey(mysql_db.RoleEdgesFromKey{
133-
FromHost: existingUser.Host,
134-
FromUser: existingUser.User,
135-
})
136-
editor.RemoveRoleEdgesToKey(mysql_db.RoleEdgesToKey{
137-
ToHost: existingUser.Host,
138-
ToUser: existingUser.User,
139-
})
140-
}
141-
if err := mysqlDb.Persist(ctx, editor); err != nil {
142-
return nil, err
143-
}
144-
return sql.RowsToRowIter(sql.Row{types.NewOkResult(0)}), nil
145-
}

sql/plan/drop_user.go

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"fmt"
1919
"strings"
2020

21-
"github.com/dolthub/go-mysql-server/sql/mysql_db"
2221
"github.com/dolthub/go-mysql-server/sql/types"
2322

2423
"github.com/dolthub/go-mysql-server/sql"
@@ -101,40 +100,3 @@ func (n *DropUser) WithChildren(children ...sql.Node) (sql.Node, error) {
101100
func (*DropUser) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte) {
102101
return sql.Collation_binary, 7
103102
}
104-
105-
// RowIter implements the interface sql.Node.
106-
func (n *DropUser) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) {
107-
mysqlDb, ok := n.MySQLDb.(*mysql_db.MySQLDb)
108-
if !ok {
109-
return nil, sql.ErrDatabaseNotFound.New("mysql")
110-
}
111-
editor := mysqlDb.Editor()
112-
defer editor.Close()
113-
for _, user := range n.Users {
114-
existingUser := mysqlDb.GetUser(editor, user.Name, user.Host, false)
115-
if existingUser == nil {
116-
if n.IfExists {
117-
continue
118-
}
119-
return nil, sql.ErrUserDeletionFailure.New(user.String("'"))
120-
}
121-
122-
//TODO: if a user is mentioned in the "mandatory_roles" (users and roles are interchangeable) system variable then they cannot be dropped
123-
editor.RemoveUser(mysql_db.UserPrimaryKey{
124-
Host: existingUser.Host,
125-
User: existingUser.User,
126-
})
127-
editor.RemoveRoleEdgesFromKey(mysql_db.RoleEdgesFromKey{
128-
FromHost: existingUser.Host,
129-
FromUser: existingUser.User,
130-
})
131-
editor.RemoveRoleEdgesToKey(mysql_db.RoleEdgesToKey{
132-
ToHost: existingUser.Host,
133-
ToUser: existingUser.User,
134-
})
135-
}
136-
if err := mysqlDb.Persist(ctx, editor); err != nil {
137-
return nil, err
138-
}
139-
return sql.RowsToRowIter(sql.Row{types.NewOkResult(0)}), nil
140-
}

sql/plan/drop_view.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@ func (dv *SingleDropView) IsReadOnly() bool {
5656
return false
5757
}
5858

59-
// RowIter implements the Node interface. It always returns an empty iterator.
60-
func (dv *SingleDropView) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) {
61-
return sql.RowsToRowIter(), nil
62-
}
63-
6459
// Schema implements the Node interface. It always returns nil.
6560
func (dv *SingleDropView) Schema() sql.Schema { return nil }
6661

sql/plan/flush.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package plan
1616

1717
import (
1818
"github.com/dolthub/go-mysql-server/sql"
19-
"github.com/dolthub/go-mysql-server/sql/mysql_db"
2019
"github.com/dolthub/go-mysql-server/sql/types"
2120
)
2221

@@ -38,21 +37,6 @@ func NewFlushPrivileges(ft bool) *FlushPrivileges {
3837
}
3938
}
4039

41-
// RowIter implements the interface sql.Node.
42-
func (f *FlushPrivileges) RowIter(ctx *sql.Context, _ sql.Row) (sql.RowIter, error) {
43-
gts, ok := f.MysqlDb.(*mysql_db.MySQLDb)
44-
if !ok {
45-
return nil, sql.ErrDatabaseNotFound.New("mysql")
46-
}
47-
editor := gts.Editor()
48-
defer editor.Close()
49-
err := gts.Persist(ctx, editor)
50-
if err != nil {
51-
return nil, err
52-
}
53-
return sql.RowsToRowIter(sql.Row{types.NewOkResult(0)}), nil
54-
}
55-
5640
// String implements the interface sql.Node.
5741
func (*FlushPrivileges) String() string { return "FLUSH PRIVILEGES" }
5842

sql/plan/join.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,10 +471,12 @@ func (j *JoinNode) Describe(options sql.DescribeOptions) string {
471471
}
472472
}
473473
children = append(children, sql.Describe(j.left, options), sql.Describe(j.right, options))
474+
comment := j.Comment()
475+
474476
if options.Estimates {
475-
pr.WriteNode("%s %s", j.Op, j.GetDescribeStatsString(options))
477+
pr.WriteNode("%s %s%s", j.Op, j.GetDescribeStatsString(options), comment)
476478
} else {
477-
pr.WriteNode("%s", j.Op)
479+
pr.WriteNode("%s%s", j.Op, comment)
478480
}
479481
pr.WriteChildren(children...)
480482
return pr.String()

sql/plan/lock.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -131,18 +131,6 @@ func (t *UnlockTables) IsReadOnly() bool { return true }
131131
// Schema implements the sql.Node interface.
132132
func (t *UnlockTables) Schema() sql.Schema { return nil }
133133

134-
// RowIter implements the sql.Node interface.
135-
func (t *UnlockTables) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) {
136-
span, ctx := ctx.Span("plan.UnlockTables")
137-
defer span.End()
138-
139-
if err := t.Catalog.UnlockTables(ctx, ctx.ID()); err != nil {
140-
return nil, err
141-
}
142-
143-
return sql.RowsToRowIter(), nil
144-
}
145-
146134
func (t *UnlockTables) String() string {
147135
p := sql.NewTreePrinter()
148136
_ = p.WriteNode("UnlockTables")

sql/plan/namedwindows.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,6 @@ func (n *NamedWindows) DebugString() string {
7575
return pr.String()
7676
}
7777

78-
// RowIter implements sql.Node
79-
func (n *NamedWindows) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) {
80-
panic("cannot iterate *plan.NamedWindows")
81-
}
82-
8378
// WithChildren implements sql.Node
8479
func (n *NamedWindows) WithChildren(nodes ...sql.Node) (sql.Node, error) {
8580
if len(nodes) != 1 {

sql/plan/nothing.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ func (Nothing) Resolved() bool { return true }
2929
func (Nothing) IsReadOnly() bool { return true }
3030
func (Nothing) Schema() sql.Schema { return nil }
3131
func (Nothing) Children() []sql.Node { return nil }
32-
func (Nothing) RowIter(*sql.Context, sql.Row) (sql.RowIter, error) {
33-
return sql.RowsToRowIter(), nil
34-
}
3532

3633
// WithChildren implements the Node interface.
3734
func (n Nothing) WithChildren(children ...sql.Node) (sql.Node, error) {

sql/plan/prepare.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ func (pi PrepareInfo) String() string {
6060
return "Statement prepared"
6161
}
6262

63-
// RowIter implements the Node interface.
64-
func (p *PrepareQuery) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) {
65-
return sql.RowsToRowIter(sql.NewRow(types.OkResult{RowsAffected: 0, Info: PrepareInfo{}})), nil
66-
}
67-
6863
func (p *PrepareQuery) Resolved() bool {
6964
return true
7065
}
@@ -110,11 +105,6 @@ func (p *ExecuteQuery) Schema() sql.Schema {
110105
panic("ExecuteQuery methods shouldn't be used")
111106
}
112107

113-
// RowIter implements the Node interface.
114-
func (p *ExecuteQuery) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) {
115-
panic("ExecuteQuery methods shouldn't be used")
116-
}
117-
118108
func (p *ExecuteQuery) Resolved() bool {
119109
panic("ExecuteQuery methods shouldn't be used")
120110
}
@@ -160,11 +150,6 @@ func (p *DeallocateQuery) Schema() sql.Schema {
160150
return types.OkResultSchema
161151
}
162152

163-
// RowIter implements the Node interface.
164-
func (p *DeallocateQuery) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) {
165-
return sql.RowsToRowIter(sql.NewRow(types.OkResult{})), nil
166-
}
167-
168153
func (p *DeallocateQuery) Resolved() bool {
169154
return true
170155
}

0 commit comments

Comments
 (0)