From: | "Vadim B(dot) Mikheev" <vadim(at)sable(dot)krasnoyarsk(dot)su> |
---|---|
To: | Michael Meskes <meskes(at)topsystem(dot)de> |
Cc: | PostgreSQL Hacker <pgsql-hackers(at)postgreSQL(dot)org> |
Subject: | Re: [HACKERS] Recursive queries? |
Date: | 1998-02-20 09:59:17 |
Message-ID: | 34ED53F5.B3F6CEE9@sable.krasnoyarsk.su |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Michael Meskes wrote:
>
> I know that postgres originally was able to do recursive queries like
>
> retrieve* into a from a ...
>
> Is this still possible with PostgreSQL? If so, is it just for one statement
> or even as a block?
Yes, it's possible. This is from spi.txt:
---
Data changes visibility
PostgreSQL data changes visibility rule: during a query execution, data
changes made by the query itself (via SQL-function, SPI-function, triggers)
are invisible to the query scan. For example, in query
INSERT INTO a SELECT * FROM a
tuples inserted are invisible for SELECT' scan. In effect, this
duplicates the database table within itself (subject to unique index
rules, of course) without recursing.
Changes made by query Q are visible by queries which are started after
query Q, no matter whether they are started inside Q (during the execution
of Q) or after Q is done.
---
Second query 'INSERT INTO a SELECT * FROM a' inside BEGIN/END
will see tuples inserted by first one. Pg uses special CommandCounter
to distinguish changes made in the same transaction.
> This happens to be the area I worked on for several years.
I also like such areas :)
Vadim
From | Date | Subject | |
---|---|---|---|
Next Message | Meskes, Michael | 1998-02-20 10:35:18 | RE: [HACKERS] Recursive queries? |
Previous Message | Ronald Baljeu | 1998-02-20 09:46:31 | Re: [HACKERS] Solution to the pg_user passwd problem !?? (c) |