| From: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
|---|---|
| To: | "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | CheckAttributeType() forgot to recurse into multiranges |
| Date: | 2026-04-22 20:56:12 |
| Message-ID: | 93ce56cd-02a6-4db1-8224-c8999372facc@iki.fi |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Don-t-allow-composite-type-to-be-member-of-itself-vi.patch | text/x-patch | 4.9 KB |
| 0002-Don-t-call-CheckAttributeType-with-InvalidOid-on-dro.patch | text/x-patch | 1.6 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Heikki Linnakangas | 2026-04-22 21:11:51 | Re: Reduce build times of pg_trgm GIN indexes |
| Previous Message | Mok | 2026-04-22 20:18:55 | New vacuum config to avoid anti wraparound vacuums |