Opened 13 years ago

Closed 13 years ago

#1533 closed defect (fixed)

[raster] regression failure due to non-POSIX sed usage (with patch)

Reported by: gdt Owned by: pracine
Priority: medium Milestone: PostGIS 2.0.0
Component: raster Version: master
Keywords: Cc:

Description

In raster, make check fails because the upgrade script still has CREATE TYPE raster, on NetBSD, and this causes an error due to the already-existing type. The cause is that the sed that is invoked is traditional sed rather than GNU sed, and the regular expressions use \| as an alternative, when basic regular expressions clearly state that | is not special. BSD sed correctly does not treat | as special, but GNU sed interprets it as a special character.

http://pubs.opengroup.org/onlinepubs/007908799/xcu/sed.html http://pubs.opengroup.org/onlinepubs/007908799/xbd/re.html

The following patch changes the preparation of the upgrade sql script to use extended regular expressions rather than basic regular expressions. While POSIX sed does not require extended REs, BSD sed and GNU sed both support extended REs and thus this should be widely portable. In addition, an inexplicably quoted ; is no longer quoted; POSIX says ; is not special.

It has been tested with NetBSD sed, which documents -E for extended REs, and GNU sed 4.2.1, which supports -E but does not document it.

Index: raster/rt_pg/Makefile.in
===================================================================
--- raster/rt_pg/Makefile.in	(revision 9013)
+++ raster/rt_pg/Makefile.in	(working copy)
@@ -96,9 +96,13 @@
 $(SQL_OBJS): ../../postgis/sqldefines.h
 
 #remove all create object types since these can't be done cleanly in an upgrade
+
+# Use extended regular expressions, because | is not supported in
+# basic regular expressions.
+# Use -E, the traditional switch, because it is also supported by GNU sed.
 rtpostgis_upgrade.sql: rtpostgis.sql
-		 sed -e '/^\(CREATE\|ALTER\) \(CAST\|OPERATOR\|TYPE\|TABLE\|SCHEMA\|DOMAIN\|TRIGGER\).*;/d' \
-	 	 -e '/^\(CREATE\|ALTER\) \(CAST\|OPERATOR\|TYPE\|TABLE\|SCHEMA\|DOMAIN\|TRIGGER\)/,/\;/d' \
+		 sed -E -e '/^(CREATE|ALTER) (CAST|OPERATOR|TYPE|TABLE|SCHEMA|DOMAIN|TRIGGER).*;/d' \
+	 	 -e '/^(CREATE|ALTER) (CAST|OPERATOR|TYPE|TABLE|SCHEMA|DOMAIN|TRIGGER)/,/;/d' \
 	 	 $< > $@
 
 rtpostgis_upgrade_20_minor.sql: rtpostgis_drop.sql rtpostgis_upgrade_cleanup.sql rtpostgis_upgrade.sql 

Change History (4)

comment:1 by Bborie Park, 13 years ago

Patch looks good in 64-bit Linux and OSX. Committed in r9014.

comment:2 by Bborie Park, 13 years ago

Reverted r9014 in r9015. Hudson ain't happy with sed -E. I expect that the only foolproof solution is to use a perl script.

comment:3 by Bborie Park, 13 years ago

gdt,

Can you test r9037 as pramsey replaced the use of sed with a perl one-liner.

comment:4 by gdt, 13 years ago

Resolution: fixed
Status: newclosed

I have test r9078 and and now gmake check gets all the way to topology!

Note: See TracTickets for help on using tickets.