Skip to content

Commit

Permalink
colinfo: add version gate for storing pg_lsn types
Browse files Browse the repository at this point in the history
We don't want mixed version clusters storing pg_lsn types, in case they
need to rollback / older versions do not understand the type.

Release note: None
  • Loading branch information
otan committed Jun 22, 2023
1 parent 320e861 commit aad4c19
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
10 changes: 9 additions & 1 deletion pkg/sql/catalog/colinfo/col_type_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func ValidateColumnDefType(ctx context.Context, version clusterversion.Handle, t
return ValidateColumnDefType(ctx, version, t.ArrayContents())

case types.BitFamily, types.IntFamily, types.FloatFamily, types.BoolFamily, types.BytesFamily, types.DateFamily,
types.INetFamily, types.IntervalFamily, types.JsonFamily, types.OidFamily, types.PGLSNFamily, types.TimeFamily,
types.INetFamily, types.IntervalFamily, types.JsonFamily, types.OidFamily, types.TimeFamily,
types.TimestampFamily, types.TimestampTZFamily, types.UuidFamily, types.TimeTZFamily,
types.GeographyFamily, types.GeometryFamily, types.EnumFamily, types.Box2DFamily:
// These types are OK.
Expand All @@ -124,6 +124,14 @@ func ValidateColumnDefType(ctx context.Context, version clusterversion.Handle, t
"TSVector/TSQuery not supported until version 23.1")
}

case types.PGLSNFamily:
if !version.IsActive(ctx, clusterversion.V23_2) {
return pgerror.Newf(
pgcode.FeatureNotSupported,
"pg_lsn not supported until version 23.2",
)
}

default:
return pgerror.Newf(pgcode.InvalidTableDefinition,
"value type %s cannot be used for table columns", t.String())
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/logictest/testdata/logic_test/pg_lsn
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# LogicTest: !local-mixed-22.2-23.1
query T
SELECT 'A01F0/1AAA'::pg_lsn
----
Expand Down Expand Up @@ -27,7 +28,6 @@ SELECT * FROM pg_lsn_table WHERE id = '10/10' ORDER BY id
----
10/10 A01/A100


query TT
SELECT * FROM pg_lsn_table WHERE val = 'A01/A1000' ORDER BY id
----
Expand Down
5 changes: 5 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/pg_lsn_mixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# LogicTest: local-mixed-22.2-23.1
# TODO(otan): add tests for mixed 23.1-23.2.

statement error pg_lsn not supported until version 23.2
CREATE TABLE pg_lsn_table(id pg_lsn, val pg_lsn)

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions pkg/workload/schemachange/operation_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,14 @@ func (og *operationGenerator) createTable(ctx context.Context, tx pgx.Tx) (*opSt
}
return false
}()
// PGLSN was added in 23.2.
pgLSNNotSupported, err := isClusterVersionLessThan(
ctx,
tx,
clusterversion.ByKey(clusterversion.V23_2))
if err != nil {
return nil, err
}
// Forward indexes for arrays were added in 23.1, so check the index
// definitions for them in mixed version states.
forwardIndexesOnArraysNotSupported, err := isClusterVersionLessThan(
Expand Down Expand Up @@ -1460,6 +1468,8 @@ func (og *operationGenerator) createTable(ctx context.Context, tx pgx.Tx) (*opSt
opStmt.potentialExecErrors.addAll(codesWithConditions{
{code: pgcode.Syntax, condition: hasUnsupportedTSQuery},
{code: pgcode.FeatureNotSupported, condition: hasUnsupportedTSQuery},
{code: pgcode.Syntax, condition: pgLSNNotSupported},
{code: pgcode.FeatureNotSupported, condition: pgLSNNotSupported},
{code: pgcode.FeatureNotSupported, condition: hasUnsupportedIdxQueries},
{code: pgcode.InvalidTableDefinition, condition: hasUnsupportedIdxQueries},
})
Expand Down

0 comments on commit aad4c19

Please sign in to comment.