[postgis] 01/04: New upstream version 2.3.3+dfsg

Bas Couwenberg sebastic at debian.org
Sat Jul 1 19:19:02 UTC 2017


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository postgis.

commit 805c5fc185bf31eadd742f0fd9e067c99e1d4661
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Sat Jul 1 20:46:05 2017 +0200

    New upstream version 2.3.3+dfsg
---
 .drone.yml                                         |   6 +-
 .travis.yml                                        |   2 +-
 ChangeLog                                          | 215 +++++++++++++++++++++
 NEWS                                               |  26 ++-
 README.md                                          |   4 +-
 README.postgis                                     |  22 +--
 Version.config                                     |   4 +-
 config.guess                                       |  28 ++-
 config.sub                                         |  22 ++-
 configure                                          |   1 -
 doc/Makefile.in                                    |   1 +
 doc/extras_tigergeocoder.xml                       |   4 +-
 doc/installation.xml                               |   4 +-
 doc/performance_tips.xml                           |  30 +--
 doc/po/de_DE/release_notes.xml.po                  |   2 +-
 doc/po/es/release_notes.xml.po                     |   2 +-
 doc/po/fr/release_notes.xml.po                     |   2 +-
 doc/po/it_IT/release_notes.xml.po                  |   2 +-
 doc/po/ja/release_notes.xml.po                     |   2 +-
 doc/po/ko_KR/release_notes.xml.po                  |   2 +-
 doc/po/pl/release_notes.xml.po                     |   2 +-
 doc/po/pt_BR/release_notes.xml.po                  |   2 +-
 doc/po/templates/release_notes.xml.pot             |   2 +-
 doc/reference_measure.xml                          |   2 +-
 doc/reference_processing.xml                       |  29 +--
 doc/release_notes.xml                              |  54 ++++--
 doc/texstyle.sty                                   |  14 ++
 doc/tiger_geocoder_comments.sql                    |   2 +-
 doc/using_postgis_dataman.xml                      |  17 +-
 doc/xsl/postgis_gardentest.sql.xsl                 | 114 +++++------
 extensions/address_standardizer/Makefile           |   6 +-
 .../address_standardizer.control                   |   2 +-
 .../address_standardizer_data_us.control           |   2 +-
 extensions/postgis/Makefile                        |   2 +-
 extensions/postgis/postgis.control                 |   2 +-
 extensions/postgis_sfcgal/Makefile                 |   2 +-
 extensions/postgis_sfcgal/postgis_sfcgal.control   |   2 +-
 extensions/postgis_tiger_geocoder/Makefile         |   2 +-
 .../postgis_tiger_geocoder.control                 |   2 +-
 extensions/postgis_topology/Makefile               |   2 +-
 .../postgis_topology/postgis_topology.control      |   2 +-
 extensions/upgradeable_versions.mk                 |   3 +-
 liblwgeom/lwgeom.c                                 |  12 +-
 liblwgeom/lwgeom_topo.c                            |  36 +++-
 liblwgeom/lwout_x3d.c                              |  23 ++-
 libtool                                            |   9 +-
 loader/pgsql2shp-core.c                            | 139 +++++++------
 loader/pgsql2shp-core.h                            |  14 +-
 ltmain.sh                                          |   4 +-
 macros/libtool.m4                                  |   1 -
 postgis/Makefile.in                                |  16 +-
 postgis/lwgeom_btree.c                             |  64 ++++--
 postgis/postgis.sql.in                             |   2 +-
 postgis/sqldefines.h                               |   8 +-
 postgis_svn_revision.h                             |   2 +-
 raster/loader/raster2pgsql.c                       |   8 +-
 raster/rt_pg/rtpg_mapalgebra.c                     |  14 +-
 raster/rt_pg/rtpostgis.sql.in                      |  46 ++---
 regress/dumper/realtable-pre.sql                   |   4 +-
 regress/dumper/realtable_expected.dbf              | Bin 77 -> 162 bytes
 regress/knn_recheck.sql                            |  24 +--
 regress/knn_recheck_expected                       |  22 ---
 regress/operators.sql                              |  22 ++-
 regress/operators_expected                         |   8 +
 regress/subdivide.sql                              |  17 ++
 regress/subdivide_expected                         |   1 +
 regress/tickets.sql                                |   3 +
 regress/tickets_expected                           |   1 +
 topology/postgis_topology.c                        |  23 +--
 topology/test/regress/topogeo_addlinestring.sql    |  10 +
 .../regress/topogeo_addlinestring_expected_newsnap |   5 +
 .../regress/topogeo_addlinestring_expected_oldsnap |   5 +
 72 files changed, 813 insertions(+), 378 deletions(-)

diff --git a/.drone.yml b/.drone.yml
index b3b7b5b..abc8dbb 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -1,9 +1,5 @@
 # See http://readme.drone.io/0.5/usage/overview
 
-env:
-  global:
-    - RUNTESTFLAGS=-v
-
 # See https://git.osgeo.org/gogs/postgis/postgis-docker
 test-image: &test-image docker.kbt.io/postgis/build-test:trisquel
 
@@ -22,6 +18,6 @@ pipeline:
     image: *test-image
     commands:
       - service postgresql start
-      - make check
+      - make check RUNTESTFLAGS=-v
       - make install
       - utils/check_all_upgrades.sh 2.4.0dev
diff --git a/.travis.yml b/.travis.yml
index c432742..7673b5b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,7 +11,7 @@ before_install:
       postgresql-9.4 postgresql-server-dev-9.4
       build-essential autoconf libtool libcunit1-dev
       xsltproc docbook-xsl docbook-mathml dblatex
-      libproj-dev libgdal-dev libgeos-dev libjson0-dev
+      libproj-dev libgdal1h libgdal-dev libgeos-dev libjson0-dev
   - dpkg -l | grep postgresql
   - ./autogen.sh
 
diff --git a/ChangeLog b/ChangeLog
index 32007c9..034c3e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,218 @@
+2017-06-30 20:43  Regina Obe <lr at pcorp.us>
+
+	* [r15469] doc/performance_tips.xml, doc/using_postgis_dataman.xml:
+	  Bring performance tips section up to newer versions
+	  Closes #3746 for PostGIS 2.3 (branch)
+
+2017-06-24 06:18  Regina Obe <lr at pcorp.us>
+
+	* [r15463] .travis.yml: try to fix travis gdal related build error
+
+2017-06-24 05:36  Regina Obe <lr at pcorp.us>
+
+	* [r15460] doc/installation.xml: fix typo
+
+2017-06-24 05:36  Regina Obe <lr at pcorp.us>
+
+	* [r15459] doc/installation.xml: Specify highest version of
+	  PostgreSQL supported.
+	  References #3762 for PostGIS 2.3.3
+
+2017-06-24 05:31  Regina Obe <lr at pcorp.us>
+
+	* [r15458] doc/extras_tigergeocoder.xml: change doco for
+	  Geocode_Intersection to agree with function definition.
+	  Closes #3717 for PostGIS 2.3.3
+
+2017-06-24 04:58  Regina Obe <lr at pcorp.us>
+
+	* [r15457] NEWS, raster/rt_pg/rtpg_mapalgebra.c: Change ST_Clip
+	  from Error to Notice when ST_Clip can compute no band
+	  Closest #3730 for PostGIS 2.3.3
+
+2017-06-24 04:33  Regina Obe <lr at pcorp.us>
+
+	* [r15454] doc/reference_processing.xml: Update 3D example and put
+	  a note about function may return the same geometry.
+	  References #3702 for PostGIS 2.4 (trunk)
+
+2017-06-24 04:06  Regina Obe <lr at pcorp.us>
+
+	* [r15452] doc/xsl/postgis_gardentest.sql.xsl: Increase LIMIT
+	  clause on tests so can more readily catch issues like #3704.
+
+2017-06-23 22:57  Sandro Santilli <strk at kbt.io>
+
+	* [r15451] postgis/lwgeom_btree.c, regress/operators.sql,
+	  regress/operators_expected: Fix lwgeom_cmp return code
+	  
+	  Closes #3777 once again (for 2.3 branch)
+
+2017-06-23 15:07  Sandro Santilli <strk at kbt.io>
+
+	* [r15449] topology/postgis_topology.c: Fix compiler warnings about
+	  printf-like formats
+	  
+	  This was already fixed in trunk
+
+2017-06-23 14:58  Sandro Santilli <strk at kbt.io>
+
+	* [r15448] NEWS, postgis/lwgeom_btree.c, regress/operators.sql,
+	  regress/operators_expected: Fix handling of EMPTY geometries in
+	  btree operator
+	  
+	  Includes regress test
+	  
+	  Closes #3777 for 2.3 branch
+
+2017-06-23 06:15  Regina Obe <lr at pcorp.us>
+
+	* [r15445] NEWS, liblwgeom/lwout_x3d.c, regress/tickets.sql,
+	  regress/tickets_expected: ST_AsX3D handle empty geometries
+	  Closes #3704 for PostGIS 2.3.3
+
+2017-06-23 05:55  Regina Obe <lr at pcorp.us>
+
+	* [r15443] regress/dumper/realtable-pre.sql: Backport test sql
+	  script missed in last commit
+	  References #3682 for 2.3.3
+	  References #3701 for 2.3.3
+
+2017-06-23 05:19  Regina Obe <lr at pcorp.us>
+
+	* [r15442] NEWS, loader/pgsql2shp-core.c, loader/pgsql2shp-core.h,
+	  regress/dumper/realtable_expected.dbf: Backport fixes for
+	  pgsql2shp for Boolean field length and quote escaping
+	  Includes tests for both
+	  Closes #3682
+	  Closes #3701
+
+2017-06-19 20:37  Sandro Santilli <strk at kbt.io>
+
+	* [r15437] postgis/Makefile.in: Avoid ever-growing postgis
+	  extension upgrade scripts
+	  
+	  Fixes #3775 for 2.3 branch
+
+2017-06-19 20:37  Sandro Santilli <strk at kbt.io>
+
+	* [r15436] postgis/Makefile.in: Style only change: remove trailing
+	  blanks
+
+2017-06-06 12:27  Sandro Santilli <strk at kbt.io>
+
+	* [r15421] NEWS, doc/po/de_DE/release_notes.xml.po,
+	  doc/po/es/release_notes.xml.po, doc/po/fr/release_notes.xml.po,
+	  doc/po/it_IT/release_notes.xml.po,
+	  doc/po/ja/release_notes.xml.po,
+	  doc/po/ko_KR/release_notes.xml.po,
+	  doc/po/pl/release_notes.xml.po,
+	  doc/po/pt_BR/release_notes.xml.po,
+	  doc/po/templates/release_notes.xml.pot, doc/release_notes.xml:
+	  Speep up -> Speed up
+	  
+	  Thanks Andreas Schild via
+	  https://www.transifex.com/postgis/postgis/translate/#de/release_notesxmlpot/74993598/
+
+2017-06-06 12:22  Sandro Santilli <strk at kbt.io>
+
+	* [r15418] NEWS, doc/release_notes.xml: shp2pgsql locale fixes are
+	  #3084, not #3048
+	  
+	  Thanks Andreas Schild via
+	  https://www.transifex.com/postgis/postgis/translate/#de/release_notesxmlpot/74993584/
+
+2017-05-04 18:01  Sandro Santilli <strk at kbt.io>
+
+	* [r15388] .drone.yml: Set RUNTESTFLAGS env variable locally
+	  
+	  global env doesn't seem to work with Drone
+
+2017-05-03 03:50  Regina Obe <lr at pcorp.us>
+
+	* [r15383] NEWS, postgis/postgis.sql.in,
+	  raster/rt_pg/rtpostgis.sql.in: @ operator not schema qualified
+	  and ~ not schema qualified in some places
+	  apply patch with adjustments. Patch provided by Shane StClair
+	  (Axiom Data Science)
+	  Closes #3750 for PostGIS 2.3.3
+
+2017-04-25 08:20  Regina Obe <lr at pcorp.us>
+
+	* [r15368] regress/subdivide.sql, regress/subdivide_expected:
+	  revise ST_Subdivide regress to use ticket instead of github pull
+	  request
+	  References #3744 for PostGIS 2.3
+
+2017-04-25 06:02  Regina Obe <lr at pcorp.us>
+
+	* [r15365] NEWS, doc/Makefile.in, doc/texstyle.sty: PDF manual from
+	  dblatex renders fancy quotes for programlisting
+	  Change to use regular quotes
+	  patch from Mike Toews
+	  References #3726 for PostGIS 2.3
+
+2017-04-24 20:42  Regina Obe <lr at pcorp.us>
+
+	* [r15364] NEWS, liblwgeom/lwgeom.c, regress/subdivide.sql,
+	  regress/subdivide_expected: ST_Subdivide loses subparts of
+	  inverted geometries patch from Darafei Praliaskouski (Komzpa)
+	  Closes #3744 for PostGIS 2.3
+	  changed area regress to cast to numeric so doesn't return
+	  scientific notation on windows
+
+2017-04-23 20:34  Regina Obe <lr at pcorp.us>
+
+	* [r15362] NEWS, raster/loader/raster2pgsql.c: Get rid of logic
+	  that set out_srid to same as input srid and change to not try to
+	  transform when out_srid is unknown.
+	  Closes #3738 for PostGIS 2.3
+
+2017-04-12 13:35  Sandro Santilli <strk at kbt.io>
+
+	* [r15352] README.md: Fix drone build badge url
+	  
+	  [ci skip]
+
+2017-04-08 12:25  Regina Obe <lr at pcorp.us>
+
+	* [r15348] regress/knn_recheck.sql, regress/knn_recheck_expected:
+	  Get rid of knn tests where multiple records have the same
+	  distances
+	  references #3649 for 2.3
+
+2017-04-04 17:40  Daniel Baston <dbaston at gmail.com>
+
+	* [r15346] doc/reference_measure.xml: Fix error in docs for
+	  ST_ClusterDBSCAN
+
+2017-03-11 16:23  Sandro Santilli <strk at kbt.io>
+
+	* [r15331] NEWS, liblwgeom/lwgeom_topo.c,
+	  topology/test/regress/topogeo_addlinestring.sql,
+	  topology/test/regress/topogeo_addlinestring_expected_newsnap,
+	  topology/test/regress/topogeo_addlinestring_expected_oldsnap: Fix
+	  azimuth computation for 2.5D edge ends
+	  
+	  The change disreguard vertical movemements of the edge and
+	  computes
+	  azimuth of the first segment getting away from the node.
+	  
+	  Includes automated testcase
+	  
+	  Closes #3711 (in 2.3 branch)
+
+2017-01-31 05:05  Regina Obe <lr at pcorp.us>
+
+	* [r15303] Version.config, extensions/upgradeable_versions.mk: Bump
+	  to next dev revision
+
+2017-01-30 05:59  Regina Obe <lr at pcorp.us>
+
+	* [r15301] ChangeLog, NEWS, README.postgis, Version.config,
+	  doc/release_notes.xml, extensions/upgradeable_versions.mk: Prep
+	  for PostGIS 2.3.2 release
+
 2017-01-28 04:10  Regina Obe <lr at pcorp.us>
 
 	* [r15295] liblwgeom/lwprint.c: Fix for 32-bit lwprint to support
diff --git a/NEWS b/NEWS
index bc20478..d460308 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,25 @@
+PostGIS 2.3.3
+2017/07/01
+
+  * Bug Fixes
+
+  - #3777, GROUP BY anomaly with empty geometries
+  - #3711, Azimuth error upon adding 2.5D edges to topology
+  - #3726, PDF manual from dblatex renders fancy quotes for programlisting
+           (Mike Toews)
+  - #3738, raster: Using -s without -Y in raster2pgsql transforms
+           raster data instead of setting srid
+  - #3744, ST_Subdivide loses subparts of inverted geometries
+           (Darafei Praliaskouski Komzpa)
+  - #3750, @ and ~ operator not always schema qualified in geometry
+           and raster functions. Causes restore issues.
+           (Shane StClair of Axiom Data Science)
+  - #3682, Strange fieldlength for boolean in result of pgsql2shp
+  - #3701, Escape double quotes issue in pgsql2shp
+  - #3704, ST_AsX3D crashes on empty geometry
+  - #3730, Change ST_Clip from Error to Notice when ST_Clip can't compute a band
+
+
 PostGIS 2.3.2
 2017/01/31
 
@@ -297,7 +319,7 @@ PostGIS 2.2.0
            max extent constraint
   - #3018, GROUP BY geography sometimes returns duplicate rows
   - #3020, ST_AddBand out-db bug where height using width value
-  - #3048, shp2pgsql - illegal number format when specific system locale set
+  - #3084, shp2pgsql - illegal number format when specific system locale set
   - #3061, Allow duplicate points in JSON, GML, GML ST_GeomFrom* functions
   - #3086, ST_DumpValues() crashes backend on cleanup with invalid
            band indexes
@@ -340,7 +362,7 @@ PostGIS 2.1.6
 
   - #3000, Ensure edge splitting and healing algorithms use indexes
   - #3048, Speed up geometry simplification (J.Santana @ CartoDB)
-  - #3050, Speep up geometry type reading (J.Santana @ CartoDB)
+  - #3050, Speed up geometry type reading (J.Santana @ CartoDB)
 
  * Bug Fixes *
 
