public inbox for [email protected]
help / color / mirror / Atom feedRe: Bug in CREATE TABLE .. LIKE .. INCLUDING STATISTICS?
2+ messages / 2 participants
[nested] [flat]
* Re: Bug in CREATE TABLE .. LIKE .. INCLUDING STATISTICS?
@ 2026-04-16 07:44 Srinath Reddy Sadipiralla <[email protected]>
2026-04-22 11:58 ` Re: Bug in CREATE TABLE .. LIKE .. INCLUDING STATISTICS? Ayush Tiwari <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Srinath Reddy Sadipiralla @ 2026-04-16 07:44 UTC (permalink / raw)
To: Julien Tachoires <[email protected]>; [email protected]; +Cc: [email protected]
Hi Julien,
On Wed, Apr 15, 2026 at 7:47 PM Julien Tachoires <[email protected]>
wrote:
> 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.
>
yeah, i was able to reproduce and also check the flow which is the same
as you mentioned.
>
> 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.
>
I think it's better to write a 4 column test, with this it covers both
cases of lookup either returning the wrong column name or errors
out when the attnum does not exist in the child, thoughts?
something like this ....
CREATE TABLE parent_like_stats (a int, b int, c int, d int);
ALTER TABLE parent_like_stats DROP COLUMN b;
CREATE STATISTICS s_parent ON a, c FROM parent_like_stats;
CREATE TABLE child_like_stats (LIKE parent_like_stats INCLUDING STATISTICS);
other than this patches LGTM.
--
Thanks,
Srinath Reddy Sadipiralla
EDB: https://www.enterprisedb.com/
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Bug in CREATE TABLE .. LIKE .. INCLUDING STATISTICS?
2026-04-16 07:44 Re: Bug in CREATE TABLE .. LIKE .. INCLUDING STATISTICS? Srinath Reddy Sadipiralla <[email protected]>
@ 2026-04-22 11:58 ` Ayush Tiwari <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Ayush Tiwari @ 2026-04-22 11:58 UTC (permalink / raw)
To: Srinath Reddy Sadipiralla <[email protected]>; +Cc: Julien Tachoires <[email protected]>; [email protected]; [email protected]
Hi,
On Thu, 16 Apr 2026 at 13:14, Srinath Reddy Sadipiralla <
[email protected]> wrote:
> Hi Julien,
>
> On Wed, Apr 15, 2026 at 7:47 PM Julien Tachoires <[email protected]>
> wrote:
>
>> 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.
>>
>
> yeah, i was able to reproduce and also check the flow which is the same
> as you mentioned.
>
I looked into this and the issue is in generateClonedExtStatsStmt().
It passes the child's relation OID
to get_attname() with attribute numbers from the parent's stxkeys.
With dropped columns the attnums don't match.
Julien's patch fixes that, it likely needs to be backported too.
Regards,
Ayush
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2026-04-22 11:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-04-16 07:44 Re: Bug in CREATE TABLE .. LIKE .. INCLUDING STATISTICS? Srinath Reddy Sadipiralla <[email protected]>
2026-04-22 11:58 ` Ayush Tiwari <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox