[postgis-tickets] r17759 - Add support for extension sequences in create_unpackaged.pl

Sandro Santilli strk at kbt.io
Thu Aug 22 07:59:53 PDT 2019


Author: strk
Date: 2019-08-22 07:59:53 -0700 (Thu, 22 Aug 2019)
New Revision: 17759

Modified:
   trunk/utils/create_unpackaged.pl
Log:
Add support for extension sequences in create_unpackaged.pl

Should fix topology dump-restore
References #4488

Modified: trunk/utils/create_unpackaged.pl
===================================================================
--- trunk/utils/create_unpackaged.pl	2019-08-22 13:36:59 UTC (rev 17758)
+++ trunk/utils/create_unpackaged.pl	2019-08-22 14:59:53 UTC (rev 17759)
@@ -44,6 +44,7 @@
 my @opcs = ();
 my @views = ();
 my @tables = ();
+my @sequences = ();
 my @schemas = ();
 
 sub strip_default {
@@ -68,7 +69,19 @@
 		push (@views, $1);
 	}
 	elsif ($line =~ /^create table \s*([\w\.]+)/i) {
-		push (@tables, $1);
+		#print STDERR "XXX table $1\n";
+		my $fqtn = $1;
+		push (@tables, $fqtn);
+		my $defn = $line;
+		while( not $defn =~ /\)/ ) {
+			#print STDERR "XXX defn $defn\n";
+			if ($defn =~ /([\w]+) serial\b/i) {
+				my $seq = "${fqtn}_$1_seq";
+				#print STDERR "XXX serial field [$seq]\n";
+				push (@sequences, $seq);
+			}
+			$defn = <>;
+		}
 	}
 	elsif ($line =~ /^create schema \s*([\w\.]+)/i) {
 		push (@schemas, $1);
@@ -186,7 +199,13 @@
 	add_if_not_exists("TABLE $table");
 }
 
+print "-- Register all sequences.\n";
+foreach my $seq (@sequences)
+{
+	add_if_not_exists("SEQUENCE $seq");
+}
 
+
 print "-- Register all aggregates.\n";
 foreach my $agg (@aggs)
 {



More information about the postgis-tickets mailing list