PostgreSQL Source Code
git master
|
#include "catalog/dependency.h"
#include "catalog/genbki.h"
#include "catalog/pg_constraint_d.h"
#include "nodes/pg_list.h"
Go to the source code of this file.
Macros | |
#define | ConstraintNameNspIndexId 2664 |
#define | ConstraintRelidTypidNameIndexId 2665 |
#define | ConstraintTypidIndexId 2666 |
#define | ConstraintOidIndexId 2667 |
#define | ConstraintParentIndexId 2579 |
Typedefs | |
typedef FormData_pg_constraint * | Form_pg_constraint |
typedef enum ConstraintCategory | ConstraintCategory |
Enumerations | |
enum | ConstraintCategory { CONSTRAINT_RELATION, CONSTRAINT_DOMAIN, CONSTRAINT_ASSERTION } |
Functions | |
CATALOG (pg_constraint, 2606, ConstraintRelationId) | |
DECLARE_TOAST (pg_constraint, 2832, 2833) | |
DECLARE_INDEX (pg_constraint_conname_nsp_index, 2664, on pg_constraint using btree(conname name_ops, connamespace oid_ops)) | |
DECLARE_UNIQUE_INDEX (pg_constraint_conrelid_contypid_conname_index, 2665, on pg_constraint using btree(conrelid oid_ops, contypid oid_ops, conname name_ops)) | |
DECLARE_INDEX (pg_constraint_contypid_index, 2666, on pg_constraint using btree(contypid oid_ops)) | |
DECLARE_UNIQUE_INDEX (pg_constraint_oid_index, 2667, on pg_constraint using btree(oid oid_ops)) | |
DECLARE_INDEX (pg_constraint_conparentid_index, 2579, on pg_constraint using btree(conparentid oid_ops)) | |
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, char foreignMatchType, const Oid *exclOp, Node *conExpr, const char *conBin, bool conIsLocal, int conInhCount, bool conNoInherit, bool is_internal) |
void | RemoveConstraintById (Oid conId) |
void | RenameConstraintById (Oid conId, const char *newname) |
bool | ConstraintNameIsUsed (ConstraintCategory conCat, Oid objId, const char *conname) |
bool | ConstraintNameExists (const char *conname, Oid namespaceid) |
char * | ChooseConstraintName (const char *name1, const char *name2, const char *label, Oid namespaceid, List *others) |
void | AlterConstraintNamespaces (Oid ownerId, Oid oldNspId, Oid newNspId, bool isType, ObjectAddresses *objsMoved) |
void | ConstraintSetParentConstraint (Oid childConstrId, Oid parentConstrId, Oid childTableId) |
Oid | get_relation_constraint_oid (Oid relid, const char *conname, bool missing_ok) |
Bitmapset * | get_relation_constraint_attnos (Oid relid, const char *conname, bool missing_ok, Oid *constraintOid) |
Oid | get_domain_constraint_oid (Oid typid, const char *conname, bool missing_ok) |
Oid | get_relation_idx_constraint_oid (Oid relationId, Oid indexId) |
Bitmapset * | get_primary_key_attnos (Oid relid, bool deferrableOk, Oid *constraintOid) |
void | DeconstructFkConstraintRow (HeapTuple tuple, int *numfks, AttrNumber *conkey, AttrNumber *confkey, Oid *pf_eq_oprs, Oid *pp_eq_oprs, Oid *ff_eq_oprs) |
bool | check_functional_grouping (Oid relid, Index varno, Index varlevelsup, List *grouping_columns, List **constraintDeps) |
Variables | |
FormData_pg_constraint | |
#define ConstraintNameNspIndexId 2664 |
Definition at line 159 of file pg_constraint.h.
Referenced by AfterTriggerSetState(), ChooseConstraintName(), and ConstraintNameExists().
#define ConstraintOidIndexId 2667 |
Definition at line 165 of file pg_constraint.h.
Referenced by CreateConstraintEntry(), heap_truncate_find_FKs(), and pg_get_constraintdef_worker().
#define ConstraintParentIndexId 2579 |
Definition at line 167 of file pg_constraint.h.
Referenced by AfterTriggerSetState().
#define ConstraintRelidTypidNameIndexId 2665 |
Definition at line 161 of file pg_constraint.h.
Referenced by AlterConstraintNamespaces(), AlterDomainDropConstraint(), AlterDomainValidateConstraint(), ATExecAlterConstraint(), ATExecDropConstraint(), ATExecValidateConstraint(), ATPrepChangePersistence(), CheckConstraintFetch(), ConstraintNameIsUsed(), get_domain_constraint_oid(), get_primary_key_attnos(), get_relation_constraint_attnos(), get_relation_constraint_oid(), get_relation_idx_constraint_oid(), MergeConstraintsIntoExisting(), MergeWithExistingConstraint(), RelationGetExclusionInfo(), RelationGetFKeyList(), and RemoveInheritance().
#define ConstraintTypidIndexId 2666 |
Definition at line 163 of file pg_constraint.h.
Referenced by load_domaintype_info().
typedef enum ConstraintCategory ConstraintCategory |
typedef FormData_pg_constraint* Form_pg_constraint |
Definition at line 154 of file pg_constraint.h.
enum ConstraintCategory |
Enumerator | |
---|---|
CONSTRAINT_RELATION | |
CONSTRAINT_DOMAIN | |
CONSTRAINT_ASSERTION |
Definition at line 190 of file pg_constraint.h.
void AlterConstraintNamespaces | ( | Oid | ownerId, |
Oid | oldNspId, | ||
Oid | newNspId, | ||
bool | isType, | ||
ObjectAddresses * | objsMoved | ||
) |
Definition at line 700 of file pg_constraint.c.
References add_exact_object_address(), BTEqualStrategyNumber, CatalogTupleUpdate(), ConstraintRelidTypidNameIndexId, GETSTRUCT, heap_copytuple(), HeapTupleIsValid, InvalidOid, InvokeObjectPostAlterHook, sort-test::key, object_address_present(), ObjectAddressSet, ObjectAddress::objectId, ObjectIdGetDatum, RowExclusiveLock, ScanKeyInit(), systable_beginscan(), systable_endscan(), systable_getnext(), HeapTupleData::t_self, table_close(), and table_open().
Referenced by AlterTableNamespaceInternal(), and AlterTypeNamespaceInternal().
CATALOG | ( | pg_constraint | , |
2606 | , | ||
ConstraintRelationId | |||
) |
Definition at line 31 of file pg_constraint.h.
bool check_functional_grouping | ( | Oid | relid, |
Index | varno, | ||
Index | varlevelsup, | ||
List * | grouping_columns, | ||
List ** | constraintDeps | ||
) |
Definition at line 1282 of file pg_constraint.c.
References bms_add_member(), bms_is_subset(), FirstLowInvalidHeapAttributeNumber, get_primary_key_attnos(), IsA, lappend_oid(), lfirst, Var::varattno, Var::varlevelsup, and Var::varno.
Referenced by check_ungrouped_columns_walker().
char* ChooseConstraintName | ( | const char * | name1, |
const char * | name2, | ||
const char * | label, | ||
Oid | namespaceid, | ||
List * | others | ||
) |
Definition at line 487 of file pg_constraint.c.
References AccessShareLock, BTEqualStrategyNumber, ConstraintNameNspIndexId, CStringGetDatum, HeapTupleIsValid, lfirst, makeObjectName(), NAMEDATALEN, ObjectIdGetDatum, pfree(), ScanKeyInit(), snprintf, strlcpy(), systable_beginscan(), systable_endscan(), systable_getnext(), table_close(), and table_open().
Referenced by addFkRecurseReferenced(), addFkRecurseReferencing(), AddRelationNewConstraints(), ATExecAddConstraint(), CloneFkReferencing(), and domainAddConstraint().
Definition at line 433 of file pg_constraint.c.
References AccessShareLock, BTEqualStrategyNumber, ConstraintNameNspIndexId, CStringGetDatum, HeapTupleIsValid, ObjectIdGetDatum, ScanKeyInit(), systable_beginscan(), systable_endscan(), systable_getnext(), table_close(), and table_open().
Referenced by ChooseRelationName().
bool ConstraintNameIsUsed | ( | ConstraintCategory | conCat, |
Oid | objId, | ||
const char * | conname | ||
) |
Definition at line 388 of file pg_constraint.c.
References AccessShareLock, BTEqualStrategyNumber, CONSTRAINT_DOMAIN, CONSTRAINT_RELATION, ConstraintRelidTypidNameIndexId, CStringGetDatum, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, ScanKeyInit(), systable_beginscan(), systable_endscan(), systable_getnext(), table_close(), and table_open().
Referenced by addFkRecurseReferenced(), addFkRecurseReferencing(), ATExecAddConstraint(), CloneFkReferencing(), domainAddConstraint(), index_create(), and RenameConstraintById().
Definition at line 769 of file pg_constraint.c.
References Assert, CatalogTupleUpdate(), CONSTROID, deleteDependencyRecordsForClass(), DEPENDENCY_PARTITION_PRI, DEPENDENCY_PARTITION_SEC, elog, ERROR, GETSTRUCT, heap_copytuple(), HeapTupleIsValid, InvalidOid, ObjectAddressSet, ObjectIdGetDatum, OidIsValid, recordDependencyOn(), ReleaseSysCache(), RowExclusiveLock, SearchSysCache1(), HeapTupleData::t_self, table_close(), and table_open().
Referenced by ATExecAttachPartitionIdx(), ATExecDetachPartition(), AttachPartitionEnsureIndexes(), DefineIndex(), and tryAttachPartitionForeignKey().
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, | ||
char | foreignMatchType, | ||
const Oid * | exclOp, | ||
Node * | conExpr, | ||
const char * | conBin, | ||
bool | conIsLocal, | ||
int | conInhCount, | ||
bool | conNoInherit, | ||
bool | is_internal | ||
) |
Definition at line 50 of file pg_constraint.c.
References add_exact_object_address(), Assert, BoolGetDatum, CatalogTupleInsert(), CharGetDatum, ObjectAddress::classId, ConstraintOidIndexId, construct_array(), CStringGetTextDatum, DEPENDENCY_AUTO, DEPENDENCY_NORMAL, free_object_addresses(), GetNewOidWithIndex(), heap_form_tuple(), i, Int16GetDatum, Int32GetDatum, InvokeObjectPostCreateHookArg, NameGetDatum, namestrcpy(), new_object_addresses(), ObjectAddressSet, ObjectAddressSubSet, ObjectAddress::objectId, ObjectIdGetDatum, ObjectAddress::objectSubId, OidIsValid, palloc(), PointerGetDatum, record_object_address_dependencies(), recordDependencyOnSingleRelExpr(), RelationGetDescr, RowExclusiveLock, table_close(), table_open(), and values.
Referenced by addFkRecurseReferenced(), addFkRecurseReferencing(), CloneFkReferencing(), CreateTrigger(), domainAddConstraint(), index_constraint_create(), and StoreRelCheck().
DECLARE_INDEX | ( | pg_constraint_conname_nsp_index | , |
2664 | , | ||
on pg_constraint using | btreeconname name_ops, connamespace oid_ops | ||
) |
DECLARE_INDEX | ( | pg_constraint_contypid_index | , |
2666 | , | ||
on pg_constraint using | btreecontypid oid_ops | ||
) |
DECLARE_INDEX | ( | pg_constraint_conparentid_index | , |
2579 | , | ||
on pg_constraint using | btreeconparentid oid_ops | ||
) |
DECLARE_TOAST | ( | pg_constraint | , |
2832 | , | ||
2833 | |||
) |
DECLARE_UNIQUE_INDEX | ( | pg_constraint_conrelid_contypid_conname_index | , |
2665 | , | ||
on pg_constraint using | btreeconrelid oid_ops, contypid oid_ops, conname name_ops | ||
) |
DECLARE_UNIQUE_INDEX | ( | pg_constraint_oid_index | , |
2667 | , | ||
on pg_constraint using | btreeoid oid_ops | ||
) |
void DeconstructFkConstraintRow | ( | HeapTuple | tuple, |
int * | numfks, | ||
AttrNumber * | conkey, | ||
AttrNumber * | confkey, | ||
Oid * | pf_eq_oprs, | ||
Oid * | pp_eq_oprs, | ||
Oid * | ff_eq_oprs | ||
) |
Definition at line 1164 of file pg_constraint.c.
References ARR_DATA_PTR, ARR_DIMS, ARR_ELEMTYPE, ARR_HASNULL, ARR_NDIM, CONSTROID, DatumGetArrayTypeP, DatumGetPointer, elog, ERROR, GETSTRUCT, INDEX_MAX_KEYS, pfree(), and SysCacheGetAttr().
Referenced by CloneFkReferenced(), CloneFkReferencing(), RelationGetFKeyList(), and ri_LoadConstraintInfo().
Definition at line 1020 of file pg_constraint.c.
References AccessShareLock, BTEqualStrategyNumber, ConstraintRelidTypidNameIndexId, CStringGetDatum, ereport, errcode(), errmsg(), ERROR, format_type_be(), GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, OidIsValid, ScanKeyInit(), systable_beginscan(), systable_endscan(), systable_getnext(), table_close(), and table_open().
Referenced by get_object_address(), and rename_constraint_internal().
Definition at line 1079 of file pg_constraint.c.
References AccessShareLock, ARR_DATA_PTR, ARR_DIMS, ARR_ELEMTYPE, ARR_HASNULL, ARR_NDIM, bms_add_member(), BTEqualStrategyNumber, ConstraintRelidTypidNameIndexId, DatumGetArrayTypeP, elog, ERROR, FirstLowInvalidHeapAttributeNumber, GETSTRUCT, heap_getattr, HeapTupleIsValid, i, InvalidOid, ObjectIdGetDatum, RelationGetDescr, ScanKeyInit(), systable_beginscan(), systable_endscan(), systable_getnext(), table_close(), and table_open().
Referenced by check_functional_grouping(), and remove_useless_groupby_columns().
Bitmapset* get_relation_constraint_attnos | ( | Oid | relid, |
const char * | conname, | ||
bool | missing_ok, | ||
Oid * | constraintOid | ||
) |
Definition at line 895 of file pg_constraint.c.
References AccessShareLock, ARR_DATA_PTR, ARR_DIMS, ARR_ELEMTYPE, ARR_HASNULL, ARR_NDIM, bms_add_member(), BTEqualStrategyNumber, ConstraintRelidTypidNameIndexId, CStringGetDatum, DatumGetArrayTypeP, elog, ereport, errcode(), errmsg(), ERROR, FirstLowInvalidHeapAttributeNumber, get_rel_name(), GETSTRUCT, heap_getattr, HeapTupleIsValid, i, InvalidOid, ObjectIdGetDatum, OidIsValid, RelationGetDescr, ScanKeyInit(), systable_beginscan(), systable_endscan(), systable_getnext(), table_close(), and table_open().
Referenced by transformOnConflictArbiter().
Definition at line 838 of file pg_constraint.c.
References AccessShareLock, BTEqualStrategyNumber, ConstraintRelidTypidNameIndexId, CStringGetDatum, ereport, errcode(), errmsg(), ERROR, get_rel_name(), GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, OidIsValid, ScanKeyInit(), systable_beginscan(), systable_endscan(), systable_getnext(), table_close(), and table_open().
Referenced by expandTableLikeClause(), get_object_address_relobject(), and rename_constraint_internal().
Definition at line 980 of file pg_constraint.c.
References AccessShareLock, BTEqualStrategyNumber, ConstraintRelidTypidNameIndexId, GETSTRUCT, InvalidOid, sort-test::key, ObjectIdGetDatum, ScanKeyInit(), systable_beginscan(), systable_endscan(), systable_getnext(), table_close(), and table_open().
Referenced by ATExecAttachPartitionIdx(), ATExecDetachPartition(), AttachPartitionEnsureIndexes(), and DefineIndex().
void RemoveConstraintById | ( | Oid | conId | ) |
Definition at line 557 of file pg_constraint.c.
References AccessExclusiveLock, CatalogTupleDelete(), CatalogTupleUpdate(), CONSTROID, elog, ERROR, GETSTRUCT, heap_freetuple(), HeapTupleIsValid, NoLock, ObjectIdGetDatum, OidIsValid, RelationGetRelationName, ReleaseSysCache(), RELOID, RowExclusiveLock, SearchSysCache1(), SearchSysCacheCopy1, HeapTupleData::t_self, table_close(), and table_open().
Referenced by doDeletion().
void RenameConstraintById | ( | Oid | conId, |
const char * | newname | ||
) |
Definition at line 648 of file pg_constraint.c.
References CatalogTupleUpdate(), CONSTRAINT_DOMAIN, CONSTRAINT_RELATION, ConstraintNameIsUsed(), CONSTROID, elog, ereport, errcode(), ERRCODE_DUPLICATE_OBJECT, errmsg(), ERROR, format_type_be(), get_rel_name(), GETSTRUCT, heap_freetuple(), HeapTupleIsValid, InvokeObjectPostAlterHook, namestrcpy(), ObjectIdGetDatum, OidIsValid, RowExclusiveLock, SearchSysCacheCopy1, HeapTupleData::t_self, table_close(), and table_open().
Referenced by rename_constraint_internal(), and RenameRelationInternal().
FormData_pg_constraint |
Definition at line 147 of file pg_constraint.h.