Skip to content

Commit 83510d1

Browse files
authored
planner: skip check AllowCartesianProduct for internal SQL (#55286)
close #55250
1 parent b22d1ea commit 83510d1

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

pkg/planner/core/optimizer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ func doOptimize(
288288
return nil, nil, 0, err
289289
}
290290

291-
if !AllowCartesianProduct.Load() && existsCartesianProduct(logic) {
291+
if !sctx.GetSessionVars().InRestrictedSQL && !AllowCartesianProduct.Load() && existsCartesianProduct(logic) {
292292
return nil, nil, 0, errors.Trace(plannererrors.ErrCartesianProductUnsupported)
293293
}
294294
planCounter := PlanCounterTp(sessVars.StmtCtx.StmtHints.ForceNthPlan)

pkg/session/bootstraptest/BUILD.bazel

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ go_test(
88
"main_test.go",
99
],
1010
flaky = True,
11-
shard_count = 11,
11+
shard_count = 12,
1212
deps = [
1313
"//pkg/config",
1414
"//pkg/ddl",
@@ -17,6 +17,7 @@ go_test(
1717
"//pkg/meta",
1818
"//pkg/parser/model",
1919
"//pkg/parser/terror",
20+
"//pkg/planner/core",
2021
"//pkg/server/handler",
2122
"//pkg/session", #keep
2223
"//pkg/session/types",

pkg/session/bootstraptest/bootstrap_upgrade_test.go

+17
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/pingcap/tidb/pkg/meta"
3232
"github.com/pingcap/tidb/pkg/parser/model"
3333
"github.com/pingcap/tidb/pkg/parser/terror"
34+
plannercore "github.com/pingcap/tidb/pkg/planner/core"
3435
"github.com/pingcap/tidb/pkg/server/handler"
3536
"github.com/pingcap/tidb/pkg/session"
3637
sessiontypes "github.com/pingcap/tidb/pkg/session/types"
@@ -844,3 +845,19 @@ func TestUpgradeWithPauseDDL(t *testing.T) {
844845
" PARTITION `p3` VALUES LESS THAN (4096),\n" +
845846
" PARTITION `p4` VALUES LESS THAN (7096))"))
846847
}
848+
849+
func TestUpgradeWithCrossJoinDisabled(t *testing.T) {
850+
session.SupportUpgradeHTTPOpVer--
851+
ddl.SetWaitTimeWhenErrorOccurred(1 * time.Microsecond)
852+
backup := plannercore.AllowCartesianProduct.Load()
853+
t.Cleanup(func() {
854+
plannercore.AllowCartesianProduct.Store(backup)
855+
})
856+
plannercore.AllowCartesianProduct.Store(false)
857+
858+
store, dom := session.CreateStoreAndBootstrap(t)
859+
defer func() {
860+
dom.Close()
861+
require.NoError(t, store.Close())
862+
}()
863+
}

0 commit comments

Comments
 (0)