Repository navigation
Fix shard-hiding filter on pg_class under outer joins - #8992
Gilles Darold (darold) wants to merge 1 commit into
Conversation
FilterShardsFromPgclass() adds "relation_is_a_known_shard(oid) IS NOT TRUE" to the top-level quals of any query that reads pg_class. The Var for pg_class.oid was built with empty varnullingrels, even when pg_class is on the nullable side of an outer join. Since PG16, a Var that references a nullable relation from above the outer join must carry the join's RT index in varnullingrels. Without it the planner gets an inconsistent tree; on PG18 this fails during deconstruct_jointree() with: ERROR: negative bitmapset member not allowed for queries as simple as: SELECT c.relname FROM pg_class c LEFT JOIN pg_class t ON c.reltoastrelid = t.oid; As a result, vacuumdb on PostgreSQL 18 fails on every database with the extension, because it builds its relation list with this kind of join. Walk the jointree to collect the RT indexes of the outer joins that null the pg_class RTE (right side of LEFT JOIN, left side of RIGHT JOIN, both sides of FULL JOIN) and set them in the filter Var's varnullingrels. The filter placement and its semantics are unchanged.
|
@microsoft-github-policy-service agree |
|
Thanks for your contribution, though #8973 is already covering this case and in progress to merge soon. Please take a look and let us know if you dont agree. |
|
The patch your are pointing need to be rebased on master, it can't be applied. I don't have time to do that because a lot of thing have changed in the code but reading the patch it seems to fix the issue and also cover PG19 changes that I have not verified. If the tests I have provided above pass successfully before merging you can consider that commit 42b2389 fix this issue. Then you can close this PR and the related issue. |
|
Hi, explain select c.relkind, am.amname from pg_catalog.pg_class c left join pg_catalog.pg_class tc on (c.reltoastrelid = tc.oid) left join pg_catalog.pg_am am on (c.relam = am.oid) where c.oid = 1259; set citus.show_shards_for_app_name_prefixes = '*' makes it plan normally, consistent with the shard-hiding filter being the cause. Thanks for reading. |
FilterShardsFromPgclass() adds "relation_is_a_known_shard(oid) IS NOT TRUE" to the top-level quals of any query that reads pg_class. The Var for pg_class.oid was built with empty varnullingrels, even when pg_class is on the nullable side of an outer join. Since PG16, a Var that references a nullable relation from above the outer join must carry the join's RT index in varnullingrels. Without it the planner gets an inconsistent tree; on PG18 this fails during deconstruct_jointree() with:
ERROR: negative bitmapset member not allowed
for queries as simple as:
SELECT c.relname FROM pg_class c
LEFT JOIN pg_class t ON c.reltoastrelid = t.oid;
As a result, vacuumdb on PostgreSQL 18 fails on every database with the extension, because it builds its relation list with this kind of join.
Walk the jointree to collect the RT indexes of the outer joins that null the pg_class RTE (right side of LEFT JOIN, left side of RIGHT JOIN, both sides of FULL JOIN) and set them in the filter Var's varnullingrels. The filter placement and its semantics are unchanged.
DESCRIPTION: PR description that will go into the change log, up to 78 characters