diff --git a/README.md b/README.md
index 9b5249d..6907319 100644
--- a/README.md
+++ b/README.md
@@ -5,8 +5,8 @@ Winnie:
  [![Build Status](https://debbie.postgis.net:444/buildStatus/icon?job=PostGIS_2.3)]
  (https://debbie.postgis.net:444/view/PostGIS/job/PostGIS_2.3/)
 Dronie:
- [![Build Status](https://drone.osgeo.kbt.io/api/badges/postgis/postgis/status.svg?branch=svn-2.3)]
- (https://drone.osgeo.kbt.io/postgis/postgis?branch=svn-2.3)
+ [![Build Status](https://drone.osgeo.org/api/badges/postgis/postgis/status.svg?branch=svn-2.3)]
+ (https://drone.osgeo.org/postgis/postgis?branch=svn-2.3)
 Travis:
  [![Build Status](https://secure.travis-ci.org/postgis/postgis.png?branch=svn-2.3)]
  (http://travis-ci.org/postgis/postgis?branch=svn-2.3)
diff --git a/README.postgis b/README.postgis
index 7ffa9a8..e88cbf4 100644
--- a/README.postgis
+++ b/README.postgis
@@ -1,8 +1,8 @@
 PostGIS - Geographic Information Systems Extensions to PostgreSQL
 =================================================================
 
-:Version: 2.3.2
-:Date: 2017-01-30
+:Version: 2.3.3
+:Date: 2017-07-01
 :Website: http://postgis.net
 
 This distribution contains a module which implements GIS simple features, ties
@@ -31,7 +31,7 @@ Directory structure::
 REQUIREMENTS
 ------------
 
-PostGIS is compatible with PostgreSQL 9.2 and above.
+PostGIS 2.3.3 is compatible with PostgreSQL 9.2-9.6.
 
 You *must* have the full PostgreSQL - including server headers - installed for
 this to work.
@@ -43,8 +43,8 @@ this to work.
 
     http://trac.osgeo.org/proj/
 
-* GEOS (Required, Version 3.3.0 or higher 
-  - 3.4+ is strongly recommended and needed for full features):
+* GEOS (Required, Version 3.3.0 or higher
+  - 3.6+ is strongly recommended and needed for full features):
 
   The GEOS library provides support for exact topological tests such as
   ST_Touches(), ST_Contains(), ST_Disjoint() and spatial operations such as
@@ -77,10 +77,10 @@ this to work.
 
 * GDAL (Optional, Version 1.8.0 or higher 1.9+ is strongly recommended)
 
-  GDAL (http://gdal.org) is *required* if you want to compile PostGIS 
+  GDAL (http://gdal.org) is *required* if you want to compile PostGIS
   with raster or extension support. To compile without raster support you
   must ``./configure --without-raster`` (also disables extension)
-  
+
 * CGAL 4.1+ and SFCGAL (Optional) needed for advanced 3D support
 
   https://github.com/Oslandia/SFCGAL
@@ -176,11 +176,11 @@ You can change them using ``./configure`` switches. See CONFIGURATION section.
 CREATING NEW SPATIAL DATABASES
 ------------------------------
 
-PostGIS support must be enabled for each database that requires its usage. 
+PostGIS support must be enabled for each database that requires its usage.
 Enabling spatial functionality requires a PostgreSQL super-user.
 
     CREATE EXTENSION postgis;
-  
+
 
 UPGRADING EXISTING SPATIAL DATABASES
 ------------------------------------
@@ -188,8 +188,8 @@ UPGRADING EXISTING SPATIAL DATABASES
 Upgrade PostGIS using the "ALTER EXTENSION" facility.
 
   ALTER EXTENSION postgis UPDATE;
-  
-  
+
+
 
 USAGE
 -----
diff --git a/Version.config b/Version.config
index 26c7df6..a8ae4c3 100644
--- a/Version.config
+++ b/Version.config
@@ -1,11 +1,11 @@
-# Version numbering central repository, to be included from various 
+# Version numbering central repository, to be included from various
 # places during the build process
 
 # See HOWTO_RELEASE file in SVN for definitions of those three.
 
 POSTGIS_MAJOR_VERSION=2
 POSTGIS_MINOR_VERSION=3
-POSTGIS_MICRO_VERSION=2
+POSTGIS_MICRO_VERSION=3
 
 # Liblwgeom interface versioning, reset to 0:0:0 (cur:age:rev)
 # when changing POSTGIS_MINOR_VERSION
diff --git a/config.guess b/config.guess
index 0967f2a..2e9ad7f 100755
--- a/config.guess
+++ b/config.guess
@@ -2,7 +2,7 @@
 # Attempt to guess a canonical system name.
 #   Copyright 1992-2016 Free Software Foundation, Inc.
 
-timestamp='2016-04-02'
+timestamp='2016-10-02'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -186,9 +186,12 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 	    *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
 	esac
 	# The Operating System including object format, if it has switched
-	# to ELF recently, or will in the future.
+	# to ELF recently (or will in the future) and ABI.
 	case "${UNAME_MACHINE_ARCH}" in
-	    arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax)
+	    earm*)
+		os=netbsdelf
+		;;
+	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
 		eval $set_cc_for_build
 		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
 			| grep -q __ELF__
@@ -997,6 +1000,9 @@ EOF
 	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
 	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
 	;;
+    mips64el:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
     openrisc*:Linux:*:*)
 	echo or1k-unknown-linux-${LIBC}
 	exit ;;
@@ -1029,6 +1035,9 @@ EOF
     ppcle:Linux:*:*)
 	echo powerpcle-unknown-linux-${LIBC}
 	exit ;;
+    riscv32:Linux:*:* | riscv64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
     s390:Linux:*:* | s390x:Linux:*:*)
 	echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
 	exit ;;
@@ -1408,18 +1417,17 @@ esac
 cat >&2 <<EOF
 $0: unable to guess system type
 
-This script, last modified $timestamp, has failed to recognize
-the operating system you are using. It is advised that you
-download the most up to date version of the config scripts from
+This script (version $timestamp), has failed to recognize the
+operating system you are using. If your script is old, overwrite
+config.guess and config.sub with the latest versions from:
 
   http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
 and
   http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
 
-If the version you run ($0) is already up to date, please
-send the following data and any information you think might be
-pertinent to <config-patches at gnu.org> in order to provide the needed
-information to handle your system.
+If $0 has already been updated, send the following data and any
+information you think might be pertinent to config-patches at gnu.org to
+provide the necessary information to handle your system.
 
 config.guess timestamp = $timestamp
 
diff --git a/config.sub b/config.sub
index 8d39c4b..dd2ca93 100755
--- a/config.sub
+++ b/config.sub
@@ -2,7 +2,7 @@
 # Configuration validation subroutine script.
 #   Copyright 1992-2016 Free Software Foundation, Inc.
 
-timestamp='2016-03-30'
+timestamp='2016-11-04'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -117,7 +117,7 @@ case $maybe_os in
   nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
   linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
   knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
-  kopensolaris*-gnu* | \
+  kopensolaris*-gnu* | cloudabi*-eabi* | \
   storm-chaos* | os2-emx* | rtmk-nova*)
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
@@ -301,6 +301,7 @@ case $basic_machine in
 	| open8 | or1k | or1knd | or32 \
 	| pdp10 | pdp11 | pj | pjl \
 	| powerpc | powerpc64 | powerpc64le | powerpcle \
+	| pru \
 	| pyramid \
 	| riscv32 | riscv64 \
 	| rl78 | rx \
@@ -428,6 +429,7 @@ case $basic_machine in
 	| orion-* \
 	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
 	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
+	| pru-* \
 	| pyramid-* \
 	| riscv32-* | riscv64-* \
 	| rl78-* | romp-* | rs6000-* | rx-* \
@@ -643,6 +645,14 @@ case $basic_machine in
 		basic_machine=m68k-bull
 		os=-sysv3
 		;;
+	e500v[12])
+		basic_machine=powerpc-unknown
+		os=$os"spe"
+		;;
+	e500v[12]-*)
+		basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=$os"spe"
+		;;
 	ebmon29k)
 		basic_machine=a29k-amd
 		os=-ebmon
@@ -1022,7 +1032,7 @@ case $basic_machine in
 	ppc-* | ppcbe-*)
 		basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
-	ppcle | powerpclittle | ppc-le | powerpc-little)
+	ppcle | powerpclittle)
 		basic_machine=powerpcle-unknown
 		;;
 	ppcle-* | powerpclittle-*)
@@ -1032,7 +1042,7 @@ case $basic_machine in
 		;;
 	ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
-	ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+	ppc64le | powerpc64little)
 		basic_machine=powerpc64le-unknown
 		;;
 	ppc64le-* | powerpc64little-*)
@@ -1389,7 +1399,7 @@ case $os in
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
 	      | -chorusos* | -chorusrdb* | -cegcc* \
 	      | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-	      | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
+	      | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
 	      | -linux-newlib* | -linux-musl* | -linux-uclibc* \
 	      | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
 	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
@@ -1399,7 +1409,7 @@ case $os in
 	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
 	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
 	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \
-	      | -onefs* | -tirtos*)
+	      | -onefs* | -tirtos* | -phoenix* | -fuchsia*)
 	# Remember, each alternative MUST END IN *, to match a version number.
 		;;
 	-qnx*)
diff --git a/configure b/configure
index 266fb10..31f1559 100755
--- a/configure
+++ b/configure
@@ -19043,7 +19043,6 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
     cat <<_LT_EOF >> "$cfgfile"
 #! $SHELL
 # Generated automatically by $as_me ($PACKAGE) $VERSION
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
 
 # Provide generalized library-building support services.
