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 support for altering sequence options identity columns #119432
Conversation
Thank you for contributing to CockroachDB. Please ensure you have followed the guidelines for creating a PR. My owl senses detect your PR is good for review. Please keep an eye out for any test failures in CI. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
03dbe88
to
d549508
Compare
Thank you for updating your pull request. My owl senses detect your PR is good for review. Please keep an eye out for any test failures in CI. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
d29ebb6
to
64f61ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @andrew-delph and thanks for doing this. Its fairly close just some minor comments / nits.
Reviewed 10 of 12 files at r1, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @andrew-delph)
pkg/sql/alter_table.go
line 1071 at r1 (raw file):
// It is assummed that an identiy column owns only one sequence. if col.NumUsesSequences() != 1 { return colinfo.NewUndefinedColumnError(string(col.ColName()))
I don't think this should happen so lets use errors.AssertionFailed if we see it.
pkg/sql/alter_table.go
line 1088 at r1 (raw file):
opts := seqDesc.GetSequenceOpts() f := tree.NewFmtCtx(tree.FmtSimple) f.Printf(" MINVALUE %d", opts.MinValue)
Might be cleaner to just make this out of tree.SequenceOption and then format it out
pkg/sql/alter_table.go
line 1096 at r1 (raw file):
Previously, andrew-delph (Andrew Delph) wrote…
Is it possible that 'GeneratedAsIdentitySequenceOption' can be overridden by another transaction?
It will be parsed down stream when writing to the information_schema.
So other concurrent writes can happen, but your transaction will be forced to retry because of the conflict. So, theres no danger and this will work correctly.
pkg/sql/logictest/testdata/logic_test/information_schema
line 2976 at r1 (raw file):
statement ok CREATE DATABASE test_identity
You can just use the same database for this test, no need to make a new one
64f61ae
to
2d74f42
Compare
Informs: cockroachdb#110010 This change introduces the 'ALTER [COLUMN] column_name SET sequence_option | RESTART [ [ WITH ] restart ] }' command. This enhancement allows for the modification of identity column sequence options, thereby providing more precise control over the behavior of identity columns. Release note (sql change): Identity columns now support enhanced sequence management through the 'ALTER [COLUMN] column_name SET sequence_option' and 'ALTER [COLUMN] column_name RESTART [WITH restart]' commands. This update facilitates the fine-tuning of identity column sequences.
2d74f42
to
021bc99
Compare
Thank you @fqazi for the comments! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 12 of 12 files at r2, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @andrew-delph)
bors r+ |
Build failed (retrying...): |
Build succeeded: |
Informs: #110010
This change introduces the 'ALTER [COLUMN] column_name SET sequence_option | RESTART [ [ WITH ] restart ] }' command. This enhancement allows for the modification of identity column sequence options, thereby providing more precise control over the behavior of identity columns.
Release note (sql change): Identity columns now support enhanced sequence management through the 'ALTER [COLUMN] column_name SET sequence_option' and 'ALTER [COLUMN] column_name RESTART [WITH restart]' commands. This update facilitates the fine-tuning of identity column sequences.