]> granicus.if.org Git - postgresql/commitdiff
Don't attempt to limit target database for pg_restore.
authorKevin Grittner <kgrittn@postgresql.org>
Sun, 29 Dec 2013 21:17:52 +0000 (15:17 -0600)
committerKevin Grittner <kgrittn@postgresql.org>
Sun, 29 Dec 2013 21:17:52 +0000 (15:17 -0600)
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.

src/bin/pg_dump/pg_backup_archiver.c

index 63a800938aef8ac51be010550b3542d1ee630a09..7fc0288d0e3839d1f1f222bf369390842f93a24a 100644 (file)
@@ -297,8 +297,12 @@ RestoreArchive(Archive *AHX)
                if (AH->version < K_VERS_1_3)
                        exit_horribly(modulename, "direct database connections are not supported in pre-1.3 archives\n");
 
-               /* XXX Should get this from the archive */
-               AHX->minRemoteVersion = 070100;
+               /*
+                * We don't want to guess at whether the dump will successfully
+                * restore; allow the attempt regardless of the version of the restore
+                * target.
+                */
+               AHX->minRemoteVersion = 0;
                AHX->maxRemoteVersion = 999999;
 
                ConnectDatabase(AHX, ropt->dbname,