Skip to content

Commit e9af3e2

Browse files
committed
Merge branch 'main' of https://github.com/dolthub/go-mysql-server into angela/funcdeps
2 parents cac6646 + 312762f commit e9af3e2

26 files changed

+25
-555
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)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/dolthub/go-icu-regex v0.0.0-20250916051405-78a38d478790
77
github.com/dolthub/jsonpath v0.0.2-0.20240227200619-19675ab05c71
88
github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81
9-
github.com/dolthub/vitess v0.0.0-20251105091622-b08b393fd9b1
9+
github.com/dolthub/vitess v0.0.0-20251107003339-843d10a6a8d4
1010
github.com/go-sql-driver/mysql v1.9.3
1111
github.com/gocraft/dbr/v2 v2.7.2
1212
github.com/google/uuid v1.3.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ github.com/dolthub/vitess v0.0.0-20251031205214-d09b65bd77b0 h1:RXopPQP1bwb5fsnX
2222
github.com/dolthub/vitess v0.0.0-20251031205214-d09b65bd77b0/go.mod h1:FLWqdXsAeeBQyFwDjmBVu0GnbjI2MKeRf3tRVdJEKlI=
2323
github.com/dolthub/vitess v0.0.0-20251105091622-b08b393fd9b1 h1:2uiHo4gkf2n/Cw9uCBDkCWj35Vz48Uhif2B9P+DqgCg=
2424
github.com/dolthub/vitess v0.0.0-20251105091622-b08b393fd9b1/go.mod h1:FLWqdXsAeeBQyFwDjmBVu0GnbjI2MKeRf3tRVdJEKlI=
25+
github.com/dolthub/vitess v0.0.0-20251107003339-843d10a6a8d4 h1:vOF5qPLC0Yd4BN/FKJlRLNELIZZlev40TrckORQqzhA=
26+
github.com/dolthub/vitess v0.0.0-20251107003339-843d10a6a8d4/go.mod h1:FLWqdXsAeeBQyFwDjmBVu0GnbjI2MKeRf3tRVdJEKlI=
2527
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
2628
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
2729
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=

server/handler.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,10 @@ func (h *Handler) resultForDefaultIter(ctx *sql.Context, c *mysql.Conn, schema s
702702
defer wg.Done()
703703
for {
704704
if r == nil {
705-
r = &sqltypes.Result{Fields: resultFields}
705+
r = &sqltypes.Result{
706+
Fields: resultFields,
707+
Rows: make([][]sqltypes.Value, 0, rowsBatch),
708+
}
706709
}
707710
if r.RowsAffected == rowsBatch {
708711
if err := resetCallback(r, more); err != nil {

sql/analyzer/costed_index_scan.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,11 @@ func costedIndexLookup(ctx *sql.Context, n sql.Node, a *Analyzer, iat sql.IndexA
141141
ret = plan.NewTableAlias(aliasName, ret)
142142
}
143143

144-
a.Log("new indexed table: %s/%s/%s", ita.Index().Database(), ita.Index().Table(), ita.Index().ID())
145-
a.Log("index stats cnt: %d", stats.RowCount())
146-
a.Log("index stats histogram: %s", stats.Histogram().DebugString())
144+
if a.Debug {
145+
a.Log("new indexed table: %s/%s/%s", ita.Index().Database(), ita.Index().Table(), ita.Index().ID())
146+
a.Log("index stats cnt: %d", stats.RowCount())
147+
a.Log("index stats histogram: %s", stats.Histogram().DebugString())
148+
}
147149

148150
// excluded from tree + not included in index scan => filter above scan
149151
if len(filters) > 0 {

sql/mysql_db/auth.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package mysql_db
1717
import (
1818
"bytes"
1919
"crypto/sha1"
20-
"crypto/x509"
2120
"encoding/hex"
2221
"net"
2322

@@ -108,7 +107,7 @@ var _ mysql.CachingStorage = (*noopCachingStorage)(nil)
108107
//
109108
// This implementation also handles authentication when a client doesn't send an auth response and
110109
// the associated user account does not have a password set.
111-
func (n noopCachingStorage) UserEntryWithCacheHash(_ []*x509.Certificate, _ []byte, user string, authResponse []byte, remoteAddr net.Addr) (mysql.Getter, mysql.CacheState, error) {
110+
func (n noopCachingStorage) UserEntryWithCacheHash(_ *mysql.Conn, _ []byte, user string, authResponse []byte, remoteAddr net.Addr) (mysql.Getter, mysql.CacheState, error) {
112111
db := n.db
113112

114113
// If there is no mysql database of user info, then don't approve or reject, since we can't look at
@@ -167,7 +166,7 @@ var _ mysql.PlainTextStorage = (*sha2PlainTextStorage)(nil)
167166

168167
// UserEntryWithPassword implements the mysql.PlainTextStorage interface.
169168
// The auth framework in Vitess also passes in user certificates, but we don't support that feature yet.
170-
func (s sha2PlainTextStorage) UserEntryWithPassword(_ []*x509.Certificate, user string, password string, remoteAddr net.Addr) (mysql.Getter, error) {
169+
func (s sha2PlainTextStorage) UserEntryWithPassword(_ *mysql.Conn, user string, password string, remoteAddr net.Addr) (mysql.Getter, error) {
171170
db := s.db
172171

173172
host, err := extractHostAddress(remoteAddr)
@@ -230,7 +229,7 @@ var _ mysql.PlainTextStorage = (*extendedAuthPlainTextStorage)(nil)
230229
// UserEntryWithPassword implements the mysql.PlainTextStorage interface. This method is called by the
231230
// MySQL clear password auth method to authenticate a user with a custom PlaintextAuthPlugin that was
232231
// previously registered with the MySQLDb instance.
233-
func (f extendedAuthPlainTextStorage) UserEntryWithPassword(userCerts []*x509.Certificate, user string, password string, remoteAddr net.Addr) (mysql.Getter, error) {
232+
func (f extendedAuthPlainTextStorage) UserEntryWithPassword(conn *mysql.Conn, user string, password string, remoteAddr net.Addr) (mysql.Getter, error) {
234233
db := f.db
235234

236235
host, err := extractHostAddress(remoteAddr)
@@ -330,7 +329,7 @@ var _ mysql.HashStorage = (*nativePasswordHashStorage)(nil)
330329

331330
// UserEntryWithHash implements the mysql.HashStorage interface. This implementation is called by the MySQL
332331
// native password auth method to validate a password hash with the user's stored password hash.
333-
func (nphs *nativePasswordHashStorage) UserEntryWithHash(_ []*x509.Certificate, salt []byte, user string, authResponse []byte, remoteAddr net.Addr) (mysql.Getter, error) {
332+
func (nphs *nativePasswordHashStorage) UserEntryWithHash(_ *mysql.Conn, salt []byte, user string, authResponse []byte, remoteAddr net.Addr) (mysql.Getter, error) {
334333
db := nphs.db
335334

336335
host, err := extractHostAddress(remoteAddr)

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

0 commit comments

Comments
 (0)