CheckAttributeType() forgot to recurse into multiranges
Heikki Linnakangas <hlinnaka@iki.fi>
From: Heikki Linnakangas <hlinnaka@iki.fi>
To: "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2026-04-22T20:56:12Z
Lists: pgsql-hackers
Attachments
- 0001-Don-t-allow-composite-type-to-be-member-of-itself-vi.patch (text/x-patch) patch 0001
- 0002-Don-t-call-CheckAttributeType-with-InvalidOid-on-dro.patch (text/x-patch) patch 0002
Happened to spot this little bug: create type two_ints as (a int, b int); create type two_ints_range as range (subtype = two_ints); -- CheckAttributeType() forbids this: alter type two_ints add attribute c two_ints_range; ERROR: composite type two_ints cannot be made a member of itself -- But the same with a multirange is allowed: alter type two_ints add attribute c two_ints_multirange; ALTER TYPE That looks like a straightforward oversight in CheckAttributeType(). When multiranges were introduced, it didn't get the memo. Fix attached. Assuming no objections, I'll commit and backpatch that. While working on the fix, I noticed that in case of dropped columns, CheckAttributeType() is called with InvalidOid. It tolerates that, but it seems accidental and it performs a bunch of futile syscache lookups with InvalidOid, so it would be better to not do that. The second patch fixes that. - Heikki
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Don't allow composite type to be member of itself via multirange
- c7a1d5fc6513 14.23 landed
- 34ebeb15c8b1 15.18 landed
- 06e304524d5c 16.14 landed
- 54343f6f9046 17.10 landed
- ff8f27d6eae2 18.4 landed
- dd4069197650 19 (unreleased) landed
-
Don't call CheckAttributeType() with InvalidOid on dropped cols
- d2f58c42a261 14.23 landed
- e1830ebf5219 15.18 landed
- 526d9ca619cc 16.14 landed
- d54e75441518 17.10 landed
- 01db3f0398fd 18.4 landed
- 713bce9484de 19 (unreleased) landed