Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc22ed3d

Browse files
committed
Turn the -i/--ignore-version options of pg_dump and pg_dumpall into no-ops:
the server version check is now always enforced. Relax the version check toallow a server that is of pg_dump's own major version but a later minorversion; this is the only case that -i was at all safe to use in.pg_restore already enforced only a very weak version check, so this isreally just a documentation change for it.Per discussion.
1 parentba1c463 commitc22ed3d

File tree

9 files changed

+46
-82
lines changed

9 files changed

+46
-82
lines changed

‎doc/src/sgml/ref/pg_dump.sgml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/pg_dump.sgml,v 1.101 2008/03/26 16:34:47 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/pg_dump.sgml,v 1.102 2008/04/13 03:49:21 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -296,20 +296,7 @@ PostgreSQL documentation
296296
<term><option>--ignore-version</></term>
297297
<listitem>
298298
<para>
299-
Ignore version mismatch between
300-
<application>pg_dump</application> and the database server.
301-
</para>
302-
303-
<para>
304-
By default, <application>pg_dump</> will refuse to attempt
305-
to dump from a server that is of a newer <productname>PostgreSQL</>
306-
version than <application>pg_dump</application> is. It will also
307-
refuse to attempt to dump from a server that is older than the oldest
308-
supported version (currently, 7.0). The <option>-i</> option
309-
overrides this check and forces a dump to be attempted anyway.
310-
This option is <emphasis>deprecated</> because the dump is very
311-
likely to fail &mdash; or worse, seem to succeed but be wrong or
312-
incomplete.
299+
A deprecated option that is now ignored.
313300
</para>
314301
</listitem>
315302
</varlistentry>

‎doc/src/sgml/ref/pg_dumpall.sgml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/pg_dumpall.sgml,v 1.71 2008/03/26 16:34:47 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/pg_dumpall.sgml,v 1.72 2008/04/13 03:49:21 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -156,20 +156,7 @@ PostgreSQL documentation
156156
<term><option>--ignore-version</></term>
157157
<listitem>
158158
<para>
159-
Ignore version mismatch between
160-
<application>pg_dumpall</application> and the database server.
161-
</para>
162-
163-
<para>
164-
By default, <application>pg_dumpall</> will refuse to attempt
165-
to dump from a server that is of a newer <productname>PostgreSQL</>
166-
version than <application>pg_dumpall</application> is. It will also
167-
refuse to attempt to dump from a server that is older than the oldest
168-
supported version (currently, 7.0). The <option>-i</> option
169-
overrides this check and forces a dump to be attempted anyway.
170-
This option is <emphasis>deprecated</> because the dump is very
171-
likely to fail &mdash; or worse, seem to succeed but be wrong or
172-
incomplete.
159+
A deprecated option that is now ignored.
173160
</para>
174161
</listitem>
175162
</varlistentry>

‎doc/src/sgml/ref/pg_restore.sgml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/ref/pg_restore.sgml,v 1.74 2008/03/26 16:34:47 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/ref/pg_restore.sgml,v 1.75 2008/04/13 03:49:21 tgl Exp $ -->
22

33
<refentry id="APP-PGRESTORE">
44
<refmeta>
@@ -200,8 +200,7 @@
200200
<term><option>--ignore-version</option></term>
201201
<listitem>
202202
<para>
203-
Ignore version mismatch between
204-
<application>pg_restore</application> and the database server.
203+
A deprecated option that is now ignored.
205204
</para>
206205
</listitem>
207206
</varlistentry>

‎src/bin/pg_dump/pg_backup.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup.h,v 1.46 2008/03/20 17:36:57 tgl Exp $
18+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup.h,v 1.47 2008/04/13 03:49:21 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -116,7 +116,6 @@ typedef struct _restoreOptions
116116
char*pgport;
117117
char*pghost;
118118
char*username;
119-
intignoreVersion;
120119
intnoDataForFailedTables;
121120
intrequirePassword;
122121
intexit_on_error;
@@ -144,9 +143,7 @@ PGconn *ConnectDatabase(Archive *AH,
144143
constchar*pghost,
145144
constchar*pgport,
146145
constchar*username,
147-
constintreqPwd,
148-
constintignoreVersion);
149-
146+
intreqPwd);
150147

151148
/* Called to add a TOC entry */
152149
externvoidArchiveEntry(Archive*AHX,

‎src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.153 2008/03/20 17:36:57 tgl Exp $
18+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.154 2008/04/13 03:49:21 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -162,7 +162,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
162162

163163
ConnectDatabase(AHX,ropt->dbname,
164164
ropt->pghost,ropt->pgport,ropt->username,
165-
ropt->requirePassword,ropt->ignoreVersion);
165+
ropt->requirePassword);
166166

