[SCM] PostGIS branch master updated. 3.6.0rc2-643-g45c26068e

git at osgeo.org git at osgeo.org
Sun Jun 21 07:13:12 PDT 2026


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".

The branch, master has been updated
       via  45c26068ef27de003a39e69c01532340063ecc13 (commit)
      from  6884c2be41810eb4d02a1d0f88ca61439024f827 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 45c26068ef27de003a39e69c01532340063ecc13
Author: Darafei Praliaskouski <me at komzpa.net>
Date:   Sun Jun 21 18:12:09 2026 +0400

    Clarify shp2pgsql zip archive input
    
    Report .zip archive input before the loader tries to open shapefile sidecar files, and document that shapefiles must be unpacked before loading.
    
    References #1577
    
    Closes https://github.com/postgis/postgis/pull/1109

diff --git a/NEWS b/NEWS
index c67f2b50f..20209cb38 100644
--- a/NEWS
+++ b/NEWS
@@ -57,6 +57,8 @@ To take advantage of all postgis_sfcgal extension features SFCGAL 2.3+ is needed
 
 * Enhancements *
 
+ - #1577, [loader] Report unsupported .zip archive input before trying
+          to open shapefile sidecar files (Darafei Praliaskouski)
  - #3158, Move geometry and geography typmod bit helpers out of the
           public liblwgeom header (Darafei Praliaskouski)
  - #2116, [raster] Add ST_Value nearest-neighbor boundary options
diff --git a/doc/man/shp2pgsql.1 b/doc/man/shp2pgsql.1
index c840c60f9..2cd3b9720 100644
--- a/doc/man/shp2pgsql.1
+++ b/doc/man/shp2pgsql.1
@@ -19,6 +19,8 @@ Version: 1.1.5 (2006/10/06)
 The <shapefile> is the name of the shape file, without any extension
 information. For example, 'roads' would be the name of the shapefile 
 comprising the 'roads.shp', 'roads.shx', and 'roads.dbf' files.
+Compressed archives are not read directly; unpack .zip packages before
+loading the shapefile components.
 
 The <tablename> is the (optionally schema-qualified) name of the database 
 table you want the data stored in in the database. Within that table, 
diff --git a/doc/using_postgis_dataman.xml b/doc/using_postgis_dataman.xml
index 8f840a5ce..be8c75391 100644
--- a/doc/using_postgis_dataman.xml
+++ b/doc/using_postgis_dataman.xml
@@ -1877,6 +1877,11 @@ COMMIT;</programlisting>
     insertion into a PostGIS/PostgreSQL database either in geometry or geography format.
     The loader has several operating modes selected by command line flags.
   </para>
+  <para>
+    The input must be an unpacked shapefile path. The loader does not read
+    <filename>.zip</filename> archives directly; unpack the <filename>.shp</filename>,
+    <filename>.shx</filename>, and <filename>.dbf</filename> files before loading.
+  </para>
   <para>There is also a <filename>shp2pgsql-gui</filename> graphical interface with most
 	of the options as the command-line loader.
     This may be easier to use for one-off non-scripted loading or if you are new to PostGIS.
diff --git a/loader/cunit/cu_shp2pgsql.c b/loader/cunit/cu_shp2pgsql.c
index 01be2be03..c43f5ac55 100644
--- a/loader/cunit/cu_shp2pgsql.c
+++ b/loader/cunit/cu_shp2pgsql.c
@@ -20,6 +20,7 @@ void test_ShpLoaderDestroy(void);
 void test_ShpLoaderGetSQLHeader_drop_prepare(void);
 void test_ShpLoaderGetSQLHeader_if_not_exists_table_modifier(void);
 void test_ShpLoaderGetSQLFooter_if_not_exists_index_modifier(void);
+void test_ShpLoaderOpenShapeRejectsZip(void);
 
 SHPLOADERCONFIG *loader_config;
 SHPLOADERSTATE *loader_state;
