1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* pg_dump.h
|
2002-05-11 00:36:27 +02:00
|
|
|
* Common header file for the pg_dump utility
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2002-06-20 22:29:54 +02:00
|
|
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2002-09-04 22:31:48 +02:00
|
|
|
* $Id: pg_dump.h,v 1.99 2002/09/04 20:31:35 momjian Exp $
|
2000-09-15 06:35:16 +02:00
|
|
|
*
|
1996-07-09 08:22:35 +02:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
1999-10-23 05:13:33 +02:00
|
|
|
#ifndef PG_DUMP_H
|
|
|
|
#define PG_DUMP_H
|
|
|
|
|
2000-07-04 16:25:28 +02:00
|
|
|
#include "pg_backup.h"
|
1999-10-23 05:13:33 +02:00
|
|
|
|
2002-05-11 00:36:27 +02:00
|
|
|
/*
|
|
|
|
* The data structures used to store system catalog information
|
|
|
|
*
|
|
|
|
* NOTE: the structures described here live for the entire pg_dump run;
|
|
|
|
* and in most cases we make a struct for every object we can find in the
|
2002-09-04 22:31:48 +02:00
|
|
|
* catalogs, not only those we are actually going to dump. Hence, it's
|
2002-05-11 00:36:27 +02:00
|
|
|
* best to store a minimal amount of per-object info in these structs,
|
|
|
|
* and retrieve additional per-object info when and if we dump a specific
|
2002-09-04 22:31:48 +02:00
|
|
|
* object. In particular, try to avoid retrieving expensive-to-compute
|
2002-05-11 00:36:27 +02:00
|
|
|
* information until it's known to be needed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct _namespaceInfo
|
|
|
|
{
|
|
|
|
char *oid;
|
|
|
|
char *nspname;
|
|
|
|
char *usename; /* name of owner, or empty string */
|
|
|
|
char *nspacl;
|
|
|
|
bool dump; /* true if need to dump definition */
|
|
|
|
} NamespaceInfo;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
typedef struct _typeInfo
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
char *oid;
|
2002-05-11 00:36:27 +02:00
|
|
|
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 */
|
|
|
|
char *typelem; /* OID */
|
|
|
|
char *typrelid; /* OID */
|
2002-08-15 18:36:08 +02:00
|
|
|
char typrelkind; /* 'r', 'v', 'c', etc */
|
2002-05-11 00:36:27 +02:00
|
|
|
char typtype; /* 'b', 'c', etc */
|
|
|
|
bool isArray; /* true if user-defined array type */
|
|
|
|
bool isDefined; /* true if typisdefined */
|
1997-09-08 23:56:23 +02:00
|
|
|
} TypeInfo;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
typedef struct _funcInfo
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
char *oid;
|
|
|
|
char *proname;
|
2002-05-11 00:36:27 +02:00
|
|
|
NamespaceInfo *pronamespace; /* link to containing namespace */
|
|
|
|
char *usename; /* name of owner, or empty string */
|
2001-08-10 20:57:42 +02:00
|
|
|
Oid lang;
|
1997-09-08 04:41:22 +02:00
|
|
|
int nargs;
|
2002-09-04 22:31:48 +02:00
|
|
|
char **argtypes; /* OIDs */
|
2002-05-11 00:36:27 +02:00
|
|
|
char *prorettype; /* OID */
|
2002-05-19 12:08:25 +02:00
|
|
|
char *proacl;
|
2002-05-11 00:36:27 +02:00
|
|
|
bool dumped; /* true if already dumped */
|
1997-09-08 23:56:23 +02:00
|
|
|
} FuncInfo;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-05-11 00:36:27 +02:00
|
|
|
typedef struct _aggInfo
|
2000-07-04 16:25:28 +02:00
|
|
|
{
|
|
|
|
char *oid;
|
2002-05-11 00:36:27 +02:00
|
|
|
char *aggname;
|
2002-05-29 00:26:57 +02:00
|
|
|
char *aggbasetype; /* OID */
|
2002-05-11 00:36:27 +02:00
|
|
|
NamespaceInfo *aggnamespace; /* link to containing namespace */
|
|
|
|
char *usename;
|
2002-05-19 12:08:25 +02:00
|
|
|
char *aggacl;
|
2002-08-22 02:01:51 +02:00
|
|
|
bool anybasetype; /* is the basetype "any"? */
|
2002-05-29 00:26:57 +02:00
|
|
|
char *fmtbasetype; /* formatted type name */
|
2002-05-11 00:36:27 +02:00
|
|
|
} AggInfo;
|
|
|
|
|
|
|
|
typedef struct _oprInfo
|
|
|
|
{
|
|
|
|
char *oid;
|
|
|
|
char *oprname;
|
|
|
|
NamespaceInfo *oprnamespace; /* link to containing namespace */
|
|
|
|
char *usename;
|
|
|
|
char *oprcode; /* as OID, not regproc name */
|
|
|
|
} OprInfo;
|
2000-07-04 16:25:28 +02:00
|
|
|
|
2002-07-30 23:56:04 +02:00
|
|
|
typedef struct _opclassInfo
|
|
|
|
{
|
|
|
|
char *oid;
|
|
|
|
char *opcname;
|
|
|
|
NamespaceInfo *opcnamespace; /* link to containing namespace */
|
|
|
|
char *usename;
|
|
|
|
} OpclassInfo;
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct _tableInfo
|
|
|
|
{
|
2002-05-11 00:36:27 +02:00
|
|
|
/*
|
|
|
|
* These fields are collected for every table in the database.
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
char *oid;
|
|
|
|
char *relname;
|
2002-05-11 00:36:27 +02:00
|
|
|
NamespaceInfo *relnamespace; /* link to containing namespace */
|
|
|
|
char *usename; /* name of owner, or empty string */
|
1997-09-08 04:41:22 +02:00
|
|
|
char *relacl;
|
2002-01-12 00:21:55 +01:00
|
|
|
char relkind;
|
|
|
|
bool hasindex; /* does it have any indexes? */
|
2002-05-11 00:36:27 +02:00
|
|
|
bool hasrules; /* does it have any rules? */
|
2001-08-10 20:57:42 +02:00
|
|
|
bool hasoids; /* does it have OIDs? */
|
2002-05-11 00:36:27 +02:00
|
|
|
int ncheck; /* # of CHECK expressions */
|
|
|
|
int ntrig; /* # of triggers */
|
2002-08-19 21:33:36 +02:00
|
|
|
/* these two are set only if table is a SERIAL column's sequence: */
|
|
|
|
char *owning_tab; /* OID of table owning sequence */
|
|
|
|
int owning_col; /* attr # of column owning sequence */
|
2002-05-11 00:36:27 +02:00
|
|
|
|
|
|
|
bool interesting; /* true if need to collect more data */
|
|
|
|
bool dump; /* true if we want to dump it */
|
|
|
|
|
|
|
|
/*
|
2002-09-04 22:31:48 +02:00
|
|
|
* 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).
|
2002-05-11 00:36:27 +02:00
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
int numatts; /* number of attributes */
|
|
|
|
char **attnames; /* the attribute names */
|
2002-05-11 00:36:27 +02:00
|
|
|
char **atttypnames; /* attribute type names */
|
|
|
|
int *atttypmod; /* type-specific type modifiers */
|
2002-07-31 19:19:54 +02:00
|
|
|
int *attstattarget; /* attribute statistics targets */
|
2002-08-19 21:33:36 +02:00
|
|
|
bool *attisdropped; /* true if attr is dropped; don't dump it */
|
|
|
|
bool *attisserial; /* true if attr is serial or bigserial */
|
2002-09-04 22:31:48 +02:00
|
|
|
|
2002-05-11 00:36:27 +02:00
|
|
|
/*
|
|
|
|
* Note: we need to store per-attribute notnull and default stuff for
|
|
|
|
* all interesting tables so that we can tell which constraints were
|
|
|
|
* inherited.
|
|
|
|
*/
|
|
|
|
bool *notnull; /* Not null constraints on attributes */
|
1997-10-02 15:57:07 +02:00
|
|
|
char **adef_expr; /* DEFAULT expressions */
|
2002-05-11 00:36:27 +02:00
|
|
|
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 */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stuff computed only for dumpable tables.
|
|
|
|
*/
|
|
|
|
int numParents; /* number of (immediate) parent tables */
|
|
|
|
int *parentIndexes; /* TableInfo indexes of immediate parents */
|
|
|
|
|
|
|
|
char *viewoid; /* OID of view - should be >= oid of table
|
|
|
|
* important because views may be
|
|
|
|
* constructed manually from rules, and
|
|
|
|
* rule may ref things created after the
|
|
|
|
* base table was created. */
|
1997-09-08 23:56:23 +02:00
|
|
|
} TableInfo;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
typedef struct _inhInfo
|
|
|
|
{
|
2002-05-11 00:36:27 +02:00
|
|
|
char *inhrelid; /* OID of a child table */
|
|
|
|
char *inhparent; /* OID of its parent */
|
1997-09-08 23:56:23 +02:00
|
|
|
} InhInfo;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/* global decls */
|
2001-08-22 22:23:24 +02:00
|
|
|
extern bool force_quotes; /* double-quotes for identifiers flag */
|
1997-09-08 04:41:22 +02:00
|
|
|
extern bool g_verbose; /* verbose flag */
|
2000-07-04 16:25:28 +02:00
|
|
|
extern Archive *g_fout; /* the script file */
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/* placeholders for comment starting and ending delimiters */
|
1997-09-08 04:41:22 +02:00
|
|
|
extern char g_comment_start[10];
|
|
|
|
extern char g_comment_end[10];
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
extern char g_opaque_type[10]; /* name for the opaque type */
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* common utility functions
|
2002-05-11 00:36:27 +02:00
|
|
|
*/
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2000-07-04 16:25:28 +02:00
|
|
|
extern TableInfo *dumpSchema(Archive *fout,
|
1997-09-07 07:04:48 +02:00
|
|
|
int *numTablesPtr,
|
2002-05-11 00:36:27 +02:00
|
|
|
const bool aclsSkip,
|
2000-07-04 16:25:28 +02:00
|
|
|
const bool schemaOnly,
|
|
|
|
const bool dataOnly);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
typedef enum _OidOptions
|
|
|
|
{
|
2001-10-28 07:26:15 +01:00
|
|
|
zeroAsOpaque = 1,
|
|
|
|
zeroAsAny = 2,
|
|
|
|
zeroAsStar = 4,
|
2002-05-11 00:36:27 +02:00
|
|
|
zeroAsNone = 8
|
2000-09-15 06:35:16 +02:00
|
|
|
} OidOptions;
|
|
|
|
|
2002-05-11 00:36:27 +02:00
|
|
|
extern int findTableByOid(TableInfo *tbinfo, int numTables, const char *oid);
|
1997-09-08 23:56:23 +02:00
|
|
|
extern char *findOprByOid(OprInfo *oprinfo, int numOprs, const char *oid);
|
2002-05-11 00:36:27 +02:00
|
|
|
extern int findFuncByOid(FuncInfo *finfo, int numFuncs, const char *oid);
|
2002-07-19 01:11:32 +02:00
|
|
|
extern int findTypeByOid(TypeInfo *tinfo, int numTypes, const char *oid);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
extern void check_conn_and_db(void);
|
2002-05-11 00:36:27 +02:00
|
|
|
extern void exit_nicely(void);
|
|
|
|
|
2000-01-16 04:54:58 +01:00
|
|
|
extern void parseNumericArray(const char *str, char **array, int arraysize);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* version specific routines
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
2002-05-11 00:36:27 +02:00
|
|
|
extern NamespaceInfo *getNamespaces(int *numNamespaces);
|
1997-09-07 07:04:48 +02:00
|
|
|
extern TypeInfo *getTypes(int *numTypes);
|
|
|
|
extern FuncInfo *getFuncs(int *numFuncs);
|
|
|
|
extern AggInfo *getAggregates(int *numAggregates);
|
|
|
|
extern OprInfo *getOperators(int *numOperators);
|
2002-07-30 23:56:04 +02:00
|
|
|
extern OpclassInfo *getOpclasses(int *numOpclasses);
|
2002-05-11 00:36:27 +02:00
|
|
|
extern TableInfo *getTables(int *numTables);
|
1997-09-07 07:04:48 +02:00
|
|
|
extern InhInfo *getInherits(int *numInherits);
|
2002-05-11 00:36:27 +02:00
|
|
|
|
1997-09-08 23:56:23 +02:00
|
|
|
extern void getTableAttrs(TableInfo *tbinfo, int numTables);
|
2000-07-04 16:25:28 +02:00
|
|
|
extern void dumpDBComment(Archive *outfile);
|
2002-05-11 00:36:27 +02:00
|
|
|
extern void dumpNamespaces(Archive *fout,
|
2002-09-04 22:31:48 +02:00
|
|
|
NamespaceInfo *nsinfo, int numNamespaces);
|
2000-07-04 16:25:28 +02:00
|
|
|
extern void dumpTypes(Archive *fout, FuncInfo *finfo, int numFuncs,
|
1997-09-08 23:56:23 +02:00
|
|
|
TypeInfo *tinfo, int numTypes);
|
2002-05-19 12:08:25 +02:00
|
|
|
extern void dumpProcLangs(Archive *fout, FuncInfo finfo[], int numFuncs);
|
|
|
|
extern void dumpFuncs(Archive *fout, FuncInfo finfo[], int numFuncs);
|
2002-07-19 01:11:32 +02:00
|
|
|
extern void dumpCasts(Archive *fout, FuncInfo *finfo, int numFuncs,
|
2002-09-04 22:31:48 +02:00
|
|
|
TypeInfo *tinfo, int numTypes);
|
2002-05-19 12:08:25 +02:00
|
|
|
extern void dumpAggs(Archive *fout, AggInfo agginfo[], int numAggregates);
|
2002-05-11 00:36:27 +02:00
|
|
|
extern void dumpOprs(Archive *fout, OprInfo *oprinfo, int numOperators);
|
2002-07-30 23:56:04 +02:00
|
|
|
extern void dumpOpclasses(Archive *fout,
|
2002-09-04 22:31:48 +02:00
|
|
|
OpclassInfo *opcinfo, int numOpclasses);
|
2002-05-19 12:08:25 +02:00
|
|
|
extern void dumpTables(Archive *fout, TableInfo tblinfo[], int numTables,
|
2002-09-04 22:31:48 +02:00
|
|
|
const bool aclsSkip,
|
|
|
|
const bool schemaOnly, const bool dataOnly);
|
2002-05-11 00:36:27 +02:00
|
|
|
extern void dumpIndexes(Archive *fout, TableInfo *tbinfo, int numTables);
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2002-07-06 22:12:30 +02:00
|
|
|
/* sprompt.h */
|
|
|
|
extern char *simple_prompt(const char *prompt, int maxlen, bool echo);
|
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* PG_DUMP_H */
|