postgresql/src/include
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
..
access Revert back-branch changes in behavior of age(xid). 2012-05-31 11:12:33 -04:00
bootstrap Introduce Streaming Replication. 2010-01-15 09:19:10 +00:00
catalog Fix permissions on pg_largeobject_metadata.h in 9.0 branch. 2011-09-11 13:17:12 -04:00
commands Prevent CREATE TABLE LIKE/INHERITS from (mis) copying whole-row Vars. 2012-06-30 16:44:09 -04:00
executor Fix PlanRowMark/ExecRowMark structures to handle inheritance correctly. 2011-01-12 20:47:09 -05:00
foreign Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
lib Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
libpq Remove arbitrary limitation on length of common name in SSL certificates. 2012-02-23 15:48:14 -05:00
mb pgindent run for 9.0 2010-02-26 02:01:40 +00:00
nodes Fix memory leak in ARRAY(SELECT ...) subqueries. 2012-06-21 17:26:24 -04:00
optimizer Fix nested PlaceHolderVar expressions that appear only in targetlists. 2011-08-09 00:49:04 -04:00
parser Make OFF keyword unreserved. It's not hard to imagine wanting to use 'off' 2010-10-22 17:44:36 +03:00
port Backport changes to allow building with MinGW 64 bit compiler. 2011-04-09 17:59:27 -04:00
portability Support inlining various small performance-critical functions on non-GCC 2010-02-13 02:34:16 +00:00
postmaster pgindent run for 9.0 2010-02-26 02:01:40 +00:00
regex Teach the regular expression functions to do case-insensitive matching and 2009-12-01 21:00:24 +00:00
replication Remove prototype for non-existent function from walreceiver.h. Tidy up by 2010-09-13 10:14:30 +00:00
rewrite Prevent CREATE TABLE LIKE/INHERITS from (mis) copying whole-row Vars. 2012-06-30 16:44:09 -04:00
snowball Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
storage Resolve timing issue with logging locks for Hot Standby. 2012-02-01 09:33:16 +00:00
tcop pgindent run for 9.0 2010-02-26 02:01:40 +00:00
tsearch Update a number of broken links in comments. 2010-04-02 15:21:20 +00:00
utils Expand the allowed range of timezone offsets to +/-15:59:59 from Greenwich. 2012-05-30 19:58:47 -04:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:06 +02:00
c.h Backport changes to allow building with MinGW 64 bit compiler. 2011-04-09 17:59:27 -04:00
fmgr.h Mark PG_MODULE_MAGIC and PG_FUNCTION_INFO_V1 with PGDLLEXPORT 2010-05-27 07:59:48 +00:00
funcapi.h pgindent run for 9.0 2010-02-26 02:01:40 +00:00
getaddrinfo.h Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
getopt_long.h Remove optreset from src/port/ implementations of getopt and getopt_long. 2010-12-16 16:22:12 -05:00
Makefile Fix server header file installation with vpath builds 2011-11-10 20:55:39 +02:00
miscadmin.h Do stack-depth checking in all postmaster children. 2012-04-08 19:09:12 +03:00
pg_config.h.in Use __sync_lock_test_and_set() for spinlocks on ARM, if available. 2012-01-07 15:39:05 -05:00
pg_config.h.win32 Stamp 9.0.8. 2012-05-31 19:09:35 -04:00
pg_config_manual.h Remove all the special-case code for INT64_IS_BUSTED, per decision that 2010-01-07 04:53:35 +00:00
pg_trace.h Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
pgstat.h Fix VACUUM so that it always updates pg_class.reltuples/relpages. 2011-05-30 17:07:07 -04:00
pgtime.h Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
port.h Move the line to undefine setlocale() macro on Win32 outside USE_REPL_SNPRINTF 2011-09-01 09:18:27 +03:00
postgres.h Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
postgres_ext.h Move NAMEDATALEN definition from postgres_ext.h to pg_config_manual.h. It 2007-02-06 09:16:08 +00:00
postgres_fe.h Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
rusagestub.h Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
windowapi.h Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00