[SCM] PostGIS branch master updated. 3.6.0rc2-169-gcf5994644

git at osgeo.org git at osgeo.org
Thu Oct 30 10:21:17 PDT 2025


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  cf5994644e5233da594c17bc3b4fd49a780e72ff (commit)
      from  5f13309312fb79142c5d870828e17455c6f8f93d (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 cf5994644e5233da594c17bc3b4fd49a780e72ff
Author: Darafei Praliaskouski <me at komzpa.net>
Date:   Thu Oct 30 21:21:02 2025 +0400

    [raster] ST_DumpAsPolygons honours PostgreSQL interrupts
    
    Closes #4222

diff --git a/NEWS b/NEWS
index 06b41d6f1..0c485943c 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,7 @@ xxxx/xx/xx
  - #4798, ST_AsGeoJSON warns about duplicate property keys (Darafei Praliaskouski)
  - #5950, Document POSTGIS_REGRESS_DB_OWNER for sandboxed regression roles (Darafei Praliaskouski)
  - #4332, Clarify the scope of several Function Reference categories (Darafei Praliaskouski)
+ - #4222, [raster] ST_DumpAsPolygons honours PostgreSQL interrupts (Darafei Praliaskouski)
 
 
 * Bug Fixes *
diff --git a/doc/reference_raster.xml b/doc/reference_raster.xml
index cd7ab9b8f..10559043e 100644
--- a/doc/reference_raster.xml
+++ b/doc/reference_raster.xml
@@ -14169,6 +14169,7 @@ FROM (SELECT ST_SetRotation(rast, 0.1, 0.1) As rast
                     can be used to expand a single raster into multiple POLYGONS/MULTIPOLYGONS.</para>
 
                     <para>Changed 3.3.0, validation and fixing is disabled to improve performance. May result invalid geometries.</para>
+                    <para>Changed 3.7.0, the polygonization honours PostgreSQL interrupts so cancellations and statement timeouts halt processing promptly.</para>
                     <para role="availability" conformance="1.7">Availability: Requires GDAL 1.7 or higher.</para>
                     <note><para>If there is a no data value set for a band, pixels with that value will not be returned except in the case of exclude_nodata_value=false.</para></note>
                     <note><para>If you only care about count of pixels with a given value in a raster, it is faster to use <xref linkend="RT_ST_ValueCount"/>.</para></note>
diff --git a/raster/rt_core/librtcore.h b/raster/rt_core/librtcore.h
index b4395ba2b..ded95f1c9 100644
--- a/raster/rt_core/librtcore.h
+++ b/raster/rt_core/librtcore.h
@@ -2373,6 +2373,9 @@ rt_util_gdal_register_all(int force_register_all);
 int
 rt_util_gdal_driver_registered(const char *drv);
 
+int
+rt_util_gdal_progress_func(double dfComplete, const char *pszMessage, void *pProgressArg);
+
 /*
 	wrapper for GDALOpen and GDALOpenShared
 */
diff --git a/raster/rt_core/rt_gdal.c b/raster/rt_core/rt_gdal.c
index 748a8ff12..ff01c1d66 100644
--- a/raster/rt_core/rt_gdal.c
+++ b/raster/rt_core/rt_gdal.c
@@ -4,6 +4,7 @@
  * http://trac.osgeo.org/postgis/wiki/WKTRaster
  *
  * Copyright (C) 2021 Paul Ramsey <pramsey at cleverelephant.ca>
+ * Copyright (C) 2025 Darafei Praliaskouski <me at komzpa.net>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -55,10 +56,14 @@ typedef struct
 /*  GDAL progress callback for interrupt handling */
 /* ---------------------------------------------------------------- */
 
-static int rt_util_gdal_progress_func(
-	double dfComplete,
-	const char *pszMessage,
-	void *pProgressArg)
+/*
+ * WHY: We surface a single callback so every GDAL routine invoked from the
+ * raster core can honour PostgreSQL cancellations consistently.  Returning
+ * FALSE forces the GDAL algorithm to unwind immediately when liblwgeom has
+ * recorded an interrupt request (#4222).
+ */
+int
+rt_util_gdal_progress_func(double dfComplete, const char *pszMessage, void *pProgressArg)
 {
 	(void)dfComplete;
 	(void)pszMessage;
@@ -66,7 +71,7 @@ static int rt_util_gdal_progress_func(
 	if (_lwgeom_interrupt_requested)
 	{
 		// rtwarn("%s interrupted at %g", (const char*)pProgressArg, dfComplete);
-		_lwgeom_interrupt_requested = 0;
+		lwgeom_cancel_interrupt();
 		return FALSE;
 	}
 	else
diff --git a/raster/rt_core/rt_geometry.c b/raster/rt_core/rt_geometry.c
index 7c997d44f..2c126f4b8 100644
--- a/raster/rt_core/rt_geometry.c
+++ b/raster/rt_core/rt_geometry.c
@@ -10,6 +10,7 @@
  * Copyright (C) 2009-2011 Pierre Racine <pierre.racine at sbf.ulaval.ca>
  * Copyright (C) 2009-2011 Mateusz Loskot <mateusz at loskot.net>
  * Copyright (C) 2008-2009 Sandro Santilli <strk at kbt.io>
+ * Copyright (C) 2025 Darafei Praliaskouski <me at komzpa.net>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -1136,8 +1137,12 @@ rt_raster_gdal_polygonize(
 		return NULL;
 	}
 
-	/* We don't need a raster mask band. Each band has a nodata value. */
-	cplerr = GDALFPolygonize(gdal_band, NULL, hLayer, iPixVal, NULL, NULL, NULL);
+	/*
+	 * Why: We pass the shared interrupt-aware progress callback so GDAL can
+	 * unwind promptly when PostgreSQL requests cancellation (#4222).
+	 */
+	cplerr = GDALFPolygonize(
+	    gdal_band, NULL, hLayer, iPixVal, NULL, rt_util_gdal_progress_func, (void *)"GDALFPolygonize");
 
 	if (cplerr != CE_None) {
 		rterror("rt_raster_gdal_polygonize: Could not polygonize GDAL band");
diff --git a/raster/test/cunit/cu_gdal.c b/raster/test/cunit/cu_gdal.c
index 421bf93f3..aa53fe268 100644
--- a/raster/test/cunit/cu_gdal.c
+++ b/raster/test/cunit/cu_gdal.c
@@ -4,6 +4,7 @@
  *
  * Copyright (C) 2012 Regents of the University of California
  *   <bkpark at ucdavis.edu>
+ * Copyright (C) 2025 Darafei Praliaskouski <me at komzpa.net>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -277,6 +278,29 @@ static void test_gdal_polygonize() {
 	cu_free_raster(rt);
 }
 
+static void
+test_gdal_polygonize_interrupt(void)
+{
+	rt_raster rt;
+	int nPols = 0;
+	rt_geomval gv = NULL;
+
+	rt = fillRasterToPolygonize(0, 0.0);
+	CU_ASSERT(rt != NULL);
+
+	/* Why: confirm that the GDAL callback honours liblwgeom interrupts (#4222). */
+	lwgeom_request_interrupt();
+	gv = rt_raster_gdal_polygonize(rt, 0, TRUE, &nPols);
+	lwgeom_cancel_interrupt();
+
+	CU_ASSERT_PTR_NULL(gv);
+	CU_ASSERT_EQUAL(nPols, 0);
+
+	if (gv)
+		rtdealloc(gv);
+	cu_free_raster(rt);
+}
+
 static void test_raster_to_gdal() {
 	rt_pixtype pixtype = PT_64BF;
 	rt_raster raster = NULL;
@@ -608,6 +632,7 @@ void gdal_suite_setup(void)
 	PG_ADD_TEST(suite, test_gdal_drivers);
 	PG_ADD_TEST(suite, test_gdal_rasterize);
 	PG_ADD_TEST(suite, test_gdal_polygonize);
+	PG_ADD_TEST(suite, test_gdal_polygonize_interrupt);
 	PG_ADD_TEST(suite, test_raster_to_gdal);
 	PG_ADD_TEST(suite, test_gdal_to_raster);
 	PG_ADD_TEST(suite, test_gdal_warp);

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

Summary of changes:
 NEWS                         |  1 +
 doc/reference_raster.xml     |  1 +
 raster/rt_core/librtcore.h   |  3 +++
 raster/rt_core/rt_gdal.c     | 15 ++++++++++-----
 raster/rt_core/rt_geometry.c |  9 +++++++--
 raster/test/cunit/cu_gdal.c  | 25 +++++++++++++++++++++++++
 6 files changed, 47 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list