Re: [GENERAL] DECLARE CURSOR

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, Marc Fournier <scrappy(at)hub(dot)org>
Cc: snpe <snpe(at)snpe(dot)co(dot)yu>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [GENERAL] DECLARE CURSOR
Date: 2002-11-17 23:58:02
Message-ID: 10127.1037577482@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> Let's just fix it and roll an RC2 with the fix. If not, we can just fix
> it in 7.3.1 but I see little problem in rolling an RC2.

Since Marc hasn't yet announced RC1, I think we could get away with just
a quick fix and re-roll of RC1 ...

regards, tom lane

> ---------------------------------------------------------------------------

> Tom Lane wrote:
>> snpe <snpe(at)snpe(dot)co(dot)yu> writes:
> When I call DECLARE CURSOR out of transaction command success,
> but cursor is not created
> Reference manual say that this get error :
> ERROR: DECLARE CURSOR may only be used in begin/end transaction blocks
>>
>> Oops. I removed that test on 21-Oct as part of this fix:
>>
>> 2002-10-21 18:06 tgl
>>
>> * src/: backend/access/transam/xact.c, backend/catalog/heap.c,
>> backend/catalog/index.c, backend/commands/dbcommands.c,
>> backend/commands/indexcmds.c, backend/commands/tablecmds.c,
>> backend/commands/vacuum.c, backend/parser/analyze.c,
>> include/access/xact.h: Fix places that were using
>> IsTransactionBlock() as an (inadequate) check that they'd get to
>> commit immediately on finishing. There's now a centralized routine
>> PreventTransactionChain() that implements the necessary tests.
>>
>> My reasons for removing it were (a) it was in the wrong place (analyze.c
>> is not the right place to test execution-time constraints), and (b) it
>> was the wrong test: the test as written was just IsTransactionBlock(),
>> which is wrong in the case of autocommit-off, since a DECLARE CURSOR
>> will start a new transaction perfectly well. Another objection is that
>> inside a function call, it ought to be legal to do DECLARE CURSOR even
>> if we're not in a transaction block, since the function might intend to
>> use the cursor itself before returning.
>>
>> I think I had intended to put together an alternative test that only
>> complained about interactive DECLARE CURSOR and understood about
>> autocommit, but I forgot.
>>
>> At this point we can either add the fixed-up error check (meaning RC1
>> won't be the release after all), or change the documentation.
>>
>> Comments?
>>
>> regards, tom lane
>>
>> ---------------------------(end of broadcast)---------------------------
>> TIP 2: you can get off all lists at once with the unregister command
>> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>>

> --
> Bruce Momjian | http://candle.pha.pa.us
> pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
> + If your life is a hard drive, | 13 Roberts Road
> + Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-11-18 00:30:31 Re: [GENERAL] DECLARE CURSOR
Previous Message Bruce Momjian 2002-11-17 23:44:58 Re: [GENERAL] DECLARE CURSOR

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2002-11-18 00:30:31 Re: [GENERAL] DECLARE CURSOR
Previous Message Bruce Momjian 2002-11-17 23:44:58 Re: [GENERAL] DECLARE CURSOR