From af8756713fcbbf907954b7a77072229910662520 Mon Sep 17 00:00:00 2001
From: Bruce Momjian <bruce@momjian.us>
Date: Mon, 4 Jul 2005 19:03:30 +0000
Subject: This patch allows the PL/Python module to do (SRF) functions.

The patch was taken from the CVS version.

I have modified the plpython.c file and have added a test sql script for
testing the functionality. It was actually the script that was in the
8.0.3 version but have since been removed.

In order to signal the end of a set, the called python function must
simply return plpy.EndOfSet and the set would be returned.

Gerrit van Dyk
---
 src/pl/plpython/sql/plpython_setof.sql | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 src/pl/plpython/sql/plpython_setof.sql

(limited to 'src/pl/plpython/sql/plpython_setof.sql')

diff --git a/src/pl/plpython/sql/plpython_setof.sql b/src/pl/plpython/sql/plpython_setof.sql
new file mode 100644
index 0000000000..6e15788672
--- /dev/null
+++ b/src/pl/plpython/sql/plpython_setof.sql
@@ -0,0 +1,12 @@
+
+CREATE or replace FUNCTION test_setof() returns setof text
+	AS
+'if GD.has_key("calls"):
+	GD["calls"] = GD["calls"] + 1
+	if GD["calls"] > 2:
+		del GD["calls"]
+		return plpy.EndOfSet
+else:
+	GD["calls"] = 1
+return str(GD["calls"])'
+	LANGUAGE plpythonu;
-- 
cgit v1.2.1

