Re: Prepared statements and cursors

Поиск
Список
Период
Сортировка
От Andreas Lubensky
Тема Re: Prepared statements and cursors
Дата
Msg-id 1390917216.26141.15.camel@aries.cognitec-systems.de
обсуждение исходный текст
Ответ на Re: Prepared statements and cursors  (Merlin Moncure <mmoncure@gmail.com>)
Ответы Re: Prepared statements and cursors
Список pgsql-general
That is an interesting approach. However, I see the problem that the
functions would have to be removed when no longer needed. If that fails
(broken connection etc.), they would be orphaned.
Prepared statements are bound to the connection, so when the connection
is closed they are gone.

On Thu, 2014-01-23 at 15:07 -0600, Merlin Moncure wrote:
> On Thu, Jan 23, 2014 at 8:31 AM, Andreas Lubensky <lubensky@cognitec.com> wrote:
> > Hello,
> > When implementing a database backend with libpq I realized that it seems
> > to be impossible to declare a cursor on a prepared statement. Is this
> > correct? What is the reason for this limitation?
>
> I can't think of any but it can be trivially worked around:
> create or replace function f() returns void as $$ declare v cursor for
> select 0; $$ language sql;
> prepare p as select f();
> postgres=# begin;
> BEGIN
> postgres=# execute p;
>  f
> ---
>
> (1 row)
>
> postgres=# fetch all from v;
>  ?column?
> ----------
>         0
>
> merlin
>

--
with best regards,

Andreas Lubensky

Software Engineer



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

Предыдущее
От: John R Pierce
Дата:
Сообщение: Re: Fully-automatic streaming replication failover when master dies?
Следующее
От: Merlin Moncure
Дата:
Сообщение: Re: Prepared statements and cursors