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 @@
*
*
* 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
*
......@@ -16,6 +16,14 @@
* - Added single. quote to twin single quote expansion for 'insert' string
* 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);
*/
char *
findTypeByOid(TypeInfo *tinfo, int numTypes, const char *oid)
findTypeByOid(TypeInfo *tinfo, int numTypes, const char *oid, OidOptions opts)
{
int i;
if (strcmp(oid, "0") == 0)
return g_opaque_type;
if (strcmp(oid, "0") == 0) {
if ( (opts & zeroAsOpaque) != 0 ) {
return g_opaque_type;
} else if ( (opts & zeroAsAny) != 0 ) {
return "'any'";
}
}
for (i = 0; i < numTypes; i++)
{
if (strcmp(tinfo[i].oid, oid) == 0)
return tinfo[i].typname;
if (strcmp(tinfo[i].oid, oid) == 0) {
if ( (opts & useBaseTypeName) != 0 ) {
return fmtId(tinfo[i].typname, false);
} else {
return tinfo[i].typedefn;
}
}
}
/* should never get here */
......
......@@ -20,7 +20,10 @@
*
* 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;
#define K_VERS_MAJOR 1
#define K_VERS_MINOR 4
#define K_VERS_REV 11
#define K_VERS_REV 14
/* Data block types */
#define BLK_DATA 1
......@@ -124,6 +127,7 @@ typedef struct {
sqlparseState state;
char lastChar;
char quoteChar;
int braceDepth;
} sqlparseInfo;
typedef struct _archiveHandle {
......
......@@ -483,7 +483,7 @@ int ExecuteSqlCommandBuf(ArchiveHandle* AH, void *qryv, int bufLen)
case SQL_SCAN: /* Default state == 0, set in _allocAH */
if (qry[pos] == ';')
if (qry[pos] == ';' && AH->sqlparse.braceDepth == 0)
{
/* Send It & reset the buffer */
/* fprintf(stderr, " sending: '%s'\n\n", AH->sqlBuf->data); */
......@@ -507,7 +507,16 @@ int ExecuteSqlCommandBuf(ArchiveHandle* AH, void *qryv, int bufLen)
else if (qry[pos] == '*' && AH->sqlparse.lastChar == '/')
{
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];
}
......
This diff is collapsed.
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* 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
*
......@@ -17,6 +17,12 @@
* Modifications - 6/1/97 - igor@sba.miami.edu
* - Added extern's for the functions that clear allocated memory
* 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
char *typdefault;
char *typrelid;
char *usename;
char *typedefn;
int passedbyvalue;
int isArray;
} TypeInfo;
......@@ -80,6 +87,7 @@ typedef struct _tableInfo
char *oid;
char *relname;
char *relacl;
char *viewdef;
bool sequence;
int numatts; /* number of attributes */
int *inhAttrs; /* an array of flags, one for each
......@@ -87,6 +95,7 @@ typedef struct _tableInfo
* attribute is an inherited attribute */
char **attnames; /* the attribute names */
char **attoids; /* oids of the various attributes */
char **atttypedefns; /* formatted column type definitions */
char **typnames; /* fill out attributes */
bool *notnull; /* Not null constraints of an attribute */
char **adef_expr; /* DEFAULT expressions */
......@@ -197,7 +206,13 @@ extern void dumpSchemaIdx(Archive *fout,
TableInfo *tblinfo,
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 int findFuncByName(FuncInfo *finfo, int numFuncs, const char *name);
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