From b16d4d8ffa088ce19ce9fffa322dc02ac6599a53 Mon Sep 17 00:00:00 2001 From: yisaer Date: Tue, 13 Dec 2022 17:55:44 +0800 Subject: [PATCH] fix --- executor/executor_test.go | 1 + executor/plan_replayer.go | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/executor/executor_test.go b/executor/executor_test.go index 59e70022727d5..28a46b25faa62 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -87,6 +87,7 @@ func checkFileName(s string) bool { "global_bindings.sql", "sql/sql0.sql", "explain/sql0.txt", + "sql_meta.txt", } for _, f := range files { if strings.Compare(f, s) == 0 { diff --git a/executor/plan_replayer.go b/executor/plan_replayer.go index 6bd58077f1db4..6dcee1efc624c 100644 --- a/executor/plan_replayer.go +++ b/executor/plan_replayer.go @@ -381,21 +381,23 @@ func createSchemaAndItems(ctx sessionctx.Context, f *zip.File) error { if err != nil { return errors.AddStack(err) } - sqls := strings.Split(buf.String(), ";") - if len(sqls) != 3 { - return errors.New("plan replayer: create schema and tables failed") - } + originText := buf.String() + index1 := strings.Index(originText, ";") + createDatabaseSQL := originText[:index1+1] + index2 := strings.Index(originText[index1+1:], ";") + useDatabaseSQL := originText[index1+1:][:index2+1] + createTableSQL := originText[index1+1:][index2+1:] c := context.Background() // create database if not exists - _, err = ctx.(sqlexec.SQLExecutor).Execute(c, sqls[0]) + _, err = ctx.(sqlexec.SQLExecutor).Execute(c, createDatabaseSQL) logutil.BgLogger().Debug("plan replayer: skip error", zap.Error(err)) // use database - _, err = ctx.(sqlexec.SQLExecutor).Execute(c, sqls[1]) + _, err = ctx.(sqlexec.SQLExecutor).Execute(c, useDatabaseSQL) if err != nil { return err } // create table or view - _, err = ctx.(sqlexec.SQLExecutor).Execute(c, sqls[2]) + _, err = ctx.(sqlexec.SQLExecutor).Execute(c, createTableSQL) if err != nil { return err }