Skip to content

Commit f0b83e6

Browse files
committed
workload/schemachanger: exclude array types for ltree and citext
Previously, we added version gates for ltree and citext, but this only included non-array types. This meant we could still incorrectly use arrays of these types in mixed version states. To address this, this patch detects the array variants of these types. Fixes: #154637 Release note: None
1 parent 881d2d7 commit f0b83e6

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

pkg/workload/schemachange/operation_generator.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2528,6 +2528,17 @@ func (og *operationGenerator) setColumnDefault(ctx context.Context, tx pgx.Tx) (
25282528
stmt.potentialExecErrors.add(pgcode.Syntax)
25292529
stmt.potentialExecErrors.add(pgcode.InvalidTableDefinition)
25302530
}
2531+
// Check for references to any types that are not supported in mixed version
2532+
// clusters.
2533+
ltreeNotSupported, err := isClusterVersionLessThan(ctx, tx, clusterversion.V25_4.Version())
2534+
if err != nil {
2535+
return nil, err
2536+
}
2537+
if ltreeNotSupported &&
2538+
defaultDatum.ResolvedType().Family() == types.ArrayFamily &&
2539+
strings.HasPrefix(defaultDatum.ResolvedType().ArrayContents().SQLString(), "LTREE") {
2540+
stmt.expectedExecErrors.add(pgcode.FeatureNotSupported)
2541+
}
25312542

25322543
strDefault := tree.AsStringWithFlags(defaultDatum, tree.FmtParsable)
25332544
// Always use explicit type casting to ensure consistent behavior and avoid parse errors.
@@ -4147,8 +4158,8 @@ func (og *operationGenerator) randType(
41474158

41484159
typ := randgen.RandSortingType(og.params.rng)
41494160
for (pgVectorNotSupported && typ.Family() == types.PGVectorFamily) ||
4150-
(citextNotSupported && typ.Oid() == oidext.T_citext) ||
4151-
(ltreeNotSupported && typ.Oid() == oidext.T_ltree) {
4161+
(citextNotSupported && typ.Oid() == oidext.T_citext || typ.Oid() == oidext.T__citext) ||
4162+
(ltreeNotSupported && (typ.Oid() == oidext.T_ltree || typ.Oid() == oidext.T__ltree)) {
41524163
typ = randgen.RandSortingType(og.params.rng)
41534164
}
41544165

@@ -4354,10 +4365,12 @@ FROM
43544365
continue
43554366
}
43564367

4357-
if citextNotSupported && typeVal.Oid() == oidext.T_citext {
4368+
if citextNotSupported &&
4369+
(typeVal.Oid() == oidext.T_citext || typeVal.Oid() == oidext.T__citext) {
43584370
continue
43594371
}
4360-
if ltreeNotSupported && typeVal.Oid() == oidext.T_ltree {
4372+
if ltreeNotSupported &&
4373+
(typeVal.Oid() == oidext.T_ltree || typeVal.Oid() == oidext.T__ltree) {
43614374
continue
43624375
}
43634376

0 commit comments

Comments
 (0)