[postgis-tickets] r17488 - Use CREATE OR REPLACE AGGREGATE for PG12+
Raul
raul at rmr.ninja
Tue Jun 11 03:18:22 PDT 2019
Author: algunenano
Date: 2019-06-11 03:18:21 -0700 (Tue, 11 Jun 2019)
New Revision: 17488
Modified:
trunk/NEWS
trunk/utils/postgis_proc_upgrade.pl
Log:
Use CREATE OR REPLACE AGGREGATE for PG12+
References #4352
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2019-06-10 22:12:00 UTC (rev 17487)
+++ trunk/NEWS 2019-06-11 10:18:21 UTC (rev 17488)
@@ -18,6 +18,7 @@
- #4198, Add ST_ConstrainedDelaunayTriangles SFCGAL function (Darafei
Praliaskouski)
- #4414, Include version number in address_standardizer lib (Raúl Marín)
+ - #4352, Use CREATE OR REPLACE AGGREGATE for PG12+ (Raúl Marín)
PostGIS 3.0.0alpha1
2019/05/26
@@ -159,6 +160,7 @@
(Darafei Praliaskouski)
- #4422, Modernize Python 2 code to get ready for Python 3 (Christian Clauss)
- #4383, Fix undefined behaviour in implicit conversions (Raúl Marín)
+ - #4352, Use CREATE OR REPLACE AGGREGATE for PG12+ (Raúl Marín)
PostGIS 2.5.0
Modified: trunk/utils/postgis_proc_upgrade.pl
===================================================================
--- trunk/utils/postgis_proc_upgrade.pl 2019-06-10 22:12:00 UTC (rev 17487)
+++ trunk/utils/postgis_proc_upgrade.pl 2019-06-11 10:18:21 UTC (rev 17488)
@@ -234,6 +234,7 @@
}
# This code handles aggregates by dropping and recreating them.
+ # For PG12 use REPLACE instead
if ( /^create aggregate\s+([^(]+)\s*\(/i )
{
my $aggname = $1;
@@ -258,12 +259,21 @@
if ( ! $last_updated ) {
die "ERROR: no last updated info for aggregate '${aggsig}'\n";
}
+
+ my $pg12_def = $def =~ s/CREATE AGGREGATE/CREATE OR REPLACE AGGREGATE/r;
+ if ($pg12_def eq "")
+ {
+ $pg12_def = "RAISE EXCEPTION 'Could not parse AGGREGATE'"
+ }
print "-- Aggregate ${aggsig} -- LastUpdated: ${last_updated}\n";
print <<"EOF";
DO LANGUAGE 'plpgsql'
\$postgis_proc_upgrade\$
BEGIN
- IF $last_updated > version_from_num OR (
+ IF current_setting('server_version_num')::integer >= 120000
+ THEN
+ EXECUTE \$postgis_proc_upgrade_parsed_def\$ $pg12_def \$postgis_proc_upgrade_parsed_def\$;
+ ELSIF $last_updated > version_from_num OR (
$last_updated = version_from_num AND version_from_isdev
) FROM _postgis_upgrade_info
THEN
More information about the postgis-tickets
mailing list