[postgis-tickets] [SCM] PostGIS branch master updated. 3.1.0rc1-64-g88b689c

git at osgeo.org git at osgeo.org
Tue Feb 9 06:24:24 PST 2021


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  88b689c8f1d3e72dde2e3ee534d48b514ccf63f3 (commit)
      from  937eaae4abd88811e9bd8ba4270471cc00f3bb3b (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 88b689c8f1d3e72dde2e3ee534d48b514ccf63f3
Author: Sandro Santilli <strk at kbt.io>
Date:   Fri Feb 5 16:24:06 2021 +0100

    Allows uninstalling when having functions returning table types.
    
    Drops tables at the end, before schemas
    Drops table triggers before dropping functions
    
    References #4841

diff --git a/utils/create_undef.pl b/utils/create_undef.pl
index d98ccce..4036801 100755
--- a/utils/create_undef.pl
+++ b/utils/create_undef.pl
@@ -4,6 +4,7 @@
 # PostGIS - Spatial Types for PostgreSQL
 # http://postgis.net
 #
+# Copyright (C) 2021 Sandro Santilli <strk at kbt.io>
 # Copyright (C) 2011 OpenGeo.org
 # Copyright (C) 2009-2010 Paul Ramsey <pramsey at opengeo.org>
 # Copyright (C) 2001-2005 Refractions Research Inc.
@@ -23,14 +24,18 @@ eval "exec perl -w $0 $@"
 ($#ARGV == 1) || die "Usage: perl create_undef.pl <postgis.sql> <pgsql_version #>\nCreates a new SQL script to delete all the PostGIS functions.\n";
 
 # drops are in the following order:
-#	1. Indexing system stuff
-#	2. Meta datatables <not done>
-#	3. Aggregates
-#	3. Casts
-#	4. Operators
-#	5. Functions
-#	6. Types
-#	7. Tables
+# - Views
+# - Aggregates
+# - Operator classes and families
+# - Operators
+# - Casts
+# - Table triggers
+# - Functions except those needed for types definition
+# - Types (if unused in column types)
+# - Support functions
+# - Functions needed for types definition
+# - Tables
+# - Schemas
 
 my @aggs = ();
 my @casts = ();
@@ -44,6 +49,7 @@ my @opcs = ();
 my @views = ();
 my @tables = ();
 my @schemas = ();
+my @triggers = ();
 
 my $version = $ARGV[1];
 
@@ -103,6 +109,30 @@ while( my $line = <INPUT>)
 	elsif ($line =~ /^create schema \s*([\w\.]+)/i) {
 		push (@schemas, $1);
 	}
+	elsif ($line =~ /^create trigger \s*([\w\.]+)/i) {
+		my $trignam = $1;
+		my $trigtab = undef;
+		#print STDERR "XXX trignam: $trignam\n";
+		while ( not defined($trigtab) )
+		{
+			#print STDERR "XXX subline: $line";
+			if ( $line =~ /ON\s*([\w\.]*)/i )
+			{
+				$trigtab = $1;
+				#print STDERR "XXX trigtab: $trigtab\n";
+				last;
+			}
+			last if ( $line =~ /;\s*$/ );
+			$line = <INPUT>;
+		}
+		if ( not defined($trigtab) )
+		{
+			die "Couldn't parse CREATE TRIGGER $trignam (could not find target table)\n";
+		}
+		my $trigdef = $trignam . ' ON ' . $trigtab;
+		#print STDERR "XXX trigdef: $trigdef\n";
+		push (@triggers, $trigdef);
+	}
 	elsif ( $line =~ /^create operator class (\w+)/i ) {
 		my $opcname = $1;
 		my $am = '';
@@ -161,16 +191,6 @@ foreach my $view (@views)
 	print "DROP VIEW IF EXISTS $view;\n";
 }
 
-print "-- Drop all tables.\n";
-# we reverse table definitions so foreign key constraints
-# are more likely not to get in our way
- at tables = reverse(@tables);
-foreach my $table (@tables)
-{
-	print "DROP TABLE IF EXISTS $table;\n";
-}
-
-
 print "-- Drop all aggregates.\n";
 foreach my $agg (@aggs)
 {
@@ -222,6 +242,12 @@ foreach my $cast (@casts)
 	}
 }
 
+print "-- Drop all table triggers.\n";
+foreach my $tr (@triggers)
+{
+	print "DROP TRIGGER IF EXISTS $tr;\n";
+}
+
 print "-- Drop all functions except " . (keys %type_funcs) . " needed for type definition.\n";
 
 foreach my $fn (@funcs)
@@ -325,6 +351,16 @@ foreach my $fn (@type_funcs)
 	}
 }
 
+print "-- Drop all tables.\n";
+# we reverse table definitions so foreign key constraints
+# are more likely not to get in our way
+ at tables = reverse(@tables);
+foreach my $table (@tables)
+{
+	print "DROP TABLE IF EXISTS $table;\n";
+}
+
+
 print "-- Drop all schemas.\n";
 if (@schemas)
 {

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

Summary of changes:
 utils/create_undef.pl | 72 ++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 54 insertions(+), 18 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list