* along with the relation's initial contents.
*
*
- * Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/include/catalog/pg_constraint.h
#define PG_CONSTRAINT_H
#include "catalog/genbki.h"
-#include "catalog/dependency.h"
-#include "nodes/pg_list.h"
/* ----------------
* pg_constraint definition. cpp turns this into
* relations. This is partly for backwards compatibility with past
* Postgres practice, and partly because we don't want to have to obtain a
* global lock to generate a globally unique name for a nameless
- * constraint. We associate a namespace with constraint names only for
+ * constraint. We associate a namespace with constraint names only for
* SQL-spec compatibility.
*/
NameData conname; /* name of this constraint */
/*
* contypid links to the pg_type row for a domain if this is a domain
- * constraint. Otherwise it's 0.
+ * constraint. Otherwise it's 0.
*
* For SQL-style global ASSERTIONs, both conrelid and contypid would be
* zero. This is not presently supported, however.
/*
* These fields, plus confkey, are only meaningful for a foreign-key
- * constraint. Otherwise confrelid is 0 and the char fields are spaces.
+ * constraint. Otherwise confrelid is 0 and the char fields are spaces.
*/
Oid confrelid; /* relation referenced by foreign key */
char confupdtype; /* foreign key's ON UPDATE action */
*/
int16 conkey[1];
+ /*
+ * Columns of conrelid that the constraint does not apply to,
+ * but included into the same index with key columns.
+ */
+ int16 conincluding[1];
+
/*
* If a foreign key, the referenced columns of confrelid
*/
* compiler constants for pg_constraint
* ----------------
*/
-#define Natts_pg_constraint 24
+#define Natts_pg_constraint 25
#define Anum_pg_constraint_conname 1
#define Anum_pg_constraint_connamespace 2
#define Anum_pg_constraint_contype 3
#define Anum_pg_constraint_coninhcount 15
#define Anum_pg_constraint_connoinherit 16
#define Anum_pg_constraint_conkey 17
-#define Anum_pg_constraint_confkey 18
-#define Anum_pg_constraint_conpfeqop 19
-#define Anum_pg_constraint_conppeqop 20
-#define Anum_pg_constraint_conffeqop 21
-#define Anum_pg_constraint_conexclop 22
-#define Anum_pg_constraint_conbin 23
-#define Anum_pg_constraint_consrc 24
+#define Anum_pg_constraint_conincluding 18
+#define Anum_pg_constraint_confkey 19
+#define Anum_pg_constraint_conpfeqop 20
+#define Anum_pg_constraint_conppeqop 21
+#define Anum_pg_constraint_conffeqop 22
+#define Anum_pg_constraint_conexclop 23
+#define Anum_pg_constraint_conbin 24
+#define Anum_pg_constraint_consrc 25
+
+/* ----------------
+ * initial contents of pg_constraint
+ * ----------------
+ */
+
+/* nothing, at present */
/* Valid values for contype */
* the FKCONSTR_MATCH_xxx constants defined in parsenodes.h.
*/
-/*
- * Identify constraint type for lookup purposes
- */
-typedef enum ConstraintCategory
-{
- CONSTRAINT_RELATION,
- CONSTRAINT_DOMAIN,
- CONSTRAINT_ASSERTION /* for future expansion */
-} ConstraintCategory;
-
-/*
- * prototypes for functions in pg_constraint.c
- */
-extern Oid CreateConstraintEntry(const char *constraintName,
- Oid constraintNamespace,
- char constraintType,
- bool isDeferrable,
- bool isDeferred,
- bool isValidated,
- Oid relId,
- const int16 *constraintKey,
- int constraintNKeys,
- 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,
- const char *conSrc,
- bool conIsLocal,
- int conInhCount,
- bool conNoInherit,
- bool is_internal);
-
-extern void RemoveConstraintById(Oid conId);
-extern void RenameConstraintById(Oid conId, const char *newname);
-extern void SetValidatedConstraintById(Oid conId);
-
-extern bool ConstraintNameIsUsed(ConstraintCategory conCat, Oid objId,
- Oid objNamespace, const char *conname);
-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 get_constraint_relation_oids(Oid constraint_oid, Oid *conrelid, Oid *confrelid);
-extern Oid get_relation_constraint_oid(Oid relid, const char *conname, bool missing_ok);
-extern Oid get_domain_constraint_oid(Oid typid, const char *conname, bool missing_ok);
-
-extern bool check_functional_grouping(Oid relid,
- Index varno, Index varlevelsup,
- List *grouping_columns,
- List **constraintDeps);
-
#endif /* PG_CONSTRAINT_H */