Re: Recursive plpgsql function in rule

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: mito <milos(dot)orszag(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Recursive plpgsql function in rule
Date: 2009-04-19 13:18:54
Message-ID: 49EB24BE.2080109@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Stefan Kaltenbrunner 2009-04-19 13:29:01 planner crash/assert hit in 8.4B1
Previous Message mito 2009-04-19 11:57:20 Reference on partial data