mirror of
https://github.com/postgres/postgres.git
synced 2025-07-09 22:41:56 +03:00
Quick-and-dirty fix for recursive plpgsql functions, per bug report from
Frank Miles 7-Sep-01. This is really just sticking a finger in the dike. Frank's case works now, but we still couldn't support a recursive function returning a set. Really need to restructure querytrees and execution state so that the querytree is *read only*. We've run into this over and over and over again ... it has to happen sometime soon.
This commit is contained in:
@ -1515,3 +1515,22 @@ insert into IFace values ('IF', 'notthere', 'eth0', '');
|
||||
ERROR: system "notthere" does not exist
|
||||
insert into IFace values ('IF', 'orion', 'ethernet_interface_name_too_long', '');
|
||||
ERROR: IFace slotname "IF.orion.ethernet_interface_name_too_long" too long (20 char max)
|
||||
--
|
||||
-- Test recursion, per bug report 7-Sep-01
|
||||
--
|
||||
CREATE FUNCTION recursion_test(int,int) RETURNS text AS '
|
||||
DECLARE rslt text;
|
||||
BEGIN
|
||||
IF $1 <= 0 THEN
|
||||
rslt = CAST($2 AS TEXT);
|
||||
ELSE
|
||||
rslt = CAST($1 AS TEXT) || '','' || recursion_test($1 - 1, $2);
|
||||
END IF;
|
||||
RETURN rslt;
|
||||
END;' LANGUAGE 'plpgsql';
|
||||
SELECT recursion_test(4,3);
|
||||
recursion_test
|
||||
----------------
|
||||
4,3,2,1,3
|
||||
(1 row)
|
||||
|
||||
|
@ -1399,3 +1399,18 @@ delete from HSlot;
|
||||
insert into IFace values ('IF', 'notthere', 'eth0', '');
|
||||
insert into IFace values ('IF', 'orion', 'ethernet_interface_name_too_long', '');
|
||||
|
||||
--
|
||||
-- Test recursion, per bug report 7-Sep-01
|
||||
--
|
||||
CREATE FUNCTION recursion_test(int,int) RETURNS text AS '
|
||||
DECLARE rslt text;
|
||||
BEGIN
|
||||
IF $1 <= 0 THEN
|
||||
rslt = CAST($2 AS TEXT);
|
||||
ELSE
|
||||
rslt = CAST($1 AS TEXT) || '','' || recursion_test($1 - 1, $2);
|
||||
END IF;
|
||||
RETURN rslt;
|
||||
END;' LANGUAGE 'plpgsql';
|
||||
|
||||
SELECT recursion_test(4,3);
|
||||
|
Reference in New Issue
Block a user