diff --git a/doc/Makefile.in b/doc/Makefile.in
index 2b765db..cc095fa 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -276,6 +276,7 @@ postgis-${POSTGIS_MAJOR_VERSION}.${POSTGIS_MINOR_VERSION}.${POSTGIS_MICRO_VERSIO
 		   -P figure.warning="${PWD}/html/images/warning" \
 		   -P figure.caution="${PWD}/html/images/caution" \
 		   -P latex.output.revhistory=0 \
+		   -s texstyle \
 		   -o postgis-${POSTGIS_MAJOR_VERSION}.${POSTGIS_MINOR_VERSION}.${POSTGIS_MICRO_VERSION}$(DOCSUFFIX).pdf $<; \
 	fi
 	
diff --git a/doc/extras_tigergeocoder.xml b/doc/extras_tigergeocoder.xml
index 75044eb..48a2497 100644
--- a/doc/extras_tigergeocoder.xml
+++ b/doc/extras_tigergeocoder.xml
@@ -390,7 +390,7 @@ Total query runtime: 245 ms.
             <paramdef><type>text </type> <parameter> in_state</parameter></paramdef>
             <paramdef choice="opt"><type>text </type> <parameter> in_city</parameter></paramdef>
             <paramdef choice="opt"><type>text </type> <parameter> in_zip</parameter></paramdef>
-            <paramdef choice="opt"><type>integer </type> <parameter>max_results=10</parameter></paramdef>
+            <paramdef choice="opt"><type>integer </type> <parameter>num_results=10</parameter></paramdef>
             <paramdef><type>norm_addy </type> <parameter>OUT addy</parameter></paramdef>
             <paramdef><type>geometry </type> <parameter>OUT geomout</parameter></paramdef>
             <paramdef><type>integer </type> <parameter>OUT rating</parameter></paramdef>
@@ -732,7 +732,7 @@ for z in *.zip; do $UNZIPTOOL -o -d $TMPDIR $z; done
           </listitem>
         </orderedlist>
         <para>Availability: 2.0.0 to support Tiger 2010 structured data and load census tract (tract), block groups (bg), and blocks (tabblocks) tables .</para>
-        <note><para>If you are using pgAdmin 3, be warned that by default pgAdmin 3 truncates long text.  To fix, change 
+        <note><para>If you are using pgAdmin 3, be warned that by default pgAdmin 3 truncates long text.  To fix, change
          <emphasis>File -> Options -> Query Tool -> Query Editor - > Max. characters per column</emphasis> to larger than 50000 characters.</para></note>
 
 
diff --git a/doc/installation.xml b/doc/installation.xml
index 8517512..042e495 100644
--- a/doc/installation.xml
+++ b/doc/installation.xml
@@ -94,7 +94,7 @@ psql -d yourdatabase -f sfcgal_comments.sql
 	<itemizedlist>
 	  <listitem>
 		<para>
-		  PostgreSQL &min_postgres_version; or higher. A complete installation
+		  PostgreSQL &min_postgres_version; and <= PostgreSQL 9.6. A complete installation
 		  of PostgreSQL (including server headers) is required. PostgreSQL
 		  is available from
 		  <ulink url="http://www.postgresql.org">
@@ -1395,7 +1395,7 @@ All 2 tests passed.
 
 	<para>You can later run <filename>uninstall_legacy.sql</filename> to get rid of the deprecated functions after you are done with restoring and cleanup.</para>
   </sect1>
-  
+
     <sect1 id="create_new_db">
 	<title>Create a spatially-enabled database without using extensions</title>
 
diff --git a/doc/performance_tips.xml b/doc/performance_tips.xml
index adf2931..8832a75 100644
--- a/doc/performance_tips.xml
+++ b/doc/performance_tips.xml
@@ -8,7 +8,7 @@
     <sect2>
       <title>Problem description</title>
 
-      <para>Current PostgreSQL versions (including 8.0) suffer from a query
+      <para>Current PostgreSQL versions (including 9.6) suffer from a query
       optimizer weakness regarding TOAST tables. TOAST tables are a kind of
       "extension room" used to store large (in the sense of data size) values
       that do not fit into normal data pages (like long texts, images or
@@ -17,7 +17,7 @@
       information).</para>
 
       <para>The problem appears if you happen to have a table with rather
-      large geometries, but not too much rows of them (like a table containing
+      large geometries, but not too manyrows of them (like a table containing
       the boundaries of all European countries in high resolution). Then the
       table itself is small, but it uses lots of TOAST space. In our example
       case, the table itself had about 80 rows and used only 3 data pages, but
@@ -26,17 +26,19 @@
       <para>Now issue a query where you use the geometry operator &&
       to search for a bounding box that matches only very few of those rows.
       Now the query optimizer sees that the table has only 3 pages and 80
-      rows. He estimates that a sequential scan on such a small table is much
-      faster than using an index. And so he decides to ignore the GIST index.
+      rows. It estimates that a sequential scan on such a small table is much
+      faster than using an index. And so it decides to ignore the GIST index.
       Usually, this estimation is correct. But in our case, the &&
       operator has to fetch every geometry from disk to compare the bounding
       boxes, thus reading all TOAST pages, too.</para>
 
-      <para>To see whether your suffer from this bug, use the "EXPLAIN
+      <para>To see whether your suffer from this issue, use the "EXPLAIN
       ANALYZE" postgresql command. For more information and the technical
       details, you can read the thread on the postgres performance mailing
       list:
-      http://archives.postgresql.org/pgsql-performance/2005-02/msg00030.php</para>
+      <ulink url="http://archives.postgresql.org/pgsql-performance/2005-02/msg00030.php">http://archives.postgresql.org/pgsql-performance/2005-02/msg00030.php</ulink></para>
+
+      <para>and newer thread on PostGIS <ulink url="https://lists.osgeo.org/pipermail/postgis-devel/2017-June/026209.html">https://lists.osgeo.org/pipermail/postgis-devel/2017-June/026209.html</ulink></para>
     </sect2>
 
     <sect2>
@@ -146,7 +148,7 @@ VACUUM FULL ANALYZE mytable;</programlisting>
     geometries and rasters are heavy so memory related optimizations generally have more of an impact on PostGIS than other types of PostgreSQL queries.</para>
 
     <para>For general details about optimizing PostgreSQL, refer to <ulink url="https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server">Tuning your PostgreSQL Server</ulink>.</para>
-    
+
     <para>For PostgreSQL 9.4+ all these can be set at the server level without touching postgresql.conf or postgresql.auto.conf
     by using the <code>ALTER SYSTEM..</code> command.</para>
     <programlisting>ALTER SYSTEM SET work_mem = '256MB';
@@ -191,17 +193,17 @@ SHOW work_mem;</programlisting>
         <itemizedlist>
           <listitem>
             <para>
-              Default: ~32MB
+              Default: ~128MB in PostgreSQL 9.6
             </para>
           </listitem>
           <listitem>
             <para>
-              Set to about 1/3 to 3/4 of available RAM
+              Set to about 25% to 40% of available RAM.  On windows you may not be able to set as high.
             </para>
           </listitem>
         </itemizedlist>
-        
-        
+
+
        <para>
           <ulink url="https://www.postgresql.org/docs/current/static/runtime-config-resource.html#GUC-MAX-WORKER-PROCESSES">max_worker_processes</ulink>
           This setting is only available for PostgreSQL 9.4+.  For PostgreSQL 9.6+ this setting has additional importance in that it controls the
@@ -251,7 +253,7 @@ SHOW work_mem;</programlisting>
             <para>
                 If you have lots of RAM and few developers:
                 <programlisting>
-                    SET work_mem TO '256MB';;
+                    SET work_mem TO '256MB';
                 </programlisting>
             </para>
           </listitem>
@@ -282,10 +284,10 @@ SHOW work_mem;</programlisting>
             </para>
           </listitem>
         </itemizedlist>
-        
+
         <para>
           <ulink url="https://www.postgresql.org/docs/current/static/runtime-config-resource.html#GUC-MAX-PARALLEL-WORKERS-PER-GATHER">max_parallel_workers_per_gather</ulink>
-          This setting is only available for PostgreSQL 9.6+ and will only affect PostGIS 2.3+, since only PostGIS 2.3+ supports parallel queries.  
+          This setting is only available for PostgreSQL 9.6+ and will only affect PostGIS 2.3+, since only PostGIS 2.3+ supports parallel queries.
           If set to higher than 0, then some queries such as those involving relation functions like <code>ST_Intersects</code> can use multiple processes and can run
           more than twice as fast when doing so.  If you have a lot of processors to spare, you should change the value of this to as many processors as you have.
           Also make sure to bump up <code>max_worker_processes</code> to at least as high as this number.
diff --git a/doc/po/de_DE/release_notes.xml.po b/doc/po/de_DE/release_notes.xml.po
index 3fb00dd..3c297d5 100644
--- a/doc/po/de_DE/release_notes.xml.po
+++ b/doc/po/de_DE/release_notes.xml.po
@@ -920,7 +920,7 @@ msgstr ""
 #. Tag: para
 #: release_notes.xml:158
 #, no-c-format
-msgid "#3050, Speep up geometry type reading (J.Santana @ CartoDB)"
+msgid "#3050, Speed up geometry type reading (J.Santana @ CartoDB)"
 msgstr ""
 
 #. Tag: para
diff --git a/doc/po/es/release_notes.xml.po b/doc/po/es/release_notes.xml.po
index 186ed7d..7bef7c4 100644
--- a/doc/po/es/release_notes.xml.po
+++ b/doc/po/es/release_notes.xml.po
@@ -922,7 +922,7 @@ msgstr ""
 #. Tag: para
 #: release_notes.xml:158
 #, no-c-format
-msgid "#3050, Speep up geometry type reading (J.Santana @ CartoDB)"
+msgid "#3050, Speed up geometry type reading (J.Santana @ CartoDB)"
 msgstr ""
 
 #. Tag: para
diff --git a/doc/po/fr/release_notes.xml.po b/doc/po/fr/release_notes.xml.po
index fd49e4a..eedb600 100644
--- a/doc/po/fr/release_notes.xml.po
+++ b/doc/po/fr/release_notes.xml.po
@@ -922,7 +922,7 @@ msgstr ""
 #. Tag: para
 #: release_notes.xml:158
 #, no-c-format
-msgid "#3050, Speep up geometry type reading (J.Santana @ CartoDB)"
+msgid "#3050, Speed up geometry type reading (J.Santana @ CartoDB)"
 msgstr ""
 
 #. Tag: para
diff --git a/doc/po/it_IT/release_notes.xml.po b/doc/po/it_IT/release_notes.xml.po
index 91fa5fc..fcf708d 100644
--- a/doc/po/it_IT/release_notes.xml.po
+++ b/doc/po/it_IT/release_notes.xml.po
@@ -920,7 +920,7 @@ msgstr ""
 #. Tag: para
 #: release_notes.xml:158
 #, no-c-format
-msgid "#3050, Speep up geometry type reading (J.Santana @ CartoDB)"
+msgid "#3050, Speed up geometry type reading (J.Santana @ CartoDB)"
 msgstr ""
 
 #. Tag: para
diff --git a/doc/po/ja/release_notes.xml.po b/doc/po/ja/release_notes.xml.po
index eebeda8..a27016a 100644
--- a/doc/po/ja/release_notes.xml.po
+++ b/doc/po/ja/release_notes.xml.po
@@ -920,7 +920,7 @@ msgstr ""
 #. Tag: para
 #: release_notes.xml:158
 #, no-c-format
-msgid "#3050, Speep up geometry type reading (J.Santana @ CartoDB)"
+msgid "#3050, Speed up geometry type reading (J.Santana @ CartoDB)"
 msgstr ""
 
 #. Tag: para
diff --git a/doc/po/ko_KR/release_notes.xml.po b/doc/po/ko_KR/release_notes.xml.po
index f82814b..e91016b 100644
--- a/doc/po/ko_KR/release_notes.xml.po
+++ b/doc/po/ko_KR/release_notes.xml.po
@@ -920,7 +920,7 @@ msgstr ""
 #. Tag: para
 #: release_notes.xml:158
 #, no-c-format
-msgid "#3050, Speep up geometry type reading (J.Santana @ CartoDB)"
+msgid "#3050, Speed up geometry type reading (J.Santana @ CartoDB)"
 msgstr ""
 
 #. Tag: para
diff --git a/doc/po/pl/release_notes.xml.po b/doc/po/pl/release_notes.xml.po
index 67ea411..a6b820b 100644
--- a/doc/po/pl/release_notes.xml.po
+++ b/doc/po/pl/release_notes.xml.po
@@ -921,7 +921,7 @@ msgstr ""
 #. Tag: para
 #: release_notes.xml:158
 #, no-c-format
-msgid "#3050, Speep up geometry type reading (J.Santana @ CartoDB)"
+msgid "#3050, Speed up geometry type reading (J.Santana @ CartoDB)"
 msgstr ""
 
 #. Tag: para
diff --git a/doc/po/pt_BR/release_notes.xml.po b/doc/po/pt_BR/release_notes.xml.po
index f680c4f..df57d03 100644
--- a/doc/po/pt_BR/release_notes.xml.po
+++ b/doc/po/pt_BR/release_notes.xml.po
@@ -923,7 +923,7 @@ msgstr ""
 #. Tag: para
 #: release_notes.xml:158
 #, no-c-format
-msgid "#3050, Speep up geometry type reading (J.Santana @ CartoDB)"
+msgid "#3050, Speed up geometry type reading (J.Santana @ CartoDB)"
 msgstr ""
 
 #. Tag: para
diff --git a/doc/po/templates/release_notes.xml.pot b/doc/po/templates/release_notes.xml.pot
index 7137625..a434ea9 100644
--- a/doc/po/templates/release_notes.xml.pot
+++ b/doc/po/templates/release_notes.xml.pot
@@ -725,7 +725,7 @@ msgstr ""
 #. Tag: para
 #: release_notes.xml:158
 #, no-c-format
-msgid "#3050, Speep up geometry type reading (J.Santana @ CartoDB)"
+msgid "#3050, Speed up geometry type reading (J.Santana @ CartoDB)"
 msgstr ""
 
 #. Tag: para
diff --git a/doc/reference_measure.xml b/doc/reference_measure.xml
index 5c57765..a4accfb 100644
--- a/doc/reference_measure.xml
+++ b/doc/reference_measure.xml
@@ -1089,7 +1089,7 @@ SELECT ST_AsText(
 		  <itemizedlist>
               <listitem>
                   <para>
-                      A "core" geometry, that is within <varname>eps</varname> distance of at least <varname>minpoints</varname> other input geometries, or
+                      A "core" geometry, that is within <varname>eps</varname> distance of at least <varname>minpoints</varname> input geometries (including itself) or
                   </para>
 			  </listitem>
 			  <listitem>
diff --git a/doc/reference_processing.xml b/doc/reference_processing.xml
index 2b27710..c87beeb 100644
--- a/doc/reference_processing.xml
+++ b/doc/reference_processing.xml
@@ -1862,8 +1862,8 @@ from  ST_GeomFromText('LINESTRING Z (2 2 6,1.5 1.5 7,1 1 8,0.5 0.5 8,0 0 10)') A
 	  <refsection>
 		<title>Description</title>
 
-		<para>Converts plain LINESTRING/POLYGONS to CIRCULAR STRINGs and Curved Polygons.  Note much fewer points are needed to describe the curved equivalent.</para>
-
+		<para>Converts plain LINESTRING/POLYGON to CIRCULAR STRINGs and Curved Polygons.  Note much fewer points are needed to describe the curved equivalent.</para>
+		<note><para>If the input LINESTRING/POLYGON is not curved enough to clearly represent a curve, the function will return the same input geometry.</para></note>
 		<para>Availability: 1.2.2?</para>
 		<para>&Z_support;</para>
 		<para>&curve_support;</para>
@@ -1871,9 +1871,9 @@ from  ST_GeomFromText('LINESTRING Z (2 2 6,1.5 1.5 7,1 1 8,0.5 0.5 8,0 0 10)') A
 
 
 	  <refsection>
-		<title>Examples: 2D</title>
+		<title>Examples</title>
 
-		<programlisting>
+		<programlisting> -- 2D Example
 SELECT ST_AsText(ST_LineToCurve(foo.the_geom)) As curvedastext,ST_AsText(foo.the_geom) As non_curvedastext
 	FROM (SELECT ST_Buffer('POINT(1 3)'::geometry, 3) As the_geom) As foo;
 
@@ -1887,15 +1887,20 @@ CURVEPOLYGON(CIRCULARSTRING(4 3,3.12132034355964 0.878679656440359, | POLYGON((4
                                                                     |  -0.666710699058802 0.505591163092361,-1.12132034355964 0.878679656440353,
                                                                     |  -1.49440883690763 1.33328930094119,-1.77163859753386 1.85194970290472
                                                                     |  --ETC-- ,3.94235584120969 3.58527096604839,4 3))
---3D example
-SELECT ST_AsEWKT(ST_LineToCurve(ST_GeomFromEWKT('LINESTRING(1 2 3, 3 4 8, 5 6 4, 7 8 4, 9 10 4)')));
-
-			 st_asewkt
-------------------------------------
- CIRCULARSTRING(1 2 3,5 6 4,9 10 4)
 
-		</programlisting>
-	  </refsection>
+--3D example
+SELECT ST_AsText(ST_LineToCurve(geom)) As curved, ST_AsText(geom) AS not_curved
+FROM (SELECT ST_Translate(ST_Force3D(ST_Boundary(ST_Buffer(ST_Point(1,3), 2,2))),0,0,3) AS geom) AS foo;
+
+                        curved                        |               not_curved
+------------------------------------------------------+---------------------------------------------------------------------
+ CIRCULARSTRING Z (3 3 3,-1 2.99999999999999 3,3 3 3) | LINESTRING Z (3 3 3,2.4142135623731 1.58578643762691 3,1 1 3,
+                                                      |	-0.414213562373092 1.5857864376269 3,-1 2.99999999999999 3,
+                                                      | -0.414213562373101 4.41421356237309 3,
+                                                      |	0.999999999999991 5 3,2.41421356237309 4.4142135623731 3,3 3 3)
+(1 row)
+</programlisting>
+	</refsection>
 
 
 
diff --git a/doc/release_notes.xml b/doc/release_notes.xml
index a4a231c..7aa8d0f 100644
--- a/doc/release_notes.xml
+++ b/doc/release_notes.xml
@@ -3,6 +3,30 @@
   <title>Appendix</title>
     <subtitle>Release Notes</subtitle>
     <sect1>
+      <title>Release 2.3.3</title>
+      <para>Release date: 2017/07/01</para>
+      <para>This is a bug fix and performance improvement release.</para>
+      <simplesect>
+        <title>Bug Fixes and Enhancements</title>
+          <para>#3777, GROUP BY anomaly with empty geometries</para>
+          <para>#3711, Azimuth error upon adding 2.5D edges to topology</para>
+          <para>#3726, PDF manual from dblatex renders fancy quotes for programlisting
+                  (Mike Toews)</para>
+          <para>#3738, raster: Using -s without -Y in raster2pgsql transforms
+                  raster data instead of setting srid</para>
+          <para>#3744, ST_Subdivide loses subparts of inverted geometries
+                  (Darafei Praliaskouski Komzpa)</para>
+          <para>#3750, @ and ~ operator not always schema qualified in geometry
+                  and raster functions. Causes restore issues.
+                  (Shane StClair of Axiom Data Science)</para>
+          <para>#3682, Strange fieldlength for boolean in result of pgsql2shp</para>
+          <para>#3701, Escape double quotes issue in pgsql2shp</para>
+          <para>#3704, ST_AsX3D crashes on empty geometry</para>
+          <para>#3730, Change ST_Clip from Error to Notice when ST_Clip can't compute a band</para>
+      </simplesect>
+    </sect1>
+
+    <sect1>
       <title>Release 2.3.2</title>
       <para>Release date: 2017/01/31</para>
       <para>This is a bug fix and performance improvement release.</para>
@@ -15,7 +39,7 @@
           <para>#3688, ST_AsLatLonText: round minutes</para>
       </simplesect>
     </sect1>
-    
+
     <sect1>
       <title>Release 2.3.1</title>
       <para>Release date: 2016/11/28</para>
@@ -28,7 +52,7 @@
                 for large tables</para>
           <para>#3643, PostGIS not building on latest OSX XCode</para>
           <para>#3644, Deadlock on interrupt</para>
-          <para>#3650, Mark ST_Extent, ST_3DExtent and ST_Mem* 
+          <para>#3650, Mark ST_Extent, ST_3DExtent and ST_Mem*
                 agg functions as parallel safe so they can be parallelized</para>
           <para>#3652, Crash on Collection(MultiCurve())</para>
           <para>#3656, Fix upgrade of aggregates from 2.2 or lower version</para>
@@ -40,21 +64,21 @@
             patch from Hugo Mercier (Oslandia)</para>
       </simplesect>
     </sect1>
-      
+
     <sect1>
       <title>Release 2.3.0</title>
         <para>Release date: 2016/09/26</para>
         <para>This is a new feature release, with new functions, improved performance, all relevant bug fixes from PostGIS 2.2.3,and other goodies.</para>
-        
+
       <simplesect>
         <title>Important / Breaking Changes</title>
           <para>#3466, Casting from box3d to geometry now returns a 3D
-                   geometry (Julien Rouhaud of Dalibo)</para>     
+                   geometry (Julien Rouhaud of Dalibo)</para>
           <para>#3396, ST_EstimatedExtent, throw WARNING instead of ERROR
                    (Regina Obe)</para>
       </simplesect>
-      
-      
+
+
       <simplesect>
           <title>New Features</title>
             <para>Add support for custom TOC in postgis_restore.pl
@@ -68,7 +92,7 @@
             <para>#1758, ST_Normalize (Sandro Santilli)</para>
             <para>#2236, shp2pgsql -d now emits "DROP TABLE IF EXISTS"</para>
             <para>#2259, ST_VoronoiPolygons and ST_VoronoiLines (Dan Baston)</para>
-            <para>#2841 and #2996, ST_MinimumBoundingRadius and new ST_MinimumBoundingCircle 
+            <para>#2841 and #2996, ST_MinimumBoundingRadius and new ST_MinimumBoundingCircle
                      implementation using Welzl's algorithm (Dan Baston)</para>
             <para>#2991, Enable ST_Transform to use PROJ.4 text (Mike Toews)</para>
             <para>#3059, Allow passing per-dimension parameters in ST_Expand (Dan Baston)</para>
@@ -95,7 +119,7 @@
             <para>#3613, Segmentize geography using equal length segments
                      (Hugo Mercier of Oslandia)</para>
       </simplesect>
-      
+
       <simplesect>
           <title>Bug Fixes</title>
              <para>All relevant bug fixes from PostGIS 2.2.3</para>
@@ -103,7 +127,7 @@
              <para>#3604, pgcommon/Makefile.in orders CFLAGS incorrectly leading to
                      wrong liblwgeom.h (Greg Troxel)</para>
       </simplesect>
-      
+
       <simplesect>
           <title>Performance Enhancements</title>
             <para>#75, Enhancement to PIP short circuit (Dan Baston)</para>
@@ -113,9 +137,9 @@
             <para>Make adding a line to topology interruptible (Sandro Santilli)</para>
             <para>Documentation updates from Mike Toews</para>
       </simplesect>
-    
+
     </sect1>
-   
+
    <sect1>
       <title>Release 2.2.2</title>
         <para>Release date: 2016/03/22</para>
@@ -136,7 +160,7 @@
           <para>#3426, failing POINT EMPTY tests on fun architectures</para>
         </simplesect>
     </sect1>
-    
+
      <sect1>
   <title>Release 2.2.1</title>
       <para>Release date: 2016/01/06</para>
@@ -260,7 +284,7 @@
         <title>Bug Fixes</title>
         <para>#3159, do not force a bbox cache on ST_Affine</para>
         <para>#3018, GROUP BY geography sometimes returns duplicate rows</para>
-        <para>#3048, shp2pgsql - illegal number format when specific system locale set</para>
+        <para>#3084, shp2pgsql - illegal number format when specific system locale set</para>
         <para>#3094, Malformed GeoJSON inputs crash backend</para>
         <para>#3104, st_asgml introduces random characters in ID field</para>
         <para>#3155, Remove liblwgeom.h on make uninstall</para>
@@ -289,7 +313,7 @@
         <title>Enhancements</title>
         <para>#3000, Ensure edge splitting and healing algorithms use indexes</para>
         <para>#3048, Speed up geometry simplification (J.Santana @ CartoDB)</para>
-        <para>#3050, Speep up geometry type reading (J.Santana @ CartoDB)</para>
+        <para>#3050, Speed up geometry type reading (J.Santana @ CartoDB)</para>
       </simplesect>
       <simplesect>
         <title>Bug Fixes</title>
diff --git a/doc/texstyle.sty b/doc/texstyle.sty
new file mode 100644
index 0000000..58689bb
--- /dev/null
+++ b/doc/texstyle.sty
@@ -0,0 +1,14 @@
+%%
+%% This style is derived from the manual
+%% http://dblatex.sourceforge.net/doc/manual/sec-custom-latex.html
+%%
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{texstyle}[2017/04/25 PostGIS DocBook Style]
+
+%% Just use the original package and pass the options
+\RequirePackageWithOptions{docbook}
+
+%% Make regular quotes within programlisting tags (#3726)
+\usepackage{listings}
+\lstset{upquote=true}
+
diff --git a/doc/tiger_geocoder_comments.sql b/doc/tiger_geocoder_comments.sql
index 4412f4d..bd8bd7c 100644
--- a/doc/tiger_geocoder_comments.sql
+++ b/doc/tiger_geocoder_comments.sql
@@ -9,7 +9,7 @@ COMMENT ON FUNCTION geocode(varchar , integer , geometry ) IS 'args: address, ma
 			
 COMMENT ON FUNCTION geocode(norm_addy , integer , geometry ) IS 'args: in_addy, max_results=10, restrict_region=NULL, OUT addy, OUT geomout, OUT rating - Takes in an address as a string (or other normalized address) and outputs a set of possible locations which include a point geometry in NAD 83 long lat, a normalized address for each, and the rating. The lower the rating the more likely the match. Results are sorted by lowest rating first. Can optionally pass in maximum results, default [...]
 			
-COMMENT ON FUNCTION geocode_intersection(text , text , text , text , text , integer ) IS 'args:  roadway1,  roadway2,  in_state,  in_city,  in_zip, max_results=10, OUT addy, OUT geomout, OUT rating - Takes in 2 streets that intersect and a state, city, zip, and outputs a set of possible locations on the first cross street that is at the intersection, also includes a geomout as the point location in NAD 83 long lat, a normalized_address (addy) for each location, and the rating. The lower  [...]
+COMMENT ON FUNCTION geocode_intersection(text , text , text , text , text , integer ) IS 'args:  roadway1,  roadway2,  in_state,  in_city,  in_zip, num_results=10, OUT addy, OUT geomout, OUT rating - Takes in 2 streets that intersect and a state, city, zip, and outputs a set of possible locations on the first cross street that is at the intersection, also includes a geomout as the point location in NAD 83 long lat, a normalized_address (addy) for each location, and the rating. The lower  [...]
 			
 COMMENT ON FUNCTION Get_Geocode_Setting(text ) IS 'args:  setting_name - Returns value of specific setting stored in tiger.geocode_settings table.';
 			
diff --git a/doc/using_postgis_dataman.xml b/doc/using_postgis_dataman.xml
index c908163..ef9ffc6 100644
--- a/doc/using_postgis_dataman.xml
+++ b/doc/using_postgis_dataman.xml
@@ -90,7 +90,7 @@ geometry = ST_GeometryFromText(text WKT, SRID);</programlisting>
 	  SRID information.</para>
 
 	  <para>Examples of the text representations (EWKT) of the extended
-	  spatial objects of the features are as follows. The * ones are new in this version of PostGIS:</para>
+	  spatial objects of the features are as follows.</para>
 
 	  <itemizedlist>
 		<listitem>
@@ -748,16 +748,17 @@ SELECT AddGeometryColumn( 'roads', 'roads_geom', 0, 'GEOMETRY', 3 );</programlis
 
 	<sect2 id="Manual_Register_Spatial_Column">
 		<title>Manually Registering Geometry Columns in geometry_columns</title>
-		<para>The AddGeometryColumn() approach creates a geometry column and also registers the new
-		column in the geometry_columns table.  If your software utilizes geometry_columns, then
-		any geometry columns you need to query by must be registered in this view.
+		<para>The AddGeometryColumn() approach creates a geometry column of specified type.
+		This  type and dimension are queryable from the <varname>geometry_columns</varname> view.
 		Starting with PostGIS 2.0, geometry_columns is no longer editable and all geometry columns are autoregistered.</para>
-		<para>However they may be registered as a generic geometry column if the column was not defined as a specific type during creation.</para>
+		<para>If your geometry columns were created as generic in a table or view and no constraints applied, they will not have a dimension, type or srid in geometry_columns views, but will still be listed.</para>
 
 		<para>Two of the cases
 		where this may happen, but you can't use
-		AddGeometryColumn, is in the case of SQL Views and bulk inserts.  For these cases, you can correct the registration in the geometry_columns table
-		by constraining the column.  Note in PostGIS 2.0+ if your column is typmod based, the creation process would register it correctly, so no need to do anything.</para>
+		AddGeometryColumn, is in the case of SQL Views and bulk inserts.  For bulk insert case, you can correct the registration in the geometry_columns table
+		by constraining the column or doing an alter table.  For views, you could expose using a CAST operation.
+		Note in PostGIS 2.0+ if your column is typmod based, the creation process would register it correctly, so no need to do anything.
+		Also views that have no spatial function applied to the geometry will register the same as the underlying table geometry column.</para>
 
 		<programlisting>--Lets say you have a view created like this
 CREATE VIEW  public.vwmytablemercator AS
@@ -805,7 +806,7 @@ SELECT populate_geometry_columns('myschema.my_special_pois'::regclass);
 -- set new optional  use_typmod argument to false
 SELECT populate_geometry_columns('myschema.my_special_pois'::regclass, false); </programlisting>
 
-<para>Although the old-constraint based method is still supported, a constraint-based geomentry column used directly
+<para>Although the old-constraint based method is still supported, a constraint-based geometry column used directly
 in a view, will not register correctly in geometry_columns, as will a typmod one.
 In this example we define a column using typmod and another using constraints.</para>
 <programlisting>CREATE TABLE pois_ny(gid SERIAL PRIMARY KEY
diff --git a/doc/xsl/postgis_gardentest.sql.xsl b/doc/xsl/postgis_gardentest.sql.xsl
index 32b65d3..c962024 100644
--- a/doc/xsl/postgis_gardentest.sql.xsl
+++ b/doc/xsl/postgis_gardentest.sql.xsl
@@ -32,11 +32,11 @@
 	<xsl:variable name='var_matrix'>'FF1FF0102'</xsl:variable>
 	<xsl:variable name='var_boolean'>false</xsl:variable>
 	<xsl:variable name='var_logtable'>postgis_garden_log23</xsl:variable>
-	<xsl:variable name='var_logupdatesql'>UPDATE <xsl:value-of select="$var_logtable" /> SET log_end = clock_timestamp() 
+	<xsl:variable name='var_logupdatesql'>UPDATE <xsl:value-of select="$var_logtable" /> SET log_end = clock_timestamp()
 		FROM (SELECT logid FROM <xsl:value-of select="$var_logtable" /> ORDER BY logid DESC limit 1) As foo
 		WHERE <xsl:value-of select="$var_logtable" />.logid = foo.logid  AND <xsl:value-of select="$var_logtable" />.log_end IS NULL;</xsl:variable>
-		
-	<!-- for queries that result data, we first log the sql in our log table and then use query_to_xml to output it as xml for easy storage 
+
+	<!-- for queries that result data, we first log the sql in our log table and then use query_to_xml to output it as xml for easy storage
 	    with this approach our run statement is always exactly the same -->
 	<xsl:variable name='var_logresultsasxml'>INSERT INTO <xsl:value-of select="$var_logtable" />_output(logid, log_output)
 				SELECT logid, query_to_xml(log_sql, false,false,'') As log_output
@@ -77,7 +77,7 @@
 FROM (VALUES ( ST_GeomFromEWKT('SRID=4326;POLYGONM((-71.1319 42.2503 1,-71.132 42.2502 3,-71.1323 42.2504 -2,-71.1322 42.2505 1,-71.1319 42.2503 0))') ),
 	( ST_GeomFromEWKT('SRID=4326;POLYGONM((-71.1319 42.2512 0,-71.1318 42.2511 20,-71.1317 42.2511 -20,-71.1317 42.251 5,-71.1317 42.2509 4,-71.132 42.2511 6,-71.1319 42.2512 30))') )
 		)	As g(geom))</pgis:gset>
-		
+
 		<pgis:gset ID='POINTZ' GeometryType='POINTZ'>(SELECT ST_SetSRID(ST_MakePoint(i,j,k),4326) As the_geom
 		FROM generate_series(-10,50,20) As i
 			CROSS JOIN generate_series(40,70, 20) j
@@ -92,48 +92,48 @@ FROM (VALUES ( ST_GeomFromEWKT('SRID=4326;POLYGONM((-71.1319 42.2503 1,-71.132 4
 		FROM generate_series(-10,50,20) As i
 			CROSS JOIN generate_series(50,70, 20) As j
 			CROSS JOIN generate_series(1,2) As m
-			ORDER BY i, j, i+j+m, m, i*j*m)</pgis:gset>-->	
+			ORDER BY i, j, i+j+m, m, i*j*m)</pgis:gset>-->
 		<pgis:gset ID='POLYGONZ' GeometryType='POLYGONZ'>(SELECT geom  As the_geom
 FROM (VALUES ( ST_GeomFromEWKT('SRID=4326;POLYGON((-71.0771 42.3866 1,-71.0767 42.3872 1,-71.0767 42.3863 1,-71.0771 42.3866 1))') ),
 	( ST_GeomFromEWKT('SRID=4326;POLYGON((-71.0775 42.386 2,-71.0773 42.3863 1.75,-71.0773 42.3859 1.75,-71.0775 42.386 2))') )
 		)	As g(geom))</pgis:gset>
-		
+
 		<pgis:gset ID='POLYGONZM' GeometryType='POLYGONZM'>(SELECT geom  As the_geom
 FROM (VALUES ( ST_GeomFromEWKT('SRID=4326;POLYGON((-71.0771 42.3866 1 2,-71.0767 42.3872 1 2.3,-71.0767 42.3863 1 2.3,-71.0771 42.3866 1 2))') ),
 	( ST_GeomFromEWKT('SRID=4326;POLYGON((-71.0775 42.386 2 1.5,-71.0773 42.3863 1.75 1.5,-71.0773 42.3859 1.75 1.5,-71.0775 42.386 2 1.5))') )
 		)	As g(geom))</pgis:gset>
-			
+
 		<pgis:gset ID='POLYHEDRALSURFACE' GeometryType='POLYHEDRALSURFACE'>(SELECT ST_Translate(the_geom,-72.2, 41.755) As the_geom
 		FROM (VALUES ( ST_GeomFromEWKT(
-'SRID=4326;PolyhedralSurface( 
-((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)),  
-((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)), ((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)),  ((1 1 0, 1 1 1, 1 0 1, 1 0 0, 1 1 0)),  
-((0 1 0, 0 1 1, 1 1 1, 1 1 0, 0 1 0)),  ((0 0 1, 1 0 1, 1 1 1, 0 1 1, 0 0 1)) 
+'SRID=4326;PolyhedralSurface(
+((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)),
+((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)), ((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)),  ((1 1 0, 1 1 1, 1 0 1, 1 0 0, 1 1 0)),
+((0 1 0, 0 1 1, 1 1 1, 1 1 0, 0 1 0)),  ((0 0 1, 1 0 1, 1 1 1, 0 1 1, 0 0 1))
 )') ) ,
 ( ST_GeomFromEWKT(
-'SRID=4326;PolyhedralSurface( 
-((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)),  
+'SRID=4326;PolyhedralSurface(
+((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)),
 ((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)) )') ) )
 As foo(the_geom)  ) </pgis:gset>
 
 		<pgis:gset ID='TRIANGLE' GeometryType='TRIANGLE'>(SELECT ST_GeomFromEWKT(
 'SRID=4326;TRIANGLE ((
-                -71.0821 42.3036, 
-                -71.0821 42.3936, 
-                -71.0901 42.3036, 
+                -71.0821 42.3036,
+                -71.0821 42.3936,
+                -71.0901 42.3036,
                 -71.0821 42.3036
             ))') As the_geom) </pgis:gset>
-            
+
 		<pgis:gset ID='TIN' GeometryType='TIN'>(SELECT ST_GeomFromEWKT(
 'SRID=4326;TIN (((
-                -71.0821 42.3036 0, 
-               -71.0821 42.3036 1, 
-                -71.0821 42.3436 0, 
+                -71.0821 42.3036 0,
+               -71.0821 42.3036 1,
+                -71.0821 42.3436 0,
                 -71.0821 42.3036 0
             )), ((
-                -71.0821 42.3036 0, 
-                -71.0821 42.3436 0, 
-                -71.0831 42.3436 0, 
+                -71.0821 42.3036 0,
+                -71.0821 42.3436 0,
+                -71.0831 42.3436 0,
                 -71.0821 42.3036 0
             ))
             )') As the_geom) </pgis:gset>
@@ -149,7 +149,7 @@ As foo(the_geom)  ) </pgis:gset>
 		)	As g(geom) CROSS JOIN generate_series(1,3) As i
 		GROUP BY i
 			)</pgis:gset>
-			
+
 		<pgis:gset ID='GEOMETRYCOLLECTIONM' GeometryType='GEOMETRYCOLLECTIONM' SkipUnary='1'>(SELECT ST_Collect(geom)  As the_geom
 		FROM (VALUES ( ST_GeomFromEWKT('SRID=4326;MULTIPOLYGONM(((-71.0821 42.3036 2,-71.0822 42.3036 3,-71.082 42.3038 2,-71.0819 42.3037 2,-71.0821 42.3036 2)))') ),
 	( ST_GeomFromEWKT('SRID=4326;POLYGONM((-71.1261 42.2703 1,-71.1257 42.2703 1,-71.1257 42.2701 2,-71.126 42.2701 1,-71.1261 42.2702 1,-71.1261 42.2703 1))') )
@@ -196,7 +196,7 @@ As foo(the_geom)  ) </pgis:gset>
 FROM (VALUES ( ST_GeomFromEWKT('SRID=4326;MULTIPOLYGON(((-71.0821 42.3036 2,-71.0822 42.3036 2,-71.082 42.3038 2,-71.0819 42.3037 2,-71.0821 42.3036 2)))') ),
 	( ST_GeomFromEWKT('SRID=4326;MULTIPOLYGON(((-71.1261 42.2703 1,-71.1257 42.2703 1,-71.1257 42.2701 1,-71.126 42.2701 1,-71.1261 42.2702 1,-71.1261 42.2703 1)))') )
 		)	As g(geom))</pgis:gset>
-			
+
 
 		<pgis:gset ID='MULTIPOINTM' GeometryType='MULTIPOINTM'>(SELECT ST_Collect(s.the_geom) As the_geom
 		FROM (SELECT ST_SetSRID(ST_MakePointM(i - 0.0821,j + 0.3036,m),4326) As the_geom
@@ -215,11 +215,11 @@ FROM (VALUES ( ST_GeomFromEWKT('SRID=4326;MULTIPOLYGON(((-71.0821 42.3036 2,-71.
 		<pgis:gset ID='MULTIPOLYGONM' GeometryType='MULTIPOLYGONM'>(
 			SELECT ST_GeomFromEWKT('SRID=4326;MULTIPOLYGONM(((0 0 2,10 0 1,10 10 -2,0 10 -5,0 0 -5),(5 5 6,7 5 6,7 7 6,5 7 10,5 5 -2)))')  As the_geom
 			)</pgis:gset>
-			
+
 		<!-- replacing crasher with a more harmless curve polygon and circular string -->
 		<pgis:gset ID='CURVEPOLYGON' GeometryType='CURVEPOLYGON'>(SELECT ST_GeomFromEWKT('SRID=4326;CURVEPOLYGON(CIRCULARSTRING(-71.0821 42.3036, -71.4821 42.3036, -71.7821 42.7036, -71.0821 42.7036, -71.0821 42.3036),(-71.1821 42.4036, -71.3821 42.6036, -71.3821 42.4036, -71.1821 42.4036) ) ') As the_geom)</pgis:gset>
-		
-		<pgis:gset ID='CURVEPOLYGON2' GeometryType='CURVEPOLYGON'>(SELECT ST_LineToCurve(ST_Buffer(ST_SetSRID(ST_Point(i,j),4326), j))  As the_geom 
+
+		<pgis:gset ID='CURVEPOLYGON2' GeometryType='CURVEPOLYGON'>(SELECT ST_LineToCurve(ST_Buffer(ST_SetSRID(ST_Point(i,j),4326), j))  As the_geom
 		        FROM generate_series(-10,50,10) As i
 					CROSS JOIN generate_series(40,70, 20) As j
 					ORDER BY i, j, i*j)
@@ -235,12 +235,12 @@ FROM (VALUES ( ST_GeomFromEWKT('SRID=4326;MULTIPOLYGON(((-71.0821 42.3036 2,-71.
 			UNION ALL SELECT ST_GeomFromText('MULTILINESTRING EMPTY',4326) As the_geom
 		)
 		</pgis:gset>
-		
-	
+
+
 		<pgis:gset ID="Empty Geometry Collection" GeometryType="GEOMETRY" createtable="false">
 		 (SELECT ST_GeomFromText('GEOMETRYCOLLECTION EMPTY',4326) As the_geom )
 		</pgis:gset>
-			
+
 		<pgis:gset ID="Single NULL" GeometryType="GEOMETRY" createtable="false">(SELECT CAST(Null As geometry) As the_geom)</pgis:gset>
 		<pgis:gset ID="Multiple NULLs" GeometryType="GEOMETRY" createtable="false">(SELECT CAST(Null As geometry) As the_geom FROM generate_series(1,4) As foo)</pgis:gset>
 
@@ -264,13 +264,13 @@ FROM (VALUES ( ST_GeomFromEWKT('SRID=4326;MULTIPOLYGON(((-71.0821 42.3036 2,-71.
 				FROM generate_series(-10,50,10) As i
 					CROSS JOIN generate_series(40,70, 20) As j
 					ORDER BY i, j, i*j)</pgis:gset>
-					
+
 		<pgis:gset ID="Collection of Empties" GeometryType="GEOMETRY" createtable="false">(SELECT ST_Collect(ST_GeomFromText('GEOMETRYCOLLECTION EMPTY',4326), ST_GeomFromText('POLYGON EMPTY',4326)) As the_geom
 			UNION ALL SELECT ST_COLLECT(ST_GeomFromText('POLYGON EMPTY',4326),ST_GeomFromText('TRIANGLE EMPTY',4326))  As the_geom
 			UNION ALL SELECT ST_Collect(ST_GeomFromText('POINT EMPTY',4326), ST_GeomFromText('MULTIPOINT EMPTY',4326)) As the_geom
 		)</pgis:gset>
 		<pgis:gset ID="POLYGON EMPTY" GeometryType="POLYGON" createtable="false">(SELECT ST_GeomFromText('POLYGON EMPTY',4326) As the_geom)</pgis:gset>
-		
+
 
 	<pgis:gardencrashers>
 
@@ -298,7 +298,7 @@ SELECT '<xsl:value-of select="$log_label" />: Start Testing';
 			FROM (<xsl:value-of select="." />) As foo limit 1;
 	SELECT AddGeometryColumn('pgis_garden','the_geom_multi',ST_SRID(the_geom),GeometryType(ST_Multi(the_geom)),ST_CoordDim(the_geom))
 			FROM (<xsl:value-of select="." />) As foo limit 1;</xsl:variable>
-INSERT INTO <xsl:value-of select="$var_logtable" />(log_label, func, g1, log_start, log_sql) 
+INSERT INTO <xsl:value-of select="$var_logtable" />(log_label, func, g1, log_start, log_sql)
 VALUES('<xsl:value-of select="$log_label" /> AddGeometryColumn','AddGeometryColumn', '<xsl:value-of select="@GeometryType" />', clock_timestamp(),
     '<xsl:call-template name="escapesinglequotes"><xsl:with-param name="arg1"><xsl:value-of select="$var_sql" /></xsl:with-param></xsl:call-template>');
 BEGIN;
@@ -323,7 +323,7 @@ COMMIT;
 SELECT '<xsl:value-of select="$log_label" /> geometry brin index: End Testing <xsl:value-of select="@ID" />';
 
 
-INSERT INTO <xsl:value-of select="$var_logtable" />(log_label, func, g1, log_start, log_sql) 
+INSERT INTO <xsl:value-of select="$var_logtable" />(log_label, func, g1, log_start, log_sql)
 VALUES('<xsl:value-of select="$log_label" /> insert data Geometry','insert data', '<xsl:value-of select="@ID" />', clock_timestamp(), '<xsl:call-template name="escapesinglequotes">
  <xsl:with-param name="arg1">INSERT INTO pgis_garden(the_geom, the_geom_multi)
 	SELECT the_geom, ST_Multi(the_geom)
@@ -334,7 +334,7 @@ BEGIN;
 	SELECT the_geom, ST_Multi(the_geom)
 	FROM (<xsl:value-of select="." />) As foo;
 	<xsl:value-of select="$var_logupdatesql" />
-COMMIT;	
+COMMIT;
 
 
 SELECT '<xsl:value-of select="$log_label" /> Geometry index overlaps: Start Testing <xsl:value-of select="@ID" />';
@@ -346,27 +346,27 @@ BEGIN;
 COMMIT;
 
 SELECT '<xsl:value-of select="$log_label" /> geometry index overlaps: End Testing <xsl:value-of select="@ID" />';
-		
-INSERT INTO <xsl:value-of select="$var_logtable" />(log_label, func, g1, log_start) 
+
+INSERT INTO <xsl:value-of select="$var_logtable" />(log_label, func, g1, log_start)
 VALUES('<xsl:value-of select="$log_label" /> UpdateGeometrySRID','UpdateGeometrySRID', '<xsl:value-of select="@GeometryType" />', clock_timestamp());
 BEGIN;
 	SELECT UpdateGeometrySRID('pgis_garden', 'the_geom', 4269);
 	<xsl:value-of select="$var_logupdatesql" />
 COMMIT;
 
-INSERT INTO <xsl:value-of select="$var_logtable" />(log_label, func, g1, log_start) 
+INSERT INTO <xsl:value-of select="$var_logtable" />(log_label, func, g1, log_start)
 VALUES('<xsl:value-of select="$log_label" /> vacuum analyze Geometry','vacuum analyze Geometry', '<xsl:value-of select="@ID" />', clock_timestamp());
 VACUUM ANALYZE pgis_garden;
 <xsl:value-of select="$var_logupdatesql" />
 
-INSERT INTO <xsl:value-of select="$var_logtable" />(log_label, func, g1, log_start) 
+INSERT INTO <xsl:value-of select="$var_logtable" />(log_label, func, g1, log_start)
 VALUES('<xsl:value-of select="$log_label" /> DropGeometryColumn','DropGeometryColumn', '<xsl:value-of select="@GeometryType" />', clock_timestamp());
 
 BEGIN;
 	SELECT DropGeometryColumn ('pgis_garden','the_geom');
 	<xsl:value-of select="$var_logupdatesql" />
 COMMIT;
-INSERT INTO <xsl:value-of select="$var_logtable" />(log_label, func, g1, log_start) 
+INSERT INTO <xsl:value-of select="$var_logtable" />(log_label, func, g1, log_start)
 VALUES('<xsl:value-of select="$log_label" /> DropGeometryTable','DropGeometryTable', '<xsl:value-of select="@ID" />', clock_timestamp());
 
 BEGIN;
@@ -441,7 +441,7 @@ SELECT '<xsl:value-of select="$log_label" /> Geography: End Testing';
 		<xsl:for-each select="document('')//pgis:gardens/pgis:gset">
 		<xsl:choose>
 			  <xsl:when test="contains($fndef, 'geography')">
-			  INSERT INTO <xsl:value-of select="$var_logtable" />(log_label, func, g1, g2, log_start, log_sql) 
+			  INSERT INTO <xsl:value-of select="$var_logtable" />(log_label, func, g1, g2, log_start, log_sql)
 			  	VALUES('<xsl:value-of select="$log_label" /> Geography <xsl:value-of select="$geom1id" /><xsl:text> </xsl:text><xsl:value-of select="@ID" />','<xsl:value-of select="$fnname" />', '<xsl:value-of select="$geom1id" />','<xsl:value-of select="@ID" />', clock_timestamp(),
 			  	'<xsl:call-template name="escapesinglequotes">
  <xsl:with-param name="arg1">SELECT ST_AsEWKT(foo1.the_geom) as ewktgeog1, ST_AsEWKT(foo2.the_geom) as ewktgeog2, geography(foo1.the_geom) <xsl:value-of select="$fnname" /> geography(foo2.the_geom) As geog1_op_geog2
@@ -458,7 +458,7 @@ SELECT '<xsl:value-of select="$log_label" /> Geography: End Testing';
 			</xsl:when>
 			<xsl:otherwise>
 			SELECT 'Geometry <xsl:value-of select="$fnname" /><xsl:text> </xsl:text><xsl:value-of select="@ID" />: Start Testing <xsl:value-of select="$geom1id" />, <xsl:value-of select="@ID" />';
-			 INSERT INTO <xsl:value-of select="$var_logtable" />(log_label, func, g1, g2, log_start, log_sql) 
+			 INSERT INTO <xsl:value-of select="$var_logtable" />(log_label, func, g1, g2, log_start, log_sql)
 			  	VALUES('<xsl:value-of select="$log_label" /> Geometry <xsl:value-of select="$geom1id" /><xsl:text> </xsl:text><xsl:value-of select="@ID" />','<xsl:value-of select="$fnname" />', '<xsl:value-of select="$geom1id" />','<xsl:value-of select="@ID" />', clock_timestamp(),
 			  	'<xsl:call-template name="escapesinglequotes">
  <xsl:with-param name="arg1">SELECT ST_AsEWKT(foo1.the_geom) as ewktgeom1, ST_AsEWKT(foo2.the_geom) as ewktgeom2, foo1.the_geom <xsl:value-of select="$fnname" /> foo2.the_geom As geom1_op_geom2
@@ -508,7 +508,7 @@ SELECT '<xsl:value-of select="$log_label" /> Geography: End Testing';
 					</xsl:otherwise>
 				  </xsl:choose>
 				</xsl:variable>
-				
+
 				<!-- is a window function -->
 				<xsl:variable name='over_clause'>
 					 <xsl:choose>
@@ -524,14 +524,14 @@ SELECT '<xsl:value-of select="$log_label" /> Geography: End Testing';
 				<xsl:choose>
 <!--Test functions that take no arguments and take no geometries/geographies -->
 	<xsl:when test="($numparamgeoms = '0' and $numparamgeogs = '0') and not(contains($fnexclude,funcdef/function))">SELECT  'Starting <xsl:value-of select="funcdef/function" />(<xsl:value-of select="$fnargs" />)';
-INSERT INTO <xsl:value-of select="$var_logtable" />(log_label, func, log_start, log_sql) 
+INSERT INTO <xsl:value-of select="$var_logtable" />(log_label, func, log_start, log_sql)
 			  	VALUES('<xsl:value-of select="$log_label" /> <xsl:value-of select="$geoftype" />','<xsl:value-of select="$fnname" />', clock_timestamp(),
 			  	    '<xsl:call-template name="escapesinglequotes">
  <xsl:with-param name="arg1">SELECT  <xsl:value-of select="funcdef/function" />(<xsl:value-of select="$fnfakeparams" />) As output;</xsl:with-param></xsl:call-template>');
-	
+
 BEGIN;
     <xsl:value-of select="$var_logresultsasxml" />
-	<xsl:value-of select="$var_logupdatesql" />	
+	<xsl:value-of select="$var_logupdatesql" />
 COMMIT;
 SELECT  'Ending <xsl:value-of select="funcdef/function" />(<xsl:value-of select="$fnargs" />)';
 	</xsl:when>
@@ -542,17 +542,17 @@ SELECT  'Ending <xsl:value-of select="funcdef/function" />(<xsl:value-of select=
 		<xsl:for-each select="document('')//pgis:gardens/pgis:gset">
 		SELECT '<xsl:value-of select="$geoftype" /> <xsl:value-of select="$fnname" /><xsl:text> </xsl:text><xsl:value-of select="@ID" />: Start Testing';
 
-	INSERT INTO <xsl:value-of select="$var_logtable" />(log_label, func, g1, log_start, log_sql) 
+	INSERT INTO <xsl:value-of select="$var_logtable" />(log_label, func, g1, log_start, log_sql)
 			  	VALUES('<xsl:value-of select="$log_label" /> <xsl:value-of select="$geoftype" />  <xsl:text> </xsl:text><xsl:value-of select="@ID" /><xsl:text> </xsl:text>','<xsl:value-of select="$fnname" />', '<xsl:value-of select="@ID" />', clock_timestamp(),
 			  	'<xsl:call-template name="escapesinglequotes">
  <xsl:with-param name="arg1">SELECT <xsl:value-of select="$fnname" />(<xsl:value-of select="$fnfakeparams" />)<xsl:value-of select="$over_clause" />  As result
 							FROM (<xsl:value-of select="." />) As foo1
-				LIMIT 3;</xsl:with-param></xsl:call-template>');
+				LIMIT 10;</xsl:with-param></xsl:call-template>');
 BEGIN;
     <xsl:value-of select="$var_logresultsasxml" />
-	<xsl:value-of select="$var_logupdatesql" />	
-COMMIT;		  
-			SELECT '<xsl:value-of select="$geoftype" /> <xsl:value-of select="$fnname" /><xsl:text> </xsl:text><xsl:value-of select="@ID" />: End Testing';	
+	<xsl:value-of select="$var_logupdatesql" />
+COMMIT;
+			SELECT '<xsl:value-of select="$geoftype" /> <xsl:value-of select="$fnname" /><xsl:text> </xsl:text><xsl:value-of select="@ID" />: End Testing';
 		</xsl:for-each>
 	</xsl:when>
 
@@ -567,12 +567,12 @@ SELECT '<xsl:value-of select="$fnname" /> <xsl:text> </xsl:text><xsl:value-of se
 				<xsl:for-each select="document('')//pgis:gardens/pgis:gset">
 			<xsl:choose>
 			  <xsl:when test="($numparamgeogs > '0' or $numparamgeoms > '0')">
-	INSERT INTO <xsl:value-of select="$var_logtable" />(log_label, func, g1, g2,  log_start, log_sql) 
+	INSERT INTO <xsl:value-of select="$var_logtable" />(log_label, func, g1, g2,  log_start, log_sql)
 			  	VALUES('<xsl:value-of select="$log_label" /> <xsl:value-of select="$geoftype" /> <xsl:text> </xsl:text> <xsl:value-of select="@ID" />','<xsl:value-of select="$fnname" />','<xsl:value-of select="$geom1id" />', '<xsl:value-of select="@ID" />', clock_timestamp(),
 			  			'<xsl:call-template name="escapesinglequotes">
  <xsl:with-param name="arg1">SELECT <xsl:value-of select="$fnname" />(<xsl:value-of select="$fnfakeparams" />) As result, ST_AsText(foo1.the_geom) As ref1_geom, ST_AsText(foo2.the_geom) As ref2_geom
 	FROM (<xsl:value-of select="$from1" />) As foo1 CROSS JOIN (<xsl:value-of select="." />) As foo2
-			LIMIT 2;</xsl:with-param></xsl:call-template>');
+			LIMIT 10;</xsl:with-param></xsl:call-template>');
 
 			BEGIN;
 				 <xsl:value-of select="$var_logresultsasxml" />
@@ -580,7 +580,7 @@ SELECT '<xsl:value-of select="$fnname" /> <xsl:text> </xsl:text><xsl:value-of se
 			COMMIT;
 			</xsl:when>
 			  <xsl:otherwise>
-			  	INSERT INTO <xsl:value-of select="$var_logtable" />(log_label, func, g1, g2, log_start, log_sql) 
+			  	INSERT INTO <xsl:value-of select="$var_logtable" />(log_label, func, g1, g2, log_start, log_sql)
 			  	VALUES('<xsl:value-of select="$log_label" /> Other <xsl:text> </xsl:text><xsl:value-of select="$geom1id" /><xsl:text> </xsl:text><xsl:value-of select="@ID" />','<xsl:value-of select="$fnname" />', '<xsl:value-of select="$geom1id" />','<xsl:value-of select="@DI" />', clock_timestamp(),
 			  	'<xsl:call-template name="escapesinglequotes">
  <xsl:with-param name="arg1">SELECT <xsl:value-of select="$fnname" />(<xsl:value-of select="$fnfakeparams" />)</xsl:with-param></xsl:call-template>');
@@ -592,7 +592,7 @@ SELECT '<xsl:value-of select="$fnname" /> <xsl:text> </xsl:text><xsl:value-of se
 				COMMIT;
 			  </xsl:otherwise>
 			</xsl:choose>
-		
+
 	SELECT '<xsl:value-of select="$fnname" />(<xsl:value-of select="$fnargs" />) <xsl:text> </xsl:text> <xsl:value-of select="@ID" />: End Testing <xsl:value-of select="$geom1id" />, <xsl:value-of select="@GeometryType" />';
 		<xsl:text>
 
@@ -733,7 +733,7 @@ SELECT '<xsl:value-of select="$fnname" /><xsl:text> </xsl:text><xsl:value-of sel
 			</xsl:for-each>
 		</xsl:for-each>
 	</xsl:template>
-	
+
 	<!-- copied from http://www.thedumbterminal.co.uk/php/knowledgebase/?action=view&id=94 -->
     <xsl:template name="escapesinglequotes">
      <xsl:param name="arg1"/>
diff --git a/extensions/address_standardizer/Makefile b/extensions/address_standardizer/Makefile
index 20e1e0f..99f6555 100644
--- a/extensions/address_standardizer/Makefile
+++ b/extensions/address_standardizer/Makefile
@@ -30,14 +30,14 @@ POSTGIS_PGSQL_VERSION=96
 SQLPP = /usr/bin/cpp -traditional-cpp -w -P
 GREP=/bin/grep
 PERL=/usr/bin/perl
-EXTVERSION    = 2.3.2
+EXTVERSION    = 2.3.3
 MINORVERSION  = 2.3
 MODULE_big = address_standardizer-2.3
 EXTENSION = address_standardizer
 DATA = address_standardizer_data_us.control sql/$(EXTENSION).sql sql/$(EXTENSION)_data_us.sql
 
 all:  sql/address_standardizer.sql sql/address_standardizer--1.0--$(EXTVERSION).sql sql/address_standardizer--$(EXTVERSION).sql sql/address_standardizer--$(EXTVERSION)--$(EXTVERSION)next.sql sql/address_standardizer--$(EXTVERSION)next--$(EXTVERSION).sql \
- sql/$(EXTENSION)_data_us.sql sql/address_standardizer--2.3.2.sql sql/$(EXTENSION)_data_us--2.3.2.sql  sql/$(EXTENSION)_data_us--$(EXTVERSION)--$(EXTVERSION)next.sql \
+ sql/$(EXTENSION)_data_us.sql sql/address_standardizer--2.3.3.sql sql/$(EXTENSION)_data_us--2.3.3.sql  sql/$(EXTENSION)_data_us--$(EXTVERSION)--$(EXTVERSION)next.sql \
 sql/$(EXTENSION)_data_us--$(EXTVERSION)next--$(EXTVERSION).sql \
 sql/test-init-extensions.sql sql/test-parseaddress.sql sql/test-standardize_address_1.sql sql/test-standardize_address_2.sql
 
@@ -68,7 +68,7 @@ sql/%.sql: %.sql.in
 	$(SQLPP) -I../libpgcommon $< | grep -v '^#' | \
 	$(PERL) -lpe "s'MODULE_PATHNAME'\$$libdir/${EXTENSION}-${MINORVERSION}'g" > $@
 	
-sql/address_standardizer--2.3.2.sql: sql/address_standardizer_types.sql \
+sql/address_standardizer--2.3.3.sql: sql/address_standardizer_types.sql \
     sql/address_standardizer_functions.sql
 	cat $^ > $@
 	
diff --git a/extensions/address_standardizer/address_standardizer.control b/extensions/address_standardizer/address_standardizer.control
index 011a6fa..cecffff 100644
--- a/extensions/address_standardizer/address_standardizer.control
+++ b/extensions/address_standardizer/address_standardizer.control
@@ -1,4 +1,4 @@
 # address_standardizer extension
 comment = 'Used to parse an address into constituent elements. Generally used to support geocoding address normalization step.'
-default_version = '2.3.2'
+default_version = '2.3.3'
 relocatable = true
diff --git a/extensions/address_standardizer/address_standardizer_data_us.control b/extensions/address_standardizer/address_standardizer_data_us.control
index 65e5218..881ed9a 100644
--- a/extensions/address_standardizer/address_standardizer_data_us.control
+++ b/extensions/address_standardizer/address_standardizer_data_us.control
@@ -1,4 +1,4 @@
 # address standardizer us dataset
 comment = 'Address Standardizer US dataset example'
-default_version = '2.3.2'
+default_version = '2.3.3'
 relocatable = true
diff --git a/extensions/postgis/Makefile b/extensions/postgis/Makefile
index 69e6848..f230041 100644
--- a/extensions/postgis/Makefile
+++ b/extensions/postgis/Makefile
@@ -1,7 +1,7 @@
 include ../upgradeable_versions.mk
 
 EXTENSION     = postgis
-EXTVERSION    = 2.3.2
+EXTVERSION    = 2.3.3
 MINORVERSION  = 2.3
 GREP = /bin/grep
 PERL = /usr/bin/perl
diff --git a/extensions/postgis/postgis.control b/extensions/postgis/postgis.control
index 5156b26..b48b9a0 100644
--- a/extensions/postgis/postgis.control
+++ b/extensions/postgis/postgis.control
@@ -1,5 +1,5 @@
 # postgis extension
 comment = 'PostGIS geometry, geography, and raster spatial types and functions'
-default_version = '2.3.2'
+default_version = '2.3.3'
 module_pathname = '$libdir/postgis-2.3'
 relocatable = false
diff --git a/extensions/postgis_sfcgal/Makefile b/extensions/postgis_sfcgal/Makefile
index 3a9c146..e0d5cf1 100644
--- a/extensions/postgis_sfcgal/Makefile
+++ b/extensions/postgis_sfcgal/Makefile
@@ -1,7 +1,7 @@
 include ../upgradeable_versions.mk
 
 EXTENSION    = postgis_sfcgal
-EXTVERSION    = 2.3.2
+EXTVERSION    = 2.3.3
 MINORVERSION  = 2.3
 GREP = /bin/grep
 PERL = /usr/bin/perl
diff --git a/extensions/postgis_sfcgal/postgis_sfcgal.control b/extensions/postgis_sfcgal/postgis_sfcgal.control
index ae39248..3781181 100644
--- a/extensions/postgis_sfcgal/postgis_sfcgal.control
+++ b/extensions/postgis_sfcgal/postgis_sfcgal.control
@@ -1,5 +1,5 @@
 # postgis topology extension
 comment = 'PostGIS SFCGAL functions'
-default_version = '2.3.2'
+default_version = '2.3.3'
 relocatable = true
 requires = postgis
diff --git a/extensions/postgis_tiger_geocoder/Makefile b/extensions/postgis_tiger_geocoder/Makefile
index c5b4813..bd7c834 100644
--- a/extensions/postgis_tiger_geocoder/Makefile
+++ b/extensions/postgis_tiger_geocoder/Makefile
@@ -1,7 +1,7 @@
 include ../upgradeable_versions.mk
 
 EXTENSION    = postgis_tiger_geocoder
-EXTVERSION    = 2.3.2
+EXTVERSION    = 2.3.3
 MINORVERSION  = 2011.2.3
 GREP = /bin/grep
 PERL = /usr/bin/perl
diff --git a/extensions/postgis_tiger_geocoder/postgis_tiger_geocoder.control b/extensions/postgis_tiger_geocoder/postgis_tiger_geocoder.control
index 45bbc5b..d8f1c73 100644
--- a/extensions/postgis_tiger_geocoder/postgis_tiger_geocoder.control
+++ b/extensions/postgis_tiger_geocoder/postgis_tiger_geocoder.control
@@ -1,6 +1,6 @@
 # postgis tiger geocoder extension
 comment = 'PostGIS tiger geocoder and reverse geocoder'
-default_version = '2.3.2'
+default_version = '2.3.3'
 relocatable = false
 schema = tiger
 requires = 'postgis,fuzzystrmatch'
diff --git a/extensions/postgis_topology/Makefile b/extensions/postgis_topology/Makefile
index 84e2267..bc31e9a 100644
--- a/extensions/postgis_topology/Makefile
+++ b/extensions/postgis_topology/Makefile
@@ -1,7 +1,7 @@
 include ../upgradeable_versions.mk
 
 EXTENSION     = postgis_topology
-EXTVERSION    = 2.3.2
+EXTVERSION    = 2.3.3
 MINORVERSION  = 2.3
 GREP = /bin/grep
 PERL = /usr/bin/perl
diff --git a/extensions/postgis_topology/postgis_topology.control b/extensions/postgis_topology/postgis_topology.control
index be7b734..36d3b99 100644
--- a/extensions/postgis_topology/postgis_topology.control
+++ b/extensions/postgis_topology/postgis_topology.control
@@ -1,6 +1,6 @@
 # postgis topology extension
 comment = 'PostGIS topology spatial types and functions'
-default_version = '2.3.2'
+default_version = '2.3.3'
 relocatable = false
 schema = topology
 requires = postgis
diff --git a/extensions/upgradeable_versions.mk b/extensions/upgradeable_versions.mk
index 751ae95..5a83e62 100644
--- a/extensions/upgradeable_versions.mk
+++ b/extensions/upgradeable_versions.mk
@@ -24,7 +24,8 @@ UPGRADEABLE_VERSIONS = \
 	2.2.4 \
 	2.2.5 \
 	2.3.0 \
-	2.3.1
+	2.3.1 \
+    2.3.2
 
 # This is to avoid forcing "check-installed-upgrades" as a default
 # rule, see https://trac.osgeo.org/postgis/ticket/3420
diff --git a/liblwgeom/lwgeom.c b/liblwgeom/lwgeom.c
index 769d001..54e053b 100644
--- a/liblwgeom/lwgeom.c
+++ b/liblwgeom/lwgeom.c
@@ -1950,11 +1950,11 @@ lwgeom_subdivide_recursive(const LWGEOM *geom, int maxvertices, int depth, LWCOL
 		return n;
 	}
 	
-	/* But don't go too far. 2^25 = 33M, that's enough subdivision */
-	/* Signal callers above that we depth'ed out with a negative */
-	/* return value */
+	/* But don't go too far. 2^50 ~= 10^15, that's enough subdivision */
+	/* Just add what's left */
 	if ( depth > maxdepth )
 	{
+		lwcollection_add_lwgeom(col, lwgeom_clone_deep(geom));
 		return 0;
 	}
 	
@@ -2001,15 +2001,17 @@ lwgeom_subdivide_recursive(const LWGEOM *geom, int maxvertices, int depth, LWCOL
 	clipped1 = lwgeom_clip_by_rect(geom, subbox1.xmin, subbox1.ymin, subbox1.xmax, subbox1.ymax);
 	clipped2 = lwgeom_clip_by_rect(geom, subbox2.xmin, subbox2.ymin, subbox2.xmax, subbox2.ymax);
 	
+	++depth;
+	
 	if ( clipped1 )
 	{
-		n += lwgeom_subdivide_recursive(clipped1, maxvertices, ++depth, col, &subbox1);
+		n += lwgeom_subdivide_recursive(clipped1, maxvertices, depth, col, &subbox1);
 		lwgeom_free(clipped1);
 	}
 
 	if ( clipped2 )
 	{
-		n += lwgeom_subdivide_recursive(clipped2, maxvertices, ++depth, col, &subbox2);
+		n += lwgeom_subdivide_recursive(clipped2, maxvertices, depth, col, &subbox2);
 		lwgeom_free(clipped2);
 	}
 	
diff --git a/liblwgeom/lwgeom_topo.c b/liblwgeom/lwgeom_topo.c
index 33fbc46..6fd3a00 100644
--- a/liblwgeom/lwgeom_topo.c
+++ b/liblwgeom/lwgeom_topo.c
@@ -1401,7 +1401,7 @@ typedef struct edgeend_t {
  * Get first distinct vertex from endpoint
  * @param pa the pointarray to seek points in
  * @param ref the point we want to search a distinct one
- * @param from vertex index to start from
+ * @param from vertex index to start from (will really start from "from"+dir)
  * @param dir  1 to go forward
  *            -1 to go backward
  * @return 0 if edge is collapsed (no distinct points)
@@ -1570,7 +1570,12 @@ _lwt_FindAdjacentEdges( LWT_TOPOLOGY* topo, LWT_ELEMID node, edgeend *data,
 
     if ( edge->start_node == node ) {
       getPoint2d_p(pa, 0, &p1);
-      getPoint2d_p(pa, 1, &p2);
+      if ( ! _lwt_FirstDistinctVertex2D(pa, &p1, 0, 1, &p2) )
+      {
+        lwerror("Edge %d has no distinct vertices: [%.15g %.15g,%.15g %.15g]: ",
+                edge->edge_id, p1.x, p1.y, p2.x, p2.y);
+        return -1;
+      }
       LWDEBUGF(1, "edge %" LWTFMT_ELEMID
                   " starts on node %" LWTFMT_ELEMID
                   ", edgeend is %g,%g-%g,%g",
@@ -1627,7 +1632,12 @@ _lwt_FindAdjacentEdges( LWT_TOPOLOGY* topo, LWT_ELEMID node, edgeend *data,
 
     if ( edge->end_node == node ) {
       getPoint2d_p(pa, pa->npoints-1, &p1);
-      getPoint2d_p(pa, pa->npoints-2, &p2);
+      if ( ! _lwt_FirstDistinctVertex2D(pa, &p1, pa->npoints-1, -1, &p2) )
+      {
+        lwerror("Edge %d has no distinct vertices: [%.15g %.15g,%.15g %.15g]: ",
+                edge->edge_id, p1.x, p1.y, p2.x, p2.y);
+        return -1;
+      }
       LWDEBUGF(1, "edge %" LWTFMT_ELEMID " ends on node %" LWTFMT_ELEMID
                   ", edgeend is %g,%g-%g,%g",
                   edge->edge_id, node, p1.x, p1.y, p2.x, p2.y);
@@ -2362,6 +2372,7 @@ _lwt_AddEdge( LWT_TOPOLOGY* topo,
   newedge.geom = geom;
   newedge.face_left = -1;
   newedge.face_right = -1;
+  /* TODO: should do the repeated points removal in 2D space */
   cleangeom = lwgeom_remove_repeated_points( lwline_as_lwgeom(geom), 0 );
 
   pa = lwgeom_as_lwline(cleangeom)->points;
@@ -2375,18 +2386,17 @@ _lwt_AddEdge( LWT_TOPOLOGY* topo,
   span.cwFace = span.ccwFace =
   epan.cwFace = epan.ccwFace = -1;
 
-  /* Compute azimut of first edge end on start node */
+  /* Compute azimuth of first edge end on start node */
   getPoint2d_p(pa, 0, &p1);
-  getPoint2d_p(pa, 1, &pn);
-  if ( p2d_same(&p1, &pn) ) {
+  if ( ! _lwt_FirstDistinctVertex2D(pa, &p1, 0, 1, &pn) )
+  {
     lwgeom_free(cleangeom);
-    /* Can still happen, for 2-point lines */
     lwerror("Invalid edge (no two distinct vertices exist)");
     return -1;
   }
   if ( ! azimuth_pt_pt(&p1, &pn, &span.myaz) ) {
     lwgeom_free(cleangeom);
-    lwerror("error computing azimuth of first edgeend [%g,%g-%g,%g]",
+    lwerror("error computing azimuth of first edgeend [%.15g %.15g,%.15g %.15g]",
             p1.x, p1.y, pn.x, pn.y);
     return -1;
   }
@@ -2394,10 +2404,16 @@ _lwt_AddEdge( LWT_TOPOLOGY* topo,
 
   /* Compute azimuth of last edge end on end node */
   getPoint2d_p(pa, pa->npoints-1, &p2);
-  getPoint2d_p(pa, pa->npoints-2, &pn);
+  if ( ! _lwt_FirstDistinctVertex2D(pa, &p2, pa->npoints-1, -1, &pn) )
+  {
+    lwgeom_free(cleangeom);
+    /* This should never happen as we checked the edge while computing first edgend */
+    lwerror("Invalid clean edge (no two distinct vertices exist) - should not happen");
+    return -1;
+  }
   lwgeom_free(cleangeom);
   if ( ! azimuth_pt_pt(&p2, &pn, &epan.myaz) ) {
-    lwerror("error computing azimuth of last edgeend [%g,%g-%g,%g]",
+    lwerror("error computing azimuth of last edgeend [%.15g %.15g,%.15g %.15g]",
             p2.x, p2.y, pn.x, pn.y);
     return -1;
   }
diff --git a/liblwgeom/lwout_x3d.c b/liblwgeom/lwout_x3d.c
index e6058e0..5dd2a51 100644
--- a/liblwgeom/lwout_x3d.c
+++ b/liblwgeom/lwout_x3d.c
@@ -61,6 +61,15 @@ lwgeom_to_x3d3(const LWGEOM *geom, char *srs, int precision, int opts, const cha
 {
 	int type = geom->type;
 
+	/* Empty string for empties */
+	if( lwgeom_is_empty(geom) )
+	{
+		char *ret = NULL;
+		ret = lwalloc(1);
+		ret[0] = '\0';
+		return ret;
+	}
+
 	switch (type)
 	{
 	case POINTTYPE:
@@ -156,7 +165,7 @@ asx3d3_line_size(const LWLINE *line, char *srs, int precision, int opts, const c
 	size_t defidlen = strlen(defid);
 
 	size = pointArray_X3Dsize(line->points, precision)*2;
-	
+
 	if ( X3D_USE_GEOCOORDS(opts) ) {
 			size += (
 	            sizeof("<LineSet vertexCount=''><GeoCoordinate geoSystem='\"GD\" \"WE\" \"longitude_first\"' point='' /></LineSet>")  + defidlen
@@ -394,7 +403,7 @@ asx3d3_multi_size(const LWCOLLECTION *col, char *srs, int precision, int opts, c
 		size = sizeof("<PointSet><GeoCoordinate geoSystem='\"GD\" \"WE\" \"longitude_first\"' point='' /></PointSet>");
 	else
 		size = sizeof("<PointSet><Coordinate point='' /></PointSet>") + defidlen;
-	
+
 
 	/* if ( srs ) size += strlen(srs) + sizeof(" srsName=.."); */
 
@@ -525,7 +534,7 @@ asx3d3_psurface_size(const LWPSURFACE *psur, char *srs, int precision, int opts,
 
 	if ( X3D_USE_GEOCOORDS(opts) ) size = sizeof("<IndexedFaceSet convex='false' coordIndex=''><GeoCoordinate geoSystem='\"GD\" \"WE\" \"longitude_first\"' point='' />") + defidlen;
 	else size = sizeof("<IndexedFaceSet convex='false' coordIndex=''><Coordinate point='' />") + defidlen;
-	
+
 
 	for (i=0; i<psur->ngeoms; i++)
 	{
@@ -658,7 +667,7 @@ asx3d3_tin_buf(const LWTIN *tin, char *srs, char *output, int precision, int opt
 
 	if ( X3D_USE_GEOCOORDS(opts) ) ptr += sprintf(ptr, "'><GeoCoordinate geoSystem='\"GD\" \"WE\" \"%s\"' point='", ( (opts & LW_X3D_FLIP_XY) ? "latitude_first" : "longitude_first") );
 	else ptr += sprintf(ptr, "'><Coordinate point='");
-	
+
 	for (i=0; i<tin->ngeoms; i++)
 	{
 		ptr += asx3d3_triangle_buf(tin->geoms[i], 0, ptr, precision,
@@ -781,12 +790,12 @@ asx3d3_collection_buf(const LWCOLLECTION *col, char *srs, char *output, int prec
 		else if ( subgeom->type == TINTYPE )
 		{
 			ptr += asx3d3_tin_buf((LWTIN*)subgeom, srs, ptr, precision, opts,  defid);
-			
+
 		}
 		else if ( subgeom->type == POLYHEDRALSURFACETYPE )
 		{
 			ptr += asx3d3_psurface_buf((LWPSURFACE*)subgeom, srs, ptr, precision, opts,  defid);
-			
+
 		}
 		else if ( lwgeom_is_collection(subgeom) )
 		{
@@ -862,7 +871,7 @@ pointArray_toX3D3(POINTARRAY *pa, char *output, int precision, int opts, int is_
 
 				if ( i )
 					ptr += sprintf(ptr, " ");
-					
+
 				if ( ( opts & LW_X3D_FLIP_XY) )
 					ptr += sprintf(ptr, "%s %s", y, x);
 				else
diff --git a/libtool b/libtool
index a2f6fc6..6e40ef0 100755
--- a/libtool
+++ b/libtool
@@ -1,6 +1,5 @@
 #! /bin/bash
 # Generated automatically by config.status () 
-# Libtool was configured on host Debbie:
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
 
 # Provide generalized library-building support services.
@@ -51,7 +50,7 @@ build_old_libs=yes
 pic_mode=default
 
 # Whether or not to optimize for fast installation.
-fast_install=yes
+fast_install=needless
 
 # Shared archive member basename,for filename based shared library versioning on AIX.
 shared_archive_member_spec=
@@ -250,7 +249,7 @@ runpath_var=LD_RUN_PATH
 shlibpath_var=LD_LIBRARY_PATH
 
 # Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=no
+shlibpath_overrides_runpath=yes
 
 # Format of library name prefix.
 libname_spec="lib\$name"
@@ -529,7 +528,7 @@ func_cc_basename ()
 
 PROGRAM=libtool
 PACKAGE=libtool
-VERSION="2.4.6 Debian-2.4.6-0.1"
+VERSION="2.4.6 Debian-2.4.6-2"
 package_revision=2.4.6
 
 
@@ -2566,7 +2565,7 @@ include the following information:
        compiler:       $LTCC
        compiler flags: $LTCFLAGS
        linker:         $LD (gnu? $with_gnu_ld)
-       version:        $progname (GNU libtool) 2.4.6
+       version:        $progname $scriptversion Debian-2.4.6-2
        automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
        autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
 
diff --git a/loader/pgsql2shp-core.c b/loader/pgsql2shp-core.c
index 7856d1e..8952c10 100644
--- a/loader/pgsql2shp-core.c
+++ b/loader/pgsql2shp-core.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * PostGIS - Spatial Types for PostgreSQL
- * http://www.postgis.org
+ * http://postgis.net
  *
  * Copyright (C) 2001-2003 Refractions Research Inc.
  *
@@ -15,6 +15,7 @@
  * Original Author: Jeff Lounsbury <jeffloun at refractions.net>
  * Contributions by: Sandro Santilli <strk at keybit.bet>
  * Enhanced by: Mark Cave-Ayland <mark.cave-ayland at siriusit.co.uk>
+ * Enhanced by: Regina Obe <lr at pcorp.us>
  *
  **********************************************************************/
 
@@ -882,14 +883,14 @@ getTableInfo(SHPDUMPERSTATE *state)
 		if (state->schema)
 		{
 			query = malloc(150 + 4 * strlen(state->geo_col_name) + strlen(state->schema) + strlen(state->table));
-	
+
 			sprintf(query, "SELECT count(\"%s\"), max(ST_zmflag(\"%s\"::geometry)), geometrytype(\"%s\"::geometry) FROM \"%s\".\"%s\" GROUP BY geometrytype(\"%s\"::geometry)",
 			state->geo_col_name, state->geo_col_name, state->geo_col_name, state->schema, state->table, state->geo_col_name);
 		}
 		else
 		{
 			query = malloc(150 + 4 * strlen(state->geo_col_name) + strlen(state->table));
-	
+
 			sprintf(query, "SELECT count(\"%s\"), max(ST_zmflag(\"%s\"::geometry)), geometrytype(\"%s\"::geometry) FROM \"%s\" GROUP BY geometrytype(\"%s\"::geometry)",
 			state->geo_col_name, state->geo_col_name, state->geo_col_name, state->table, state->geo_col_name);
 		}
@@ -900,7 +901,7 @@ getTableInfo(SHPDUMPERSTATE *state)
 		if (state->schema)
 		{
 			query = malloc(40 + strlen(state->schema) + strlen(state->table));
-			
+
 			sprintf(query, "SELECT count(1) FROM \"%s\".\"%s\"", state->schema, state->table);
 		}
 		else
@@ -973,7 +974,7 @@ getTableInfo(SHPDUMPERSTATE *state)
 					typemismatch = 1;
 				else
 					typefound = MULTILINETYPE;
-				break;					
+				break;
 
 			case MULTIPOLYGONTYPE:
 				if (typefound != MULTIPOLYGONTYPE && typefound != POLYGONTYPE)
@@ -1043,11 +1044,11 @@ getTableInfo(SHPDUMPERSTATE *state)
 			case 'z':
 				state->outshptype = SHPT_POINTZ;
 				break;
-	
+
 			case 'm':
 				state->outshptype = SHPT_POINTM;
 				break;
-	
+
 			default:
 				state->outshptype = SHPT_POINT;
 			}
@@ -1059,11 +1060,11 @@ getTableInfo(SHPDUMPERSTATE *state)
 			case 'z':
 				state->outshptype = SHPT_MULTIPOINTZ;
 				break;
-	
+
 			case 'm':
 				state->outshptype = SHPT_MULTIPOINTM;
 				break;
-	
+
 			default:
 				state->outshptype = SHPT_MULTIPOINT;
 			}
@@ -1076,11 +1077,11 @@ getTableInfo(SHPDUMPERSTATE *state)
 			case 'z':
 				state->outshptype = SHPT_ARCZ;
 				break;
-	
+
 			case 'm':
 				state->outshptype = SHPT_ARCM;
 				break;
-	
+
 			default:
 				state->outshptype = SHPT_ARC;
 			}
@@ -1093,11 +1094,11 @@ getTableInfo(SHPDUMPERSTATE *state)
 			case 'z':
 				state->outshptype = SHPT_POLYGONZ;
 				break;
-	
+
 			case 'm':
 				state->outshptype = SHPT_POLYGONM;
 				break;
-	
+
 			default:
 				state->outshptype = SHPT_POLYGON;
 			}
@@ -1167,7 +1168,7 @@ ShpDumperCreate(SHPDUMPERCONFIG *config)
 	state->pgfieldnames = NULL;
 	state->big_endian = is_bigendian();
 	colmap_init(&state->column_map);
-	
+
 	return state;
 }
 
@@ -1177,7 +1178,7 @@ ShpDumperGetConnectionStringFromConn(SHPCONNECTIONCONFIG *conn)
 {
 	char *connstring;
 	int connlen;
-	
+
 	connlen = 64 +
 		(conn->host ? strlen(conn->host) : 0) + (conn->port ? strlen(conn->port) : 0) +
 		(conn->username ? strlen(conn->username) : 0) + (conn->password ? strlen(conn->password) : 0) +
@@ -1205,7 +1206,7 @@ ShpDumperGetConnectionStringFromConn(SHPCONNECTIONCONFIG *conn)
 	}
 
 	if (conn->password)
-	{	
+	{
 		strcat(connstring, " password='");
 		strcat(connstring, conn->password);
 		strcat(connstring, "'");
@@ -1265,7 +1266,7 @@ ShpDumperConnectDatabase(SHPDUMPERSTATE *state)
 		snprintf(state->message, SHPDUMPERMSGLEN, "%s", PQresultErrorMessage(res));
 		PQclear(res);
 		free(connstring);
-		return SHPDUMPERERR;		
+		return SHPDUMPERERR;
 	}
 
 	tmpvalue = PQgetvalue(res, 0, 0);
@@ -1280,7 +1281,7 @@ ShpDumperConnectDatabase(SHPDUMPERSTATE *state)
 		snprintf(state->message, SHPDUMPERMSGLEN, _("Error looking up geometry oid: %s"), PQresultErrorMessage(res));
 		PQclear(res);
 		free(connstring);
-		return SHPDUMPERERR;		
+		return SHPDUMPERERR;
 	}
 
 	if (PQntuples(res) > 0)
@@ -1305,7 +1306,7 @@ ShpDumperConnectDatabase(SHPDUMPERSTATE *state)
 		snprintf(state->message, SHPDUMPERMSGLEN, _("Error looking up geography oid: %s"), PQresultErrorMessage(res));
 		PQclear(res);
 		free(connstring);
-		return SHPDUMPERERR;		
+		return SHPDUMPERERR;
 	}
 
 	if (PQntuples(res) > 0)
@@ -1341,7 +1342,7 @@ ShpDumperOpenTable(SHPDUMPERSTATE *state)
 		                  &state->column_map, state->message, SHPDUMPERMSGLEN);
 		if (!ret) return SHPDUMPERERR;
 	}
-		
+
 	/* If a user-defined query has been specified, create and point the state to our new table */
 	if (state->config->usrquery)
 	{
@@ -1434,7 +1435,7 @@ ShpDumperOpenTable(SHPDUMPERSTATE *state)
 	{
 		state->dbf = DBFCreateEx(state->shp_file, "UTF-8");
 	}
-		
+
 	if (!state->dbf)
 	{
 		snprintf(state->message, SHPDUMPERMSGLEN, _("Could not create dbf file %s"), state->shp_file);
@@ -1485,7 +1486,7 @@ ShpDumperOpenTable(SHPDUMPERSTATE *state)
 				if (!state->config->geo_col_name || !strcmp(state->config->geo_col_name, pgfieldname))
 				{
 					dbffieldtype = 9;
-	
+
 					state->geo_col_name = strdup(pgfieldname);
 				}
 			}
@@ -1534,7 +1535,7 @@ ShpDumperOpenTable(SHPDUMPERSTATE *state)
 			  dbffieldname[10] = '\0';
 			}
 		}
-			
+
 		/*
 		 * make sure the fields all have unique names,
 		 */
@@ -1629,7 +1630,7 @@ ShpDumperOpenTable(SHPDUMPERSTATE *state)
 		else if (pgfieldtype == 16)
 		{
 			dbffieldtype = FTLogical;
-			dbffieldsize = 2;
+			dbffieldsize = 1;
 			dbffielddecs = 0;
 		}
 
@@ -1748,14 +1749,14 @@ ShpDumperOpenTable(SHPDUMPERSTATE *state)
 				snprintf(buf, 256, _("Warning: values of field '%s' exceeding maximum dbf field width (%d) "
 					"will be truncated.\n"), dbffieldname, MAX_DBF_FIELD_SIZE);
 				strncat(state->message, buf, SHPDUMPERMSGLEN - strlen(state->message));
-				dbffieldsize = MAX_DBF_FIELD_SIZE;				
+				dbffieldsize = MAX_DBF_FIELD_SIZE;
 
 				ret = SHPDUMPERWARN;
 			}
 		}
 
 		LWDEBUGF(3, "DBF FIELD_NAME: %s, SIZE: %d\n", dbffieldname, dbffieldsize);
-	
+
 		if (dbffieldtype != 9)
 		{
 			/* Add the field to the DBF file */
@@ -1765,14 +1766,14 @@ ShpDumperOpenTable(SHPDUMPERSTATE *state)
 
 				return SHPDUMPERERR;
 			}
-	
+
 			/* Add the field information to our field arrays */
 			state->dbffieldnames[state->fieldcount] = dbffieldname;
 			state->dbffieldtypes[state->fieldcount] = dbffieldtype;
 			state->pgfieldnames[state->fieldcount] = pgfieldname;
 			state->pgfieldlens[state->fieldcount] = pgfieldlen;
 			state->pgfieldtypmods[state->fieldcount] = pgtypmod;
-			
+
 			state->fieldcount++;
 		}
 	}
@@ -1804,7 +1805,7 @@ ShpDumperOpenTable(SHPDUMPERSTATE *state)
 			strncat(state->message, buf, SHPDUMPERMSGLEN - strlen(state->message));
 
 			state->shp = NULL;
-			
+
 			ret = SHPDUMPERWARN;
 		}
 	}
@@ -1819,16 +1820,17 @@ ShpDumperOpenTable(SHPDUMPERSTATE *state)
 			return SHPDUMPERERR;
 		}
 	}
-	
+
 
 	/* Now we have the complete list of fieldnames, let's generate the SQL query. First let's make sure
 	   we reserve enough space for tables with lots of columns */
 	j = 0;
+	/*TODO: this really should be rewritten to use stringbuffer */
 	for (i = 0; i < state->fieldcount; i++)
-		j += strlen(state->pgfieldnames[i] + 2);	/* Add 2 for leading and trailing quotes */
-	
+		j += strlen( state->pgfieldnames[i]) + 10;	/*add extra space for the quotes to quote identify and any embedded quotes that may need escaping */
+
 	state->main_scan_query = malloc(1024 + j);
-	
+
 	sprintf(state->main_scan_query, "DECLARE cur ");
 	if (state->config->binary)
 		strcat(state->main_scan_query, "BINARY ");
@@ -1840,11 +1842,11 @@ ShpDumperOpenTable(SHPDUMPERSTATE *state)
 		/* Comma-separated column names */
 		if (i > 0)
 			strcat(state->main_scan_query, ",");
-			
+
 		if (state->config->binary)
-			sprintf(buf, "\"%s\"::text", state->pgfieldnames[i]);
+			sprintf(buf, "%s::text", quote_identifier(state->pgfieldnames[i]) ) ;
 		else
-			sprintf(buf, "\"%s\"", state->pgfieldnames[i]);
+			sprintf(buf, "%s", quote_identifier(state->pgfieldnames[i]) );
 
 		strcat(state->main_scan_query, buf);
 	}
@@ -1855,29 +1857,29 @@ ShpDumperOpenTable(SHPDUMPERSTATE *state)
 		/* If this is the (only) column, no need for the initial comma */
 		if (state->fieldcount > 0)
 			strcat(state->main_scan_query, ",");
-		
+
 		if (state->big_endian)
 		{
 			if (state->pgis_major_version > 0)
 			{
-				sprintf(buf, "ST_asEWKB(ST_SetSRID(\"%s\"::geometry, 0), 'XDR') AS _geoX", state->geo_col_name);
+				sprintf(buf, "ST_asEWKB(ST_SetSRID(%s::geometry, 0), 'XDR') AS _geoX", quote_identifier(state->geo_col_name) );
 			}
 			else
 			{
-				sprintf(buf, "asbinary(\"%s\"::geometry, 'XDR') AS _geoX",
-					state->geo_col_name);
+				sprintf(buf, "asbinary(%s::geometry, 'XDR') AS _geoX",
+					quote_identifier(state->geo_col_name) );
 			}
 		}
 		else /* little_endian */
 		{
 			if (state->pgis_major_version > 0)
 			{
-				sprintf(buf, "ST_AsEWKB(ST_SetSRID(\"%s\"::geometry, 0), 'NDR') AS _geoX", state->geo_col_name);
+				sprintf(buf, "ST_AsEWKB(ST_SetSRID(%s::geometry, 0), 'NDR') AS _geoX", quote_identifier(state->geo_col_name) ) ;
 			}
 			else
 			{
-				sprintf(buf, "asbinary(\"%s\"::geometry, 'NDR') AS _geoX",
-					state->geo_col_name);
+				sprintf(buf, "asbinary(%s::geometry, 'NDR') AS _geoX",
+					quote_identifier(state->geo_col_name) );
 			}
 		}
 
@@ -2081,43 +2083,43 @@ int ShpLoaderGenerateShapeRow(SHPDUMPERSTATE *state)
 				PQclear(state->fetchres);
 				return SHPDUMPERERR;
 			}
-	
+
 			/* Call the relevant method depending upon the geometry type */
 			LWDEBUGF(4, "geomtype: %s\n", lwtype_name(lwgeom->type));
-	
+
 			switch (lwgeom->type)
 			{
 			case POINTTYPE:
 				obj = create_point(state, lwgeom_as_lwpoint(lwgeom));
 				break;
-	
+
 			case MULTIPOINTTYPE:
 				obj = create_multipoint(state, lwgeom_as_lwmpoint(lwgeom));
 				break;
-	
+
 			case POLYGONTYPE:
 				obj = create_polygon(state, lwgeom_as_lwpoly(lwgeom));
 				break;
-	
+
 			case MULTIPOLYGONTYPE:
 				obj = create_multipolygon(state, lwgeom_as_lwmpoly(lwgeom));
 				break;
-	
+
 			case LINETYPE:
 				obj = create_linestring(state, lwgeom_as_lwline(lwgeom));
 				break;
-	
+
 			case MULTILINETYPE:
 				obj = create_multilinestring(state, lwgeom_as_lwmline(lwgeom));
 				break;
-	
+
 			default:
 				snprintf(state->message, SHPDUMPERMSGLEN, _("Unknown WKB type (%d) for record %d"), lwgeom->type, state->currow);
 				PQclear(state->fetchres);
 				SHPDestroyObject(obj);
 				return SHPDUMPERERR;
 			}
-	
+
 			/* Free both the original and geometries */
 			lwgeom_free(lwgeom);
 
@@ -2165,7 +2167,7 @@ ShpDumperCloseTable(SHPDUMPERSTATE *state)
 
 	/* If a geo column is present, generate the projection file */
 	if (state->geo_col_name)
-		ret = projFileCreate(state);	
+		ret = projFileCreate(state);
 
 	/* Close the DBF and SHP files */
 	if (state->dbf)
@@ -2202,16 +2204,16 @@ ShpDumperDestroy(SHPDUMPERSTATE *state)
 				free(state->dbffieldnames[i]);
 			free(state->dbffieldnames);
 		}
-		
+
 		if (state->dbffieldtypes)
 			free(state->dbffieldtypes);
-		
+
 		if (state->pgfieldnames)
 			free(state->pgfieldnames);
 
 		/* Free any column map fieldnames if specified */
 		colmap_clean(&state->column_map);
-		
+
 		/* Free other names */
 		if (state->table)
 			free(state->table);
@@ -2224,3 +2226,28 @@ ShpDumperDestroy(SHPDUMPERSTATE *state)
 		free(state);
 	}
 }
+
+/*
+ * quote_identifier()
+ *		Properly double-quote a SQL identifier.
+ *  Copied from PostgreSQL pg_upgrade/util.c
+ */
+char *
+quote_identifier(const char *s)
+{
+	char	   *result = malloc(strlen(s) * 2 + 3);
+	char	   *r = result;
+
+	*r++ = '"';
+	while (*s)
+	{
+		if (*s == '"')
+			*r++ = *s;
+		*r++ = *s;
+		s++;
+	}
+	*r++ = '"';
+	*r++ = '\0';
+
+	return result;
+}
diff --git a/loader/pgsql2shp-core.h b/loader/pgsql2shp-core.h
index fefe83d..d2e2162 100644
--- a/loader/pgsql2shp-core.h
+++ b/loader/pgsql2shp-core.h
@@ -23,11 +23,14 @@
 #include <iconv.h>
 
 #include "libpq-fe.h"
+
 #include "shapefil.h"
 #include "shpcommon.h"
 #include "getopt.h"
 
-#define P2S_RCSID "$Id: pgsql2shp-core.h 14869 2016-04-27 14:45:28Z strk $"
+
+
+#define P2S_RCSID "$Id: pgsql2shp-core.h 15442 2017-06-23 05:19:48Z robe $"
 
 /*
  * Error message handling
@@ -84,7 +87,7 @@ typedef struct shp_dumper_config
 
 	/* Name of the column map file if specified */
 	char *column_map_filename;
-	
+
 } SHPDUMPERCONFIG;
 
 
@@ -99,7 +102,7 @@ typedef struct shp_dumper_state
 
 	/* Database connection being used */
 	PGconn *conn;
-	
+
 	/* Version of PostGIS being used */
 	int pgis_major_version;
 
@@ -132,10 +135,10 @@ typedef struct shp_dumper_state
 
 	/* PostgreSQL column lengths for all non-spatial fields */
 	int *pgfieldlens;
-	
+
 	/* PostgreSQL column typmods for all non-spatial fields */
 	int *pgfieldtypmods;
-	
+
 	/* Number of non-spatial fields in DBF output file */
 	int fieldcount;
 
@@ -199,3 +202,4 @@ int ShpDumperGetRecordCount(SHPDUMPERSTATE *state);
 int ShpLoaderGenerateShapeRow(SHPDUMPERSTATE *state);
 int ShpDumperCloseTable(SHPDUMPERSTATE *state);
 void ShpDumperDestroy(SHPDUMPERSTATE *state);
+char *quote_identifier(const char *s);
diff --git a/ltmain.sh b/ltmain.sh
index 147d758..a736cf9 100644
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -31,7 +31,7 @@
 
 PROGRAM=libtool
 PACKAGE=libtool
-VERSION="2.4.6 Debian-2.4.6-0.1"
+VERSION="2.4.6 Debian-2.4.6-2"
 package_revision=2.4.6
 
 
@@ -2068,7 +2068,7 @@ include the following information:
        compiler:       $LTCC
        compiler flags: $LTCFLAGS
        linker:         $LD (gnu? $with_gnu_ld)
-       version:        $progname (GNU libtool) 2.4.6
+       version:        $progname $scriptversion Debian-2.4.6-2
        automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
        autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
 
diff --git a/macros/libtool.m4 b/macros/libtool.m4
index 10ab284..ee80844 100644
--- a/macros/libtool.m4
+++ b/macros/libtool.m4
@@ -728,7 +728,6 @@ _LT_CONFIG_SAVE_COMMANDS([
     cat <<_LT_EOF >> "$cfgfile"
 #! $SHELL
 # Generated automatically by $as_me ($PACKAGE) $VERSION
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
 
 # Provide generalized library-building support services.
diff --git a/postgis/Makefile.in b/postgis/Makefile.in
index c76773b..3b6cf5e 100644
--- a/postgis/Makefile.in
+++ b/postgis/Makefile.in
@@ -27,7 +27,7 @@ MODULE_big=postgis- at POSTGIS_MAJOR_VERSION@. at POSTGIS_MINOR_VERSION@
 MODULEDIR=contrib/$(MODULE_big)
 
 # Files to be copied to the contrib/ directory
-SQL_built=postgis.sql postgis_for_extension.sql uninstall_postgis.sql postgis_upgrade.sql postgis_upgrade_for_extension.sql postgis_proc_set_search_path.sql legacy.sql uninstall_legacy.sql legacy_minimal.sql legacy_gist.sql 
+SQL_built=postgis.sql postgis_for_extension.sql uninstall_postgis.sql postgis_upgrade.sql postgis_upgrade_for_extension.sql postgis_proc_set_search_path.sql legacy.sql uninstall_legacy.sql legacy_minimal.sql legacy_gist.sql
 DATA=../spatial_ref_sys.sql
 
 # SQL objects (files requiring pre-processing)
@@ -126,7 +126,7 @@ EXTRA_CLEAN=$(SQL_OBJS) \
 	postgis_upgrade.sql.in \
 	postgis_upgrade.sql \
 	sfcgal_upgrade.sql.in \
-	sfcgal_upgrade.sql 
+	sfcgal_upgrade.sql
 
 # PGXS information
 PG_CONFIG = @PG_CONFIG@
@@ -176,10 +176,10 @@ $(PG_OBJS): ../liblwgeom/.libs/liblwgeom.a ../libpgcommon/libpgcommon.a ../postg
 %.sql: %.sql.in
 	$(SQLPP) -I../libpgcommon $< | grep -v '^#' | \
 	$(PERL) -lpe "s'MODULE_PATHNAME'\$$libdir/postgis- at POSTGIS_MAJOR_VERSION@. at POSTGIS_MINOR_VERSION@'g;s'@extschema@\.''g" > $@
-	
+
 postgis_upgrade_for_extension.sql: postgis_drop_before.sql postgis_upgrade_for_extension.sql.in postgis_drop_after.sql
-	cat $^ >> $@
-	
+	cat $^ > $@
+
 postgis_for_extension.sql: postgis.sql.in
 	$(SQLPP) -I../libpgcommon $< | grep -v '^#' | \
 	$(PERL) -lpe "s'MODULE_PATHNAME'\$$libdir/postgis- at POSTGIS_MAJOR_VERSION@. at POSTGIS_MINOR_VERSION@'g" > $@
@@ -187,10 +187,10 @@ postgis_for_extension.sql: postgis.sql.in
 #this is redundant but trying to fold in with extension just hangs
 postgis_upgrade.sql.in: postgis.sql ../utils/postgis_proc_upgrade.pl
 	$(PERL) ../utils/postgis_proc_upgrade.pl $< UNUSED > $@
-	
+
 postgis_upgrade_for_extension.sql.in: postgis_for_extension.sql ../utils/postgis_proc_upgrade.pl
 	$(PERL) ../utils/postgis_proc_upgrade.pl $< UNUSED > $@
-	
+
 postgis_proc_set_search_path.sql: postgis.sql ../utils/postgis_proc_set_search_path.pl
 	$(PERL) ../utils/postgis_proc_set_search_path.pl $< UNUSED > $@
 
@@ -199,7 +199,7 @@ postgis_upgrade.sql: postgis_drop_before.sql postgis_upgrade.sql.in postgis_drop
 	cat $^ >> $@
 	echo "COMMIT;" >> $@
 
-sfcgal_upgrade.sql.in: sfcgal.sql ../utils/postgis_proc_upgrade.pl 
+sfcgal_upgrade.sql.in: sfcgal.sql ../utils/postgis_proc_upgrade.pl
 	$(PERL) ../utils/postgis_proc_upgrade.pl $< UNUSED > $@
 
 sfcgal_upgrade.sql: sfcgal_upgrade.sql.in postgis_drop_after.sql
diff --git a/postgis/lwgeom_btree.c b/postgis/lwgeom_btree.c
index 328ee5c..2ee935c 100644
--- a/postgis/lwgeom_btree.c
+++ b/postgis/lwgeom_btree.c
@@ -53,6 +53,7 @@ Datum lwgeom_lt(PG_FUNCTION_ARGS)
 	GSERIALIZED *geom2 = PG_GETARG_GSERIALIZED_P(1);
 	GBOX box1;
 	GBOX box2;
+	bool empty1, empty2;
 
 	POSTGIS_DEBUG(2, "lwgeom_lt called");
 
@@ -60,14 +61,19 @@ Datum lwgeom_lt(PG_FUNCTION_ARGS)
 
 	POSTGIS_DEBUG(3, "lwgeom_lt passed getSRID test");
 
-	gserialized_get_gbox_p(geom1, &box1);
-	gserialized_get_gbox_p(geom2, &box2);
+	empty1 = ( gserialized_get_gbox_p(geom1, &box1) == LW_FAILURE );
+	empty2 = ( gserialized_get_gbox_p(geom2, &box2) == LW_FAILURE );
 
 	PG_FREE_IF_COPY(geom1, 0);
 	PG_FREE_IF_COPY(geom2, 1);
 
 	POSTGIS_DEBUG(3, "lwgeom_lt getbox2d_p passed");
 
+	if  ( empty1 != empty2 )
+	{
+		PG_RETURN_BOOL(FALSE);
+	}
+
 	if  ( ! FPeq(box1.xmin , box2.xmin) )
 	{
 		if  (box1.xmin < box2.xmin)
@@ -102,17 +108,23 @@ Datum lwgeom_le(PG_FUNCTION_ARGS)
 	GSERIALIZED *geom2 = PG_GETARG_GSERIALIZED_P(1);
 	GBOX box1;
 	GBOX box2;
+	bool empty1, empty2;
 
 	POSTGIS_DEBUG(2, "lwgeom_le called");
 
 	error_if_srid_mismatch(gserialized_get_srid(geom1), gserialized_get_srid(geom2));
 
-	gserialized_get_gbox_p(geom1, &box1);
-	gserialized_get_gbox_p(geom2, &box2);
+	empty1 = ( gserialized_get_gbox_p(geom1, &box1) == LW_FAILURE );
+	empty2 = ( gserialized_get_gbox_p(geom2, &box2) == LW_FAILURE );
 
 	PG_FREE_IF_COPY(geom1, 0);
 	PG_FREE_IF_COPY(geom2, 1);
 
+	if  ( empty1 != empty2 )
+	{
+		PG_RETURN_BOOL(FALSE);
+	}
+
 	if  ( ! FPeq(box1.xmin , box2.xmin) )
 	{
 		if  (box1.xmin < box2.xmin)
@@ -168,9 +180,10 @@ Datum lwgeom_eq(PG_FUNCTION_ARGS)
 
 	gbox_init(&box1);
 	gbox_init(&box2);
-	
+
 	empty1 = ( gserialized_get_gbox_p(geom1, &box1) == LW_FAILURE );
 	empty2 = ( gserialized_get_gbox_p(geom2, &box2) == LW_FAILURE );
+
 	PG_FREE_IF_COPY(geom1, 0);
 	PG_FREE_IF_COPY(geom2, 1);
 
@@ -198,17 +211,23 @@ Datum lwgeom_ge(PG_FUNCTION_ARGS)
 	GSERIALIZED *geom2 = PG_GETARG_GSERIALIZED_P(1);
 	GBOX box1;
 	GBOX box2;
+	bool empty1, empty2;
 
 	POSTGIS_DEBUG(2, "lwgeom_ge called");
 
 	error_if_srid_mismatch(gserialized_get_srid(geom1), gserialized_get_srid(geom2));
 
-	gserialized_get_gbox_p(geom1, &box1);
-	gserialized_get_gbox_p(geom2, &box2);
+	empty1 = ( gserialized_get_gbox_p(geom1, &box1) == LW_FAILURE );
+	empty2 = ( gserialized_get_gbox_p(geom2, &box2) == LW_FAILURE );
 
 	PG_FREE_IF_COPY(geom1, 0);
 	PG_FREE_IF_COPY(geom2, 1);
 
+	if  ( empty1 != empty2 )
+	{
+		PG_RETURN_BOOL(FALSE);
+	}
+
 	if  ( ! FPeq(box1.xmin , box2.xmin) )
 	{
 		if  (box1.xmin > box2.xmin)
@@ -255,17 +274,23 @@ Datum lwgeom_gt(PG_FUNCTION_ARGS)
 	GSERIALIZED *geom2 = PG_GETARG_GSERIALIZED_P(1);
 	GBOX box1;
 	GBOX box2;
+	bool empty1, empty2;
 
 	POSTGIS_DEBUG(2, "lwgeom_gt called");
 
 	error_if_srid_mismatch(gserialized_get_srid(geom1), gserialized_get_srid(geom2));
 
-	gserialized_get_gbox_p(geom1, &box1);
-	gserialized_get_gbox_p(geom2, &box2);
+	empty1 = ( gserialized_get_gbox_p(geom1, &box1) == LW_FAILURE );
+	empty2 = ( gserialized_get_gbox_p(geom2, &box2) == LW_FAILURE );
 
 	PG_FREE_IF_COPY(geom1, 0);
 	PG_FREE_IF_COPY(geom2, 1);
 
+	if  ( empty1 != empty2 )
+	{
+		PG_RETURN_BOOL(FALSE);
+	}
+
 	if  ( ! FPeq(box1.xmin , box2.xmin) )
 	{
 		if  (box1.xmin > box2.xmin)
@@ -308,17 +333,34 @@ Datum lwgeom_cmp(PG_FUNCTION_ARGS)
 	GSERIALIZED *geom2 = PG_GETARG_GSERIALIZED_P(1);
 	GBOX box1;
 	GBOX box2;
+	bool empty1, empty2;
 
 	POSTGIS_DEBUG(2, "lwgeom_cmp called");
 
 	error_if_srid_mismatch(gserialized_get_srid(geom1), gserialized_get_srid(geom2));
 
-	gserialized_get_gbox_p(geom1, &box1);
-	gserialized_get_gbox_p(geom2, &box2);
+	empty1 = ( gserialized_get_gbox_p(geom1, &box1) == LW_FAILURE );
+	empty2 = ( gserialized_get_gbox_p(geom2, &box2) == LW_FAILURE );
 
 	PG_FREE_IF_COPY(geom1, 0);
 	PG_FREE_IF_COPY(geom2, 1);
 
+	if  ( empty1 || empty2 )
+	{
+		if  ( empty1 && empty2 )
+		{
+			PG_RETURN_INT32(1);
+		}
+		else if ( empty1 )
+		{
+			PG_RETURN_INT32(-1);
+		}
+		else
+		{
+			PG_RETURN_INT32(1);
+		}
+	}
+
 	if  ( ! FPeq(box1.xmin , box2.xmin) )
 	{
 		if  (box1.xmin < box2.xmin)
diff --git a/postgis/postgis.sql.in b/postgis/postgis.sql.in
index 61114ff..a906721 100644
--- a/postgis/postgis.sql.in
+++ b/postgis/postgis.sql.in
@@ -4061,7 +4061,7 @@ CREATE OR REPLACE FUNCTION _ST_CoveredBy(geom1 geometry, geom2 geometry)
 -- Availability: 1.2.2
 CREATE OR REPLACE FUNCTION ST_CoveredBy(geom1 geometry, geom2 geometry)
 	RETURNS boolean
-	AS 'SELECT $1 @ $2 AND @extschema at ._ST_CoveredBy($1,$2)'
+	AS 'SELECT $1 OPERATOR(@extschema at .@) $2 AND @extschema at ._ST_CoveredBy($1,$2)'
 	LANGUAGE 'sql' IMMUTABLE _PARALLEL;
 
 -- Availability: 1.2.2
diff --git a/postgis/sqldefines.h b/postgis/sqldefines.h
index 8932293..b0cd8ee 100644
--- a/postgis/sqldefines.h
+++ b/postgis/sqldefines.h
@@ -9,7 +9,7 @@
 #define POSTGIS_PGSQL_VERSION 96
 #define POSTGIS_GEOS_VERSION 37
 #define POSTGIS_PROJ_VERSION 49
-#define POSTGIS_LIB_VERSION '2.3.2'
+#define POSTGIS_LIB_VERSION '2.3.3'
 #define POSTGIS_LIBXML2_VERSION 2.9.4
 #define POSTGIS_SFCGAL_VERSION 13
 
@@ -25,12 +25,12 @@
  * won't substitute within apostrophes)
  */
 #define _POSTGIS_SQL_SELECT_POSTGIS_VERSION 'SELECT ''2.3 USE_GEOS=1 USE_PROJ=1 USE_STATS=1''::text AS version'
-#define _POSTGIS_SQL_SELECT_POSTGIS_BUILD_DATE 'SELECT ''2017-01-31 06:00:14''::text AS version'
+#define _POSTGIS_SQL_SELECT_POSTGIS_BUILD_DATE 'SELECT ''2017-07-01 17:22:37''::text AS version'
 
 #if POSTGIS_SVN_REVISION
-#define _POSTGIS_SQL_SELECT_POSTGIS_SCRIPTS_VERSION $$ SELECT '2.3.2'::text || ' r' || POSTGIS_SVN_REVISION::text AS version $$
+#define _POSTGIS_SQL_SELECT_POSTGIS_SCRIPTS_VERSION $$ SELECT '2.3.3'::text || ' r' || POSTGIS_SVN_REVISION::text AS version $$
 #else
-#define _POSTGIS_SQL_SELECT_POSTGIS_SCRIPTS_VERSION $$ SELECT '2.3.2'::text AS version $$
+#define _POSTGIS_SQL_SELECT_POSTGIS_SCRIPTS_VERSION $$ SELECT '2.3.3'::text AS version $$
 #endif
 
 #define SRID_USR_MAX 998999
diff --git a/postgis_svn_revision.h b/postgis_svn_revision.h
index c680fe9..2c10f81 100644
--- a/postgis_svn_revision.h
+++ b/postgis_svn_revision.h
@@ -1 +1 @@
-#define POSTGIS_SVN_REVISION 15302
+#define POSTGIS_SVN_REVISION 15473
diff --git a/raster/loader/raster2pgsql.c b/raster/loader/raster2pgsql.c
index d7b2d97..4db7a1e 100644
--- a/raster/loader/raster2pgsql.c
+++ b/raster/loader/raster2pgsql.c
@@ -2317,7 +2317,7 @@ main(int argc, char **argv) {
 				sscanf(optarg, "%d", &config->srid);
 				sscanf(ptr, "%d", &config->out_srid);
 			} else {
-				config->srid = config->out_srid = atoi(optarg);
+				config->srid = atoi(optarg);
 			}
 		}
 		/* band index */
@@ -2648,15 +2648,11 @@ main(int argc, char **argv) {
 		}
 	}
 
-	if (config->srid != config->out_srid) {
+	if (config->srid != config->out_srid && config->out_srid != SRID_UNKNOWN) {
 		if (config->copy_statements) {
 			rterror(_("Invalid argument combination - cannot use -Y with -s FROM_SRID:TO_SRID"));
 			exit(1);
 		}
-		if (config->out_srid == SRID_UNKNOWN) {
-			rterror(_("Unknown target SRID is invalid when source SRID is given"));
-			exit(1);
-		}
 	}
 
 	/* register GDAL drivers */
diff --git a/raster/rt_pg/rtpg_mapalgebra.c b/raster/rt_pg/rtpg_mapalgebra.c
index 43d04fa..2ad47df 100644
--- a/raster/rt_pg/rtpg_mapalgebra.c
+++ b/raster/rt_pg/rtpg_mapalgebra.c
@@ -520,7 +520,7 @@ Datum RASTER_nMapAlgebra(PG_FUNCTION_ARGS)
 	int num;
 	int *maskDims;
 	int x,y;
-	
+
 
 	int i = 0;
 	int noerr = 0;
@@ -662,7 +662,7 @@ Datum RASTER_nMapAlgebra(PG_FUNCTION_ARGS)
 			rtpg_nmapalgebra_arg_destroy(arg);
 			PG_RETURN_NULL();
 		}
-	
+
 		maskDims = ARR_DIMS(maskArray);
 
 		if (maskDims[0] % 2 == 0 || maskDims[1] % 2 == 0) {
@@ -670,7 +670,7 @@ Datum RASTER_nMapAlgebra(PG_FUNCTION_ARGS)
 			rtpg_nmapalgebra_arg_destroy(arg);
 			PG_RETURN_NULL();
 		}
-	
+
 		deconstruct_array(
 			maskArray,
 			etype,
@@ -742,7 +742,7 @@ Datum RASTER_nMapAlgebra(PG_FUNCTION_ARGS)
 	}
 
 	noerr = 1;
-	
+
 	/* all rasters are empty, return empty raster */
 	if (allempty == arg->numraster) {
 		elog(NOTICE, "All input rasters are empty. Returning empty raster");
@@ -2858,7 +2858,7 @@ Datum RASTER_union_finalfn(PG_FUNCTION_ARGS)
 		) {
 			rt_raster_destroy(_raster);
 		}
-			
+
 		for (j = 0; j < iwr->bandarg[i].numraster; j++) {
 			if (iwr->bandarg[i].raster[j] == NULL)
 				continue;
@@ -3398,7 +3398,7 @@ Datum RASTER_clip(PG_FUNCTION_ARGS)
 				rt_raster_destroy(_raster);
 				rt_raster_destroy(rtn);
 				PG_FREE_IF_COPY(pgraster, 0);
-				elog(ERROR, "RASTER_clip: Could not get band from working raster");
+				elog(NOTICE, "RASTER_clip: Could not get band from working raster");
 				PG_RETURN_NULL();
 			}
 
@@ -4275,7 +4275,7 @@ Datum RASTER_colorMap(PG_FUNCTION_ARGS)
 						/* get the band stats */
 						if (arg->bandstats == NULL) {
 							POSTGIS_RT_DEBUG(4, "Getting band stats");
-							
+
 							arg->bandstats = rt_band_get_summary_stats(arg->band, 1, 1, 0, NULL, NULL, NULL);
 							if (arg->bandstats == NULL) {
 								pfree(_element);
diff --git a/raster/rt_pg/rtpostgis.sql.in b/raster/rt_pg/rtpostgis.sql.in
index b2f3d6b..295892d 100644
--- a/raster/rt_pg/rtpostgis.sql.in
+++ b/raster/rt_pg/rtpostgis.sql.in
@@ -5718,7 +5718,7 @@ CREATE OR REPLACE FUNCTION raster_same(raster, raster)
 
 CREATE OR REPLACE FUNCTION raster_contained(raster, raster)
     RETURNS bool
-    AS 'select $1::geometry @ $2::geometry'
+    AS 'select $1::geometry OPERATOR(@extschema at .@) $2::geometry'
     LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
 
 CREATE OR REPLACE FUNCTION raster_contain(raster, raster)
@@ -5742,7 +5742,7 @@ CREATE OR REPLACE FUNCTION raster_geometry_contain(raster, geometry)
 -- Availability: 2.0.5
 CREATE OR REPLACE FUNCTION raster_contained_by_geometry(raster, geometry)
     RETURNS bool
-    AS 'select $1::geometry @ $2'
+    AS 'select $1::geometry OPERATOR(@extschema at .@) $2'
     LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
 
 -- Availability: 2.0.0
@@ -5756,13 +5756,13 @@ CREATE OR REPLACE FUNCTION raster_geometry_overlap(raster, geometry)
 -- Availability: 2.0.0
 CREATE OR REPLACE FUNCTION geometry_raster_contain(geometry, raster)
     RETURNS bool
-    AS 'select $1 ~ $2::geometry'
+    AS 'select $1 OPERATOR(@extschema at .~) $2::geometry'
     LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
 
 -- Availability: 2.0.5
 CREATE OR REPLACE FUNCTION geometry_contained_by_raster(geometry, raster)
     RETURNS bool
-    AS 'select $1 @ $2::geometry'
+    AS 'select $1 OPERATOR(@extschema at .@) $2::geometry'
     LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
 
 -- Availability: 2.0.0
@@ -7146,34 +7146,28 @@ CREATE OR REPLACE FUNCTION _add_raster_constraint_extent(rastschema name, rastta
 		END IF;
 		fqtn := fqtn || quote_ident($2);
 
-		sql := 'SELECT MAX(@extschema at .ST_SRID('
+		sql := 'SELECT @extschema at .ST_SRID('
             || quote_ident($3)
-      || ') ) FROM '
+      || ') FROM '
             || fqtn
-            || ' HAVING COUNT(DISTINCT @extschema at .ST_SRID('
-            || quote_ident($3)
-      || ') ) = 1';
+            || ' LIMIT 1;';
     EXECUTE sql INTO srid;
     
 		cn := 'enforce_max_extent_' || $3;
 
-		IF srid > -1 THEN
-      sql := 'SELECT @extschema at .st_ashexewkb( @extschema at .st_setsrid( @extschema at .st_extent( @extschema at .st_envelope('
-        || quote_ident($3)
-        || ')), ' || srid || ')) FROM '
-        || fqtn;
-      EXECUTE sql INTO attr;
-  
-      sql := 'ALTER TABLE ' || fqtn
-        || ' ADD CONSTRAINT ' || quote_ident(cn)
-        || ' CHECK ( @extschema at .st_envelope('
-        || quote_ident($3)
-        || ') @ ''' || attr || '''::geometry) ';
-      RETURN  @extschema at ._add_raster_constraint(cn, sql);
-    ELSE 
-      -- no valid srid therefore doesn't make sense to set extent
-      RETURN false;
-    END IF;
+		sql := 'SELECT @extschema at .st_ashexewkb( @extschema at .st_setsrid( @extschema at .st_extent( @extschema at .st_envelope('
+			|| quote_ident($3)
+			|| ')), ' || srid || ')) FROM '
+			|| fqtn;
+		EXECUTE sql INTO attr;
+
+		-- NOTE: I put NOT VALID to prevent the costly step of validating the constraint
+		sql := 'ALTER TABLE ' || fqtn
+			|| ' ADD CONSTRAINT ' || quote_ident(cn)
+			|| ' CHECK ( @extschema at .st_envelope('
+			|| quote_ident($3)
+			|| ') @ ''' || attr || '''::geometry) NOT VALID';
+		RETURN  @extschema at ._add_raster_constraint(cn, sql);
 	END;
 	$$ LANGUAGE 'plpgsql' VOLATILE STRICT
 	COST 9000;
diff --git a/regress/dumper/realtable-pre.sql b/regress/dumper/realtable-pre.sql
index a6d1dca..f880101 100644
--- a/regress/dumper/realtable-pre.sql
+++ b/regress/dumper/realtable-pre.sql
@@ -1,3 +1,3 @@
 insert into spatial_ref_sys(srid,srtext) values (1,'fake["srs"],text');
-create table c (i int, g geometry);
-insert into c values (1,'SRID=1;POINT(0 0)');
+create table c (i int, g geometry, b boolean, """qColumn" varchar(20));
+insert into c values (1,'SRID=1;POINT(0 0)', true, 'quote test');
diff --git a/regress/dumper/realtable_expected.dbf b/regress/dumper/realtable_expected.dbf
index 7f420e4..f0147df 100644
Binary files a/regress/dumper/realtable_expected.dbf and b/regress/dumper/realtable_expected.dbf differ
diff --git a/regress/knn_recheck.sql b/regress/knn_recheck.sql
index c216ead..6d9e0e2 100644
--- a/regress/knn_recheck.sql
+++ b/regress/knn_recheck.sql
@@ -14,7 +14,7 @@ FROM generate_series(0,3) i;
 
 
 INSERT INTO knn_recheck_geom(gid,geom)
-SELECT 600000 + ROW_NUMBER() OVER(ORDER BY gid) AS gid, ST_Translate(ST_Buffer(geom,8,15),100,300) As geom
+SELECT 600000 + ROW_NUMBER() OVER(ORDER BY gid) AS gid, ST_Translate(ST_Buffer(geom,8,15 ),100,300) As geom
 FROM knn_recheck_geom
 WHERE gid IN(1000, 10000, 2000,3000);
 
@@ -37,8 +37,8 @@ FROM knn_recheck_geom As a
 	LEFT JOIN 
 		LATERAL ( SELECT  gid, geom, a.geom <-> g.geom As knn_dist
 			FROM knn_recheck_geom As g WHERE a.gid <> g.gid ORDER BY a.geom <-> g.geom LIMIT 5) As b ON true
-	WHERE a.gid IN(1,500101,500003)
-ORDER BY a.gid, true_rn;
+	WHERE a.gid IN(1,500101)
+ORDER BY a.gid, true_rn, b.gid;
 
 -- create index and repeat
 CREATE INDEX idx_knn_recheck_geom_gist ON knn_recheck_geom USING gist(geom);
@@ -60,8 +60,8 @@ FROM knn_recheck_geom As a
 	LEFT JOIN 
 		LATERAL ( SELECT  gid, geom, a.geom <-> g.geom As knn_dist
 			FROM knn_recheck_geom As g WHERE a.gid <> g.gid ORDER BY a.geom <-> g.geom LIMIT 5) As b ON true
-	WHERE a.gid IN(1,500101,500003)
-ORDER BY a.gid, true_rn;
+	WHERE a.gid IN(1,500101)
+ORDER BY a.gid, true_rn, b.gid;
 
 DROP TABLE knn_recheck_geom;
 
@@ -102,7 +102,7 @@ SELECT '#3g' As t, a.gid,  ARRAY(SELECT  gid
 			FROM knn_recheck_geog As g WHERE a.gid <> g.gid ORDER BY ST_Distance(a.geog, g.geog, false) LIMIT 5) = ARRAY(SELECT  gid
 			FROM knn_recheck_geog As g WHERE a.gid <> g.gid ORDER BY a.geog <-> g.geog LIMIT 5) As dist_order_agree
 FROM knn_recheck_geog As a 
-	WHERE a.gid IN(500000,500010,1000,2614)
+	WHERE a.gid IN(500000,500010,1000)
 ORDER BY a.gid;
 
 
@@ -121,11 +121,11 @@ SELECT '#2g' As t, gid, ST_Distance( 'LINESTRING(75 10, 75 12, 80 20)'::geograph
 FROM knn_recheck_geog
 ORDER BY 'LINESTRING(75 10, 75 12, 80 20)'::geography <-> geog LIMIT 5;
 
-SELECT '#3g' As t, a.gid,  ARRAY(SELECT  gid
+SELECT '#3g' As t, a.gid,  ARRAY(SELECT  g.gid
 			FROM knn_recheck_geog As g WHERE a.gid <> g.gid ORDER BY ST_Distance(a.geog, g.geog, false) LIMIT 5) = ARRAY(SELECT  gid
 			FROM knn_recheck_geog As g WHERE a.gid <> g.gid ORDER BY a.geog <-> g.geog LIMIT 5) As dist_order_agree
 FROM knn_recheck_geog As a 
-	WHERE a.gid IN(500000,500010,1000,2614)
+	WHERE a.gid IN(500000,500010,1000)
 ORDER BY a.gid;
 
 DROP TABLE knn_recheck_geog;
@@ -189,8 +189,8 @@ FROM knn_recheck_geom_nd As a
 	LEFT JOIN 
 		LATERAL ( SELECT  gid, geom, a.geom <<->> g.geom As knn_dist
 			FROM knn_recheck_geom_nd As g WHERE a.gid <> g.gid ORDER BY a.geom <<->> g.geom LIMIT 5) As b ON true
-	WHERE a.gid IN(1,500003,600001)
-ORDER BY a.gid, true_rn;
+	WHERE a.gid IN(1,600001)
+ORDER BY a.gid, true_rn, b.gid;
 
 -- create index and repeat
 CREATE INDEX idx_knn_recheck_geom_nd_gist ON knn_recheck_geom_nd USING gist(geom gist_geometry_ops_nd);
@@ -214,8 +214,8 @@ FROM knn_recheck_geom_nd As a
 	LEFT JOIN 
 		LATERAL ( SELECT  gid, geom, a.geom <<->> g.geom As knn_dist
 			FROM knn_recheck_geom_nd As g WHERE a.gid <> g.gid ORDER BY a.geom <<->> g.geom LIMIT 5) As b ON true
-	WHERE a.gid IN(1,500003,600001)
-ORDER BY a.gid, true_rn;
+	WHERE a.gid IN(1,600001)
+ORDER BY a.gid, true_rn, b.gid;
 
 
 DROP TABLE knn_recheck_geom_nd;
diff --git a/regress/knn_recheck_expected b/regress/knn_recheck_expected
index 9c37f23..c280daa 100644
--- a/regress/knn_recheck_expected
+++ b/regress/knn_recheck_expected
@@ -13,11 +13,6 @@
 #3|1|147|9.6598|9.6598
 #3|1|291|10.8780|10.8780
 #3|1|292|13.4929|13.4929
-#3|500003|500004|1447.7424|1447.7424
-#3|500003|500002|1447.7424|1447.7424
-#3|500003|500001|3423.4486|3423.4486
-#3|500003|500005|3423.4486|3423.4486
-#3|500003|22837|5123.7770|5123.7770
 #3|500101|500000|0.0000|0.0000
 #3|500101|600004|971.4947|971.4947
 #3|500101|600001|1106.0791|1106.0791
@@ -38,11 +33,6 @@
 #3|1|147|9.6598|9.6598
 #3|1|291|10.8780|10.8780
 #3|1|292|13.4929|13.4929
-#3|500003|500004|1447.7424|1447.7424
-#3|500003|500002|1447.7424|1447.7424
-#3|500003|500001|3423.4486|3423.4486
-#3|500003|500005|3423.4486|3423.4486
-#3|500003|22837|5123.7770|5123.7770
 #3|500101|500000|0.0000|0.0000
 #3|500101|600004|971.4947|971.4947
 #3|500101|600001|1106.0791|1106.0791
@@ -59,7 +49,6 @@
 #2g|30695|21264.3654|21264.3654
 #2g|30512|25313.2118|25313.2118
 #3g|1000|t
-#3g|2614|t
 #3g|500000|t
 #1g|500000|0.0000|0.0000
 #1g|600003|69974.6935|69974.6935
@@ -72,7 +61,6 @@
 #2g|30695|21264.3654|21264.3654
 #2g|30512|25313.2118|25313.2118
 #3g|1000|t
-#3g|2614|t
 #3g|500000|t
 #1nd-3|290|260.6797|260.6797
 #1nd-3|287|264.3000|264.3000
@@ -89,11 +77,6 @@
 #3nd-3|1|294|9.6598|9.6598
 #3nd-3|1|582|10.8780|10.8780
 #3nd-3|1|583|13.4929|13.4929
-#3nd-3|500003|500004|1448.3262|1448.3262
-#3nd-3|500003|500002|1448.3262|1448.3262
-#3nd-3|500003|500001|3424.9088|3424.9088
-#3nd-3|500003|500005|3424.9088|3424.9088
-#3nd-3|500003|45674|5153.7747|5153.7747
 #3nd-3|600001|600002|0.0000|0.0000
 #3nd-3|600001|9752|54.2730|54.2730
 #3nd-3|600001|9461|54.3900|54.3900
@@ -114,11 +97,6 @@
 #3nd-3|1|294|9.6598|9.6598
 #3nd-3|1|582|10.8780|10.8780
 #3nd-3|1|583|13.4929|13.4929
-#3nd-3|500003|500004|1448.3262|1448.3262
-#3nd-3|500003|500002|1448.3262|1448.3262
-#3nd-3|500003|500001|3424.9088|3424.9088
-#3nd-3|500003|500005|3424.9088|3424.9088
-#3nd-3|500003|45674|5153.7747|5153.7747
 #3nd-3|600001|600002|0.0000|0.0000
 #3nd-3|600001|9752|54.2730|54.2730
 #3nd-3|600001|9461|54.3900|54.3900
diff --git a/regress/operators.sql b/regress/operators.sql
index 1306700..21cc153 100644
--- a/regress/operators.sql
+++ b/regress/operators.sql
@@ -140,4 +140,24 @@ WITH v(i,g) AS ( VALUES
 SELECT 'ndovm2', array_agg(i) FROM v WHERE g &&& 'POINTZ(0 0 1)'::geometry
 ORDER BY 1;
 
-
+-- GROUP BY on empty
+SELECT '#3777', ST_AsText(geom), count(*) FROM (
+SELECT 'POINT(0 0)'::geometry geom UNION ALL
+SELECT 'POINT(0 0)'::geometry UNION ALL
+SELECT 'POINT(0 0)'::geometry UNION ALL
+SELECT 'POINT(0 1)'::geometry UNION ALL
+SELECT 'LINESTRING(0 0,0 1)'::geometry UNION ALL
+SELECT 'GEOMETRYCOLLECTION EMPTY'::geometry UNION ALL
+SELECT 'POINT EMPTY'::geometry
+) foo
+GROUP BY geom ORDER BY 2;
+SELECT '#3777.1', ST_AsText(geom), count(*) FROM (
+SELECT 'POINT(0 0)'::geometry geom UNION ALL
+SELECT 'POINT(0 0)'::geometry UNION ALL
+SELECT 'POINT EMPTY'::geometry UNION ALL
+SELECT 'POINT(0 0)'::geometry UNION ALL
+SELECT 'POINT(0 1)'::geometry UNION ALL
+SELECT 'LINESTRING(0 0,0 1)'::geometry UNION ALL
+SELECT 'GEOMETRYCOLLECTION EMPTY'::geometry geom
+) foo
+GROUP BY geom ORDER BY 2;
diff --git a/regress/operators_expected b/regress/operators_expected
index c1539e6..1dfd634 100644
--- a/regress/operators_expected
+++ b/regress/operators_expected
@@ -56,3 +56,11 @@ ndov6|t
 ndov7|t
 ndovm1|{1,2,3,4,5,8}
 ndovm2|{1,2,4,6,7}
+#3777|GEOMETRYCOLLECTION EMPTY|2
+#3777|LINESTRING(0 0,0 1)|1
+#3777|POINT(0 0)|3
+#3777|POINT(0 1)|1
+#3777.1|GEOMETRYCOLLECTION EMPTY|2
+#3777.1|LINESTRING(0 0,0 1)|1
+#3777.1|POINT(0 0)|3
+#3777.1|POINT(0 1)|1
diff --git a/regress/subdivide.sql b/regress/subdivide.sql
index 30c941e..70717b3 100644
--- a/regress/subdivide.sql
+++ b/regress/subdivide.sql
@@ -24,3 +24,20 @@ FROM gs
 GROUP BY gs.full_area;
 
 SELECT '#3522', ST_AsText(ST_Subdivide(ST_GeomFromText('POINT(1 1)',4326),10));
+
+
+with inverted_geom as (
+    select ST_Difference(
+               ST_Expand('SRID=3857;POINT(0 0)' :: geometry, 20000000),
+               ST_Buffer(
+                   'SRID=3857;POINT(0 0)' :: geometry,
+                   1,
+                   1000
+               )
+           ) as geom
+)
+select '#3744', ST_Area(ST_Simplify(ST_Union(geom), 2))::numeric
+from (
+         select ST_Subdivide(geom) geom
+         from inverted_geom
+     ) z;
diff --git a/regress/subdivide_expected b/regress/subdivide_expected
index 43e89ec..0947a14 100644
--- a/regress/subdivide_expected
+++ b/regress/subdivide_expected
@@ -2,3 +2,4 @@
 2|t|6|7
 3|t|15|9
 #3522|POINT(1 1)
+#3744|1600000000000000
diff --git a/regress/tickets.sql b/regress/tickets.sql
index 44fca10..b5c105c 100644
--- a/regress/tickets.sql
+++ b/regress/tickets.sql
@@ -1012,5 +1012,8 @@ SELECT '#3620b', ST_AsText(ST_MinimumBoundingCircle('LINESTRING (2 8, 2 8)'));
 SELECT '#3627a', ST_AsEncodedPolyline('SRID=4326;LINESTRING(-0.250691 49.283048,-0.250633 49.283376,-0.250502 49.283972,-0.251245 49.284028,-0.251938 49.284232,-0.251938 49.2842)', 6);
 SELECT '#3627b', ST_Equals(geom, ST_LineFromEncodedPolyline(ST_AsEncodedPolyline(geom, 7), 7)) FROM (VALUES ('SRID=4326;LINESTRING (0 0, 1 1)')) AS v (geom);
 
+-- #3704
+SELECT '#3704', ST_AsX3D('LINESTRING EMPTY') = '';
+
 -- Clean up
 DELETE FROM spatial_ref_sys;
diff --git a/regress/tickets_expected b/regress/tickets_expected
index 787e5d7..cbe200c 100644
--- a/regress/tickets_expected
+++ b/regress/tickets_expected
@@ -301,3 +301,4 @@ ERROR:  invalid KML representation
 #3620b|POINT(2 8)
 #3627a|o}~~|AdshNoSsBgd at eGoBlm@wKhj@~@?
 #3627b|t
+#3704|t
diff --git a/topology/postgis_topology.c b/topology/postgis_topology.c
index c7e8894..c834e23 100644
--- a/topology/postgis_topology.c
+++ b/topology/postgis_topology.c
@@ -1423,9 +1423,9 @@ cb_insertNodes( const LWT_BE_TOPOLOGY* topo,
   if ( SPI_processed ) topo->be_data->data_changed = true;
 
   if ( SPI_processed != numelems ) {
-		cberror(topo->be_data, "processed %u rows, expected %d",
-            SPI_processed, numelems);
-	  return 0;
+    cberror(topo->be_data, "processed " UINT64_FORMAT " rows, expected %d",
+            (uint64)SPI_processed, numelems);
+    return 0;
   }
 
   /* Set node_id (could skip this if none had it set to -1) */
@@ -1480,9 +1480,9 @@ cb_insertEdges( const LWT_BE_TOPOLOGY* topo,
   if ( SPI_processed ) topo->be_data->data_changed = true;
   POSTGIS_DEBUGF(1, "cb_insertEdges query processed %d rows", SPI_processed);
   if ( SPI_processed != numelems ) {
-		cberror(topo->be_data, "processed %u rows, expected %d",
-            SPI_processed, numelems);
-	  return -1;
+    cberror(topo->be_data, "processed " UINT64_FORMAT " rows, expected %d",
+            (uint64)SPI_processed, numelems);
+    return -1;
   }
 
   if ( needsEdgeIdReturn )
@@ -1538,9 +1538,9 @@ cb_insertFaces( const LWT_BE_TOPOLOGY* topo,
   if ( SPI_processed ) topo->be_data->data_changed = true;
   POSTGIS_DEBUGF(1, "cb_insertFaces query processed %d rows", SPI_processed);
   if ( SPI_processed != numelems ) {
-		cberror(topo->be_data, "processed %u rows, expected %d",
-            SPI_processed, numelems);
-	  return -1;
+    cberror(topo->be_data, "processed " UINT64_FORMAT " rows, expected %d",
+           (uint64)SPI_processed, numelems);
+    return -1;
   }
 
   if ( needsFaceIdReturn )
@@ -1904,8 +1904,9 @@ cb_getNextEdgeId( const LWT_BE_TOPOLOGY* topo )
   if ( SPI_processed ) topo->be_data->data_changed = true;
 
   if ( SPI_processed != 1 ) {
-		cberror(topo->be_data, "processed %d rows, expected 1", SPI_processed);
-	  return -1;
+    cberror(topo->be_data, "processed " UINT64_FORMAT " rows, expected 1",
+            (uint64)SPI_processed);
+    return -1;
   }
 
   dat = SPI_getbinval( SPI_tuptable->vals[0],
diff --git a/topology/test/regress/topogeo_addlinestring.sql b/topology/test/regress/topogeo_addlinestring.sql
index 283ef70..83397d0 100644
--- a/topology/test/regress/topogeo_addlinestring.sql
+++ b/topology/test/regress/topogeo_addlinestring.sql
@@ -322,3 +322,13 @@ SELECT 't3412.L2', TopoGeo_AddLinestring('bug3412',
 '0102000000020000003AB42BBFEE4C22410010C5A997A6524167BB5DBDEE4C224117FE3DA85FA75241'
 ::geometry, 0);
 SELECT 't3412.end', DropTopology('bug3412');
+
+-- See http://trac.osgeo.org/postgis/ticket/3711
+SELECT 't3371.start', topology.CreateTopology('bug3711', 0, 0, true) > 1;
+SELECT 't3371.L1', topology.TopoGeo_AddLineString('bug3711',
+'LINESTRING (618369 4833784 0.88, 618370 4833784 1.93, 618370 4833780 1.90)'
+::geometry, 0);
+SELECT 't3371.L2', topology.TopoGeo_AddLineString( 'bug3711',
+'LINESTRING (618370 4833780 1.92, 618370 4833784 1.90, 618371 4833780 1.93)'
+::geometry, 0);
+SELECT 't3371.end', topology.DropTopology('bug3711');
diff --git a/topology/test/regress/topogeo_addlinestring_expected_newsnap b/topology/test/regress/topogeo_addlinestring_expected_newsnap
index 0c56476..475bb75 100644
--- a/topology/test/regress/topogeo_addlinestring_expected_newsnap
+++ b/topology/test/regress/topogeo_addlinestring_expected_newsnap
@@ -201,3 +201,8 @@ t3412.L2|3
 t3412.L2|5
 t3412.L2|4
 t3412.end|Topology 'bug3412' dropped
+t3371.start|t
+t3371.L1|1
+t3371.L2|3
+t3371.L2|2
+t3371.end|Topology 'bug3711' dropped
diff --git a/topology/test/regress/topogeo_addlinestring_expected_oldsnap b/topology/test/regress/topogeo_addlinestring_expected_oldsnap
index dec535d..f3e29c3 100644
--- a/topology/test/regress/topogeo_addlinestring_expected_oldsnap
+++ b/topology/test/regress/topogeo_addlinestring_expected_oldsnap
@@ -198,3 +198,8 @@ t3412.L2|3
 t3412.L2|5
 t3412.L2|4
 t3412.end|Topology 'bug3412' dropped
+t3371.start|t
+t3371.L1|1
+t3371.L2|3
+t3371.L2|2
+t3371.end|Topology 'bug3711' dropped

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/postgis.git



More information about the Pkg-grass-devel mailing list