codekingpro/portable-devtools
114k
1/*-------------------------------------------------------------------------2 *3 * pg_attrdef.h4 * definition of the "attribute defaults" system catalog (pg_attrdef)5 *6 *7 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group8 * Portions Copyright (c) 1994, Regents of the University of California9 *10 * src/include/catalog/pg_attrdef.h11 *12 * NOTES13 * The Catalog.pm module reads this file and derives schema14 * information.15 *16 *-------------------------------------------------------------------------17 */18#ifndef PG_ATTRDEF_H19#define PG_ATTRDEF_H20 21#include "catalog/genbki.h"22#include "catalog/objectaddress.h"23#include "catalog/pg_attrdef_d.h"24 25/* ----------------26 * pg_attrdef definition. cpp turns this into27 * typedef struct FormData_pg_attrdef28 * ----------------29 */30CATALOG(pg_attrdef,2604,AttrDefaultRelationId)31{32 Oid oid; /* oid */33 34 Oid adrelid BKI_LOOKUP(pg_class); /* OID of table containing35 * attribute */36 int16 adnum; /* attnum of attribute */37 38#ifdef CATALOG_VARLEN /* variable-length fields start here */39 pg_node_tree adbin BKI_FORCE_NOT_NULL; /* nodeToString representation of40 * default */41#endif42} FormData_pg_attrdef;43 44/* ----------------45 * Form_pg_attrdef corresponds to a pointer to a tuple with46 * the format of pg_attrdef relation.47 * ----------------48 */49typedef FormData_pg_attrdef *Form_pg_attrdef;50 51DECLARE_TOAST(pg_attrdef, 2830, 2831);52 53DECLARE_UNIQUE_INDEX(pg_attrdef_adrelid_adnum_index, 2656, AttrDefaultIndexId, on pg_attrdef using btree(adrelid oid_ops, adnum int2_ops));54DECLARE_UNIQUE_INDEX_PKEY(pg_attrdef_oid_index, 2657, AttrDefaultOidIndexId, on pg_attrdef using btree(oid oid_ops));55 56DECLARE_FOREIGN_KEY((adrelid, adnum), pg_attribute, (attrelid, attnum));57 58 59extern Oid StoreAttrDefault(Relation rel, AttrNumber attnum,60 Node *expr, bool is_internal,61 bool add_column_mode);62extern void RemoveAttrDefault(Oid relid, AttrNumber attnum,63 DropBehavior behavior,64 bool complain, bool internal);65extern void RemoveAttrDefaultById(Oid attrdefId);66 67extern Oid GetAttrDefaultOid(Oid relid, AttrNumber attnum);68extern ObjectAddress GetAttrDefaultColumnAddress(Oid attrdefoid);69 70#endif /* PG_ATTRDEF_H */71 