Skip to content

Commit

Permalink
Support for 'legacy' (MySQL 5.7.31 at this time) env for fakesqldb; a…
Browse files Browse the repository at this point in the history
…dd 'Legacy' tests in engine_test

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
  • Loading branch information
shlomi-noach committed Nov 7, 2024
1 parent 27608c6 commit 25949d4
Show file tree
Hide file tree
Showing 5 changed files with 623 additions and 171 deletions.
1 change: 1 addition & 0 deletions go/mysql/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ package config

const DefaultSQLMode = "ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
const DefaultMySQLVersion = "8.0.30"
const LegacyMySQLVersion = "5.7.31"
7 changes: 6 additions & 1 deletion go/mysql/fakesqldb/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ type ExpectedExecuteFetch struct {

// New creates a server, and starts listening.
func New(t testing.TB) *DB {
return NewWithEnv(t, vtenv.NewTestEnv())
}

// NewWithEnv creates a server, and starts listening.
func NewWithEnv(t testing.TB, env *vtenv.Environment) *DB {
// Pick a path for our socket.
socketDir, err := os.MkdirTemp("", "fakesqldb")
if err != nil {
Expand All @@ -185,7 +190,7 @@ func New(t testing.TB) *DB {
queryPatternUserCallback: make(map[*regexp.Regexp]func(string)),
patternData: make(map[string]exprResult),
lastErrorMu: sync.Mutex{},
env: vtenv.NewTestEnv(),
env: env,
}

db.Handler = db
Expand Down
6 changes: 6 additions & 0 deletions go/vt/vtenv/vtenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ func NewTestEnv() *Environment {
}
}

func NewLegacyTestEnv() *Environment {
env := NewTestEnv()
env.mysqlVersion = config.LegacyMySQLVersion
return env
}

func (e *Environment) CollationEnv() *collations.Environment {
return e.collationEnv
}
Expand Down
Loading

0 comments on commit 25949d4

Please sign in to comment.