| 1 |
/*------------------------------------------------------------------------- |
| 2 |
* |
| 3 |
* pg_dump.h |
| 4 |
* Common header file for the pg_dump utility |
| 5 |
* |
| 6 |
* Portions Copyright (c) 1996-2025, 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 |
#include "catalog/pg_publication_d.h" |
| 19 |
|
| 20 |
|
| 21 |
#define oidcmp(x,y) ( ((x) < (y) ? -1 : ((x) > (y)) ? 1 : 0) ) |
| 22 |
|
| 23 |
/* |
| 24 |
* The data structures used to store system catalog information. Every |
| 25 |
* dumpable object is a subclass of DumpableObject. |
| 26 |
* |
| 27 |
* NOTE: the structures described here live for the entire pg_dump run; |
| 28 |
* and in most cases we make a struct for every object we can find in the |
| 29 |
* catalogs, not only those we are actually going to dump. Hence, it's |
| 30 |
* best to store a minimal amount of per-object info in these structs, |
| 31 |
* and retrieve additional per-object info when and if we dump a specific |
| 32 |
* object. In particular, try to avoid retrieving expensive-to-compute |
| 33 |
* information until it's known to be needed. We do, however, have to |
| 34 |
* store enough info to determine whether an object should be dumped and |
| 35 |
* what order to dump in. |
| 36 |
*/ |
| 37 |
|
| 38 |
typedef enum |
| 39 |
{ |
| 40 |
/* When modifying this enum, update priority tables in pg_dump_sort.c! */ |
| 41 |
DO_NAMESPACE, |
| 42 |
DO_EXTENSION, |
| 43 |
DO_TYPE, |
| 44 |
DO_SHELL_TYPE, |
| 45 |
DO_FUNC, |
| 46 |
DO_AGG, |
| 47 |
DO_OPERATOR, |
| 48 |
DO_ACCESS_METHOD, |
| 49 |
DO_OPCLASS, |
| 50 |
DO_OPFAMILY, |
| 51 |
DO_COLLATION, |
| 52 |
DO_CONVERSION, |
| 53 |
DO_TABLE, |
| 54 |
DO_TABLE_ATTACH, |
| 55 |
DO_ATTRDEF, |
| 56 |
DO_INDEX, |
| 57 |
DO_INDEX_ATTACH, |
| 58 |
DO_STATSEXT, |
| 59 |
DO_RULE, |
| 60 |
DO_TRIGGER, |
| 61 |
DO_CONSTRAINT, |
| 62 |
DO_FK_CONSTRAINT, /* see note for ConstraintInfo */ |
| 63 |
DO_PROCLANG, |
| 64 |
DO_CAST, |
| 65 |
DO_TABLE_DATA, |
| 66 |
DO_SEQUENCE_SET, |
| 67 |
DO_DUMMY_TYPE, |
| 68 |
DO_TSPARSER, |
| 69 |
DO_TSDICT, |
| 70 |
DO_TSTEMPLATE, |
| 71 |
DO_TSCONFIG, |
| 72 |
DO_FDW, |
| 73 |
DO_FOREIGN_SERVER, |
| 74 |
DO_DEFAULT_ACL, |
| 75 |
DO_TRANSFORM, |
| 76 |
DO_LARGE_OBJECT, |
| 77 |
DO_LARGE_OBJECT_DATA, |
| 78 |
DO_PRE_DATA_BOUNDARY, |
| 79 |
DO_POST_DATA_BOUNDARY, |
| 80 |
DO_EVENT_TRIGGER, |
| 81 |
DO_REFRESH_MATVIEW, |
| 82 |
DO_POLICY, |
| 83 |
DO_PUBLICATION, |
| 84 |
DO_PUBLICATION_REL, |
| 85 |
DO_PUBLICATION_TABLE_IN_SCHEMA, |
| 86 |
DO_REL_STATS, |
| 87 |
DO_SUBSCRIPTION, |
| 88 |
DO_SUBSCRIPTION_REL, /* see note for SubRelInfo */ |
| 89 |
} DumpableObjectType; |
| 90 |
|
| 91 |
#define NUM_DUMPABLE_OBJECT_TYPES (DO_SUBSCRIPTION_REL + 1) |
| 92 |
|
| 93 |
/* |
| 94 |
* DumpComponents is a bitmask of the potentially dumpable components of |
| 95 |
* a database object: its core definition, plus optional attributes such |
| 96 |
* as ACL, comments, etc. |
| 97 |
* |
| 98 |
* The NONE and ALL symbols are convenient shorthands for assigning values, |
| 99 |
* but be careful about using them in tests. For example, a test like |
| 100 |
* "if (dobj->dump == DUMP_COMPONENT_NONE)" is probably wrong; you likely want |
| 101 |
* "if (!(dobj->dump & DUMP_COMPONENT_DEFINITION))" instead. This is because |
| 102 |
* we aren't too careful about the values of irrelevant bits, as indeed can be |
| 103 |
* seen in the definition of DUMP_COMPONENT_ALL. It's also possible that an |
| 104 |
* object has only subsidiary bits such as DUMP_COMPONENT_ACL set, leading to |
| 105 |
* unexpected behavior of a test against NONE. |
| 106 |
*/ |
| 107 |
typedef uint32 DumpComponents; |
| 108 |
#define DUMP_COMPONENT_NONE (0) |
| 109 |
#define DUMP_COMPONENT_DEFINITION (1 << 0) |
| 110 |
#define DUMP_COMPONENT_DATA (1 << 1) |
| 111 |
#define DUMP_COMPONENT_COMMENT (1 << 2) |
| 112 |
#define DUMP_COMPONENT_SECLABEL (1 << 3) |
| 113 |
#define DUMP_COMPONENT_ACL (1 << 4) |
| 114 |
#define DUMP_COMPONENT_POLICY (1 << 5) |
| 115 |
#define DUMP_COMPONENT_USERMAP (1 << 6) |
| 116 |
#define DUMP_COMPONENT_STATISTICS (1 << 7) |
| 117 |
#define DUMP_COMPONENT_ALL (0xFFFF) |
| 118 |
|
| 119 |
/* |
| 120 |
* component types which require us to obtain a lock on the table |
| 121 |
* |
| 122 |
* Note that some components only require looking at the information |
| 123 |
* in the pg_catalog tables and, for those components, we do not need |
| 124 |
* to lock the table. Be careful here though- some components use |
| 125 |
* server-side functions which pull the latest information from |
| 126 |
* SysCache and in those cases we *do* need to lock the table. |
| 127 |
* |
| 128 |
* We do not need locks for the COMMENT and SECLABEL components as |
| 129 |
* those simply query their associated tables without using any |
| 130 |
* server-side functions. We do not need locks for the ACL component |
| 131 |
* as we pull that information from pg_class without using any |
| 132 |
* server-side functions that use SysCache. The USERMAP component |
| 133 |
* is only relevant for FOREIGN SERVERs and not tables, so no sense |
| 134 |
* locking a table for that either (that can happen if we are going |
| 135 |
* to dump "ALL" components for a table). |
| 136 |
* |
| 137 |
* We DO need locks for DEFINITION, due to various server-side |
| 138 |
* functions that are used and POLICY due to pg_get_expr(). We set |
| 139 |
* this up to grab the lock except in the cases we know to be safe. |
| 140 |
*/ |
| 141 |
#define DUMP_COMPONENTS_REQUIRING_LOCK (\ |
| 142 |
DUMP_COMPONENT_DEFINITION |\ |
| 143 |
DUMP_COMPONENT_DATA |\ |
| 144 |
DUMP_COMPONENT_STATISTICS |\ |
| 145 |
DUMP_COMPONENT_POLICY) |
| 146 |
|
| 147 |
typedef struct _dumpableObject |
| 148 |
{ |
| 149 |
DumpableObjectType objType; |
| 150 |
CatalogId catId; /* zero if not a cataloged object */ |
| 151 |
DumpId dumpId; /* assigned by AssignDumpId() */ |
| 152 |
char *name; /* object name (should never be NULL) */ |
| 153 |
struct _namespaceInfo *namespace; /* containing namespace, or NULL */ |
| 154 |
DumpComponents dump; /* bitmask of components requested to dump */ |
| 155 |
DumpComponents dump_contains; /* as above, but for contained objects */ |
| 156 |
DumpComponents components; /* bitmask of components available to dump */ |
| 157 |
bool ext_member; /* true if object is member of extension */ |
| 158 |
bool depends_on_ext; /* true if object depends on an extension */ |
| 159 |
DumpId *dependencies; /* dumpIds of objects this one depends on */ |
| 160 |
int nDeps; /* number of valid dependencies */ |
| 161 |
int allocDeps; /* allocated size of dependencies[] */ |
| 162 |
} DumpableObject; |
| 163 |
|
| 164 |
/* |
| 165 |
* Object types that have ACLs must store them in a DumpableAcl sub-struct, |
| 166 |
* which must immediately follow the DumpableObject base struct. |
| 167 |
*/ |
| 168 |
typedef struct _dumpableAcl |
| 169 |
{ |
| 170 |
char *acl; /* the object's actual ACL string */ |
| 171 |
char *acldefault; /* default ACL for the object's type & owner */ |
| 172 |
/* these fields come from the object's pg_init_privs entry, if any: */ |
| 173 |
char privtype; /* entry type, 'i' or 'e'; 0 if no entry */ |
| 174 |
char *initprivs; /* the object's initial ACL string, or NULL */ |
| 175 |
} DumpableAcl; |
| 176 |
|
| 177 |
/* Generic struct that can be used to access any object type having an ACL */ |
| 178 |
typedef struct _dumpableObjectWithAcl |
| 179 |
{ |
| 180 |
DumpableObject dobj; |
| 181 |
DumpableAcl dacl; |
| 182 |
} DumpableObjectWithAcl; |
| 183 |
|
| 184 |
typedef struct _namespaceInfo |
| 185 |
{ |
| 186 |
DumpableObject dobj; |
| 187 |
DumpableAcl dacl; |
| 188 |
bool create; /* CREATE SCHEMA, or just set owner? */ |
| 189 |
Oid nspowner; /* OID of owner */ |
| 190 |
const char *rolname; /* name of owner */ |
| 191 |
} NamespaceInfo; |
| 192 |
|
| 193 |
typedef struct _extensionInfo |
| 194 |
{ |
| 195 |
DumpableObject dobj; |
| 196 |
char *namespace; /* schema containing extension's objects */ |
| 197 |
bool relocatable; |
| 198 |
char *extversion; |
| 199 |
char *extconfig; /* info about configuration tables */ |
| 200 |
char *extcondition; |
| 201 |
} ExtensionInfo; |
| 202 |
|
| 203 |
typedef struct _typeInfo |
| 204 |
{ |
| 205 |
DumpableObject dobj; |
| 206 |
DumpableAcl dacl; |
| 207 |
|
| 208 |
/* |
| 209 |
* Note: dobj.name is the raw pg_type.typname entry. ftypname is the |
| 210 |
* result of format_type(), which will be quoted if needed, and might be |
| 211 |
* schema-qualified too. |
| 212 |
*/ |
| 213 |
char *ftypname; |
| 214 |
const char *rolname; |
| 215 |
Oid typelem; |
| 216 |
Oid typrelid; |
| 217 |
Oid typarray; |
| 218 |
char typrelkind; /* 'r', 'v', 'c', etc */ |
| 219 |
char typtype; /* 'b', 'c', etc */ |
| 220 |
bool isArray; /* true if auto-generated array type */ |
| 221 |
bool isMultirange; /* true if auto-generated multirange type */ |
| 222 |
bool isDefined; /* true if typisdefined */ |
| 223 |
/* If needed, we'll create a "shell type" entry for it; link that here: */ |
| 224 |
struct _shellTypeInfo *shellType; /* shell-type entry, or NULL */ |
| 225 |
/* If it's a domain, its not-null constraint is here: */ |
| 226 |
struct _constraintInfo *notnull; |
| 227 |
/* If it's a domain, we store links to its CHECK constraints here: */ |
| 228 |
int nDomChecks; |
| 229 |
struct _constraintInfo *domChecks; |
| 230 |
} TypeInfo; |
| 231 |
|
| 232 |
typedef struct _shellTypeInfo |
| 233 |
{ |
| 234 |
DumpableObject dobj; |
| 235 |
|
| 236 |
TypeInfo *baseType; /* back link to associated base type */ |
| 237 |
} ShellTypeInfo; |
| 238 |
|
| 239 |
typedef struct _funcInfo |
| 240 |
{ |
| 241 |
DumpableObject dobj; |
| 242 |
DumpableAcl dacl; |
| 243 |
const char *rolname; |
| 244 |
Oid lang; |
| 245 |
int nargs; |
| 246 |
Oid *argtypes; |
| 247 |
Oid prorettype; |
| 248 |
bool postponed_def; /* function must be postponed into post-data */ |
| 249 |
} FuncInfo; |
| 250 |
|
| 251 |
/* AggInfo is a superset of FuncInfo */ |
| 252 |
typedef struct _aggInfo |
| 253 |
{ |
| 254 |
FuncInfo aggfn; |
| 255 |
/* we don't require any other fields at the moment */ |
| 256 |
} AggInfo; |
| 257 |
|
| 258 |
typedef struct _oprInfo |
| 259 |
{ |
| 260 |
DumpableObject dobj; |
| 261 |
const char *rolname; |
| 262 |
char oprkind; |
| 263 |
Oid oprleft; |
| 264 |
Oid oprright; |
| 265 |
Oid oprcode; |
| 266 |
} OprInfo; |
| 267 |
|
| 268 |
typedef struct _accessMethodInfo |
| 269 |
{ |
| 270 |
DumpableObject dobj; |
| 271 |
char amtype; |
| 272 |
char *amhandler; |
| 273 |
} AccessMethodInfo; |
| 274 |
|
| 275 |
typedef struct _opclassInfo |
| 276 |
{ |
| 277 |
DumpableObject dobj; |
| 278 |
Oid opcmethod; |
| 279 |
const char *rolname; |
| 280 |
} OpclassInfo; |
| 281 |
|
| 282 |
typedef struct _opfamilyInfo |
| 283 |
{ |
| 284 |
DumpableObject dobj; |
| 285 |
Oid opfmethod; |
| 286 |
const char *rolname; |
| 287 |
} OpfamilyInfo; |
| 288 |
|
| 289 |
typedef struct _collInfo |
| 290 |
{ |
| 291 |
DumpableObject dobj; |
| 292 |
const char *rolname; |
| 293 |
int collencoding; |
| 294 |
} CollInfo; |
| 295 |
|
| 296 |
typedef struct _convInfo |
| 297 |
{ |
| 298 |
DumpableObject dobj; |
| 299 |
const char *rolname; |
| 300 |
} ConvInfo; |
| 301 |
|
| 302 |
typedef struct _tableInfo |
| 303 |
{ |
| 304 |
/* |
| 305 |
* These fields are collected for every table in the database. |
| 306 |
*/ |
| 307 |
DumpableObject dobj; |
| 308 |
DumpableAcl dacl; |
| 309 |
const char *rolname; |
| 310 |
char relkind; |
| 311 |
char relpersistence; /* relation persistence */ |
| 312 |
bool relispopulated; /* relation is populated */ |
| 313 |
char relreplident; /* replica identifier */ |
| 314 |
char *reltablespace; /* relation tablespace */ |
| 315 |
char *reloptions; /* options specified by WITH (...) */ |
| 316 |
char *checkoption; /* WITH CHECK OPTION, if any */ |
| 317 |
char *toast_reloptions; /* WITH options for the TOAST table */ |
| 318 |
bool hasindex; /* does it have any indexes? */ |
| 319 |
bool hasrules; /* does it have any rules? */ |
| 320 |
bool hastriggers; /* does it have any triggers? */ |
| 321 |
bool hascolumnACLs; /* do any columns have non-default ACLs? */ |
| 322 |
bool rowsec; /* is row security enabled? */ |
| 323 |
bool forcerowsec; /* is row security forced? */ |
| 324 |
bool hasoids; /* does it have OIDs? */ |
| 325 |
uint32 frozenxid; /* table's relfrozenxid */ |
| 326 |
uint32 minmxid; /* table's relminmxid */ |
| 327 |
Oid toast_oid; /* toast table's OID, or 0 if none */ |
| 328 |
uint32 toast_frozenxid; /* toast table's relfrozenxid, if any */ |
| 329 |
uint32 toast_minmxid; /* toast table's relminmxid */ |
| 330 |
int ncheck; /* # of CHECK expressions */ |
| 331 |
Oid reltype; /* OID of table's composite type, if any */ |
| 332 |
Oid reloftype; /* underlying type for typed table */ |
| 333 |
Oid foreign_server; /* foreign server oid, if applicable */ |
| 334 |
/* these two are set only if table is a sequence owned by a column: */ |
| 335 |
Oid owning_tab; /* OID of table owning sequence */ |
| 336 |
int owning_col; /* attr # of column owning sequence */ |
| 337 |
bool is_identity_sequence; |
| 338 |
int32 relpages; /* table's size in pages (from pg_class) */ |
| 339 |
int toastpages; /* toast table's size in pages, if any */ |
| 340 |
|
| 341 |
bool interesting; /* true if need to collect more data */ |
| 342 |
bool dummy_view; /* view's real definition must be postponed */ |
| 343 |
bool postponed_def; /* matview must be postponed into post-data */ |
| 344 |
bool ispartition; /* is table a partition? */ |
| 345 |
bool unsafe_partitions; /* is it an unsafe partitioned table? */ |
| 346 |
|
| 347 |
int numParents; /* number of (immediate) parent tables */ |
| 348 |
struct _tableInfo **parents; /* TableInfos of immediate parents */ |
| 349 |
|
| 350 |
/* |
| 351 |
* These fields are computed only if we decide the table is interesting |
| 352 |
* (it's either a table to dump, or a direct parent of a dumpable table). |
| 353 |
*/ |
| 354 |
int numatts; /* number of attributes */ |
| 355 |
char **attnames; /* the attribute names */ |
| 356 |
char **atttypnames; /* attribute type names */ |
| 357 |
int *attstattarget; /* attribute statistics targets */ |
| 358 |
char *attstorage; /* attribute storage scheme */ |
| 359 |
char *typstorage; /* type storage scheme */ |
| 360 |
bool *attisdropped; /* true if attr is dropped; don't dump it */ |
| 361 |
char *attidentity; |
| 362 |
char *attgenerated; |
| 363 |
int *attlen; /* attribute length, used by binary_upgrade */ |
| 364 |
char *attalign; /* attribute align, used by binary_upgrade */ |
| 365 |
bool *attislocal; /* true if attr has local definition */ |
| 366 |
char **attoptions; /* per-attribute options */ |
| 367 |
Oid *attcollation; /* per-attribute collation selection */ |
| 368 |
char *attcompression; /* per-attribute compression method */ |
| 369 |
char **attfdwoptions; /* per-attribute fdw options */ |
| 370 |
char **attmissingval; /* per attribute missing value */ |
| 371 |
char **notnull_constrs; /* NOT NULL constraint names. If null, |
| 372 |
* there isn't one on this column. If |
| 373 |
* empty string, unnamed constraint |
| 374 |
* (pre-v17) */ |
| 375 |
char **notnull_comment; /* comment thereof */ |
| 376 |
bool *notnull_invalid; /* true for NOT NULL NOT VALID */ |
| 377 |
bool *notnull_noinh; /* NOT NULL is NO INHERIT */ |
| 378 |
bool *notnull_islocal; /* true if NOT NULL has local definition */ |
| 379 |
struct _attrDefInfo **attrdefs; /* DEFAULT expressions */ |
| 380 |
struct _constraintInfo *checkexprs; /* CHECK constraints */ |
| 381 |
struct _relStatsInfo *stats; /* only set for matviews */ |
| 382 |
bool needs_override; /* has GENERATED ALWAYS AS IDENTITY */ |
| 383 |
char *amname; /* relation access method */ |
| 384 |
|
| 385 |
/* |
| 386 |
* Stuff computed only for dumpable tables. |
| 387 |
*/ |
| 388 |
int numIndexes; /* number of indexes */ |
| 389 |
struct _indxInfo *indexes; /* indexes */ |
| 390 |
struct _tableDataInfo *dataObj; /* TableDataInfo, if dumping its data */ |
| 391 |
int numTriggers; /* number of triggers for table */ |
| 392 |
struct _triggerInfo *triggers; /* array of TriggerInfo structs */ |
| 393 |
} TableInfo; |
| 394 |
|
| 395 |
typedef struct _tableAttachInfo |
| 396 |
{ |
| 397 |
DumpableObject dobj; |
| 398 |
TableInfo *parentTbl; /* link to partitioned table */ |
| 399 |
TableInfo *partitionTbl; /* link to partition */ |
| 400 |
} TableAttachInfo; |
| 401 |
|
| 402 |
typedef struct _attrDefInfo |
| 403 |
{ |
| 404 |
DumpableObject dobj; /* note: dobj.name is name of table */ |
| 405 |
TableInfo *adtable; /* link to table of attribute */ |
| 406 |
int adnum; |
| 407 |
char *adef_expr; /* decompiled DEFAULT expression */ |
| 408 |
bool separate; /* true if must dump as separate item */ |
| 409 |
} AttrDefInfo; |
| 410 |
|
| 411 |
typedef struct _tableDataInfo |
| 412 |
{ |
| 413 |
DumpableObject dobj; |
| 414 |
TableInfo *tdtable; /* link to table to dump */ |
| 415 |
char *filtercond; /* WHERE condition to limit rows dumped */ |
| 416 |
} TableDataInfo; |
| 417 |
|
| 418 |
typedef struct _indxInfo |
| 419 |
{ |
| 420 |
DumpableObject dobj; |
| 421 |
TableInfo *indextable; /* link to table the index is for */ |
| 422 |
char *indexdef; |
| 423 |
char *tablespace; /* tablespace in which index is stored */ |
| 424 |
char *indreloptions; /* options specified by WITH (...) */ |
| 425 |
char *indstatcols; /* column numbers with statistics */ |
| 426 |
char *indstatvals; /* statistic values for columns */ |
| 427 |
int indnkeyattrs; /* number of index key attributes */ |
| 428 |
int indnattrs; /* total number of index attributes */ |
| 429 |
int *indkeys; /* In spite of the name 'indkeys' this field |
| 430 |
* contains both key and nonkey attributes */ |
| 431 |
bool indisclustered; |
| 432 |
bool indisreplident; |
| 433 |
bool indnullsnotdistinct; |
| 434 |
Oid parentidx; /* if a partition, parent index OID */ |
| 435 |
SimplePtrList partattaches; /* if partitioned, partition attach objects */ |
| 436 |
|
| 437 |
/* if there is an associated constraint object, its dumpId: */ |
| 438 |
DumpId indexconstraint; |
| 439 |
} IndxInfo; |
| 440 |
|
| 441 |
typedef struct _indexAttachInfo |
| 442 |
{ |
| 443 |
DumpableObject dobj; |
| 444 |
IndxInfo *parentIdx; /* link to index on partitioned table */ |
| 445 |
IndxInfo *partitionIdx; /* link to index on partition */ |
| 446 |
} IndexAttachInfo; |
| 447 |
|
| 448 |
typedef struct _relStatsInfo |
| 449 |
{ |
| 450 |
DumpableObject dobj; |
| 451 |
int32 relpages; |
| 452 |
char *reltuples; |
| 453 |
int32 relallvisible; |
| 454 |
int32 relallfrozen; |
| 455 |
char relkind; /* 'r', 'm', 'i', etc */ |
| 456 |
|
| 457 |
/* |
| 458 |
* indAttNames/nindAttNames are populated only if the relation is an index |
| 459 |
* with at least one expression column; we don't need them otherwise. |
| 460 |
*/ |
| 461 |
char **indAttNames; /* attnames of the index, in order */ |
| 462 |
int32 nindAttNames; /* number of attnames stored (can be 0) */ |
| 463 |
teSection section; /* stats may appear in data or post-data */ |
| 464 |
} RelStatsInfo; |
| 465 |
|
| 466 |
typedef struct _statsExtInfo |
| 467 |
{ |
| 468 |
DumpableObject dobj; |
| 469 |
const char *rolname; /* owner */ |
| 470 |
TableInfo *stattable; /* link to table the stats are for */ |
| 471 |
int stattarget; /* statistics target */ |
| 472 |
} StatsExtInfo; |
| 473 |
|
| 474 |
typedef struct _ruleInfo |
| 475 |
{ |
| 476 |
DumpableObject dobj; |
| 477 |
TableInfo *ruletable; /* link to table the rule is for */ |
| 478 |
char ev_type; |
| 479 |
bool is_instead; |
| 480 |
char ev_enabled; |
| 481 |
bool separate; /* true if must dump as separate item */ |
| 482 |
/* separate is always true for non-ON SELECT rules */ |
| 483 |
} RuleInfo; |
| 484 |
|
| 485 |
typedef struct _triggerInfo |
| 486 |
{ |
| 487 |
DumpableObject dobj; |
| 488 |
TableInfo *tgtable; /* link to table the trigger is for */ |
| 489 |
char tgenabled; |
| 490 |
bool tgispartition; |
| 491 |
char *tgdef; |
| 492 |
} TriggerInfo; |
| 493 |
|
| 494 |
typedef struct _evttriggerInfo |
| 495 |
{ |
| 496 |
DumpableObject dobj; |
| 497 |
char *evtname; |
| 498 |
char *evtevent; |
| 499 |
const char *evtowner; |
| 500 |
char *evttags; |
| 501 |
char *evtfname; |
| 502 |
char evtenabled; |
| 503 |
} EventTriggerInfo; |
| 504 |
|
| 505 |
/* |
| 506 |
* struct ConstraintInfo is used for all constraint types. However we |
| 507 |
* use a different objType for foreign key constraints, to make it easier |
| 508 |
* to sort them the way we want. |
| 509 |
* |
| 510 |
* Not-null constraints don't need this, unless they are NOT VALID. |
| 511 |
* |
| 512 |
* Note: condeferrable and condeferred are currently only valid for |
| 513 |
* unique/primary-key constraints. Otherwise that info is in condef. |
| 514 |
*/ |
| 515 |
typedef struct _constraintInfo |
| 516 |
{ |
| 517 |
DumpableObject dobj; |
| 518 |
TableInfo *contable; /* NULL if domain constraint */ |
| 519 |
TypeInfo *condomain; /* NULL if table constraint */ |
| 520 |
char contype; |
| 521 |
char *condef; /* definition, if CHECK or FOREIGN KEY */ |
| 522 |
Oid confrelid; /* referenced table, if FOREIGN KEY */ |
| 523 |
DumpId conindex; /* identifies associated index if any */ |
| 524 |
bool condeferrable; /* true if constraint is DEFERRABLE */ |
| 525 |
bool condeferred; /* true if constraint is INITIALLY DEFERRED */ |
| 526 |
bool conperiod; /* true if the constraint is WITHOUT OVERLAPS */ |
| 527 |
bool conislocal; /* true if constraint has local definition */ |
| 528 |
bool separate; /* true if must dump as separate item */ |
| 529 |
} ConstraintInfo; |
| 530 |
|
| 531 |
typedef struct _procLangInfo |
| 532 |
{ |
| 533 |
DumpableObject dobj; |
| 534 |
DumpableAcl dacl; |
| 535 |
bool lanpltrusted; |
| 536 |
Oid lanplcallfoid; |
| 537 |
Oid laninline; |
| 538 |
Oid lanvalidator; |
| 539 |
const char *lanowner; |
| 540 |
} ProcLangInfo; |
| 541 |
|
| 542 |
typedef struct _castInfo |
| 543 |
{ |
| 544 |
DumpableObject dobj; |
| 545 |
Oid castsource; |
| 546 |
Oid casttarget; |
| 547 |
Oid castfunc; |
| 548 |
char castcontext; |
| 549 |
char castmethod; |
| 550 |
} CastInfo; |
| 551 |
|
| 552 |
typedef struct _transformInfo |
| 553 |
{ |
| 554 |
DumpableObject dobj; |
| 555 |
Oid trftype; |
| 556 |
Oid trflang; |
| 557 |
Oid trffromsql; |
| 558 |
Oid trftosql; |
| 559 |
} TransformInfo; |
| 560 |
|
| 561 |
/* InhInfo isn't a DumpableObject, just temporary state */ |
| 562 |
typedef struct _inhInfo |
| 563 |
{ |
| 564 |
Oid inhrelid; /* OID of a child table */ |
| 565 |
Oid inhparent; /* OID of its parent */ |
| 566 |
} InhInfo; |
| 567 |
|
| 568 |
typedef struct _prsInfo |
| 569 |
{ |
| 570 |
DumpableObject dobj; |
| 571 |
Oid prsstart; |
| 572 |
Oid prstoken; |
| 573 |
Oid prsend; |
| 574 |
Oid prsheadline; |
| 575 |
Oid prslextype; |
| 576 |
} TSParserInfo; |
| 577 |
|
| 578 |
typedef struct _dictInfo |
| 579 |
{ |
| 580 |
DumpableObject dobj; |
| 581 |
const char *rolname; |
| 582 |
Oid dicttemplate; |
| 583 |
char *dictinitoption; |
| 584 |
} TSDictInfo; |
| 585 |
|
| 586 |
typedef struct _tmplInfo |
| 587 |
{ |
| 588 |
DumpableObject dobj; |
| 589 |
Oid tmplinit; |
| 590 |
Oid tmpllexize; |
| 591 |
} TSTemplateInfo; |
| 592 |
|
| 593 |
typedef struct _cfgInfo |
| 594 |
{ |
| 595 |
DumpableObject dobj; |
| 596 |
const char *rolname; |
| 597 |
Oid cfgparser; |
| 598 |
} TSConfigInfo; |
| 599 |
|
| 600 |
typedef struct _fdwInfo |
| 601 |
{ |
| 602 |
DumpableObject dobj; |
| 603 |
DumpableAcl dacl; |
| 604 |
const char *rolname; |
| 605 |
char *fdwhandler; |
| 606 |
char *fdwvalidator; |
| 607 |
char *fdwoptions; |
| 608 |
} FdwInfo; |
| 609 |
|
| 610 |
typedef struct _foreignServerInfo |
| 611 |
{ |
| 612 |
DumpableObject dobj; |
| 613 |
DumpableAcl dacl; |
| 614 |
const char *rolname; |
| 615 |
Oid srvfdw; |
| 616 |
char *srvtype; |
| 617 |
char *srvversion; |
| 618 |
char *srvoptions; |
| 619 |
} ForeignServerInfo; |
| 620 |
|
| 621 |
typedef struct _defaultACLInfo |
| 622 |
{ |
| 623 |
DumpableObject dobj; |
| 624 |
DumpableAcl dacl; |
| 625 |
const char *defaclrole; |
| 626 |
char defaclobjtype; |
| 627 |
} DefaultACLInfo; |
| 628 |
|
| 629 |
/* |
| 630 |
* LoInfo represents a group of large objects (blobs) that share the same |
| 631 |
* owner and ACL setting. dobj.components has the DUMP_COMPONENT_COMMENT bit |
| 632 |
* set if any blob in the group has a comment; similarly for sec labels. |
| 633 |
* If there are many blobs with the same owner/ACL, we can divide them into |
| 634 |
* multiple LoInfo groups, which will each spawn a BLOB METADATA and a BLOBS |
| 635 |
* (data) TOC entry. This allows more parallelism during restore. |
| 636 |
*/ |
| 637 |
typedef struct _loInfo |
| 638 |
{ |
| 639 |
DumpableObject dobj; |
| 640 |
DumpableAcl dacl; |
| 641 |
const char *rolname; |
| 642 |
int numlos; |
| 643 |
Oid looids[FLEXIBLE_ARRAY_MEMBER]; |
| 644 |
} LoInfo; |
| 645 |
|
| 646 |
/* |
| 647 |
* The PolicyInfo struct is used to represent policies on a table and |
| 648 |
* to indicate if a table has RLS enabled (ENABLE ROW SECURITY). If |
| 649 |
* polname is NULL, then the record indicates ENABLE ROW SECURITY, while if |
| 650 |
* it's non-NULL then this is a regular policy definition. |
| 651 |
*/ |
| 652 |
typedef struct _policyInfo |
| 653 |
{ |
| 654 |
DumpableObject dobj; |
| 655 |
TableInfo *poltable; |
| 656 |
char *polname; /* null indicates RLS is enabled on rel */ |
| 657 |
char polcmd; |
| 658 |
bool polpermissive; |
| 659 |
char *polroles; |
| 660 |
char *polqual; |
| 661 |
char *polwithcheck; |
| 662 |
} PolicyInfo; |
| 663 |
|
| 664 |
/* |
| 665 |
* The PublicationInfo struct is used to represent publications. |
| 666 |
*/ |
| 667 |
typedef struct _PublicationInfo |
| 668 |
{ |
| 669 |
DumpableObject dobj; |
| 670 |
const char *rolname; |
| 671 |
bool puballtables; |
| 672 |
bool pubinsert; |
| 673 |
bool pubupdate; |
| 674 |
bool pubdelete; |
| 675 |
bool pubtruncate; |
| 676 |
bool pubviaroot; |
| 677 |
PublishGencolsType pubgencols_type; |
| 678 |
} PublicationInfo; |
| 679 |
|
| 680 |
/* |
| 681 |
* The PublicationRelInfo struct is used to represent publication table |
| 682 |
* mapping. |
| 683 |
*/ |
| 684 |
typedef struct _PublicationRelInfo |
| 685 |
{ |
| 686 |
DumpableObject dobj; |
| 687 |
PublicationInfo *publication; |
| 688 |
TableInfo *pubtable; |
| 689 |
char *pubrelqual; |
| 690 |
char *pubrattrs; |
| 691 |
} PublicationRelInfo; |
| 692 |
|
| 693 |
/* |
| 694 |
* The PublicationSchemaInfo struct is used to represent publication schema |
| 695 |
* mapping. |
| 696 |
*/ |
| 697 |
typedef struct _PublicationSchemaInfo |
| 698 |
{ |
| 699 |
DumpableObject dobj; |
| 700 |
PublicationInfo *publication; |
| 701 |
NamespaceInfo *pubschema; |
| 702 |
} PublicationSchemaInfo; |
| 703 |
|
| 704 |
/* |
| 705 |
* The SubscriptionInfo struct is used to represent subscription. |
| 706 |
*/ |
| 707 |
typedef struct _SubscriptionInfo |
| 708 |
{ |
| 709 |
DumpableObject dobj; |
| 710 |
const char *rolname; |
| 711 |
bool subenabled; |
| 712 |
bool subbinary; |
| 713 |
char substream; |
| 714 |
char subtwophasestate; |
| 715 |
bool subdisableonerr; |
| 716 |
bool subpasswordrequired; |
| 717 |
bool subrunasowner; |
| 718 |
bool subfailover; |
| 719 |
char *subconninfo; |
| 720 |
char *subslotname; |
| 721 |
char *subsynccommit; |
| 722 |
char *subpublications; |
| 723 |
char *suborigin; |
| 724 |
char *suboriginremotelsn; |
| 725 |
} SubscriptionInfo; |
| 726 |
|
| 727 |
/* |
| 728 |
* The SubRelInfo struct is used to represent a subscription relation. |
| 729 |
* |
| 730 |
* XXX Currently, the subscription tables are added to the subscription after |
| 731 |
* enabling the subscription in binary-upgrade mode. As the apply workers will |
| 732 |
* not be started in binary_upgrade mode the ordering of enable subscription |
| 733 |
* does not matter. The order of adding the subscription tables to the |
| 734 |
* subscription and enabling the subscription should be taken care of if this |
| 735 |
* feature will be supported in a non-binary-upgrade mode in the future. |
| 736 |
*/ |
| 737 |
typedef struct _SubRelInfo |
| 738 |
{ |
| 739 |
DumpableObject dobj; |
| 740 |
SubscriptionInfo *subinfo; |
| 741 |
TableInfo *tblinfo; |
| 742 |
char srsubstate; |
| 743 |
char *srsublsn; |
| 744 |
} SubRelInfo; |
| 745 |
|
| 746 |
/* |
| 747 |
* common utility functions |
| 748 |
*/ |
| 749 |
|
| 750 |
extern TableInfo *getSchemaData(Archive *fout, int *numTablesPtr); |
| 751 |
|
| 752 |
extern void AssignDumpId(DumpableObject *dobj); |
| 753 |
extern void recordAdditionalCatalogID(CatalogId catId, DumpableObject *dobj); |
| 754 |
extern DumpId createDumpId(void); |
| 755 |
extern DumpId getMaxDumpId(void); |
| 756 |
extern DumpableObject *findObjectByDumpId(DumpId dumpId); |
| 757 |
extern DumpableObject *findObjectByCatalogId(CatalogId catalogId); |
| 758 |
extern void getDumpableObjects(DumpableObject ***objs, int *numObjs); |
| 759 |
|
| 760 |
extern void addObjectDependency(DumpableObject *dobj, DumpId refId); |
| 761 |
extern void removeObjectDependency(DumpableObject *dobj, DumpId refId); |
| 762 |
|
| 763 |
extern TableInfo *findTableByOid(Oid oid); |
| 764 |
extern TypeInfo *findTypeByOid(Oid oid); |
| 765 |
extern FuncInfo *findFuncByOid(Oid oid); |
| 766 |
extern OprInfo *findOprByOid(Oid oid); |
| 767 |
extern AccessMethodInfo *findAccessMethodByOid(Oid oid); |
| 768 |
extern CollInfo *findCollationByOid(Oid oid); |
| 769 |
extern NamespaceInfo *findNamespaceByOid(Oid oid); |
| 770 |
extern ExtensionInfo *findExtensionByOid(Oid oid); |
| 771 |
extern PublicationInfo *findPublicationByOid(Oid oid); |
| 772 |
extern SubscriptionInfo *findSubscriptionByOid(Oid oid); |
| 773 |
|
| 774 |
extern void recordExtensionMembership(CatalogId catId, ExtensionInfo *ext); |
| 775 |
extern ExtensionInfo *findOwningExtension(CatalogId catalogId); |
| 776 |
|
| 777 |
extern Oid *parseOidArray(const char *str, int arraysize); |
| 778 |
extern int *parseIntArray(const char *str, int arraysize); |
| 779 |
|
| 780 |
extern void sortDumpableObjects(DumpableObject **objs, int numObjs, |
| 781 |
DumpId preBoundaryId, DumpId postBoundaryId); |
| 782 |
extern void sortDumpableObjectsByTypeName(DumpableObject **objs, int numObjs); |
| 783 |
|
| 784 |
/* |
| 785 |
* version specific routines |
| 786 |
*/ |
| 787 |
extern void getNamespaces(Archive *fout); |
| 788 |
extern ExtensionInfo *getExtensions(Archive *fout, int *numExtensions); |
| 789 |
extern void getTypes(Archive *fout); |
| 790 |
extern void getFuncs(Archive *fout); |
| 791 |
extern void getAggregates(Archive *fout); |
| 792 |
extern void getOperators(Archive *fout); |
| 793 |
extern void getAccessMethods(Archive *fout); |
| 794 |
extern void getOpclasses(Archive *fout); |
| 795 |
extern void getOpfamilies(Archive *fout); |
| 796 |
extern void getCollations(Archive *fout); |
| 797 |
extern void getConversions(Archive *fout); |
| 798 |
extern TableInfo *getTables(Archive *fout, int *numTables); |
| 799 |
extern void getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables); |
| 800 |
extern InhInfo *getInherits(Archive *fout, int *numInherits); |
| 801 |
extern void getPartitioningInfo(Archive *fout); |
| 802 |
extern void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables); |
| 803 |
extern void getExtendedStatistics(Archive *fout); |
| 804 |
extern void getConstraints(Archive *fout, TableInfo tblinfo[], int numTables); |
| 805 |
extern void getRules(Archive *fout); |
| 806 |
extern void getTriggers(Archive *fout, TableInfo tblinfo[], int numTables); |
| 807 |
extern void getProcLangs(Archive *fout); |
| 808 |
extern void getCasts(Archive *fout); |
| 809 |
extern void getTransforms(Archive *fout); |
| 810 |
extern void getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables); |
| 811 |
extern bool shouldPrintColumn(const DumpOptions *dopt, const TableInfo *tbinfo, int colno); |
| 812 |
extern void getTSParsers(Archive *fout); |
| 813 |
extern void getTSDictionaries(Archive *fout); |
| 814 |
extern void getTSTemplates(Archive *fout); |
| 815 |
extern void getTSConfigurations(Archive *fout); |
| 816 |
extern void getForeignDataWrappers(Archive *fout); |
| 817 |
extern void getForeignServers(Archive *fout); |
| 818 |
extern void getDefaultACLs(Archive *fout); |
| 819 |
extern void getExtensionMembership(Archive *fout, ExtensionInfo extinfo[], |
| 820 |
int numExtensions); |
| 821 |
extern void processExtensionTables(Archive *fout, ExtensionInfo extinfo[], |
| 822 |
int numExtensions); |
| 823 |
extern void getEventTriggers(Archive *fout); |
| 824 |
extern void getPolicies(Archive *fout, TableInfo tblinfo[], int numTables); |
| 825 |
extern void getPublications(Archive *fout); |
| 826 |
extern void getPublicationNamespaces(Archive *fout); |
| 827 |
extern void getPublicationTables(Archive *fout, TableInfo tblinfo[], |
| 828 |
int numTables); |
| 829 |
extern void getSubscriptions(Archive *fout); |
| 830 |
extern void getSubscriptionTables(Archive *fout); |
| 831 |
|
| 832 |
#endif /* PG_DUMP_H */ |