Fix pg_catalog compliance for strict PG wire clients#3
Merged
Conversation
Three categories of pg_catalog gaps that break strict PostgreSQL drivers (Npgsql 4.0/4.1/8.0, used by PowerBI/.NET) and BI tools (DBeaver, pgAdmin): 1. pg_type / pg_namespace NOT NULL + schema compliance (default_views.cpp) PostgreSQL declares typnotnull/typdelim/typinput/typoutput/typreceive/ typsend NOT NULL; the view hardcoded them NULL, so Npgsql's type loader (reads every column as a non-nullable string) crashed on connect. Now: typnotnull=false, typdelim=',', typinput/typoutput/typreceive/typsend=0. The base branch also emitted NULL oids for unmappable types; those rows are now filtered out (oid is NOT NULL in PG, and a NULL oid breaks driver type-loading). Built-in types' typnamespace now routes to pg_catalog (via the `internal` flag) so a driver joining typnamespace->pg_namespace resolves them as pg_catalog.<type>, matching its built-in readers; user enums keep their real schema. pg_namespace drops the now-redundant type-host clause. 2. Twelve standard catalog tables (default_views.cpp) pg_roles (one synthetic superuser), pg_extension, pg_foreign_data_wrapper, pg_foreign_server, pg_shdescription, pg_conversion, pg_aggregate, pg_trigger, pg_rewrite, pg_inherits, pg_language, pg_range. Mostly empty stubs carrying the columns clients join/select, so introspection queries parse and resolve to zero rows instead of erroring on a missing table. 3. Catalog functions (default_functions.cpp) pg_relation_size/pg_total_relation_size/pg_table_size/pg_indexes_size/ pg_stat_get_numscans (->0), pg_get_indexdef/pg_get_triggerdef/ pg_get_ruledef (->''), pg_get_userbyid (->'postgres'), pg_encoding_to_char (->'UTF8'), and a 3-arg pg_get_expr (pretty flag). Tests: pg_type non-null columns + no-NULL-oid + pg_catalog typnamespace assertions; a new pg_catalog_compat.test covering every added table and function; sqlalchemy.test updated for built-ins-in-pg_catalog. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes a set of
pg_catalognon-compliance gaps that break strict PostgreSQL wire-protocol clients — confirmed against Npgsql 4.0.12 / 4.1.12 / 8.0.6 (the .NET driver behind PowerBI) and BI tools (DBeaver, pgAdmin) connecting throughvgi-postgresql. All changes are SQL view / macro literals — no C++ or parser changes.1.
pg_type/pg_namespaceNOT-NULL + schema compliance (default_views.cpp)PostgreSQL declares
typnotnull,typdelim,typinput,typoutput,typreceive,typsendasNOT NULL. The view hardcoded themNULL, so Npgsql's type loader (which reads every column as a non-nullable string) threw on connect. Now:typnotnull=false,typdelim=',',typinput/typoutput/typreceive/typsend=0.UNION ALLbranch emitted aNULLoid for typesmap_to_pg_oidcan't represent; those rows are now filtered out.typnamespacenow routes topg_catalog(via theinternalflag); user enums keep their real schema.pg_namespacedrops the now-redundant type-host clause.2. Twelve standard catalog tables (
default_views.cpp)pg_roles(one synthetic superuser),pg_extension,pg_foreign_data_wrapper,pg_foreign_server,pg_shdescription,pg_conversion,pg_aggregate,pg_trigger,pg_rewrite,pg_inherits,pg_language,pg_range— mostly empty stubs carrying the columns clients join/select.3. Catalog functions (
default_functions.cpp)pg_relation_size/pg_total_relation_size/pg_table_size/pg_indexes_size/pg_stat_get_numscans(-> 0),pg_get_indexdef/pg_get_triggerdef/pg_get_ruledef(-> ''),pg_get_userbyid(-> 'postgres'),pg_encoding_to_char(-> 'UTF8'), and a 3-argpg_get_expr.Tests
[pg_catalog]-> 489 assertions / 19 cases pass;[catalog]-> 1554 / 56 pass. Newpg_catalog_compat.testplus extendedpg_type.testand updatedsqlalchemy.test.🤖 Generated with Claude Code