[postgis-tickets] [SCM] PostGIS branch master updated. 3.3.0rc2-622-gf7885e500

git at osgeo.org git at osgeo.org
Thu Feb 16 08:42:09 PST 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".

The branch, master has been updated
       via  f7885e500686145b098a633356a70b49bfb1c1eb (commit)
       via  ecea1b90e42943d78affaf8ddb96dbacc198f9a9 (commit)
      from  7223866c546ddce6b2d4b2d304cf70eb099b0da0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f7885e500686145b098a633356a70b49bfb1c1eb
Author: Sandro Santilli <strk at kbt.io>
Date:   Thu Feb 16 17:39:35 2023 +0100

    Add test for #5338

diff --git a/raster/test/regress/hooks/hook-after-upgrade-raster.sql b/raster/test/regress/hooks/hook-after-upgrade-raster.sql
index 49f51173b..b220246ea 100644
--- a/raster/test/regress/hooks/hook-after-upgrade-raster.sql
+++ b/raster/test/regress/hooks/hook-after-upgrade-raster.sql
@@ -1 +1,2 @@
 DROP TABLE upgrade_test_raster;
+DROP TABLE upgrade_test_raster_with_regular_blocking;
diff --git a/raster/test/regress/hooks/hook-before-upgrade-raster.sql b/raster/test/regress/hooks/hook-before-upgrade-raster.sql
index 8c000dbaf..94d972fc3 100644
--- a/raster/test/regress/hooks/hook-before-upgrade-raster.sql
+++ b/raster/test/regress/hooks/hook-before-upgrade-raster.sql
@@ -14,3 +14,20 @@ INSERT INTO upgrade_test_raster(r) VALUES
 
 --SET client_min_messages TO ERROR;
 SELECT AddRasterConstraints('upgrade_test_raster', 'r');
+
+CREATE TABLE upgrade_test_raster_with_regular_blocking(r raster);
+INSERT INTO upgrade_test_raster_with_regular_blocking(r) VALUES
+(
+	ST_AddBand(
+		ST_MakeEmptyRaster(
+			10, 10, 1, 1, 2, 2, 0, 0,4326
+		),
+		1,
+		'8BSI'::text,
+		-129,
+		NULL
+	)
+);
+
+--SET client_min_messages TO ERROR;
+SELECT AddRasterConstraints('upgrade_test_raster_with_regular_blocking', 'r', 'regular_blocking');

commit ecea1b90e42943d78affaf8ddb96dbacc198f9a9
Author: Sandro Santilli <strk at kbt.io>
Date:   Wed Nov 9 12:59:42 2022 +0100

    run_test.pl: run before-upgrade hooks before dump, use postgis_restore.pl when needed
    
    We can only use pg_restore when the dumped database is extension based.
    
    See #5075 and #5338

diff --git a/regress/run_test.pl b/regress/run_test.pl
index 5750dce07..3f2b1291c 100755
--- a/regress/run_test.pl
+++ b/regress/run_test.pl
@@ -142,7 +142,10 @@ sub findOrDie
 
 # Prepend scripts' build dirs to path
 # TODO: make this conditional ?
-$ENV{PATH} = $TOP_BUILDDIR . '/loader:' . $TOP_BUILDDIR .  '/raster/loader:' . $ENV{PATH};
+$ENV{PATH} = $TOP_BUILDDIR . '/loader:' .
+             $TOP_BUILDDIR . '/raster/loader:' .
+             $TOP_BUILDDIR . '/utils:' .
+             $ENV{PATH};
 
 our $SHP2PGSQL;
 sub shp2pgsql
@@ -165,6 +168,12 @@ sub raster2pgsql
     return $RASTER2PGSQL;
 }
 
