00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef PG_CONSTRAINT_H
00020 #define PG_CONSTRAINT_H
00021
00022 #include "catalog/genbki.h"
00023 #include "catalog/dependency.h"
00024 #include "nodes/pg_list.h"
00025
00026
00027
00028
00029
00030
00031 #define ConstraintRelationId 2606
00032
00033 CATALOG(pg_constraint,2606)
00034 {
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 NameData conname;
00045 Oid connamespace;
00046 char contype;
00047 bool condeferrable;
00048 bool condeferred;
00049 bool convalidated;
00050
00051
00052
00053
00054
00055
00056 Oid conrelid;
00057
00058
00059
00060
00061
00062
00063
00064
00065 Oid contypid;
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 Oid conindid;
00076
00077
00078
00079
00080
00081 Oid confrelid;
00082 char confupdtype;
00083 char confdeltype;
00084 char confmatchtype;
00085
00086
00087 bool conislocal;
00088
00089
00090 int32 coninhcount;
00091
00092
00093 bool connoinherit;
00094
00095 #ifdef CATALOG_VARLEN
00096
00097
00098
00099
00100
00101 int16 conkey[1];
00102
00103
00104
00105
00106 int16 confkey[1];
00107
00108
00109
00110
00111
00112 Oid conpfeqop[1];
00113
00114
00115
00116
00117
00118 Oid conppeqop[1];
00119
00120
00121
00122
00123
00124 Oid conffeqop[1];
00125
00126
00127
00128
00129
00130 Oid conexclop[1];
00131
00132
00133
00134
00135 pg_node_tree conbin;
00136
00137
00138
00139
00140 text consrc;
00141 #endif
00142 } FormData_pg_constraint;
00143
00144
00145
00146
00147
00148
00149 typedef FormData_pg_constraint *Form_pg_constraint;
00150
00151
00152
00153
00154
00155 #define Natts_pg_constraint 24
00156 #define Anum_pg_constraint_conname 1
00157 #define Anum_pg_constraint_connamespace 2
00158 #define Anum_pg_constraint_contype 3
00159 #define Anum_pg_constraint_condeferrable 4
00160 #define Anum_pg_constraint_condeferred 5
00161 #define Anum_pg_constraint_convalidated 6
00162 #define Anum_pg_constraint_conrelid 7
00163 #define Anum_pg_constraint_contypid 8
00164 #define Anum_pg_constraint_conindid 9
00165 #define Anum_pg_constraint_confrelid 10
00166 #define Anum_pg_constraint_confupdtype 11
00167 #define Anum_pg_constraint_confdeltype 12
00168 #define Anum_pg_constraint_confmatchtype 13
00169 #define Anum_pg_constraint_conislocal 14
00170 #define Anum_pg_constraint_coninhcount 15
00171 #define Anum_pg_constraint_connoinherit 16
00172 #define Anum_pg_constraint_conkey 17
00173 #define Anum_pg_constraint_confkey 18
00174 #define Anum_pg_constraint_conpfeqop 19
00175 #define Anum_pg_constraint_conppeqop 20
00176 #define Anum_pg_constraint_conffeqop 21
00177 #define Anum_pg_constraint_conexclop 22
00178 #define Anum_pg_constraint_conbin 23
00179 #define Anum_pg_constraint_consrc 24
00180
00181
00182
00183 #define CONSTRAINT_CHECK 'c'
00184 #define CONSTRAINT_FOREIGN 'f'
00185 #define CONSTRAINT_PRIMARY 'p'
00186 #define CONSTRAINT_UNIQUE 'u'
00187 #define CONSTRAINT_TRIGGER 't'
00188 #define CONSTRAINT_EXCLUSION 'x'
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199 typedef enum ConstraintCategory
00200 {
00201 CONSTRAINT_RELATION,
00202 CONSTRAINT_DOMAIN,
00203 CONSTRAINT_ASSERTION
00204 } ConstraintCategory;
00205
00206
00207
00208
00209 extern Oid CreateConstraintEntry(const char *constraintName,
00210 Oid constraintNamespace,
00211 char constraintType,
00212 bool isDeferrable,
00213 bool isDeferred,
00214 bool isValidated,
00215 Oid relId,
00216 const int16 *constraintKey,
00217 int constraintNKeys,
00218 Oid domainId,
00219 Oid indexRelId,
00220 Oid foreignRelId,
00221 const int16 *foreignKey,
00222 const Oid *pfEqOp,
00223 const Oid *ppEqOp,
00224 const Oid *ffEqOp,
00225 int foreignNKeys,
00226 char foreignUpdateType,
00227 char foreignDeleteType,
00228 char foreignMatchType,
00229 const Oid *exclOp,
00230 Node *conExpr,
00231 const char *conBin,
00232 const char *conSrc,
00233 bool conIsLocal,
00234 int conInhCount,
00235 bool conNoInherit,
00236 bool is_internal);
00237
00238 extern void RemoveConstraintById(Oid conId);
00239 extern void RenameConstraintById(Oid conId, const char *newname);
00240 extern void SetValidatedConstraintById(Oid conId);
00241
00242 extern bool ConstraintNameIsUsed(ConstraintCategory conCat, Oid objId,
00243 Oid objNamespace, const char *conname);
00244 extern char *ChooseConstraintName(const char *name1, const char *name2,
00245 const char *label, Oid namespaceid,
00246 List *others);
00247
00248 extern void AlterConstraintNamespaces(Oid ownerId, Oid oldNspId,
00249 Oid newNspId, bool isType, ObjectAddresses *objsMoved);
00250 extern Oid get_relation_constraint_oid(Oid relid, const char *conname, bool missing_ok);
00251 extern Oid get_domain_constraint_oid(Oid typid, const char *conname, bool missing_ok);
00252
00253 extern bool check_functional_grouping(Oid relid,
00254 Index varno, Index varlevelsup,
00255 List *grouping_columns,
00256 List **constraintDeps);
00257
00258 #endif