Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

colinfo: add version gate for storing pg_lsn types #105391

Merged
merged 1 commit into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
10 changes: 10 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,10 @@
# LogicTest: local-mixed-22.2-23.1
# TODO(otan): add tests for mixed 23.1-23.2.

query T
SELECT '1010F/AAAA'::pg_lsn
----
1010F/AAAA

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