00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef PG_DUMP_H
00015 #define PG_DUMP_H
00016
00017 #include "postgres_fe.h"
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 typedef struct
00036 {
00037 Oid tableoid;
00038 Oid oid;
00039 } CatalogId;
00040
00041 typedef int DumpId;
00042
00043
00044
00045
00046
00047
00048
00049 typedef struct SimpleOidListCell
00050 {
00051 struct SimpleOidListCell *next;
00052 Oid val;
00053 } SimpleOidListCell;
00054
00055 typedef struct SimpleOidList
00056 {
00057 SimpleOidListCell *head;
00058 SimpleOidListCell *tail;
00059 } SimpleOidList;
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 typedef enum
00078 {
00079
00080 DO_NAMESPACE,
00081 DO_EXTENSION,
00082 DO_TYPE,
00083 DO_SHELL_TYPE,
00084 DO_FUNC,
00085 DO_AGG,
00086 DO_OPERATOR,
00087 DO_OPCLASS,
00088 DO_OPFAMILY,
00089 DO_COLLATION,
00090 DO_CONVERSION,
00091 DO_TABLE,
00092 DO_ATTRDEF,
00093 DO_INDEX,
00094 DO_RULE,
00095 DO_TRIGGER,
00096 DO_CONSTRAINT,
00097 DO_FK_CONSTRAINT,
00098 DO_PROCLANG,
00099 DO_CAST,
00100 DO_TABLE_DATA,
00101 DO_DUMMY_TYPE,
00102 DO_TSPARSER,
00103 DO_TSDICT,
00104 DO_TSTEMPLATE,
00105 DO_TSCONFIG,
00106 DO_FDW,
00107 DO_FOREIGN_SERVER,
00108 DO_DEFAULT_ACL,
00109 DO_BLOB,
00110 DO_BLOB_DATA,
00111 DO_PRE_DATA_BOUNDARY,
00112 DO_POST_DATA_BOUNDARY,
00113 DO_EVENT_TRIGGER,
00114 DO_REFRESH_MATVIEW
00115 } DumpableObjectType;
00116
00117 typedef struct _dumpableObject
00118 {
00119 DumpableObjectType objType;
00120 CatalogId catId;
00121 DumpId dumpId;
00122 char *name;
00123 struct _namespaceInfo *namespace;
00124 bool dump;
00125 bool ext_member;
00126 DumpId *dependencies;
00127 int nDeps;
00128 int allocDeps;
00129 } DumpableObject;
00130
00131 typedef struct _namespaceInfo
00132 {
00133 DumpableObject dobj;
00134 char *rolname;
00135 char *nspacl;
00136 } NamespaceInfo;
00137
00138 typedef struct _extensionInfo
00139 {
00140 DumpableObject dobj;
00141 char *namespace;
00142 bool relocatable;
00143 char *extversion;
00144 char *extconfig;
00145 char *extcondition;
00146 } ExtensionInfo;
00147
00148 typedef struct _typeInfo
00149 {
00150 DumpableObject dobj;
00151
00152
00153
00154
00155
00156 char *rolname;
00157 char *typacl;
00158 Oid typelem;
00159 Oid typrelid;
00160 char typrelkind;
00161 char typtype;
00162 bool isArray;
00163 bool isDefined;
00164
00165 struct _shellTypeInfo *shellType;
00166
00167 int nDomChecks;
00168 struct _constraintInfo *domChecks;
00169 } TypeInfo;
00170
00171 typedef struct _shellTypeInfo
00172 {
00173 DumpableObject dobj;
00174
00175 TypeInfo *baseType;
00176 } ShellTypeInfo;
00177
00178 typedef struct _funcInfo
00179 {
00180 DumpableObject dobj;
00181 char *rolname;
00182 Oid lang;
00183 int nargs;
00184 Oid *argtypes;
00185 Oid prorettype;
00186 char *proacl;
00187 char *proiargs;
00188 } FuncInfo;
00189
00190
00191 typedef struct _aggInfo
00192 {
00193 FuncInfo aggfn;
00194
00195 } AggInfo;
00196
00197 typedef struct _oprInfo
00198 {
00199 DumpableObject dobj;
00200 char *rolname;
00201 char oprkind;
00202 Oid oprcode;
00203 } OprInfo;
00204
00205 typedef struct _opclassInfo
00206 {
00207 DumpableObject dobj;
00208 char *rolname;
00209 } OpclassInfo;
00210
00211 typedef struct _opfamilyInfo
00212 {
00213 DumpableObject dobj;
00214 char *rolname;
00215 } OpfamilyInfo;
00216
00217 typedef struct _collInfo
00218 {
00219 DumpableObject dobj;
00220 char *rolname;
00221 } CollInfo;
00222
00223 typedef struct _convInfo
00224 {
00225 DumpableObject dobj;
00226 char *rolname;
00227 } ConvInfo;
00228
00229 typedef struct _tableInfo
00230 {
00231
00232
00233
00234 DumpableObject dobj;
00235 char *rolname;
00236 char *relacl;
00237 char relkind;
00238 char relpersistence;
00239 char *reltablespace;
00240 char *reloptions;
00241 char *toast_reloptions;
00242 bool hasindex;
00243 bool hasrules;
00244 bool hastriggers;
00245 bool hasoids;
00246 bool isscannable;
00247 uint32 frozenxid;
00248 Oid toast_oid;
00249 uint32 toast_frozenxid;
00250 int ncheck;
00251 char *reloftype;
00252
00253 Oid owning_tab;
00254 int owning_col;
00255 int relpages;
00256
00257 bool interesting;
00258
00259
00260
00261
00262
00263 int numatts;
00264 char **attnames;
00265 char **atttypnames;
00266 int *atttypmod;
00267 int *attstattarget;
00268 char *attstorage;
00269 char *typstorage;
00270 bool *attisdropped;
00271 int *attlen;
00272 char *attalign;
00273 bool *attislocal;
00274 char **attoptions;
00275 Oid *attcollation;
00276 char **attfdwoptions;
00277 bool *notnull;
00278 bool *inhNotNull;
00279 struct _attrDefInfo **attrdefs;
00280 struct _constraintInfo *checkexprs;
00281
00282
00283
00284
00285 int numParents;
00286 struct _tableInfo **parents;
00287 struct _tableDataInfo *dataObj;
00288 } TableInfo;
00289
00290 typedef struct _attrDefInfo
00291 {
00292 DumpableObject dobj;
00293 TableInfo *adtable;
00294 int adnum;
00295 char *adef_expr;
00296 bool separate;
00297 } AttrDefInfo;
00298
00299 typedef struct _tableDataInfo
00300 {
00301 DumpableObject dobj;
00302 TableInfo *tdtable;
00303 bool oids;
00304 char *filtercond;
00305 } TableDataInfo;
00306
00307 typedef struct _indxInfo
00308 {
00309 DumpableObject dobj;
00310 TableInfo *indextable;
00311 char *indexdef;
00312 char *tablespace;
00313 char *options;
00314 int indnkeys;
00315 Oid *indkeys;
00316 bool indisclustered;
00317
00318 DumpId indexconstraint;
00319 int relpages;
00320 } IndxInfo;
00321
00322 typedef struct _ruleInfo
00323 {
00324 DumpableObject dobj;
00325 TableInfo *ruletable;
00326 char ev_type;
00327 bool is_instead;
00328 char ev_enabled;
00329 bool separate;
00330
00331 char *reloptions;
00332
00333 } RuleInfo;
00334
00335 typedef struct _triggerInfo
00336 {
00337 DumpableObject dobj;
00338 TableInfo *tgtable;
00339 char *tgfname;
00340 int tgtype;
00341 int tgnargs;
00342 char *tgargs;
00343 bool tgisconstraint;
00344 char *tgconstrname;
00345 Oid tgconstrrelid;
00346 char *tgconstrrelname;
00347 char tgenabled;
00348 bool tgdeferrable;
00349 bool tginitdeferred;
00350 char *tgdef;
00351 } TriggerInfo;
00352
00353 typedef struct _evttriggerInfo
00354 {
00355 DumpableObject dobj;
00356 char *evtname;
00357 char *evtevent;
00358 char *evtowner;
00359 char *evttags;
00360 char *evtfname;
00361 char evttype;
00362 char evtenabled;
00363 } EventTriggerInfo;
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373 typedef struct _constraintInfo
00374 {
00375 DumpableObject dobj;
00376 TableInfo *contable;
00377 TypeInfo *condomain;
00378 char contype;
00379 char *condef;
00380 Oid confrelid;
00381 DumpId conindex;
00382 bool condeferrable;
00383 bool condeferred;
00384 bool conislocal;
00385 bool separate;
00386 } ConstraintInfo;
00387
00388 typedef struct _procLangInfo
00389 {
00390 DumpableObject dobj;
00391 bool lanpltrusted;
00392 Oid lanplcallfoid;
00393 Oid laninline;
00394 Oid lanvalidator;
00395 char *lanacl;
00396 char *lanowner;
00397 } ProcLangInfo;
00398
00399 typedef struct _castInfo
00400 {
00401 DumpableObject dobj;
00402 Oid castsource;
00403 Oid casttarget;
00404 Oid castfunc;
00405 char castcontext;
00406 char castmethod;
00407 } CastInfo;
00408
00409
00410 typedef struct _inhInfo
00411 {
00412 Oid inhrelid;
00413 Oid inhparent;
00414 } InhInfo;
00415
00416 typedef struct _prsInfo
00417 {
00418 DumpableObject dobj;
00419 Oid prsstart;
00420 Oid prstoken;
00421 Oid prsend;
00422 Oid prsheadline;
00423 Oid prslextype;
00424 } TSParserInfo;
00425
00426 typedef struct _dictInfo
00427 {
00428 DumpableObject dobj;
00429 char *rolname;
00430 Oid dicttemplate;
00431 char *dictinitoption;
00432 } TSDictInfo;
00433
00434 typedef struct _tmplInfo
00435 {
00436 DumpableObject dobj;
00437 Oid tmplinit;
00438 Oid tmpllexize;
00439 } TSTemplateInfo;
00440
00441 typedef struct _cfgInfo
00442 {
00443 DumpableObject dobj;
00444 char *rolname;
00445 Oid cfgparser;
00446 } TSConfigInfo;
00447
00448 typedef struct _fdwInfo
00449 {
00450 DumpableObject dobj;
00451 char *rolname;
00452 char *fdwhandler;
00453 char *fdwvalidator;
00454 char *fdwoptions;
00455 char *fdwacl;
00456 } FdwInfo;
00457
00458 typedef struct _foreignServerInfo
00459 {
00460 DumpableObject dobj;
00461 char *rolname;
00462 Oid srvfdw;
00463 char *srvtype;
00464 char *srvversion;
00465 char *srvacl;
00466 char *srvoptions;
00467 } ForeignServerInfo;
00468
00469 typedef struct _defaultACLInfo
00470 {
00471 DumpableObject dobj;
00472 char *defaclrole;
00473 char defaclobjtype;
00474 char *defaclacl;
00475 } DefaultACLInfo;
00476
00477 typedef struct _blobInfo
00478 {
00479 DumpableObject dobj;
00480 char *rolname;
00481 char *blobacl;
00482 } BlobInfo;
00483
00484
00485 extern bool force_quotes;
00486 extern bool g_verbose;
00487
00488
00489 extern char g_comment_start[10];
00490 extern char g_comment_end[10];
00491
00492 extern char g_opaque_type[10];
00493
00494
00495
00496
00497
00498 struct Archive;
00499 typedef struct Archive Archive;
00500
00501 extern TableInfo *getSchemaData(Archive *, int *numTablesPtr);
00502
00503 typedef enum _OidOptions
00504 {
00505 zeroAsOpaque = 1,
00506 zeroAsAny = 2,
00507 zeroAsStar = 4,
00508 zeroAsNone = 8
00509 } OidOptions;
00510
00511 extern void AssignDumpId(DumpableObject *dobj);
00512 extern DumpId createDumpId(void);
00513 extern DumpId getMaxDumpId(void);
00514 extern DumpableObject *findObjectByDumpId(DumpId dumpId);
00515 extern DumpableObject *findObjectByCatalogId(CatalogId catalogId);
00516 extern void getDumpableObjects(DumpableObject ***objs, int *numObjs);
00517
00518 extern void addObjectDependency(DumpableObject *dobj, DumpId refId);
00519 extern void removeObjectDependency(DumpableObject *dobj, DumpId refId);
00520
00521 extern TableInfo *findTableByOid(Oid oid);
00522 extern TypeInfo *findTypeByOid(Oid oid);
00523 extern FuncInfo *findFuncByOid(Oid oid);
00524 extern OprInfo *findOprByOid(Oid oid);
00525 extern CollInfo *findCollationByOid(Oid oid);
00526 extern NamespaceInfo *findNamespaceByOid(Oid oid);
00527
00528 extern void simple_oid_list_append(SimpleOidList *list, Oid val);
00529 extern bool simple_oid_list_member(SimpleOidList *list, Oid val);
00530
00531 extern void parseOidArray(const char *str, Oid *array, int arraysize);
00532
00533 extern void sortDumpableObjects(DumpableObject **objs, int numObjs,
00534 DumpId preBoundaryId, DumpId postBoundaryId);
00535 extern void sortDumpableObjectsByTypeName(DumpableObject **objs, int numObjs);
00536 extern void sortDumpableObjectsByTypeOid(DumpableObject **objs, int numObjs);
00537 extern void sortDataAndIndexObjectsBySize(DumpableObject **objs, int numObjs);
00538
00539
00540
00541
00542 extern NamespaceInfo *getNamespaces(Archive *fout, int *numNamespaces);
00543 extern ExtensionInfo *getExtensions(Archive *fout, int *numExtensions);
00544 extern TypeInfo *getTypes(Archive *fout, int *numTypes);
00545 extern FuncInfo *getFuncs(Archive *fout, int *numFuncs);
00546 extern AggInfo *getAggregates(Archive *fout, int *numAggregates);
00547 extern OprInfo *getOperators(Archive *fout, int *numOperators);
00548 extern OpclassInfo *getOpclasses(Archive *fout, int *numOpclasses);
00549 extern OpfamilyInfo *getOpfamilies(Archive *fout, int *numOpfamilies);
00550 extern CollInfo *getCollations(Archive *fout, int *numCollations);
00551 extern ConvInfo *getConversions(Archive *fout, int *numConversions);
00552 extern TableInfo *getTables(Archive *fout, int *numTables);
00553 extern void getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables);
00554 extern InhInfo *getInherits(Archive *fout, int *numInherits);
00555 extern void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables);
00556 extern void getConstraints(Archive *fout, TableInfo tblinfo[], int numTables);
00557 extern RuleInfo *getRules(Archive *fout, int *numRules);
00558 extern void getTriggers(Archive *fout, TableInfo tblinfo[], int numTables);
00559 extern ProcLangInfo *getProcLangs(Archive *fout, int *numProcLangs);
00560 extern CastInfo *getCasts(Archive *fout, int *numCasts);
00561 extern void getTableAttrs(Archive *fout, TableInfo *tbinfo, int numTables);
00562 extern bool shouldPrintColumn(TableInfo *tbinfo, int colno);
00563 extern TSParserInfo *getTSParsers(Archive *fout, int *numTSParsers);
00564 extern TSDictInfo *getTSDictionaries(Archive *fout, int *numTSDicts);
00565 extern TSTemplateInfo *getTSTemplates(Archive *fout, int *numTSTemplates);
00566 extern TSConfigInfo *getTSConfigurations(Archive *fout, int *numTSConfigs);
00567 extern FdwInfo *getForeignDataWrappers(Archive *fout,
00568 int *numForeignDataWrappers);
00569 extern ForeignServerInfo *getForeignServers(Archive *fout,
00570 int *numForeignServers);
00571 extern DefaultACLInfo *getDefaultACLs(Archive *fout, int *numDefaultACLs);
00572 extern void getExtensionMembership(Archive *fout, ExtensionInfo extinfo[],
00573 int numExtensions);
00574 extern EventTriggerInfo *getEventTriggers(Archive *fout, int *numEventTriggers);
00575
00576 #endif