+our $POSTGIS_RESTORE;
+sub postgis_restore
+{
+    $POSTGIS_RESTORE = findOrDie 'postgis_restore.pl', @_ unless defined($POSTGIS_RESTORE);
+}
+
 if ( $OPT_UPGRADE_PATH )
 {
   $OPT_UPGRADE = 1; # implied
@@ -366,34 +375,59 @@ if ( $OPT_UPGRADE )
 {
     print "Upgrading from postgis $libver\n";
 
-	foreach my $hook (@OPT_HOOK_BEFORE_UPGRADE)
-	{
-		print "Running before-upgrade-script $hook\n";
-		die unless load_sql_file($hook, 1);
-	}
-
-    if ( $OPT_EXTENSIONS )
+    foreach my $hook (@OPT_HOOK_BEFORE_UPGRADE)
     {
-        die unless upgrade_spatial_extensions();
+        print "Running before-upgrade-script $hook\n";
+        die unless load_sql_file($hook, 1);
     }
-    else
-    {
-        die unless upgrade_spatial();
+}
+
+if ( $OPT_DUMPRESTORE )
+{
+    my $DBDUMP = dump_db();
+    die unless defined $DBDUMP;
+
+    print "Dropping db '${DB}'\n";
+    my $rv = system("dropdb ${DB} >> $REGRESS_LOG 2>&1");
+    if ( $rv ) {
+        fail("Could not drop ${DB}", $REGRESS_LOG);
+        die;
     }
 
-	foreach my $hook (@OPT_HOOK_AFTER_UPGRADE)
-	{
-		print "Running after-upgrade-script $hook\n";
-		die unless load_sql_file($hook, 1);
-	}
+    print "Creating spatial db '${DB}'\n";
+    undef($OPT_UPGRADE_FROM); # to directly prepare the target
+    $rv = create_spatial();
+    if ( ! $rv ) {
+        fail("Could not create spatial db ${DB}", $REGRESS_LOG);
+        die;
+    }
+    die unless restore_db($DBDUMP);
 
-    # Update libver
-    $libver = sql("select postgis_lib_version()");
+    unlink($DBDUMP);
 }
 
-if ( $OPT_DUMPRESTORE )
+if ( $OPT_UPGRADE )
 {
-    die unless dump_restore();
+    unless ( $OPT_DUMPRESTORE )
+    {
+        if ( $OPT_EXTENSIONS )
+        {
+            die unless upgrade_spatial_extensions();
+        }
+        else
+        {
+            die unless upgrade_spatial();
+        }
+    }
+
+    foreach my $hook (@OPT_HOOK_AFTER_UPGRADE)
+    {
+        print "Running after-upgrade-script $hook\n";
+        die unless load_sql_file($hook, 1);
+    }
+
+    # Update libver
+    $libver = sql("select postgis_lib_version()");
 }
 
 ##################################################################
@@ -632,7 +666,8 @@ Options:
                        an exclamation mark (ie: ":auto!" or "3.0.0!") to
                        request upgrade via postgis_extensions_upgrade()
                        if available.
-  --dumprestore   dump and restore spatially-enabled db before running tests
+  --dumprestore   dump and (after upgrade, if --upgrade is given)
+                  restore spatially-enabled db before running tests
   --nodrop        do not drop the regression database on exit
   --schema        where to install/find PostGIS (relocatable) PostGIS
                   (defaults to "public")
@@ -1414,7 +1449,7 @@ sub create_spatial
         if ( ! $OPT_UPGRADE_FROM )
         {
             exit($FAIL) unless prepare_spatial();
-            return;
+            return 1;
         }
 
         if ( $OPT_UPGRADE_FROM !~ /^unpackaged(.*)/ )
@@ -1428,6 +1463,8 @@ sub create_spatial
         }
         exit($FAIL) unless prepare_spatial($1);
     }
+
+    return 1;
 }
 
 
@@ -1966,33 +2003,36 @@ sub uninstall_spatial
 	return 1;
 }
 
-# Dump and restore the database
-sub dump_restore
+# Dump the database, return dump filename
+sub dump_db
 {
-    my $DBDUMP = $TMPDIR . '/' . $DB . ".dump";
     my $rv;
+    my $DBDUMP = $TMPDIR . '/' . $DB . '.dump';
 
-	print "Dumping and restoring database '${DB}'\n";
+    print "Dumping database '${DB}'\n";
 
     $rv = system("pg_dump -Fc -f${DBDUMP} ${DB} >> $REGRESS_LOG 2>&1");
     if ( $rv ) {
         fail("Could not dump ${DB}", $REGRESS_LOG);
-        return 0;
-    }
-
-    $rv = system("dropdb ${DB} >> $REGRESS_LOG 2>&1");
-    if ( $rv ) {
-        fail("Could not drop db ${DB}", $REGRESS_LOG);
-        return 0;
+        return undef;
     }
+    return ${DBDUMP};
+}
 
-    $rv = create_db();
-    if ( $rv ) {
-        fail("Could not create ${DB}", $REGRESS_LOG);
-        return 0;
+# Restore the dump file passed as first argument
+sub restore_db
+{
+    my $rv;
+    my $DBDUMP = shift;
+
+    if ( $OPT_EXTENSIONS ) {
+        print "Restoring database '${DB}' using pg_restore\n";
+        $rv = system("pg_restore -d ${DB} ${DBDUMP} >> $REGRESS_LOG 2>&1");
+    } else {
+        print "Restoring database '${DB}' using postgis_restore.pl\n";
+        my $cmd = postgis_restore() . " ${DBDUMP} | psql --set ON_ERROR_STOP=1 -X ${DB} >> $REGRESS_LOG 2>&1";
+        $rv = system($cmd);
     }
-
-    $rv = system("pg_restore -d ${DB} ${DBDUMP} >> $REGRESS_LOG 2>&1");
     if ( $rv ) {
         fail("Could not restore ${DB}", $REGRESS_LOG);
         return 0;
@@ -2011,11 +2051,10 @@ sub dump_restore
         }
     }
 
-    unlink($DBDUMP);
-
     return 1;
 }
 
+# Dump and restore the database
 sub diff
 {
 	my ($expected_file, $obtained_file) = @_;

-----------------------------------------------------------------------

Summary of changes:
 .../regress/hooks/hook-after-upgrade-raster.sql    |   1 +
 .../regress/hooks/hook-before-upgrade-raster.sql   |  17 +++
 regress/run_test.pl                                | 123 ++++++++++++++-------
 3 files changed, 99 insertions(+), 42 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list