Skip to content

Commit 4dbf560

Browse files
committed
workload/schemachange: don't use CITEXT in mixed version cluster
Release note: None
1 parent 48c636e commit 4dbf560

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

pkg/workload/schemachange/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ go_library(
2828
"//pkg/sql/catalog/catpb",
2929
"//pkg/sql/catalog/colinfo",
3030
"//pkg/sql/lexbase",
31+
"//pkg/sql/oidext",
3132
"//pkg/sql/parser",
3233
"//pkg/sql/pgwire/pgcode",
3334
"//pkg/sql/pgwire/pgerror",

pkg/workload/schemachange/operation_generator.go

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/cockroachdb/cockroach/pkg/sql/catalog/catpb"
2525
"github.com/cockroachdb/cockroach/pkg/sql/catalog/colinfo"
2626
"github.com/cockroachdb/cockroach/pkg/sql/lexbase"
27+
"github.com/cockroachdb/cockroach/pkg/sql/oidext"
2728
"github.com/cockroachdb/cockroach/pkg/sql/parser"
2829
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode"
2930
"github.com/cockroachdb/cockroach/pkg/sql/randgen"
@@ -1283,6 +1284,15 @@ func (og *operationGenerator) createTable(ctx context.Context, tx pgx.Tx) (*opSt
12831284
}
12841285
return false
12851286
}()
1287+
hasCitextType := func() bool {
1288+
// Check if any of the columns have CITEXT types involved.
1289+
for _, def := range stmt.Defs {
1290+
if col, ok := def.(*tree.ColumnTableDef); ok && col.Type.SQLString() == "CITEXT" {
1291+
return true
1292+
}
1293+
}
1294+
return false
1295+
}()
12861296

12871297
// Randomly create as schema locked table.
12881298
versionBefore253, err := isClusterVersionLessThan(ctx, tx, clusterversion.V25_3.Version())
@@ -1314,6 +1324,8 @@ func (og *operationGenerator) createTable(ctx context.Context, tx pgx.Tx) (*opSt
13141324
opStmt.potentialExecErrors.addAll(codesWithConditions{
13151325
{code: pgcode.Syntax, condition: hasVectorType},
13161326
{code: pgcode.FeatureNotSupported, condition: hasVectorType},
1327+
{code: pgcode.Syntax, condition: hasCitextType},
1328+
{code: pgcode.FeatureNotSupported, condition: hasCitextType},
13171329
})
13181330
opStmt.sql = tree.Serialize(stmt)
13191331
return opStmt, nil
@@ -4090,8 +4102,18 @@ func (og *operationGenerator) randType(
40904102
return nil, nil, err
40914103
}
40924104

4105+
// Block CITEXT usage until v25.3 is finalized.
4106+
citextNotSupported, err := isClusterVersionLessThan(
4107+
ctx,
4108+
tx,
4109+
clusterversion.V25_3.Version())
4110+
if err != nil {
4111+
return nil, nil, err
4112+
}
4113+
40934114
typ := randgen.RandSortingType(og.params.rng)
4094-
for pgVectorNotSupported && typ.Family() == types.PGVectorFamily {
4115+
for (pgVectorNotSupported && typ.Family() == types.PGVectorFamily) ||
4116+
(citextNotSupported && typ.Oid() == oidext.T_citext) {
40954117
typ = randgen.RandSortingType(og.params.rng)
40964118
}
40974119

@@ -4274,6 +4296,11 @@ FROM
42744296
possibleParamReferences = append(possibleParamReferences, fmt.Sprintf(`enum_%d %s`, i, enum["name"]))
42754297
}
42764298

4299+
citextNotSupported, err := isClusterVersionLessThan(ctx, tx, clusterversion.V25_3.Version())
4300+
if err != nil {
4301+
return nil, err
4302+
}
4303+
42774304
// Generate random parameters / values for builtin types.
42784305
for i, typeVal := range randgen.SeedTypes {
42794306
// If we have types where invalid values can exist then skip over these,
@@ -4287,6 +4314,10 @@ FROM
42874314
continue
42884315
}
42894316

4317+
if citextNotSupported && typeVal.Oid() == oidext.T_citext {
4318+
continue
4319+
}
4320+
42904321
possibleReturnReferences = append(possibleReturnReferences, typeVal.SQLStandardName())
42914322
possibleParamReferences = append(possibleParamReferences, fmt.Sprintf("val_%d %s", i+len(enums), typeVal.SQLStandardName()))
42924323
optionalDefaultValue := randgen.RandDatum(og.params.rng, typeVal, true)

0 commit comments

Comments
 (0)