postgresql/src/backend
Tom Lane 1015162c35 Fix handling of extended expression statistics in CREATE TABLE LIKE.
transformTableLikeClause believed that it could process extended
statistics immediately because "the representation of CreateStatsStmt
doesn't depend on column numbers".  That was true when extended stats
were first introduced, but it was falsified by the addition of
extended stats on expressions: the parsed expression tree is fed
forward by the LIKE option, and that will contain Vars.  So if the
new table doesn't have attnums identical to the old one's (typically
because there are some dropped columns in the old one), that doesn't
work.  The CREATE goes through, but it emits invalid statistics
objects that will cause problems later.

Fortunately, we already have logic that can adapt expression trees
to the possibly-new column numbering.  To use it, we have to delay
processing of CREATE_TABLE_LIKE_STATISTICS into expandTableLikeClause,
just as for other LIKE options that involve expressions.

Per bug #18468 from Alexander Lakhin.  Back-patch to v14 where
extended statistics on expressions were added.

Discussion: https://postgr.es/m/18468-f5add190e3fa5902@postgresql.org
2024-05-22 17:54:17 -04:00
..
access Update nbits_set in brin_bloom_union 2024-04-14 18:18:07 +02:00
bootstrap Rethink definition of pg_attribute.attcompression. 2021-05-27 13:24:27 -04:00
catalog Fix privilege checks in pg_stats_ext and pg_stats_ext_exprs. 2024-05-06 09:00:19 -05:00
commands Fix handling of polymorphic output arguments for procedures. 2024-05-14 20:19:20 -04:00
executor Ensure we allocate NAMEDATALEN bytes for names in Index Only Scans 2024-05-01 13:22:41 +12:00
foreign Update copyright for 2021 2021-01-02 13:06:25 -05:00
jit Fix illegal attribute propagation in LLVM JIT. 2024-04-10 12:15:07 +12:00
lib Fix lock assertions in dshash.c. 2022-07-11 15:47:12 +12:00
libpq Disconnect if socket cannot be put into non-blocking mode 2024-03-12 10:18:51 +02:00
main Fix outdated --help message for postgres -f 2022-08-15 13:37:38 +09:00
nodes Remove inappropriate raw_expression_tree_walker() code 2023-06-29 10:35:53 +02:00
optimizer Account for optimized MinMax aggregates during SS_finalize_plan. 2024-05-18 14:31:35 -04:00
parser Fix handling of extended expression statistics in CREATE TABLE LIKE. 2024-05-22 17:54:17 -04:00
partitioning Fix incorrect pruning of NULL partition for boolean IS NOT clauses 2024-02-20 12:50:57 +13:00
po Translation updates 2024-05-06 12:12:28 +02:00
port Close socket in case of errors in setting non-blocking 2024-01-17 11:24:11 +01:00
postmaster Avoid deadlock during orphan temp table removal. 2024-04-02 14:59:04 -04:00
regex Avoid character classification in regex escape parsing. 2023-04-21 08:20:32 -07:00
replication Revert "Skip .DS_Store files in server side utils" 2024-02-13 14:09:52 +01:00
rewrite Disallow converting a table to a view within an outer SQL command. 2024-04-30 15:22:55 -04:00
snowball In the Snowball dictionary, don't try to stem excessively-long words. 2022-08-31 10:42:05 -04:00
statistics Fix incorrectly reported stats kind in "can't happen" ERROR 2024-03-05 16:18:42 +13:00
storage Fix documentation about DROP DATABASE FORCE process termination rights. 2024-05-16 14:11:13 -07:00
tcop Be more rigorous about local variables in PostgresMain(). 2023-07-10 12:14:34 -04:00
tsearch Limit to_tsvector_byid's initial array allocation to something sane. 2023-09-25 11:50:28 -04:00
utils Detect more overflows in timestamp[tz]_pl_interval. 2024-04-28 13:42:13 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
Makefile Use sort_template.h for qsort_tuple() and qsort_ssup(). 2021-03-03 17:02:32 +13:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
nls.mk Translation updates 2021-09-20 16:23:13 +02:00