diff --git a/pkg/session/bootstrap.go b/pkg/session/bootstrap.go index d8c8127170208..7fc5197e9b311 100644 --- a/pkg/session/bootstrap.go +++ b/pkg/session/bootstrap.go @@ -49,6 +49,7 @@ import ( "github.com/pingcap/tidb/pkg/util/intest" "github.com/pingcap/tidb/pkg/util/logutil" "github.com/pingcap/tidb/pkg/util/sqlescape" + "github.com/pingcap/tidb/pkg/util/sqlexec" "go.uber.org/zap" ) @@ -1042,13 +1043,9 @@ func upgrade(s sessiontypes.Session) { // initGlobalVariableIfNotExists initialize a global variable with specific val if it does not exist. func initGlobalVariableIfNotExists(s sessiontypes.Session, name string, val any) { ctx := kv.WithInternalSourceType(context.Background(), kv.InternalTxnBootstrap) - rs, err := s.ExecuteInternal(ctx, "SELECT VARIABLE_VALUE FROM %n.%n WHERE VARIABLE_NAME=%?;", - mysql.SystemDB, mysql.GlobalVariablesTable, name) + rows, err := sqlexec.ExecSQL(ctx, s, "SELECT VARIABLE_VALUE FROM %n.%n WHERE VARIABLE_NAME=%?;", mysql.SystemDB, mysql.GlobalVariablesTable, name) terror.MustNil(err) - req := rs.NewChunk(nil) - err = rs.Next(ctx, req) - terror.MustNil(err) - if req.NumRows() != 0 { + if len(rows) != 0 { return } diff --git a/pkg/session/bootstrap_test.go b/pkg/session/bootstrap_test.go index 74d6417fdb3c4..51bb2f3ae782f 100644 --- a/pkg/session/bootstrap_test.go +++ b/pkg/session/bootstrap_test.go @@ -2323,6 +2323,20 @@ func TestTiDBUpgradeToVer212(t *testing.T) { MustExec(t, seCurVer, "select sample_sql, start_time, plan_digest from mysql.tidb_runaway_queries") } +func TestIssue61890(t *testing.T) { + store, dom := CreateStoreAndBootstrap(t) + defer func() { require.NoError(t, store.Close()) }() + + s1 := CreateSessionAndSetID(t, store) + MustExec(t, s1, "drop table mysql.global_variables") + MustExec(t, s1, "create table mysql.global_variables(`VARIABLE_NAME` varchar(64) NOT NULL PRIMARY KEY clustered, `VARIABLE_VALUE` varchar(16383) DEFAULT NULL)") + + s2 := CreateSessionAndSetID(t, store) + initGlobalVariableIfNotExists(s2, vardef.TiDBEnableINLJoinInnerMultiPattern, vardef.Off) + + dom.Close() +} + func TestIndexJoinMultiPatternByUpgrade650To840(t *testing.T) { ctx := context.Background() store, dom := CreateStoreAndBootstrap(t)