Re: DECLARE CURSOR must not contain data-modifying statements in WITH

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: DECLARE CURSOR must not contain data-modifying statements in WITH
Date: 2011-09-23 13:42:48
Message-ID: CA+TgmoZCOg3+LbWT5hwX4VMrrH0=u2NtfTJHZoMFrUw=9HJubg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Sep 21, 2011 at 12:19 PM, Andres Freund <andres(at)anarazel(dot)de> wrote:
>        /*
>         * We also disallow data-modifying WITH in a cursor.  (This could be
>         * allowed, but the semantics of when the updates occur might be
>         * surprising.)
>         */
>        if (result->hasModifyingCTE)
>                ereport(ERROR,
>                                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
>                                 errmsg("DECLARE CURSOR must not contain data-modifying
> statements in WITH")));
>
> Given that cursors are about the only sensible way to return larger amounts of
> data, that behaviour reduces the usefulness of wCTEs a bit.
>
> Whats the exact cause of concern here? I personally don't think there is a
> problem documenting that you should fetch the cursor fully before relying on
> the updated tables to be in a sensible state. But that may be just me.

Well, it looks like right now you can't even using a simple INSERT ..
RETURNING there:

rhaas=# create table wuzzle (a int);
CREATE TABLE
rhaas=# declare w cursor for insert into wuzzle select g from
generate_series(1, 10) g returning g;
ERROR: syntax error at or near "insert"
LINE 1: declare w cursor for insert into wuzzle select g from genera...
^

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Cédric Villemain 2011-09-23 13:47:15 Re: new createuser option for replication role
Previous Message Magnus Hagander 2011-09-23 13:39:46 Re: Re: [BUGS] BUG #6189: libpq: sslmode=require verifies server certificate if root.crt is present