summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane2022-03-21 18:38:23 +0000
committerTom Lane2022-03-21 18:38:23 +0000
commit17f3bc09284e1b529cdf524bbba709af6493f30c (patch)
tree1b4d7460118487d5c560657e1b09804df8edd401 /src/include
parent7b6ec86532c2ca585d671239bba867fe380448ed (diff)
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
Diffstat (limited to 'src/include')
-rw-r--r--src/include/catalog/heap.h8
-rw-r--r--src/include/catalog/pg_attrdef.h13
2 files changed, 14 insertions, 7 deletions
diff --git a/src/include/catalog/heap.h b/src/include/catalog/heap.h
index c4757bda2d5..07c5b88f0e3 100644
--- a/src/include/catalog/heap.h
+++ b/src/include/catalog/heap.h
@@ -117,10 +117,6 @@ extern List *AddRelationNewConstraints(Relation rel,
extern void RelationClearMissing(Relation rel);
extern void SetAttrMissing(Oid relid, char *attname, char *value);
-extern Oid StoreAttrDefault(Relation rel, AttrNumber attnum,
- Node *expr, bool is_internal,
- bool add_column_mode);
-
extern Node *cookDefault(ParseState *pstate,
Node *raw_default,
Oid atttypid,
@@ -132,9 +128,7 @@ extern void DeleteRelationTuple(Oid relid);
extern void DeleteAttributeTuples(Oid relid);
extern void DeleteSystemAttributeTuples(Oid relid);
extern void RemoveAttributeById(Oid relid, AttrNumber attnum);
-extern void RemoveAttrDefault(Oid relid, AttrNumber attnum,
- DropBehavior behavior, bool complain, bool internal);
-extern void RemoveAttrDefaultById(Oid attrdefId);
+
extern void CopyStatistics(Oid fromrelid, Oid torelid);
extern void RemoveStatistics(Oid relid, AttrNumber attnum);
diff --git a/src/include/catalog/pg_attrdef.h b/src/include/catalog/pg_attrdef.h
index 2916feb5c93..a21dd3812bc 100644
--- a/src/include/catalog/pg_attrdef.h
+++ b/src/include/catalog/pg_attrdef.h
@@ -19,6 +19,7 @@
#define PG_ATTRDEF_H
#include "catalog/genbki.h"
+#include "catalog/objectaddress.h"
#include "catalog/pg_attrdef_d.h"
/* ----------------
@@ -54,4 +55,16 @@ DECLARE_UNIQUE_INDEX_PKEY(pg_attrdef_oid_index, 2657, AttrDefaultOidIndexId, on
DECLARE_FOREIGN_KEY((adrelid, adnum), pg_attribute, (attrelid, attnum));
+
+extern Oid StoreAttrDefault(Relation rel, AttrNumber attnum,
+ Node *expr, bool is_internal,
+ bool add_column_mode);
+extern void RemoveAttrDefault(Oid relid, AttrNumber attnum,
+ DropBehavior behavior,
+ bool complain, bool internal);
+extern void RemoveAttrDefaultById(Oid attrdefId);
+
+extern Oid GetAttrDefaultOid(Oid relid, AttrNumber attnum);
+extern ObjectAddress GetAttrDefaultColumnAddress(Oid attrdefoid);
+
#endif /* PG_ATTRDEF_H */