Move pg_attrdef manipulation code into new file catalog/pg_attrdef.c.
Tom Lane <tgl@sss.pgh.pa.us>
Move pg_attrdef manipulation code into new file catalog/pg_attrdef.c. This is a pure refactoring commit: there isn't (I hope) any functional change. StoreAttrDefault and RemoveAttrDefault[ById] are moved from heap.c, reducing the size of that overly-large file by about 300 lines. I took the opportunity to trim unused #includes from heap.c, too. Two new functions for translating between a pg_attrdef OID and the relid/attnum of the owning column are created by extracting ad-hoc code from objectaddress.c. This already removes one copy of said code, and a follow-on bug fix will create more callers. The only other function directly manipulating pg_attrdef is AttrDefaultFetch. I judged it was better to leave that in relcache.c, since it shares special concerns about recursion and error handling with the rest of that module. Discussion: https://postgr.es/m/651168.1647451676@sss.pgh.pa.us
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/catalog/heap.c | modified | +0 −330 |
| src/backend/catalog/Makefile | modified | +1 −0 |
| src/backend/catalog/objectaddress.c | modified | +6 −89 |
| src/backend/catalog/pg_attrdef.c | added | +428 −0 |
| src/backend/commands/tablecmds.c | modified | +1 −0 |
| src/include/catalog/heap.h | modified | +1 −7 |
| src/include/catalog/pg_attrdef.h | modified | +13 −0 |
Discussion
- BUG #17439: DROP FUNCTION functionName(); drops associated generated column without using CASCADE 9 messages · 2022-03-15 → 2022-03-16