提交 8dc42a3a 编写于 作者: P Philip Warner

- Fixed CONSTRAINT TRIGGER dump to record tgconstrelid properly

- pgsql v7.0 compatbility
上级 38b0f2fb
......@@ -15,7 +15,7 @@
*
*
* 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
*
......@@ -50,6 +50,9 @@
#define atooid(x) ((Oid) strtoul((x), NULL, 10))
#define oidcmp(x,y) ( ((x) < (y) ? -1 : ((x) > (y)) ? 1 : 0) )
#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
{
......@@ -66,7 +69,10 @@ typedef enum _archiveFormat
*/
typedef struct _Archive
{
int verbose;
int verbose;
int remoteVersion;
int minRemoteVersion;
int maxRemoteVersion;
/* The rest is private */
} Archive;
......@@ -115,6 +121,7 @@ typedef struct _restoreOptions
int limitToList;
int compression;
int suppressDumpWarnings; /* Suppress output of WARNING entries to stderr */
} RestoreOptions;
/*
......
......@@ -15,7 +15,7 @@
*
*
* 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
*
......@@ -169,6 +169,10 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
if (AH->version < K_VERS_1_3)
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,
ropt->requirePassword, ropt->ignoreVersion);
......@@ -260,6 +264,18 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
/* Work out what, if anything, we want from this entry */
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 */
{
/* Reconnect if necessary */
......@@ -405,6 +421,7 @@ NewRestoreOptions(void)
opts = (RestoreOptions *) calloc(1, sizeof(RestoreOptions));
opts->format = archUnknown;
opts->suppressDumpWarnings = false;
return opts;
}
......@@ -1419,7 +1436,8 @@ _discoverArchiveFormat(ArchiveHandle *AH)
cnt = fread(sig, 1, 5, fh);
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 */
strncpy(&AH->lookahead[0], sig, 5);
......
......@@ -17,7 +17,7 @@
*
*
* 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
* - Initial version.
......@@ -68,7 +68,7 @@ typedef z_stream *z_streamp;
#define K_VERS_MAJOR 1
#define K_VERS_MINOR 5
#define K_VERS_REV 3
#define K_VERS_REV 5
/* Data block types */
#define BLK_DATA 1
......
......@@ -19,7 +19,7 @@
*
*
* 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
*
......@@ -786,6 +786,7 @@ _ReadBuf(ArchiveHandle *AH, void *buf, int len)
res = fread(buf, 1, len, AH->FH);
ctx->filePos += res;
return res;
}
......@@ -854,7 +855,10 @@ _getFilePos(ArchiveHandle *AH, lclContext *ctx)
{
pos = ftell(AH->FH);
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
pos = ctx->filePos;
......
......@@ -5,7 +5,7 @@
* Implements the basic DB functions used by the archiver.
*
* 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
*
......@@ -114,17 +114,36 @@ _prompt_for_password(char *username, char *password)
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
_check_database_version(ArchiveHandle *AH, bool ignoreVersion)
{
PGresult *res;
double myversion;
int myversion;
const char *remoteversion_str;
double remoteversion;
int remoteversion;
PGconn *conn = AH->connection;
myversion = strtod(PG_VERSION, NULL);
myversion = _parse_version(AH, PG_VERSION);
res = PQexec(conn, "SELECT version()");
if (!res ||
PQresultStatus(res) != PGRES_TUPLES_OK ||
......@@ -134,8 +153,14 @@ _check_database_version(ArchiveHandle *AH, bool ignoreVersion)
"Explanation from backend: '%s'.\n", PQerrorMessage(conn));
remoteversion_str = PQgetvalue(res, 0, 0);
remoteversion = strtod(remoteversion_str + 11, NULL);
if (myversion != remoteversion)
remoteversion = _parse_version(AH, remoteversion_str + 11);
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",
remoteversion_str, progname, PG_VERSION);
......@@ -145,7 +170,6 @@ _check_database_version(ArchiveHandle *AH, bool ignoreVersion)
die_horribly(AH, "Aborting because of version mismatch.\n"
"Use --ignore-version if you think it's safe to proceed anyway.\n");
}
PQclear(res);
}
/*
......
......@@ -16,7 +16,7 @@
*
*
* 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
*
......@@ -834,6 +834,7 @@ _CloseArchive(ArchiveHandle *AH)
ropt->dropSchema = 1;
ropt->compression = 0;
ropt->superuser = PQuser(AH->connection);
ropt->suppressDumpWarnings = true;
savVerbose = AH->public.verbose;
AH->public.verbose = 0;
......
此差异已折叠。
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* 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
*
......@@ -159,6 +159,7 @@ typedef struct _aggInfo
char *aggbasetype;
char *agginitval;
char *usename;
int convertok; /* Flag to indicate of version convertsion is OK */
} AggInfo;
typedef struct _oprInfo
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册