Skip to content

Commit c41f036

Browse files
committed
Don't attempt to limit target database for pg_restore.
There was an apparent attempt to limit the target database for pg_restore to version 7.1.0 or later. Due to a leading zero this was interpreted as an octal number, which allowed targets with version numbers down to 2.87.36. The lowest actual release above that was 6.0.0, so that was effectively the limit. Since the success of the restore attempt will depend primarily on on what statements were generated by the dump run, we don't want pg_restore trying to guess whether a given target should be allowed based on version number. Allow a connection to any version. Since it is very unlikely that anyone would be using a recent version of pg_restore to restore to a pre-6.0 database, this has little to no practical impact, but it makes the code less confusing to read. Issue reported and initial patch suggestion from Joel Jacobson based on an article by Andrey Karpov reporting on issues found by PVS-Studio static code analyzer. Final patch based on analysis by Tom Lane. Back-patch to all supported branches.
1 parent 1f069d2 commit c41f036

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,12 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
285285
if (AH->version < K_VERS_1_3)
286286
die_horribly(AH, modulename, "direct database connections are not supported in pre-1.3 archives\n");
287287

288-
/* XXX Should get this from the archive */
289-
AHX->minRemoteVersion = 070100;
288+
/*
289+
* We don't want to guess at whether the dump will successfully
290+
* restore; allow the attempt regardless of the version of the restore
291+
* target.
292+
*/
293+
AHX->minRemoteVersion = 0;
290294
AHX->maxRemoteVersion = 999999;
291295

292296
ConnectDatabase(AHX, ropt->dbname,

0 commit comments

Comments
 (0)