Browse files

This commit was manufactured by cvs2svn to create tag 'pgis_1_0_4'.

git-svn-id: http://svn.osgeo.org/postgis/tags/pgis_1_0_4@1905 b70326c6-7e19-0410-871a-916f4a2858ee
  • Loading branch information...
1 parent b8e9c8a commit eea3fe0177ad3b15b955695f7adb42254bbb00f4 No Body committed Sep 9, 2005
View
56 CHANGES
@@ -1,4 +1,58 @@
+PostGIS 1.0.4
+2005/09/12
+ - Memory leak plugged in GiST indexing
+ - Segfault fix in transform() handling of proj4 errors
+ - Fixed some proj4 texts in spatial_ref_sys (missing +proj)
+ - GiST indexing cleanup
+ - Loader: fixed string functions usage, reworked NULL objects check,
+ fixed segfault on MULTILINESTRING input.
+ - Fixed bug in MakeLine dimension handling
+ - Looser syntax acceptance in box3d parser
+ - Documentation improvements
+ - More robust selectivity estimator
+ - Minor speedup in distance()
+ - Minor cleanups
+ - Fixed bug in translate() corrupting output bounding box
+
+PostGIS 1.0.3
+2005/08/08
+ - Severe bugfix in lwgeom's 2d bounding box computation
+ - Bugfix in WKT (-w) POINT handling in loader
+ - Bugfix in dumper on 64bit machines
+ - Bugfix in dumper handling of user-defined queries
+ - Bugfix in create_undef.pl script
+ - Small performance improvement in canonical input function
+ - Minor cleanups in loader
+ - Support for multibyte field names in loader
+ - Improvement in the postgis_restore.pl script
+ - New rebuild_bbox_caches.pl util script
+
+PostGIS 1.0.2
+2005/07/04
+ - Fault tolerant btree ops
+ - Memory Leak fix in pg_error
+ - Rtree index fix. See:
+ http://archives.postgresql.org/pgsql-hackers/2005-06/msg01108.php
+ - Initial support for postgresql 8.1dev
+ - Cleaner build scripts: avoided mix of CFLAGS and CXXFLAGS
+ - NEW -I switch for pgsql2shp (GiST index)
+
+PostGIS 1.0.1
+2005/05/24
+ - BUGFIX in shp2pgql escape functions
+ - BUGFIX in 3d computation of lenght_spheroid
+ - better support for concurrent postgis in multiple schemas
+ - documentation fixes
+ - BUGFIX in join selectivity estimator returning invalid estimates (>1)
+ - jdbc2: compile with "-target 1.2 -source 1.2" by default
+ - NEW -k switch for pgsql2shp
+ - NEW support for custom createdb options in postgis_restore.pl
+ - BUGFIX in pgsql2shp attribute names unicity enforcement
+ - BUGFIX in Paris projections definitions
+ - postgis_restore.pl cleanups
+
PostGIS 1.0.0
+2005/04/19
- NEW manual pages for loader/dumper
- NEW shp2pgsql support for old (HWGEOM) postgis versions
- NEW -p flag for shp2pgsql
@@ -7,6 +61,8 @@ PostGIS 1.0.0
- NEW chapter about OGC compliancy enforcement
- BUGFIX in shp2pgsql escape of values starting with "'" or "\t"
- NEW autoconf support for JTS lib
+ - BUGFIX in estimator testers (support for LWGEOM and schema parsing)
+ - BUGFIX in join selectivity estimator (defaults, leaks, tuplecount, sd)
PostGIS 1.0.0RC6
2005/03/30
View
5 CREDITS
@@ -42,5 +42,10 @@ Version 0.9 of PostGIS includes patches from:
Olivier Courtin <pnine@free.fr> on AsSVG()
Bruno Wolff III on the distance_sphere algorithm
+Version 1.0.0 of PostGIS includes code from:
+ Mark Cave-Ayland <m.cave-ayland@webbased.co.uk> with new positional
+ operators, join estimator and general testing and support.
+ Markus Schaber <markus@schabi.de> author of the jdbc2 interface
+
See the postgis manual for more contributors.
View
6 Makefile.config
@@ -124,7 +124,11 @@ else
ifneq ($(findstring 7.4,$(VERSION)),)
USE_VERSION=74
else
- USE_VERSION=80
+ ifneq ($(findstring 8.0,$(VERSION)),)
+ USE_VERSION=80
+ else
+ USE_VERSION=81
+ endif
endif
endif
endif
View
2 Version.config
@@ -4,7 +4,7 @@
# shared library version
SO_MAJOR_VERSION=1
SO_MINOR_VERSION=0
-SO_MICRO_VERSION=0
+SO_MICRO_VERSION=4
# sql scripts version
SCRIPTS_VERSION=0.3.0
View
4 doc/man/pgsql2shp.1
@@ -56,6 +56,10 @@ Raw mode. Do not drop the gid field, or escape column names.
\fB\-d\fR
For backward compatibility: write a 3\-dimensional shape file when dumping from old (pre\-1.0.0) postgis databases (the default is to write a 2\-dimensional shape file in that case). Starting from postgis\-1.0.0+, dimensions are fully encoded.
+.TP
+\fB\-k\fR
+Keep idendifiers case (don't uppercase field names).
+
.SH "AUTHORS"
.LP
View
2 doc/man/shp2pgsql.1
@@ -41,7 +41,7 @@ Creates and populates the geometry tables with the specified SRID.
.TP
\fB\-k\fR
-Keep idendifiers case (column, schema and attributes). Note that attributes in Shapefile are all UPPERCASE.
+Keep idendifiers case (column, schema and attributes). Note that attributes in Shapefile are usually all UPPERCASE.
.TP
\fB\-i\fR
View
456 doc/postgis.xml
@@ -104,7 +104,7 @@
Carl Anderson, David Skea, David Techer,
IIDA Tetsushi, Geographic Data BC, Gerald Fenoy,
Gino Lucrezi, Klaus Foerster, Kris Jurka, Mark Cave-Ayland,
- Mark Sondheim, Markus Schaber, Norman Vine,
+ Mark Sondheim, Markus Schaber, Nikita Shulga, Norman Vine,
Olivier Courtin, Ralph Mason,
Steffen Macke.
</para>
@@ -155,7 +155,7 @@
<listitem>
<para>The "<ulink
- url="http://www.opengis.org/techno/specs/99-049.pdf">Simple Features
+ url="http://www.opengis.org/docs/99-049.pdf">Simple Features
for Specification for SQL</ulink>" is available at the OpenGIS
Consortium web site: <ulink
url="http://www.opengis.org">http://www.opengis.org</ulink>.</para>
@@ -260,7 +260,7 @@
<listitem>
<para>Once your PostgreSQL installation is up-to-date, enter the
"postgis" directory, and edit the
- <filename>Makefile</filename>.</para>
+ <filename>Makefile.config</filename> file.</para>
<itemizedlist>
<listitem>
@@ -345,12 +345,43 @@
<title>Upgrading</title>
<para>
-Upgrading PostGIS can be tricky, because the underlying C libraries which
-support the object types and geometries may have changed between versions.
+Upgrading PostGIS can be tricky, because it is composed by both a shared
+library and a set of definitions that are stored in the host database.
</para>
<para>
-For this purpose PostGIS provides an utility script to restore a dump
+When the set of definitions changes (new objects, or procedural language
+functions modifications) it is not always easy to have them replace the
+old ones. Having a mismatch between definitions and implementations can
+bring to an unstable or unsable system.
+ </para>
+
+ <para>
+Since postgis version 0.9.0 You can check your installation state
+using <link linkend="postgis_full_version">postgis_full_version()</link>.
+The function will warn you with a "need proc upgrade" message if a mismatch
+is found.
+ </para>
+
+ <para>
+Before attempting to upgrade postgis, it is always worth to backup
+your data. If you use the -Fc flag to pg_dump you will always be able
+to restore the dump with an HARD UPGRADE.
+ </para>
+
+ <sect3 id="hard_upgrade">
+ <title>Hard upgrade</title>
+
+ <para>
+By HARD UPGRADE we intend full dump/reload of postgis-enabled databases.
+You need an HARD UPGRADE when postgis objects' internal storage
+changes or when SOFT UPGRADE is not possible.
+The <link linkend="release_notes">Release Notes</link> appendix reports for each version wheter you need a
+dump/reload (HARD UPGRADE) to upgrade.
+ </para>
+
+ <para>
+PostGIS provides an utility script to restore a dump
produced with the pg_dump -Fc command. It is experimental so redirecting
its output to a file will help in case of problems. The procedure is
as follow:
@@ -359,7 +390,7 @@ as follow:
<programlisting>
# Create a "custom-format" dump of the database you want
# to upgrade (let's call it "olddb")
- $ pg_dump -Fc olddb olddb.dump
+ $ pg_dump -Fc olddb &gt; olddb.dump
# Restore the dump contextually upgrading postgis into
# a new database. The new database doesn't have to exist.
@@ -384,15 +415,66 @@ as follow:
# If you did make additions we assume you know how to backup them before
# upgrading the table. Replace of it with the new one is done like this:
$ psql newdb
- newdb=&gt; drop table spatial_ref_sys;
+ newdb=&gt; delete from spatial_ref_sys;
DROP
newdb=&gt; \i spatial_ref_sys.sql
</programlisting>
+ </sect3>
+
+ <sect3 id="soft_upgrade">
+ <title>Soft upgrade</title>
+
+ <para>
+By SOFT UPGRADE we intend a live replacement of objects definitions.
+This is only possible in certain circumstances as not all objects
+are replaceable in a live system.
+ </para>
+
+ <para>
+To know wheter a SOFT UPGRADE should work for you refer to your new
+version section in the <link linkend="release_notes">Release Notes</link>
+appendix of this manual.
+ </para>
+
+ <para>
+The <link linkend="postgis_full_version">postgis_full_version()</link>
+function will also show you current state
+and by that you should be able to find out wheter or not SOFT UPGRADE
+will be possible. You should look at the DBPROC and RELPROC values.
+DBPROC are the procedures stored in the database, RELPROC are the
+procedures expected by the shared library (RELeased PROCedures).
+Their values represent SCRIPTS versions. If they don't match the
+function will warn you with a message: "needs proc upgrade".
+ </para>
+
+ <para>
+Soft (proc) upgrade will only be possible when the DBPROC and RELPROC
+versions share MAJOR and MINOR numbers. If this is the case you can
+try to use the utils/postgis_proc_upgrade.pl script. Note that the
+script will check for this itself so you should be safe attempting
+w/out checking it manually. Here is how you do:
+ </para>
+
+ <programlisting>
+
+ $ make install # DON'T DO IT IF WITHOUT BACKING UP YOUR DATA !
+
+ $ utils/postgis_proc_upgrade.pl lwpostgis.sql | psql &lt;db&gt;
+
+ </programlisting>
+
+ </sect3>
+
+
+
+ <sect3 id="hack_upgrade">
+ <title>Old method</title>
+
<para>
Following is the "old" procedure description. IT SHOULD BE AVOIDED if possible,
as it will leave in the database many spurious functions. It is kept in this document
-as a "backup" in case postgis_restore.pl won't work for you:
+as a "backup" in case HARD UPGRADE or SOFT UPGRADE won't work for you:
</para>
<programlisting>
@@ -405,6 +487,8 @@ as a "backup" in case postgis_restore.pl won't work for you:
vacuumdb -z yourdatabase
</programlisting>
+ </sect3>
+
</sect2>
@@ -448,23 +532,23 @@ as a "backup" in case postgis_restore.pl won't work for you:
</orderedlist>
<para>Also check that you have made any necessary changes to the top
- of the Makefile. This includes:</para>
+ of the Makefile.config. This includes:</para>
<orderedlist>
<listitem>
<para>If you want to be able to do coordinate reprojections, you
must install the Proj4 library on your system, set the
<varname>USE_PROJ</varname> variable to 1 and the
<varname>PROJ_DIR</varname> to your installation prefix in the
- Makefile.</para>
+ Makefile.config.</para>
</listitem>
<listitem>
<para>If you want to be able to use GEOS functions you must
install the GEOS library on your system, and set the
<varname>USE_GEOS</varname> to 1 and the
<varname>GEOS_DIR</varname> to your installation prefix in the
- Makefile.</para>
+ Makefile.config</para>
</listitem>
</orderedlist>
</sect2>
@@ -1518,7 +1602,7 @@ WHERE
AsText(GEOM) AS GEOM
FROM ROADS_GEOM
WHERE
- GEOM &amp;&amp; GeomFromText('BOX3D(191232 243117,191232 243119)'::box3d,-1);</programlisting>
+ GEOM &amp;&amp; SetSRID('BOX3D(191232 243117,191232 243119)'::box3d,-1);</programlisting>
<para>Note the use of the SRID, to specify the projection of the
BOX3D. The value -1 is used to indicate no specified SRID.</para>
@@ -2755,7 +2839,7 @@ dimension(the_geom)>2" skips re-writing of geometries that already are in 2D.
</varlistentry>
<varlistentry>
- <term>SetSRID(geometry)</term>
+ <term>SetSRID(geometry, integer)</term>
<listitem>
<para>Set the SRID on a geometry to a particular integer value.
@@ -2770,7 +2854,7 @@ dimension(the_geom)>2" skips re-writing of geometries that already are in 2D.
<variablelist>
<varlistentry>
- <term>Distance(geometry,geometry)</term>
+ <term>Distance(geometry, geometry)</term>
<listitem>
<para>Return the cartesian distance between two geometries in
@@ -2779,13 +2863,13 @@ dimension(the_geom)>2" skips re-writing of geometries that already are in 2D.
</varlistentry>
<varlistentry>
- <term>Equals(geometry,geometry)</term>
+ <term>Equals(geometry, geometry)</term>
<listitem>
- <para>Returns 1 (TRUE) if this Geometry is "spatially equal" to
- anotherGeometry. Use this for a 'better' answer than '='. equals
- ('LINESTRING(0 0, 10 10)','LINESTRING(0 0, 5 5, 10 10)') is
- true.</para>
+ <para>Returns 1 (TRUE) if the given Geometries are
+ "spatially equal". Use this for a 'better' answer than '='.
+ equals('LINESTRING(0 0, 10 10)','LINESTRING(0 0, 5 5, 10 10)')
+ is true.</para>
<para>Performed by the GEOS module</para>
@@ -2794,11 +2878,11 @@ dimension(the_geom)>2" skips re-writing of geometries that already are in 2D.
</varlistentry>
<varlistentry>
- <term>Disjoint(geometry,geometry)</term>
+ <term>Disjoint(geometry, geometry)</term>
<listitem>
- <para>Returns 1 (TRUE) if this Geometry is "spatially disjoint"
- from anotherGeometry.</para>
+ <para>Returns 1 (TRUE) if the Geometries are "spatially disjoint".
+ </para>
<para>Performed by the GEOS module</para>
@@ -2814,11 +2898,11 @@ dimension(the_geom)>2" skips re-writing of geometries that already are in 2D.
</varlistentry>
<varlistentry>
- <term>Intersects(geometry,geometry)</term>
+ <term>Intersects(geometry, geometry)</term>
<listitem>
- <para>Returns 1 (TRUE) if this Geometry "spatially intersects"
- anotherGeometry.</para>
+ <para>Returns 1 (TRUE) if the Geometries "spatially intersect".
+ </para>
<para>Performed by the GEOS module</para>
@@ -2834,11 +2918,11 @@ dimension(the_geom)>2" skips re-writing of geometries that already are in 2D.
</varlistentry>
<varlistentry>
- <term>Touches(geometry,geometry)</term>
+ <term>Touches(geometry, geometry)</term>
<listitem>
- <para>Returns 1 (TRUE) if this Geometry "spatially touches"
- anotherGeometry.</para>
+ <para>Returns 1 (TRUE) if the Geometries "spatially touch".
+ </para>
<para>Performed by the GEOS module</para>
@@ -2855,11 +2939,11 @@ dimension(the_geom)>2" skips re-writing of geometries that already are in 2D.
</varlistentry>
<varlistentry>
- <term>Crosses(geometry,geometry)</term>
+ <term>Crosses(geometry, geometry)</term>
<listitem>
- <para>Returns 1 (TRUE) if this Geometry "spatially crosses"
- anotherGeometry.</para>
+ <para>Returns 1 (TRUE) if the Geometries "spatially cross".
+ </para>
<para>Performed by the GEOS module</para>
@@ -2875,11 +2959,11 @@ dimension(the_geom)>2" skips re-writing of geometries that already are in 2D.
</varlistentry>
<varlistentry>
- <term>Within(geometry,geometry)</term>
+ <term>Within(geometry A, geometry B)</term>
<listitem>
- <para>Returns 1 (TRUE) if this Geometry is "spatially within"
- anotherGeometry.</para>
+ <para>Returns 1 (TRUE) if Geometry A is "spatially within"
+ Geometry B.</para>
<para>Performed by the GEOS module</para>
@@ -2895,11 +2979,11 @@ dimension(the_geom)>2" skips re-writing of geometries that already are in 2D.
</varlistentry>
<varlistentry>
- <term>Overlaps(geometry,geometry)</term>
+ <term>Overlaps(geometry, geometry)</term>
<listitem>
- <para>Returns 1 (TRUE) if this Geometry is "spatially
- overlapping" anotherGeometry.</para>
+ <para>Returns 1 (TRUE) if the Geometries "spatially
+ overlap".</para>
<para>Performed by the GEOS module</para>
@@ -2914,11 +2998,11 @@ dimension(the_geom)>2" skips re-writing of geometries that already are in 2D.
</varlistentry>
<varlistentry>
- <term>Contains(geometry,geometry)</term>
+ <term>Contains(geometry A, geometry B)</term>
<listitem>
- <para>Returns 1 (TRUE) if this Geometry is "spatially contains"
- anotherGeometry.</para>
+ <para>Returns 1 (TRUE) if Geometry A "spatially contains"
+ Geometry B.</para>
<para>Performed by the GEOS module</para>
@@ -2929,16 +3013,16 @@ dimension(the_geom)>2" skips re-writing of geometries that already are in 2D.
boolean, not an integer.</para>
<para>OGC SPEC s2.1.1.2 // s2.1.13.3 - same as
- within(geometry,geometry)</para>
+ within(geometry B, geometry A)</para>
</listitem>
</varlistentry>
<varlistentry>
- <term>Intersects(geometry,geometry)</term>
+ <term>Intersects(geometry, geometry)</term>
<listitem>
- <para>Returns 1 (TRUE) if this Geometry is "spatially
- intersects" anotherGeometry.</para>
+ <para>Returns 1 (TRUE) if the Geometries "spatially
+ intersect".</para>
<para>Performed by the GEOS module</para>
@@ -2949,12 +3033,12 @@ dimension(the_geom)>2" skips re-writing of geometries that already are in 2D.
boolean, not an integer.</para>
<para>OGC SPEC s2.1.1.2 // s2.1.13.3 - NOT
- disjoint(geometry,geometry)</para>
+ disjoint(geometry, geometry)</para>
</listitem>
</varlistentry>
<varlistentry>
- <term>Relate(geometry,geometry, intersectionPatternMatrix)</term>
+ <term>Relate(geometry, geometry, intersectionPatternMatrix)</term>
<listitem>
<para>Returns 1 (TRUE) if this Geometry is spatially related to
@@ -2975,7 +3059,7 @@ dimension(the_geom)>2" skips re-writing of geometries that already are in 2D.
</varlistentry>
<varlistentry>
- <term>Relate(geometry,geometry)</term>
+ <term>Relate(geometry, geometry)</term>
<listitem>
<para>returns the DE-9IM (dimensionally extended
@@ -3060,7 +3144,7 @@ dimension(the_geom)>2" skips re-writing of geometries that already are in 2D.
</varlistentry>
<varlistentry>
- <term>Buffer(geometry,double,[integer])</term>
+ <term>Buffer(geometry, double, [integer])</term>
<listitem>
<para>Returns a geometry that represents all points whose
@@ -3093,11 +3177,11 @@ dimension(the_geom)>2" skips re-writing of geometries that already are in 2D.
</varlistentry>
<varlistentry>
- <term>Intersection(geometry,geometry)</term>
+ <term>Intersection(geometry, geometry)</term>
<listitem>
<para>Returns a geometry that represents the point set
- intersection of this Geometry with anotherGeometry.</para>
+ intersection of the Geometies.</para>
<para>Performed by the GEOS module</para>
@@ -3109,11 +3193,11 @@ dimension(the_geom)>2" skips re-writing of geometries that already are in 2D.
</varlistentry>
<varlistentry>
- <term>SymDifference(geometry,geometry)</term>
+ <term>SymDifference(geometry A, geometry B)</term>
<listitem>
<para>Returns a geometry that represents the point set symmetric
- difference of this Geometry with anotherGeometry.</para>
+ difference of Geometry A with Geometry B.</para>
<para>Performed by the GEOS module</para>
@@ -3125,11 +3209,11 @@ dimension(the_geom)>2" skips re-writing of geometries that already are in 2D.
</varlistentry>
<varlistentry>
- <term>Difference(geometry,geometry)</term>
+ <term>Difference(geometry A, geometry B)</term>
<listitem>
<para>Returns a geometry that represents the point set symmetric
- difference of this Geometry with anotherGeometry.</para>
+ difference of Geometry A with Geometry B.</para>
<para>Performed by the GEOS module</para>
@@ -3141,11 +3225,11 @@ dimension(the_geom)>2" skips re-writing of geometries that already are in 2D.
</varlistentry>
<varlistentry>
- <term>GeomUnion(geometry,geometry)</term>
+ <term>GeomUnion(geometry, geometry)</term>
<listitem>
<para>Returns a geometry that represents the point set union of
- this Geometry with anotherGeometry.</para>
+ the Geometries.</para>
<para>Performed by the GEOS module</para>
@@ -3327,7 +3411,10 @@ dimension
GEOMETRYCOLLECTION, MULTIPOINT, MULTILINESTRING or MULTIPOLYGON.
Otherwise, return NULL.</para>
- <para>1 is 1st geometry</para>
+ <note> <para>
+ Index is 1-based as for OGC specs since version 0.8.0.
+ Previous versions implemented this as 0-based instead.
+ </para></note>
</listitem>
</varlistentry>
@@ -3348,6 +3435,10 @@ dimension
<para>Return the N'th point in the first linestring in the
geometry. Return NULL if there is no linestring in the
geometry.</para>
+ <note> <para>
+ Index is 1-based as for OGC specs since version 0.8.0.
+ Previous versions implemented this as 0-based instead.
+ </para></note>
</listitem>
</varlistentry>
@@ -3376,7 +3467,11 @@ dimension
<listitem>
<para>Return the N'th interior ring of the polygon geometry.
Return NULL if the geometry is not a polygon or the given
- N is out of range (1-based).</para>
+ N is out of range.</para>
+ <note> <para>
+ Index is 1-based as for OGC specs since version 0.8.0.
+ Previous versions implemented this as 0-based instead.
+ </para></note>
</listitem>
</varlistentry>
@@ -3785,20 +3880,29 @@ dimension
<term>postgis_lib_version()</term>
<listitem>
<para>Returns the version number of the PostGIS library.</para>
+ <para>
+ Availability: 0.9.0
+ </para>
</listitem>
</varlistentry>
<varlistentry>
<term>postgis_lib_build_date()</term>
<listitem>
<para>Returns build date of the PostGIS library.</para>
+ <para>
+ Availability: 1.0.0RC1
+ </para>
</listitem>
</varlistentry>
<varlistentry>
<term>postgis_script_build_date()</term>
<listitem>
<para>Returns build date of the PostGIS scripts.</para>
+ <para>
+ Availability: 1.0.0RC1
+ </para>
</listitem>
</varlistentry>
@@ -3808,6 +3912,9 @@ dimension
<listitem>
<para>Returns the version number of the lwpostgis.sql script
installed in this database.</para>
+ <para>
+ Availability: 0.9.0
+ </para>
</listitem>
</varlistentry>
@@ -3817,6 +3924,9 @@ dimension
<listitem>
<para>Returns the version number of the lwpostgis.sql script
released with the installed postgis lib.</para>
+ <para>
+ Availability: 0.9.0
+ </para>
</listitem>
</varlistentry>
@@ -3826,6 +3936,23 @@ dimension
<listitem>
<para>Returns the version number of the GEOS library, or NULL if
GEOS support is not enabled.</para>
+ <para>
+ Availability: 0.9.0
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>postgis_jts_version()</term>
+
+ <listitem>
+ <para>Returns the version number of the JTS library, or NULL if
+ JTS support is not enabled.</para>
+
+ <para>
+ Availability: 1.1.0
+ </para>
+
</listitem>
</varlistentry>
@@ -3835,6 +3962,9 @@ dimension
<listitem>
<para>Returns the version number of the PROJ4 library, or NULL if
PROJ4 support is not enabled.</para>
+ <para>
+ Availability: 0.9.0
+ </para>
</listitem>
</varlistentry>
@@ -3844,15 +3974,20 @@ dimension
<listitem>
<para>Returns true if STATS usage has been enabled, false
otherwise.</para>
+ <para>
+ Availability: 0.9.0
+ </para>
</listitem>
</varlistentry>
- <varlistentry>
+ <varlistentry id="postgis_full_version">
<term>postgis_full_version()</term>
<listitem>
<para>Reports full postgis version and build configuration
infos.</para>
+
+ <para>Availability: 0.9.0</para>
</listitem>
</varlistentry>
@@ -4658,12 +4793,207 @@ FROM geometry_table;</literallayout>
</sect1>
</chapter>
- <appendix>
+ <appendix id="release_notes">
<title>Release Notes</title>
<sect1>
+ <title>Release 1.0.4</title>
+ <para>Release date: 2005/09/12</para>
+
+ <para>
+Contains important bug fixes and a few improvements. In particular, it
+fixes a memory leak preventing successful build of GiST indexes
+for large spatial tables.
+ </para>
+
+ <sect2>
+ <title>Upgrading</title>
+
+ <para>If you are upgrading from
+ release 1.0.3 you <emphasis>DO
+ NOT</emphasis> need a dump/reload.
+ </para>
+
+ <para>If you are upgrading from
+ a release <emphasis>between 1.0.0RC6 and
+ 1.0.2</emphasis> (inclusive) and really want
+ a live upgrade read the <link
+ linkend="rel_1.0.3_upgrading">upgrade
+ section</link> of the 1.0.3 release notes
+ chapter.
+ </para>
+
+ <para>
+ Upgrade from any release prior to 1.0.0RC6
+ requires an <link linkend="hard_upgrade">hard
+ upgrade</link>.
+ </para>
+ </sect2>
+
+ <sect2>
+ <title>Bug fixes</title>
+ <para>Memory leak plugged in GiST indexing</para>
+ <para>Segfault fix in transform() handling of proj4 errors</para>
+ <para>Fixed some proj4 texts in spatial_ref_sys (missing +proj)</para>
+ <para>Loader: fixed string functions usage, reworked NULL objects check, fixed segfault on MULTILINESTRING input.</para>
+ <para>Fixed bug in MakeLine dimension handling</para>
+ <para>Fixed bug in translate() corrupting output bounding box</para>
+ </sect2>
+
+ <sect2>
+ <title>Improvements</title>
+ <para>Documentation improvements</para>
+ <para>More robust selectivity estimator </para>
+ <para>Minor speedup in distance()</para>
+ <para>Minor cleanups </para>
+ <para>GiST indexing cleanup</para>
+ <para>Looser syntax acceptance in box3d parser</para>
+ </sect2>
+
+ </sect1>
+
+ <sect1>
+ <title>Release 1.0.3</title>
+ <para>Release date: 2005/08/08</para>
+
+ <para>
+Contains some bug fixes - <emphasis>including a severe one affecting
+correctness of stored geometries</emphasis> - and a few improvements.
+ </para>
+
+ <sect2 id="rel_1.0.3_upgrading">
+ <title>Upgrading</title>
+
+ <para>
+Due to a bug in a bounding box computation routine, the upgrade procedure
+requires special attention, as bounding boxes cached in the database could
+be incorrect.
+ </para>
+
+ <para>
+An <link linkend="hard_upgrade">hard upgrade</link> procedure (dump/reload)
+will force recomputation of all bounding boxes (not included in dumps).
+This is <emphasis>required</emphasis> if upgrading from releases prior
+to 1.0.0RC6.
+ </para>
+
+ <para>
+If you are upgrading from versions 1.0.0RC6 or up, this release includes a
+perl script (utils/rebuild_bbox_caches.pl) to force recomputation of
+geometries' bounding boxes and invoke all operations required to propagate
+eventual changes in them (geometry statistics update, reindexing).
+Invoke the script after a make install (run with no args for syntax help).
+Optionally run utils/postgis_proc_upgrade.pl to refresh postgis procedures
+and functions signatures (see <link linkend="soft_upgrade">Soft upgrade</link>).
+ </para>
+
+
+ </sect2>
+
+ <sect2>
+ <title>Bug fixes</title>
+ <para>Severe bugfix in lwgeom's 2d bounding box computation</para>
+ <para>Bugfix in WKT (-w) POINT handling in loader</para>
+ <para>Bugfix in dumper on 64bit machines</para>
+ <para>Bugfix in dumper handling of user-defined queries </para>
+ <para>Bugfix in create_undef.pl script</para>
+ </sect2>
+
+ <sect2>
+ <title>Improvements</title>
+ <para>Small performance improvement in canonical input function</para>
+ <para>Minor cleanups in loader</para>
+ <para>Support for multibyte field names in loader</para>
+ <para>Improvement in the postgis_restore.pl script</para>
+ <para>New rebuild_bbox_caches.pl util script</para>
+ </sect2>
+
+ </sect1>
+
+ <sect1>
+ <title>Release 1.0.2</title>
+ <para>Release date: 2005/07/04</para>
+
+ <para>
+ Contains a few bug fixes and improvements.
+ </para>
+
+ <sect2>
+ <title>Upgrading</title>
+
+ <para>If you are upgrading from
+ release 1.0.0RC6 or up you <emphasis>DO
+ NOT</emphasis> need a dump/reload.</para>
+
+ <para>Upgrading from older releases
+ requires a dump/reload.
+ See the <link
+ linkend="upgrading">upgrading</link>
+ chapter for more informations.</para>
+ </sect2>
+
+ <sect2>
+ <title>Bug fixes</title>
+ <para>Fault tolerant btree ops</para>
+ <para>Memory leak plugged in pg_error</para>
+ <para>Rtree index fix</para>
+ <para>Cleaner build scripts (avoided mix of CFLAGS and CXXFLAGS)</para>
+ </sect2>
+
+ <sect2>
+ <title>Improvements</title>
+ <para>New index creation capabilities in loader (-I switch)</para>
+ <para>Initial support for postgresql 8.1dev</para>
+ </sect2>
+
+ </sect1>
+
+ <sect1>
+ <title>Release 1.0.1</title>
+ <para>Release date: 2005/05/24</para>
+
+ <para>
+ Contains a few bug fixes and some improvements.
+ </para>
+
+ <sect2>
+ <title>Upgrading</title>
+
+ <para>If you are upgrading from
+ release 1.0.0RC6 or up you <emphasis>DO
+ NOT</emphasis> need a dump/reload.</para>
+
+ <para>Upgrading from older releases
+ requires a dump/reload.
+ See the <link
+ linkend="upgrading">upgrading</link>
+ chapter for more informations.</para>
+ </sect2>
+
+ <sect2>
+ <title>Library changes</title>
+ <para>BUGFIX in 3d computation of lenght_spheroid()</para>
+ <para>BUGFIX in join selectivity estimator</para>
+ </sect2>
+
+ <sect2>
+ <title>Other changes/additions</title>
+ <para>BUGFIX in shp2pgql escape functions</para>
+ <para>better support for concurrent postgis in multiple schemas</para>
+ <para>documentation fixes</para>
+ <para>jdbc2: compile with "-target 1.2 -source 1.2" by default</para>
+ <para>NEW -k switch for pgsql2shp</para>
+ <para>NEW support for custom createdb options in postgis_restore.pl</para>
+ <para>BUGFIX in pgsql2shp attribute names unicity enforcement</para>
+ <para>BUGFIX in Paris projections definitions</para>
+ <para>postgis_restore.pl cleanups</para>
+ </sect2>
+
+ </sect1>
+
+ <sect1>
<title>Release 1.0.0</title>
- <para>Release date: 2005/04/??</para>
+ <para>Release date: 2005/04/19</para>
<para>Final 1.0.0 release.
Contains a few bug fixes, some improvements
@@ -4689,6 +5019,7 @@ FROM geometry_table;</literallayout>
<title>Library changes</title>
<para>BUGFIX in transform() releasing random memory address</para>
<para>BUGFIX in force_3dm() allocating less memory then required</para>
+ <para>BUGFIX in join selectivity estimator (defaults, leaks, tuplecount, sd)</para>
</sect2>
<sect2>
@@ -4699,6 +5030,7 @@ FROM geometry_table;</literallayout>
<para>NEW -p (prepare) flag for shp2pgsql</para>
<para>NEW manual chapter about OGC compliancy enforcement</para>
<para>NEW autoconf support for JTS lib</para>
+ <para>BUGFIX in estimator testers (support for LWGEOM and schema parsing)</para>
</sect2>
</sect1>
View
1 jdbc2/.cvsignore
@@ -5,3 +5,4 @@ stubbin
stubcompile
jtscompile
versionstamp
+eclipsebin
View
2 jdbc2/Makefile
@@ -27,7 +27,7 @@
# Configure the helper executables used during build.
-JAVAC?=javac
+JAVAC?=javac -target 1.2 -source 1.2
JAVA?=java
JAR?=jar
MKDIR?=mkdir -p
View
177 loader/pgsql2shp.c
@@ -73,6 +73,7 @@ int dswitchprovided;
int includegid;
int unescapedattrs;
int binary;
+int keep_fieldname_case;
SHPObject * (*shape_creator)(byte *, int);
int big_endian = 0;
int pgis_major_version;
@@ -166,6 +167,7 @@ main(int ARGC, char **ARGV)
includegid=0;
unescapedattrs=0;
binary = 0;
+ keep_fieldname_case = 0;
#ifdef DEBUG
FILE *debug;
#endif
@@ -2272,7 +2274,8 @@ usage(int status)
printf(" -b Use a binary cursor.\n");
printf(" -r Raw mode. Do not assume table has been created by \n");
printf(" the loader. This would not unescape attribute names\n");
- printf(" and will not skip the 'gid' attribute.");
+ printf(" and will not skip the 'gid' attribute.\n");
+ printf(" -k Keep postgresql identifiers case.\n");
printf("\n");
exit (status);
}
@@ -2287,50 +2290,52 @@ parse_commandline(int ARGC, char **ARGV)
buf[1023] = '\0'; // just in case...
/* Parse command line */
- while ((c = getopt(ARGC, ARGV, "bf:h:du:p:P:g:r")) != EOF){
- switch (c) {
- case 'b':
- binary = 1;
- break;
- case 'f':
- shp_file = optarg;
- break;
- case 'h':
- //setenv("PGHOST", optarg, 1);
- snprintf(buf, 255, "PGHOST=%s", optarg);
- putenv(strdup(buf));
- break;
- case 'd':
- dswitchprovided = 1;
- outtype = 'z';
- break;
- case 'r':
- includegid = 1;
- unescapedattrs = 1;
- break;
- case 'u':
- //setenv("PGUSER", optarg, 1);
- snprintf(buf, 255, "PGUSER=%s", optarg);
- putenv(strdup(buf));
- break;
- case 'p':
- //setenv("PGPORT", optarg, 1);
- snprintf(buf, 255, "PGPORT=%s", optarg);
- putenv(strdup(buf));
- break;
- case 'P':
- //setenv("PGPASSWORD", optarg, 1);
- snprintf(buf, 255, "PGPASSWORD=%s", optarg);
- putenv(strdup(buf));
- break;
- case 'g':
- geo_col_name = optarg;
- break;
- case '?':
- return 0;
- default:
- return 0;
- }
+ while ((c = getopt(ARGC, ARGV, "bf:h:du:p:P:g:rk")) != EOF){
+ switch (c) {
+ case 'b':
+ binary = 1;
+ break;
+ case 'f':
+ shp_file = optarg;
+ break;
+ case 'h':
+ //setenv("PGHOST", optarg, 1);
+ snprintf(buf, 255, "PGHOST=%s", optarg);
+ putenv(strdup(buf));
+ break;
+ case 'd':
+ dswitchprovided = 1;
+ outtype = 'z';
+ break;
+ case 'r':
+ includegid = 1;
+ unescapedattrs = 1;
+ break;
+ case 'u':
+ //setenv("PGUSER", optarg, 1);
+ snprintf(buf, 255, "PGUSER=%s", optarg);
+ putenv(strdup(buf));
+ break;
+ case 'p':
+ //setenv("PGPORT", optarg, 1);
+ snprintf(buf, 255, "PGPORT=%s", optarg);
+ putenv(strdup(buf));
+ break;
+ case 'P':
+ //setenv("PGPASSWORD", optarg, 1);
+ snprintf(buf, 255, "PGPASSWORD=%s", optarg);
+ putenv(strdup(buf));
+ break;
+ case 'g':
+ geo_col_name = optarg;
+ break;
+ case 'k':
+ keep_fieldname_case = 1;
+ break;
+ case '?':
+ default:
+ return 0;
+ }
}
curindex=0;
@@ -2365,7 +2370,6 @@ get_postgis_major_version(void)
exit(1);
}
- res = PQexec(conn, query);
version = PQgetvalue(res, 0, 0);
ver = atoi(version);
PQclear(res);
@@ -2390,6 +2394,8 @@ initialize(void)
int mainscan_nflds=0;
int size;
int gidfound=0;
+ char *dbf_flds[256];
+ int dbf_nfields=0;
/* Detect postgis version */
pgis_major_version = get_postgis_major_version();
@@ -2499,7 +2505,7 @@ initialize(void)
* This is exactly the geometry privided
* by the user.
*/
- else if (!strcmp(geo_col_name,fname))
+ else if (!strcmp(geo_col_name, fname))
{
geom_fld = mainscan_nflds;
type_ary[mainscan_nflds]=9;
@@ -2533,50 +2539,46 @@ initialize(void)
* becomes __xmin when escaped
*/
-
- if(strlen(ptr) <32) strcpy(field_name, ptr);
- else
- {
- /*
- * TODO: you find an appropriate name if
- * running in RAW mode
- */
- printf("dbf attribute name %s is too long, must be "
- "less than 32 characters.\n", ptr);
- return 0;
- }
-
-
- /* make UPPERCASE */
- for(j=0; j < strlen(field_name); j++)
- field_name[j] = toupper(field_name[j]);
+ /* Limit dbf field name to 10-digits */
+ strncpy(field_name, ptr, 10);
+ field_name[10] = 0;
/*
* make sure the fields all have unique names,
- * 10-digit limit on dbf names...
*/
- for(j=0;j<i;j++)
+ tmpint=1;
+ for(j=0; j<dbf_nfields; j++)
{
- if(strncmp(field_name, PQgetvalue(res, j, 0),10) == 0)
+ if(!strncasecmp(field_name, dbf_flds[j], 10))
{
- printf("\nWarning: Field '%s' has first 10 characters which "
- "duplicate a previous field name's.\n"
- "Renaming it to be: '",field_name);
- strncpy(field_name,field_name,9);
- field_name[9] = 0;
- sprintf(field_name,"%s%d",field_name,i);
- printf("%s'\n\n",field_name);
+ sprintf(field_name,"%.7s_%.2d",
+ ptr,
+ tmpint++);
+ j=-1; continue;
}
}
+ /* make UPPERCASE if keep_fieldname_case = 0 */
+ if (keep_fieldname_case == 0)
+ for(j=0; j<strlen(field_name); j++)
+ field_name[j] = toupper(field_name[j]);
+
+ if ( strcasecmp(fname, field_name) ) {
+ fprintf(stderr, "Warning, field %s renamed to %s\n",
+ fname, field_name);
+ }
+
+ //fprintf(stderr, "DBFfield: %s\n", field_name);
+ dbf_flds[dbf_nfields++] = strdup(field_name);
+
/*
* Find appropriate type of dbf attributes
*/
/* integer type */
if(type == 20 || type == 21 || type == 23)
{
- if(DBFAddField(dbf, field_name,FTInteger,16,0) == -1)
+ if(DBFAddField(dbf, field_name, FTInteger,16,0) == -1)
{
printf( "error - Field could not "
"be created.\n");
@@ -2632,7 +2634,7 @@ initialize(void)
//printf( "FIELD_NAME: %s, SIZE: %d\n", field_name, size);
/* generic type (use string representation) */
- if(DBFAddField(dbf, field_name,FTString,size,0) == -1)
+ if(DBFAddField(dbf, field_name, FTString, size, 0) == -1)
{
printf( "error - Field could not "
"be created.\n");
@@ -2642,6 +2644,9 @@ initialize(void)
mainscan_flds[mainscan_nflds++] = fname;
}
+ /* Release dbf field memory */
+ for (i=0; i<dbf_nfields; i++) free(dbf_flds[i]);
+
/*
* If no geometry has been found
* we have finished with initialization
@@ -2999,14 +3004,14 @@ byte popbyte(byte **c) {
}
uint32 popint(byte **c) {
- uint32 i;
+ uint32 i=0;
memcpy(&i, *c, 4);
*c+=4;
return i;
}
uint32 getint(byte *c) {
- uint32 i;
+ uint32 i=0;
memcpy(&i, c, 4);
return i;
}
@@ -3016,7 +3021,7 @@ void skipint(byte **c) {
}
double popdouble(byte **c) {
- double d;
+ double d=0.0;
memcpy(&d, *c, 8);
*c+=8;
return d;
@@ -3098,7 +3103,7 @@ create_usrquerytable(void)
char *query;
PGresult *res;
- query = malloc(sizeof(table)+sizeof(usrquery)+256);
+ query = malloc(strlen(table)+strlen(usrquery)+32);
sprintf(query, "CREATE TEMP TABLE \"%s\" AS %s", table, usrquery);
printf("Preparing table for user query... ");
@@ -3117,6 +3122,18 @@ create_usrquerytable(void)
/**********************************************************************
* $Log$
+ * Revision 1.74.2.4 2005/07/22 19:20:49 strk
+ * Fixed bug in {get,pop}{int,double} for 64bit archs
+ *
+ * Revision 1.74.2.3 2005/07/12 16:19:29 strk
+ * Fixed bug in user query handling, reported by Andrew Seales
+ *
+ * Revision 1.74.2.2 2005/05/16 17:51:17 strk
+ * BUGFIX in attribute names unicity enforcement
+ *
+ * Revision 1.74.2.1 2005/05/16 08:03:29 strk
+ * Back-ported -k patch
+ *
* Revision 1.74 2005/03/25 18:43:07 strk
* Fixed PQunescapeBytearea argument (might give problems on 64bit archs)
*
View
147 loader/shp2pgsql.c
@@ -59,6 +59,7 @@ typedef struct Ring {
int dump_format = 0; //0=insert statements, 1 = dump
int quoteidentifiers = 0;
int forceint4 = 0;
+int createindex = 0;
char opt = ' ';
char *col_names = NULL;
char *pgtype;
@@ -90,6 +91,7 @@ char *protect_quotes_string(char *str);
int PIP( Point P, Point* V, int n );
void *safe_malloc(size_t size);
void CreateTable(void);
+void CreateIndex(void);
void usage(char *me, int exitcode);
void InsertPoint(void);
void InsertPointWKT(void);
@@ -172,7 +174,7 @@ make_good_string(char *str)
if (toescape == 0) return str;
- size = ptr-str+toescape;
+ size = ptr-str+toescape+1;
result = calloc(1, size);
@@ -225,7 +227,7 @@ protect_quotes_string(char *str)
if (toescape == 0) return str;
- size = ptr-str+toescape;
+ size = ptr-str+toescape+1;
result = calloc(1, size);
@@ -396,6 +398,11 @@ main (int ARGC, char **ARGV)
if(opt != 'a') CreateTable();
/*
+ * Create GiST index if requested
+ */
+ if(createindex) CreateIndex();
+
+ /*
* Generate INSERT or COPY lines
*/
if(opt != 'p') LoadData();
@@ -423,6 +430,7 @@ void
OpenShape(void)
{
int j;
+ SHPObject *obj=NULL;
hSHPHandle = SHPOpen( shp_file, "rb" );
if (hSHPHandle == NULL) {
@@ -438,9 +446,17 @@ OpenShape(void)
SHPGetInfo(hSHPHandle, &num_entities, &shpfiletype, NULL, NULL);
/* Check we have at least a not-null geometry */
- j=num_entities;
- while( ( obj == NULL || obj->nVertices == 0 ) && j--)
+ for (j=0; j<num_entities; j++)
+ {
obj = SHPReadObject(hSHPHandle,j);
+ if ( obj && obj->nVertices > 0 ) {
+ SHPDestroyObject(obj);
+ break;
+ }
+ SHPDestroyObject(obj);
+ obj=NULL;
+ }
+
if ( obj == NULL)
{
fprintf(stderr, "Shapefile contains %d NULL object(s)\n",
@@ -567,6 +583,22 @@ CreateTable(void)
}
void
+CreateIndex(void)
+{
+ /*
+ * Create gist index
+ */
+ if ( schema )
+ {
+ printf("CREATE INDEX \"%s_%s_gist\" ON \"%s\".\"%s\" using gist (\"%s\" gist_geometry_ops);\n", table, geom, schema, table, geom);
+ }
+ else
+ {
+ printf("CREATE INDEX \"%s_%s_gist\" ON \"%s\" using gist (\"%s\" gist_geometry_ops);\n", table, geom, table, geom);
+ }
+}
+
+void
LoadData(void)
{
int j, trans=0;
@@ -707,6 +739,8 @@ usage(char *me, int exitcode)
fprintf(stderr, "\n");
fprintf(stderr, " -i Use int4 type for all integer dbf fields.\n");
fprintf(stderr, "\n");
+ fprintf(stderr, " -I Create a GiST index on the geometry column.\n");
+ fprintf(stderr, "\n");
fprintf(stderr, " -w Use wkt format (for postgis-0.x support - drops M - drifts coordinates).\n");
#ifdef USE_ICONV
fprintf(stderr, "\n");
@@ -732,7 +766,6 @@ InsertLineString(int id)
if (dump_format) printf("\\N\n");
else printf("NULL);\n");
- SHPDestroyObject(obj);
return;
}
@@ -787,7 +820,6 @@ InsertLineStringWKT(int id)
if (dump_format) printf("\\N\n");
else printf("NULL);\n");
- SHPDestroyObject(obj);
return;
}
@@ -1126,8 +1158,8 @@ void
InsertPointWKT(void)
{
unsigned int u;
- if (dump_format) printf("SRID=%s;POINT(",sr_id);
- else printf("GeometryFromText('POINT (");
+ if (dump_format) printf("SRID=%s;%s(", sr_id, pgtype);
+ else printf("GeometryFromText('%s(", pgtype);
for (u=0;u<obj->nVertices; u++){
if (u>0) printf(",");
@@ -1176,7 +1208,7 @@ ParseCmdline(int ARGC, char **ARGV)
extern char *optarg;
extern int optind;
- while ((c = getopt(ARGC, ARGV, "kcdapDs:g:iW:w")) != EOF){
+ while ((c = getopt(ARGC, ARGV, "kcdapDs:g:iW:wI")) != EOF){
switch (c) {
case 'c':
if (opt == ' ')
@@ -1217,6 +1249,9 @@ ParseCmdline(int ARGC, char **ARGV)
case 'i':
forceint4 = 1;
break;
+ case 'I':
+ createindex = 1;
+ break;
case 'w':
hwgeom = 1;
break;
@@ -1382,11 +1417,12 @@ dump_ring(Ring *ring)
{
char *buf = malloc(256*ring->n);
int i;
+
+ buf[0] = '\0';
for (i=0; i<ring->n; i++)
{
- if (i) sprintf(buf, "%s,", buf);
- sprintf(buf, "%s%g %g",
- buf,
+ if (i) strcat(buf, ",");
+ sprintf(buf+strlen(buf), "%g %g",
ring->list[i].x,
ring->list[i].y);
}
@@ -1483,19 +1519,27 @@ DropTable(char *schema, char *table, char *geom)
void
GetFieldsSpec(void)
{
+/*
+ * Shapefile (dbf) field name are at most 10chars + 1 NULL.
+ * Postgresql field names are at most 63 bytes + 1 NULL.
+ */
+#define MAXFIELDNAMELEN 64
int field_precision, field_width;
int j, z;
- char name[64];
- char name2[64];
+ char name[MAXFIELDNAMELEN];
+ char name2[MAXFIELDNAMELEN];
DBFFieldType type = -1;
+#ifdef USE_ICONV
+ char *utf8str;
+#endif
num_fields = DBFGetFieldCount( hDBFHandle );
num_records = DBFGetRecordCount(hDBFHandle);
field_names = malloc(num_fields*sizeof(char*));
types = (DBFFieldType *)malloc(num_fields*sizeof(int));
widths = malloc(num_fields*sizeof(int));
precisions = malloc(num_fields*sizeof(int));
- col_names = malloc((num_fields+2) * sizeof(char) * 32);
+ col_names = malloc((num_fields+2) * sizeof(char) * MAXFIELDNAMELEN);
strcpy(col_names, "(" );
//fprintf(stderr, "Number of fields from DBF: %d\n", num_fields);
@@ -1508,41 +1552,38 @@ GetFieldsSpec(void)
widths[j] = field_width;
precisions[j] = field_precision;
+#ifdef USE_ICONV
+ if ( encoding )
+ {
+ utf8str = utf8(encoding, name);
+ if ( ! utf8str ) exit(1);
+ strcpy(name, utf8str);
+ free(utf8str);
+ }
+#endif
+
+
/*
* Make field names lowercase unless asked to
* keep identifiers case.
*/
- if ( ! quoteidentifiers ) {
- for(z=0; z<strlen(name) ;z++)
- name[z] = tolower(name[z]);
- }
+ if ( ! quoteidentifiers ) LowerCase(name);
/*
* Escape names starting with the
- * escape char (_)
- */
- if( name[0]=='_' )
- {
- strcpy(name2+2, name);
- name2[0] = '_';
- name2[1] = '_';
- strcpy(name, name2);
- }
-
- /*
- * Escape attributes named 'gid'
- * and pgsql reserved attribute names
+ * escape char (_), those named 'gid'
+ * or after pgsql reserved attribute names
*/
- else if(
+ if( name[0]=='_' ||
! strcmp(name,"gid") ||
! strcmp(name, "tableoid") ||
! strcmp(name, "cmax") ||
! strcmp(name, "xmax") ||
! strcmp(name, "cmin") ||
! strcmp(name, "primary") ||
! strcmp(name, "oid") ||
- ! strcmp(name, "ctid")
- ) {
+ ! strcmp(name, "ctid") )
+ {
strcpy(name2+2, name);
name2[0] = '_';
name2[1] = '_';
@@ -1553,18 +1594,22 @@ GetFieldsSpec(void)
for(z=0; z < j ; z++){
if(strcmp(field_names[z],name)==0){
strcat(name,"__");
- sprintf(name,"%s%i",name,j);
+ sprintf(name+strlen(name),"%i",j);
break;
}
}
-
- field_names[j] = malloc ( strlen(name)+3 );
+ field_names[j] = malloc (strlen(name)+1);
strcpy(field_names[j], name);
- sprintf(col_names, "%s\"%s\",", col_names, name);
+ /*sprintf(col_names, "%s\"%s\",", col_names, name);*/
+ strcat(col_names, "\"");
+ strcat(col_names, name);
+ strcat(col_names, "\",");
}
- sprintf(col_names, "%s\"%s\")", col_names, geom);
+ /*sprintf(col_names, "%s\"%s\")", col_names, geom);*/
+ strcat(col_names, geom);
+ strcat(col_names, ")");
}
#ifdef USE_ICONV
@@ -1615,6 +1660,28 @@ utf8 (const char *fromcode, char *inputbuf)
/**********************************************************************
* $Log$
+ * Revision 1.88.2.7 2005/08/29 22:36:14 strk
+ * Removed premature object destruction in InsertLineString{WKT,} causing segfault
+ *
+ * Revision 1.88.2.6 2005/08/29 11:48:42 strk
+ * Fixed sprintf() calls to avoid overlapping memory,
+ * reworked not-null objects existance check to reduce startup costs.
+ *
+ * Revision 1.88.2.5 2005/07/27 02:47:06 strk
+ * Support for multibyte field names in loader
+ *
+ * Revision 1.88.2.4 2005/07/27 02:34:29 strk
+ * Minor cleanups in loader
+ *
+ * Revision 1.88.2.3 2005/07/27 02:05:20 strk
+ * Fixed handling of POINT types as WKT (-w) in loader
+ *
+ * Revision 1.88.2.2 2005/07/01 14:22:40 strk
+ * backported -I switch
+ *
+ * Revision 1.88.2.1 2005/04/21 09:07:41 strk
+ * Applied patch from Ron Mayer fixing a segfault in string escaper funx
+ *
* Revision 1.88 2005/04/14 12:58:59 strk
* Applied patch by Gino Lucrezi fixing bug in string escaping code.
*
View
15 lwgeom/Makefile
@@ -38,24 +38,25 @@ POSTGIS_BUILD_DATE := $(shell date -u "+%Y-%m-%d %H:%M:%S")
#---------------------------------------------------------------
-override CFLAGS += -g -O2 -fexceptions
-override CFLAGS += -fPIC
-#override CFLAGS += -I$(srcdir) -DFRONTEND -DSYSCONFDIR='"$(sysconfdir)"'
+CSTAR_FLAGS = -g -O2 -fPIC -fexceptions
+
override CFLAGS += -DUSE_VERSION=$(USE_VERSION)
override CFLAGS += -DPOSTGIS_LIB_VERSION='"$(POSTGIS_LIB_VERSION)"'
override CFLAGS += -DPOSTGIS_SCRIPTS_VERSION='"$(SCRIPTS_VERSION)"'
override CFLAGS += -DPOSTGIS_BUILD_DATE='"$(POSTGIS_BUILD_DATE)"'
JTS_OBJ=lwgeom_nojts.o
ifeq ($(USE_GEOS),1)
- override CFLAGS += -I$(GEOS_DIR)/include -DUSE_GEOS
+ CXXFLAGS += -I$(GEOS_DIR)/include
+ CSTAR_FLAGS += -DUSE_GEOS
GEOS_RULES=detect_geos_version
GEOS_WRAPPER=lwgeom_geos_wrapper.o
JTS_OBJ=lwgeom_geos.o
endif
ifeq ($(USE_JTS),1)
- override CFLAGS += -I$(JTS_INCLUDES) -DUSE_JTS
+ CXXFLAGS += -I$(JTS_INCLUDES)
+ CSTAR_FLAGS += -DUSE_JTS
JTS_WRAPPER=lwgeom_jts_wrapper.o
JTS_OBJ=lwgeom_jts.o
endif
@@ -68,7 +69,9 @@ override CFLAGS += -I$(PROJ_DIR)/include -DAUTOCACHE_BBOX=$(AUTOCACHE_BBOX)
override DLLLIBS += $(BE_DLLLIBS)
-override CXXFLAGS := $(CFLAGS)
+override CFLAGS += $(CSTAR_FLAGS)
+override CXXFLAGS += $(CSTAR_FLAGS)
+
# memory debug for gcc 2.91, 2.95, 3.0 and 3.1
# for gcc >= 3.2.2 set GLIBCPP_FORCE_NEW at runtime instead
#override CXXFLAGS += -D__USE_MALLOC
View
2 lwgeom/liblwgeom.h
@@ -345,7 +345,7 @@ extern int pointArray_ptsize(const POINTARRAY *pa);
* WHERE
* B = 16 byte BOX2DFLOAT4 follows (probably not aligned) [before SRID]
* S = 4 byte SRID attached (0= not attached (-1), 1= attached)
- * ZM = dimentionality (hasZ, hasM)
+ * ZM = dimensionality (hasZ, hasM)
* tttt = actual type (as per the WKB type):
*
* enum wkbGeometryType {
View
26 lwgeom/lwgeom_api.c
@@ -618,16 +618,12 @@ pointArray_construct(uchar *points, char hasz, char hasm,
uint32 npoints)
{
POINTARRAY *pa;
- size_t size;
pa = (POINTARRAY*)lwalloc(sizeof(POINTARRAY));
pa->dims = 0;
- TYPE_SETZM(pa->dims, hasz, hasm);
+ TYPE_SETZM(pa->dims, hasz?1:0, hasm?1:0);
pa->npoints = npoints;
- size=(2+hasz+hasm)*sizeof(double)*npoints;
- //pa->serialized_pointlist = lwalloc(size);
- //memcpy(pa->serialized_pointlist, points, size);
pa->serialized_pointlist = points;
return pa;
@@ -1361,15 +1357,17 @@ lwgeom_size_inspected(const LWGEOM_INSPECTED *inspected, int geom_number)
int
compute_serialized_box3d_p(uchar *srl, BOX3D *out)
{
- BOX3D *box = compute_serialized_box3d(srl);
- if ( ! box ) return 0;
- out->xmin = box->xmin;
- out->ymin = box->ymin;
- out->zmin = box->zmin;
- out->xmax = box->xmax;
- out->ymax = box->ymax;
- out->zmax = box->zmax;
- return 1;
+ BOX3D *box = compute_serialized_box3d(srl);
+ if ( ! box ) return 0;
+ out->xmin = box->xmin;
+ out->ymin = box->ymin;
+ out->zmin = box->zmin;
+ out->xmax = box->xmax;
+ out->ymax = box->ymax;
+ out->zmax = box->zmax;
+ lwfree(box);
+
+ return 1;
}
// Compute bounding box of a serialized LWGEOM, even if it is
View
4 lwgeom/lwgeom_box3d.c
@@ -70,12 +70,12 @@ Datum BOX3D_in(PG_FUNCTION_ARGS)
PG_RETURN_NULL();
}
- nitems = sscanf(str,"BOX3D(%le %le %le,%le %le %le)",
+ nitems = sscanf(str,"BOX3D(%le %le %le ,%le %le %le)",
&box->xmin, &box->ymin, &box->zmin,
&box->xmax, &box->ymax, &box->zmax);
if (nitems != 6 )
{
- nitems = sscanf(str,"BOX3D(%le %le,%le %le)",
+ nitems = sscanf(str,"BOX3D(%le %le ,%le %le)",
&box->xmin, &box->ymin, &box->xmax, &box->ymax);
if (nitems != 4)
{
View
25 lwgeom/lwgeom_btree.c
@@ -29,6 +29,16 @@ Datum lwgeom_cmp(PG_FUNCTION_ARGS);
//#define PGIS_DEBUG
+#if USE_VERSION == 72
+#define BTREE_SRID_MISMATCH_SEVERITY NOTICE
+#else
+#if USE_VERSION < 80
+#define BTREE_SRID_MISMATCH_SEVERITY WARNING
+#else
+#define BTREE_SRID_MISMATCH_SEVERITY ERROR
+#endif
+#endif
+
PG_FUNCTION_INFO_V1(lwgeom_lt);
Datum lwgeom_lt(PG_FUNCTION_ARGS)
{
@@ -43,7 +53,7 @@ Datum lwgeom_lt(PG_FUNCTION_ARGS)
if (pglwgeom_getSRID(geom1) != pglwgeom_getSRID(geom2))
{
- elog(ERROR,
+ elog(BTREE_SRID_MISMATCH_SEVERITY,
"Operation on two GEOMETRIES with different SRIDs\n");
if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 )
pfree(geom1);
@@ -100,7 +110,7 @@ Datum lwgeom_le(PG_FUNCTION_ARGS)
if (pglwgeom_getSRID(geom1) != pglwgeom_getSRID(geom2))
{
- elog(ERROR,
+ elog(BTREE_SRID_MISMATCH_SEVERITY,
"Operation on two GEOMETRIES with different SRIDs\n");
if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 )
pfree(geom1);
@@ -180,7 +190,7 @@ Datum lwgeom_eq(PG_FUNCTION_ARGS)
if (pglwgeom_getSRID(geom1) != pglwgeom_getSRID(geom2))
{
- elog(ERROR,
+ elog(BTREE_SRID_MISMATCH_SEVERITY,
"Operation on two GEOMETRIES with different SRIDs\n");
if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 )
pfree(geom1);
@@ -240,7 +250,7 @@ Datum lwgeom_ge(PG_FUNCTION_ARGS)
if (pglwgeom_getSRID(geom1) != pglwgeom_getSRID(geom2))
{
- elog(ERROR,
+ elog(BTREE_SRID_MISMATCH_SEVERITY,
"Operation on two GEOMETRIES with different SRIDs\n");
if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 )
pfree(geom1);
@@ -312,7 +322,7 @@ Datum lwgeom_gt(PG_FUNCTION_ARGS)
if (pglwgeom_getSRID(geom1) != pglwgeom_getSRID(geom2))
{
- elog(ERROR,
+ elog(BTREE_SRID_MISMATCH_SEVERITY,
"Operation on two GEOMETRIES with different SRIDs\n");
if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 )
pfree(geom1);
@@ -380,7 +390,7 @@ Datum lwgeom_cmp(PG_FUNCTION_ARGS)
if (pglwgeom_getSRID(geom1) != pglwgeom_getSRID(geom2))
{
- elog(ERROR,
+ elog(BTREE_SRID_MISMATCH_SEVERITY,
"Operation on two GEOMETRIES with different SRIDs\n");
if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 )
pfree(geom1);
@@ -449,6 +459,9 @@ Datum lwgeom_cmp(PG_FUNCTION_ARGS)
/***********************************************************
*
* $Log$
+ * Revision 1.7.2.1 2005/06/15 16:04:31 strk
+ * fault tolerant btree ops
+ *
* Revision 1.7 2005/02/07 13:21:10 strk
* Replaced DEBUG* macros with PGIS_DEBUG*, to avoid clashes with postgresql DEBUG
*
View
101 lwgeom/lwgeom_estimate.c
@@ -775,7 +775,11 @@ calculate_column_intersection(BOX2DFLOAT4 *search_box, GEOM_STATS *geomstats1, G
PG_FUNCTION_INFO_V1(LWGEOM_gist_joinsel);
Datum LWGEOM_gist_joinsel(PG_FUNCTION_ARGS)
{
+#if USE_VERSION < 81
Query *root = (Query *) PG_GETARG_POINTER(0);
+#else
+ PlannerInfo *root = (PlannerInfo *) PG_GETARG_POINTER(0);
+#endif
//Oid operator = PG_GETARG_OID(1);
List *args = (List *) PG_GETARG_POINTER(2);
JoinType jointype = (JoinType) PG_GETARG_INT16(3);
@@ -828,9 +832,14 @@ Datum LWGEOM_gist_joinsel(PG_FUNCTION_ARGS)
}
var1 = (Var *)arg1;
- relid1 = getrelid(var1->varno, root->rtable);
var2 = (Var *)arg2;
+#if USE_VERSION < 81
+ relid1 = getrelid(var1->varno, root->rtable);
relid2 = getrelid(var2->varno, root->rtable);
+#else
+ relid1 = getrelid(var1->varno, root->parse->rtable);
+ relid2 = getrelid(var2->varno, root->parse->rtable);
+#endif
#if DEBUG_GEOMETRY_STATS
elog(NOTICE, "Working with relations oids: %d %d", relid1, relid2);
@@ -841,9 +850,9 @@ Datum LWGEOM_gist_joinsel(PG_FUNCTION_ARGS)
if ( ! stats1_tuple )
{
#if DEBUG_GEOMETRY_STATS
- elog(NOTICE, " No statistics, returning default estimate");
+ elog(NOTICE, " No statistics, returning default geometry join selectivity");
#endif
- PG_RETURN_FLOAT8(DEFAULT_GEOMETRY_SEL);
+ PG_RETURN_FLOAT8(DEFAULT_GEOMETRY_JOINSEL);
}
@@ -853,10 +862,10 @@ Datum LWGEOM_gist_joinsel(PG_FUNCTION_ARGS)
(float4 **)&geomstats1, &geomstats1_nvalues) )
{
#if DEBUG_GEOMETRY_STATS
- elog(NOTICE, " STATISTIC_KIND_GEOMETRY stats not found - returning default geometry selectivity");
+ elog(NOTICE, " STATISTIC_KIND_GEOMETRY stats not found - returning default geometry join selectivity");
#endif
ReleaseSysCache(stats1_tuple);
- PG_RETURN_FLOAT8(DEFAULT_GEOMETRY_SEL);
+ PG_RETURN_FLOAT8(DEFAULT_GEOMETRY_JOINSEL);
}
@@ -865,9 +874,12 @@ Datum LWGEOM_gist_joinsel(PG_FUNCTION_ARGS)
if ( ! stats2_tuple )
{
#if DEBUG_GEOMETRY_STATS
- elog(NOTICE, " No statistics, returning default estimate");
+ elog(NOTICE, " No statistics, returning default geometry join selectivity");
#endif
- PG_RETURN_FLOAT8(DEFAULT_GEOMETRY_SEL);
+ free_attstatsslot(0, NULL, 0, (float *)geomstats1,
+ geomstats1_nvalues);
+ ReleaseSysCache(stats1_tuple);
+ PG_RETURN_FLOAT8(DEFAULT_GEOMETRY_JOINSEL);
}
@@ -876,10 +888,13 @@ Datum LWGEOM_gist_joinsel(PG_FUNCTION_ARGS)
(float4 **)&geomstats2, &geomstats2_nvalues) )
{
#if DEBUG_GEOMETRY_STATS
- elog(NOTICE, " STATISTIC_KIND_GEOMETRY stats not found - returning default geometry selectivity");
+ elog(NOTICE, " STATISTIC_KIND_GEOMETRY stats not found - returning default geometry join selectivity");
#endif
+ free_attstatsslot(0, NULL, 0, (float *)geomstats1,
+ geomstats1_nvalues);
ReleaseSysCache(stats2_tuple);
- PG_RETURN_FLOAT8(DEFAULT_GEOMETRY_SEL);
+ ReleaseSysCache(stats1_tuple);
+ PG_RETURN_FLOAT8(DEFAULT_GEOMETRY_JOINSEL);
}
@@ -963,6 +978,24 @@ Datum LWGEOM_gist_joinsel(PG_FUNCTION_ARGS)
elog(NOTICE, "Estimated rows returned: %f", rows_returned);
#endif
+ /*
+ * One (or both) tuple count is zero...
+ * We return default selectivity estimate.
+ * We could probably attempt at an estimate
+ * w/out looking at tables tuple count, with
+ * a function of selectivity1, selectivity2.
+ */
+ if ( ! total_tuples )
+ {
+#if DEBUG_GEOMETRY_STATS
+ elog(NOTICE, "Total tuples == 0, returning default join selectivity");
+#endif
+ PG_RETURN_FLOAT8(DEFAULT_GEOMETRY_JOINSEL);
+ }
+
+ if ( rows_returned > total_tuples )
+ PG_RETURN_FLOAT8(1.0);
+
PG_RETURN_FLOAT8(rows_returned / total_tuples);
}
@@ -1329,7 +1362,9 @@ Datum LWGEOM_estimated_extent(PG_FUNCTION_ARGS)
* of a search_box looking at data in the GEOM_STATS
* structure.
*
- * TODO: handle box dimension collapses
+ * TODO: handle box dimension collapses (probably should be handled
+ * by the statistic generator, avoiding GEOM_STATS with collapsed
+ * dimensions)
*/
static float8
estimate_selectivity(BOX2DFLOAT4 *box, GEOM_STATS *geomstats)
@@ -1381,6 +1416,11 @@ estimate_selectivity(BOX2DFLOAT4 *box, GEOM_STATS *geomstats)
histocols = geomstats->cols;
historows = geomstats->rows;
+#if DEBUG_GEOMETRY_STATS
+ elog(NOTICE, " histogram has %d cols, %d rows", histocols, historows);
+ elog(NOTICE, " histogram geosize is %fx%f", geow, geoh);
+#endif
+
cell_area = (geow*geoh) / (histocols*historows);
//box_area = (box->high.x-box->low.x)*(box->high.y-box->low.y);
box_area = (box->xmax-box->xmin)*(box->ymax-box->ymin);
@@ -1537,6 +1577,14 @@ elog(NOTICE, " search_box overlaps %f cells", overlapping_cells);
elog(NOTICE, " avg feat overlaps %f cells", avg_feat_cells);
#endif
+ if ( ! overlapping_cells )
+ {
+#if DEBUG_GEOMETRY_STATS
+ elog(NOTICE, " no overlapping cells, returning 0.0");
+#endif
+ return 0.0;
+ }
+
gain = 1/LW_MIN(overlapping_cells, avg_feat_cells);
selectivity = value*gain;
@@ -1571,7 +1619,11 @@ elog(NOTICE, " avg feat overlaps %f cells", avg_feat_cells);
PG_FUNCTION_INFO_V1(LWGEOM_gist_sel);
Datum LWGEOM_gist_sel(PG_FUNCTION_ARGS)
{
+#if USE_VERSION < 81
Query *root = (Query *) PG_GETARG_POINTER(0);
+#else
+ PlannerInfo *root = (PlannerInfo *) PG_GETARG_POINTER(0);
+#endif
//Oid operator = PG_GETARG_OID(1);
List *args = (List *) PG_GETARG_POINTER(2);
//int varRelid = PG_GETARG_INT32(3);
@@ -1656,8 +1708,12 @@ Datum LWGEOM_gist_sel(PG_FUNCTION_ARGS)
* Get pg_statistic row
*/
+#if USE_VERSION < 81
// relid = getrelid(varRelid, root->rtable);
relid = getrelid(self->varno, root->rtable);
+#else
+ relid = getrelid(self->varno, root->parse->rtable);
+#endif
stats_tuple = SearchSysCache(STATRELATT, ObjectIdGetDatum(relid), Int16GetDatum(self->varattno), 0, 0);
if ( ! stats_tuple )
@@ -1917,10 +1973,10 @@ compute_geometry_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc,
sdHIGx += (box->xmax - avgHIGx) * (box->xmax - avgHIGx);
sdHIGy += (box->ymax - avgHIGy) * (box->ymax - avgHIGy);
}
- sdLOWx = sqrt(sdLOWx/(notnull_cnt-1));
- sdLOWy = sqrt(sdLOWy/(notnull_cnt-1));
- sdHIGx = sqrt(sdHIGx/(notnull_cnt-1));
- sdHIGy = sqrt(sdHIGy/(notnull_cnt-1));
+ sdLOWx = sqrt(sdLOWx/notnull_cnt);
+ sdLOWy = sqrt(sdLOWy/notnull_cnt);
+ sdHIGx = sqrt(sdHIGx/notnull_cnt);
+ sdHIGy = sqrt(sdHIGy/notnull_cnt);
#if DEBUG_GEOMETRY_STATS
elog(NOTICE, " standard deviations:");
@@ -2454,6 +2510,23 @@ Datum LWGEOM_estimated_extent(PG_FUNCTION_ARGS)
/**********************************************************************
* $Log$
+ * Revision 1.29.2.5 2005/09/08 19:26:10 strk
+ * Handled search_box outside of histogram_box case in selectivity estimator
+ *
+ * Revision 1.29.2.4 2005/06/28 22:00:05 strk
+ * Fixed extimators to work with postgresql 8.1.x
+ *
+ * Revision 1.29.2.3 2005/04/22 01:05:41 strk
+ * Fixed bug in join selectivity estimator returning invalid estimates (>1)
+ *
+ * Revision 1.29.2.2 2005/04/18 14:12:59 strk
+ * Slightly changed standard deviation computation to be more corner-case-friendly.
+ *
+ * Revision 1.29.2.1 2005/04/18 10:57:01 strk
+ * Applied patched by Ron Mayer fixing memory leakages and invalid results
+ * in join selectivity estimator. Fixed some return to use default JOIN
+ * selectivity estimate instead of default RESTRICT selectivity estimate.
+ *
* Revision 1.29 2005/03/25 09:34:25 strk
* code cleanup
*
View
4 lwgeom/lwgeom_functions_basic.c
@@ -1500,13 +1500,15 @@ Datum LWGEOM_translate(PG_FUNCTION_ARGS)
lwgeom_translate_recursive(srl, xoff, yoff, zoff);
/* COMPUTE_BBOX WHEN_SIMPLE */
- hasbbox=getbox2d_p(srl, &box);
+ hasbbox = lwgeom_hasBBOX(geom->type);
if ( hasbbox )
{
+ getbox2d_p(srl, &box);
box.xmin += xoff;
box.xmax += xoff;
box.ymin += yoff;
box.ymax += yoff;
+ memcpy(srl+1, &box, sizeof(BOX2DFLOAT4));
}
// Construct PG_LWGEOM
View
1