summaryrefslogtreecommitdiff
path: root/src/pl/plpython/sql/plpython_spi.sql
diff options
context:
space:
mode:
Diffstat (limited to 'src/pl/plpython/sql/plpython_spi.sql')
-rw-r--r--src/pl/plpython/sql/plpython_spi.sql19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/pl/plpython/sql/plpython_spi.sql b/src/pl/plpython/sql/plpython_spi.sql
index a882738e0b..87170609da 100644
--- a/src/pl/plpython/sql/plpython_spi.sql
+++ b/src/pl/plpython/sql/plpython_spi.sql
@@ -52,9 +52,6 @@ return None
'
LANGUAGE plpythonu;
-
-
-
CREATE FUNCTION join_sequences(s sequences) RETURNS text
AS
'if not s["multipart"]:
@@ -68,10 +65,16 @@ return seq
'
LANGUAGE plpythonu;
+CREATE FUNCTION spi_recursive_sum(a int) RETURNS int
+ AS
+'r = 0
+if a > 1:
+ r = plpy.execute("SELECT spi_recursive_sum(%d) as a" % (a-1))[0]["a"]
+return a + r
+'
+ LANGUAGE plpythonu;
-
-
-
+--
-- spi and nested calls
--
select nested_call_one('pass this along');
@@ -79,15 +82,13 @@ select spi_prepared_plan_test_one('doe');
select spi_prepared_plan_test_one('smith');
select spi_prepared_plan_test_nested('smith');
-
-
-
SELECT join_sequences(sequences) FROM sequences;
SELECT join_sequences(sequences) FROM sequences
WHERE join_sequences(sequences) ~* '^A';
SELECT join_sequences(sequences) FROM sequences
WHERE join_sequences(sequences) ~* '^B';
+SELECT spi_recursive_sum(10);
--
-- plan and result objects