[postgis-tickets] r16076 - Have output of create_unpackaged survive already-registered objects
Sandro Santilli
strk at kbt.io
Sun Oct 29 11:04:08 PDT 2017
Author: strk
Date: 2017-10-29 11:04:08 -0700 (Sun, 29 Oct 2017)
New Revision: 16076
Modified:
trunk/utils/create_unpackaged.pl
Log:
Have output of create_unpackaged survive already-registered objects
References #3913
Modified: trunk/utils/create_unpackaged.pl
===================================================================
--- trunk/utils/create_unpackaged.pl 2017-10-28 18:55:00 UTC (rev 16075)
+++ trunk/utils/create_unpackaged.pl 2017-10-29 18:04:08 UTC (rev 16076)
@@ -125,7 +125,20 @@
#close( INPUT );
-my $addprefix = "ALTER EXTENSION $extname ADD";
+sub add_if_not_exists
+{
+ my $obj = shift;
+ print <<"EOF"
+DO \$\$
+BEGIN
+ ALTER EXTENSION $extname ADD $obj;
+ RAISE NOTICE 'newly registered $obj';
+EXCEPTION WHEN object_not_in_prerequisite_state THEN
+ RAISE NOTICE 'already registered $obj';
+END;
+\$\$ LANGUAGE 'plpgsql';
+EOF
+}
my $time = POSIX::strftime("%c", localtime);
print "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n";
@@ -156,7 +169,7 @@
print "-- Register all views.\n";
foreach my $view (@views)
{
- print "$addprefix VIEW $view;\n";
+ add_if_not_exists("VIEW $view");
}
print "-- Register all tables.\n";
@@ -165,7 +178,7 @@
@tables = reverse(@tables);
foreach my $table (@tables)
{
- print "$addprefix TABLE $table;\n";
+ add_if_not_exists("TABLE $table");
}
@@ -174,11 +187,11 @@
{
if ( $agg =~ /create aggregate\s*([\w\.]+)\s*\(\s*.*basetype = ([\w\.]+)/ism )
{
- print "$addprefix AGGREGATE $1 ($2);\n";
+ add_if_not_exists("AGGREGATE $1 ($2)");
}
elsif ( $agg =~ /create aggregate\s*([\w\.]+)\s*\(\s*([\w,\.\s\[\]]+)\s*\)/ism )
{
- print "$addprefix AGGREGATE $1 ($2);\n";
+ add_if_not_exists("AGGREGATE $1 ($2)");
}
else
{
@@ -189,8 +202,8 @@
print "-- Register all operators classes and families.\n";
foreach my $opc (@opcs)
{
- print "$addprefix OPERATOR CLASS $opc;\n";
- print "$addprefix OPERATOR FAMILY $opc;\n";
+ add_if_not_exists("OPERATOR CLASS $opc");
+ add_if_not_exists("OPERATOR FAMILY $opc");
}
print "-- Register all operators.\n";
@@ -198,7 +211,7 @@
{
if ($op =~ /create operator ([^(]+)\s*\(.*LEFTARG\s*=\s*(\w+),\s*RIGHTARG\s*=\s*(\w+).*/ism )
{
- print "$addprefix OPERATOR $1 ($2,$3);\n";
+ add_if_not_exists("OPERATOR $1 ($2,$3)");
}
else
{
@@ -212,7 +225,7 @@
{
if ($cast =~ /create cast\s*\((.+?)\)/i )
{
- print "$addprefix CAST ($1);\n";
+ add_if_not_exists("CAST ($1)");
}
else
{
@@ -232,7 +245,7 @@
$fn_arg = strip_default($fn_arg);
if ( ! exists($type_funcs{$fn_nm}) )
{
- print "$addprefix FUNCTION $fn_nm ($fn_arg);\n";
+ add_if_not_exists("FUNCTION $fn_nm ($fn_arg)");
}
else
{
@@ -255,7 +268,7 @@
$fn_arg =~ s/DEFAULT [\w']+//ig;
- print "$addprefix FUNCTION $fn_nm ($fn_arg);\n";
+ add_if_not_exists("FUNCTION $fn_nm ($fn_arg)");
}
else
{
@@ -266,7 +279,7 @@
print "-- Register all types.\n";
foreach my $type (@types)
{
- print "$addprefix TYPE $type;\n";
+ add_if_not_exists("TYPE $type");
}
@@ -278,7 +291,7 @@
#{
# foreach my $schema (@schemas)
# {
-# print "$addprefix SCHEMA \"$schema\";\n";
+# add_if_not_exists("SCHEMA \"$schema\"");
# }
#}
More information about the postgis-tickets
mailing list