* pg_dump.h
* Common header file for the pg_dump utility
*
- * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.h,v 1.107 2003/12/06 03:00:16 tgl Exp $
+ * src/bin/pg_dump/pg_dump.h
*
*-------------------------------------------------------------------------
*/
#include "postgres_fe.h"
-
/*
* pg_dump uses two different mechanisms for identifying database objects:
*
Oid oid;
} CatalogId;
-typedef int DumpId;
+typedef int DumpId;
+
+/*
+ * Data structures for simple lists of OIDs and strings. The support for
+ * these is very primitive compared to the backend's List facilities, but
+ * it's all we need in pg_dump.
+ */
+
+typedef struct SimpleOidListCell
+{
+ struct SimpleOidListCell *next;
+ Oid val;
+} SimpleOidListCell;
+
+typedef struct SimpleOidList
+{
+ SimpleOidListCell *head;
+ SimpleOidListCell *tail;
+} SimpleOidList;
+
+typedef struct SimpleStringListCell
+{
+ struct SimpleStringListCell *next;
+ char val[1]; /* VARIABLE LENGTH FIELD */
+} SimpleStringListCell;
+typedef struct SimpleStringList
+{
+ SimpleStringListCell *head;
+ SimpleStringListCell *tail;
+} SimpleStringList;
/*
* The data structures used to store system catalog information. Every
typedef enum
{
- /* When modifying this enum, update priority table in pg_dump_sort.c! */
+ /* When modifying this enum, update priority tables in pg_dump_sort.c! */
DO_NAMESPACE,
DO_TYPE,
+ DO_SHELL_TYPE,
DO_FUNC,
DO_AGG,
DO_OPERATOR,
DO_OPCLASS,
+ DO_OPFAMILY,
DO_CONVERSION,
DO_TABLE,
DO_ATTRDEF,
DO_FK_CONSTRAINT, /* see note for ConstraintInfo */
DO_PROCLANG,
DO_CAST,
- DO_TABLE_DATA
+ DO_TABLE_DATA,
+ DO_DUMMY_TYPE,
+ DO_TSPARSER,
+ DO_TSDICT,
+ DO_TSTEMPLATE,
+ DO_TSCONFIG,
+ DO_FDW,
+ DO_FOREIGN_SERVER,
+ DO_DEFAULT_ACL,
+ DO_BLOB,
+ DO_BLOB_DATA
} DumpableObjectType;
typedef struct _dumpableObject
DumpableObjectType objType;
CatalogId catId; /* zero if not a cataloged object */
DumpId dumpId; /* assigned by AssignDumpId() */
+ char *name; /* object name (should never be NULL) */
+ struct _namespaceInfo *namespace; /* containing namespace, or NULL */
+ bool dump; /* true if we want to dump this object */
DumpId *dependencies; /* dumpIds of objects this one depends on */
int nDeps; /* number of valid dependencies */
int allocDeps; /* allocated size of dependencies[] */
typedef struct _namespaceInfo
{
DumpableObject dobj;
- char *nspname;
- char *usename; /* name of owner, or empty string */
+ char *rolname; /* name of owner, or empty string */
char *nspacl;
- bool dump; /* true if need to dump definition */
} NamespaceInfo;
typedef struct _typeInfo
{
DumpableObject dobj;
- char *typname; /* name as seen in catalog */
- /* Note: format_type might produce something different than typname */
- NamespaceInfo *typnamespace; /* link to containing namespace */
- char *usename; /* name of owner, or empty string */
- Oid typinput;
+
+ /*
+ * Note: dobj.name is the pg_type.typname entry. format_type() might
+ * produce something different than typname
+ */
+ char *rolname; /* name of owner, or empty string */
Oid typelem;
Oid typrelid;
char typrelkind; /* 'r', 'v', 'c', etc */
char typtype; /* 'b', 'c', etc */
- bool isArray; /* true if user-defined array type */
+ bool isArray; /* true if auto-generated array type */
bool isDefined; /* true if typisdefined */
+ /* If it's a dumpable base type, we create a "shell type" entry for it */
+ struct _shellTypeInfo *shellType; /* shell-type entry, or NULL */
/* If it's a domain, we store links to its constraints here: */
int nDomChecks;
struct _constraintInfo *domChecks;
} TypeInfo;
+typedef struct _shellTypeInfo
+{
+ DumpableObject dobj;
+
+ TypeInfo *baseType; /* back link to associated base type */
+} ShellTypeInfo;
+
typedef struct _funcInfo
{
DumpableObject dobj;
- char *proname;
- NamespaceInfo *pronamespace; /* link to containing namespace */
- char *usename; /* name of owner, or empty string */
+ char *rolname; /* name of owner, or empty string */
Oid lang;
int nargs;
Oid *argtypes;
typedef struct _aggInfo
{
FuncInfo aggfn;
- bool anybasetype; /* is the basetype "any"? */
- char *fmtbasetype; /* formatted type name */
+ /* we don't require any other fields at the moment */
} AggInfo;
typedef struct _oprInfo
{
DumpableObject dobj;
- char *oprname;
- NamespaceInfo *oprnamespace; /* link to containing namespace */
- char *usename;
+ char *rolname;
Oid oprcode;
} OprInfo;
typedef struct _opclassInfo
{
DumpableObject dobj;
- char *opcname;
- NamespaceInfo *opcnamespace; /* link to containing namespace */
- char *usename;
+ char *rolname;
} OpclassInfo;
+typedef struct _opfamilyInfo
+{
+ DumpableObject dobj;
+ char *rolname;
+} OpfamilyInfo;
+
typedef struct _convInfo
{
DumpableObject dobj;
- char *conname;
- NamespaceInfo *connamespace; /* link to containing namespace */
- char *usename;
+ char *rolname;
} ConvInfo;
typedef struct _tableInfo
* These fields are collected for every table in the database.
*/
DumpableObject dobj;
- char *relname;
- NamespaceInfo *relnamespace; /* link to containing namespace */
- char *usename; /* name of owner, or empty string */
+ char *rolname; /* name of owner, or empty string */
char *relacl;
char relkind;
+ char relpersistence; /* relation persistence */
+ char *reltablespace; /* relation tablespace */
+ char *reloptions; /* options specified by WITH (...) */
+ char *toast_reloptions; /* ditto, for the TOAST table */
bool hasindex; /* does it have any indexes? */
bool hasrules; /* does it have any rules? */
+ bool hastriggers; /* does it have any triggers? */
bool hasoids; /* does it have OIDs? */
+ uint32 frozenxid; /* for restore frozen xid */
int ncheck; /* # of CHECK expressions */
- int ntrig; /* # of triggers */
- /* these two are set only if table is a SERIAL column's sequence: */
+ char *reloftype; /* underlying type for typed table */
+ /* these two are set only if table is a sequence owned by a column: */
Oid owning_tab; /* OID of table owning sequence */
int owning_col; /* attr # of column owning sequence */
bool interesting; /* true if need to collect more data */
- bool dump; /* true if we want to dump it */
/*
- * These fields are computed only if we decide the table is
- * interesting (it's either a table to dump, or a direct parent of a
- * dumpable table).
+ * These fields are computed only if we decide the table is interesting
+ * (it's either a table to dump, or a direct parent of a dumpable table).
*/
int numatts; /* number of attributes */
char **attnames; /* the attribute names */
char *attstorage; /* attribute storage scheme */
char *typstorage; /* type storage scheme */
bool *attisdropped; /* true if attr is dropped; don't dump it */
+ int *attlen; /* attribute length, used by binary_upgrade */
+ char *attalign; /* attribute align, used by binary_upgrade */
bool *attislocal; /* true if attr has local definition */
- bool *attisserial; /* true if attr is serial or bigserial */
+ char **attoptions; /* per-attribute options */
/*
* Note: we need to store per-attribute notnull, default, and constraint
* were inherited.
*/
bool *notnull; /* Not null constraints on attributes */
- struct _attrDefInfo **attrdefs; /* DEFAULT expressions */
+ struct _attrDefInfo **attrdefs; /* DEFAULT expressions */
bool *inhAttrs; /* true if each attribute is inherited */
bool *inhAttrDef; /* true if attr's default is inherited */
bool *inhNotNull; /* true if NOT NULL is inherited */
- struct _constraintInfo *checkexprs; /* CHECK constraints */
+ struct _constraintInfo *checkexprs; /* CHECK constraints */
/*
* Stuff computed only for dumpable tables.
*/
int numParents; /* number of (immediate) parent tables */
- struct _tableInfo **parents; /* TableInfos of immediate parents */
+ struct _tableInfo **parents; /* TableInfos of immediate parents */
+ struct _tableDataInfo *dataObj; /* TableDataInfo, if dumping its data */
} TableInfo;
typedef struct _attrDefInfo
typedef struct _indxInfo
{
DumpableObject dobj;
- char *indexname;
TableInfo *indextable; /* link to table the index is for */
char *indexdef;
+ char *tablespace; /* tablespace in which index is stored */
+ char *options; /* options specified by WITH (...) */
int indnkeys;
Oid *indkeys;
bool indisclustered;
typedef struct _ruleInfo
{
DumpableObject dobj;
- char *rulename;
TableInfo *ruletable; /* link to table the rule is for */
char ev_type;
bool is_instead;
+ char ev_enabled;
+ bool separate; /* TRUE if must dump as separate item */
+ /* separate is always true for non-ON SELECT rules */
} RuleInfo;
typedef struct _triggerInfo
{
DumpableObject dobj;
TableInfo *tgtable; /* link to table the trigger is for */
- char *tgname;
char *tgfname;
int tgtype;
int tgnargs;
char *tgconstrname;
Oid tgconstrrelid;
char *tgconstrrelname;
+ char tgenabled;
bool tgdeferrable;
bool tginitdeferred;
+ char *tgdef;
} TriggerInfo;
/*
- * struct ConstraintInfo is used for all constraint types. However we
+ * struct ConstraintInfo is used for all constraint types. However we
* use a different objType for foreign key constraints, to make it easier
* to sort them the way we want.
+ *
+ * Note: condeferrable and condeferred are currently only valid for
+ * unique/primary-key constraints. Otherwise that info is in condef.
*/
typedef struct _constraintInfo
{
DumpableObject dobj;
- char *conname;
TableInfo *contable; /* NULL if domain constraint */
TypeInfo *condomain; /* NULL if table constraint */
char contype;
char *condef; /* definition, if CHECK or FOREIGN KEY */
+ Oid confrelid; /* referenced table, if FOREIGN KEY */
DumpId conindex; /* identifies associated index if any */
- bool coninherited; /* TRUE if appears to be inherited */
+ bool condeferrable; /* TRUE if constraint is DEFERRABLE */
+ bool condeferred; /* TRUE if constraint is INITIALLY DEFERRED */
+ bool conislocal; /* TRUE if constraint has local definition */
bool separate; /* TRUE if must dump as separate item */
} ConstraintInfo;
typedef struct _procLangInfo
{
DumpableObject dobj;
- char *lanname;
bool lanpltrusted;
Oid lanplcallfoid;
+ Oid laninline;
Oid lanvalidator;
char *lanacl;
+ char *lanowner; /* name of owner, or empty string */
} ProcLangInfo;
typedef struct _castInfo
Oid casttarget;
Oid castfunc;
char castcontext;
+ char castmethod;
} CastInfo;
/* InhInfo isn't a DumpableObject, just temporary state */
Oid inhparent; /* OID of its parent */
} InhInfo;
+typedef struct _prsInfo
+{
+ DumpableObject dobj;
+ Oid prsstart;
+ Oid prstoken;
+ Oid prsend;
+ Oid prsheadline;
+ Oid prslextype;
+} TSParserInfo;
+
+typedef struct _dictInfo
+{
+ DumpableObject dobj;
+ char *rolname;
+ Oid dicttemplate;
+ char *dictinitoption;
+} TSDictInfo;
+
+typedef struct _tmplInfo
+{
+ DumpableObject dobj;
+ Oid tmplinit;
+ Oid tmpllexize;
+} TSTemplateInfo;
+
+typedef struct _cfgInfo
+{
+ DumpableObject dobj;
+ char *rolname;
+ Oid cfgparser;
+} TSConfigInfo;
+
+typedef struct _fdwInfo
+{
+ DumpableObject dobj;
+ char *rolname;
+ char *fdwvalidator;
+ char *fdwoptions;
+ char *fdwacl;
+} FdwInfo;
+
+typedef struct _foreignServerInfo
+{
+ DumpableObject dobj;
+ char *rolname;
+ Oid srvfdw;
+ char *srvtype;
+ char *srvversion;
+ char *srvacl;
+ char *srvoptions;
+} ForeignServerInfo;
+
+typedef struct _defaultACLInfo
+{
+ DumpableObject dobj;
+ char *defaclrole;
+ char defaclobjtype;
+ char *defaclacl;
+} DefaultACLInfo;
+
+typedef struct _blobInfo
+{
+ DumpableObject dobj;
+ char *rolname;
+ char *blobacl;
+} BlobInfo;
/* global decls */
extern bool force_quotes; /* double-quotes for identifiers flag */
* common utility functions
*/
-extern TableInfo *getSchemaData(int *numTablesPtr,
- const bool schemaOnly,
- const bool dataOnly);
+extern TableInfo *getSchemaData(int *numTablesPtr);
typedef enum _OidOptions
{
extern FuncInfo *findFuncByOid(Oid oid);
extern OprInfo *findOprByOid(Oid oid);
+extern void simple_oid_list_append(SimpleOidList *list, Oid val);
+extern void simple_string_list_append(SimpleStringList *list, const char *val);
+extern bool simple_oid_list_member(SimpleOidList *list, Oid val);
+extern bool simple_string_list_member(SimpleStringList *list, const char *val);
+
+extern char *pg_strdup(const char *string);
+extern void *pg_malloc(size_t size);
+extern void *pg_calloc(size_t nmemb, size_t size);
+extern void *pg_realloc(void *ptr, size_t size);
+
extern void check_conn_and_db(void);
extern void exit_nicely(void);
extern void parseOidArray(const char *str, Oid *array, int arraysize);
extern void sortDumpableObjects(DumpableObject **objs, int numObjs);
-extern void sortDumpableObjectsByType(DumpableObject **objs, int numObjs);
+extern void sortDumpableObjectsByTypeName(DumpableObject **objs, int numObjs);
+extern void sortDumpableObjectsByTypeOid(DumpableObject **objs, int numObjs);
/*
* version specific routines
extern AggInfo *getAggregates(int *numAggregates);
extern OprInfo *getOperators(int *numOperators);
extern OpclassInfo *getOpclasses(int *numOpclasses);
+extern OpfamilyInfo *getOpfamilies(int *numOpfamilies);
extern ConvInfo *getConversions(int *numConversions);
extern TableInfo *getTables(int *numTables);
extern InhInfo *getInherits(int *numInherits);
extern ProcLangInfo *getProcLangs(int *numProcLangs);
extern CastInfo *getCasts(int *numCasts);
extern void getTableAttrs(TableInfo *tbinfo, int numTables);
+extern TSParserInfo *getTSParsers(int *numTSParsers);
+extern TSDictInfo *getTSDictionaries(int *numTSDicts);
+extern TSTemplateInfo *getTSTemplates(int *numTSTemplates);
+extern TSConfigInfo *getTSConfigurations(int *numTSConfigs);
+extern FdwInfo *getForeignDataWrappers(int *numForeignDataWrappers);
+extern ForeignServerInfo *getForeignServers(int *numForeignServers);
+extern DefaultACLInfo *getDefaultACLs(int *numDefaultACLs);
#endif /* PG_DUMP_H */