v1-0001-hstore_plperl-Add-CHECK_FOR_INTERRUPTS-in-referen.patch
text/x-patch
Filename: v1-0001-hstore_plperl-Add-CHECK_FOR_INTERRUPTS-in-referen.patch
Type: text/x-patch
Part: 0
Patch
Format: format-patch
Series: patch v1-0001
Subject: hstore_plperl: Add CHECK_FOR_INTERRUPTS() in reference-unwinding loop
| File | + | − |
|---|---|---|
| contrib/hstore_plperl/hstore_plperl.c | 4 | 0 |
From 43c7cc6353ca9700471ca41c8e4aa1db4aee58c1 Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <aleksander@tigerdata.com>
Date: Thu, 18 Jun 2026 14:41:33 +0300
Subject: [PATCH v1] hstore_plperl: Add CHECK_FOR_INTERRUPTS() in
reference-unwinding loop
plperl_to_hstore() uses a while loop to dereference chains of Perl
references before processing the underlying hash value. This loop had
no way to be interrupted, so a circular reference chain (e.g. $x = \$x)
would cause the backend to spin indefinitely without any possibility of
cancellation via Ctrl+C.
Add CHECK_FOR_INTERRUPTS() inside the loop so that a query involving a
circular Perl reference can be cancelled by the user.
This is a follow-up to da82fbb8f9, which fixed the same issue in
SV_to_JsonbValue() in jsonb_plperl.
Author: Aleksander Alekseev <aleksander@tigerdata.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAJ7c6TPbjkzUk4qJ5dHvDNEz0hBuFue3A-XWz_=897z+BC+z8A@mail.gmail.com
Backpatch-through: 14
---
contrib/hstore_plperl/hstore_plperl.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/contrib/hstore_plperl/hstore_plperl.c b/contrib/hstore_plperl/hstore_plperl.c
index 996b46b148d..1da6fd228ce 100644
--- a/contrib/hstore_plperl/hstore_plperl.c
+++ b/contrib/hstore_plperl/hstore_plperl.c
@@ -2,6 +2,7 @@
#include "fmgr.h"
#include "hstore/hstore.h"
+#include "miscadmin.h"
#include "plperl.h"
PG_MODULE_MAGIC_EXT(
@@ -111,7 +112,10 @@ plperl_to_hstore(PG_FUNCTION_ARGS)
/* Dereference references recursively. */
while (SvROK(in))
+ {
+ CHECK_FOR_INTERRUPTS();
in = SvRV(in);
+ }
/* Now we must have a hash. */
if (SvTYPE(in) != SVt_PVHV)
--
2.43.0