| 1 | /*------------------------------------------------------------------------- | 
|---|
| 2 | * | 
|---|
| 3 | * pg_dump.h | 
|---|
| 4 | *	  Common header file for the pg_dump utility | 
|---|
| 5 | * | 
|---|
| 6 | * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group | 
|---|
| 7 | * Portions Copyright (c) 1994, Regents of the University of California | 
|---|
| 8 | * | 
|---|
| 9 | * src/bin/pg_dump/pg_dump.h | 
|---|
| 10 | * | 
|---|
| 11 | *------------------------------------------------------------------------- | 
|---|
| 12 | */ | 
|---|
| 13 |  | 
|---|
| 14 | #ifndef PG_DUMP_H | 
|---|
| 15 | #define PG_DUMP_H | 
|---|
| 16 |  | 
|---|
| 17 | #include "pg_backup.h" | 
|---|
| 18 |  | 
|---|
| 19 |  | 
|---|
| 20 | #define oidcmp(x,y) ( ((x) < (y) ? -1 : ((x) > (y)) ?  1 : 0) ) | 
|---|
| 21 | #define oideq(x,y) ( (x) == (y) ) | 
|---|
| 22 | #define oidle(x,y) ( (x) <= (y) ) | 
|---|
| 23 | #define oidge(x,y) ( (x) >= (y) ) | 
|---|
| 24 | #define oidzero(x) ( (x) == 0 ) | 
|---|
| 25 |  | 
|---|
| 26 | /* | 
|---|
| 27 | * The data structures used to store system catalog information.  Every | 
|---|
| 28 | * dumpable object is a subclass of DumpableObject. | 
|---|
| 29 | * | 
|---|
| 30 | * NOTE: the structures described here live for the entire pg_dump run; | 
|---|
| 31 | * and in most cases we make a struct for every object we can find in the | 
|---|
| 32 | * catalogs, not only those we are actually going to dump.  Hence, it's | 
|---|
| 33 | * best to store a minimal amount of per-object info in these structs, | 
|---|
| 34 | * and retrieve additional per-object info when and if we dump a specific | 
|---|
| 35 | * object.  In particular, try to avoid retrieving expensive-to-compute | 
|---|
| 36 | * information until it's known to be needed.  We do, however, have to | 
|---|
| 37 | * store enough info to determine whether an object should be dumped and | 
|---|
| 38 | * what order to dump in. | 
|---|
| 39 | */ | 
|---|
| 40 |  | 
|---|
| 41 | typedef enum | 
|---|
| 42 | { | 
|---|
| 43 | /* When modifying this enum, update priority tables in pg_dump_sort.c! */ | 
|---|
| 44 | DO_NAMESPACE, | 
|---|
| 45 | DO_EXTENSION, | 
|---|
| 46 | DO_TYPE, | 
|---|
| 47 | DO_SHELL_TYPE, | 
|---|
| 48 | DO_FUNC, | 
|---|
| 49 | DO_AGG, | 
|---|
| 50 | DO_OPERATOR, | 
|---|
| 51 | DO_ACCESS_METHOD, | 
|---|
| 52 | DO_OPCLASS, | 
|---|
| 53 | DO_OPFAMILY, | 
|---|
| 54 | DO_COLLATION, | 
|---|
| 55 | DO_CONVERSION, | 
|---|
| 56 | DO_TABLE, | 
|---|
| 57 | DO_ATTRDEF, | 
|---|
| 58 | DO_INDEX, | 
|---|
| 59 | DO_INDEX_ATTACH, | 
|---|
| 60 | DO_STATSEXT, | 
|---|
| 61 | DO_RULE, | 
|---|
| 62 | DO_TRIGGER, | 
|---|
| 63 | DO_CONSTRAINT, | 
|---|
| 64 | DO_FK_CONSTRAINT,			/* see note for ConstraintInfo */ | 
|---|
| 65 | DO_PROCLANG, | 
|---|
| 66 | DO_CAST, | 
|---|
| 67 | DO_TABLE_DATA, | 
|---|
| 68 | DO_SEQUENCE_SET, | 
|---|
| 69 | DO_DUMMY_TYPE, | 
|---|
| 70 | DO_TSPARSER, | 
|---|
| 71 | DO_TSDICT, | 
|---|
| 72 | DO_TSTEMPLATE, | 
|---|
| 73 | DO_TSCONFIG, | 
|---|
| 74 | DO_FDW, | 
|---|
| 75 | DO_FOREIGN_SERVER, | 
|---|
| 76 | DO_DEFAULT_ACL, | 
|---|
| 77 | DO_TRANSFORM, | 
|---|
| 78 | DO_BLOB, | 
|---|
| 79 | DO_BLOB_DATA, | 
|---|
| 80 | DO_PRE_DATA_BOUNDARY, | 
|---|
| 81 | DO_POST_DATA_BOUNDARY, | 
|---|
| 82 | DO_EVENT_TRIGGER, | 
|---|
| 83 | DO_REFRESH_MATVIEW, | 
|---|
| 84 | DO_POLICY, | 
|---|
| 85 | DO_PUBLICATION, | 
|---|
| 86 | DO_PUBLICATION_REL, | 
|---|
| 87 | DO_SUBSCRIPTION | 
|---|
| 88 | } DumpableObjectType; | 
|---|
| 89 |  | 
|---|
| 90 | /* component types of an object which can be selected for dumping */ | 
|---|
| 91 | typedef uint32 DumpComponents;	/* a bitmask of dump object components */ | 
|---|
| 92 | #define DUMP_COMPONENT_NONE			(0) | 
|---|
| 93 | #define DUMP_COMPONENT_DEFINITION	(1 << 0) | 
|---|
| 94 | #define DUMP_COMPONENT_DATA			(1 << 1) | 
|---|
| 95 | #define 		(1 << 2) | 
|---|
| 96 | #define DUMP_COMPONENT_SECLABEL		(1 << 3) | 
|---|
| 97 | #define DUMP_COMPONENT_ACL			(1 << 4) | 
|---|
| 98 | #define DUMP_COMPONENT_POLICY		(1 << 5) | 
|---|
| 99 | #define DUMP_COMPONENT_USERMAP		(1 << 6) | 
|---|
| 100 | #define DUMP_COMPONENT_ALL			(0xFFFF) | 
|---|
| 101 |  | 
|---|
| 102 | /* | 
|---|
| 103 | * component types which require us to obtain a lock on the table | 
|---|
| 104 | * | 
|---|
| 105 | * Note that some components only require looking at the information | 
|---|
| 106 | * in the pg_catalog tables and, for those components, we do not need | 
|---|
| 107 | * to lock the table.  Be careful here though- some components use | 
|---|
| 108 | * server-side functions which pull the latest information from | 
|---|
| 109 | * SysCache and in those cases we *do* need to lock the table. | 
|---|
| 110 | * | 
|---|
| 111 | * We do not need locks for the COMMENT and SECLABEL components as | 
|---|
| 112 | * those simply query their associated tables without using any | 
|---|
| 113 | * server-side functions.  We do not need locks for the ACL component | 
|---|
| 114 | * as we pull that information from pg_class without using any | 
|---|
| 115 | * server-side functions that use SysCache.  The USERMAP component | 
|---|
| 116 | * is only relevant for FOREIGN SERVERs and not tables, so no sense | 
|---|
| 117 | * locking a table for that either (that can happen if we are going | 
|---|
| 118 | * to dump "ALL" components for a table). | 
|---|
| 119 | * | 
|---|
| 120 | * We DO need locks for DEFINITION, due to various server-side | 
|---|
| 121 | * functions that are used and POLICY due to pg_get_expr().  We set | 
|---|
| 122 | * this up to grab the lock except in the cases we know to be safe. | 
|---|
| 123 | */ | 
|---|
| 124 | #define DUMP_COMPONENTS_REQUIRING_LOCK (\ | 
|---|
| 125 | DUMP_COMPONENT_DEFINITION |\ | 
|---|
| 126 | DUMP_COMPONENT_DATA |\ | 
|---|
| 127 | DUMP_COMPONENT_POLICY) | 
|---|
| 128 |  | 
|---|
| 129 | typedef struct _dumpableObject | 
|---|
| 130 | { | 
|---|
| 131 | DumpableObjectType objType; | 
|---|
| 132 | CatalogId	catId;			/* zero if not a cataloged object */ | 
|---|
| 133 | DumpId		dumpId;			/* assigned by AssignDumpId() */ | 
|---|
| 134 | char	   *name;			/* object name (should never be NULL) */ | 
|---|
| 135 | struct _namespaceInfo *namespace;	/* containing namespace, or NULL */ | 
|---|
| 136 | DumpComponents dump;		/* bitmask of components to dump */ | 
|---|
| 137 | DumpComponents dump_contains;	/* as above, but for contained objects */ | 
|---|
| 138 | bool		ext_member;		/* true if object is member of extension */ | 
|---|
| 139 | DumpId	   *dependencies;	/* dumpIds of objects this one depends on */ | 
|---|
| 140 | int			nDeps;			/* number of valid dependencies */ | 
|---|
| 141 | int			allocDeps;		/* allocated size of dependencies[] */ | 
|---|
| 142 | } DumpableObject; | 
|---|
| 143 |  | 
|---|
| 144 | typedef struct _namespaceInfo | 
|---|
| 145 | { | 
|---|
| 146 | DumpableObject dobj; | 
|---|
| 147 | char	   *rolname;		/* name of owner, or empty string */ | 
|---|
| 148 | char	   *nspacl; | 
|---|
| 149 | char	   *rnspacl; | 
|---|
| 150 | char	   *initnspacl; | 
|---|
| 151 | char	   *initrnspacl; | 
|---|
| 152 | } NamespaceInfo; | 
|---|
| 153 |  | 
|---|
| 154 | typedef struct _extensionInfo | 
|---|
| 155 | { | 
|---|
| 156 | DumpableObject dobj; | 
|---|
| 157 | char	   *namespace;		/* schema containing extension's objects */ | 
|---|
| 158 | bool		relocatable; | 
|---|
| 159 | char	   *extversion; | 
|---|
| 160 | char	   *extconfig;		/* info about configuration tables */ | 
|---|
| 161 | char	   *extcondition; | 
|---|
| 162 | } ExtensionInfo; | 
|---|
| 163 |  | 
|---|
| 164 | typedef struct _typeInfo | 
|---|
| 165 | { | 
|---|
| 166 | DumpableObject dobj; | 
|---|
| 167 |  | 
|---|
| 168 | /* | 
|---|
| 169 | * Note: dobj.name is the pg_type.typname entry.  format_type() might | 
|---|
| 170 | * produce something different than typname | 
|---|
| 171 | */ | 
|---|
| 172 | char	   *rolname;		/* name of owner, or empty string */ | 
|---|
| 173 | char	   *typacl; | 
|---|
| 174 | char	   *rtypacl; | 
|---|
| 175 | char	   *inittypacl; | 
|---|
| 176 | char	   *initrtypacl; | 
|---|
| 177 | Oid			typelem; | 
|---|
| 178 | Oid			typrelid; | 
|---|
| 179 | char		typrelkind;		/* 'r', 'v', 'c', etc */ | 
|---|
| 180 | char		typtype;		/* 'b', 'c', etc */ | 
|---|
| 181 | bool		isArray;		/* true if auto-generated array type */ | 
|---|
| 182 | bool		isDefined;		/* true if typisdefined */ | 
|---|
| 183 | /* If needed, we'll create a "shell type" entry for it; link that here: */ | 
|---|
| 184 | struct _shellTypeInfo *shellType;	/* shell-type entry, or NULL */ | 
|---|
| 185 | /* If it's a domain, we store links to its constraints here: */ | 
|---|
| 186 | int			nDomChecks; | 
|---|
| 187 | struct _constraintInfo *domChecks; | 
|---|
| 188 | } TypeInfo; | 
|---|
| 189 |  | 
|---|
| 190 | typedef struct _shellTypeInfo | 
|---|
| 191 | { | 
|---|
| 192 | DumpableObject dobj; | 
|---|
| 193 |  | 
|---|
| 194 | TypeInfo   *baseType;		/* back link to associated base type */ | 
|---|
| 195 | } ShellTypeInfo; | 
|---|
| 196 |  | 
|---|
| 197 | typedef struct _funcInfo | 
|---|
| 198 | { | 
|---|
| 199 | DumpableObject dobj; | 
|---|
| 200 | char	   *rolname;		/* name of owner, or empty string */ | 
|---|
| 201 | Oid			lang; | 
|---|
| 202 | int			nargs; | 
|---|
| 203 | Oid		   *argtypes; | 
|---|
| 204 | Oid			prorettype; | 
|---|
| 205 | char	   *proacl; | 
|---|
| 206 | char	   *rproacl; | 
|---|
| 207 | char	   *initproacl; | 
|---|
| 208 | char	   *initrproacl; | 
|---|
| 209 | } FuncInfo; | 
|---|
| 210 |  | 
|---|
| 211 | /* AggInfo is a superset of FuncInfo */ | 
|---|
| 212 | typedef struct _aggInfo | 
|---|
| 213 | { | 
|---|
| 214 | FuncInfo	aggfn; | 
|---|
| 215 | /* we don't require any other fields at the moment */ | 
|---|
| 216 | } AggInfo; | 
|---|
| 217 |  | 
|---|
| 218 | typedef struct _oprInfo | 
|---|
| 219 | { | 
|---|
| 220 | DumpableObject dobj; | 
|---|
| 221 | char	   *rolname; | 
|---|
| 222 | char		oprkind; | 
|---|
| 223 | Oid			oprcode; | 
|---|
| 224 | } OprInfo; | 
|---|
| 225 |  | 
|---|
| 226 | typedef struct _accessMethodInfo | 
|---|
| 227 | { | 
|---|
| 228 | DumpableObject dobj; | 
|---|
| 229 | char		amtype; | 
|---|
| 230 | char	   *amhandler; | 
|---|
| 231 | } AccessMethodInfo; | 
|---|
| 232 |  | 
|---|
| 233 | typedef struct _opclassInfo | 
|---|
| 234 | { | 
|---|
| 235 | DumpableObject dobj; | 
|---|
| 236 | char	   *rolname; | 
|---|
| 237 | } OpclassInfo; | 
|---|
| 238 |  | 
|---|
| 239 | typedef struct _opfamilyInfo | 
|---|
| 240 | { | 
|---|
| 241 | DumpableObject dobj; | 
|---|
| 242 | char	   *rolname; | 
|---|
| 243 | } OpfamilyInfo; | 
|---|
| 244 |  | 
|---|
| 245 | typedef struct _collInfo | 
|---|
| 246 | { | 
|---|
| 247 | DumpableObject dobj; | 
|---|
| 248 | char	   *rolname; | 
|---|
| 249 | } CollInfo; | 
|---|
| 250 |  | 
|---|
| 251 | typedef struct _convInfo | 
|---|
| 252 | { | 
|---|
| 253 | DumpableObject dobj; | 
|---|
| 254 | char	   *rolname; | 
|---|
| 255 | } ConvInfo; | 
|---|
| 256 |  | 
|---|
| 257 | typedef struct _tableInfo | 
|---|
| 258 | { | 
|---|
| 259 | /* | 
|---|
| 260 | * These fields are collected for every table in the database. | 
|---|
| 261 | */ | 
|---|
| 262 | DumpableObject dobj; | 
|---|
| 263 | char	   *rolname;		/* name of owner, or empty string */ | 
|---|
| 264 | char	   *relacl; | 
|---|
| 265 | char	   *rrelacl; | 
|---|
| 266 | char	   *initrelacl; | 
|---|
| 267 | char	   *initrrelacl; | 
|---|
| 268 | char		relkind; | 
|---|
| 269 | char		relpersistence; /* relation persistence */ | 
|---|
| 270 | bool		relispopulated; /* relation is populated */ | 
|---|
| 271 | char		relreplident;	/* replica identifier */ | 
|---|
| 272 | char	   *reltablespace;	/* relation tablespace */ | 
|---|
| 273 | char	   *reloptions;		/* options specified by WITH (...) */ | 
|---|
| 274 | char	   *checkoption;	/* WITH CHECK OPTION, if any */ | 
|---|
| 275 | char	   *toast_reloptions;	/* WITH options for the TOAST table */ | 
|---|
| 276 | bool		hasindex;		/* does it have any indexes? */ | 
|---|
| 277 | bool		hasrules;		/* does it have any rules? */ | 
|---|
| 278 | bool		hastriggers;	/* does it have any triggers? */ | 
|---|
| 279 | bool		rowsec;			/* is row security enabled? */ | 
|---|
| 280 | bool		forcerowsec;	/* is row security forced? */ | 
|---|
| 281 | bool		hasoids;		/* does it have OIDs? */ | 
|---|
| 282 | uint32		frozenxid;		/* table's relfrozenxid */ | 
|---|
| 283 | uint32		minmxid;		/* table's relminmxid */ | 
|---|
| 284 | Oid			toast_oid;		/* toast table's OID, or 0 if none */ | 
|---|
| 285 | uint32		toast_frozenxid;	/* toast table's relfrozenxid, if any */ | 
|---|
| 286 | uint32		toast_minmxid;	/* toast table's relminmxid */ | 
|---|
| 287 | int			ncheck;			/* # of CHECK expressions */ | 
|---|
| 288 | char	   *reloftype;		/* underlying type for typed table */ | 
|---|
| 289 | /* these two are set only if table is a sequence owned by a column: */ | 
|---|
| 290 | Oid			owning_tab;		/* OID of table owning sequence */ | 
|---|
| 291 | int			owning_col;		/* attr # of column owning sequence */ | 
|---|
| 292 | bool		is_identity_sequence; | 
|---|
| 293 | int			relpages;		/* table's size in pages (from pg_class) */ | 
|---|
| 294 |  | 
|---|
| 295 | bool		interesting;	/* true if need to collect more data */ | 
|---|
| 296 | bool		dummy_view;		/* view's real definition must be postponed */ | 
|---|
| 297 | bool		postponed_def;	/* matview must be postponed into post-data */ | 
|---|
| 298 | bool		ispartition;	/* is table a partition? */ | 
|---|
| 299 |  | 
|---|
| 300 | /* | 
|---|
| 301 | * These fields are computed only if we decide the table is interesting | 
|---|
| 302 | * (it's either a table to dump, or a direct parent of a dumpable table). | 
|---|
| 303 | */ | 
|---|
| 304 | int			numatts;		/* number of attributes */ | 
|---|
| 305 | char	  **attnames;		/* the attribute names */ | 
|---|
| 306 | char	  **atttypnames;	/* attribute type names */ | 
|---|
| 307 | int		   *atttypmod;		/* type-specific type modifiers */ | 
|---|
| 308 | int		   *attstattarget;	/* attribute statistics targets */ | 
|---|
| 309 | char	   *attstorage;		/* attribute storage scheme */ | 
|---|
| 310 | char	   *typstorage;		/* type storage scheme */ | 
|---|
| 311 | bool	   *attisdropped;	/* true if attr is dropped; don't dump it */ | 
|---|
| 312 | char	   *attidentity; | 
|---|
| 313 | char	   *attgenerated; | 
|---|
| 314 | int		   *attlen;			/* attribute length, used by binary_upgrade */ | 
|---|
| 315 | char	   *attalign;		/* attribute align, used by binary_upgrade */ | 
|---|
| 316 | bool	   *attislocal;		/* true if attr has local definition */ | 
|---|
| 317 | char	  **attoptions;		/* per-attribute options */ | 
|---|
| 318 | Oid		   *attcollation;	/* per-attribute collation selection */ | 
|---|
| 319 | char	  **attfdwoptions;	/* per-attribute fdw options */ | 
|---|
| 320 | char	  **attmissingval;	/* per attribute missing value */ | 
|---|
| 321 | bool	   *notnull;		/* NOT NULL constraints on attributes */ | 
|---|
| 322 | bool	   *inhNotNull;		/* true if NOT NULL is inherited */ | 
|---|
| 323 | struct _attrDefInfo **attrdefs; /* DEFAULT expressions */ | 
|---|
| 324 | struct _constraintInfo *checkexprs; /* CHECK constraints */ | 
|---|
| 325 | char	   *partkeydef;		/* partition key definition */ | 
|---|
| 326 | char	   *partbound;		/* partition bound definition */ | 
|---|
| 327 | bool		needs_override; /* has GENERATED ALWAYS AS IDENTITY */ | 
|---|
| 328 | char	   *amname;			/* relation access method */ | 
|---|
| 329 |  | 
|---|
| 330 | /* | 
|---|
| 331 | * Stuff computed only for dumpable tables. | 
|---|
| 332 | */ | 
|---|
| 333 | int			numParents;		/* number of (immediate) parent tables */ | 
|---|
| 334 | struct _tableInfo **parents;	/* TableInfos of immediate parents */ | 
|---|
| 335 | int			numIndexes;		/* number of indexes */ | 
|---|
| 336 | struct _indxInfo *indexes;	/* indexes */ | 
|---|
| 337 | struct _tableDataInfo *dataObj; /* TableDataInfo, if dumping its data */ | 
|---|
| 338 | int			numTriggers;	/* number of triggers for table */ | 
|---|
| 339 | struct _triggerInfo *triggers;	/* array of TriggerInfo structs */ | 
|---|
| 340 | } TableInfo; | 
|---|
| 341 |  | 
|---|
| 342 | typedef struct _attrDefInfo | 
|---|
| 343 | { | 
|---|
| 344 | DumpableObject dobj;		/* note: dobj.name is name of table */ | 
|---|
| 345 | TableInfo  *adtable;		/* link to table of attribute */ | 
|---|
| 346 | int			adnum; | 
|---|
| 347 | char	   *adef_expr;		/* decompiled DEFAULT expression */ | 
|---|
| 348 | bool		separate;		/* true if must dump as separate item */ | 
|---|
| 349 | } AttrDefInfo; | 
|---|
| 350 |  | 
|---|
| 351 | typedef struct _tableDataInfo | 
|---|
| 352 | { | 
|---|
| 353 | DumpableObject dobj; | 
|---|
| 354 | TableInfo  *tdtable;		/* link to table to dump */ | 
|---|
| 355 | char	   *filtercond;		/* WHERE condition to limit rows dumped */ | 
|---|
| 356 | } TableDataInfo; | 
|---|
| 357 |  | 
|---|
| 358 | typedef struct _indxInfo | 
|---|
| 359 | { | 
|---|
| 360 | DumpableObject dobj; | 
|---|
| 361 | TableInfo  *indextable;		/* link to table the index is for */ | 
|---|
| 362 | char	   *indexdef; | 
|---|
| 363 | char	   *tablespace;		/* tablespace in which index is stored */ | 
|---|
| 364 | char	   *indreloptions;	/* options specified by WITH (...) */ | 
|---|
| 365 | char	   *indstatcols;	/* column numbers with statistics */ | 
|---|
| 366 | char	   *indstatvals;	/* statistic values for columns */ | 
|---|
| 367 | int			indnkeyattrs;	/* number of index key attributes */ | 
|---|
| 368 | int			indnattrs;		/* total number of index attributes */ | 
|---|
| 369 | Oid		   *indkeys;		/* In spite of the name 'indkeys' this field | 
|---|
| 370 | * contains both key and nonkey attributes */ | 
|---|
| 371 | bool		indisclustered; | 
|---|
| 372 | bool		indisreplident; | 
|---|
| 373 | Oid			parentidx;		/* if partitioned, parent index OID */ | 
|---|
| 374 | /* if there is an associated constraint object, its dumpId: */ | 
|---|
| 375 | DumpId		indexconstraint; | 
|---|
| 376 | } IndxInfo; | 
|---|
| 377 |  | 
|---|
| 378 | typedef struct _indexAttachInfo | 
|---|
| 379 | { | 
|---|
| 380 | DumpableObject dobj; | 
|---|
| 381 | IndxInfo   *parentIdx;		/* link to index on partitioned table */ | 
|---|
| 382 | IndxInfo   *partitionIdx;	/* link to index on partition */ | 
|---|
| 383 | } IndexAttachInfo; | 
|---|
| 384 |  | 
|---|
| 385 | typedef struct _statsExtInfo | 
|---|
| 386 | { | 
|---|
| 387 | DumpableObject dobj; | 
|---|
| 388 | char	   *rolname;		/* name of owner, or empty string */ | 
|---|
| 389 | } StatsExtInfo; | 
|---|
| 390 |  | 
|---|
| 391 | typedef struct _ruleInfo | 
|---|
| 392 | { | 
|---|
| 393 | DumpableObject dobj; | 
|---|
| 394 | TableInfo  *ruletable;		/* link to table the rule is for */ | 
|---|
| 395 | char		ev_type; | 
|---|
| 396 | bool		is_instead; | 
|---|
| 397 | char		ev_enabled; | 
|---|
| 398 | bool		separate;		/* true if must dump as separate item */ | 
|---|
| 399 | /* separate is always true for non-ON SELECT rules */ | 
|---|
| 400 | } RuleInfo; | 
|---|
| 401 |  | 
|---|
| 402 | typedef struct _triggerInfo | 
|---|
| 403 | { | 
|---|
| 404 | DumpableObject dobj; | 
|---|
| 405 | TableInfo  *tgtable;		/* link to table the trigger is for */ | 
|---|
| 406 | char	   *tgfname; | 
|---|
| 407 | int			tgtype; | 
|---|
| 408 | int			tgnargs; | 
|---|
| 409 | char	   *tgargs; | 
|---|
| 410 | bool		tgisconstraint; | 
|---|
| 411 | char	   *tgconstrname; | 
|---|
| 412 | Oid			tgconstrrelid; | 
|---|
| 413 | char	   *tgconstrrelname; | 
|---|
| 414 | char		tgenabled; | 
|---|
| 415 | bool		tgdeferrable; | 
|---|
| 416 | bool		tginitdeferred; | 
|---|
| 417 | char	   *tgdef; | 
|---|
| 418 | } TriggerInfo; | 
|---|
| 419 |  | 
|---|
| 420 | typedef struct _evttriggerInfo | 
|---|
| 421 | { | 
|---|
| 422 | DumpableObject dobj; | 
|---|
| 423 | char	   *evtname; | 
|---|
| 424 | char	   *evtevent; | 
|---|
| 425 | char	   *evtowner; | 
|---|
| 426 | char	   *evttags; | 
|---|
| 427 | char	   *evtfname; | 
|---|
| 428 | char		evtenabled; | 
|---|
| 429 | } EventTriggerInfo; | 
|---|
| 430 |  | 
|---|
| 431 | /* | 
|---|
| 432 | * struct ConstraintInfo is used for all constraint types.  However we | 
|---|
| 433 | * use a different objType for foreign key constraints, to make it easier | 
|---|
| 434 | * to sort them the way we want. | 
|---|
| 435 | * | 
|---|
| 436 | * Note: condeferrable and condeferred are currently only valid for | 
|---|
| 437 | * unique/primary-key constraints.  Otherwise that info is in condef. | 
|---|
| 438 | */ | 
|---|
| 439 | typedef struct _constraintInfo | 
|---|
| 440 | { | 
|---|
| 441 | DumpableObject dobj; | 
|---|
| 442 | TableInfo  *contable;		/* NULL if domain constraint */ | 
|---|
| 443 | TypeInfo   *condomain;		/* NULL if table constraint */ | 
|---|
| 444 | char		contype; | 
|---|
| 445 | char	   *condef;			/* definition, if CHECK or FOREIGN KEY */ | 
|---|
| 446 | Oid			confrelid;		/* referenced table, if FOREIGN KEY */ | 
|---|
| 447 | DumpId		conindex;		/* identifies associated index if any */ | 
|---|
| 448 | bool		condeferrable;	/* true if constraint is DEFERRABLE */ | 
|---|
| 449 | bool		condeferred;	/* true if constraint is INITIALLY DEFERRED */ | 
|---|
| 450 | bool		conislocal;		/* true if constraint has local definition */ | 
|---|
| 451 | bool		separate;		/* true if must dump as separate item */ | 
|---|
| 452 | } ConstraintInfo; | 
|---|
| 453 |  | 
|---|
| 454 | typedef struct _procLangInfo | 
|---|
| 455 | { | 
|---|
| 456 | DumpableObject dobj; | 
|---|
| 457 | bool		lanpltrusted; | 
|---|
| 458 | Oid			lanplcallfoid; | 
|---|
| 459 | Oid			laninline; | 
|---|
| 460 | Oid			lanvalidator; | 
|---|
| 461 | char	   *lanacl; | 
|---|
| 462 | char	   *rlanacl; | 
|---|
| 463 | char	   *initlanacl; | 
|---|
| 464 | char	   *initrlanacl; | 
|---|
| 465 | char	   *lanowner;		/* name of owner, or empty string */ | 
|---|
| 466 | } ProcLangInfo; | 
|---|
| 467 |  | 
|---|
| 468 | typedef struct _castInfo | 
|---|
| 469 | { | 
|---|
| 470 | DumpableObject dobj; | 
|---|
| 471 | Oid			castsource; | 
|---|
| 472 | Oid			casttarget; | 
|---|
| 473 | Oid			castfunc; | 
|---|
| 474 | char		castcontext; | 
|---|
| 475 | char		castmethod; | 
|---|
| 476 | } CastInfo; | 
|---|
| 477 |  | 
|---|
| 478 | typedef struct _transformInfo | 
|---|
| 479 | { | 
|---|
| 480 | DumpableObject dobj; | 
|---|
| 481 | Oid			trftype; | 
|---|
| 482 | Oid			trflang; | 
|---|
| 483 | Oid			trffromsql; | 
|---|
| 484 | Oid			trftosql; | 
|---|
| 485 | } TransformInfo; | 
|---|
| 486 |  | 
|---|
| 487 | /* InhInfo isn't a DumpableObject, just temporary state */ | 
|---|
| 488 | typedef struct _inhInfo | 
|---|
| 489 | { | 
|---|
| 490 | Oid			inhrelid;		/* OID of a child table */ | 
|---|
| 491 | Oid			inhparent;		/* OID of its parent */ | 
|---|
| 492 | } InhInfo; | 
|---|
| 493 |  | 
|---|
| 494 | typedef struct _prsInfo | 
|---|
| 495 | { | 
|---|
| 496 | DumpableObject dobj; | 
|---|
| 497 | Oid			; | 
|---|
| 498 | Oid			prstoken; | 
|---|
| 499 | Oid			prsend; | 
|---|
| 500 | Oid			prsheadline; | 
|---|
| 501 | Oid			prslextype; | 
|---|
| 502 | } TSParserInfo; | 
|---|
| 503 |  | 
|---|
| 504 | typedef struct _dictInfo | 
|---|
| 505 | { | 
|---|
| 506 | DumpableObject dobj; | 
|---|
| 507 | char	   *rolname; | 
|---|
| 508 | Oid			dicttemplate; | 
|---|
| 509 | char	   *dictinitoption; | 
|---|
| 510 | } TSDictInfo; | 
|---|
| 511 |  | 
|---|
| 512 | typedef struct _tmplInfo | 
|---|
| 513 | { | 
|---|
| 514 | DumpableObject dobj; | 
|---|
| 515 | Oid			tmplinit; | 
|---|
| 516 | Oid			tmpllexize; | 
|---|
| 517 | } TSTemplateInfo; | 
|---|
| 518 |  | 
|---|
| 519 | typedef struct _cfgInfo | 
|---|
| 520 | { | 
|---|
| 521 | DumpableObject dobj; | 
|---|
| 522 | char	   *rolname; | 
|---|
| 523 | Oid			cfgparser; | 
|---|
| 524 | } TSConfigInfo; | 
|---|
| 525 |  | 
|---|
| 526 | typedef struct _fdwInfo | 
|---|
| 527 | { | 
|---|
| 528 | DumpableObject dobj; | 
|---|
| 529 | char	   *rolname; | 
|---|
| 530 | char	   *fdwhandler; | 
|---|
| 531 | char	   *fdwvalidator; | 
|---|
| 532 | char	   *fdwoptions; | 
|---|
| 533 | char	   *fdwacl; | 
|---|
| 534 | char	   *rfdwacl; | 
|---|
| 535 | char	   *initfdwacl; | 
|---|
| 536 | char	   *initrfdwacl; | 
|---|
| 537 | } FdwInfo; | 
|---|
| 538 |  | 
|---|
| 539 | typedef struct _foreignServerInfo | 
|---|
| 540 | { | 
|---|
| 541 | DumpableObject dobj; | 
|---|
| 542 | char	   *rolname; | 
|---|
| 543 | Oid			srvfdw; | 
|---|
| 544 | char	   *srvtype; | 
|---|
| 545 | char	   *srvversion; | 
|---|
| 546 | char	   *srvacl; | 
|---|
| 547 | char	   *rsrvacl; | 
|---|
| 548 | char	   *initsrvacl; | 
|---|
| 549 | char	   *initrsrvacl; | 
|---|
| 550 | char	   *srvoptions; | 
|---|
| 551 | } ForeignServerInfo; | 
|---|
| 552 |  | 
|---|
| 553 | typedef struct _defaultACLInfo | 
|---|
| 554 | { | 
|---|
| 555 | DumpableObject dobj; | 
|---|
| 556 | char	   *defaclrole; | 
|---|
| 557 | char		defaclobjtype; | 
|---|
| 558 | char	   *defaclacl; | 
|---|
| 559 | char	   *rdefaclacl; | 
|---|
| 560 | char	   *initdefaclacl; | 
|---|
| 561 | char	   *initrdefaclacl; | 
|---|
| 562 | } DefaultACLInfo; | 
|---|
| 563 |  | 
|---|
| 564 | typedef struct _blobInfo | 
|---|
| 565 | { | 
|---|
| 566 | DumpableObject dobj; | 
|---|
| 567 | char	   *rolname; | 
|---|
| 568 | char	   *blobacl; | 
|---|
| 569 | char	   *rblobacl; | 
|---|
| 570 | char	   *initblobacl; | 
|---|
| 571 | char	   *initrblobacl; | 
|---|
| 572 | } BlobInfo; | 
|---|
| 573 |  | 
|---|
| 574 | /* | 
|---|
| 575 | * The PolicyInfo struct is used to represent policies on a table and | 
|---|
| 576 | * to indicate if a table has RLS enabled (ENABLE ROW SECURITY).  If | 
|---|
| 577 | * polname is NULL, then the record indicates ENABLE ROW SECURITY, while if | 
|---|
| 578 | * it's non-NULL then this is a regular policy definition. | 
|---|
| 579 | */ | 
|---|
| 580 | typedef struct _policyInfo | 
|---|
| 581 | { | 
|---|
| 582 | DumpableObject dobj; | 
|---|
| 583 | TableInfo  *poltable; | 
|---|
| 584 | char	   *polname;		/* null indicates RLS is enabled on rel */ | 
|---|
| 585 | char		polcmd; | 
|---|
| 586 | bool		polpermissive; | 
|---|
| 587 | char	   *polroles; | 
|---|
| 588 | char	   *polqual; | 
|---|
| 589 | char	   *polwithcheck; | 
|---|
| 590 | } PolicyInfo; | 
|---|
| 591 |  | 
|---|
| 592 | /* | 
|---|
| 593 | * The PublicationInfo struct is used to represent publications. | 
|---|
| 594 | */ | 
|---|
| 595 | typedef struct _PublicationInfo | 
|---|
| 596 | { | 
|---|
| 597 | DumpableObject dobj; | 
|---|
| 598 | char	   *rolname; | 
|---|
| 599 | bool		puballtables; | 
|---|
| 600 | bool		pubinsert; | 
|---|
| 601 | bool		pubupdate; | 
|---|
| 602 | bool		pubdelete; | 
|---|
| 603 | bool		pubtruncate; | 
|---|
| 604 | } PublicationInfo; | 
|---|
| 605 |  | 
|---|
| 606 | /* | 
|---|
| 607 | * The PublicationRelInfo struct is used to represent publication table | 
|---|
| 608 | * mapping. | 
|---|
| 609 | */ | 
|---|
| 610 | typedef struct _PublicationRelInfo | 
|---|
| 611 | { | 
|---|
| 612 | DumpableObject dobj; | 
|---|
| 613 | TableInfo  *pubtable; | 
|---|
| 614 | char	   *pubname; | 
|---|
| 615 | } PublicationRelInfo; | 
|---|
| 616 |  | 
|---|
| 617 | /* | 
|---|
| 618 | * The SubscriptionInfo struct is used to represent subscription. | 
|---|
| 619 | */ | 
|---|
| 620 | typedef struct _SubscriptionInfo | 
|---|
| 621 | { | 
|---|
| 622 | DumpableObject dobj; | 
|---|
| 623 | char	   *rolname; | 
|---|
| 624 | char	   *subconninfo; | 
|---|
| 625 | char	   *subslotname; | 
|---|
| 626 | char	   *subsynccommit; | 
|---|
| 627 | char	   *subpublications; | 
|---|
| 628 | } SubscriptionInfo; | 
|---|
| 629 |  | 
|---|
| 630 | /* | 
|---|
| 631 | * We build an array of these with an entry for each object that is an | 
|---|
| 632 | * extension member according to pg_depend. | 
|---|
| 633 | */ | 
|---|
| 634 | typedef struct _extensionMemberId | 
|---|
| 635 | { | 
|---|
| 636 | CatalogId	catId;			/* tableoid+oid of some member object */ | 
|---|
| 637 | ExtensionInfo *ext;			/* owning extension */ | 
|---|
| 638 | } ExtensionMemberId; | 
|---|
| 639 |  | 
|---|
| 640 | /* global decls */ | 
|---|
| 641 | extern bool force_quotes;		/* double-quotes for identifiers flag */ | 
|---|
| 642 |  | 
|---|
| 643 | /* placeholders for comment starting and ending delimiters */ | 
|---|
| 644 | extern char [10]; | 
|---|
| 645 | extern char [10]; | 
|---|
| 646 |  | 
|---|
| 647 | extern char g_opaque_type[10];	/* name for the opaque type */ | 
|---|
| 648 |  | 
|---|
| 649 | /* | 
|---|
| 650 | *	common utility functions | 
|---|
| 651 | */ | 
|---|
| 652 |  | 
|---|
| 653 | extern TableInfo *getSchemaData(Archive *fout, int *numTablesPtr); | 
|---|
| 654 |  | 
|---|
| 655 | extern void AssignDumpId(DumpableObject *dobj); | 
|---|
| 656 | extern DumpId createDumpId(void); | 
|---|
| 657 | extern DumpId getMaxDumpId(void); | 
|---|
| 658 | extern DumpableObject *findObjectByDumpId(DumpId dumpId); | 
|---|
| 659 | extern DumpableObject *findObjectByCatalogId(CatalogId catalogId); | 
|---|
| 660 | extern void getDumpableObjects(DumpableObject ***objs, int *numObjs); | 
|---|
| 661 |  | 
|---|
| 662 | extern void addObjectDependency(DumpableObject *dobj, DumpId refId); | 
|---|
| 663 | extern void removeObjectDependency(DumpableObject *dobj, DumpId refId); | 
|---|
| 664 |  | 
|---|
| 665 | extern TableInfo *findTableByOid(Oid oid); | 
|---|
| 666 | extern TypeInfo *findTypeByOid(Oid oid); | 
|---|
| 667 | extern FuncInfo *findFuncByOid(Oid oid); | 
|---|
| 668 | extern OprInfo *findOprByOid(Oid oid); | 
|---|
| 669 | extern CollInfo *findCollationByOid(Oid oid); | 
|---|
| 670 | extern NamespaceInfo *findNamespaceByOid(Oid oid); | 
|---|
| 671 | extern ExtensionInfo *findExtensionByOid(Oid oid); | 
|---|
| 672 |  | 
|---|
| 673 | extern void setExtensionMembership(ExtensionMemberId *extmems, int nextmems); | 
|---|
| 674 | extern ExtensionInfo *findOwningExtension(CatalogId catalogId); | 
|---|
| 675 |  | 
|---|
| 676 | extern void parseOidArray(const char *str, Oid *array, int arraysize); | 
|---|
| 677 |  | 
|---|
| 678 | extern void sortDumpableObjects(DumpableObject **objs, int numObjs, | 
|---|
| 679 | DumpId preBoundaryId, DumpId postBoundaryId); | 
|---|
| 680 | extern void sortDumpableObjectsByTypeName(DumpableObject **objs, int numObjs); | 
|---|
| 681 |  | 
|---|
| 682 | /* | 
|---|
| 683 | * version specific routines | 
|---|
| 684 | */ | 
|---|
| 685 | extern NamespaceInfo *getNamespaces(Archive *fout, int *numNamespaces); | 
|---|
| 686 | extern ExtensionInfo *getExtensions(Archive *fout, int *numExtensions); | 
|---|
| 687 | extern TypeInfo *getTypes(Archive *fout, int *numTypes); | 
|---|
| 688 | extern FuncInfo *getFuncs(Archive *fout, int *numFuncs); | 
|---|
| 689 | extern AggInfo *getAggregates(Archive *fout, int *numAggregates); | 
|---|
| 690 | extern OprInfo *getOperators(Archive *fout, int *numOperators); | 
|---|
| 691 | extern AccessMethodInfo *getAccessMethods(Archive *fout, int *numAccessMethods); | 
|---|
| 692 | extern OpclassInfo *getOpclasses(Archive *fout, int *numOpclasses); | 
|---|
| 693 | extern OpfamilyInfo *getOpfamilies(Archive *fout, int *numOpfamilies); | 
|---|
| 694 | extern CollInfo *getCollations(Archive *fout, int *numCollations); | 
|---|
| 695 | extern ConvInfo *getConversions(Archive *fout, int *numConversions); | 
|---|
| 696 | extern TableInfo *getTables(Archive *fout, int *numTables); | 
|---|
| 697 | extern void getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables); | 
|---|
| 698 | extern InhInfo *getInherits(Archive *fout, int *numInherits); | 
|---|
| 699 | extern void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables); | 
|---|
| 700 | extern void getExtendedStatistics(Archive *fout); | 
|---|
| 701 | extern void getConstraints(Archive *fout, TableInfo tblinfo[], int numTables); | 
|---|
| 702 | extern RuleInfo *getRules(Archive *fout, int *numRules); | 
|---|
| 703 | extern void getTriggers(Archive *fout, TableInfo tblinfo[], int numTables); | 
|---|
| 704 | extern ProcLangInfo *getProcLangs(Archive *fout, int *numProcLangs); | 
|---|
| 705 | extern CastInfo *getCasts(Archive *fout, int *numCasts); | 
|---|
| 706 | extern TransformInfo *getTransforms(Archive *fout, int *numTransforms); | 
|---|
| 707 | extern void getTableAttrs(Archive *fout, TableInfo *tbinfo, int numTables); | 
|---|
| 708 | extern bool shouldPrintColumn(DumpOptions *dopt, TableInfo *tbinfo, int colno); | 
|---|
| 709 | extern TSParserInfo *getTSParsers(Archive *fout, int *numTSParsers); | 
|---|
| 710 | extern TSDictInfo *getTSDictionaries(Archive *fout, int *numTSDicts); | 
|---|
| 711 | extern TSTemplateInfo *getTSTemplates(Archive *fout, int *numTSTemplates); | 
|---|
| 712 | extern TSConfigInfo *getTSConfigurations(Archive *fout, int *numTSConfigs); | 
|---|
| 713 | extern FdwInfo *getForeignDataWrappers(Archive *fout, | 
|---|
| 714 | int *numForeignDataWrappers); | 
|---|
| 715 | extern ForeignServerInfo *getForeignServers(Archive *fout, | 
|---|
| 716 | int *numForeignServers); | 
|---|
| 717 | extern DefaultACLInfo *getDefaultACLs(Archive *fout, int *numDefaultACLs); | 
|---|
| 718 | extern void getExtensionMembership(Archive *fout, ExtensionInfo extinfo[], | 
|---|
| 719 | int numExtensions); | 
|---|
| 720 | extern void processExtensionTables(Archive *fout, ExtensionInfo extinfo[], | 
|---|
| 721 | int numExtensions); | 
|---|
| 722 | extern EventTriggerInfo *getEventTriggers(Archive *fout, int *numEventTriggers); | 
|---|
| 723 | extern void getPolicies(Archive *fout, TableInfo tblinfo[], int numTables); | 
|---|
| 724 | extern void getPublications(Archive *fout); | 
|---|
| 725 | extern void getPublicationTables(Archive *fout, TableInfo tblinfo[], | 
|---|
| 726 | int numTables); | 
|---|
| 727 | extern void getSubscriptions(Archive *fout); | 
|---|
| 728 |  | 
|---|
| 729 | #endif							/* PG_DUMP_H */ | 
|---|
| 730 |  | 
|---|