| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #ifndef PG_CONSTRAINT_H |
| #define PG_CONSTRAINT_H |
|
|
| #include "catalog/dependency.h" |
| #include "catalog/genbki.h" |
| #include "catalog/pg_constraint_d.h" |
| #include "nodes/pg_list.h" |
|
|
| |
| |
| |
| |
| |
| CATALOG(pg_constraint,2606,ConstraintRelationId) |
| { |
| Oid oid; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| NameData conname; |
| Oid connamespace BKI_LOOKUP(pg_namespace); |
| |
| char contype; |
| bool condeferrable; |
| bool condeferred; |
| bool convalidated; |
|
|
| |
| |
| |
| |
| |
| Oid conrelid BKI_LOOKUP_OPT(pg_class); |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| Oid contypid BKI_LOOKUP_OPT(pg_type); |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| Oid conindid BKI_LOOKUP_OPT(pg_class); |
| |
|
|
| |
| |
| |
| |
| Oid conparentid BKI_LOOKUP_OPT(pg_constraint); |
|
|
| |
| |
| |
| |
| Oid confrelid BKI_LOOKUP_OPT(pg_class); |
| |
| char confupdtype; |
| char confdeltype; |
| char confmatchtype; |
|
|
| |
| bool conislocal; |
|
|
| |
| int16 coninhcount; |
|
|
| |
| bool connoinherit; |
|
|
| #ifdef CATALOG_VARLEN |
|
|
| |
| |
| |
| |
| int16 conkey[1]; |
|
|
| |
| |
| |
| int16 confkey[1]; |
|
|
| |
| |
| |
| |
| Oid conpfeqop[1] BKI_LOOKUP(pg_operator); |
|
|
| |
| |
| |
| |
| Oid conppeqop[1] BKI_LOOKUP(pg_operator); |
|
|
| |
| |
| |
| |
| Oid conffeqop[1] BKI_LOOKUP(pg_operator); |
|
|
| |
| |
| |
| |
| int16 confdelsetcols[1]; |
|
|
| |
| |
| |
| |
| Oid conexclop[1] BKI_LOOKUP(pg_operator); |
|
|
| |
| |
| |
| pg_node_tree conbin; |
| #endif |
| } FormData_pg_constraint; |
|
|
| |
| |
| |
| |
| |
| typedef FormData_pg_constraint *Form_pg_constraint; |
|
|
| DECLARE_TOAST(pg_constraint, 2832, 2833); |
|
|
| DECLARE_INDEX(pg_constraint_conname_nsp_index, 2664, ConstraintNameNspIndexId, on pg_constraint using btree(conname name_ops, connamespace oid_ops)); |
| DECLARE_UNIQUE_INDEX(pg_constraint_conrelid_contypid_conname_index, 2665, ConstraintRelidTypidNameIndexId, on pg_constraint using btree(conrelid oid_ops, contypid oid_ops, conname name_ops)); |
| DECLARE_INDEX(pg_constraint_contypid_index, 2666, ConstraintTypidIndexId, on pg_constraint using btree(contypid oid_ops)); |
| DECLARE_UNIQUE_INDEX_PKEY(pg_constraint_oid_index, 2667, ConstraintOidIndexId, on pg_constraint using btree(oid oid_ops)); |
| DECLARE_INDEX(pg_constraint_conparentid_index, 2579, ConstraintParentIndexId, on pg_constraint using btree(conparentid oid_ops)); |
|
|
| |
| DECLARE_ARRAY_FOREIGN_KEY_OPT((conrelid, conkey), pg_attribute, (attrelid, attnum)); |
| DECLARE_ARRAY_FOREIGN_KEY((confrelid, confkey), pg_attribute, (attrelid, attnum)); |
|
|
| #ifdef EXPOSE_TO_CLIENT_CODE |
|
|
| |
| #define CONSTRAINT_CHECK 'c' |
| #define CONSTRAINT_FOREIGN 'f' |
| #define CONSTRAINT_PRIMARY 'p' |
| #define CONSTRAINT_UNIQUE 'u' |
| #define CONSTRAINT_TRIGGER 't' |
| #define CONSTRAINT_EXCLUSION 'x' |
|
|
| |
| |
| |
| |
| |
|
|
| #endif |
|
|
| |
| |
| |
| typedef enum ConstraintCategory |
| { |
| CONSTRAINT_RELATION, |
| CONSTRAINT_DOMAIN, |
| CONSTRAINT_ASSERTION |
| } ConstraintCategory; |
|
|
|
|
| extern Oid CreateConstraintEntry(const char *constraintName, |
| Oid constraintNamespace, |
| char constraintType, |
| bool isDeferrable, |
| bool isDeferred, |
| bool isValidated, |
| Oid parentConstrId, |
| Oid relId, |
| const int16 *constraintKey, |
| int constraintNKeys, |
| int constraintNTotalKeys, |
| Oid domainId, |
| Oid indexRelId, |
| Oid foreignRelId, |
| const int16 *foreignKey, |
| const Oid *pfEqOp, |
| const Oid *ppEqOp, |
| const Oid *ffEqOp, |
| int foreignNKeys, |
| char foreignUpdateType, |
| char foreignDeleteType, |
| const int16 *fkDeleteSetCols, |
| int numFkDeleteSetCols, |
| char foreignMatchType, |
| const Oid *exclOp, |
| Node *conExpr, |
| const char *conBin, |
| bool conIsLocal, |
| int conInhCount, |
| bool conNoInherit, |
| bool is_internal); |
|
|
| extern void RemoveConstraintById(Oid conId); |
| extern void RenameConstraintById(Oid conId, const char *newname); |
|
|
| extern bool ConstraintNameIsUsed(ConstraintCategory conCat, Oid objId, |
| const char *conname); |
| extern bool ConstraintNameExists(const char *conname, Oid namespaceid); |
| extern char *ChooseConstraintName(const char *name1, const char *name2, |
| const char *label, Oid namespaceid, |
| List *others); |
|
|
| extern void AlterConstraintNamespaces(Oid ownerId, Oid oldNspId, |
| Oid newNspId, bool isType, ObjectAddresses *objsMoved); |
| extern void ConstraintSetParentConstraint(Oid childConstrId, |
| Oid parentConstrId, |
| Oid childTableId); |
| extern Oid get_relation_constraint_oid(Oid relid, const char *conname, bool missing_ok); |
| extern Bitmapset *get_relation_constraint_attnos(Oid relid, const char *conname, |
| bool missing_ok, Oid *constraintOid); |
| extern Oid get_domain_constraint_oid(Oid typid, const char *conname, bool missing_ok); |
| extern Oid get_relation_idx_constraint_oid(Oid relationId, Oid indexId); |
|
|
| extern Bitmapset *get_primary_key_attnos(Oid relid, bool deferrableOk, |
| Oid *constraintOid); |
| extern void DeconstructFkConstraintRow(HeapTuple tuple, int *numfks, |
| AttrNumber *conkey, AttrNumber *confkey, |
| Oid *pf_eq_oprs, Oid *pp_eq_oprs, Oid *ff_eq_oprs, |
| int *num_fk_del_set_cols, AttrNumber *fk_del_set_cols); |
|
|
| extern bool check_functional_grouping(Oid relid, |
| Index varno, Index varlevelsup, |
| List *grouping_columns, |
| List **constraintDeps); |
|
|
| #endif |
|
|