Re: cursors with prepared statements

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: cursors with prepared statements
Дата
Msg-id c8566a17-66fa-f95b-4e8d-cfad6fa12cbb@iki.fi
обсуждение исходный текст
Ответ на Re: cursors with prepared statements  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Ответы Re: cursors with prepared statements  (Dmitry Dolgov <9erthalion6@gmail.com>)
Список pgsql-hackers
On 16/07/18 15:56, Peter Eisentraut wrote:
> On 11.07.18 19:07, Heikki Linnakangas wrote:
>> It's confusing, and risks conflicting with future additions to
>> the standard. ECPG supports the actual standard syntax, with OPEN,
>> right? So this wouldn't be consistent with ECPG, either.
> 
> It would be consistent for the case of no parameters.

True. Except that if I understand correctly, in the standard syntax you 
still need to use OPEN after the DECLARE CURSOR, even when there are no 
parameters.

>>> Curiously, the direct EXECUTE statement uses the non-standard syntax
>>>
>>>       EXECUTE prep_stmt (param, param);
>>>
>>> instead of the standard
>>>
>>>       EXECUTE prep_stmt USING param, param;
>>>
>>> I tried to consolidate this.  But using
>>>
>>>       DECLARE c CURSOR FOR p (foo, bar)
>>>
>>> leads to parsing conflicts (and looks confusing?),
>>
>> How about
>>
>> DECLARE c CURSOR FOR EXECUTE p (foo, bar)
> 
> That's not the standard syntax for the case of no parameters.

My thinking here is that "DECLARE c CURSOR FOR <statement>" is standard 
syntax. And we already have "EXECUTE p (foo, bar)" as a form of 
statement, along with "SELECT ...", "EXPLAIN ..." and so forth. Allowing 
"DECLARE c CURSOR FOR EXECUTE p (foo, bar)" would not introduce a new 
syntax, it would just allow the existing two commands, DECLARE CURSOR, 
and EXECUTE, to be used together.

- Heikki


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

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: Incorrect error handling for two-phase state files resulting indata loss
Следующее
От: Amit Langote
Дата:
Сообщение: Re: Speeding up INSERTs and UPDATEs to partitioned tables