Thread: Nested/recursive query execution

Nested/recursive query execution

From
Paresh Bafna
Date:
Hi all,
I am new to postgres developement. Want some help.
Can we run nested query in postgres?
Means, can I do like -

When somequery is being executed (say "create database") it goes through
exec_simple_query():backend/tcop/postgres.c (if I am not wrong) then can
I call exec_simple_query() from createdb():backend/commands/dbcommands.c

Actually I tried to do that but I think portal used for "create
database" is still ACTIVE when I call exec_simple_again, and thats why
it give error like "can not drop portal - still active"

Is it due to exec_simple_query() creates unnamed portal?




Re: Nested/recursive query execution

From
Martijn van Oosterhout
Date:
On Sat, Oct 22, 2005 at 03:41:07PM +0530, Paresh Bafna wrote:
> Hi all,
> I am new to postgres developement. Want some help.
> Can we run nested query in postgres?

The answer is yes, although you generally need to use the SPI interface
to do it. Among other things it sets up everything to work recursively.

Consider, foreign keys, SQL functions, etc are all recursive
invokations of a sort....

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.