167167
/*
168168
* If we're talking to the DB directly, don't send comments since they

‎src/bin/pg_dump/pg_backup_db.c

Lines changed: 7 additions & 12 deletions
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-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.78 2008/03/26 14:32:22momjian Exp $
8+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.79 2008/04/13 03:49:22tgl Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -24,7 +24,7 @@
2424

2525
staticconstchar*modulename=gettext_noop("archiver (db)");
2626

27-
staticvoid_check_database_version(ArchiveHandle*AH,boolignoreVersion);
27+
staticvoid_check_database_version(ArchiveHandle*AH);
2828
staticPGconn*_connectDB(ArchiveHandle*AH,constchar*newdbname,constchar*newUser);
2929
staticvoidnotice_processor(void*arg,constchar*message);
3030
staticchar*_sendSQLLine(ArchiveHandle*AH,char*qry,char*eos);
@@ -48,7 +48,7 @@ _parse_version(ArchiveHandle *AH, const char *versionString)
4848
}
4949

5050
staticvoid
51-
_check_database_version(ArchiveHandle*AH,boolignoreVersion)
51+
_check_database_version(ArchiveHandle*AH)
5252
{
5353
intmyversion;
5454
constchar*remoteversion_str;
@@ -71,11 +71,7 @@ _check_database_version(ArchiveHandle *AH, bool ignoreVersion)
7171
{
7272
write_msg(NULL,"server version: %s; %s version: %s\n",
7373
remoteversion_str,progname,PG_VERSION);
74-
if (ignoreVersion)
75-
write_msg(NULL,"ignoring server version mismatch\n");
76-
else
77-
die_horribly(AH,NULL,"aborting because of server version mismatch\n"
78-
"Use the -i option to bypass server version check, but be prepared for failure.\n");
74+
die_horribly(AH,NULL,"aborting because of server version mismatch\n");
7975
}
8076
}
8177

@@ -182,7 +178,7 @@ _connectDB(ArchiveHandle *AH, const char *reqdb, const char *requser)
182178
free(password);
183179

184180
/* check for version mismatch */
185-
_check_database_version(AH, true);
181+
_check_database_version(AH);
186182

187183
PQsetNoticeProcessor(newConn,notice_processor,NULL);
188184

@@ -201,8 +197,7 @@ ConnectDatabase(Archive *AHX,
201197
constchar*pghost,
202198
constchar*pgport,
203199
constchar*username,
204-
constintreqPwd,
205-
constintignoreVersion)
200+
intreqPwd)
206201
{
207202
ArchiveHandle*AH= (ArchiveHandle*)AHX;
208203
char*password=NULL;
@@ -254,7 +249,7 @@ ConnectDatabase(Archive *AHX,
254249
PQdb(AH->connection),PQerrorMessage(AH->connection));
255250

256251
/* check for version mismatch */
257-
_check_database_version(AH,ignoreVersion);
252+
_check_database_version(AH);
258253

259254
PQsetNoticeProcessor(AH->connection,notice_processor,NULL);
260255

‎src/bin/pg_dump/pg_dump.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*by PostgreSQL
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.486 2008/03/28 00:21:56 tgl Exp $
15+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.487 2008/04/13 03:49:22 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -211,19 +211,20 @@ main(int argc, char **argv)
211211
inti;
212212
boolforce_password= false;
213213
intcompressLevel=-1;
214-
boolignore_version= false;
215214
intplainText=0;
216215
intoutputClean=0;
217216
intoutputCreate=0;
218217
booloutputBlobs= false;
219218
intoutputNoOwner=0;
220219
char*outputSuperuser=NULL;
220+
intmy_version;
221+
intoptindex;
222+
RestoreOptions*ropt;
223+
221224
staticintdisable_triggers=0;
222225
staticintoutputNoTablespaces=0;
223226
staticintuse_setsessauth=0;
224227

225-
RestoreOptions*ropt;
226-
227228
staticstructoptionlong_options[]= {
228229
{"data-only",no_argument,NULL,'a'},
229230
{"blobs",no_argument,NULL,'b'},
@@ -266,7 +267,6 @@ main(int argc, char **argv)
266267

267268
{NULL,0,NULL,0}
268269
};
269-
intoptindex;
270270

271271
set_pglocale_pgservice(argv[0],"pg_dump");
272272

@@ -345,8 +345,8 @@ main(int argc, char **argv)
345345
pghost=optarg;
346346
break;
347347

348-
case'i':/* ignore database version mismatch */
349-
ignore_version= true;
348+
case'i':
349+
/* ignored, deprecated option */
350350
break;
351351

352352
case'n':/* include schema(s) */
@@ -512,20 +512,26 @@ main(int argc, char **argv)
512512
/* Let the archiver know how noisy to be */
513513
g_fout->verbose=g_verbose;
514514

515-
g_fout->minRemoteVersion=70000;/* we can handle back to 7.0 */
516-
g_fout->maxRemoteVersion=parse_version(PG_VERSION);
517-
if (g_fout->maxRemoteVersion<0)
515+
my_version=parse_version(PG_VERSION);
516+
if (my_version<0)
518517
{
519518
write_msg(NULL,"could not parse version string \"%s\"\n",PG_VERSION);
520519
exit(1);
521520
}
522521

522+
/*
523+
* We allow the server to be back to 7.0, and up to any minor release
524+
* of our own major version. (See also version check in pg_dumpall.c.)
525+
*/
526+
g_fout->minRemoteVersion=70000;
527+
g_fout->maxRemoteVersion= (my_version /100)*100+99;
528+
523529
/*
524530
* Open the database using the Archiver, so it knows about it. Errors mean
525531
* death.
526532
*/
527533
g_conn=ConnectDatabase(g_fout,dbname,pghost,pgport,
528-
username,force_password,ignore_version);
534+
username,force_password);
529535

