[postgis-tickets] [SCM] PostGIS branch master updated. 3.3.0beta2-29-g523502dc1
git at osgeo.org
git at osgeo.org
Mon Aug 1 15:45:04 PDT 2022
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 523502dc1f07203b75a5cfeddccdfb3856e78e53 (commit)
via 7e529fb3aec485c2cd2ed1fdacdb9a3d09a8bb6f (commit)
from ca37a62b4759ed1c7d35bcb43c62c0e9f835771e (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 523502dc1f07203b75a5cfeddccdfb3856e78e53
Author: Regina Obe <lr at pcorp.us>
Date: Mon Aug 1 18:43:08 2022 -0400
Change address_standardizer and postgis_tiger_geocoder
CREATE EXTENSION to use CREATE instead of CREATE OR REPLACE.
References #5195 and #5196 for PostGIS 3.3.0
diff --git a/NEWS b/NEWS
index 0c1fbf4c3..80deb6cca 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,9 @@ Changes since PostGIS 3.3.0beta2:
- #5025, Ensure that additional operators are not appended
when the function and opfamily disagree
about dimensionality (Paul Ramsey)
+ - #5195, #5196 Change address_standardizer
+ and postgis_tiger_geocoder CREATE EXTENSION to use CREATE
+ instead of CREATE OR REPLACE. (Regina Obe)
diff --git a/extensions/address_standardizer/Makefile.in b/extensions/address_standardizer/Makefile.in
index 6c9a90270..0fa8f7d13 100644
--- a/extensions/address_standardizer/Makefile.in
+++ b/extensions/address_standardizer/Makefile.in
@@ -38,13 +38,16 @@ MODULE_big = address_standardizer- at POSTGIS_MAJOR_VERSION@. at POSTGIS_MINOR_VERSION
MODULEPATH = $$libdir/address_standardizer- at POSTGIS_MAJOR_VERSION@. at POSTGIS_MINOR_VERSION@
endif
EXTENSION = address_standardizer
+EXTENSION_SCRIPTS = \
+ sql/address_standardizer_types.sql \
+ sql/address_standardizer_functions.sql
DATA_built = \
$(EXTENSION).control \
$(EXTENSION)_data_us.control \
$(NULL)
-all: sql/address_standardizer.sql sql/address_standardizer--1.0--$(EXTVERSION).sql sql/$(EXTENSION)--$(EXTVERSION).sql sql/$(EXTENSION)--ANY--$(EXTVERSION).sql \
+all: sql/address_standardizer_pre.sql sql/address_standardizer.sql sql/address_standardizer--1.0--$(EXTVERSION).sql sql/$(EXTENSION)--$(EXTVERSION).sql sql/$(EXTENSION)--ANY--$(EXTVERSION).sql \
sql/$(EXTENSION)_data_us.sql sql/address_standardizer-- at POSTGIS_LIB_VERSION@.sql sql/$(EXTENSION)_data_us-- at POSTGIS_LIB_VERSION@.sql sql/$(EXTENSION)_data_us--$(EXTVERSION)--$(EXTVERSION)next.sql \
sql/$(EXTENSION)_data_us--$(EXTVERSION)next--$(EXTVERSION).sql sql/$(EXTENSION)_data_us--ANY--$(EXTVERSION).sql \
sql/test-init-extensions.sql sql/test-parseaddress.sql sql/test-standardize_address_1.sql sql/test-standardize_address_2.sql
@@ -69,23 +72,29 @@ sql/%.sql: %.sql.in
| $(PERL) -lpe "s'@EXTVERSION@'$(EXTVERSION)'g" \
> $@
-sql/address_standardizer-- at POSTGIS_LIB_VERSION@_raw.sql: sql/address_standardizer_types.sql \
- sql/address_standardizer_functions.sql
+sql/address_standardizer_pre.sql: $(EXTENSION_SCRIPTS)
mkdir -p sql
cat $^ > $@
-sql/address_standardizer.sql: sql/address_standardizer_types.sql \
- sql/address_standardizer_functions.sql
+sql/address_standardizer--$(EXTVERSION).sql: sql/address_standardizer_pre.sql ../../utils/create_or_replace_to_create.pl
mkdir -p sql
- cat $^ > $@
+ cat $< \
+ | $(PERL) ../../utils/create_or_replace_to_create.pl sql/address_standardizer_pre.sql \
+ > $@
-sql/address_standardizer--1.0--$(EXTVERSION).sql: sql/address_standardizer_functions.sql
+sql/address_standardizer.sql: sql/address_standardizer_pre.sql ../../utils/create_or_replace_to_create.pl
mkdir -p sql
- cat $^ > $@
+ cat $< \
+ | $(PERL) ../../utils/create_or_replace_to_create.pl sql/address_standardizer_pre.sql \
+ > $@
EXTENSION_UPGRADE_SCRIPTS = sql/address_standardizer_functions.sql
# upgrade logic for us data extension (to go to original round-robin yoyo cludge for dev upgrading)
+sql/$(EXTENSION)--1.0--$(EXTVERSION).sql: sql/address_standardizer_functions.sql
+ mkdir -p sql
+ cat $^ > $@
+
sql/$(EXTENSION)--$(EXTVERSION)next--$(EXTVERSION).sql: sql/address_standardizer_functions.sql
mkdir -p sql
cat $^ > $@
diff --git a/extensions/postgis_tiger_geocoder/Makefile.in b/extensions/postgis_tiger_geocoder/Makefile.in
index 8df3730e4..49cfd80a1 100644
--- a/extensions/postgis_tiger_geocoder/Makefile.in
+++ b/extensions/postgis_tiger_geocoder/Makefile.in
@@ -40,7 +40,7 @@ ifeq (@ADDRESS_STANDARDIZER@,address_standardizer)
REGRESS_OPTS += --load-extension=address_standardizer
endif
-all: sql/$(EXTENSION)--$(EXTVERSION).sql sql/$(EXTENSION)--unpackaged--$(EXTVERSION).sql sql/$(EXTENSION)--ANY--$(EXTVERSION).sql sql/test-normalize_address.sql sql/test-pagc_normalize_address.sql expected/test-normalize_address.out expected/test-pagc_normalize_address.out sql/test-upgrade.sql expected/test-upgrade.out
+all: sql/$(EXTENSION)_pre.sql sql/$(EXTENSION)--$(EXTVERSION).sql sql/$(EXTENSION)--unpackaged--$(EXTVERSION).sql sql/$(EXTENSION)--ANY--$(EXTVERSION).sql sql/test-normalize_address.sql sql/test-pagc_normalize_address.sql expected/test-normalize_address.out expected/test-pagc_normalize_address.out sql/test-upgrade.sql expected/test-upgrade.out
expected:
@@ -67,7 +67,7 @@ sql/test-upgrade.sql: | sql
%.control: %.control.in Makefile
cat $< \
- | sed -e 's|@EXTVERSION@|$(EXTVERSION)|g' \
+ | $(PERL) -lpe "s'@EXTVERSION@'$(EXTVERSION)'g" \
> $@
expected/test-upgrade.out: sql/test-upgrade.sql | expected
@@ -76,9 +76,14 @@ expected/test-upgrade.out: sql/test-upgrade.sql | expected
sql/test-pagc_normalize_address.sql: sql_bits/test_tuples_only_unaligned.sql.in ../../extras/tiger_geocoder/regress/pagc_normalize_address_regress.sql | sql
cat $^ > $@
-sql/$(EXTENSION).sql: sql/tiger_geocoder.sql sql_bits/mark_editable_objects.sql.in sql_bits/tiger_geocoder_comments.sql | sql
+sql/$(EXTENSION)_pre.sql: sql/tiger_geocoder.sql sql_bits/mark_editable_objects.sql.in sql_bits/tiger_geocoder_comments.sql | sql
cat $^ > $@
+sql/$(EXTENSION).sql: sql/$(EXTENSION)_pre.sql ../../utils/create_or_replace_to_create.pl
+ cat $< \
+ | $(PERL) ../../utils/create_or_replace_to_create.pl sql/$(EXTENSION)_pre.sql \
+ > $@
+
sql/$(EXTENSION)--ANY--$(EXTVERSION).sql: ../postgis_extension_helper.sql sql_bits/remove_from_extension.sql.in sql/tiger_geocoder_upgrade_minor.sql sql_bits/mark_editable_objects.sql.in sql_bits/tiger_geocoder_comments.sql | sql
cat $^ > $@
echo "SELECT postgis_extension_drop_if_exists('${EXTENSION}', 'DROP SCHEMA tiger_data');" >> $@
diff --git a/utils/create_or_replace_to_create.pl b/utils/create_or_replace_to_create.pl
new file mode 100644
index 000000000..6b43953f8
--- /dev/null
+++ b/utils/create_or_replace_to_create.pl
@@ -0,0 +1,169 @@
+#!/usr/bin/env perl
+
+#
+# PostGIS - Spatial Types for PostgreSQL
+# http://postgis.net
+#
+# Copyright (C) 2022 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.
+#
+
+#
+# This script produces an .sql file containing
+# CREATE OR REPLACE calls for each function
+# in postgis.sql
+#
+# In addition, the transaction contains
+# a check for Major postgis_lib_version()
+# to match the one contained in lwpostgis.sql
+#
+# This never happens by just running make install
+# as MODULE_FILENAME contains SO_MAJOR under
+# all architectures.
+#
+#
+
+eval "exec perl -w $0 $@"
+ if (0);
+
+use strict;
+use warnings;
+
+#
+# Conditionally upgraded types and operators based
+# on their last updated version and the version of
+# the target database
+#
+
+sub parse_last_updated
+{
+ my $comment = shift;
+ if ( $comment =~ m/.*(?:Availability|Changed|Updated):\s([^\.])\.([^.]*)/s )
+ {
+ return $1*100 + $2;
+ }
+ return 0;
+}
+
+sub parse_replaces
+{
+ my @replaces = ();
+ my $comment = shift;
+ my ($name, $args, $ver);
+ foreach my $line ( split /\n/, $comment )
+ {
+ if ( $line =~ m/.*Replaces\s\s*([^\(]*)\(([^\)]*)\)\s\s*deprecated in\s\s*([^\.]*)\.([^.]*)/ )
+ {
+ $name = $1;
+ $args = $2;
+ $ver = $3*100 + $4;
+ my @r = ($name, $args, $ver);
+ push @replaces, \@r;
+ }
+ }
+ return @replaces;
+}
+
+sub parse_missing
+{
+ my $comment = shift;
+ my @missing = ();
+ if ( $comment =~ m/.*(?:Missing in):\s([^\.])\.([^.]*)/s )
+ {
+ push(@missing, $1*100 + $2);
+ }
+ return join(',', at missing);
+}
+
+#
+# Commandline argument handling
+#
+($#ARGV == 0)
+ ||die
+"Usage: perl create_upgrade.pl <create_script.sql> [<schema>]\nCreates a new SQL script that has all CREATE OR REPLACE converted to CREATE so it is suitable for CREATE EXTENSION only.\n"
+ if ( @ARGV < 1 || @ARGV > 3 );
+
+my $sql_file = $ARGV[0];
+
+die "Unable to open input SQL file $sql_file\n"
+ if ( !-f $sql_file );
+
+#
+# Go through the SQL file and strip out objects that cannot be
+# applied to an existing, loaded database: types and operators
+# and operator classes that have already been defined.
+#
+my $comment = '';
+open( INPUT, $sql_file ) || die "Couldn't open file: $sql_file\n";
+while(<INPUT>)
+{
+
+ if (/^create or replace function/i)
+ {
+ my $def .= $_;
+ my $endfunc = 0;
+ $def =~ s/CREATE OR REPLACE/CREATE/;
+ #print "-- entering create or replace loop\n";
+ while(<INPUT>)
+ {
+ $def .= $_;
+ $endfunc = 1 if /^\s*(\$\$\s*)?LANGUAGE /i;
+
+ last if ( $endfunc && /\;/ );
+ }
+
+ print $def;
+ #print "-- exiting create or replace loop\n";
+ }
+ elsif (/^do *language .*\$\$/i)
+ {
+ print;
+ while(<INPUT>)
+ {
+ print;
+ last if /\$\$/;
+ }
+ }
+
+ # Always output create ore replace view (see ticket #1097)
+ elsif (/^create or replace view\s+(\S+)\s*/i)
+ {
+ my $def = $_;
+ $def = $_;
+ $def =~ s/CREATE OR REPLACE/CREATE/;
+ while(<INPUT>)
+ {
+ $def .= $_;
+ last if /\;\s*$/;
+ }
+ print $def;
+ }
+
+ # Always output create ore replace rule
+ elsif (/^create or replace rule\s+(\S+)\s*/i)
+ {
+ my $def = $_;
+ $def = $_;
+ $def =~ s/CREATE OR REPLACE/CREATE/;
+ while(<INPUT>)
+ {
+ $def .= $_;
+ last if /\;\s*$/;
+ }
+ print $def;
+ }
+ else {
+ print;
+ }
+}
+
+close(INPUT);
+
+#print "COMMIT;\n";
+
+1;
+
+__END__
+
commit 7e529fb3aec485c2cd2ed1fdacdb9a3d09a8bb6f
Author: Regina Obe <lr at pcorp.us>
Date: Mon Aug 1 12:12:11 2022 -0400
Change to use perl regex instead of sed for control file
diff --git a/extensions/address_standardizer/Makefile.in b/extensions/address_standardizer/Makefile.in
index ed18cbce0..6c9a90270 100644
--- a/extensions/address_standardizer/Makefile.in
+++ b/extensions/address_standardizer/Makefile.in
@@ -66,10 +66,10 @@ sql/%.sql: %.sql.in
%.control: %.control.in Makefile
cat $< \
- | sed -e 's|@EXTVERSION@|$(EXTVERSION)|g' \
+ | $(PERL) -lpe "s'@EXTVERSION@'$(EXTVERSION)'g" \
> $@
-sql/address_standardizer-- at POSTGIS_LIB_VERSION@.sql: sql/address_standardizer_types.sql \
+sql/address_standardizer-- at POSTGIS_LIB_VERSION@_raw.sql: sql/address_standardizer_types.sql \
sql/address_standardizer_functions.sql
mkdir -p sql
cat $^ > $@
-----------------------------------------------------------------------
Summary of changes:
NEWS | 3 +
extensions/address_standardizer/Makefile.in | 27 ++--
extensions/postgis_tiger_geocoder/Makefile.in | 11 +-
utils/create_or_replace_to_create.pl | 169 ++++++++++++++++++++++++++
4 files changed, 198 insertions(+), 12 deletions(-)
create mode 100644 utils/create_or_replace_to_create.pl
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list