postgresql/src
Tom Lane afc7328457 Prevent CREATE TABLE LIKE/INHERITS from (mis) copying whole-row Vars.
If a CHECK constraint or index definition contained a whole-row Var (that
is, "table.*"), an attempt to copy that definition via CREATE TABLE LIKE or
table inheritance produced incorrect results: the copied Var still claimed
to have the rowtype of the source table, rather than the created table.

For the LIKE case, it seems reasonable to just throw error for this
situation, since the point of LIKE is that the new table is not permanently
coupled to the old, so there's no reason to assume its rowtype will stay
compatible.  In the inheritance case, we should ideally allow such
constraints, but doing so will require nontrivial refactoring of CREATE
TABLE processing (because we'd need to know the OID of the new table's
rowtype before we adjust inherited CHECK constraints).  In view of the lack
of previous complaints, that doesn't seem worth the risk in a back-patched
bug fix, so just make it throw error for the inheritance case as well.

Along the way, replace change_varattnos_of_a_node() with a more robust
function map_variable_attnos(), which is capable of being extended to
handle insertion of ConvertRowtypeExpr whenever we get around to fixing
the inheritance case nicely, and in the meantime it returns a failure
indication to the caller so that a helpful message with some context can be
thrown.  Also, this code will do the right thing with subselects (if we
ever allow them in CHECK or indexes), and it range-checks varattnos before
using them to index into the map array.

Per report from Sergey Konoplev.  Back-patch to all supported branches.
2012-06-30 16:44:09 -04:00
..
backend Prevent CREATE TABLE LIKE/INHERITS from (mis) copying whole-row Vars. 2012-06-30 16:44:09 -04:00
bin pg_dump: Fix verbosity level in LO progress messages 2012-06-19 17:24:10 -04:00
include Prevent CREATE TABLE LIKE/INHERITS from (mis) copying whole-row Vars. 2012-06-30 16:44:09 -04:00
interfaces Update copyright year in forgotten places 2012-06-19 21:35:35 +03:00
makefiles Fix assorted issues with build and install paths containing spaces. 2011-06-14 16:41:23 -04:00
pl Translation updates 2012-05-31 23:27:32 +03:00
port Stamp 9.0.8. 2012-05-31 19:09:35 -04:00
template Don't try to force use of -no-cpp-precomp on OS X. It's been five years 2010-08-02 04:51:25 +00:00
test Fix COPY FROM for null marker strings that correspond to invalid encoding. 2012-03-25 23:17:32 -04:00
timezone Update time zone data files to tzdata release 2012c. 2012-05-31 00:48:11 -04:00
tools Backpatch "Use the preferred version of xsubpp." 2011-11-28 07:54:03 -05:00
tutorial Remove copyright mention of Andrew Yu, per author's permission. 2010-02-02 18:52:02 +00:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:06 +02:00
bcc32.mak Remove old-style win32 client-only visual c++ build infrastructure for everything except 2007-03-05 14:18:38 +00:00
DEVELOPERS Replace a couple of references to files that no longer exist in the source 2009-05-04 08:08:47 +00:00
Makefile Rethink the way walreceiver is linked into the backend. Instead than shoving 2010-01-20 09:16:24 +00:00
Makefile.global.in Accept slightly grotty coding in Makefile.global in order to keep the -L 2010-07-06 22:03:05 +00:00
Makefile.shlib Fix assorted issues with build and install paths containing spaces. 2011-06-14 16:41:23 -04:00
nls-global.mk Avoid error from mkdir if no languages are to be installed 2010-05-13 14:35:28 +00:00
win32.mak Update supported standalone VC++ version to 7.1+ only, and fix 2007-08-03 10:47:11 +00:00