Re: cursors with prepared statements

From: Bryn Llewellyn <bryn(at)yugabyte(dot)com>
To: pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Subject: Re: cursors with prepared statements
Date: 2023-04-15 21:15:41
Message-ID: 42DB8C32-AC45-4735-8A47-4D7D4DB93E2E@yugabyte.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I found this email from Peter Eisentraut:
https://www.postgresql.org/message-id/762cc764-74f0-13fb-77ed-16f91c90f40d%402ndquadrant.com

> I have developed a patch that allows declaring cursors over prepared statements... This is an SQL standard feature. ECPG already supports it (with different internals). Internally, this just connects existing functionality in different ways, so it doesn't really introduce anything new.

I tried this in Version 15.2 (avoiding the question of how to bind actual arguments to placeholders):

prepare series as select s.v from generate_series(1, 10) as s(v);
start transaction;
declare cur scroll cursor for execute series;

It caused the 42601 error, « syntax error at or near “execute” ». So it looks like Peter’s patch hasn’t yet been adopted. What is the likelihood that it will be adopted in a future version?

p.s. The section doc "PL/pgSQL under the Hood” explains that expressions and static SQL statements in a PL/pgSQL source text are effectively prepared when first encountered at run time in a session. But simple tests show that there’s no evidence if this in the “pg_prepared_statements” catalog view. Is it possible that the subquery that is used to declare a cursor (using ordinary top level SQL or the PL/pgSQL API) is also invisibly prepared under the hood?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2023-04-15 21:40:56 Re: cursors with prepared statements
Previous Message shaurya jain 2023-04-15 21:10:57 Logical replication failed with SSL SYSCALL error