-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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: make sequence integer bound consistent with default_int_size
#84555
Conversation
Note to myself: do we need a migration for this? |
8b932cd
to
aa06bb7
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.
Note to myself: do we need a migration for this?
What would the migration do?
Reviewable status: complete! 0 of 0 LGTMs obtained
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.
this seems like it lgtm after rebasing
nvm, I misunderstood. I thought we needed to reset the existing sequences' min and max values, but it doesn't seem needed. |
aa06bb7
to
45198c9
Compare
Rebased and it passed the CI. RFAL, thanks! |
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.
just a small nit!
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @rafiss and @ZhouXing19)
pkg/sql/information_schema.go
line 486 at r5 (raw file):
identityMax := tree.DNull identityMin := tree.DNull generatedAsIdentitySeqOpt, err := column.GetGeneratedAsIdentitySequenceOption(p.SessionData().DefaultIntSize)
in this case, i think we should not use the session variable, and should instead inspect the int size from the column type. e.g. pass in column..GetType().Width()
otherwise, the result shown in information_schema.columns
would depend on the session var.
CREATE TABLE t (id1 INT GENERATED BY DEFAULT AS IDENTITY);
select identity_maximum from information_schema.columns where table_name = 't' and column_name='id1';
set default_int_size = 4;
select identity_maximum from information_schema.columns where table_name = 't' and column_name='id1';
we'd want the two select
s to return the same value
45198c9
to
eeaae83
Compare
Makes sense. Made the change and updated the tests. |
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.
lgtm, nice!
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @rafiss and @ZhouXing19)
TFTR! |
Build failed (retrying...): |
Build failed (retrying...): |
Build failed (retrying...): |
Build failed: |
eeaae83
to
f1ec7da
Compare
Previously, the default bound of sequence are always `math.MaxInt64` or `math.MinInt64` (depending on the sequence's order). This is inconsistent with the cluster setting `default_int_size`. This commit is to fix it. fixes cockroachdb#84554 Release note (bug fix): make sequence integer bound consistent with the cluster setting `default_int_size`. Release justification: bug fix
f1ec7da
to
b6dc58b
Compare
bors r+ |
Build succeeded: |
This PR is based on #84034.
Please just look at the 2nd commit. I'll rebase this PR once #84034 is merged.
Previously, the default bounds of sequence are always
math.MaxInt64
or
math.MinInt64
(depending on the sequence's order). Thiscan be inconsistent with the cluster setting
default_int_size
. This commitis to fix it.
fixes #84554
Release note (bug fix): make sequence integer bound consistent with the
cluster setting
default_int_size
.Release justification: fix a bug of sequence integer bound