Bug in CREATE TABLE .. LIKE .. INCLUDING STATISTICS?

From: Julien Tachoires <julien(at)tachoires(dot)me>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Bug in CREATE TABLE .. LIKE .. INCLUDING STATISTICS?
Date: 2026-04-15 10:57:18
Message-ID: 20260415105718.tomuncfbmlt67oel@poseidon.home.virt
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

One of our customer is experiencing an issue when executing CREATE TABLE
.. LIKE .. INCLUDING ALL; on 14, the following kind of error happens:
ERROR: cache lookup failed for attribute X of relation ZZZZZZ

It seems to come from generateClonedExtStatsStmt(): get_attname()
appears to be called with an attribute number (attnum) that does not
exist.

Please find attached 2 patches for the master branch, the first one adds
a test that triggers the problem, the 2nd one is an attempt to fix it.

Best regards,

--
Julien Tachoires

Attachment Content-Type Size
v1-0001-Add-test-for-CTL-.-INCLUDING-STATS.patch text/x-diff 3.4 KB
v1-0002-Fix-attnum-remapping-in-generateClonedExtStatsStmt.patch text/x-diff 1.5 KB

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2026-04-15 11:17:11 BUG #19456: # Unit-Labeling Issue: `pg_size_pretty()` Incorrectly Labels Binary Units as Decimal Units
Previous Message Andrei Lepikhov 2026-04-15 08:20:54 MergeJoin fails on incomplete btree opfamily definition