Re: bug: virtual generated column can be partition key

From: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: bug: virtual generated column can be partition key
Date: 2025-04-22 06:20:11
Message-ID: CAExHW5tBizivPO34Y3zv933jCruyWxtA_-cjm1TwPb2GMGJTGA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Apr 22, 2025 at 11:19 AM jian he <jian(dot)universality(at)gmail(dot)com>
wrote:

> On Tue, Apr 22, 2025 at 11:45 AM Ashutosh Bapat
> <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com> wrote:
> >
> >
> > While looking at this I realised that a generated column may end up
> being part of the partition key if the partition key expression contains a
> whole row reference. Attached patch also has a fix and a testcase for the
> same. PARTITION BY RANGE ((gtest_part_key is not null)) expression in the
> test is kinda silly, but it tests the whole-row reference as part of an
> expression. I haven't looked for more sensible expressions.
> >
>
> I begin to wonder if wholerow reference should be allowed.
> then error occurred:
>
> drop table if exists t4;
> CREATE TABLE t4(f1 int, f2 bigint) PARTITION BY list ((t4));
> create table t4_1 partition of t4 for values in ((1,2));
> alter table t4 alter column f2 set data type text using f2;
>
> insert into t4 select 1, '2';
> ERROR: invalid memory alloc request size 18446744073709551615
>

I can reproduce this error without my patc. It seems to be a different
existing bug.

--
Best Wishes,
Ashutosh Bapat

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2025-04-22 06:22:51 Re: Recent pg_rewind test failures in buildfarm
Previous Message vignesh C 2025-04-22 06:10:02 Re: Logical Replication of sequences