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: use schema desc ID for OIDs in pg_catalog #88009

Merged
merged 1 commit into from
Sep 16, 2022

Conversation

knz
Copy link
Contributor

@knz knz commented Sep 15, 2022

Needed for #87606.

Prior to this patch, a synthetic OID was used for
"namespace" (schema) references in pg_catalog.

This was making it difficult/impossible to retrieve schema comments using a non-root SQL query, e.g. via

SELECT nspname AS schema,
       coalesce(pc.comment, sc.comment) as description
  FROM pg_catalog.pg_namespace t
LEFT OUTER JOIN system.comments sc
    ON t.oid = sc.object_id AND sc.type = 4
LEFT OUTER JOIN crdb_internal.predefined_comments pc
    ON t.oid = pc.object_id AND pc.type = 4

This patch fixes it.

Release note: None

@knz knz requested review from ajwerner and a team September 15, 2022 19:20
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Prior to this patch, a synthetic OID was used for
"namespace" (schema) references in `pg_catalog`.

This was making it difficult/impossible to retrieve
schema comments using a non-`root` SQL query, e.g. via

```sql
SELECT nspname AS schema,
       substr(coalesce(pc.comment, sc.comment), e'[^\n]{0,40}') as description
  FROM pg_catalog.pg_namespace t
LEFT OUTER JOIN system.comments sc
    ON t.oid = sc.object_id AND sc.type = 4
LEFT OUTER JOIN crdb_internal.predefined_comments pc
    ON t.oid = pc.object_id AND pc.type = 4
```

This patch fixes it.

Release note: None
@knz knz force-pushed the 20220915-schema-oids branch from 97f9cd9 to 0140d75 Compare September 15, 2022 21:10
Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

this is a great idea

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner)

@knz
Copy link
Contributor Author

knz commented Sep 16, 2022

thank you!

bors r=rafiss

@craig
Copy link
Contributor

craig bot commented Sep 16, 2022

Build succeeded:

@craig craig bot merged commit 4b2ee12 into cockroachdb:master Sep 16, 2022
@knz knz deleted the 20220915-schema-oids branch September 16, 2022 19:22
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.

3 participants