Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8dc42a3

Browse files
committed
- Fixed CONSTRAINT TRIGGER dump to record tgconstrelid properly
- pgsql v7.0 compatbility
1 parent 38b0f2f commit 8dc42a3

8 files changed

+370
-73
lines changed

src/bin/pg_dump/pg_backup.h

+9-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.10 2001/04/01 05:42:50 pjw Exp $
18+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.11 2001/04/25 07:03:19 pjw Exp $
1919
*
2020
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
2121
*
@@ -50,6 +50,9 @@
5050
#define atooid(x) ((Oid) strtoul((x), NULL, 10))
5151
#define oidcmp(x,y) ( ((x) < (y) ? -1 : ((x) > (y)) ? 1 : 0) )
5252
#define oideq(x,y) ( (x) == (y) )
53+
#define oidle(x,y) ( (x) <= (y) )
54+
#define oidge(x,y) ( (x) >= (y) )
55+
#define oidzero(x) ( (x) == 0 )
5356

5457
typedef enum _archiveFormat
5558
{
@@ -66,7 +69,10 @@ typedef enum _archiveFormat
6669
*/
6770
typedef struct _Archive
6871
{
69-
int verbose;
72+
int verbose;
73+
int remoteVersion;
74+
int minRemoteVersion;
75+
int maxRemoteVersion;
7076
/* The rest is private */
7177
} Archive;
7278

@@ -115,6 +121,7 @@ typedef struct _restoreOptions
115121
int limitToList;
116122
int compression;
117123

124+
int suppressDumpWarnings; /* Suppress output of WARNING entries to stderr */
118125
} RestoreOptions;
119126

120127
/*

src/bin/pg_dump/pg_backup_archiver.c

+20-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.24 2001/04/14 13:11:03 pjw Exp $
18+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.25 2001/04/25 07:03:19 pjw Exp $
1919
*
2020
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
2121
*
@@ -169,6 +169,10 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
169169
if (AH->version < K_VERS_1_3)
170170
die_horribly(AH, "Direct database connections are not supported in pre-1.3 archives");
171171

172+
/* XXX Should get this from the archive */
173+
AHX->minRemoteVersion = 070100;
174+
AHX->maxRemoteVersion = 999999;
175+
172176
ConnectDatabase(AHX, ropt->dbname, ropt->pghost, ropt->pgport,
173177
ropt->requirePassword, ropt->ignoreVersion);
174178

@@ -260,6 +264,18 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
260264
/* Work out what, if anything, we want from this entry */
261265
reqs = _tocEntryRequired(te, ropt);
262266

267+
/* Dump any relevant dump warnings to stderr */
268+
if (!ropt->suppressDumpWarnings && strcmp(te->desc, "WARNING") == 0)
269+
{
270+
if (!ropt->dataOnly && te->defn != NULL && strlen(te->defn) != 0)
271+
{
272+
fprintf(stderr, "%s: Warning from original dump file:\n%s\n", progname, te->defn);
273+
} else if (te->copyStmt != NULL && strlen(te->copyStmt) != 0)
274+
{
275+
fprintf(stderr, "%s: Warning from original dump file:\n%s\n", progname, te->copyStmt);
276+
}
277+
}
278+
263279
if ((reqs & 1) != 0) /* We want the schema */
264280
{
265281
/* Reconnect if necessary */
@@ -405,6 +421,7 @@ NewRestoreOptions(void)
405421
opts = (RestoreOptions *) calloc(1, sizeof(RestoreOptions));
406422

407423
opts->format = archUnknown;
424+
opts->suppressDumpWarnings = false;
408425

409426
return opts;
410427
}
@@ -1419,7 +1436,8 @@ _discoverArchiveFormat(ArchiveHandle *AH)
14191436
cnt = fread(sig, 1, 5, fh);
14201437

14211438
if (cnt != 5)
1422-
die_horribly(AH, "%s: input file is too short, or is unreadable\n", progname);
1439+
die_horribly(AH, "%s: input file is too short, or is unreadable (read %d, expected 5)\n",
1440+
progname, cnt);
14231441

14241442
/* Save it, just in case we need it later */
14251443
strncpy(&AH->lookahead[0], sig, 5);

src/bin/pg_dump/pg_backup_archiver.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
*
1919
* IDENTIFICATION
20-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.31 2001/04/14 13:11:03 pjw Exp $
20+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.32 2001/04/25 07:03:19 pjw Exp $
2121
*
2222
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
2323
* - Initial version.
@@ -68,7 +68,7 @@ typedef z_stream *z_streamp;
6868

6969
#define K_VERS_MAJOR 1
7070
#define K_VERS_MINOR 5
71-
#define K_VERS_REV 3
71+
#define K_VERS_REV 5
7272

