Re: CREATE TEMP TABLE AS SELECT/ GET DIAGNOSTICS ROW_COUNT

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: MLikharev(at)micropat(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: CREATE TEMP TABLE AS SELECT/ GET DIAGNOSTICS ROW_COUNT
Date: 2005-05-31 05:03:30
Message-ID: 8213.1117515810@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> I found a discussion of this issue from December, 2004:
> http://archives.postgresql.org/pgsql-general/2004-12/msg00070.php

That was the same complainant ;-)

I dug through the CVS history and determined that the behavior changed
at spi.c rev 1.87:

2003-03-09 22:53 tgl

* Restructure parsetree representation of
DECLARE CURSOR: now it's a utility statement (DeclareCursorStmt)
with a SELECT query dangling from it, rather than a SELECT query
with a few unusual fields in it. Add code to determine whether a
planned query can safely be run backwards. If DECLARE CURSOR
specifies SCROLL, ensure that the plan can be run backwards by
adding a Materialize plan node if it can't. Without SCROLL, you
get an error if you try to fetch backwards from a cursor that can't
handle it. (There is still some discussion about what the exact
behavior should be, but this is necessary infrastructure in any
case.) Along the way, make EXPLAIN DECLARE CURSOR work.

Looking at the code change, it may have just been a sloppy removal of a
local variable, ie checking queryDesc->dest rather than a previously
saved copy of same. The log message certainly doesn't suggest that I
intended to change the behavior of CREATE TABLE AS.

So the initial evidence is that this was not an intentional change.
Do we want to revert it? The behavior has been in the field now for
more than a full release cycle --- all 7.4.* releases behave this way
--- so one could argue that we should leave it be.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Brown 2005-05-31 06:31:17 Accessing PostgreSQL from C++
Previous Message Ian Harding 2005-05-31 04:30:07 Re: Carriage return in text fields