Skip to content

Commit 0f209eb

Browse files
committed
sql: reset schema_locked correctly in a mixed version state
Previously, when schema_locked was reset it would always adopt the value from create_table_with_schema_locked. This was incorrect, since this setting should only adopted if the cluster is running on 25.3. This patch adds a version gate in the reset logic. Fixes: #149266 Release note: None
1 parent 2a307b2 commit 0f209eb

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

pkg/sql/logictest/testdata/logic_test/schema_locked

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Intentionally set this to true in 25.2, this setting
2+
# should be ignored.
3+
onlyif config local-mixed-25.2
4+
statement ok
5+
SET create_table_with_schema_locked=true
6+
7+
skipif config local-mixed-25.2
18
statement ok
29
SET create_table_with_schema_locked=false
310

pkg/sql/storageparam/tablestorageparam/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ go_library(
66
importpath = "github.com/cockroachdb/cockroach/pkg/sql/storageparam/tablestorageparam",
77
visibility = ["//visibility:public"],
88
deps = [
9+
"//pkg/clusterversion",
910
"//pkg/sql/catalog/catpb",
1011
"//pkg/sql/catalog/tabledesc",
1112
"//pkg/sql/paramparse",

pkg/sql/storageparam/tablestorageparam/table_storage_param.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"math"
1313
"strings"
1414

15+
"github.com/cockroachdb/cockroach/pkg/clusterversion"
1516
"github.com/cockroachdb/cockroach/pkg/sql/catalog/catpb"
1617
"github.com/cockroachdb/cockroach/pkg/sql/catalog/tabledesc"
1718
"github.com/cockroachdb/cockroach/pkg/sql/paramparse"
@@ -608,7 +609,12 @@ var tableParams = map[string]tableParam{
608609
return nil
609610
},
610611
onReset: func(ctx context.Context, po *Setter, evalCtx *eval.Context, key string) error {
611-
po.TableDesc.SchemaLocked = evalCtx.SessionData().CreateTableWithSchemaLocked
612+
schemaLockedDefault := evalCtx.SessionData().CreateTableWithSchemaLocked
613+
// Before 25.3 tables were never created with schema_locked by default.
614+
if !evalCtx.Settings.Version.IsActive(ctx, clusterversion.V25_3) {
615+
schemaLockedDefault = false
616+
}
617+
po.TableDesc.SchemaLocked = schemaLockedDefault
612618
return nil
613619
},
614620
},

0 commit comments

Comments
 (0)