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
|
|
|
*
|
|
|
|
* Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
1997-09-08 04:41:22 +02:00
|
|
|
* $Id: pg_dump.h,v 1.21 1997/09/08 02:32:50 momjian 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
|
1996-07-09 08:22:35 +02:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
1997-05-07 04:59:59 +02:00
|
|
|
#include <catalog/pg_index.h>
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/* The *Info data structures run-time C 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;
|
|
|
|
int passedbyvalue;
|
|
|
|
int isArray;
|
|
|
|
} 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;
|
|
|
|
int lang; /* 1 if C, else SQL */
|
|
|
|
int nargs;
|
|
|
|
char *argtypes[8]; /* should be derived from obj/fmgr.h
|
1997-09-07 07:04:48 +02:00
|
|
|
* instead of hardwired */
|
1997-09-08 04:41:22 +02:00
|
|
|
char *prorettype;
|
|
|
|
int retset; /* 1 if the function returns a set, 0
|
1997-09-07 07:04:48 +02:00
|
|
|
* otherwise */
|
1997-09-08 04:41:22 +02:00
|
|
|
char *prosrc;
|
|
|
|
char *probin;
|
|
|
|
char *usename;
|
|
|
|
int dumped; /* 1 if already dumped */
|
|
|
|
} FuncInfo;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
typedef struct _tableInfo
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
char *oid;
|
|
|
|
char *relname;
|
|
|
|
char *relarch;
|
|
|
|
char *relacl;
|
|
|
|
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 */
|
1997-09-08 04:41:22 +02:00
|
|
|
char **attnames; /* the attribute names */
|
|
|
|
char **typnames; /* fill out attributes */
|
|
|
|
bool *notnull; /* Not null constraints of an attribute */
|
|
|
|
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 */
|
|
|
|
int *attlen; /* attribute lengths */
|
|
|
|
char *usename;
|
|
|
|
|
|
|
|
} TableInfo;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
typedef struct _inhInfo
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
char *inhrel;
|
|
|
|
char *inhparent;
|
|
|
|
} InhInfo;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
typedef struct _indInfo
|
|
|
|
{
|
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? */
|
|
|
|
} IndInfo;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
typedef struct _aggInfo
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
char *oid;
|
|
|
|
char *aggname;
|
|
|
|
char *aggtransfn1;
|
|
|
|
char *aggtransfn2;
|
|
|
|
char *aggfinalfn;
|
|
|
|
char *aggtranstype1;
|
|
|
|
char *aggbasetype;
|
|
|
|
char *aggtranstype2;
|
|
|
|
char *agginitval1;
|
|
|
|
char *agginitval2;
|
|
|
|
char *usename;
|
|
|
|
} AggInfo;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
typedef struct _oprInfo
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
char *oid;
|
|
|
|
char *oprname;
|
|
|
|
char *oprkind; /* "b" = binary, "l" = left unary, "r" =
|
1997-09-07 07:04:48 +02:00
|
|
|
* 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;
|
|
|
|
} OprInfo;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* global decls */
|
1997-09-08 04:41:22 +02:00
|
|
|
extern bool g_verbose; /* verbose flag */
|
|
|
|
extern int g_last_builtin_oid; /* value of the last builtin oid */
|
|
|
|
extern FILE *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
|
|
|
|
and the other works with postgres95
|
|
|
|
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
|
|
|
*/
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
extern TableInfo *
|
|
|
|
dumpSchema(FILE * fout,
|
|
|
|
int *numTablesPtr,
|
|
|
|
const char *tablename,
|
|
|
|
const bool acls);
|
|
|
|
extern void
|
|
|
|
dumpSchemaIdx(FILE * fout,
|
|
|
|
int *numTablesPtr,
|
1997-04-12 11:24:23 +02:00
|
|
|
const char *tablename,
|
1997-09-07 07:04:48 +02:00
|
|
|
TableInfo * tblinfo,
|
1997-04-12 11:24:23 +02:00
|
|
|
int numTables);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
extern char *findTypeByOid(TypeInfo * tinfo, int numTypes, const char *oid);
|
|
|
|
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);
|
|
|
|
extern void parseArgTypes(char **argtypes, const char *str);
|
|
|
|
extern int isArchiveName(const char *);
|
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);
|
|
|
|
extern TableInfo *getTables(int *numTables);
|
|
|
|
extern InhInfo *getInherits(int *numInherits);
|
1997-09-08 04:41:22 +02:00
|
|
|
extern void getTableAttrs(TableInfo * tbinfo, int numTables);
|
1997-09-07 07:04:48 +02:00
|
|
|
extern IndInfo *getIndices(int *numIndices);
|
|
|
|
extern void
|
|
|
|
dumpTypes(FILE * fout, FuncInfo * finfo, int numFuncs,
|
|
|
|
TypeInfo * tinfo, int numTypes);
|
|
|
|
extern void
|
|
|
|
dumpFuncs(FILE * fout, FuncInfo * finfo, int numFuncs,
|
|
|
|
TypeInfo * tinfo, int numTypes);
|
|
|
|
extern void
|
|
|
|
dumpAggs(FILE * fout, AggInfo * agginfo, int numAggregates,
|
|
|
|
TypeInfo * tinfo, int numTypes);
|
|
|
|
extern void
|
|
|
|
dumpOprs(FILE * fout, OprInfo * agginfo, int numOperators,
|
|
|
|
TypeInfo * tinfo, int numTypes);
|
|
|
|
extern void
|
|
|
|
dumpTables(FILE * fout, TableInfo * tbinfo, int numTables,
|
|
|
|
InhInfo * inhinfo, int numInherits,
|
|
|
|
TypeInfo * tinfo, int numTypes, const char *tablename,
|
|
|
|
const bool acls);
|
|
|
|
extern void
|
|
|
|
dumpIndices(FILE * fout, IndInfo * indinfo, int numIndices,
|
|
|
|
TableInfo * tbinfo, int numTables, const char *tablename);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/* largest query string size */
|
|
|
|
#define MAXQUERYLEN 5000
|
|
|
|
|
|
|
|
/* these voodoo constants are from the backend */
|
1997-09-07 07:04:48 +02:00
|
|
|
#define C_PROLANG_OID 13
|