1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* pg_dump.h
|
1997-09-07 07:04:48 +02:00
|
|
|
* header file for the pg_dump utility
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2001-01-24 20:43:33 +01:00
|
|
|
* Portions Copyright (c) 1996-2001, 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
|
|
|
*
|
2001-04-14 15:11:03 +02:00
|
|
|
* $Id: pg_dump.h,v 1.62 2001/04/14 13:11:03 pjw Exp $
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1996-07-22 10:37:00 +02:00
|
|
|
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
|
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* - Fixed dumpTable output to output lengths for char and varchar types!
|
|
|
|
* - Added single. quote to twin single quote expansion for 'insert' string
|
|
|
|
* mode.
|
1997-06-02 04:52:06 +02:00
|
|
|
*
|
|
|
|
* Modifications - 6/1/97 - igor@sba.miami.edu
|
|
|
|
* - Added extern's for the functions that clear allocated memory
|
1997-09-07 07:04:48 +02:00
|
|
|
* in pg_dump.c
|
2000-09-15 06:35:16 +02:00
|
|
|
*
|
|
|
|
* Modifications - 14-Sep-2000 - pjw@rhyme.com.au
|
2001-03-22 05:01:46 +01:00
|
|
|
* - Added typedefn fields to typeinfo and relinfo
|
|
|
|
* - Added enum for findTypeByOid to allow special handling of
|
2000-09-15 06:35:16 +02:00
|
|
|
* '0' OID.
|
|
|
|
*
|
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"
|
2001-02-10 03:31:31 +01:00
|
|
|
#include "pqexpbuffer.h"
|
1999-10-23 05:13:33 +02:00
|
|
|
|
2000-01-16 04:54:58 +01:00
|
|
|
/* The data structures used to store system catalog information */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
typedef struct _typeInfo
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
char *oid;
|
|
|
|
char *typowner;
|
|
|
|
char *typname;
|
|
|
|
char *typlen;
|
|
|
|
char *typprtlen;
|
|
|
|
char *typinput;
|
|
|
|
char *typoutput;
|
|
|
|
char *typreceive;
|
|
|
|
char *typsend;
|
|
|
|
char *typelem;
|
|
|
|
char *typdelim;
|
|
|
|
char *typdefault;
|
|
|
|
char *typrelid;
|
|
|
|
char *usename;
|
2000-09-15 06:35:16 +02:00
|
|
|
char *typedefn;
|
1997-09-08 04:41:22 +02:00
|
|
|
int passedbyvalue;
|
|
|
|
int isArray;
|
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;
|
|
|
|
char *proowner;
|
1997-09-24 17:36:36 +02:00
|
|
|
int lang;
|
1997-09-08 04:41:22 +02:00
|
|
|
int nargs;
|
2000-01-16 04:54:58 +01:00
|
|
|
char *argtypes[FUNC_MAX_ARGS];
|
1997-09-08 04:41:22 +02:00
|
|
|
char *prorettype;
|
2000-01-16 04:54:58 +01:00
|
|
|
int retset; /* 1 if the function returns a set, else 0 */
|
1997-09-08 04:41:22 +02:00
|
|
|
char *prosrc;
|
|
|
|
char *probin;
|
|
|
|
char *usename;
|
2000-08-07 14:32:54 +02:00
|
|
|
int iscachable; /* Attr */
|
2000-10-10 15:55:28 +02:00
|
|
|
int isstrict; /* Attr */
|
1997-09-08 04:41:22 +02:00
|
|
|
int dumped; /* 1 if already dumped */
|
1997-09-08 23:56:23 +02:00
|
|
|
} FuncInfo;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-07-04 16:25:28 +02:00
|
|
|
typedef struct _trigInfo
|
|
|
|
{
|
|
|
|
char *oid;
|
|
|
|
char *tgname;
|
|
|
|
char *tgsrc;
|
|
|
|
char *tgdel;
|
|
|
|
char *tgcomment;
|
|
|
|
} TrigInfo;
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct _tableInfo
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
char *oid;
|
|
|
|
char *relname;
|
|
|
|
char *relacl;
|
2000-09-15 06:35:16 +02:00
|
|
|
char *viewdef;
|
2001-04-14 15:11:03 +02:00
|
|
|
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 04:41:22 +02:00
|
|
|
bool sequence;
|
|
|
|
int numatts; /* number of attributes */
|
|
|
|
int *inhAttrs; /* an array of flags, one for each
|
1997-09-07 07:04:48 +02:00
|
|
|
* attribute if the value is 1, then this
|
|
|
|
* attribute is an inherited attribute */
|
2001-04-03 10:52:59 +02:00
|
|
|
int *inhAttrDef; /* Flags indicating if attrdef is inherited */
|
|
|
|
int *inhNotNull; /* Flags indicating if NOT NULL in inherited */
|
1997-09-08 04:41:22 +02:00
|
|
|
char **attnames; /* the attribute names */
|
2000-04-12 19:17:23 +02:00
|
|
|
char **attoids; /* oids of the various attributes */
|
2000-09-15 06:35:16 +02:00
|
|
|
char **atttypedefns; /* formatted column type definitions */
|
1997-09-08 04:41:22 +02:00
|
|
|
char **typnames; /* fill out attributes */
|
|
|
|
bool *notnull; /* Not null constraints of an attribute */
|
1997-10-02 15:57:07 +02:00
|
|
|
char **adef_expr; /* DEFAULT expressions */
|
1997-09-08 04:41:22 +02:00
|
|
|
int numParents; /* number of (immediate) parent
|
1997-09-07 07:04:48 +02:00
|
|
|
* supertables */
|
1997-09-08 04:41:22 +02:00
|
|
|
char **parentRels; /* names of parent relations, NULL if
|
1997-09-07 07:04:48 +02:00
|
|
|
* numParents == 0 */
|
1997-09-08 04:41:22 +02:00
|
|
|
char **out_attnames; /* the attribute names, in the order they
|
|
|
|
* would be in, when the table is created
|
|
|
|
* in the target query language. this is
|
|
|
|
* needed because the SQL tables will not
|
|
|
|
* have the same order of attributes as
|
|
|
|
* the POSTQUEL tables */
|
1998-01-17 00:21:07 +01:00
|
|
|
int *atttypmod; /* type-specific type modifier */
|
1997-09-08 04:41:22 +02:00
|
|
|
char *usename;
|
1997-10-02 15:57:07 +02:00
|
|
|
int ncheck; /* # of CHECK expressions */
|
|
|
|
char **check_expr; /* [CONSTRAINT name] CHECK expressions */
|
|
|
|
int ntrig; /* # of triggers */
|
2001-03-22 05:01:46 +01:00
|
|
|
TrigInfo *triggers; /* Triggers on the table */
|
2001-01-12 16:41:29 +01:00
|
|
|
char *pkIndexOid; /* Primary Key index OID */
|
2001-03-22 05:01:46 +01:00
|
|
|
char *primary_key_name; /* PRIMARY KEY name, if any */
|
1997-09-08 23:56:23 +02:00
|
|
|
} TableInfo;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
typedef struct _inhInfo
|
|
|
|
{
|
1999-11-22 18:56:41 +01:00
|
|
|
char *inhrelid;
|
1997-09-08 04:41:22 +02:00
|
|
|
char *inhparent;
|
1997-09-08 23:56:23 +02:00
|
|
|
} InhInfo;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
typedef struct _indInfo
|
|
|
|
{
|
2001-01-12 16:41:29 +01:00
|
|
|
char *oid; /* Oid of the pg_index entry */
|
2000-04-12 19:17:23 +02:00
|
|
|
char *indoid; /* oid of the pg_class entry for the index */
|
1997-09-08 04:41:22 +02:00
|
|
|
char *indexrelname; /* name of the secondary index class */
|
|
|
|
char *indrelname; /* name of the indexed heap class */
|
|
|
|
char *indamname; /* name of the access method (e.g. btree,
|
1997-09-07 07:04:48 +02:00
|
|
|
* rtree, etc.) */
|
1997-09-08 04:41:22 +02:00
|
|
|
char *indproc; /* oid of the function to compute the
|
1997-09-07 07:04:48 +02:00
|
|
|
* index, 0 if none */
|
1997-09-08 04:41:22 +02:00
|
|
|
char *indkey[INDEX_MAX_KEYS]; /* attribute numbers of the key
|
|
|
|
* attributes */
|
|
|
|
char *indclass[INDEX_MAX_KEYS]; /* opclass of the keys */
|
|
|
|
char *indisunique; /* is this index unique? */
|
2001-01-12 16:41:29 +01:00
|
|
|
char *indisprimary; /* is this a PK index? */
|
1997-09-08 23:56:23 +02:00
|
|
|
} IndInfo;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
typedef struct _aggInfo
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
char *oid;
|
|
|
|
char *aggname;
|
2000-07-17 05:05:41 +02:00
|
|
|
char *aggtransfn;
|
1997-09-08 04:41:22 +02:00
|
|
|
char *aggfinalfn;
|
2000-07-17 05:05:41 +02:00
|
|
|
char *aggtranstype;
|
1997-09-08 04:41:22 +02:00
|
|
|
char *aggbasetype;
|
2000-07-17 05:05:41 +02:00
|
|
|
char *agginitval;
|
1997-09-08 04:41:22 +02:00
|
|
|
char *usename;
|
1997-09-08 22:59:27 +02:00
|
|
|
} AggInfo;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
typedef struct _oprInfo
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
char *oid;
|
|
|
|
char *oprname;
|
2001-03-23 05:49:58 +01:00
|
|
|
char *oprkind; /*----------
|
|
|
|
* b = binary,
|
|
|
|
* l = left unary
|
|
|
|
* r = right unary
|
|
|
|
*----------
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
char *oprcode; /* operator function name */
|
|
|
|
char *oprleft; /* left operand type */
|
|
|
|
char *oprright; /* right operand type */
|
|
|
|
char *oprcom; /* oid of the commutator operator */
|
|
|
|
char *oprnegate; /* oid of the negator operator */
|
|
|
|
char *oprrest; /* name of the function to calculate
|
1997-09-07 07:04:48 +02:00
|
|
|
* operator restriction selectivity */
|
1997-09-08 04:41:22 +02:00
|
|
|
char *oprjoin; /* name of the function to calculate
|
1997-09-07 07:04:48 +02:00
|
|
|
* operator join selectivity */
|
1997-09-08 04:41:22 +02:00
|
|
|
char *oprcanhash; /* can we use hash join strategy ? */
|
|
|
|
char *oprlsortop; /* oid's of the left and right sort
|
1997-09-07 07:04:48 +02:00
|
|
|
* operators */
|
1997-09-08 04:41:22 +02:00
|
|
|
char *oprrsortop;
|
|
|
|
char *usename;
|
1997-09-08 23:56:23 +02:00
|
|
|
} OprInfo;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/* global decls */
|
1998-10-02 18:43:41 +02:00
|
|
|
extern bool g_force_quotes; /* double-quotes for identifiers flag */
|
1997-09-08 04:41:22 +02:00
|
|
|
extern bool g_verbose; /* verbose flag */
|
2000-11-14 19:37:49 +01:00
|
|
|
extern Oid g_last_builtin_oid; /* value of the last builtin oid */
|
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
|
|
|
|
|
|
|
/* pg_dump is really two programs in one
|
1997-09-07 07:04:48 +02:00
|
|
|
one version works with postgres v4r2
|
1998-03-14 22:58:09 +01:00
|
|
|
and the other works with postgreSQL
|
1997-09-07 07:04:48 +02:00
|
|
|
the common routines are declared here
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* common utility functions
|
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,
|
|
|
|
const char *tablename,
|
2000-07-04 16:25:28 +02:00
|
|
|
const bool acls,
|
|
|
|
const bool oids,
|
|
|
|
const bool schemaOnly,
|
|
|
|
const bool dataOnly);
|
|
|
|
extern void dumpSchemaIdx(Archive *fout,
|
1997-04-12 11:24:23 +02:00
|
|
|
const char *tablename,
|
1997-09-08 23:56:23 +02:00
|
|
|
TableInfo *tblinfo,
|
1997-04-12 11:24:23 +02:00
|
|
|
int numTables);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
typedef enum _OidOptions
|
|
|
|
{
|
2000-09-15 06:35:16 +02:00
|
|
|
zeroAsOpaque = 1,
|
|
|
|
zeroAsAny = 2,
|
2001-03-22 05:01:46 +01:00
|
|
|
useBaseTypeName = 1024
|
2000-09-15 06:35:16 +02:00
|
|
|
} OidOptions;
|
|
|
|
|
|
|
|
extern char *findTypeByOid(TypeInfo *tinfo, int numTypes, const char *oid, OidOptions opts);
|
1997-09-08 23:56:23 +02:00
|
|
|
extern char *findOprByOid(OprInfo *oprinfo, int numOprs, const char *oid);
|
|
|
|
extern int findFuncByName(FuncInfo *finfo, int numFuncs, const char *name);
|
|
|
|
extern int findTableByName(TableInfo *tbinfo, int numTables, const char *relname);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
extern void check_conn_and_db(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
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
extern TypeInfo *getTypes(int *numTypes);
|
|
|
|
extern FuncInfo *getFuncs(int *numFuncs);
|
|
|
|
extern AggInfo *getAggregates(int *numAggregates);
|
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
extern void clearAggInfo(AggInfo *, int);
|
|
|
|
extern void clearFuncInfo(FuncInfo *, int);
|
|
|
|
extern void clearInhInfo(InhInfo *, int);
|
|
|
|
extern void clearIndInfo(IndInfo *, int);
|
|
|
|
extern void clearOprInfo(OprInfo *, int);
|
|
|
|
extern void clearTypeInfo(TypeInfo *, int);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
extern OprInfo *getOperators(int *numOperators);
|
1997-10-02 15:57:07 +02:00
|
|
|
extern TableInfo *getTables(int *numTables, FuncInfo *finfo, int numFuncs);
|
1997-09-07 07:04:48 +02:00
|
|
|
extern InhInfo *getInherits(int *numInherits);
|
1997-09-08 23:56:23 +02:00
|
|
|
extern void getTableAttrs(TableInfo *tbinfo, int numTables);
|
1997-09-07 07:04:48 +02:00
|
|
|
extern IndInfo *getIndices(int *numIndices);
|
2000-07-04 16:25:28 +02:00
|
|
|
extern void dumpDBComment(Archive *outfile);
|
|
|
|
extern void dumpTypes(Archive *fout, FuncInfo *finfo, int numFuncs,
|
1997-09-08 23:56:23 +02:00
|
|
|
TypeInfo *tinfo, int numTypes);
|
2000-07-04 16:25:28 +02:00
|
|
|
extern void dumpProcLangs(Archive *fout, FuncInfo *finfo, int numFuncs,
|
1999-05-25 18:15:34 +02:00
|
|
|
TypeInfo *tinfo, int numTypes);
|
2000-07-04 16:25:28 +02:00
|
|
|
extern void dumpFuncs(Archive *fout, FuncInfo *finfo, int numFuncs,
|
1997-09-08 23:56:23 +02:00
|
|
|
TypeInfo *tinfo, int numTypes);
|
2000-07-04 16:25:28 +02:00
|
|
|
extern void dumpAggs(Archive *fout, AggInfo *agginfo, int numAggregates,
|
1997-09-08 23:56:23 +02:00
|
|
|
TypeInfo *tinfo, int numTypes);
|
2000-07-04 16:25:28 +02:00
|
|
|
extern void dumpOprs(Archive *fout, OprInfo *agginfo, int numOperators,
|
1997-09-08 23:56:23 +02:00
|
|
|
TypeInfo *tinfo, int numTypes);
|
2000-07-04 16:25:28 +02:00
|
|
|
extern void dumpTables(Archive *fout, TableInfo *tbinfo, int numTables,
|
2001-01-12 16:41:29 +01:00
|
|
|
IndInfo *indinfo, int numIndices,
|
1997-09-08 23:56:23 +02:00
|
|
|
InhInfo *inhinfo, int numInherits,
|
|
|
|
TypeInfo *tinfo, int numTypes, const char *tablename,
|
2000-07-04 16:25:28 +02:00
|
|
|
const bool acls, const bool oids,
|
|
|
|
const bool schemaOnly, const bool dataOnly);
|
|
|
|
extern void dumpIndices(Archive *fout, IndInfo *indinfo, int numIndices,
|
1997-09-08 23:56:23 +02:00
|
|
|
TableInfo *tbinfo, int numTables, const char *tablename);
|
1999-05-26 23:51:13 +02:00
|
|
|
extern const char *fmtId(const char *identifier, bool force_quotes);
|
1999-10-23 05:13:33 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
#endif /* PG_DUMP_H */
|