From f0b83e65b85d9702fe924c6b0b294abaa4e29e53 Mon Sep 17 00:00:00 2001 From: Faizan Qazi Date: Tue, 7 Oct 2025 19:49:39 +0000 Subject: [PATCH] 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 --- .../schemachange/operation_generator.go | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/pkg/workload/schemachange/operation_generator.go b/pkg/workload/schemachange/operation_generator.go index 55275c28f39b..226c0f59fc23 100644 --- a/pkg/workload/schemachange/operation_generator.go +++ b/pkg/workload/schemachange/operation_generator.go @@ -2528,6 +2528,17 @@ func (og *operationGenerator) setColumnDefault(ctx context.Context, tx pgx.Tx) ( stmt.potentialExecErrors.add(pgcode.Syntax) stmt.potentialExecErrors.add(pgcode.InvalidTableDefinition) } + // Check for references to any types that are not supported in mixed version + // clusters. + ltreeNotSupported, err := isClusterVersionLessThan(ctx, tx, clusterversion.V25_4.Version()) + if err != nil { + return nil, err + } + if ltreeNotSupported && + defaultDatum.ResolvedType().Family() == types.ArrayFamily && + strings.HasPrefix(defaultDatum.ResolvedType().ArrayContents().SQLString(), "LTREE") { + stmt.expectedExecErrors.add(pgcode.FeatureNotSupported) + } strDefault := tree.AsStringWithFlags(defaultDatum, tree.FmtParsable) // Always use explicit type casting to ensure consistent behavior and avoid parse errors. @@ -4147,8 +4158,8 @@ func (og *operationGenerator) randType( typ := randgen.RandSortingType(og.params.rng) for (pgVectorNotSupported && typ.Family() == types.PGVectorFamily) || - (citextNotSupported && typ.Oid() == oidext.T_citext) || - (ltreeNotSupported && typ.Oid() == oidext.T_ltree) { + (citextNotSupported && typ.Oid() == oidext.T_citext || typ.Oid() == oidext.T__citext) || + (ltreeNotSupported && (typ.Oid() == oidext.T_ltree || typ.Oid() == oidext.T__ltree)) { typ = randgen.RandSortingType(og.params.rng) } @@ -4354,10 +4365,12 @@ FROM continue } - if citextNotSupported && typeVal.Oid() == oidext.T_citext { + if citextNotSupported && + (typeVal.Oid() == oidext.T_citext || typeVal.Oid() == oidext.T__citext) { continue } - if ltreeNotSupported && typeVal.Oid() == oidext.T_ltree { + if ltreeNotSupported && + (typeVal.Oid() == oidext.T_ltree || typeVal.Oid() == oidext.T__ltree) { continue }