Skip to content

Add the catalog visibility and comment functions - #161

Merged
tamnd merged 1 commit into
mainfrom
m2-catinfo
Oct 8, 2026
Merged

tamnd merged 1 commit into
mainfrom
m2-catinfo

Conversation

@tamnd

@tamnd tamnd commented Oct 8, 2026

Copy link
Copy Markdown
Owner

This PR adds the catalog information functions of spec/07 section 7.18.3 that read only the catalog: the pg_*_is_visible functions, pg_get_userbyid and the comment functions. It is part of the SELECT item of M2.

What changes

  • rupg-func has a new module catinfo.rs. It has the kernels of pg_table_is_visible, pg_type_is_visible, pg_function_is_visible, pg_operator_is_visible, pg_opclass_is_visible, pg_opfamily_is_visible, pg_collation_is_visible, pg_conversion_is_visible, pg_ts_parser_is_visible, pg_ts_dict_is_visible, pg_ts_template_is_visible, pg_ts_config_is_visible and pg_statistics_obj_is_visible.
  • Each visibility function uses the lookups of reg.rs, so it finds the object in the schemas of search_path as namespace.c does. An OID that no object has gives a null. An operator class or an operator family is visible only when the first one with the same name and the same access method is the same object.
  • pg_get_userbyid gives the name of the role, or unknown (OID=n) for an OID that no role has.
  • obj_description, col_description and shobj_description are SQL functions in PostgreSQL. The engine runs a kernel for each one, with the same result as the SQL text in system_functions.sql.
  • rupg-pgcatalog loads the rows of pg_description and pg_shdescription, and gives the rows of pg_ts_parser, pg_ts_template, pg_opclass, pg_opfamily and pg_conversion by name and by OID.

Limits

The catalog has the built-in objects and comments only. The objects that the scripts of initdb add, such as the system views, the ICU collations and the snowball dictionaries, are not there yet. There is no extended statistics object, so pg_statistics_obj_is_visible gives a null for each OID.

Tests

  • The new test catalog_information_functions in rupg-exec runs 85 queries. Each expected value is the output of the PostgreSQL 19 oracle for the same query. The counts over the catalogs use only the OIDs below 10000, because the scripts of initdb add more rows.
  • cargo fmt, cargo clippy --workspace --all-targets -D warnings, cargo test --workspace and the cargo xtask checks pass on server1.

@tamnd tamnd added this to the M2: Connect and introspect milestone Oct 8, 2026
@tamnd tamnd added kind/feature It does not do something that it must do. area/catalog The catalog, pg_catalog, information_schema and the statistics views. area/functions Built-in functions and operators. labels Oct 8, 2026
@tamnd tamnd self-assigned this Oct 8, 2026
@tamnd
tamnd merged commit d65884c into main Oct 8, 2026
5 checks passed
@tamnd
tamnd deleted the m2-catinfo branch October 8, 2026 04:47
This was referenced Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/catalog The catalog, pg_catalog, information_schema and the statistics views. area/functions Built-in functions and operators. kind/feature It does not do something that it must do.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant