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

introspection: use obj_description/col_description in postgres #4136

Merged
merged 3 commits into from
Aug 14, 2023

Conversation

aqrln
Copy link
Member

@aqrln aqrln commented Aug 11, 2023

Summary

Use obj_description and col_description functions instead of manual joining on pg_description:

Description

When searching for database comments in pg_description catalog, our introspection queries for Postgres assumed that OIDs of different objects are unique, but in fact they are only unique in the containing catalog for this type of objects and not throughout the whole database. The assumption often holds true in practice in PostgreSQL because the OID generation algorithm tries to keep them separated and they only start overlapping in very big databases, however CockroachDB uses simpler IDs so they are ambiguous right away.

This issue was uncovered as CockroachDB 23 added descriptions for all built-in functions, so our introspection queries started picking them up when searching for descriptions of tables, columns, views and enums.

#4055 partially fixed this in table queries by filtering by classoid in addition to objoid. It wasn't fixed in view, column and enum queries, as we learned when we tried to add CRDB 23 to CI in #4132 and it showed that some tests were failing because descriptions of random built-in functions were attached to unrelated views.

This PR fixes the issue by using comment information functions instead of joining the pg_description catalog manually.

Closes: prisma/prisma#19935
Ref: #4135
Ref: #4132

@codspeed-hq
Copy link

codspeed-hq bot commented Aug 11, 2023

CodSpeed Performance Report

Merging #4136 will not alter performance

Comparing integration/obj-description (facb547) with main (9fe3fe4)

Summary

✅ 11 untouched benchmarks

@aqrln aqrln force-pushed the integration/obj-description branch from 9d73630 to facb547 Compare August 11, 2023 21:05
@aqrln aqrln added this to the 5.2.0 milestone Aug 11, 2023
@aqrln aqrln marked this pull request as ready for review August 12, 2023 22:39
@aqrln aqrln requested a review from a team as a code owner August 12, 2023 22:39
Copy link
Contributor

@Jolg42 Jolg42 left a comment

Choose a reason for hiding this comment

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

We should see the comments on the views disappear from introspection-ci after this.

Copy link
Contributor

@tomhoule tomhoule left a comment

Choose a reason for hiding this comment

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

💯

@Jolg42 Jolg42 merged commit aec118a into main Aug 14, 2023
49 checks passed
@Jolg42 Jolg42 deleted the integration/obj-description branch August 14, 2023 09:08
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.

Use PostgreSQL System Information Functions instead of manually joining fields
3 participants