Skip to content

Commit a9e1469

Browse files
author
James Cor
committed
changing can persist to validatecanepersist
1 parent 90e07e8 commit a9e1469

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

enginetest/enginetests.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5399,8 +5399,8 @@ type memoryPersister struct {
53995399

54005400
var _ mysql_db.MySQLDbPersistence = &memoryPersister{}
54015401

5402-
func (p *memoryPersister) CanPersist() bool {
5403-
return true
5402+
func (p *memoryPersister) ValidateCanPersist() error {
5403+
return nil
54045404
}
54055405

54065406
func (p *memoryPersister) Persist(ctx *sql.Context, data []byte) error {

sql/mysql_db/mysql_db.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232

3333
// MySQLDbPersistence is used to determine the behavior of how certain tables in MySQLDb will be persisted.
3434
type MySQLDbPersistence interface {
35-
CanPersist() bool
35+
ValidateCanPersist() error
3636
Persist(ctx *sql.Context, data []byte) error
3737
}
3838

@@ -42,8 +42,8 @@ type NoopPersister struct{}
4242
var _ MySQLDbPersistence = &NoopPersister{}
4343

4444
// CanPersist implements the MySQLDbPersistence interface
45-
func (p *NoopPersister) CanPersist() bool {
46-
return true
45+
func (p *NoopPersister) ValidateCanPersist() error {
46+
return nil
4747
}
4848

4949
// Persist implements the MySQLDbPersistence interface
@@ -349,8 +349,8 @@ func (t *MySQLDb) Negotiate(c *mysql.Conn, user string, addr net.Addr) (mysql.Ge
349349
}
350350

351351
// CanPersist calls the persister's CanPersist method
352-
func (t *MySQLDb) CanPersist() bool {
353-
return t.persister.CanPersist()
352+
func (t *MySQLDb) ValidateCanPersist() error {
353+
return t.persister.ValidateCanPersist()
354354
}
355355

356356
// Persist passes along all changes to the integrator.

sql/plan/create_role.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ func (n *CreateRole) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error)
108108
}
109109

110110
// Check if you can even persist in the first place
111-
if !mysqlDb.CanPersist() {
112-
return nil, fmt.Errorf("no privilege file specified, to persist users/grants run with --privilege-file=<file_path>")
111+
if err := mysqlDb.ValidateCanPersist(); err != nil {
112+
return nil, err
113113
}
114114

115115
userTableData := mysqlDb.UserTable().Data()

sql/plan/create_user.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ func (n *CreateUser) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error)
101101
return nil, sql.ErrDatabaseNotFound.New("mysql")
102102
}
103103
// Check if you can even persist in the first place
104-
if !mysqlDb.CanPersist() {
105-
return nil, fmt.Errorf("no privilege file specified, to persist users/grants run with --privilege-file=<file_path>")
104+
if err := mysqlDb.ValidateCanPersist(); err != nil {
105+
return nil, err
106106
}
107107
userTableData := mysqlDb.UserTable().Data()
108108
for _, user := range n.Users {

0 commit comments

Comments
 (0)