[SCM] PostGIS branch stable-3.3 updated. 3.3.4-21-gfb96c5174

git at osgeo.org git at osgeo.org
Thu Oct 26 06:04:18 PDT 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, stable-3.3 has been updated
       via  fb96c51744307232166e48d600b6ca9e1fbb7900 (commit)
       via  26dc67c7f6f17ee9f05a23f520ef541ef7c95188 (commit)
       via  8131a1d0b33ce2eb725a45f368bed67a732d8a7c (commit)
       via  f03f601589b3ef6b9b35cf58117f39d5c0710d4e (commit)
      from  bef9d154e2a172e7794000d8a2fbca606d4463d1 (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 fb96c51744307232166e48d600b6ca9e1fbb7900
Author: Sandro Santilli <strk at kbt.io>
Date:   Thu Oct 26 15:03:52 2023 +0200

    Copy run_test.pl from current master branch

diff --git a/regress/run_test.pl b/regress/run_test.pl
index 0ec5b2db0..11d0dabf6 100755
--- a/regress/run_test.pl
+++ b/regress/run_test.pl
@@ -16,7 +16,6 @@
 use File::Basename;
 use File::Temp 'tempdir';
 use Time::HiRes qw(time);
-#use File::Which;
 use File::Copy;
 use File::Path;
 use Cwd 'abs_path';
@@ -49,10 +48,21 @@ BEGIN {
 ##################################################################
 
 our $DB = $ENV{"POSTGIS_REGRESS_DB"} || "postgis_reg";
-our $REGDIR = abs_path(dirname($0));
-our $TOP_BUILDDIR = $ENV{"POSTGIS_TOP_BUILD_DIR"} || ${REGDIR} . '/..';
+our $REGDIR = $ENV{"POSTGIS_REGRESS_DIR"} || abs_path(dirname($0));
+our $TOP_SOURCEDIR = ${REGDIR} . '/..';
+our $ABS_TOP_SOURCEDIR = abs_path(${TOP_SOURCEDIR});
+our $TOP_BUILDDIR = $ENV{"POSTGIS_TOP_BUILD_DIR"};
 our $sysdiff = !system("diff --strip-trailing-cr $0 $0 2> /dev/null");
 
+##################################################################
+# Set up some global variables
+##################################################################
+
+my $RUN = 0;
+my $FAIL = 0;
+my $SKIP = 0;
+our $TEST = "";
+
 ##################################################################
 # Parse command line opts
 ##################################################################
@@ -68,7 +78,12 @@ my $OPT_WITH_RASTER = 0;
 my $OPT_WITH_SFCGAL = 0;
 my $OPT_EXPECT = 0;
 my $OPT_EXTENSIONS = 0;
+my $OPT_LEGACY = 0;
 my @OPT_HOOK_AFTER_CREATE;
+my @OPT_HOOK_AFTER_RESTORE;
+my @OPT_HOOK_BEFORE_DUMP;
+my @OPT_HOOK_BEFORE_TEST;
+my @OPT_HOOK_AFTER_TEST;
 my @OPT_HOOK_BEFORE_UNINSTALL;
 my @OPT_HOOK_BEFORE_UPGRADE;
 my @OPT_HOOK_AFTER_UPGRADE;
@@ -80,10 +95,10 @@ our $VERBOSE = 0;
 our $OPT_SCHEMA = 'public';
 
 GetOptions (
-	'verbose' => \$VERBOSE,
+	'verbose+' => \$VERBOSE,
 	'clean' => \$OPT_CLEAN,
 	'nodrop' => \$OPT_NODROP,
-	'upgrade' => \$OPT_UPGRADE,
+	'upgrade+' => \$OPT_UPGRADE,
 	'upgrade-path=s' => \$OPT_UPGRADE_PATH,
 	'dumprestore' => \$OPT_DUMPRESTORE,
 	'nocreate' => \$OPT_NOCREATE,
@@ -93,12 +108,17 @@ GetOptions (
 	'sfcgal' => \$OPT_WITH_SFCGAL,
 	'expect' => \$OPT_EXPECT,
 	'extensions' => \$OPT_EXTENSIONS,
+	'legacy' => \$OPT_LEGACY,
 	'schema=s' => \$OPT_SCHEMA,
 	'build-dir=s' => \$TOP_BUILDDIR,
 	'after-create-script=s' => \@OPT_HOOK_AFTER_CREATE,
+	'after-test-script=s' => \@OPT_HOOK_AFTER_TEST,
 	'before-uninstall-script=s' => \@OPT_HOOK_BEFORE_UNINSTALL,
+	'before-test-script=s' => \@OPT_HOOK_BEFORE_TEST,
 	'before-upgrade-script=s' => \@OPT_HOOK_BEFORE_UPGRADE,
-	'after-upgrade-script=s' => \@OPT_HOOK_AFTER_UPGRADE
+	'before-dump-script=s' => \@OPT_HOOK_BEFORE_DUMP,
+	'after-upgrade-script=s' => \@OPT_HOOK_AFTER_UPGRADE,
+	'after-restore-script=s' => \@OPT_HOOK_AFTER_RESTORE
 	);
 
 if ( @ARGV < 1 )
@@ -106,13 +126,79 @@ if ( @ARGV < 1 )
 	usage();
 }
 
-our $SHP2PGSQL = $TOP_BUILDDIR . "/loader/shp2pgsql";
-our $PGSQL2SHP = $TOP_BUILDDIR . "/loader/pgsql2shp";
-our $RASTER2PGSQL = $TOP_BUILDDIR . "/raster/loader/raster2pgsql";
+sub findOrDie
+{
+    my $exec = shift;
+    my $verbose = shift;
+    printf "Checking for %s ... ", $exec if $verbose gt 1;
+    foreach my $d ( split /:/, $ENV{PATH} )
+    {
+        my $path = $d . '/' . $exec;
+        if ( -x $path ) {
+            if ( $verbose gt 1 ) {
+                print "found";
+                print " ($path)" if $verbose gt 1;
+                print "\n";
+            }
+            return $path
+        }
+    }
+    print STDERR "Unable to find $exec executable.\n";
+    print STDERR "PATH is " . $ENV{"PATH"} . "\n";
+    die "HINT: use POSTGIS_TOP_BUILD_DIR env or --build-dir switch the specify top build dir.\n";
+}
+
+
+# If build dir is not given, try to guess
+if ( "${TOP_BUILDDIR}" eq "" )
+{
+    foreach my $d ( $ENV{'PWD'}, "${TOP_SOURCEDIR}" )
+    {
+        if ( -e ${d} . '/postgis_revision.h' )
+        {
+            $TOP_BUILDDIR="${d}";
+            last;
+        }
+    }
+}
+
+# Prepend scripts' build dirs to path
+# TODO: make this conditional ?
+$ENV{PATH} = $TOP_BUILDDIR . '/loader:' .
+             $TOP_BUILDDIR . '/raster/loader:' .
+             $TOP_BUILDDIR . '/utils:' .
+             $ENV{PATH};
+
+our $SHP2PGSQL;
+sub shp2pgsql
+{
+    $SHP2PGSQL = findOrDie 'shp2pgsql', @_ unless defined($SHP2PGSQL);
+    return $SHP2PGSQL;
+}
+
+our $PGSQL2SHP;
+sub pgsql2shp
+{
+    $PGSQL2SHP = findOrDie 'pgsql2shp', @_ unless defined($PGSQL2SHP);
+    return $PGSQL2SHP;
+}
+
+our $RASTER2PGSQL;
+sub raster2pgsql
+{
+    $RASTER2PGSQL = findOrDie 'raster2pgsql', @_ unless defined($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
+  $OPT_UPGRADE = 1 if not $OPT_UPGRADE; # implied
   my @path = split ('--', $OPT_UPGRADE_PATH);
   $OPT_UPGRADE_FROM = $path[0]
     || die "Malformed upgrade path, <from>--<to> expected, $OPT_UPGRADE_PATH given";
@@ -152,9 +238,6 @@ $PGOPTIONS .= " -c client_min_messages=NOTICE";
 $PGOPTIONS .= " -c extra_float_digits=0";
 $ENV{"PGOPTIONS"} = $PGOPTIONS;
 
-# Bring the path info in
-my $PATH = $ENV{"PATH"}; # this is useless
-
 # Calculate the regression directory locations
 my $STAGED_INSTALL_DIR = $TOP_BUILDDIR . "/regress/00-regress-install";
 my $STAGED_SCRIPTS_DIR = $STAGED_INSTALL_DIR . "/share/contrib/postgis";
@@ -163,40 +246,22 @@ my $OBJ_COUNT_PRE = 0;
 my $OBJ_COUNT_POST = 0;
 
 ##################################################################
-# Check that we have the executables we need
+# Set up the temporary directory
 ##################################################################
 
-print "PATH is $PATH\n";
-
-foreach my $exec ( ($SHP2PGSQL, $PGSQL2SHP) )
+# Pre-flight to check if we need
+# to find shp2pgsql/pgsql2shp/raster2pgsql
+foreach $TEST (@ARGV)
 {
-	printf "Checking for %s ... ", basename($exec);
-	if ( -x $exec )
-	{
-		print "found\n";
-	}
-	else
-	{
-		print "failed\n";
-		print STDERR "Unable to find $exec executable.\n";
-		print STDERR "TOP_BUILDDIR is ${TOP_BUILDDIR}\n";
-		die "HINT: use POSTGIS_TOP_BUILD_DIR env or --build-dir switch the specify top build dir.\n";
-	}
-
-}
-
-if ( $OPT_WITH_RASTER )
-{
-	print "Checking for raster2pgsql ... ";
-	if ( -x $RASTER2PGSQL )
-	{
-		print "found\n";
-	}
-	else
-	{
-		print "failed\n";
-		die "Unable to find raster2pgsql executable.\n";
-	}
+    if ( -r "${TEST}.dbf" )
+    {
+        shp2pgsql($VERBOSE);
+        pgsql2shp($VERBOSE);
+    }
+    elsif ( -r "${TEST}.tif" )
+    {
+        raster2pgsql($VERBOSE);
+    }
 }
 
 ##################################################################
@@ -223,7 +288,7 @@ mkpath $TMPDIR; # make sure tmp dir exists
 my $REGRESS_LOG = "${TMPDIR}/regress_log";
 
 # Report
-print "TMPDIR is $TMPDIR\n";
+print "TMPDIR is $TMPDIR\n" if $VERBOSE gt 1;
 
 ##################################################################
 # Prepare the database
@@ -247,6 +312,7 @@ psql -XtAc "
 	WHERE name = 'postgis'
 " template1
 `;
+chop $defextver;
 
 my $dbcount = @dblist;
 
@@ -279,6 +345,28 @@ else
 
 my $libver = sql("select postgis_lib_version()");
 
+sub compute_executor_slow_factor
+{
+    my $ms_to_fetch_full_version = sql(<<EOF
+        CREATE TEMP TABLE _start AS SELECT clock_timestamp() c;
+        SELECT FROM postgis_full_version();
+        SELECT EXTRACT(milliseconds FROM clock_timestamp()-c)
+             FROM _start;
+EOF
+    );
+    my $default_ms_to_fetch_full_version = 10;
+    my $test_executor_slow_factor = 1;
+    if ( $ms_to_fetch_full_version gt $default_ms_to_fetch_full_version )
+    {
+        $test_executor_slow_factor = $ms_to_fetch_full_version / $default_ms_to_fetch_full_version;
+    }
+    #
+    print "Executor slow factor: $test_executor_slow_factor ($ms_to_fetch_full_version ms to fetch full version)\n";
+    sql("ALTER DATABASE \\\"$DB\\\" SET test.executor_slow_factor = $test_executor_slow_factor");
+}
+
+compute_executor_slow_factor;
+
 if ( ! $libver )
 {
 	`dropdb $DB`;
@@ -287,6 +375,16 @@ if ( ! $libver )
 	exit(1);
 }
 
+sub staged_scripts_dir
+{
+    unless ( -d $STAGED_SCRIPTS_DIR ) {
+        print STDERR "Unable to find $STAGED_SCRIPTS_DIR directory.\n";
+        print STDERR "TOP_BUILDDIR is $TOP_BUILDDIR.\n";
+        die "HINT: use POSTGIS_TOP_BUILD_DIR env or --build-dir switch the specify top build dir.\n";
+    }
+    $STAGED_SCRIPTS_DIR;
+}
+
 sub scriptdir
 {
 	my ( $version, $systemwide ) = @_;
@@ -298,7 +396,7 @@ sub scriptdir
 		chop $scriptdir;
 		$scriptdir .= "/contrib/postgis-" . $pgis_majmin;
 	} else {
-		$scriptdir = $STAGED_SCRIPTS_DIR;
+		$scriptdir = staged_scripts_dir()
 	}
 	#print "XXX: scriptdir: $scriptdir\n";
 	return $scriptdir;
@@ -320,40 +418,65 @@ sub semver_lessthan
 	return @bcomp ? 1 : 0;
 }
 
-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 )
-  {
-    upgrade_spatial_extensions();
-  }
-  else
-  {
-	  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()");
-}
-
 if ( $OPT_DUMPRESTORE )
 {
-  dump_restore();
+    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;
+    }
+
+    print "Creating db '${DB}'\n";
+    $rv = create_db();
+    if ( ! $rv ) {
+        fail("Could not create db ${DB}", $REGRESS_LOG);
+        die;
+    }
+
+    die unless restore_db($DBDUMP);
+
+    # Update libver
+    $libver = sql("select postgis_lib_version()");
+
+    unlink($DBDUMP);
 }
 
+if ( $OPT_UPGRADE )
+{
+    my $upgradesleft = $OPT_UPGRADE;
+    print "Upgrading from postgis $libver ($upgradesleft upgrades requested)\n";
+
+    foreach my $hook (@OPT_HOOK_BEFORE_UPGRADE)
+    {
+        print "Running before-upgrade-script $hook\n";
+        die unless load_sql_file($hook, 1);
+    }
+
+    while ( $upgradesleft-- )
+    {
+        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()");
+}
 
 ##################################################################
 # Report PostGIS environment
@@ -383,14 +506,6 @@ print "  SFCGAL: $sfcgalver\n" if $sfcgalver;
 print "  GDAL: $gdalver\n" if $gdalver;
 
 
-##################################################################
-# Set up some global variables
-##################################################################
-my $RUN = 0;
-my $FAIL = 0;
-my $SKIP = 0;
-our $TEST = "";
-
 ##################################################################
 # Run the tests
 ##################################################################
@@ -432,6 +547,12 @@ foreach $TEST (@ARGV)
 	# catch a common mistake (strip trailing .sql)
 	$TEST =~ s/.sql$//;
 
+	foreach my $hook (@OPT_HOOK_BEFORE_TEST)
+	{
+		print "  Running before-test-script $hook\n" if $VERBOSE > 1;
+		die unless load_sql_file($hook, 1);
+	}
+
 	start_test($TEST);
 	$TEST_OBJ_COUNT_PRE = count_postgis_objects();
 
@@ -514,6 +635,12 @@ foreach $TEST (@ARGV)
 		fail("PostGIS object count pre-test ($TEST_OBJ_COUNT_POST) != post-test ($TEST_OBJ_COUNT_PRE)");
 	}
 
+	foreach my $hook (@OPT_HOOK_AFTER_TEST)
+	{
+		print "  Running after-test-script $hook\n" if $VERBOSE > 1;
+		die unless load_sql_file($hook, 1);
+	}
+
 }
 
 foreach my $hook (@OPT_HOOK_BEFORE_UNINSTALL)
@@ -578,7 +705,8 @@ Usage: $0 [<options>] <testname> [<testname>]
 Options:
   -v, --verbose   be verbose about failures
   --nocreate      do not create the regression database on start
-  --upgrade       source the upgrade scripts on start
+  --upgrade       upgrade db before runnign tests, can be passed
+                  multiple times to perform multiple upgrades.
   --upgrade-path  upgrade path, format <from>--<to>.
                   <from> can be specified as "unpackaged<version>"
                          to specify a script version to start from.
@@ -587,17 +715,19 @@ 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")
   --raster        load also raster extension
-  --tiger      		load also tiger_geocoder extension
+  --tiger         load also tiger_geocoder extension
   --topology      load also topology extension
   --sfcgal        use also sfcgal backend
   --clean         cleanup test logs on exit
   --expect        save obtained output as expected
   --extension     load using extensions
+  --legacy        load also legacy scripts
   --build-dir <path>
                   specify where to find the top build dir of PostGIS,
                   to find binaries and scripts
@@ -607,12 +737,24 @@ Options:
   --before-uninstall-script <path>
                   script to load before spatial extension uninstall
                   (multiple switches supported, to be run in given order)
+  --before-dump-script <path>
+                  script to load before dump, if --dumprestore is given
+                  (multiple switches supported, to be run in given order)
+  --after-restore-script <path>
+                  script to load after restore, if --dumprestore is given
+                  (multiple switches supported, to be run in given order)
   --before-upgrade-script <path>
                   script to load before upgrade
                   (multiple switches supported, to be run in given order)
   --after-upgrade-script <path>
                   script to load after upgrade
                   (multiple switches supported, to be run in given order)
+  --before-test-script <path>
+                  script to load before each test run
+                  (multiple switches supported, to be run in given order)
+  --after-test-script <path>
+                  script to load after each test run
+                  (multiple switches supported, to be run in given order)
 };
 
 }
@@ -621,6 +763,12 @@ Options:
 sub start_test
 {
     my $test = shift;
+    my $abstest = abs_path($test);
+    if ( defined($abstest) )
+    {
+        $test = $abstest;
+    }
+    $test =~ s|${ABS_TOP_SOURCEDIR}/||;
     print " $test ";
 	$RUN++;
     show_progress();
@@ -656,7 +804,7 @@ sub fail
 	{
 		printf(" failed (%s)\n", $msg);
 	}
-	elsif ( $VERBOSE == 1 )
+	elsif ( $VERBOSE )
 	{
 		printf(" failed (%s: %s)\n", $msg, $log);
 		print "-----------------------------------------------------------------------------\n";
@@ -896,7 +1044,7 @@ sub run_loader_and_check_output
 	{
 		show_progress();
 		# Produce the output SQL file.
-		$cmd = "$SHP2PGSQL $loader_options -g the_geom ${TEST}.shp $tblname > $outfile 2> $errfile";
+		$cmd = shp2pgsql() . " $loader_options -g the_geom ${TEST}.shp $tblname > $outfile 2> $errfile";
 		$rv = system($cmd);
 
 		if ( $rv )
@@ -962,7 +1110,7 @@ sub run_dumper_and_check_output
 	if ( $run_always || -r $expected_shp_file )
 	{
 		show_progress();
-		$cmd = "${PGSQL2SHP} -f ${TMPDIR}/dumper $DB $tblname > $errfile 2>&1";
+		$cmd = pgsql2shp() . " -f ${TMPDIR}/dumper $DB $tblname > $errfile 2>&1";
 		$rv = system($cmd);
 
 		if ( $rv )
@@ -1029,7 +1177,7 @@ sub run_raster_loader_and_check_output
 		show_progress();
 
 		# Produce the output SQL file.
-		$cmd = "$RASTER2PGSQL $loader_options $raster_file $tblname > $outfile 2> $errfile";
+		$cmd = raster2pgsql() . " $loader_options $raster_file $tblname > $outfile 2> $errfile";
 		$rv = system($cmd);
 
 		if ( $rv )
@@ -1199,7 +1347,7 @@ sub run_dumper_test
   chomp(@dumplines);
   my $dumpstring = shift @dumplines;
   @dumplines = map { local $_ = $_; s/{regdir}/$REGDIR/; $_ } @dumplines;
-  my @cmd = ("${PGSQL2SHP}", "-f", ${shpfile});
+  my @cmd = ( pgsql2shp(), "-f", ${shpfile});
   push @cmd, @dumplines;
   push @cmd, ${DB};
   push @cmd, $dumpstring;
@@ -1345,7 +1493,7 @@ sub create_db
 		$createcmd .= " --locale=C --locale-provider=libc"
 	}
 	$createcmd .= " $DB > $REGRESS_LOG";
-	return system($createcmd);
+	return not system($createcmd);
 }
 
 sub create_spatial
@@ -1360,14 +1508,14 @@ sub create_spatial
 
     if ( $OPT_EXTENSIONS )
     {
-        prepare_spatial_extensions();
+        exit($FAIL) unless prepare_spatial_extensions();
     }
     else
     {
         if ( ! $OPT_UPGRADE_FROM )
         {
-            prepare_spatial();
-            return;
+            exit($FAIL) unless prepare_spatial();
+            return 1;
         }
 
         if ( $OPT_UPGRADE_FROM !~ /^unpackaged(.*)/ )
@@ -1379,8 +1527,10 @@ sub create_spatial
         {
             die "--upgrade-path without --extension is only supported with target :auto";
         }
-        prepare_spatial($1);
+        exit($FAIL) unless prepare_spatial($1);
     }
+
+    return 1;
 }
 
 
@@ -1389,18 +1539,13 @@ sub load_sql_file
 	my $file = shift;
 	my $strict = shift;
 
-	if ( $strict && ! -e $file )
-	{
-		fail "Unable to find $file";
-		return 0;
-	}
-
 	if ( -e $file )
 	{
 		# ON_ERROR_STOP is used by psql to return non-0 on an error
 		my $psql_opts = "--quiet --no-psqlrc --variable ON_ERROR_STOP=true";
 		my $cmd = "psql $psql_opts -c 'CREATE SCHEMA IF NOT EXISTS $OPT_SCHEMA' ";
 		$cmd .= "-c 'SET search_path TO $OPT_SCHEMA,topology'";
+		$cmd .= " -v \"opt_dumprestore=${OPT_DUMPRESTORE}\"";
 		$cmd .= " -Xf $file $DB >> $REGRESS_LOG 2>&1";
 		#print "  $file\n" if $VERBOSE;
 		my $rv = system($cmd);
@@ -1411,6 +1556,12 @@ sub load_sql_file
 			return 0;
 		}
 	}
+	elsif ( $strict )
+	{
+		fail "Unable to find $file";
+		return 0;
+	}
+
 	return 1;
 }
 
@@ -1425,15 +1576,14 @@ sub prepare_spatial_extensions
 	my $rv = system($cmd);
 	if ( $rv ) {
 	  fail "Error encountered creating target schema ${OPT_SCHEMA}", $REGRESS_LOG;
-	  die;
+	  return 0;
 	}
 
 	my $sql = "CREATE EXTENSION postgis";
 
 	if ( $OPT_UPGRADE_FROM ) {
 		if ( $OPT_UPGRADE_FROM =~ /^unpackaged(.*)/ ) {
-			prepare_spatial($1);
-			return;
+			return prepare_spatial($1);
 		}
 		$sql .= " VERSION '" . $OPT_UPGRADE_FROM . "'";
 	}
@@ -1445,9 +1595,9 @@ sub prepare_spatial_extensions
 	my $cmd = "psql $psql_opts -c \"". $sql . "\" $DB >> $REGRESS_LOG 2>&1";
 	my $rv = system($cmd);
 
-  if ( $rv ) {
-  	fail "Error encountered creating EXTENSION POSTGIS", $REGRESS_LOG;
-  	die;
+    if ( $rv ) {
+        fail "Error encountered creating EXTENSION POSTGIS", $REGRESS_LOG;
+        return 0;
 	}
 
 	if ( $OPT_WITH_TOPO )
@@ -1461,9 +1611,9 @@ sub prepare_spatial_extensions
 
  		$cmd = "psql $psql_opts -c \"" . $sql . "\" $DB >> $REGRESS_LOG 2>&1";
 		$rv = system($cmd);
-  	if ( $rv ) {
-  		fail "Error encountered creating EXTENSION POSTGIS_TOPOLOGY", $REGRESS_LOG;
-  		die;
+        if ( $rv ) {
+            fail "Error encountered creating EXTENSION POSTGIS_TOPOLOGY", $REGRESS_LOG;
+            return 0;
 		}
  	}
 
@@ -1478,9 +1628,9 @@ sub prepare_spatial_extensions
 
  		$cmd = "psql $psql_opts -c \"" . $sql . "\" $DB >> $REGRESS_LOG 2>&1";
 		$rv = system($cmd);
-  	if ( $rv ) {
-  		fail "Error encountered creating EXTENSION POSTGIS_TIGER_GEOCODER", $REGRESS_LOG;
-  		die;
+        if ( $rv ) {
+            fail "Error encountered creating EXTENSION POSTGIS_TIGER_GEOCODER", $REGRESS_LOG;
+            return 0;
 		}
  	}
 
@@ -1500,7 +1650,7 @@ sub prepare_spatial_extensions
 		$rv = system($cmd);
 		if ( $rv ) {
 			fail "Error encountered creating EXTENSION POSTGIS_RASTER", $REGRESS_LOG;
-			die;
+			return 0;
 		}
  	}
 
@@ -1526,7 +1676,7 @@ sub prepare_spatial_extensions
 			$rv = system($cmd);
 			if ( $rv ) {
 				fail "Error encountered creating EXTENSION POSTGIS_SFCGAL", $REGRESS_LOG;
-				die;
+				return 0;
 			}
 		}
 	}
@@ -1544,43 +1694,65 @@ sub prepare_spatial
 	print "Loading PostGIS into '${DB}' \n";
 
 	# Load postgis.sql into the database
-	load_sql_file("${scriptdir}/postgis.sql", 1);
-	load_sql_file("${scriptdir}/postgis_comments.sql", 0);
-	load_sql_file("${scriptdir}/spatial_ref_sys.sql", 0);
+	return 0 unless load_sql_file("${scriptdir}/postgis.sql", 1);
+	return 0 unless load_sql_file("${scriptdir}/postgis_comments.sql", 0);
+	return 0 unless load_sql_file("${scriptdir}/spatial_ref_sys.sql", 0);
+	if ( $OPT_LEGACY )
+	{
+		print "Loading legacy.sql from $scriptdir\n";
+		return 0 unless load_sql_file("${scriptdir}/legacy.sql", 0);
+	}
 
 	if ( $OPT_WITH_TOPO )
 	{
 		print "Loading Topology into '${DB}'\n";
-		load_sql_file("${scriptdir}/topology.sql", 1);
-		load_sql_file("${scriptdir}/topology_comments.sql", 0);
+		return 0 unless load_sql_file("${scriptdir}/topology.sql", 1);
+		return 0 unless load_sql_file("${scriptdir}/topology_comments.sql", 0);
 	}
 
 	if ( $OPT_WITH_RASTER )
 	{
 		print "Loading Raster into '${DB}'\n";
-		load_sql_file("${scriptdir}/rtpostgis.sql", 1);
-		load_sql_file("${scriptdir}/raster_comments.sql", 0);
+		return 0 unless load_sql_file("${scriptdir}/rtpostgis.sql", 1);
+		return 0 unless load_sql_file("${scriptdir}/raster_comments.sql", 0);
 	}
 
 	if ( $OPT_WITH_SFCGAL )
 	{
 		print "Loading SFCGAL into '${DB}'\n";
-		load_sql_file("${scriptdir}/sfcgal.sql", 1);
-		load_sql_file("${scriptdir}/sfcgal_comments.sql", 0);
+		return 0 unless load_sql_file("${scriptdir}/sfcgal.sql", 1);
+		return 0 unless load_sql_file("${scriptdir}/sfcgal_comments.sql", 0);
 	}
 
 	return 1;
 }
 
+sub upgrade_extension_sql
+{
+    my ($extname, $from, $to) = @_;
+
+    my $sql = '';
+    if ( "${libver}" eq "${to}" ) {
+        if ( semver_lessthan($to, "3.3.0") ) {
+            $sql .= "ALTER EXTENSION $extname UPDATE TO '${to}next'; ";
+        } else {
+            $sql .= "ALTER EXTENSION $extname UPDATE TO 'ANY'; ";
+        }
+    }
+    $sql .= "ALTER EXTENSION $extname UPDATE TO '${to}'";
+
+    return $sql;
+}
+
 sub package_extension_sql
 {
 	my ($extname, $extver) = @_;
 	my $sql;
 
 	if ( $pgvernum lt 130000 ) {
-		$sql = "CREATE EXTENSION ${extname} VERSION '${extver}' FROM unpackaged;";
+		$sql = "CREATE EXTENSION IF NOT EXISTS ${extname} VERSION '${extver}' FROM unpackaged;";
 	} else {
-		$sql = "CREATE EXTENSION ${extname} VERSION unpackaged;";
+		$sql = "CREATE EXTENSION IF NOT EXISTS ${extname} VERSION unpackaged;";
 		$sql .= "ALTER EXTENSION ${extname} UPDATE TO '${extver}'";
 	}
 	return $sql;
@@ -1589,31 +1761,34 @@ sub package_extension_sql
 # Upgrade an existing database (soft upgrade)
 sub upgrade_spatial
 {
-    print "Upgrading PostGIS in '${DB}' \n" ;
+    my $version = shift;
+    my $scriptdir = scriptdir($version);
+
+    print "Upgrading PostGIS in '${DB}' using scripts from $scriptdir\n" ;
 
     my $script = "${STAGED_SCRIPTS_DIR}/postgis_upgrade.sql";
     print "Upgrading core\n";
-    die unless load_sql_file($script, 1);
+    return 0 unless load_sql_file($script, 1);
 
     if ( $OPT_WITH_TOPO )
     {
         $script = "${STAGED_SCRIPTS_DIR}/topology_upgrade.sql";
         print "Upgrading topology\n";
-        die unless load_sql_file($script, 1);
+        return 0 unless load_sql_file($script, 1);
     }
 
     if ( $OPT_WITH_RASTER )
     {
         $script = "${STAGED_SCRIPTS_DIR}/rtpostgis_upgrade.sql";
         print "Upgrading raster\n";
-        die unless load_sql_file($script, 1);
+        return 0 unless load_sql_file($script, 1);
     }
 
     if ( $OPT_WITH_SFCGAL )
     {
         $script = "${STAGED_SCRIPTS_DIR}/sfcgal_upgrade.sql";
         print "Upgrading sfcgal\n";
-        die unless load_sql_file($script, 1);
+        return 0 unless load_sql_file($script, 1);
     }
 
     return 1;
@@ -1649,19 +1824,20 @@ sub upgrade_spatial_extensions
       $OPT_UPGRADE_TO = $defextver;
     }
 
-    my $nextver = $OPT_UPGRADE_TO ? "${OPT_UPGRADE_TO}" : "${libver}next";
+    my $nextver = $OPT_UPGRADE_TO ? "${OPT_UPGRADE_TO}" : "${libver}";
 
     if ( $upgrade_via_function )
     {
-      $sql = "SELECT postgis_extensions_upgrade()";
+        # TODO: pass ${nextver} if supported by OPT_UPGRADE_FROM ?
+        $sql = "SELECT postgis_extensions_upgrade()";
     }
     elsif ( $OPT_UPGRADE_FROM =~ /^unpackaged/ )
     {
-			$sql = package_extension_sql('postgis', ${nextver});
+        $sql = package_extension_sql('postgis', ${nextver});
     }
     else
     {
-      $sql = "ALTER EXTENSION postgis UPDATE TO '${nextver}'";
+        $sql = upgrade_extension_sql('postgis', ${libver}, ${nextver});
     }
 
     print "Upgrading PostGIS in '${DB}' using: ${sql}\n" ;
@@ -1671,7 +1847,7 @@ sub upgrade_spatial_extensions
     my $rv = system($cmd);
     if ( $rv ) {
       fail "Error encountered updating EXTENSION POSTGIS", $REGRESS_LOG;
-      die;
+      return 0;
     }
 
     # Handle raster split if coming from pre-split extension
@@ -1691,20 +1867,13 @@ sub upgrade_spatial_extensions
       my $rv = system($cmd);
       if ( $rv ) {
         fail "Error encountered creating EXTENSION POSTGIS_RASTER from unpackaged on upgrade", $REGRESS_LOG;
-        die;
+        return 0;
       }
 
       if ( ! $OPT_WITH_RASTER )
       {
-        print "Dropping PostGIS Raster in '${DB}' using: ${sql}\n" ;
-
-        $sql = "DROP EXTENSION postgis_raster";
-        $cmd = "psql $psql_opts -c \"" . $sql . "\" $DB >> $REGRESS_LOG 2>&1";
-        $rv = system($cmd);
-        if ( $rv ) {
-          fail "Error encountered dropping EXTENSION POSTGIS_RASTER on upgrade", $REGRESS_LOG;
-          die;
-        }
+        print "Marking PostGIS Raster as present for later drop\n";
+        $OPT_WITH_RASTER=1
       }
     }
 
@@ -1716,10 +1885,13 @@ sub upgrade_spatial_extensions
 
     if ( $OPT_WITH_RASTER && has_split_raster_ext(${nextver}) )
     {
-        my $sql = "ALTER EXTENSION postgis_raster UPDATE TO '${nextver}'";
+        my $sql;
 
         if ( $OPT_UPGRADE_FROM =~ /^unpackaged/ ) {
-					$sql = package_extension_sql('postgis_raster', ${nextver});
+            $sql = package_extension_sql('postgis_raster', ${nextver});
+        }
+        else {
+            $sql = upgrade_extension_sql('postgis_raster', ${libver}, ${nextver});
         }
 
         print "Upgrading PostGIS Raster in '${DB}' using: ${sql}\n" ;
@@ -1728,54 +1900,57 @@ sub upgrade_spatial_extensions
         my $rv = system($cmd);
         if ( $rv ) {
           fail "Error encountered updating EXTENSION POSTGIS_RASTER", $REGRESS_LOG;
-          die;
+          return 0;
         }
     }
 
     if ( $OPT_WITH_TOPO )
     {
-      my $sql = "ALTER EXTENSION postgis_topology UPDATE TO '${nextver}'";
+        my $sql;
 
-			if ( $OPT_UPGRADE_FROM =~ /^unpackaged/ ) {
-				$sql = package_extension_sql('postgis_topology', ${nextver});
-			}
+        if ( $OPT_UPGRADE_FROM =~ /^unpackaged/ ) {
+            $sql = package_extension_sql('postgis_topology', ${nextver});
+        }
+        else {
+            $sql = upgrade_extension_sql('postgis_topology', ${libver}, ${nextver});
+        }
 
-      print "Upgrading PostGIS Topology in '${DB}' using: ${sql}\n";
+        print "Upgrading PostGIS Topology in '${DB}' using: ${sql}\n";
 
-      my $cmd = "psql $psql_opts -c \"" . $sql . "\" $DB >> $REGRESS_LOG 2>&1";
-      my $rv = system($cmd);
-      if ( $rv ) {
-        fail "Error encountered updating EXTENSION POSTGIS_TOPOLOGY", $REGRESS_LOG;
-        die;
-      }
+        my $cmd = "psql $psql_opts -c \"" . $sql . "\" $DB >> $REGRESS_LOG 2>&1";
+        my $rv = system($cmd);
+        if ( $rv ) {
+            fail "Error encountered updating EXTENSION POSTGIS_TOPOLOGY", $REGRESS_LOG;
+            return 0;
+        }
     }
 
     if ( $OPT_WITH_SFCGAL )
     {
-			my $sql;
+        my $sql;
 
-			if ( $OPT_UPGRADE_FROM =~ /^unpackaged/ ) {
-				$sql = package_extension_sql('postgis_sfcgal', ${nextver});
-			}
-			elsif ( $OPT_UPGRADE_FROM && semver_lessthan($OPT_UPGRADE_FROM, "2.2.0") )
-			{
-				print "NOTICE: installing SFCGAL extension on upgrade "
-						. "as it was not available in version '$OPT_UPGRADE_FROM'\n";
-				$sql = "CREATE EXTENSION postgis_sfcgal VERSION '${nextver}'";
-			}
-			else
-			{
-				$sql = "ALTER EXTENSION postgis_sfcgal UPDATE TO '${nextver}'";
-			}
-      $cmd = "psql $psql_opts -c \"" . $sql . "\" $DB >> $REGRESS_LOG 2>&1";
+        if ( $OPT_UPGRADE_FROM =~ /^unpackaged/ ) {
+            $sql = package_extension_sql('postgis_sfcgal', ${nextver});
+        }
+        elsif ( $OPT_UPGRADE_FROM && semver_lessthan($OPT_UPGRADE_FROM, "2.2.0") )
+        {
+            print "NOTICE: installing SFCGAL extension on upgrade "
+                . "as it was not available in version '$OPT_UPGRADE_FROM'\n";
+            $sql = "CREATE EXTENSION postgis_sfcgal VERSION '${nextver}'";
+        }
+        else
+        {
+            $sql = upgrade_extension_sql('postgis_sfcgal', ${libver}, ${nextver});
+        }
+        $cmd = "psql $psql_opts -c \"" . $sql . "\" $DB >> $REGRESS_LOG 2>&1";
 
-			print "Upgrading PostGIS SFCGAL in '${DB}' using: ${sql}\n" ;
+        print "Upgrading PostGIS SFCGAL in '${DB}' using: ${sql}\n" ;
 
-      $rv = system($cmd);
-      if ( $rv ) {
-        fail "Error encountered creating EXTENSION POSTGIS_SFCGAL", $REGRESS_LOG;
-        die;
-      }
+        $rv = system($cmd);
+        if ( $rv ) {
+            fail "Error encountered creating EXTENSION POSTGIS_SFCGAL", $REGRESS_LOG;
+            return 0;
+        }
     }
 
     return 1;
@@ -1797,6 +1972,10 @@ sub drop_spatial
 	{
 		load_sql_file("${STAGED_SCRIPTS_DIR}/uninstall_sfcgal.sql");
 	}
+	if ( $OPT_LEGACY )
+	{
+		load_sql_file("${STAGED_SCRIPTS_DIR}/uninstall_legacy.sql");
+	}
 	load_sql_file("${STAGED_SCRIPTS_DIR}/uninstall_postgis.sql");
 
   	return 1;
@@ -1806,7 +1985,6 @@ sub drop_spatial_extensions
 {
     # ON_ERROR_STOP is used by psql to return non-0 on an error
     my $psql_opts="--no-psqlrc --variable ON_ERROR_STOP=true";
-    my $ok = 1;
     my ($cmd, $rv);
 
     if ( $OPT_WITH_TOPO )
@@ -1816,21 +1994,30 @@ sub drop_spatial_extensions
         #       http://trac.osgeo.org/postgis/ticket/2138
         $cmd = "psql $psql_opts -c \"DROP EXTENSION postgis_topology; DROP SCHEMA topology;\" $DB >> $REGRESS_LOG 2>&1";
         $rv = system($cmd);
-      	$ok = 0 if $rv;
+        if ( $rv ) {
+            fail "Error encountered dropping EXTENSION postgis_topology", $REGRESS_LOG;
+            return 0;
+        }
     }
 
     if ( $OPT_WITH_SFCGAL )
     {
         $cmd = "psql $psql_opts -c \"DROP EXTENSION postgis_sfcgal;\" $DB >> $REGRESS_LOG 2>&1";
         $rv = system($cmd);
-        $ok = 0 if $rv;
+        if ( $rv ) {
+            fail "Error encountered dropping EXTENSION postgis_sfcgal", $REGRESS_LOG;
+            return 0;
+        }
     }
 
     if ( $OPT_WITH_RASTER )
     {
         $cmd = "psql $psql_opts -c \"DROP EXTENSION IF EXISTS postgis_raster;\" $DB >> $REGRESS_LOG 2>&1";
         $rv = system($cmd);
-      	$ok = 0 if $rv;
+        if ( $rv ) {
+            fail "Error encountered dropping EXTENSION postgis_raster", $REGRESS_LOG;
+            return 0;
+        }
     }
     if ( $OPT_WITH_TIGER )
     {
@@ -1840,17 +2027,21 @@ sub drop_spatial_extensions
                 DROP SCHEMA IF EXISTS tiger_data;
                 \" $DB >> $REGRESS_LOG 2>&1";
         $rv = system($cmd);
-      	$ok = 0 if $rv;
+      	return 0 if $rv;
+        if ( $rv ) {
+            fail "Error encountered dropping EXTENSION postgis_tiger_geocoder", $REGRESS_LOG;
+            return 0;
+        }
     }
 
     $cmd = "psql $psql_opts -c \"DROP EXTENSION postgis\" $DB >> $REGRESS_LOG 2>&1";
     $rv = system($cmd);
     if ( $rv ) {
         fail "Error encountered dropping EXTENSION POSTGIS", $REGRESS_LOG;
-        die;
+      	return 0;
     }
 
-    return $ok;
+    return 1;
 }
 
 # Drop spatial from an existing database
@@ -1877,6 +2068,29 @@ sub uninstall_spatial
 	if ( $OBJ_COUNT_POST != $OBJ_COUNT_PRE )
 	{
 		fail("Object count pre-install ($OBJ_COUNT_PRE) != post-uninstall ($OBJ_COUNT_POST)");
+
+        if ( $OPT_UPGRADE_FROM )
+        {
+            my $fromversion = $OPT_UPGRADE_FROM;
+            $fromversion =~ s/unpackaged//;
+            print
+                "\n-------------------------------------------------\n",
+                "Need to add these to an after_upgrade.sql script?",
+                "\n-------------------------------------------------\n",
+                sql("
+SELECT format(
+    'SELECT _postgis_drop_function_by_identity(%L, %L, %L);',
+    proname,
+    pg_catalog.pg_get_function_identity_arguments(oid),
+    '$fromversion'
+)
+FROM pg_proc
+WHERE pronamespace = '${OPT_SCHEMA}'::regnamespace
+ORDER BY 1;
+                "),
+                "\n-------------------------------------------------\n",
+        }
+
 		return 0;
 	}
 
@@ -1884,56 +2098,82 @@ 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 $rv;
+    my $DBDUMP = $TMPDIR . '/' . $DB . '.dump';
 
-	print "Dumping and restoring database '${DB}'\n";
-
-  $rv = system("pg_dump -Fc -f${DBDUMP} ${DB} >> $REGRESS_LOG 2>&1");
-  if ( $rv ) {
-    fail("Could not dump ${DB}", $REGRESS_LOG);
-		die;
-  }
-
-  $rv = system("dropdb ${DB} >> $REGRESS_LOG 2>&1");
-  if ( $rv ) {
-    fail("Could not drop ${DB}", $REGRESS_LOG);
-		die;
-  }
-
-  $rv = create_db();
-  if ( $rv ) {
-    fail("Could not create ${DB}", $REGRESS_LOG);
-		die;
-  }
-
-  $rv = system("pg_restore -d ${DB} ${DBDUMP} >> $REGRESS_LOG 2>&1");
-  if ( $rv ) {
-    fail("Could not restore ${DB}", $REGRESS_LOG);
-    die;
-  }
-
-  if ( $OPT_WITH_TOPO )
-  {
-    # We need to re-add "topology" to the search_path as it is lost
-    # on dump/reload, see https://trac.osgeo.org/postgis/ticket/3454
-    my $psql_opts = "--no-psqlrc --variable ON_ERROR_STOP=true";
-    my $cmd = "psql $psql_opts -c \"SELECT topology.AddToSearchPath('topology')\" $DB >> $REGRESS_LOG 2>&1";
-    $rv = system($cmd);
-    if ( $rv ) {
-      fail("Error encountered adding topology to search path after restore", $REGRESS_LOG);
-      die;
+    foreach my $hook (@OPT_HOOK_BEFORE_DUMP)
+    {
+        print "Running before-dump-script $hook\n";
+        die unless load_sql_file($hook, 1);
     }
-  }
 
-  unlink($DBDUMP);
+    print "Dumping database '${DB}'\n";
 
-  return 1;
+    $rv = system("pg_dump -Fc -f${DBDUMP} ${DB} >> $REGRESS_LOG 2>&1");
+    if ( $rv ) {
+        fail("Could not dump ${DB}", $REGRESS_LOG);
+        return undef;
+    }
+    return ${DBDUMP};
 }
 
+# Restore the dump file passed as first argument
+sub restore_db
+{
+    my $rv;
+    my $DBDUMP = shift;
+    my $ext_dump = $OPT_EXTENSIONS && $OPT_UPGRADE_FROM !~ /^unpackaged/;
+
+    # If dump is not from extension-based database
+    # we need to prepare the target
+    unless ( $ext_dump )
+    {
+		if ( $OPT_UPGRADE_FROM =~ /^unpackaged(.*)/ ) {
+			die unless prepare_spatial($1);
+		} else {
+			die unless prepare_spatial();
+        }
+    }
+
+    if ( $ext_dump ) {
+        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);
+    }
+    if ( $rv ) {
+        fail("Could not restore ${DB}", $REGRESS_LOG);
+        return 0;
+    }
+
+    if ( $OPT_WITH_TOPO )
+    {
+        # We need to re-add "topology" to the search_path as it is lost
+        # on dump/reload, see https://trac.osgeo.org/postgis/ticket/3454
+        my $psql_opts = "--no-psqlrc --variable ON_ERROR_STOP=true";
+        my $cmd = "psql $psql_opts -c \"SELECT topology.AddToSearchPath('topology')\" $DB >> $REGRESS_LOG 2>&1";
+        $rv = system($cmd);
+        if ( $rv ) {
+            fail("Error encountered adding topology to search path after restore", $REGRESS_LOG);
+            return 0;
+        }
+    }
+
+    foreach my $hook (@OPT_HOOK_AFTER_RESTORE)
+    {
+        print "Running after-restore-script $hook\n";
+        die unless load_sql_file($hook, 1);
+    }
+
+    return 1;
+}
+
+# Dump and restore the database
 sub diff
 {
 	my ($expected_file, $obtained_file) = @_;

commit 26dc67c7f6f17ee9f05a23f520ef541ef7c95188
Author: Sandro Santilli <strk at kbt.io>
Date:   Fri May 5 16:16:27 2023 +0200

    Tolerate 250ms elapsed time for ST_Buffer interruption
    
    Hopefully works on more bots

diff --git a/regress/core/interrupt_buffer.sql b/regress/core/interrupt_buffer.sql
index c0d6a4fb5..77290e0d2 100644
--- a/regress/core/interrupt_buffer.sql
+++ b/regress/core/interrupt_buffer.sql
@@ -35,7 +35,7 @@ SET statement_timeout TO 100;
 select ST_Buffer(g,100) from _inputs WHERE id = 1;
 --( select (st_dumppoints(st_buffer(st_makepoint(0,0),10000,100000))).geom g) foo;
 -- it may take some more to interrupt st_buffer, see
-SELECT _timecheck('buffer', '200ms');
+SELECT _timecheck('buffer', '250ms');
 
 -- Not affected by old timeout
 SELECT '1', ST_NPoints(ST_Buffer('POINT(4 0)'::geometry, 2, 1));

commit 8131a1d0b33ce2eb725a45f368bed67a732d8a7c
Author: Sandro Santilli <strk at kbt.io>
Date:   Thu Oct 26 10:45:56 2023 +0200

    Remove duplicated AddToSearchPath implementation
    
    Use a common one, in new libpgcommon/sql directory.
    
    References #5525 in 3.3 branch

diff --git a/.gitignore b/.gitignore
index b71e14cda..2f02ecfd6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -44,6 +44,7 @@ doc/raster_gardentest_*.sql
 doc/tiger_geocoder_comments.sql
 doc/topology_comments.sql
 extensions/Makefile
+extensions/postgis_extension_helper.sql
 extensions/address_standardizer/Makefile
 extensions/address_standardizer/mk-st-regexp
 extensions/address_standardizer/address_standardizer--*.sql
diff --git a/extensions/Makefile.in b/extensions/Makefile.in
index 0c48b615e..e984e4b06 100644
--- a/extensions/Makefile.in
+++ b/extensions/Makefile.in
@@ -9,6 +9,13 @@
 #
 #############################################################################
 
+srcdir = @srcdir@
+SQLPP = @SQLPP@
+PERL=@PERL@
+VPATH := $(srcdir)
+
+SCRIPTS_BUILT = postgis_extension_helper.sql
+
 SUBDIRS = postgis
 SUBDIRS += postgis_tiger_geocoder
 ifeq (@RASTER@,raster)
@@ -31,12 +38,23 @@ all clean distclean install uninstall installcheck:
 		$(MAKE) -C "$${DIR}" $@ || exit 1; \
 	done
 
+all: $(SCRIPTS_BUILT)
+
 distclean: distclean-local
 
 distclean-local:
 	rm -f Makefile
 
-
 check check-unit check-regress:
 	@echo "Nothing to check"
 
+# Generate any .sql file from .sql.in files by running them through the SQL pre-processor
+%.sql: %.sql.in
+	$(SQLPP) -I at top_builddir@/postgis -I at top_srcdir@ $< > $@.tmp
+	grep -v '^#' $@.tmp > $@;
+	rm -f $@.tmp
+
+clean: clean-local
+
+clean-local:
+	rm -f $(SCRIPTS_BUILT)
diff --git a/extensions/postgis_extension_helper.sql b/extensions/postgis_extension_helper.sql.in
similarity index 75%
rename from extensions/postgis_extension_helper.sql
rename to extensions/postgis_extension_helper.sql.in
index a984ecb92..632385133 100644
--- a/extensions/postgis_extension_helper.sql
+++ b/extensions/postgis_extension_helper.sql.in
@@ -102,60 +102,4 @@ $$
 LANGUAGE plpgsql VOLATILE;
 
 CREATE FUNCTION postgis_extension_AddToSearchPath(a_schema_name text)
-RETURNS text
-AS
-$$
-DECLARE
-	var_result text;
-	var_cur_search_path text;
-BEGIN
-
-	WITH settings AS (
-		SELECT pg_catalog.unnest(setconfig) config
-		FROM pg_catalog.pg_db_role_setting
-		WHERE setdatabase OPERATOR(pg_catalog.=) (
-			SELECT oid
-			FROM pg_catalog.pg_database
-			WHERE datname OPERATOR(pg_catalog.=) pg_catalog.current_database()
-		) and setrole OPERATOR(pg_catalog.=) 0
-	)
-	SELECT pg_catalog.regexp_replace(config, '^search_path=', '')
-	FROM settings WHERE config like 'search_path=%'
-	INTO var_cur_search_path;
-
-	RAISE NOTICE 'cur_search_path from pg_db_role_setting is %', var_cur_search_path;
-
-	IF var_cur_search_path IS NULL THEN
-		SELECT setting
-		INTO var_cur_search_path
-		FROM pg_catalog.pg_file_settings
-		WHERE name OPERATOR(pg_catalog.=) 'search_path' AND applied;
-
-		RAISE NOTICE 'cur_search_path from pg_file_settings is %', var_cur_search_path;
-	END IF;
-
-	IF var_cur_search_path IS NULL THEN
-		SELECT boot_val
-		INTO var_cur_search_path
-		FROM pg_catalog.pg_settings
-		WHERE name OPERATOR(pg_catalog.=) 'search_path';
-
-		RAISE NOTICE 'cur_search_path from pg_settings is %', var_cur_search_path;
-	END IF;
-
-	IF var_cur_search_path LIKE '%' OPERATOR(pg_catalog.||) pg_catalog.quote_ident(a_schema_name) OPERATOR(pg_catalog.||) '%' THEN
-		var_result := a_schema_name OPERATOR(pg_catalog.||) ' already in database search_path';
-	ELSE
-		var_cur_search_path := var_cur_search_path OPERATOR(pg_catalog.||) ', '
-                       OPERATOR(pg_catalog.||) pg_catalog.quote_ident(a_schema_name);
-		EXECUTE 'ALTER DATABASE ' OPERATOR(pg_catalog.||) pg_catalog.quote_ident(pg_catalog.current_database())
-                             OPERATOR(pg_catalog.||) ' SET search_path = ' OPERATOR(pg_catalog.||) var_cur_search_path;
-		var_result := a_schema_name OPERATOR(pg_catalog.||) ' has been added to end of database search_path ';
-	END IF;
-
-	EXECUTE 'SET search_path = ' OPERATOR(pg_catalog.||) var_cur_search_path;
-
-  RETURN var_result;
-END
-$$
-LANGUAGE 'plpgsql' VOLATILE STRICT;
+#include "libpgcommon/sql/AddToSearchPath.sql.inc"
diff --git a/topology/sql/manage/ManageHelper.sql.in b/libpgcommon/sql/AddToSearchPath.sql.inc
similarity index 72%
copy from topology/sql/manage/ManageHelper.sql.in
copy to libpgcommon/sql/AddToSearchPath.sql.inc
index eb9da2d02..2499bfa91 100644
--- a/topology/sql/manage/ManageHelper.sql.in
+++ b/libpgcommon/sql/AddToSearchPath.sql.inc
@@ -1,29 +1,18 @@
--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
---
--- PostGIS - Spatial Types for PostgreSQL
--- http://www.postgis.net
---
--- Copyright (C) 2011 Regina Obe <lr at pcorp.us>
---
--- This is free software; you can redistribute and/or modify it under
--- the terms of the GNU General Public Licence. See the COPYING file.
---
--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+/*
 
---{
---  AddToSearchPath(schema_name)
---
--- Adds the specified schema to the database search path
--- if it is not already in the database search path
--- This is a helper function for upgrade/install
--- We may want to move this function as a generic helper
-CREATE OR REPLACE FUNCTION topology.AddToSearchPath(a_schema_name varchar)
+  Common body for a function to add a schema to the search path
+  Use as follows:
+
+    CREATE OR REPLACE FUNCTION someName(someARg text)
+    #include "libpgcommon/sql/AddToSearchPath.sql.inc"
+*/
 RETURNS text
 AS
-$$
+$BODY$
 DECLARE
 	var_result text;
 	var_cur_search_path text;
+	a_schema_name text := $1;
 BEGIN
 	WITH settings AS (
 		SELECT pg_catalog.unnest(setconfig) config
@@ -72,7 +61,6 @@ BEGIN
 
   RETURN var_result;
 END
-$$
+$BODY$
 LANGUAGE 'plpgsql' VOLATILE STRICT;
 
---} AddToSearchPath
diff --git a/topology/Makefile.in b/topology/Makefile.in
index 6bd085fe3..6270b701f 100644
--- a/topology/Makefile.in
+++ b/topology/Makefile.in
@@ -104,7 +104,7 @@ endif
 
 # Generate any .sql file from .sql.in files by running them through the SQL pre-processor
 %.sql: %.sql.in
-	$(SQLPP) -I at top_builddir@/postgis $< | grep -v '^#' | \
+	$(SQLPP) -I at top_builddir@/postgis -I at top_srcdir@ $< | grep -v '^#' | \
 	$(PERL) -lpe "s'MODULE_PATHNAME'\$(MODULEPATH)'g" > $@
 
 #Generate upgrade script by stripping things that can't be reinstalled
diff --git a/topology/sql/manage/ManageHelper.sql.in b/topology/sql/manage/ManageHelper.sql.in
index eb9da2d02..4c912317b 100644
--- a/topology/sql/manage/ManageHelper.sql.in
+++ b/topology/sql/manage/ManageHelper.sql.in
@@ -18,61 +18,5 @@
 -- This is a helper function for upgrade/install
 -- We may want to move this function as a generic helper
 CREATE OR REPLACE FUNCTION topology.AddToSearchPath(a_schema_name varchar)
-RETURNS text
-AS
-$$
-DECLARE
-	var_result text;
-	var_cur_search_path text;
-BEGIN
-	WITH settings AS (
-		SELECT pg_catalog.unnest(setconfig) config
-		FROM pg_catalog.pg_db_role_setting
-		WHERE setdatabase OPERATOR(pg_catalog.=) (
-			SELECT oid
-			FROM pg_catalog.pg_database
-			WHERE datname OPERATOR(pg_catalog.=) pg_catalog.current_database()
-		) and setrole OPERATOR(pg_catalog.=) 0
-	)
-	SELECT pg_catalog.regexp_replace(config, '^search_path=', '')
-	FROM settings WHERE config like 'search_path=%'
-	INTO var_cur_search_path;
-
-	RAISE NOTICE 'cur_search_path from pg_db_role_setting is %', var_cur_search_path;
-
-	IF var_cur_search_path IS NULL THEN
-		SELECT setting
-		INTO var_cur_search_path
-		FROM pg_catalog.pg_file_settings
-		WHERE name OPERATOR(pg_catalog.=) 'search_path' AND applied;
-
-		RAISE NOTICE 'cur_search_path from pg_file_settings is %', var_cur_search_path;
-	END IF;
-
-	IF var_cur_search_path IS NULL THEN
-		SELECT boot_val
-		INTO var_cur_search_path
-		FROM pg_catalog.pg_settings
-		WHERE name OPERATOR(pg_catalog.=) 'search_path';
-
-		RAISE NOTICE 'cur_search_path from pg_settings is %', var_cur_search_path;
-	END IF;
-
-	IF var_cur_search_path LIKE '%' OPERATOR(pg_catalog.||) pg_catalog.quote_ident(a_schema_name) OPERATOR(pg_catalog.||) '%' THEN
-		var_result := a_schema_name OPERATOR(pg_catalog.||) ' already in database search_path';
-	ELSE
-		var_cur_search_path := var_cur_search_path OPERATOR(pg_catalog.||) ', '
-                       OPERATOR(pg_catalog.||) pg_catalog.quote_ident(a_schema_name);
-		EXECUTE 'ALTER DATABASE ' OPERATOR(pg_catalog.||) pg_catalog.quote_ident(pg_catalog.current_database())
-                             OPERATOR(pg_catalog.||) ' SET search_path = ' OPERATOR(pg_catalog.||) var_cur_search_path;
-		var_result := a_schema_name OPERATOR(pg_catalog.||) ' has been added to end of database search_path ';
-	END IF;
-
-	EXECUTE 'SET search_path = ' OPERATOR(pg_catalog.||) var_cur_search_path;
-
-  RETURN var_result;
-END
-$$
-LANGUAGE 'plpgsql' VOLATILE STRICT;
-
+#include "libpgcommon/sql/AddToSearchPath.sql.inc"
 --} AddToSearchPath

commit f03f601589b3ef6b9b35cf58117f39d5c0710d4e
Author: Sandro Santilli <strk at kbt.io>
Date:   Thu Oct 26 14:44:50 2023 +0200

    [woodie] Share clone step for regress workflow

diff --git a/.woodpecker/regress.yml b/.woodpecker/regress.yml
index aa4d55983..167670125 100644
--- a/.woodpecker/regress.yml
+++ b/.woodpecker/regress.yml
@@ -1,14 +1,39 @@
-matrix:
-  PG_VERSION:
-    - 15
-    - 14
-    - 12
-    - 11
+variables:
+  test-image: &test-image docker.osgeo.org/postgis/build-test:trisquel3
+
+clone:
+  clone:
+    image: woodpeckerci/plugin-git
+    depth: 50
 
 steps:
-  build:
-    group: build
-    image: docker.osgeo.org/postgis/build-test:trisquel3
+
+  autogen:
+    image: *test-image
+    pull: true
     commands:
-      - sh autogen.sh
-      - PGVER=${PG_VERSION} sh ci/dronie/postgis_regress.sh
+      - ./autogen.sh
+
+  regress-pg11:
+    image: *test-image
+    group: build
+    commands:
+      - PGVER=11 sh ci/dronie/postgis_regress.sh
+
+  regress-pg12:
+    image: *test-image
+    group: build
+    commands:
+      - PGVER=12 sh ci/dronie/postgis_regress.sh
+
+  regress-pg14:
+    image: *test-image
+    group: build
+    commands:
+      - PGVER=15 sh ci/dronie/postgis_regress.sh
+
+  regress-pg15:
+    image: *test-image
+    group: build
+    commands:
+      - PGVER=15 sh ci/dronie/postgis_regress.sh

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

Summary of changes:
 .gitignore                                         |   1 +
 .woodpecker/regress.yml                            |  45 +-
 extensions/Makefile.in                             |  20 +-
 ..._helper.sql => postgis_extension_helper.sql.in} |  58 +-
 .../sql/AddToSearchPath.sql.inc                    |  32 +-
 regress/core/interrupt_buffer.sql                  |   2 +-
 regress/run_test.pl                                | 684 ++++++++++++++-------
 topology/Makefile.in                               |   2 +-
 topology/sql/manage/ManageHelper.sql.in            |  58 +-
 9 files changed, 531 insertions(+), 371 deletions(-)
 rename extensions/{postgis_extension_helper.sql => postgis_extension_helper.sql.in} (75%)
 copy topology/sql/manage/ManageHelper.sql.in => libpgcommon/sql/AddToSearchPath.sql.inc (72%)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list