7373
/* Data block types */
7474
#define BLK_DATA 1

src/bin/pg_dump/pg_backup_custom.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*
2020
*
2121
* IDENTIFICATION
22-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.10 2001/04/01 05:42:51 pjw Exp $
22+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.11 2001/04/25 07:03:19 pjw Exp $
2323
*
2424
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
2525
*
@@ -786,6 +786,7 @@ _ReadBuf(ArchiveHandle *AH, void *buf, int len)
786786

787787
res = fread(buf, 1, len, AH->FH);
788788
ctx->filePos += res;
789+
789790
return res;
790791
}
791792

@@ -854,7 +855,10 @@ _getFilePos(ArchiveHandle *AH, lclContext *ctx)
854855
{
855856
pos = ftell(AH->FH);
856857
if (pos != ctx->filePos)
857-
fprintf(stderr, "Warning: ftell mismatch with filePos\n");
858+
{
859+
fprintf(stderr, "Warning: ftell mismatch with filePos - filePos used\n");
860+
pos = ctx->filePos;
861+
}
858862
}
859863
else
860864
pos = ctx->filePos;

src/bin/pg_dump/pg_backup_db.c

+31-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Implements the basic DB functions used by the archiver.
66
*
77
* IDENTIFICATION
8-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.17 2001/03/23 04:49:55 momjian Exp $
8+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.18 2001/04/25 07:03:19 pjw Exp $
99
*
1010
* NOTES
1111
*
@@ -114,17 +114,36 @@ _prompt_for_password(char *username, char *password)
114114
fprintf(stderr, "\n\n");
115115
}
116116

117+
static int
118+
_parse_version(ArchiveHandle *AH, const char* versionString)
119+
{
120+
int cnt;
121+
int vmaj, vmin, vrev;
122+
123+
cnt = sscanf(versionString, "%d.%d.%d", &vmaj, &vmin, &vrev);
124+
125+
if (cnt < 2)
126+
{
127+
die_horribly(AH, "Unable to parse version string: %s\n", versionString);
128+
}
129+
130+
if (cnt == 2)
131+
vrev = 0;
132+
133+
return (100 * vmaj + vmin) * 100 + vrev;
134+
}
117135

118136
static void
119137
_check_database_version(ArchiveHandle *AH, bool ignoreVersion)
120138
{
121139
PGresult *res;
122-
double myversion;
140+
int myversion;
123141
const char *remoteversion_str;
124-
double remoteversion;
142+
int remoteversion;
125143
PGconn *conn = AH->connection;
126144

127-
myversion = strtod(PG_VERSION, NULL);
145+
myversion = _parse_version(AH, PG_VERSION);
146+
128147
res = PQexec(conn, "SELECT version()");
129148
if (!res ||
130149
PQresultStatus(res) != PGRES_TUPLES_OK ||
@@ -134,8 +153,14 @@ _check_database_version(ArchiveHandle *AH, bool ignoreVersion)
134153
"Explanation from backend: '%s'.\n", PQerrorMessage(conn));
135154

136155
remoteversion_str = PQgetvalue(res, 0, 0);
137-
remoteversion = strtod(remoteversion_str + 11, NULL);
138-
if (myversion != remoteversion)
156+
remoteversion = _parse_version(AH, remoteversion_str + 11);
157+
158+
PQclear(res);
159+
160+
AH->public.remoteVersion = remoteversion;
161+
162+
if (myversion != remoteversion
163+
&& (remoteversion < AH->public.minRemoteVersion || remoteversion > AH->public.maxRemoteVersion) )
139164
{
140165
fprintf(stderr, "Database version: %s\n%s version: %s\n",
141166
remoteversion_str, progname, PG_VERSION);
@@ -145,7 +170,6 @@ _check_database_version(ArchiveHandle *AH, bool ignoreVersion)
145170
die_horribly(AH, "Aborting because of version mismatch.\n"
146171
"Use --ignore-version if you think it's safe to proceed anyway.\n");
147172
}
148-
PQclear(res);
149173
}
150174

151175
/*

src/bin/pg_dump/pg_backup_tar.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
*
1818
* IDENTIFICATION
19-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.14 2001/04/14 13:11:03 pjw Exp $
19+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.15 2001/04/25 07:03:19 pjw Exp $
2020
*
2121
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
2222
*
@@ -834,6 +834,7 @@ _CloseArchive(ArchiveHandle *AH)
834834
ropt->dropSchema = 1;
835835
ropt->compression = 0;
836836
ropt->superuser = PQuser(AH->connection);
837+
ropt->suppressDumpWarnings = true;
837838

838839
savVerbose = AH->public.verbose;
839840
AH->public.verbose = 0;

0 commit comments

Comments
 (0)