530536
/* Set the client encoding if requested */
531537
if (dumpencoding)
@@ -739,7 +745,6 @@ help(const char *progname)
739745
printf(_("\nGeneral options:\n"));
740746
printf(_(" -f, --file=FILENAME output file name\n"));
741747
printf(_(" -F, --format=c|t|p output file format (custom, tar, plain text)\n"));
742-
printf(_(" -i, --ignore-version ignore server version mismatch\n"));
743748
printf(_(" -v, --verbose verbose mode\n"));
744749
printf(_(" -Z, --compress=0-9 compression level for compressed formats\n"));
745750
printf(_(" --help show this help, then exit\n"));

‎src/bin/pg_dump/pg_dumpall.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
88
*
9-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.103 2008/03/26 14:32:22momjian Exp $
9+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.104 2008/04/13 03:49:22tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -60,7 +60,6 @@ static PQExpBuffer pgdumpopts;
6060
staticbooloutput_clean= false;
6161
staticboolskip_acls= false;
6262
staticboolverbose= false;
63-
staticboolignoreVersion= false;
6463

6564
staticintdisable_dollar_quoting=0;
6665
staticintdisable_triggers=0;
@@ -214,8 +213,7 @@ main(int argc, char *argv[])
214213
break;
215214

216215
case'i':
217-
ignoreVersion= true;
218-
appendPQExpBuffer(pgdumpopts," -i");
216+
/* ignored, deprecated option */
219217
break;
220218

221219
case'l':
@@ -488,7 +486,6 @@ help(void)
488486

489487
printf(_("\nGeneral options:\n"));
490488
printf(_(" -f, --file=FILENAME output file name\n"));
491-
printf(_(" -i, --ignore-version ignore server version mismatch\n"));
492489
printf(_(" --help show this help, then exit\n"));
493490
printf(_(" --version output version information, then exit\n"));
494491
printf(_("\nOptions controlling the output content:\n"));
@@ -1391,20 +1388,18 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport,
13911388
exit(1);
13921389
}
13931390

1391+
/*
1392+
* We allow the server to be back to 7.0, and up to any minor release
1393+
* of our own major version. (See also version check in pg_dump.c.)
1394+
*/
13941395
if (my_version!=server_version
1395-
&& (server_version<70000/* we can handle back to 7.0 */
1396-
||server_version>my_version))
1396+
&& (server_version<70000||
1397+
(server_version/100)> (my_version /100)))
13971398
{
13981399
fprintf(stderr,_("server version: %s; %s version: %s\n"),
13991400
remoteversion_str,progname,PG_VERSION);
1400-
if (ignoreVersion)
1401-
fprintf(stderr,_("ignoring server version mismatch\n"));
1402-
else
1403-
{
1404-
fprintf(stderr,_("aborting because of server version mismatch\n"
1405-
"Use the -i option to bypass server version check, but be prepared for failure.\n"));
1406-
exit(1);
1407-
}
1401+
fprintf(stderr,_("aborting because of server version mismatch\n"));
1402+
exit(1);
14081403
}
14091404

14101405
/*

‎src/bin/pg_dump/pg_restore.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*
3535
*
3636
* IDENTIFICATION
37-
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.87 2008/03/26 14:32:22momjian Exp $
37+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.88 2008/04/13 03:49:22tgl Exp $
3838
*
3939
*-------------------------------------------------------------------------
4040
*/
@@ -171,7 +171,7 @@ main(int argc, char **argv)
171171
opts->pghost=strdup(optarg);
172172
break;
173173
case'i':
174-
opts->ignoreVersion=1;
174+
/* ignored, deprecated option */
175175
break;
176176

177177
case'l':/* Dump the TOC summary */
@@ -378,7 +378,6 @@ usage(const char *progname)
378378
printf(_(" -d, --dbname=NAME connect to database name\n"));
379379
printf(_(" -f, --file=FILENAME output file name\n"));
380380
printf(_(" -F, --format=c|t specify backup file format\n"));
381-
printf(_(" -i, --ignore-version ignore server version mismatch\n"));
382381
printf(_(" -l, --list print summarized TOC of the archive\n"));
383382
printf(_(" -v, --verbose verbose mode\n"));
384383
printf(_(" --help show this help, then exit\n"));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp