1 /*-------------------------------------------------------------------------
4 * header file for the pg_dump utility
6 * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
9 * $Id: pg_dump.h,v 1.78 2002/02/11 00:18:20 tgl Exp $
11 * Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
13 * - Fixed dumpTable output to output lengths for char and varchar types!
14 * - Added single. quote to twin single quote expansion for 'insert' string
17 * Modifications - 6/1/97 - igor@sba.miami.edu
18 * - Added extern's for the functions that clear allocated memory
21 * Modifications - 14-Sep-2000 - pjw@rhyme.com.au
22 * - Added typedefn fields to typeinfo and relinfo
23 * - Added enum for findTypeByOid to allow special handling of
26 *-------------------------------------------------------------------------
32 #include "pg_backup.h"
33 #include "pqexpbuffer.h"
35 /* The data structures used to store system catalog information */
37 typedef struct _typeInfo
61 typedef struct _funcInfo
68 char *argtypes[FUNC_MAX_ARGS];
70 int retset; /* 1 if the function returns a set, else 0 */
74 int iscachable; /* Attr */
75 int isstrict; /* Attr */
76 int dumped; /* 1 if already dumped */
79 typedef struct _trigInfo
88 typedef struct _tableInfo
94 char *viewoid; /* OID of view - should be >= oid of table
95 * important because views may be
96 * constructed manually from rules, and
97 * rule may ref things created after the
98 * base table was created. */
100 bool sequence; /* this is redundant with relkind... */
101 bool hasindex; /* does it have any indexes? */
102 bool hasoids; /* does it have OIDs? */
103 int numatts; /* number of attributes */
104 int *inhAttrs; /* an array of flags, one for each
105 * attribute if the value is 1, then this
106 * attribute is an inherited attribute */
107 int *inhAttrDef; /* Flags indicating if attrdef is
109 int *inhNotNull; /* Flags indicating if NOT NULL in
111 char **attnames; /* the attribute names */
112 char **atttypedefns; /* formatted column type definitions */
113 char **typnames; /* fill out attributes */
114 bool *notnull; /* Not null constraints of an attribute */
115 char **adef_expr; /* DEFAULT expressions */
116 int numParents; /* number of (immediate) parent
118 char **parentRels; /* names of parent relations, NULL if
120 char **out_attnames; /* the attribute names, in the order they
121 * would be in, when the table is created
122 * in the target query language. this is
123 * needed because the SQL tables will not
124 * have the same order of attributes as
125 * the POSTQUEL tables */
126 int *atttypmod; /* type-specific type modifier */
128 int ncheck; /* # of CHECK expressions */
129 char **check_expr; /* [CONSTRAINT name] CHECK expressions */
130 int ntrig; /* # of triggers */
131 TrigInfo *triggers; /* Triggers on the table */
132 char *pkIndexOid; /* Primary Key index OID */
133 char *primary_key_name; /* PRIMARY KEY name, if any */
136 typedef struct _inhInfo
142 typedef struct _indInfo
144 char *indexreloid; /* oid of the index itself */
145 char *indreloid; /* oid of the table the index is on */
146 char *indexrelname; /* name of the index itself */
147 char *indrelname; /* name of the indexed table */
148 char *indexdef; /* index definitional command */
149 char *indisprimary; /* is this a PK index? */
150 char *indkey[INDEX_MAX_KEYS]; /* attribute numbers of the key
154 typedef struct _aggInfo
164 int convertok; /* Flag to indicate of version convertsion
168 typedef struct _oprInfo
172 char *oprkind; /*----------
178 char *oprcode; /* operator function name */
179 char *oprleft; /* left operand type */
180 char *oprright; /* right operand type */
181 char *oprcom; /* oid of the commutator operator */
182 char *oprnegate; /* oid of the negator operator */
183 char *oprrest; /* name of the function to calculate
184 * operator restriction selectivity */
185 char *oprjoin; /* name of the function to calculate
186 * operator join selectivity */
187 char *oprcanhash; /* can we use hash join strategy ? */
188 char *oprlsortop; /* oid's of the left and right sort
195 extern bool force_quotes; /* double-quotes for identifiers flag */
196 extern bool g_verbose; /* verbose flag */
197 extern Oid g_last_builtin_oid; /* value of the last builtin oid */
198 extern Archive *g_fout; /* the script file */
200 /* placeholders for comment starting and ending delimiters */
201 extern char g_comment_start[10];
202 extern char g_comment_end[10];
204 extern char g_opaque_type[10]; /* name for the opaque type */
206 /* pg_dump is really two programs in one
207 one version works with postgres v4r2
208 and the other works with postgreSQL
209 the common routines are declared here
212 * common utility functions
215 extern TableInfo *dumpSchema(Archive *fout,
217 const char *tablename,
220 const bool schemaOnly,
221 const bool dataOnly);
222 extern void dumpSchemaIdx(Archive *fout,
223 const char *tablename,
227 typedef enum _OidOptions
233 useBaseTypeName = 1024
236 extern char *findTypeByOid(TypeInfo *tinfo, int numTypes, const char *oid, OidOptions opts);
237 extern char *findOprByOid(OprInfo *oprinfo, int numOprs, const char *oid);
238 extern int findFuncByName(FuncInfo *finfo, int numFuncs, const char *name);
239 extern int findTableByName(TableInfo *tbinfo, int numTables, const char *relname);
241 extern void check_conn_and_db(void);
242 extern void parseNumericArray(const char *str, char **array, int arraysize);
245 * version specific routines
247 extern TypeInfo *getTypes(int *numTypes);
248 extern FuncInfo *getFuncs(int *numFuncs);
249 extern AggInfo *getAggregates(int *numAggregates);
251 extern void clearAggInfo(AggInfo *, int);
252 extern void clearFuncInfo(FuncInfo *, int);
253 extern void clearInhInfo(InhInfo *, int);
254 extern void clearIndInfo(IndInfo *, int);
255 extern void clearOprInfo(OprInfo *, int);
256 extern void clearTypeInfo(TypeInfo *, int);
258 extern OprInfo *getOperators(int *numOperators);
259 extern TableInfo *getTables(int *numTables, FuncInfo *finfo, int numFuncs,
260 const char* tablename);
261 extern InhInfo *getInherits(int *numInherits);
262 extern void getTableAttrs(TableInfo *tbinfo, int numTables);
263 extern IndInfo *getIndexes(int *numIndexes);
264 extern void dumpDBComment(Archive *outfile);
265 extern void dumpTypes(Archive *fout, FuncInfo *finfo, int numFuncs,
266 TypeInfo *tinfo, int numTypes);
267 extern void dumpProcLangs(Archive *fout, FuncInfo *finfo, int numFuncs,
268 TypeInfo *tinfo, int numTypes);
269 extern void dumpFuncs(Archive *fout, FuncInfo *finfo, int numFuncs,
270 TypeInfo *tinfo, int numTypes);
271 extern void dumpAggs(Archive *fout, AggInfo *agginfo, int numAggregates,
272 TypeInfo *tinfo, int numTypes);
273 extern void dumpOprs(Archive *fout, OprInfo *agginfo, int numOperators,
274 TypeInfo *tinfo, int numTypes);
275 extern void dumpTables(Archive *fout, TableInfo *tbinfo, int numTables,
276 IndInfo *indinfo, int numIndexes,
277 InhInfo *inhinfo, int numInherits,
278 TypeInfo *tinfo, int numTypes, const char *tablename,
279 const bool acls, const bool oids,
280 const bool schemaOnly, const bool dataOnly);
281 extern void dumpIndexes(Archive *fout, IndInfo *indinfo, int numIndexes,
282 TableInfo *tbinfo, int numTables, const char *tablename);
283 extern void exit_nicely(void);
285 #endif /* PG_DUMP_H */