[SCM] PostGIS branch stable-3.5 updated. 3.5.2-3-g0b003a829
git at osgeo.org
git at osgeo.org
Fri Jan 24 15:08:53 PST 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, stable-3.5 has been updated
via 0b003a82991bf05022ab1b924b5f8e1e407cd043 (commit)
from ca9733b9f19805736528bbda81d5d7ca3e415c5f (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 0b003a82991bf05022ab1b924b5f8e1e407cd043
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Fri Jan 24 15:08:08 2025 -0800
Remove use of pqsignal in favour of checking pgsql interrupt
variables in order to respect user interrupt request.
References #5841
diff --git a/NEWS b/NEWS
index 6759cbd52..2458d2c98 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,10 @@ PostgreSQL 12-18 required. GEOS 3.8+ required. Proj 6.1+ required.
* Bug fixes *
+- #5841, Change approach to interrupt handling to conform to PgSQL
+ recommended practice (Paul Ramsey)
+
+
PostGIS 3.5.2
2025/01/18
diff --git a/postgis/postgis_module.c b/postgis/postgis_module.c
index 5c207d3da..01d54ca95 100644
--- a/postgis/postgis_module.c
+++ b/postgis/postgis_module.c
@@ -25,6 +25,7 @@
#include "postgres.h"
#include "fmgr.h"
+#include "miscadmin.h"
#include "executor/executor.h"
#include "utils/elog.h"
#include "utils/guc.h"
@@ -45,18 +46,31 @@
*/
PG_MODULE_MAGIC;
-static pqsigfunc coreIntHandler = 0;
-static void handleInterrupt(int sig);
-
-#ifdef WIN32
-static void interruptCallback() {
- if (UNBLOCKED_SIGNAL_QUEUE())
- pgwin32_dispatch_queued_signals();
+static void interrupt_geos_callback()
+{
+ /*
+ * If PgSQL global flags show interrupt,
+ * flip the pending flag in GEOS
+ * to end current query.
+ */
+ if (QueryCancelPending || ProcDiePending)
+ {
+ GEOS_interruptRequest();
+ }
}
-#endif
-static ExecutorStart_hook_type onExecutorStartPrev = NULL;
-static void onExecutorStart(QueryDesc *queryDesc, int eflags);
+static void interrupt_liblwgeom_callback()
+{
+ /*
+ * If PgSQL global flags show interrupt,
+ * flip the pending flag in liblwgeom
+ * to end current query.
+ */
+ if (QueryCancelPending || ProcDiePending)
+ {
+ lwgeom_request_interrupt();
+ }
+}
/*
* Pass proj error message out via the PostgreSQL logging
@@ -79,25 +93,22 @@ pjLogFunction(void* data, int logLevel, const char* message)
void _PG_init(void);
void
_PG_init(void)
-{
- coreIntHandler = pqsignal(SIGINT, handleInterrupt);
+ {
+ /*
+ * Hook up interrupt checking to call back here
+ * and examine the PgSQL interrupt state variables
+ */
+ GEOS_interruptRegisterCallback(interrupt_geos_callback);
+ lwgeom_register_interrupt_callback(interrupt_liblwgeom_callback);
-#ifdef WIN32
- GEOS_interruptRegisterCallback(interruptCallback);
- lwgeom_register_interrupt_callback(interruptCallback);
-#endif
+ /* Install PostgreSQL error/memory handlers */
+ pg_install_lwgeom_handlers();
- /* install PostgreSQL handlers */
- pg_install_lwgeom_handlers();
-
- /* pass proj messages through the pgsql error handler */
#if POSTGIS_PROJ_VERSION > 60000
- proj_log_func(NULL, NULL, pjLogFunction);
+ /* Pass proj messages through the pgsql error handler */
+ proj_log_func(NULL, NULL, pjLogFunction);
#endif
- /* setup hooks */
- onExecutorStartPrev = ExecutorStart_hook;
- ExecutorStart_hook = onExecutorStart;
}
/*
@@ -107,54 +118,7 @@ void _PG_fini(void);
void
_PG_fini(void)
{
- elog(NOTICE, "Goodbye from PostGIS %s", POSTGIS_VERSION);
- pqsignal(SIGINT, coreIntHandler);
-
- /* restore original hooks */
- ExecutorStart_hook = onExecutorStartPrev;
+ elog(NOTICE, "Goodbye from PostGIS %s", POSTGIS_VERSION);
}
-static void
-handleInterrupt(int sig)
-{
- /* NOTE: printf here would be dangerous, see
- * https://trac.osgeo.org/postgis/ticket/3644
- *
- * TODO: block interrupts during execution, to fix the problem
- */
- /* printf("Interrupt requested\n"); fflush(stdout); */
-
- GEOS_interruptRequest();
-
-#ifdef HAVE_LIBPROTOBUF
- /* Taking out per #5385 crash */
- //lwgeom_wagyu_interruptRequest();
-#endif
-
- /* request interruption of liblwgeom as well */
- lwgeom_request_interrupt();
-
- if ( coreIntHandler ) {
- (*coreIntHandler)(sig);
- }
-}
-
-static void onExecutorStart(QueryDesc *queryDesc, int eflags) {
- /* cancel interrupt requests */
-
- GEOS_interruptCancel();
-
-#ifdef HAVE_LIBPROTOBUF
- /* Taking out per #5385 crash */
- //lwgeom_wagyu_interruptReset();
-#endif
-
- lwgeom_cancel_interrupt();
-
- if (onExecutorStartPrev) {
- (*onExecutorStartPrev)(queryDesc, eflags);
- } else {
- standard_ExecutorStart(queryDesc, eflags);
- }
-}
diff --git a/raster/rt_pg/rtpostgis.c b/raster/rt_pg/rtpostgis.c
index 44e11461a..3e24479b5 100644
--- a/raster/rt_pg/rtpostgis.c
+++ b/raster/rt_pg/rtpostgis.c
@@ -646,48 +646,6 @@ rtpg_assignHookEnableOutDBRasters(bool enable, void *extra) {
}
-
-/*
-* Machinery for intercepting the system SIGINT
-* handler so we can cancel long-running GDAL operations
-* via the progress handlers.
-*/
-static pqsigfunc coreIntHandler = 0;
-
-#ifdef WIN32
-static void interruptCallback() {
- if (UNBLOCKED_SIGNAL_QUEUE())
- pgwin32_dispatch_queued_signals();
-}
-#endif
-
-
-/*
-* This is the interrupt capture for this module.
-* Before handing off the signal to the core, it
-* sets the interrupt flag for currently running
-* functions.
-*/
-static void
-handleInterrupt(int sig)
-{
- /*
- * NOTE: printf here would be dangerous, see
- * https://trac.osgeo.org/postgis/ticket/3644
- */
- // printf("postgis_raster interrupt requested\n"); fflush(stdout);
-
- /* Request interruption of liblwgeom as well */
- lwgeom_request_interrupt();
-
- /* Pass control into the usual core handler */
- if (coreIntHandler) {
- (*coreIntHandler)(sig);
- }
-}
-
-
-
/* Module load callback */
void
_PG_init(void) {
@@ -695,15 +653,6 @@ _PG_init(void) {
bool boot_postgis_enable_outdb_rasters = false;
MemoryContext old_context;
- /* Set up interrupt capture */
- coreIntHandler = pqsignal(SIGINT, handleInterrupt);
-
-#ifdef WIN32
- GEOS_interruptRegisterCallback(interruptCallback);
- lwgeom_register_interrupt_callback(interruptCallback);
-#endif
-
-
/*
* Change to context for memory allocation calls like palloc() in the
* extension initialization routine
@@ -867,9 +816,6 @@ _PG_fini(void) {
elog(NOTICE, "Goodbye from PostGIS Raster %s", POSTGIS_VERSION);
- /* Return SIGINT handling to core */
- pqsignal(SIGINT, coreIntHandler);
-
/* Clean up */
pfree(env_postgis_gdal_enabled_drivers);
pfree(boot_postgis_gdal_enabled_drivers);
diff --git a/sfcgal/lwgeom_sfcgal.c b/sfcgal/lwgeom_sfcgal.c
index 3575a1aec..c091acadb 100644
--- a/sfcgal/lwgeom_sfcgal.c
+++ b/sfcgal/lwgeom_sfcgal.c
@@ -40,17 +40,6 @@
* This is required for builds against pgsql
*/
PG_MODULE_MAGIC;
-#ifdef WIN32
-static void
-interruptCallback()
-{
- if (UNBLOCKED_SIGNAL_QUEUE())
- pgwin32_dispatch_queued_signals();
-}
-#endif
-
-static pqsigfunc coreIntHandler = 0;
-static void handleInterrupt(int sig);
/*
* Module load callback
@@ -59,14 +48,6 @@ void _PG_init(void);
void
_PG_init(void)
{
-
- coreIntHandler = pqsignal(SIGINT, handleInterrupt);
-
-#ifdef WIN32
- GEOS_interruptRegisterCallback(interruptCallback);
- lwgeom_register_interrupt_callback(interruptCallback);
-#endif
-
/* install PostgreSQL handlers */
pg_install_lwgeom_handlers();
}
@@ -79,27 +60,8 @@ void
_PG_fini(void)
{
elog(NOTICE, "Goodbye from PostGIS SFCGAL %s", POSTGIS_VERSION);
- pqsignal(SIGINT, coreIntHandler);
}
-static void
-handleInterrupt(int sig)
-{
- /* NOTE: printf here would be dangerous, see
- * https://trac.osgeo.org/postgis/ticket/3644
- *
- * TODO: block interrupts during execution, to fix the problem
- */
- /* printf("Interrupt requested\n"); fflush(stdout); */
-
- /* request interruption of liblwgeom as well */
- lwgeom_request_interrupt();
-
- if (coreIntHandler)
- {
- (*coreIntHandler)(sig);
- }
-}
Datum postgis_sfcgal_version(PG_FUNCTION_ARGS);
-----------------------------------------------------------------------
Summary of changes:
NEWS | 4 ++
postgis/postgis_module.c | 108 ++++++++++++++++-------------------------------
raster/rt_pg/rtpostgis.c | 54 ------------------------
sfcgal/lwgeom_sfcgal.c | 38 -----------------
4 files changed, 40 insertions(+), 164 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list