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: database name inconsistent in crdb_internal.create_statements table select statement #59561

Closed
RichardJCai opened this issue Jan 28, 2021 · 2 comments · Fixed by #61201
Closed
Labels
A-sql-vtables Virtual tables - pg_catalog, information_schema etc C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.

Comments

@RichardJCai
Copy link
Contributor

RichardJCai commented Jan 28, 2021

The database_name for the following SELECT statements differ although the returned row should be the same.
Tested with descriptor_name pg_views descriptor_id 4294967174

[email protected]:26257/movr> select database_name, descriptor_name, descriptor_id from movr.crdb_internal.create_statements where descriptor_id = 4294967174;
  database_name | descriptor_name | descriptor_id
----------------+-----------------+----------------
  movr          | pg_views        |    4294967174
(1 row)

Time: 2ms total (execution 2ms / network 0ms)

[email protected]:26257/movr> select database_name, descriptor_name, descriptor_id from movr.crdb_internal.create_statements where descriptor_name = 'pg_views';
  database_name | descriptor_name | descriptor_id
----------------+-----------------+----------------
  NULL          | pg_views        |    4294967174
(1 row)

Time: 97ms total (execution 96ms / network 0ms)

[email protected]:26257/movr>

It may be worth noting that descriptor_id is indexed and descriptor_name is not

@RichardJCai RichardJCai added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. A-sql-vtables Virtual tables - pg_catalog, information_schema etc labels Jan 28, 2021
@rafiss rafiss added the release-blocker Indicates a release-blocker. Use with branch-release-2x.x label to denote which branch is blocked. label Feb 2, 2021
@blathers-crl
Copy link

blathers-crl bot commented Feb 2, 2021

Hi @rafiss, please add branch-* labels to identify which branch(es) this release-blocker affects.

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

@rafiss rafiss removed the release-blocker Indicates a release-blocker. Use with branch-release-2x.x label to denote which branch is blocked. label Feb 2, 2021
@RichardJCai
Copy link
Contributor Author

Did some digging on this, turns out the reason the DB is nil is because we hardcode a nil DatabaseDescriptor at https://github.com/cockroachdb/cockroach/blob/master/pkg/sql/information_schema.go#L2132

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-vtables Virtual tables - pg_catalog, information_schema etc C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
Projects
None yet
2 participants