Commit 8dc42a3a authored by Philip Warner's avatar Philip Warner

- Fixed CONSTRAINT TRIGGER dump to record tgconstrelid properly

- pgsql v7.0 compatbility
parent 38b0f2fb
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.10 2001/04/01 05:42:50 pjw Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.11 2001/04/25 07:03:19 pjw Exp $
* *
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au * Modifications - 28-Jun-2000 - pjw@rhyme.com.au
* *
...@@ -50,6 +50,9 @@ ...@@ -50,6 +50,9 @@
#define atooid(x) ((Oid) strtoul((x), NULL, 10)) #define atooid(x) ((Oid) strtoul((x), NULL, 10))
#define oidcmp(x,y) ( ((x) < (y) ? -1 : ((x) > (y)) ? 1 : 0) ) #define oidcmp(x,y) ( ((x) < (y) ? -1 : ((x) > (y)) ? 1 : 0) )
#define oideq(x,y) ( (x) == (y) ) #define oideq(x,y) ( (x) == (y) )
#define oidle(x,y) ( (x) <= (y) )
#define oidge(x,y) ( (x) >= (y) )
#define oidzero(x) ( (x) == 0 )
typedef enum _archiveFormat typedef enum _archiveFormat
{ {
...@@ -67,6 +70,9 @@ typedef enum _archiveFormat ...@@ -67,6 +70,9 @@ typedef enum _archiveFormat
typedef struct _Archive typedef struct _Archive
{ {
int verbose; int verbose;
int remoteVersion;
int minRemoteVersion;
int maxRemoteVersion;
/* The rest is private */ /* The rest is private */
} Archive; } Archive;
...@@ -115,6 +121,7 @@ typedef struct _restoreOptions ...@@ -115,6 +121,7 @@ typedef struct _restoreOptions
int limitToList; int limitToList;
int compression; int compression;
int suppressDumpWarnings; /* Suppress output of WARNING entries to stderr */
} RestoreOptions; } RestoreOptions;
/* /*
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.24 2001/04/14 13:11:03 pjw Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.25 2001/04/25 07:03:19 pjw Exp $
* *
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au * Modifications - 28-Jun-2000 - pjw@rhyme.com.au
* *
...@@ -169,6 +169,10 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) ...@@ -169,6 +169,10 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
if (AH->version < K_VERS_1_3) if (AH->version < K_VERS_1_3)
die_horribly(AH, "Direct database connections are not supported in pre-1.3 archives"); die_horribly(AH, "Direct database connections are not supported in pre-1.3 archives");
/* XXX Should get this from the archive */
AHX->minRemoteVersion = 070100;
AHX->maxRemoteVersion = 999999;
ConnectDatabase(AHX, ropt->dbname, ropt->pghost, ropt->pgport, ConnectDatabase(AHX, ropt->dbname, ropt->pghost, ropt->pgport,
ropt->requirePassword, ropt->ignoreVersion); ropt->requirePassword, ropt->ignoreVersion);
...@@ -260,6 +264,18 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) ...@@ -260,6 +264,18 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
/* Work out what, if anything, we want from this entry */ /* Work out what, if anything, we want from this entry */
reqs = _tocEntryRequired(te, ropt); reqs = _tocEntryRequired(te, ropt);
/* Dump any relevant dump warnings to stderr */
if (!ropt->suppressDumpWarnings && strcmp(te->desc, "WARNING") == 0)
{
if (!ropt->dataOnly && te->defn != NULL && strlen(te->defn) != 0)
{
fprintf(stderr, "%s: Warning from original dump file:\n%s\n", progname, te->defn);
} else if (te->copyStmt != NULL && strlen(te->copyStmt) != 0)
{
fprintf(stderr, "%s: Warning from original dump file:\n%s\n", progname, te->copyStmt);
}
}
if ((reqs & 1) != 0) /* We want the schema */ if ((reqs & 1) != 0) /* We want the schema */
{ {
/* Reconnect if necessary */ /* Reconnect if necessary */
...@@ -405,6 +421,7 @@ NewRestoreOptions(void) ...@@ -405,6 +421,7 @@ NewRestoreOptions(void)
opts = (RestoreOptions *) calloc(1, sizeof(RestoreOptions)); opts = (RestoreOptions *) calloc(1, sizeof(RestoreOptions));
opts->format = archUnknown; opts->format = archUnknown;
opts->suppressDumpWarnings = false;
return opts; return opts;
} }
...@@ -1419,7 +1436,8 @@ _discoverArchiveFormat(ArchiveHandle *AH) ...@@ -1419,7 +1436,8 @@ _discoverArchiveFormat(ArchiveHandle *AH)
cnt = fread(sig, 1, 5, fh); cnt = fread(sig, 1, 5, fh);
if (cnt != 5) if (cnt != 5)
die_horribly(AH, "%s: input file is too short, or is unreadable\n", progname); die_horribly(AH, "%s: input file is too short, or is unreadable (read %d, expected 5)\n",
progname, cnt);
/* Save it, just in case we need it later */ /* Save it, just in case we need it later */
strncpy(&AH->lookahead[0], sig, 5); strncpy(&AH->lookahead[0], sig, 5);
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.31 2001/04/14 13:11:03 pjw Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.32 2001/04/25 07:03:19 pjw Exp $
* *
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au * Modifications - 28-Jun-2000 - pjw@rhyme.com.au
* - Initial version. * - Initial version.
...@@ -68,7 +68,7 @@ typedef z_stream *z_streamp; ...@@ -68,7 +68,7 @@ typedef z_stream *z_streamp;
#define K_VERS_MAJOR 1 #define K_VERS_MAJOR 1
#define K_VERS_MINOR 5 #define K_VERS_MINOR 5
#define K_VERS_REV 3 #define K_VERS_REV 5
/* Data block types */ /* Data block types */
#define BLK_DATA 1 #define BLK_DATA 1
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.10 2001/04/01 05:42:51 pjw Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.11 2001/04/25 07:03:19 pjw Exp $
* *
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au * Modifications - 28-Jun-2000 - pjw@rhyme.com.au
* *
...@@ -786,6 +786,7 @@ _ReadBuf(ArchiveHandle *AH, void *buf, int len) ...@@ -786,6 +786,7 @@ _ReadBuf(ArchiveHandle *AH, void *buf, int len)
res = fread(buf, 1, len, AH->FH); res = fread(buf, 1, len, AH->FH);
ctx->filePos += res; ctx->filePos += res;
return res; return res;
} }
...@@ -854,7 +855,10 @@ _getFilePos(ArchiveHandle *AH, lclContext *ctx) ...@@ -854,7 +855,10 @@ _getFilePos(ArchiveHandle *AH, lclContext *ctx)
{ {
pos = ftell(AH->FH); pos = ftell(AH->FH);
if (pos != ctx->filePos) if (pos != ctx->filePos)
fprintf(stderr, "Warning: ftell mismatch with filePos\n"); {
fprintf(stderr, "Warning: ftell mismatch with filePos - filePos used\n");
pos = ctx->filePos;
}
} }
else else
pos = ctx->filePos; pos = ctx->filePos;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Implements the basic DB functions used by the archiver. * Implements the basic DB functions used by the archiver.
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.17 2001/03/23 04:49:55 momjian Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.18 2001/04/25 07:03:19 pjw Exp $
* *
* NOTES * NOTES
* *
...@@ -114,17 +114,36 @@ _prompt_for_password(char *username, char *password) ...@@ -114,17 +114,36 @@ _prompt_for_password(char *username, char *password)
fprintf(stderr, "\n\n"); fprintf(stderr, "\n\n");
} }
static int
_parse_version(ArchiveHandle *AH, const char* versionString)
{
int cnt;
int vmaj, vmin, vrev;
cnt = sscanf(versionString, "%d.%d.%d", &vmaj, &vmin, &vrev);
if (cnt < 2)
{
die_horribly(AH, "Unable to parse version string: %s\n", versionString);
}
if (cnt == 2)
vrev = 0;
return (100 * vmaj + vmin) * 100 + vrev;
}
static void static void
_check_database_version(ArchiveHandle *AH, bool ignoreVersion) _check_database_version(ArchiveHandle *AH, bool ignoreVersion)
{ {
PGresult *res; PGresult *res;
double myversion; int myversion;
const char *remoteversion_str; const char *remoteversion_str;
double remoteversion; int remoteversion;
PGconn *conn = AH->connection; PGconn *conn = AH->connection;
myversion = strtod(PG_VERSION, NULL); myversion = _parse_version(AH, PG_VERSION);
res = PQexec(conn, "SELECT version()"); res = PQexec(conn, "SELECT version()");
if (!res || if (!res ||
PQresultStatus(res) != PGRES_TUPLES_OK || PQresultStatus(res) != PGRES_TUPLES_OK ||
...@@ -134,8 +153,14 @@ _check_database_version(ArchiveHandle *AH, bool ignoreVersion) ...@@ -134,8 +153,14 @@ _check_database_version(ArchiveHandle *AH, bool ignoreVersion)
"Explanation from backend: '%s'.\n", PQerrorMessage(conn)); "Explanation from backend: '%s'.\n", PQerrorMessage(conn));
remoteversion_str = PQgetvalue(res, 0, 0); remoteversion_str = PQgetvalue(res, 0, 0);
remoteversion = strtod(remoteversion_str + 11, NULL); remoteversion = _parse_version(AH, remoteversion_str + 11);
if (myversion != remoteversion)
PQclear(res);
AH->public.remoteVersion = remoteversion;
if (myversion != remoteversion
&& (remoteversion < AH->public.minRemoteVersion || remoteversion > AH->public.maxRemoteVersion) )
{ {
fprintf(stderr, "Database version: %s\n%s version: %s\n", fprintf(stderr, "Database version: %s\n%s version: %s\n",
remoteversion_str, progname, PG_VERSION); remoteversion_str, progname, PG_VERSION);
...@@ -145,7 +170,6 @@ _check_database_version(ArchiveHandle *AH, bool ignoreVersion) ...@@ -145,7 +170,6 @@ _check_database_version(ArchiveHandle *AH, bool ignoreVersion)
die_horribly(AH, "Aborting because of version mismatch.\n" die_horribly(AH, "Aborting because of version mismatch.\n"
"Use --ignore-version if you think it's safe to proceed anyway.\n"); "Use --ignore-version if you think it's safe to proceed anyway.\n");
} }
PQclear(res);
} }
/* /*
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.14 2001/04/14 13:11:03 pjw Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.15 2001/04/25 07:03:19 pjw Exp $
* *
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au * Modifications - 28-Jun-2000 - pjw@rhyme.com.au
* *
...@@ -834,6 +834,7 @@ _CloseArchive(ArchiveHandle *AH) ...@@ -834,6 +834,7 @@ _CloseArchive(ArchiveHandle *AH)
ropt->dropSchema = 1; ropt->dropSchema = 1;
ropt->compression = 0; ropt->compression = 0;
ropt->superuser = PQuser(AH->connection); ropt->superuser = PQuser(AH->connection);
ropt->suppressDumpWarnings = true;
savVerbose = AH->public.verbose; savVerbose = AH->public.verbose;
AH->public.verbose = 0; AH->public.verbose = 0;
......
This diff is collapsed.
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* 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.62 2001/04/14 13:11:03 pjw Exp $ * $Id: pg_dump.h,v 1.63 2001/04/25 07:03:20 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
* *
...@@ -159,6 +159,7 @@ typedef struct _aggInfo ...@@ -159,6 +159,7 @@ typedef struct _aggInfo
char *aggbasetype; char *aggbasetype;
char *agginitval; char *agginitval;
char *usename; char *usename;
int convertok; /* Flag to indicate of version convertsion is OK */
} AggInfo; } AggInfo;
typedef struct _oprInfo typedef struct _oprInfo
......
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