Re: Recursive plpgsql function in rule - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Recursive plpgsql function in rule
Date
Msg-id 49EB24BE.2080109@enterprisedb.com
Whole thread Raw
In response to Recursive plpgsql function in rule  (mito <milos.orszag@gmail.com>)
List pgsql-hackers
mito wrote:
> I am trying to select subtree by parent id in table:
> 
> create table categories(
>     id int,
>     parent_id int
> );
> 
> I am fetching it by recursive plpgsql function, which works well.
> 
> When i use that function as part of rule operation, i am getting ERROR: 
>  stack depth limit exceeded.
> 
> I have tried to rewrite without recursion which cause infinite loop in 
> rule.
> 
> Is it possible to sent dynamic structures in planer?
> Or how to fetch subtree without change of table structure inside rule?

I didn't quite understand the issue, but as a general hint you might 
want to look at PG 8.4 beta which introduces support for recursive 
queries using the SQL standard WITH syntax. That's very useful when 
dealing with tree structures.

--   Heikki Linnakangas  EnterpriseDB   http://www.enterprisedb.com


pgsql-hackers by date:

Previous
From: mito
Date:
Subject: Reference on partial data
Next
From: Stefan Kaltenbrunner
Date:
Subject: planner crash/assert hit in 8.4B1