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

sql: add pg_lsn data type #105031

Merged
merged 1 commit into from
Jun 21, 2023
Merged

Conversation

otan
Copy link
Contributor

@otan otan commented Jun 16, 2023

This commit adds the pg_lsn data type from postgres. It is an uint64
integer but displays/parses as %X/%X, where the high 32 bits and low
32 bits are separated by a /.

I believe using this data type is strictly superior to INT/STRING, as
there are custom operations that can be performed on it which I don't
think is appropriate for those types, hence the addition.

We're mostly using the automated tests to cover any poignant issues,
with some basic logic test operations added. Missing casts and operators
with pg_lsn will be added in a later PR.

Release note (sql change): Introduce the pg_lsn data type, which is
used to store the lsn associated with replication.

Epic: https://cockroachlabs.atlassian.net/browse/CRDB-26486

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@otan otan force-pushed the new_data_type branch 8 times, most recently from 0b36605 to ba8d78a Compare June 19, 2023 00:59
@otan otan requested a review from rafiss June 19, 2023 01:00
@otan otan marked this pull request as ready for review June 19, 2023 01:01
@otan otan requested review from a team as code owners June 19, 2023 01:01
@otan otan requested review from srosenberg, renatolabs, shermanCRL and rharding6373 and removed request for a team June 19, 2023 01:01
@otan otan force-pushed the new_data_type branch 6 times, most recently from b057b4f to 385fa58 Compare June 19, 2023 05:12
@otan otan force-pushed the new_data_type branch 2 times, most recently from d36e852 to bd0fd6e Compare June 19, 2023 08:56
@shermanCRL shermanCRL requested review from miretskiy and removed request for shermanCRL June 19, 2023 13:48
@@ -479,21 +480,24 @@ func TestAvroSchema(t *testing.T) {
for _, typ := range append(types.Scalar, types.BoolArray, types.MakeCollatedString(types.String, `fr`), types.MakeBit(3)) {
switch typ.Family() {
case types.OidFamily:
continue
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This diff looks like it short-circuits the test as soon as we hit an OID type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah a bad edit - thanks!

pkg/ccl/changefeedccl/avro_test.go Show resolved Hide resolved
Copy link
Collaborator

@mgartner mgartner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 64 of 64 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @miretskiy, @otan, @rafiss, @renatolabs, @rharding6373, and @srosenberg)


pkg/sql/randgen/datum.go line 716 at r1 (raw file):

			tree.DMaxIPAddr,
		},
		types.PGLSNFamily: {

❤️


pkg/sql/logictest/testdata/logic_test/pg_lsn line 2 at r1 (raw file):

query T
SELECT 'A01F0/1AAA'::pg_lsn

Can you test some invalid formats?


pkg/sql/logictest/testdata/logic_test/pg_lsn line 13 at r1 (raw file):


query TT
SELECT * FROM pg_lsn_table ORDER BY id

A lookup by PK might be a good test to have too.

Copy link
Contributor Author

@otan otan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the quick reviews!

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @HonoreDB, @mgartner, @miretskiy, @rafiss, @renatolabs, @rharding6373, and @srosenberg)


pkg/sql/logictest/testdata/logic_test/pg_lsn line 2 at r1 (raw file):

Previously, mgartner (Marcus Gartner) wrote…

Can you test some invalid formats?

Done.


pkg/sql/logictest/testdata/logic_test/pg_lsn line 13 at r1 (raw file):

Previously, mgartner (Marcus Gartner) wrote…

A lookup by PK might be a good test to have too.

Done.


pkg/ccl/changefeedccl/avro_test.go line 466 at r1 (raw file):

Previously, HonoreDB (Aaron Zinger) wrote…

Would you mind also adding an example to value_goldens?

Done.

This commit adds the `pg_lsn` data type from postgres. It is an uint64
integer but displays/parses as `%X/%X`, where the high 32 bits and low
32 bits are separated by a `/`.

I believe using this data type is strictly superior to INT/STRING, as
there are custom operations that can be performed on it which I don't
think is appropriate for those types, hence the addition.

We're mostly using the automated tests to cover any poignant issues,
with some basic logic test operations added. Missing casts and operators
with pg_lsn will be added in a later PR.

Release note (sql change): Introduce the `pg_lsn` data type, which is
used to store the `lsn` associated with replication.
Copy link
Collaborator

@rharding6373 rharding6373 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm: Nice!

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @HonoreDB, @mgartner, @miretskiy, @otan, @rafiss, @renatolabs, and @srosenberg)

@otan
Copy link
Contributor Author

otan commented Jun 21, 2023

bors r+

@craig
Copy link
Contributor

craig bot commented Jun 21, 2023

Timed out.

@otan
Copy link
Contributor Author

otan commented Jun 21, 2023

bors r+

@craig
Copy link
Contributor

craig bot commented Jun 21, 2023

Build succeeded:

@rafiss
Copy link
Collaborator

rafiss commented Jun 22, 2023

This is missing version gating. Take a look at #90842 and #92957 for an example of the places you need to gate.

@otan
Copy link
Contributor Author

otan commented Jun 22, 2023

i'm aware, was going to add it later (unless it's failing now): #105130
edit: looks like it did, will add later today

@rafiss
Copy link
Collaborator

rafiss commented Jun 22, 2023

It is failing now #105324 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants