From bd039d1e92813358c5c5a1e346b49074baf513f2 Mon Sep 17 00:00:00 2001
From: rudb <office@database.ru>
Date: Thu, 03 Dec 2026 07:46:00 +0000
Subject: [PATCH] СУБД RuDB - релиз 4
---
src/pl/plpython/sql/plpython_spi.sql | 39 +++++++++++++++++++++++++++++++++++++++
1 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/src/pl/plpython/sql/plpython_spi.sql b/src/pl/plpython/sql/plpython_spi.sql
index 00dcc8b..276d130 100644
--- a/src/pl/plpython/sql/plpython_spi.sql
+++ b/src/pl/plpython/sql/plpython_spi.sql
@@ -307,3 +307,42 @@
SELECT cursor_plan();
SELECT cursor_plan_wrong_args();
SELECT plan_composite_args();
+
+-- A custom argument sequence whose length matches the plan but whose
+-- __getitem__ raises should be reported as an error, not crash the backend.
+CREATE FUNCTION plan_broken_arg_sequence() RETURNS void AS $$
+plan = plpy.prepare("select $1", ["int4"])
+class C:
+ def __len__(self):
+ return 1
+ def __getitem__(self, i):
+ raise ValueError('getitem failed')
+plpy.execute(plan, C())
+$$ LANGUAGE plpython3u;
+
+SELECT plan_broken_arg_sequence();
+
+-- Likewise for the type-name list passed to plpy.prepare().
+CREATE FUNCTION prepare_broken_type_sequence() RETURNS void AS $$
+class C:
+ def __len__(self):
+ return 1
+ def __getitem__(self, i):
+ raise ValueError('getitem failed')
+plpy.prepare("select $1", C())
+$$ LANGUAGE plpython3u;
+
+SELECT prepare_broken_type_sequence();
+
+-- Likewise for the argument sequence passed to plpy.cursor().
+CREATE FUNCTION cursor_broken_arg_sequence() RETURNS void AS $$
+plan = plpy.prepare("select $1", ["int4"])
+class C:
+ def __len__(self):
+ return 1
+ def __getitem__(self, i):
+ raise ValueError('getitem failed')
+plpy.cursor(plan, C())
+$$ LANGUAGE plpython3u;
+
+SELECT cursor_broken_arg_sequence();
--
Gitblit v1.10.0