diff --git a/pkg/workload/schemachange/operation_generator.go b/pkg/workload/schemachange/operation_generator.go index b38003d0572f..214a58e793da 100644 --- a/pkg/workload/schemachange/operation_generator.go +++ b/pkg/workload/schemachange/operation_generator.go @@ -1278,6 +1278,18 @@ func (og *operationGenerator) createTable(ctx context.Context, tx pgx.Tx) (*opSt } return false }() + mixedVersionTest, err := isMixedVersionTest(ctx, tx) + if err != nil { + return nil, err + } + hasUnsupportedBit0Type := func() bool { + for _, def := range stmt.Defs { + if col, ok := def.(*tree.ColumnTableDef); ok && isUnsupportedBit0Type(col.Type.SQLString(), mixedVersionTest) { + return true + } + } + return false + }() tableExists, err := og.tableExists(ctx, tx, tableName) if err != nil { @@ -1297,6 +1309,7 @@ func (og *operationGenerator) createTable(ctx context.Context, tx pgx.Tx) (*opSt opStmt.potentialExecErrors.addAll(codesWithConditions{ {code: pgcode.Syntax, condition: hasVectorType}, {code: pgcode.FeatureNotSupported, condition: hasVectorType}, + {code: pgcode.InvalidParameterValue, condition: hasUnsupportedBit0Type}, }) opStmt.sql = tree.Serialize(stmt) return opStmt, nil @@ -3941,11 +3954,17 @@ func (og *operationGenerator) randType( if err != nil { return nil, nil, err } + mixedVersion, err := isMixedVersionTest(ctx, tx) + if err != nil { + return nil, nil, err + } typ := randgen.RandSortingType(og.params.rng) - for pgVectorNotSupported && typ.Family() == types.PGVectorFamily { + for (pgVectorNotSupported && typ.Family() == types.PGVectorFamily) || + isUnsupportedBit0Type(typ.SQLString(), mixedVersion) { typ = randgen.RandSortingType(og.params.rng) } + typeName := tree.MakeUnqualifiedTypeName(typ.SQLString()) return &typeName, typ, nil } @@ -4139,6 +4158,10 @@ FROM if err != nil { return nil, err } + mixedVersion, err := isMixedVersionTest(ctx, tx) + if err != nil { + return nil, err + } // Generate random parameters / values for builtin types. for i, typeVal := range randgen.SeedTypes { @@ -4152,7 +4175,8 @@ FROM typeVal.Family() == types.VoidFamily { continue } - if pgVectorNotSupported && typeVal.Family() == types.PGVectorFamily { + if pgVectorNotSupported && typeVal.Family() == types.PGVectorFamily || + isUnsupportedBit0Type(typeVal.SQLString(), mixedVersion) { continue } @@ -4808,6 +4832,22 @@ func isClusterVersionLessThan( return clusterVersion.Less(targetVersion), nil } +// isMixedVersionTest works similarly to isClusterVersionLessThan, but without +// specifying a version. It returns true if the cluster version is not the +// latest, indicating a mixed-version test. +func isMixedVersionTest(ctx context.Context, tx pgx.Tx) (bool, error) { + return isClusterVersionLessThan(ctx, tx, clusterversion.Latest.Version()) +} + +func isUnsupportedBit0Type(typName string, mixedVersion bool) bool { + // TODO(spilchen): In mixed-version tests, declaring a BIT(0) column can cause a + // syntax error. Support for this type was recently added and backported, but the + // backport release is still pending. We need to regenerate the type until + // something other than BIT(0) is generated. This can be removed once 24.2.5 is + // publicly released. + return mixedVersion && strings.HasPrefix(typName, "BIT(0)") +} + func (og *operationGenerator) setSeedInDB(ctx context.Context, tx pgx.Tx) error { if notSupported, err := isClusterVersionLessThan(ctx, tx, clusterversion.V24_1.Version()); err != nil { return err