Commit c74257e9 authored by Philip Warner's avatar Philip Warner

- Support for relkind = RELKIND_VIEW.

- Use symbols for tests on relkind (ie. use RELKIND_VIEW, not 'v')
- Fix bug in support for -b option (== --blobs).
- Dump views as views (using 'create view').
- Remove 'isViewRule' since we check the relkind when getting tables.
- Now uses temp table 'pgdump_oid' rather than 'pg_dump_oid' (errors otherwise).
- Added extra param for specifying handling of OID=0 and which typename to output.
- Fixed bug in SQL scanner when SQL contained braces. (in rules)
- Use format_type function wherever possible
parent 6d9299e1
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.45 2000/08/06 17:50:48 thomas Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.46 2000/09/15 04:35:16 pjw Exp $
* *
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2 * Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
* *
...@@ -16,6 +16,14 @@ ...@@ -16,6 +16,14 @@
* - Added single. quote to twin single quote expansion for 'insert' string * - Added single. quote to twin single quote expansion for 'insert' string
* mode. * mode.
* *
* Modifications 14-Sep-2000 - pjw@rhyme.com.au
* - Added enum for findTypeByOid to specify how to handle OID and which
* string to return - formatted type, or base type. If the base type
* is returned then fmtId is called on the string.
*
* BEWARE: Since fmtId uses a static buffer, using 'useBaseTypeName' on more
* than one call in a line will cause problems.
*
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -50,17 +58,32 @@ static int strInArray(const char *pattern, char **arr, int arr_size); ...@@ -50,17 +58,32 @@ static int strInArray(const char *pattern, char **arr, int arr_size);
*/ */
char * char *
findTypeByOid(TypeInfo *tinfo, int numTypes, const char *oid) findTypeByOid(TypeInfo *tinfo, int numTypes, const char *oid, OidOptions opts)
{ {
int i; int i;
if (strcmp(oid, "0") == 0) if (strcmp(oid, "0") == 0) {
return g_opaque_type;
if ( (opts & zeroAsOpaque) != 0 ) {
return g_opaque_type;
} else if ( (opts & zeroAsAny) != 0 ) {
return "'any'";
}
}
for (i = 0; i < numTypes; i++) for (i = 0; i < numTypes; i++)
{ {
if (strcmp(tinfo[i].oid, oid) == 0) if (strcmp(tinfo[i].oid, oid) == 0) {
return tinfo[i].typname; if ( (opts & useBaseTypeName) != 0 ) {
return fmtId(tinfo[i].typname, false);
} else {
return tinfo[i].typedefn;
}
}
} }
/* should never get here */ /* should never get here */
......
...@@ -20,7 +20,10 @@ ...@@ -20,7 +20,10 @@
* *
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au * Modifications - 28-Jun-2000 - pjw@rhyme.com.au
* *
* Initial version. * Initial version.
*
* Modifications - 15-Sep-2000 - pjw@rhyme.com.au
* - Added braceDepth to sqlparseInfo to handle braces in rule definitions.
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -59,7 +62,7 @@ typedef z_stream *z_streamp; ...@@ -59,7 +62,7 @@ typedef z_stream *z_streamp;
#define K_VERS_MAJOR 1 #define K_VERS_MAJOR 1
#define K_VERS_MINOR 4 #define K_VERS_MINOR 4
#define K_VERS_REV 11 #define K_VERS_REV 14
/* Data block types */ /* Data block types */
#define BLK_DATA 1 #define BLK_DATA 1
...@@ -124,6 +127,7 @@ typedef struct { ...@@ -124,6 +127,7 @@ typedef struct {
sqlparseState state; sqlparseState state;
char lastChar; char lastChar;
char quoteChar; char quoteChar;
int braceDepth;
} sqlparseInfo; } sqlparseInfo;
typedef struct _archiveHandle { typedef struct _archiveHandle {
......
...@@ -483,7 +483,7 @@ int ExecuteSqlCommandBuf(ArchiveHandle* AH, void *qryv, int bufLen) ...@@ -483,7 +483,7 @@ int ExecuteSqlCommandBuf(ArchiveHandle* AH, void *qryv, int bufLen)
case SQL_SCAN: /* Default state == 0, set in _allocAH */ case SQL_SCAN: /* Default state == 0, set in _allocAH */
if (qry[pos] == ';') if (qry[pos] == ';' && AH->sqlparse.braceDepth == 0)
{ {
/* Send It & reset the buffer */ /* Send It & reset the buffer */
/* fprintf(stderr, " sending: '%s'\n\n", AH->sqlBuf->data); */ /* fprintf(stderr, " sending: '%s'\n\n", AH->sqlBuf->data); */
...@@ -507,7 +507,16 @@ int ExecuteSqlCommandBuf(ArchiveHandle* AH, void *qryv, int bufLen) ...@@ -507,7 +507,16 @@ int ExecuteSqlCommandBuf(ArchiveHandle* AH, void *qryv, int bufLen)
else if (qry[pos] == '*' && AH->sqlparse.lastChar == '/') else if (qry[pos] == '*' && AH->sqlparse.lastChar == '/')
{ {
AH->sqlparse.state = SQL_IN_EXT_COMMENT; AH->sqlparse.state = SQL_IN_EXT_COMMENT;
}
else if ( qry[pos] == '(' )
{
AH->sqlparse.braceDepth++;
} }
else if (qry[pos] == ')')
{
AH->sqlparse.braceDepth--;
}
AH->sqlparse.lastChar = qry[pos]; AH->sqlparse.lastChar = qry[pos];
} }
......
This diff is collapsed.
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_dump.h,v 1.51 2000/08/07 12:32:54 pjw Exp $ * $Id: pg_dump.h,v 1.52 2000/09/15 04:35:16 pjw Exp $
* *
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2 * Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
* *
...@@ -17,6 +17,12 @@ ...@@ -17,6 +17,12 @@
* Modifications - 6/1/97 - igor@sba.miami.edu * Modifications - 6/1/97 - igor@sba.miami.edu
* - Added extern's for the functions that clear allocated memory * - Added extern's for the functions that clear allocated memory
* in pg_dump.c * in pg_dump.c
*
* Modifications - 14-Sep-2000 - pjw@rhyme.com.au
* - Added typedefn fields to typeinfo and relinfo
* - Added enum for findTypeByOid to allow special handling of
* '0' OID.
*
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -45,6 +51,7 @@ typedef struct _typeInfo ...@@ -45,6 +51,7 @@ typedef struct _typeInfo
char *typdefault; char *typdefault;
char *typrelid; char *typrelid;
char *usename; char *usename;
char *typedefn;
int passedbyvalue; int passedbyvalue;
int isArray; int isArray;
} TypeInfo; } TypeInfo;
...@@ -80,6 +87,7 @@ typedef struct _tableInfo ...@@ -80,6 +87,7 @@ typedef struct _tableInfo
char *oid; char *oid;
char *relname; char *relname;
char *relacl; char *relacl;
char *viewdef;
bool sequence; bool sequence;
int numatts; /* number of attributes */ int numatts; /* number of attributes */
int *inhAttrs; /* an array of flags, one for each int *inhAttrs; /* an array of flags, one for each
...@@ -87,6 +95,7 @@ typedef struct _tableInfo ...@@ -87,6 +95,7 @@ typedef struct _tableInfo
* attribute is an inherited attribute */ * attribute is an inherited attribute */
char **attnames; /* the attribute names */ char **attnames; /* the attribute names */
char **attoids; /* oids of the various attributes */ char **attoids; /* oids of the various attributes */
char **atttypedefns; /* formatted column type definitions */
char **typnames; /* fill out attributes */ char **typnames; /* fill out attributes */
bool *notnull; /* Not null constraints of an attribute */ bool *notnull; /* Not null constraints of an attribute */
char **adef_expr; /* DEFAULT expressions */ char **adef_expr; /* DEFAULT expressions */
...@@ -197,7 +206,13 @@ extern void dumpSchemaIdx(Archive *fout, ...@@ -197,7 +206,13 @@ extern void dumpSchemaIdx(Archive *fout,
TableInfo *tblinfo, TableInfo *tblinfo,
int numTables); int numTables);
extern char *findTypeByOid(TypeInfo *tinfo, int numTypes, const char *oid); typedef enum _OidOptions {
zeroAsOpaque = 1,
zeroAsAny = 2,
useBaseTypeName = 1024
} OidOptions;
extern char *findTypeByOid(TypeInfo *tinfo, int numTypes, const char *oid, OidOptions opts);
extern char *findOprByOid(OprInfo *oprinfo, int numOprs, 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 findFuncByName(FuncInfo *finfo, int numFuncs, const char *name);
extern int findTableByName(TableInfo *tbinfo, int numTables, const char *relname); extern int findTableByName(TableInfo *tbinfo, int numTables, const char *relname);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment