From f64a3f0d53a1a08be24fd1902cb9aff3709c23f3 Mon Sep 17 00:00:00 2001 From: Zach Musgrave Date: Thu, 6 Nov 2025 16:29:36 -0800 Subject: [PATCH 1/2] Removed unnecessary RowIter implementations (handled by row exec builder) --- sql/plan/drop_role.go | 44 --------- sql/plan/drop_user.go | 38 -------- sql/plan/drop_view.go | 5 -- sql/plan/flush.go | 16 ---- sql/plan/join.go | 6 +- sql/plan/lock.go | 12 --- sql/plan/namedwindows.go | 5 -- sql/plan/nothing.go | 3 - sql/plan/prepare.go | 15 ---- sql/plan/rename_user.go | 5 -- sql/plan/revoke.go | 11 +-- sql/plan/show_charset.go | 46 ---------- sql/plan/show_create_procedure.go | 52 ----------- sql/plan/show_privileges.go | 72 --------------- sql/plan/signal.go | 47 ---------- sql/plan/transaction.go | 142 ------------------------------ sql/plan/unresolved.go | 5 -- sql/plan/values.go | 19 ---- sql/plan/with.go | 4 - sql/rowexec/other.go | 2 +- 20 files changed, 8 insertions(+), 541 deletions(-) diff --git a/sql/plan/drop_role.go b/sql/plan/drop_role.go index 5d54065bb7..bd5cd9242b 100644 --- a/sql/plan/drop_role.go +++ b/sql/plan/drop_role.go @@ -19,7 +19,6 @@ import ( "strings" "github.com/dolthub/go-mysql-server/sql" - "github.com/dolthub/go-mysql-server/sql/mysql_db" "github.com/dolthub/go-mysql-server/sql/types" ) @@ -100,46 +99,3 @@ func (n *DropRole) WithChildren(children ...sql.Node) (sql.Node, error) { func (*DropRole) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte) { return sql.Collation_binary, 7 } - -// RowIter implements the interface sql.Node. -func (n *DropRole) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) { - mysqlDb, ok := n.MySQLDb.(*mysql_db.MySQLDb) - if !ok { - return nil, sql.ErrDatabaseNotFound.New("mysql") - } - - editor := mysqlDb.Editor() - defer editor.Close() - - for _, role := range n.Roles { - userPk := mysql_db.UserPrimaryKey{ - Host: role.Host, - User: role.Name, - } - if role.AnyHost { - userPk.Host = "%" - } - existingUser, ok := editor.GetUser(userPk) - if !ok { - if n.IfExists { - continue - } - return nil, sql.ErrRoleDeletionFailure.New(role.String("'")) - } - - //TODO: if a role is mentioned in the "mandatory_roles" system variable then they cannot be dropped - editor.RemoveUser(userPk) - editor.RemoveRoleEdgesFromKey(mysql_db.RoleEdgesFromKey{ - FromHost: existingUser.Host, - FromUser: existingUser.User, - }) - editor.RemoveRoleEdgesToKey(mysql_db.RoleEdgesToKey{ - ToHost: existingUser.Host, - ToUser: existingUser.User, - }) - } - if err := mysqlDb.Persist(ctx, editor); err != nil { - return nil, err - } - return sql.RowsToRowIter(sql.Row{types.NewOkResult(0)}), nil -} diff --git a/sql/plan/drop_user.go b/sql/plan/drop_user.go index 40f4a4cd51..c9196fb9d7 100644 --- a/sql/plan/drop_user.go +++ b/sql/plan/drop_user.go @@ -18,7 +18,6 @@ import ( "fmt" "strings" - "github.com/dolthub/go-mysql-server/sql/mysql_db" "github.com/dolthub/go-mysql-server/sql/types" "github.com/dolthub/go-mysql-server/sql" @@ -101,40 +100,3 @@ func (n *DropUser) WithChildren(children ...sql.Node) (sql.Node, error) { func (*DropUser) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte) { return sql.Collation_binary, 7 } - -// RowIter implements the interface sql.Node. -func (n *DropUser) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) { - mysqlDb, ok := n.MySQLDb.(*mysql_db.MySQLDb) - if !ok { - return nil, sql.ErrDatabaseNotFound.New("mysql") - } - editor := mysqlDb.Editor() - defer editor.Close() - for _, user := range n.Users { - existingUser := mysqlDb.GetUser(editor, user.Name, user.Host, false) - if existingUser == nil { - if n.IfExists { - continue - } - return nil, sql.ErrUserDeletionFailure.New(user.String("'")) - } - - //TODO: if a user is mentioned in the "mandatory_roles" (users and roles are interchangeable) system variable then they cannot be dropped - editor.RemoveUser(mysql_db.UserPrimaryKey{ - Host: existingUser.Host, - User: existingUser.User, - }) - editor.RemoveRoleEdgesFromKey(mysql_db.RoleEdgesFromKey{ - FromHost: existingUser.Host, - FromUser: existingUser.User, - }) - editor.RemoveRoleEdgesToKey(mysql_db.RoleEdgesToKey{ - ToHost: existingUser.Host, - ToUser: existingUser.User, - }) - } - if err := mysqlDb.Persist(ctx, editor); err != nil { - return nil, err - } - return sql.RowsToRowIter(sql.Row{types.NewOkResult(0)}), nil -} diff --git a/sql/plan/drop_view.go b/sql/plan/drop_view.go index 7bf1794c2a..d334a04c4b 100644 --- a/sql/plan/drop_view.go +++ b/sql/plan/drop_view.go @@ -56,11 +56,6 @@ func (dv *SingleDropView) IsReadOnly() bool { return false } -// RowIter implements the Node interface. It always returns an empty iterator. -func (dv *SingleDropView) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) { - return sql.RowsToRowIter(), nil -} - // Schema implements the Node interface. It always returns nil. func (dv *SingleDropView) Schema() sql.Schema { return nil } diff --git a/sql/plan/flush.go b/sql/plan/flush.go index 8d48ca76c1..e84908c472 100644 --- a/sql/plan/flush.go +++ b/sql/plan/flush.go @@ -16,7 +16,6 @@ package plan import ( "github.com/dolthub/go-mysql-server/sql" - "github.com/dolthub/go-mysql-server/sql/mysql_db" "github.com/dolthub/go-mysql-server/sql/types" ) @@ -38,21 +37,6 @@ func NewFlushPrivileges(ft bool) *FlushPrivileges { } } -// RowIter implements the interface sql.Node. -func (f *FlushPrivileges) RowIter(ctx *sql.Context, _ sql.Row) (sql.RowIter, error) { - gts, ok := f.MysqlDb.(*mysql_db.MySQLDb) - if !ok { - return nil, sql.ErrDatabaseNotFound.New("mysql") - } - editor := gts.Editor() - defer editor.Close() - err := gts.Persist(ctx, editor) - if err != nil { - return nil, err - } - return sql.RowsToRowIter(sql.Row{types.NewOkResult(0)}), nil -} - // String implements the interface sql.Node. func (*FlushPrivileges) String() string { return "FLUSH PRIVILEGES" } diff --git a/sql/plan/join.go b/sql/plan/join.go index 87266034bb..600c752dff 100644 --- a/sql/plan/join.go +++ b/sql/plan/join.go @@ -471,10 +471,12 @@ func (j *JoinNode) Describe(options sql.DescribeOptions) string { } } children = append(children, sql.Describe(j.left, options), sql.Describe(j.right, options)) + comment := j.Comment() + if options.Estimates { - pr.WriteNode("%s %s", j.Op, j.GetDescribeStatsString(options)) + pr.WriteNode("%s %s%s", j.Op, j.GetDescribeStatsString(options), comment) } else { - pr.WriteNode("%s", j.Op) + pr.WriteNode("%s%s", j.Op, comment) } pr.WriteChildren(children...) return pr.String() diff --git a/sql/plan/lock.go b/sql/plan/lock.go index 0f70bfb7b4..a3bf5ab8cf 100644 --- a/sql/plan/lock.go +++ b/sql/plan/lock.go @@ -131,18 +131,6 @@ func (t *UnlockTables) IsReadOnly() bool { return true } // Schema implements the sql.Node interface. func (t *UnlockTables) Schema() sql.Schema { return nil } -// RowIter implements the sql.Node interface. -func (t *UnlockTables) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) { - span, ctx := ctx.Span("plan.UnlockTables") - defer span.End() - - if err := t.Catalog.UnlockTables(ctx, ctx.ID()); err != nil { - return nil, err - } - - return sql.RowsToRowIter(), nil -} - func (t *UnlockTables) String() string { p := sql.NewTreePrinter() _ = p.WriteNode("UnlockTables") diff --git a/sql/plan/namedwindows.go b/sql/plan/namedwindows.go index 17672759a6..8dc1abf676 100644 --- a/sql/plan/namedwindows.go +++ b/sql/plan/namedwindows.go @@ -75,11 +75,6 @@ func (n *NamedWindows) DebugString() string { return pr.String() } -// RowIter implements sql.Node -func (n *NamedWindows) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) { - panic("cannot iterate *plan.NamedWindows") -} - // WithChildren implements sql.Node func (n *NamedWindows) WithChildren(nodes ...sql.Node) (sql.Node, error) { if len(nodes) != 1 { diff --git a/sql/plan/nothing.go b/sql/plan/nothing.go index 2b0d10365b..b84fd66eda 100644 --- a/sql/plan/nothing.go +++ b/sql/plan/nothing.go @@ -29,9 +29,6 @@ func (Nothing) Resolved() bool { return true } func (Nothing) IsReadOnly() bool { return true } func (Nothing) Schema() sql.Schema { return nil } func (Nothing) Children() []sql.Node { return nil } -func (Nothing) RowIter(*sql.Context, sql.Row) (sql.RowIter, error) { - return sql.RowsToRowIter(), nil -} // WithChildren implements the Node interface. func (n Nothing) WithChildren(children ...sql.Node) (sql.Node, error) { diff --git a/sql/plan/prepare.go b/sql/plan/prepare.go index 6f840867f6..5089a4e296 100644 --- a/sql/plan/prepare.go +++ b/sql/plan/prepare.go @@ -60,11 +60,6 @@ func (pi PrepareInfo) String() string { return "Statement prepared" } -// RowIter implements the Node interface. -func (p *PrepareQuery) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) { - return sql.RowsToRowIter(sql.NewRow(types.OkResult{RowsAffected: 0, Info: PrepareInfo{}})), nil -} - func (p *PrepareQuery) Resolved() bool { return true } @@ -110,11 +105,6 @@ func (p *ExecuteQuery) Schema() sql.Schema { panic("ExecuteQuery methods shouldn't be used") } -// RowIter implements the Node interface. -func (p *ExecuteQuery) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) { - panic("ExecuteQuery methods shouldn't be used") -} - func (p *ExecuteQuery) Resolved() bool { panic("ExecuteQuery methods shouldn't be used") } @@ -160,11 +150,6 @@ func (p *DeallocateQuery) Schema() sql.Schema { return types.OkResultSchema } -// RowIter implements the Node interface. -func (p *DeallocateQuery) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) { - return sql.RowsToRowIter(sql.NewRow(types.OkResult{})), nil -} - func (p *DeallocateQuery) Resolved() bool { return true } diff --git a/sql/plan/rename_user.go b/sql/plan/rename_user.go index 0f8bc1afd9..f05b150cd3 100644 --- a/sql/plan/rename_user.go +++ b/sql/plan/rename_user.go @@ -80,8 +80,3 @@ func (n *RenameUser) WithChildren(children ...sql.Node) (sql.Node, error) { func (*RenameUser) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte) { return sql.Collation_binary, 7 } - -// RowIter implements the interface sql.Node. -func (n *RenameUser) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) { - return nil, fmt.Errorf("not yet implemented") -} diff --git a/sql/plan/revoke.go b/sql/plan/revoke.go index 7821a4dadc..2c335bacec 100644 --- a/sql/plan/revoke.go +++ b/sql/plan/revoke.go @@ -166,7 +166,7 @@ func (n *Revoke) CheckAuth(ctx *sql.Context, opChecker sql.PrivilegedOperationCh return opChecker.UserHasPrivileges(ctx, sql.NewPrivilegedOperation(subject, convertToSqlPrivilegeType(true, n.Privileges...)...)) } else { - //TODO: add column checks + // TODO: add column checks subject = sql.PrivilegeCheckSubject{ Database: n.PrivilegeLevel.Database, Table: n.PrivilegeLevel.TableRoutine, @@ -510,7 +510,7 @@ func (n *RevokeRole) CheckAuth(ctx *sql.Context, opChecker sql.PrivilegedOperati sql.NewPrivilegedOperation(sql.PrivilegeCheckSubject{}, sql.PrivilegeType_Super)) { return true } - //TODO: only active roles may be revoked if the SUPER privilege is not held + // TODO: only active roles may be revoked if the SUPER privilege is not held mysqlDb := n.MySQLDb.(*mysql_db.MySQLDb) client := ctx.Session.Client() @@ -606,7 +606,7 @@ func (n *RevokeProxy) WithChildren(children ...sql.Node) (sql.Node, error) { // CheckAuth implements the interface sql.AuthorizationCheckerNode. func (n *RevokeProxy) CheckAuth(ctx *sql.Context, opChecker sql.PrivilegedOperationChecker) bool { - //TODO: add this when proxy support is added + // TODO: add this when proxy support is added return true } @@ -614,8 +614,3 @@ func (n *RevokeProxy) CheckAuth(ctx *sql.Context, opChecker sql.PrivilegedOperat func (*RevokeProxy) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte) { return sql.Collation_binary, 7 } - -// RowIter implements the interface sql.Node. -func (n *RevokeProxy) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) { - return nil, fmt.Errorf("not yet implemented") -} diff --git a/sql/plan/show_charset.go b/sql/plan/show_charset.go index 79385a23bb..9e37de54f4 100644 --- a/sql/plan/show_charset.go +++ b/sql/plan/show_charset.go @@ -78,49 +78,3 @@ func (sc *ShowCharset) Children() []sql.Node { } return []sql.Node{sc.CharacterSetTable} } - -func (sc *ShowCharset) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) { - //TODO: use the information_schema table instead, currently bypassing it to show currently-implemented charsets - //ri, err := sc.CharacterSetTable.RowIter(ctx, row) - //if err != nil { - // return nil, err - //} - //return &showCharsetIter{originalIter: ri}, nil - - var rows []sql.Row - iter := sql.NewCharacterSetsIterator() - for charset, ok := iter.Next(); ok; charset, ok = iter.Next() { - if charset.Encoder != nil && charset.BinaryCollation.Sorter() != nil && charset.DefaultCollation.Sorter() != nil { - rows = append(rows, sql.Row{ - charset.Name, - charset.Description, - charset.DefaultCollation.String(), - uint64(charset.MaxLength), - }) - } - } - return sql.RowsToRowIter(rows...), nil -} - -type showCharsetIter struct { - originalIter sql.RowIter -} - -func (sci *showCharsetIter) Next(ctx *sql.Context) (sql.Row, error) { - row, err := sci.originalIter.Next(ctx) - if err != nil { - return nil, err - } - - // switch the ordering (see notes on Schema()) - defaultCollationName := row[1] - - row[1] = row[2] - row[2] = defaultCollationName - - return row, nil -} - -func (sci *showCharsetIter) Close(ctx *sql.Context) error { - return sci.originalIter.Close(ctx) -} diff --git a/sql/plan/show_create_procedure.go b/sql/plan/show_create_procedure.go index 3b10138d31..fc023ff60f 100644 --- a/sql/plan/show_create_procedure.go +++ b/sql/plan/show_create_procedure.go @@ -74,58 +74,6 @@ func (s *ShowCreateProcedure) Schema() sql.Schema { return showCreateProcedureSchema } -// RowIter implements the sql.Node interface. -func (s *ShowCreateProcedure) RowIter(ctx *sql.Context, _ sql.Row) (sql.RowIter, error) { - characterSetClient, err := ctx.GetSessionVariable(ctx, "character_set_client") - if err != nil { - return nil, err - } - collationConnection, err := ctx.GetSessionVariable(ctx, "collation_connection") - if err != nil { - return nil, err - } - collationServer, err := ctx.GetSessionVariable(ctx, "collation_server") - if err != nil { - return nil, err - } - - if s.ExternalStoredProcedure != nil { - // If an external stored procedure has been plugged in by the analyzer, use that - fakeCreateProcedureStmt := s.ExternalStoredProcedure.FakeCreateProcedureStmt() - return sql.RowsToRowIter(sql.Row{ - s.ExternalStoredProcedure.Name, // Procedure - "", // sql_mode - fakeCreateProcedureStmt, // Create Procedure - characterSetClient, // character_set_client - collationConnection, // collation_connection - collationServer, // Database Collation - }), nil - } else { - // Otherwise, search the StoredProcedureDatabase for a user-created stored procedure - procedureDb, ok := s.db.(sql.StoredProcedureDatabase) - if !ok { - return nil, sql.ErrStoredProceduresNotSupported.New(s.db.Name()) - } - procedures, err := procedureDb.GetStoredProcedures(ctx) - if err != nil { - return nil, err - } - for _, procedure := range procedures { - if strings.ToLower(procedure.Name) == s.ProcedureName { - return sql.RowsToRowIter(sql.Row{ - procedure.Name, // Procedure - "", // sql_mode - procedure.CreateStatement, // Create Procedure - characterSetClient, // character_set_client - collationConnection, // collation_connection - collationServer, // Database Collation - }), nil - } - } - return nil, sql.ErrStoredProcedureDoesNotExist.New(s.ProcedureName) - } -} - // WithChildren implements the sql.Node interface. func (s *ShowCreateProcedure) WithChildren(children ...sql.Node) (sql.Node, error) { return NillaryWithChildren(s, children...) diff --git a/sql/plan/show_privileges.go b/sql/plan/show_privileges.go index b0433cf48b..6810bd4e2e 100644 --- a/sql/plan/show_privileges.go +++ b/sql/plan/show_privileges.go @@ -70,75 +70,3 @@ func (n *ShowPrivileges) WithChildren(children ...sql.Node) (sql.Node, error) { func (*ShowPrivileges) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte) { return sql.Collation_binary, 7 } - -// RowIter implements the interface sql.Node. -func (n *ShowPrivileges) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) { - return sql.RowsToRowIter( - sql.Row{"Alter", "Tables", "To alter the table"}, - sql.Row{"Alter routine", "Functions,Procedures", "To alter or drop stored functions/procedures"}, - sql.Row{"Create", "Databases,Tables,Indexes", "To create new databases and tables"}, - sql.Row{"Create routine", "Databases", "To use CREATE FUNCTION/PROCEDURE"}, - sql.Row{"Create role", "Server Admin", "To create new roles"}, - sql.Row{"Create temporary tables", "Databases", "To use CREATE TEMPORARY TABLE"}, - sql.Row{"Create view", "Tables", "To create new views"}, - sql.Row{"Create user", "Server Admin", "To create new users"}, - sql.Row{"Delete", "Tables", "To delete existing rows"}, - sql.Row{"Drop", "Databases,Tables", "To drop databases, tables, and views"}, - sql.Row{"Drop role", "Server Admin", "To drop roles"}, - sql.Row{"Event", "Server Admin", "To create, alter, drop and execute events"}, - sql.Row{"Execute", "Functions,Procedures", "To execute stored routines"}, - sql.Row{"File", "File access on server", "To read and write files on the server"}, - sql.Row{"Grant option", "Databases,Tables,Functions,Procedures", "To give to other users those privileges you possess"}, - sql.Row{"Index", "Tables", "To create or drop indexes"}, - sql.Row{"Insert", "Tables", "To insert data into tables"}, - sql.Row{"Lock tables", "Databases", "To use LOCK TABLES (together with SELECT privilege)"}, - sql.Row{"Process", "Server Admin", "To view the plain text of currently executing queries"}, - sql.Row{"Proxy", "Server Admin", "To make proxy user possible"}, - sql.Row{"References", "Databases,Tables", "To have references on tables"}, - sql.Row{"Reload", "Server Admin", "To reload or refresh tables, logs and privileges"}, - sql.Row{"Replication client", "Server Admin", "To ask where the slave or master servers are"}, - sql.Row{"Replication slave", "Server Admin", "To read binary log events from the master"}, - sql.Row{"Select", "Tables", "To retrieve rows from table"}, - sql.Row{"Show databases", "Server Admin", "To see all databases with SHOW DATABASES"}, - sql.Row{"Show view", "Tables", "To see views with SHOW CREATE VIEW"}, - sql.Row{"Shutdown", "Server Admin", "To shut down the server"}, - sql.Row{"Super", "Server Admin", "To use KILL thread, SET GLOBAL, CHANGE MASTER, etc."}, - sql.Row{"Trigger", "Tables", "To use triggers"}, - sql.Row{"Create tablespace", "Server Admin", "To create/alter/drop tablespaces"}, - sql.Row{"Update", "Tables", "To update existing rows"}, - sql.Row{"Usage", "Server Admin", "No privileges - allow connect only"}, - sql.Row{"ENCRYPTION_KEY_ADMIN", "Server Admin", ""}, - sql.Row{"INNODB_REDO_LOG_ARCHIVE", "Server Admin", ""}, - sql.Row{"REPLICATION_APPLIER", "Server Admin", ""}, - sql.Row{"INNODB_REDO_LOG_ENABLE", "Server Admin", ""}, - sql.Row{"SET_USER_ID", "Server Admin", ""}, - sql.Row{"SERVICE_CONNECTION_ADMIN", "Server Admin", ""}, - sql.Row{"GROUP_REPLICATION_ADMIN", "Server Admin", ""}, - sql.Row{"AUDIT_ABORT_EXEMPT", "Server Admin", ""}, - sql.Row{"GROUP_REPLICATION_STREAM", "Server Admin", ""}, - sql.Row{"CLONE_ADMIN", "Server Admin", ""}, - sql.Row{"SYSTEM_USER", "Server Admin", ""}, - sql.Row{"AUTHENTICATION_POLICY_ADMIN", "Server Admin", ""}, - sql.Row{"SHOW_ROUTINE", "Server Admin", ""}, - sql.Row{"BACKUP_ADMIN", "Server Admin", ""}, - sql.Row{"CONNECTION_ADMIN", "Server Admin", ""}, - sql.Row{"PERSIST_RO_VARIABLES_ADMIN", "Server Admin", ""}, - sql.Row{"RESOURCE_GROUP_ADMIN", "Server Admin", ""}, - sql.Row{"SESSION_VARIABLES_ADMIN", "Server Admin", ""}, - sql.Row{"SYSTEM_VARIABLES_ADMIN", "Server Admin", ""}, - sql.Row{"APPLICATION_PASSWORD_ADMIN", "Server Admin", ""}, - sql.Row{"FLUSH_OPTIMIZER_COSTS", "Server Admin", ""}, - sql.Row{"AUDIT_ADMIN", "Server Admin", ""}, - sql.Row{"BINLOG_ADMIN", "Server Admin", ""}, - sql.Row{"BINLOG_ENCRYPTION_ADMIN", "Server Admin", ""}, - sql.Row{"FLUSH_STATUS", "Server Admin", ""}, - sql.Row{"FLUSH_TABLES", "Server Admin", ""}, - sql.Row{"FLUSH_USER_RESOURCES", "Server Admin", ""}, - sql.Row{"XA_RECOVER_ADMIN", "Server Admin", ""}, - sql.Row{"PASSWORDLESS_USER_ADMIN", "Server Admin", ""}, - sql.Row{"TABLE_ENCRYPTION_ADMIN", "Server Admin", ""}, - sql.Row{"ROLE_ADMIN", "Server Admin", ""}, - sql.Row{"REPLICATION_SLAVE_ADMIN", "Server Admin", ""}, - sql.Row{"RESOURCE_GROUP_USER", "Server Admin", ""}, - ), nil -} diff --git a/sql/plan/signal.go b/sql/plan/signal.go index 92ca77874a..3dca3cd1f2 100644 --- a/sql/plan/signal.go +++ b/sql/plan/signal.go @@ -19,8 +19,6 @@ import ( "sort" "strings" - "github.com/dolthub/vitess/go/mysql" - "github.com/dolthub/go-mysql-server/sql" ) @@ -259,46 +257,6 @@ func (*Signal) CollationCoercibility(ctx *sql.Context) (collation sql.CollationI return sql.Collation_binary, 7 } -// RowIter implements the sql.Node interface. -func (s *Signal) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) { - //TODO: implement CLASS_ORIGIN - //TODO: implement SUBCLASS_ORIGIN - //TODO: implement CONSTRAINT_CATALOG - //TODO: implement CONSTRAINT_SCHEMA - //TODO: implement CONSTRAINT_NAME - //TODO: implement CATALOG_NAME - //TODO: implement SCHEMA_NAME - //TODO: implement TABLE_NAME - //TODO: implement COLUMN_NAME - //TODO: implement CURSOR_NAME - if s.SqlStateValue[0:2] == "01" { - //TODO: implement warnings - return nil, fmt.Errorf("warnings not yet implemented") - } else { - - messageItem := s.Info[SignalConditionItemName_MessageText] - strValue := messageItem.StrValue - if messageItem.ExprVal != nil { - exprResult, err := messageItem.ExprVal.Eval(ctx, nil) - if err != nil { - return nil, err - } - s, ok := exprResult.(string) - if !ok { - return nil, fmt.Errorf("message text expression did not evaluate to a string") - } - strValue = s - } - - return nil, mysql.NewSQLError( - int(s.Info[SignalConditionItemName_MysqlErrno].IntValue), - s.SqlStateValue, - "%s", - strValue, - ) - } -} - // Resolved implements the sql.Node interface. func (s *SignalName) Resolved() bool { return true @@ -345,11 +303,6 @@ func (*SignalName) CollationCoercibility(ctx *sql.Context) (collation sql.Collat return sql.Collation_binary, 7 } -// RowIter implements the sql.Node interface. -func (s *SignalName) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) { - return nil, fmt.Errorf("may not iterate over unresolved node *SignalName") -} - func (s SignalInfo) IsReadOnly() bool { return true } diff --git a/sql/plan/transaction.go b/sql/plan/transaction.go index f3b7d5e1b9..356d7a4020 100644 --- a/sql/plan/transaction.go +++ b/sql/plan/transaction.go @@ -63,36 +63,6 @@ func NewStartTransaction(transactionChar sql.TransactionCharacteristic) *StartTr } } -// RowIter implements the sql.Node interface. -func (s *StartTransaction) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) { - ts, ok := ctx.Session.(sql.TransactionSession) - if !ok { - return sql.RowsToRowIter(), nil - } - - currentTx := ctx.GetTransaction() - // A START TRANSACTION statement commits any pending work before beginning a new tx - // TODO: this work is wasted in the case that START TRANSACTION is the first statement after COMMIT - // an isDirty method on the transaction would allow us to avoid this - if currentTx != nil { - err := ts.CommitTransaction(ctx, currentTx) - if err != nil { - return nil, err - } - } - - transaction, err := ts.StartTransaction(ctx, s.TransChar) - if err != nil { - return nil, err - } - - ctx.SetTransaction(transaction) - // until this transaction is committed or rolled back, don't begin or commit any transactions automatically - ctx.SetIgnoreAutoCommit(true) - - return sql.RowsToRowIter(), nil -} - func (s *StartTransaction) String() string { return "Start Transaction" } @@ -120,30 +90,6 @@ func NewCommit() *Commit { return &Commit{} } -// RowIter implements the sql.Node interface. -func (c *Commit) RowIter(ctx *sql.Context, _ sql.Row) (sql.RowIter, error) { - ts, ok := ctx.Session.(sql.TransactionSession) - if !ok { - return sql.RowsToRowIter(), nil - } - - transaction := ctx.GetTransaction() - - if transaction == nil { - return sql.RowsToRowIter(), nil - } - - err := ts.CommitTransaction(ctx, transaction) - if err != nil { - return nil, err - } - - ctx.SetIgnoreAutoCommit(false) - ctx.SetTransaction(nil) - - return sql.RowsToRowIter(), nil -} - func (*Commit) String() string { return "COMMIT" } // WithChildren implements the Node interface. @@ -169,31 +115,6 @@ func NewRollback() *Rollback { return &Rollback{} } -// RowIter implements the sql.Node interface. -func (r *Rollback) RowIter(ctx *sql.Context, _ sql.Row) (sql.RowIter, error) { - ts, ok := ctx.Session.(sql.TransactionSession) - if !ok { - return sql.RowsToRowIter(), nil - } - - transaction := ctx.GetTransaction() - - if transaction == nil { - return sql.RowsToRowIter(), nil - } - - err := ts.Rollback(ctx, transaction) - if err != nil { - return nil, err - } - - // Like Commit, Rollback ends the current transaction and a new one begins with the next statement - ctx.SetIgnoreAutoCommit(false) - ctx.SetTransaction(nil) - - return sql.RowsToRowIter(), nil -} - func (*Rollback) String() string { return "ROLLBACK" } // WithChildren implements the Node interface. @@ -220,27 +141,6 @@ func NewCreateSavepoint(name string) *CreateSavepoint { return &CreateSavepoint{Name: name} } -// RowIter implements the sql.Node interface. -func (c *CreateSavepoint) RowIter(ctx *sql.Context, _ sql.Row) (sql.RowIter, error) { - ts, ok := ctx.Session.(sql.TransactionSession) - if !ok { - return sql.RowsToRowIter(), nil - } - - transaction := ctx.GetTransaction() - - if transaction == nil { - return sql.RowsToRowIter(), nil - } - - err := ts.CreateSavepoint(ctx, transaction, c.Name) - if err != nil { - return nil, err - } - - return sql.RowsToRowIter(), nil -} - func (c *CreateSavepoint) String() string { return fmt.Sprintf("SAVEPOINT %s", c.Name) } // WithChildren implements the Node interface. @@ -269,27 +169,6 @@ func NewRollbackSavepoint(name string) *RollbackSavepoint { } } -// RowIter implements the sql.Node interface. -func (r *RollbackSavepoint) RowIter(ctx *sql.Context, _ sql.Row) (sql.RowIter, error) { - ts, ok := ctx.Session.(sql.TransactionSession) - if !ok { - return sql.RowsToRowIter(), nil - } - - transaction := ctx.GetTransaction() - - if transaction == nil { - return sql.RowsToRowIter(), nil - } - - err := ts.RollbackToSavepoint(ctx, transaction, r.Name) - if err != nil { - return nil, err - } - - return sql.RowsToRowIter(), nil -} - func (r *RollbackSavepoint) String() string { return fmt.Sprintf("ROLLBACK TO SAVEPOINT %s", r.Name) } // WithChildren implements the Node interface. @@ -318,27 +197,6 @@ func NewReleaseSavepoint(name string) *ReleaseSavepoint { } } -// RowIter implements the sql.Node interface. -func (r *ReleaseSavepoint) RowIter(ctx *sql.Context, _ sql.Row) (sql.RowIter, error) { - ts, ok := ctx.Session.(sql.TransactionSession) - if !ok { - return sql.RowsToRowIter(), nil - } - - transaction := ctx.GetTransaction() - - if transaction == nil { - return sql.RowsToRowIter(), nil - } - - err := ts.ReleaseSavepoint(ctx, transaction, r.Name) - if err != nil { - return nil, err - } - - return sql.RowsToRowIter(), nil -} - func (r *ReleaseSavepoint) String() string { return fmt.Sprintf("RELEASE SAVEPOINT %s", r.Name) } // WithChildren implements the Node interface. diff --git a/sql/plan/unresolved.go b/sql/plan/unresolved.go index fe6cc838b8..c60da02043 100644 --- a/sql/plan/unresolved.go +++ b/sql/plan/unresolved.go @@ -91,11 +91,6 @@ func (*UnresolvedTable) Children() []sql.Node { return nil } // Schema implements the Node interface. func (*UnresolvedTable) Schema() sql.Schema { return nil } -// RowIter implements the RowIter interface. -func (*UnresolvedTable) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) { - return nil, ErrUnresolvedTable.New() -} - // WithChildren implements the Node interface. func (t *UnresolvedTable) WithChildren(children ...sql.Node) (sql.Node, error) { if len(children) != 0 { diff --git a/sql/plan/values.go b/sql/plan/values.go index b0a55eec27..0cd764f317 100644 --- a/sql/plan/values.go +++ b/sql/plan/values.go @@ -86,25 +86,6 @@ func (p *Values) IsReadOnly() bool { return true } -// RowIter implements the Node interface. -func (p *Values) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) { - rows := make([]sql.Row, len(p.ExpressionTuples)) - for i, et := range p.ExpressionTuples { - vals := make([]interface{}, len(et)) - for j, e := range et { - var err error - vals[j], err = e.Eval(ctx, row) - if err != nil { - return nil, err - } - } - - rows[i] = sql.NewRow(vals...) - } - - return sql.RowsToRowIter(rows...), nil -} - func (p *Values) String() string { var sb strings.Builder sb.WriteString("Values(") diff --git a/sql/plan/with.go b/sql/plan/with.go index d6da3df35a..e0f46bb702 100644 --- a/sql/plan/with.go +++ b/sql/plan/with.go @@ -73,10 +73,6 @@ func (w *With) DebugString() string { return pr.String() } -func (w *With) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) { - panic("Cannot call RowIter on With node") -} - func (w *With) WithChildren(children ...sql.Node) (sql.Node, error) { if len(children) != 1 { return nil, sql.ErrInvalidChildrenNumber.New(w, len(children), 1) diff --git a/sql/rowexec/other.go b/sql/rowexec/other.go index 793caf5016..5eacc932d3 100644 --- a/sql/rowexec/other.go +++ b/sql/rowexec/other.go @@ -94,7 +94,7 @@ func (b *BaseBuilder) buildFetch(ctx *sql.Context, n *plan.Fetch, row sql.Row) ( } func (b *BaseBuilder) buildSignalName(ctx *sql.Context, n *plan.SignalName, row sql.Row) (sql.RowIter, error) { - return nil, fmt.Errorf("%T has no exchange iterator", n) + return nil, fmt.Errorf("%T has no execution iterator", n) } func (b *BaseBuilder) buildRepeat(ctx *sql.Context, n *plan.Repeat, row sql.Row) (sql.RowIter, error) { From 9900acc6084e489a0eb27ad80c852fcef1182655 Mon Sep 17 00:00:00 2001 From: Zach Musgrave Date: Thu, 6 Nov 2025 16:43:50 -0800 Subject: [PATCH 2/2] Fix test --- enginetest/engine_only_test.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/enginetest/engine_only_test.go b/enginetest/engine_only_test.go index a378424c4b..ca4f005784 100644 --- a/enginetest/engine_only_test.go +++ b/enginetest/engine_only_test.go @@ -357,10 +357,7 @@ func TestUnlockTables(t *testing.T) { catalog.LockTable(ctx, "foo") catalog.LockTable(ctx, "bar") - node := plan.NewUnlockTables() - node.Catalog = catalog - - _, err := node.RowIter(ctx, nil) + err := catalog.UnlockTables(ctx, ctx.ID()) require.NoError(err) require.Equal(1, t1.unlocks)