@@ -47,7 +48,8 @@ CU_pSuite register_shp2pgsql_suite(void)
 				 test_ShpLoaderGetSQLHeader_if_not_exists_table_modifier)) ||
 	    (NULL == CU_add_test(pSuite,
 				 "test_ShpLoaderGetSQLFooter_if_not_exists_index_modifier()",
-				 test_ShpLoaderGetSQLFooter_if_not_exists_index_modifier)))
+				 test_ShpLoaderGetSQLFooter_if_not_exists_index_modifier)) ||
+	    (NULL == CU_add_test(pSuite, "test_ShpLoaderOpenShapeRejectsZip()", test_ShpLoaderOpenShapeRejectsZip)))
 	{
 		CU_cleanup_registry();
 		return NULL;
@@ -175,3 +177,28 @@ test_ShpLoaderGetSQLFooter_if_not_exists_index_modifier(void)
 	free(footer);
 	ShpLoaderDestroy(loader_state);
 }
+
+void
+test_ShpLoaderOpenShapeRejectsZip(void)
+{
+	int ret;
+
+	loader_config = (SHPLOADERCONFIG *)calloc(1, sizeof(SHPLOADERCONFIG));
+	set_loader_config_defaults(loader_config);
+	loader_config->shp_file = "fixtures/parcel.ZIP";
+	loader_state = ShpLoaderCreate(loader_config);
+	ret = ShpLoaderOpenShape(loader_state);
+	CU_ASSERT_EQUAL(ret, SHPLOADERERR);
+	CU_ASSERT_PTR_NOT_NULL(strstr(loader_state->message, "does not read .zip archives"));
+	ShpLoaderDestroy(loader_state);
+
+	loader_config = (SHPLOADERCONFIG *)calloc(1, sizeof(SHPLOADERCONFIG));
+	set_loader_config_defaults(loader_config);
+	loader_config->shp_file = "fixtures.zip/parcel";
+	loader_config->readshape = 0;
+	loader_state = ShpLoaderCreate(loader_config);
+	ret = ShpLoaderOpenShape(loader_state);
+	CU_ASSERT_EQUAL(ret, SHPLOADERERR);
+	CU_ASSERT_PTR_NULL(strstr(loader_state->message, "does not read .zip archives"));
+	ShpLoaderDestroy(loader_state);
+}
diff --git a/loader/shp2pgsql-core.c b/loader/shp2pgsql-core.c
index 52226802a..394d5dd66 100644
--- a/loader/shp2pgsql-core.c
+++ b/loader/shp2pgsql-core.c
@@ -16,6 +16,7 @@
 #include "../postgis_config.h"
 
 #include <math.h> /* for isnan */
+#include <strings.h>
 
 #include "shp2pgsql-core.h"
 #include "../liblwgeom/liblwgeom.h"
@@ -55,7 +56,25 @@ int PIP(Point P, Point *V, int n);
 int FindPolygons(SHPObject *obj, Ring ***Out);
 void ReleasePolygons(Ring **polys, int npolys);
 int GeneratePolygonGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry);
+static int shp_loader_is_zip_archive(const char *filename);
 
+static int
+shp_loader_is_zip_archive(const char *filename)
+{
+	const char *basename;
+	const char *ext;
+
+	if (!filename)
+		return 0;
+
+	basename = strrchr(filename, '/');
+	if (!basename)
+		basename = strrchr(filename, '\\');
+	basename = basename ? basename + 1 : filename;
+
+	ext = strrchr(basename, '.');
+	return ext && strcasecmp(ext, ".zip") == 0;
+}
 
 /* Return allocated string containing UTF8 string converted from encoding fromcode */
 static int
@@ -966,6 +985,15 @@ ShpLoaderOpenShape(SHPLOADERSTATE *state)
 	DBFFieldType type = FTInvalid;
 	char *utf8str;
 
+	if (shp_loader_is_zip_archive(state->config->shp_file))
+	{
+		snprintf(state->message,
+			 SHPLOADERMSGLEN,
+			 _("%s: shp2pgsql does not read .zip archives; unpack the .shp, .shx, and .dbf files first."),
+			 state->config->shp_file);
+		return SHPLOADERERR;
+	}
+
 	/* If we are reading the entire shapefile, open it */
 	if (state->config->readshape == 1)
 	{

-----------------------------------------------------------------------

Summary of changes:
 NEWS                          |  2 ++
 doc/man/shp2pgsql.1           |  2 ++
 doc/using_postgis_dataman.xml |  5 +++++
 loader/cunit/cu_shp2pgsql.c   | 29 ++++++++++++++++++++++++++++-
 loader/shp2pgsql-core.c       | 28 ++++++++++++++++++++++++++++
 5 files changed, 65 insertions(+), 1 deletion(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list