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: identity information under information_schema.columns is inconsistent with postgres #82064

Closed
hedwigz opened this issue May 30, 2022 · 3 comments · Fixed by #84034
Closed
Assignees
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community sync-me-8 T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)

Comments

@hedwigz
Copy link

hedwigz commented May 30, 2022

Describe the problem
The table information_schema.columns should reflect the information about an identity column and the underlying sequence information.

To Reproduce
cockroach:

CREATE TABLE t (
  id INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 4294967296),
  PRIMARY KEY (id)
);

=> select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id';
 identity_start | identity_increment | identity_maximum | identity_minimum | identity_cycle 
----------------+--------------------+------------------+------------------+----------------
                |                    |                  |                  |  
(1 row)

postgres:

=> CREATE TABLE t (
  id INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 4294967296),
  PRIMARY KEY (id)
);

=> select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id';
 identity_start | identity_increment |  identity_maximum   | identity_minimum | identity_cycle 
----------------+--------------------+---------------------+------------------+----------------
 4294967296     | 1                  | 9223372036854775807 | 1                | NO 
(1 row)

Expected behavior
The above select statement should return the information about the sequence

Environment:

  • CockroachDB version: v21.2.11
  • Server OS: Linux
  • Client app: DataGrip

Jira issue: CRDB-16195
Epic CRDB-14049

@hedwigz hedwigz added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label May 30, 2022
@blathers-crl
Copy link

blathers-crl bot commented May 30, 2022

Hello, I am Blathers. I am here to help you get the issue triaged.

Hoot - a bug! Though bugs are the bane of my existence, rest assured the wretched thing will get the best of care here.

I was unable to automatically find someone to ping.

If we have not gotten back to your issue within a few business days, you can try the following:

  • Join our community slack channel and ask on #cockroachdb.
  • Try find someone from here if you know they worked closely on the area and CC them.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

@blathers-crl blathers-crl bot added O-community Originated from the community X-blathers-untriaged blathers was unable to find an owner labels May 30, 2022
@yuzefovich yuzefovich removed the X-blathers-untriaged blathers was unable to find an owner label May 31, 2022
@blathers-crl blathers-crl bot added the T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) label May 31, 2022
@rafiss
Copy link
Collaborator

rafiss commented Jun 9, 2022

looks like we have a TODO about this:

// TODO(janexing): parse the GeneratedAsIdentitySequenceOption to
// fill out these "identity_x" columns.
tree.DNull, // identity_start
tree.DNull, // identity_increment
tree.DNull, // identity_maximum
tree.DNull, // identity_minimum
tree.DNull, // identity_cycle

@ZhouXing19
Copy link
Collaborator

To solve this we may need to solve #83208 first. I'll open a PR for it.

ZhouXing19 added a commit to ZhouXing19/cockroach that referenced this issue Jul 7, 2022
…schema

Previously, for a column created with the `GENERATED ... AS IDENTITY
(seq_options)` syntax, the info for the sequence option is not saved in the
information schema.

This commit is to fix it. We parse the sequence options saved as a string in the
descriptor, so that it's much easier to extract specific option such as
sequence's start value or increment size.

To make sure that we get the same sequence option to generate
the sequence, we reuse `assignSequenceOptions()` by breaking it into several
helper functions.

fixes cockroachdb#82064

Release note (sql): add sequence option info for identity columns under
information_schema
ZhouXing19 added a commit to ZhouXing19/cockroach that referenced this issue Jul 14, 2022
…schema

Previously, for a column created with the `GENERATED ... AS IDENTITY
(seq_options)` syntax, the info for the sequence option is not saved in the
information schema.

This commit is to fix it. We parse the sequence options saved as a string in the
descriptor, so that it's much easier to extract specific option such as
sequence's start value or increment size.

To make sure that we get the same sequence option to generate
the sequence, we reuse `assignSequenceOptions()` by breaking it into several
helper functions.

fixes cockroachdb#82064

Release note (sql): add sequence option info for identity columns under
information_schema
ZhouXing19 added a commit to ZhouXing19/cockroach that referenced this issue Jul 18, 2022
…schema

Previously, for a column created with the `GENERATED ... AS IDENTITY
(seq_options)` syntax, the info for the sequence option is not saved in the
information schema.

This commit is to fix it. We parse the sequence options saved as a string in the
descriptor, so that it's much easier to extract specific option such as
sequence's start value or increment size.

To make sure that we get the same sequence option to generate
the sequence, we reuse `assignSequenceOptions()` by breaking it into several
helper functions.

fixes cockroachdb#82064

Release note (sql): add sequence option info for identity columns under
information_schema
craig bot pushed a commit that referenced this issue Jul 18, 2022
84034: sql: add sequence option info for identity columns under information_schema r=rafiss a=ZhouXing19

Previously, for a column created with the `GENERATED ... AS IDENTITY
(seq_options)` syntax, the info for the sequence option is not saved in the
information schema.

This commit is to fix it. We parse the sequence options saved as a string in the
the descriptor, so that it's much easier to extract specific options such as
sequence's start value or increment size.

To make sure that we get the same sequence option to generate
the sequence, we reuse `assignSequenceOptions()` by breaking it into several
helper functions.

fixes #82064
fixes #83208

Release note (sql): add sequence option info for identity columns under
information_schema

84389: sql: fix auto-retries for upgraded transactions r=ZhouXing19 a=rafiss

This is implemented by adding more state to the conn executor state
machine. Now, it tracks if the open transaction was upgraded from an
implicit to an explicit txn. If so, when doing an auto retry, the
transaction is marked as an implicit again, so that the statements in
the transaction can upgrade it to explicit.

No release note is needed for v22.2, but we should use the following
 note when backporting to v22.1.

Placeholder note (bug fix): Fixed a bug where some statements in a batch
would not get executed if the following conditions were met:
- A batch of statements is sent in a single string.
- A BEGIN statement appears in the middle of the batch.
- The enable_implicit_transaction_for_batch_statements session variable
  is set to true. (This defaults to false in v22.1.x)

This bug was introduced in v22.1.2. (#82681)

Release note: None

84575: sql/schemachanger/sctest: don't rewrite if not enabled r=ajwerner a=ajwerner

This commit changes the explain diagram testing to check the output as opposed
to unconditionally rewriting. Before this change, the bazel build was broken because
the sandbox was not writable. Also, we weren't actually testing anything. 

Release note: None

Co-authored-by: Jane Xing <zhouxing@uchicago.edu>
Co-authored-by: Rafi Shamim <rafi@cockroachlabs.com>
Co-authored-by: Andrew Werner <awerner32@gmail.com>
@craig craig bot closed this as completed in bcd289b Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community sync-me-8 T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants