/*------------------------------------------------------------------------- * * pg_constraint.h * * * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * NOTES * the genbki.sh script reads this file and generates .bki * information from the DATA() statements. * *------------------------------------------------------------------------- */ #ifndef PG_CONSTRAINT_H #define PG_CONSTRAINT_H /* ---------------- * postgres.h contains the system type definintions and the * CATALOG(), BOOTSTRAP and DATA() sugar words so this file * can be read by both genbki.sh and the C compiler. * ---------------- */ /* ---------------- * pg_constraint definition. cpp turns this into * typedef struct FormData_pg_constraint * ---------------- */ CATALOG(pg_constraint) { /* Oid of the relation this constraint constrains */ Oid conrelid; /* Name of this constraint */ NameData conname; /* * contype is the Constraint Type. * * Includes 'p'rimary keys, 'u'nique keys, 'f'oreign keys * and 'c'heck constraints. */ char contype; /* * Can application of the constraint be deferred until * transaction commit? */ bool condeferrable; /* * Is the constraint deferred until transaction commit * by default? */ bool condeferred; /* * Foreign key'd relation */ Oid confrelid; /* * confupdtype is the type of update action expected */ char confupdtype; /* * confdeltype is the type of update action expected */ char confdeltype; /* * confmatchtype the match type of the foreign key * 'f'ull or 'p'artial */ char confmatchtype; /* * Columns of conrelid that the constraint applies to */ int2 conkey[1]; /* * Foreign key'd columns */ int2 confkey[1]; /* * Source (text and binary) for check constraints */ text conbin; text consrc; } FormData_pg_constraint; /* ---------------- * Form_pg_constraint corresponds to a pointer to a tuple with * the format of pg_constraint relation. * ---------------- */ typedef FormData_pg_constraint *Form_pg_constraint; /* ---------------- * compiler constants for pg_constraint * ---------------- */ #define Natts_pg_constraint 13 #define Anum_pg_constraint_conrelid 1 #define Anum_pg_constraint_conname 2 #define Anum_pg_constraint_contype 3 #define Anum_pg_constraint_condeferrable 4 #define Anum_pg_constraint_condeferred 5 #define Anum_pg_constraint_confrelid 6 #define Anum_pg_constraint_confupdtype 7 #define Anum_pg_constraint_confdeltype 8 #define Anum_pg_constraint_confmatchtype 9 #define Anum_pg_constraint_conkey 10 #define Anum_pg_constraint_confkey 11 #define Anum_pg_constraint_conbin 12 #define Anum_pg_constraint_consrc 13 #define CONSTRAINT_FKEY_RESTRICT 'r' #define CONSTRAINT_FKEY_CASCADE 'c' #define CONSTRAINT_FKEY_NULL 'n' #define CONSTRAINT_FKEY_DEFAULT 'd' #define CONSTRAINT_FKEY_NOACTION 'a' #define CONSTRAINT_FKEY_PARTIAL 'p' #define CONSTRAINT_FKEY_FULL 'f' #define CONSTRAINT_FKEY_UNSPECIFIED 'u' #define CONSTRAINT_CHECK 'c' #define CONSTRAINT_FOREIGN 'f' #define CONSTRAINT_PRIMARY 'p' #define CONSTRAINT_UNIQUE 'u' /* * prototypes for functions in pg_constraint.c */ extern Oid constraintCreate(Oid relId, const char *constraintName, char constraintType, bool isDeferrable, bool isDeferred, const AttrNumber *constraintKey, int constraintNKeys, Oid foreignRelId, const AttrNumber *foreignKey, int foreignNKeys, char foreignUpdateType, char foreignDeleteType, char foreignMatchType, char *conBin, char *conSrc); extern void DropConstraintById(Oid conId, int behavior); extern char *getConstraintName(Oid relId); #endif /* PG_CONSTRAINT_H */