Re: Prepare/Declare

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Prepare/Declare
Дата
Msg-id 20209.1180037247@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Prepare/Declare  (Michael Meskes <meskes@postgresql.org>)
Ответы Re: Prepare/Declare  (Michael Meskes <meskes@postgresql.org>)
Список pgsql-hackers
Michael Meskes <meskes@postgresql.org> writes:
> PREPARE p AS
>     SELECT * FROM foo;
> DECLARE c CURSOR for p;

> AFAIRC the standard says this group of statements are perfectly legal

I'd be interested to see where you draw that conclusion, since
(a) PREPARE statements of that form are not in the standard, and
(b) DECLARE CURSOR is clearly defined as taking a <query expression>.

It doesn't seem like an amazingly sensible thing to do, either.
DECLARE CURSOR affects the plan generated for its query (eg,
backwards-scrollability may be required), so it's not certain that
a previously PREPARE'd plan could be used.

You can achieve something approximating this at the protocol level,
since you can do partial fetches from a portal created by Bind'ing
the prepared statement.  That won't let you fetch backwards nor
persist the cursor past end of transaction, but maybe you don't
need those things.
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Michael Meskes
Дата:
Сообщение: Prepare/Declare
Следующее
От: Bernd Helmle
Дата:
Сообщение: Reviewing temp_tablespaces GUC patch