Skip to content

put pg_catalog implicitly on the search_path when it isn't there already#2223

Merged
zachmu merged 3 commits intomainfrom
zachmu/regclass
Jan 22, 2026
Merged

put pg_catalog implicitly on the search_path when it isn't there already#2223
zachmu merged 3 commits intomainfrom
zachmu/regclass

Conversation

@zachmu
Copy link
Copy Markdown
Member

@zachmu zachmu commented Jan 22, 2026

pg_catalog is always implicitly the first element on the search_path, unless it's explicitly included elsewhere:

https://www.postgresql.org/docs/current/ddl-schemas.html#DDL-SCHEMAS-CATALOG

We weren't implementing this behavior, causing us to fail to resolve ::regclass expressions in some cases with a "no such relation" error for all pg_catalog tables.

This fix isn't complete, because the same logic should also apply to all table lookups. i.e. users should be able to create a table named pg_class, and what the name pg_class resolves to depends on whether the pg_catalog schema is explicitly present in the search_path and where it is relative to the user's other schemas. That's a pretty obscure bug and is left unaddressed for now.

Fixes #2217

@zachmu zachmu requested a review from Hydrocharged January 22, 2026 01:14
@github-actions
Copy link
Copy Markdown
Contributor

Main PR
covering_index_scan_postgres 536.43/s 526.43/s -1.9%
index_join_postgres 147.29/s 149.45/s +1.4%
index_join_scan_postgres 260.06/s 262.62/s +0.9%
index_scan_postgres 13.21/s 13.26/s +0.3%
oltp_point_select 2622.02/s 2635.91/s +0.5%
oltp_read_only 2010.38/s 2094.89/s +4.2%
select_random_points 137.77/s 139.47/s +1.2%
select_random_ranges 421.60/s 413.07/s -2.1%
table_scan_postgres 12.93/s 13.00/s +0.5%
types_table_scan_postgres 6.03/s 6.01/s -0.4%

@github-actions
Copy link
Copy Markdown
Contributor

Main PR
Total 42090 42090
Successful 17563 17564
Failures 24527 24526
Partial Successes1 5582 5582
Main PR
Successful 41.7273% 41.7296%
Failures 58.2727% 58.2704%

${\color{lightgreen}Progressions (1)}$

regproc

QUERY: SELECT to_regclass('pg_class');

Footnotes

  1. These are tests that we're marking as Successful, however they do not match the expected output in some way. This is due to small differences, such as different wording on the error messages, or the column names being incorrect while the data itself is correct.

Copy link
Copy Markdown
Collaborator

@Hydrocharged Hydrocharged left a comment

Choose a reason for hiding this comment

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

LGTM! There are several places that don't use the search path function since they manually handle (or try to handle) the pg_catalog part, but those can be cleaned up in a different PR.

@zachmu zachmu merged commit ea22964 into main Jan 22, 2026
21 checks passed
@zachmu zachmu deleted the zachmu/regclass branch January 22, 2026 17:54
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.

filter with 'pg_class'::regclass produces relation "pg_class" does not exist error when Eval is called during simplifyFilters

2 participants