postgresql/src/backend
Tom Lane dc7521dcb9 Fix planner's handling of RETURNING lists in writable CTEs.
setrefs.c failed to do "rtoffset" adjustment of Vars in RETURNING lists,
which meant they were left with the wrong varnos when the RETURNING list
was in a subquery.  That was never possible before writable CTEs, of
course, but now it's broken.  The executor fails to notice any problem
because ExecEvalVar just references the ecxt_scantuple for any normal
varno; but EXPLAIN breaks when the varno is wrong, as illustrated in a
recent complaint from Bartosz Dmytrak.

Since the eventual rtoffset of the subquery is not known at the time
we are preparing its plan node, the previous scheme of executing
set_returning_clause_references() at that time cannot handle this
adjustment.  Fortunately, it turns out that we don't really need to do it
that way, because all the needed information is available during normal
setrefs.c execution; we just have to dig it out of the ModifyTable node.
So, do that, and get rid of the kluge of early setrefs processing of
RETURNING lists.  (This is a little bit of a cheat in the case of inherited
UPDATE/DELETE, because we are not passing a "root" struct that corresponds
exactly to what the subplan was built with.  But that doesn't matter, and
anyway this is less ugly than early setrefs processing was.)

Back-patch to 9.1, where the problem became possible to hit.
2012-04-25 20:20:43 -04:00
..
access Don't wait for the commit record to be replicated if we wrote no WAL. 2012-04-17 16:36:59 +03:00
bootstrap Capitalization fixes 2011-06-19 00:39:19 +03:00
catalog Ignore missing schemas during non-interactive assignment of search_path. 2012-04-11 12:03:05 -04:00
commands Fix COPY FROM for null marker strings that correspond to invalid encoding. 2012-03-25 23:17:27 -04:00
executor Don't allow CREATE TABLE AS to put relations in pg_global. 2012-03-21 12:39:48 -04:00
foreign deflist_to_tuplestore dumped core on an option with no value. 2011-09-13 11:36:53 -04:00
lib Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
libpq Remove arbitrary limitation on length of common name in SSL certificates. 2012-02-23 15:48:09 -05:00
main Pgindent run before 9.1 beta2. 2011-06-09 14:32:50 -04:00
nodes Fix copyfuncs/equalfuncs support for ReassignOwnedStmt. 2012-04-18 10:46:26 -04:00
optimizer Fix planner's handling of RETURNING lists in writable CTEs. 2012-04-25 20:20:43 -04:00
parser Fix coerce_to_target_type for coerce_type's klugy handling of COLLATE. 2012-01-02 14:43:51 -05:00
po Translation updates 2012-02-23 20:40:55 +02:00
port Back-patch assorted latch-related fixes. 2011-08-10 12:20:45 -04:00
postmaster Do stack-depth checking in all postmaster children. 2012-04-08 19:08:13 +03:00
regex Fix regex back-references that are directly quantified with *. 2012-02-20 00:52:42 -05:00
replication Cast some printf arguments to avoid possibly-nonportable behavior. 2012-03-23 20:18:08 -04:00
rewrite Ensure that whole-row junk Vars are always of composite type. 2011-11-27 22:27:32 -05:00
snowball Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
storage Correctly detect SSI conflicts of prepared transactions after crash. 2012-02-29 15:43:43 +02:00
tcop set_stack_base() no longer needs to be called in PostgresMain. 2012-04-08 19:40:54 +03:00
tsearch Pgindent run before 9.1 beta2. 2011-06-09 14:32:50 -04:00
utils Fix an Assert that turns out to be reachable after all. 2012-04-09 11:58:40 -04:00
.gitignore Add gitignore for mingw/cygwin build outputs 2011-06-09 18:11:47 +02:00
common.mk Workaround for recursive make breakage 2011-01-13 09:32:06 +02:00
Makefile Fix symlink for errcodes.h so it works in VPATH builds from tarballs. 2011-06-22 13:08:20 -04:00
nls.mk Translation updates 2012-02-23 20:40:55 +02:00