postgresql/src/include
Tom Lane 5028981923 Fix handling of CREATE TABLE LIKE with inheritance.
If a CREATE TABLE command uses both LIKE and traditional inheritance,
Vars in CHECK constraints and expression indexes that are absorbed
from a LIKE parent table tended to get mis-numbered, resulting in
wrong answers and/or bizarre error messages (though probably not any
actual crashes, thanks to validation occurring in the executor).

In v12 and up, the same could happen to Vars in GENERATED expressions,
even in cases with no LIKE clause but multiple traditional-inheritance
parents.

The cause of the problem for LIKE is that parse_utilcmd.c supposed
it could renumber such Vars correctly during transformCreateStmt(),
which it cannot since we have not yet accounted for columns added via
inheritance.  Fix that by postponing processing of LIKE INCLUDING
CONSTRAINTS, DEFAULTS, GENERATED, INDEXES till after we've performed
DefineRelation().

The error with GENERATED and multiple inheritance is a simple oversight
in MergeAttributes(); it knows it has to renumber Vars in inherited
CHECK constraints, but forgot to apply the same processing to inherited
GENERATED expressions (a/k/a defaults).

Per bug #16272 from Tom Gottfried.  The non-GENERATED variants of the
issue are ancient, presumably dating right back to the addition of
CREATE TABLE LIKE; hence back-patch to all supported branches.

Discussion: https://postgr.es/m/16272-6e32da020e9a9381@postgresql.org
2020-08-21 15:00:47 -04:00
..
access snapshot scalability: cache snapshots using a xact completion counter. 2020-08-17 21:08:30 -07:00
bootstrap
catalog Add pg_backend_memory_contexts system view. 2020-08-19 15:34:43 +09:00
commands Unify drop-by-OID functions 2020-06-09 09:39:46 +02:00
common Move connect.h from fe_utils to src/include/common. 2020-08-10 09:22:54 -07:00
datatype
executor Fix comment in instrument.h 2020-07-31 14:17:29 +09:00
fe_utils Move connect.h from fe_utils to src/include/common. 2020-08-10 09:22:54 -07:00
foreign
jit Fix a few typos in JIT comments and README 2020-08-21 09:33:56 +12:00
lib Correct comment in simplehash.h. 2020-08-03 12:23:05 +12:00
libpq Fix postmaster's behavior during smart shutdown. 2020-08-14 13:26:57 -04:00
mb Allow Unicode escapes in any server encoding, not only UTF-8. 2020-03-06 14:17:43 -05:00
nodes Fix handling of CREATE TABLE LIKE with inheritance. 2020-08-21 15:00:47 -04:00
optimizer Be more careful about the shape of hashable subplan clauses. 2020-08-14 22:14:03 -04:00
parser Fix handling of CREATE TABLE LIKE with inheritance. 2020-08-21 15:00:47 -04:00
partitioning Fix some header identifications 2020-07-14 13:39:45 +09:00
port Remove obsolete cygwin.h hack 2020-08-15 11:27:41 +02:00
portability
postmaster Trigger autovacuum based on number of INSERTs 2020-03-28 19:20:12 +13:00
regex Assume that we have <wchar.h>. 2020-02-21 14:30:47 -05:00
replication Add some const decorations 2020-08-08 07:31:52 +02:00
rewrite
snowball Update snowball 2020-06-08 08:07:15 +02:00
statistics Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
storage Prevent concurrent SimpleLruTruncate() for any given SLRU. 2020-08-15 10:15:53 -07:00
tcop code: replace 'master' with 'primary' where appropriate. 2020-07-08 12:57:23 -07:00
tsearch Replace TS_execute's TS_EXEC_CALC_NOT flag with TS_EXEC_SKIP_NOT. 2020-07-24 15:43:56 -04:00
utils snapshot scalability: cache snapshots using a xact completion counter. 2020-08-17 21:08:30 -07:00
.gitignore
c.h Replace remaining StrNCpy() by strlcpy() 2020-08-10 23:20:37 +02:00
fmgr.h Fix -Wcast-function-type warnings 2020-07-14 19:55:25 +02:00
funcapi.h Avoid holding a directory FD open across assorted SRF calls. 2020-03-16 21:05:52 -04:00
getaddrinfo.h
getopt_long.h
Makefile
miscadmin.h Add hash_mem_multiplier GUC. 2020-07-29 14:14:58 -07:00
pg_config_ext.h.in
pg_config_manual.h Add nbtree Valgrind buffer lock checks. 2020-07-21 15:50:58 -07:00
pg_config.h.in Rename configure.in to configure.ac 2020-07-24 10:42:08 +02:00
pg_getopt.h
pg_trace.h
pgstat.h Improve server code to read files as part of a base backup. 2020-06-17 11:39:17 -04:00
pgtar.h Assorted cleanup of tar-related code. 2020-06-15 15:28:49 -04:00
pgtime.h
port.h Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
postgres_ext.h
postgres_fe.h
postgres.h
rusagestub.h
windowapi.h