bug: virtual generated column can be partition key

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: bug: virtual generated column can be partition key
Date: 2025-04-21 02:30:01
Message-ID: CACJufxF=WDGthXSAQr9thYUsfx_1_t9E6N8tE3B8EqXcVoVfQw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

hi.
While trying to make the virtual generated column be part of the partition key,
I found this bug.
it also influences the stored generated column, i added a test
on generated_stored.sql.

CREATE TABLE gtest_part_key (
f1 date NOT NULL, f2 bigint,
f3 bigint GENERATED ALWAYS AS (f2 * 2) VIRTUAL)
PARTITION BY RANGE (f3);

ERROR: cannot use generated column in partition key
LINE 4: PARTITION BY RANGE (f3);
^
DETAIL: Column "f3" is a generated column.

the following is essentially the same as above, it should also fail.

CREATE TABLE gtest_part_key (
f1 date NOT NULL, f2 bigint,
f3 bigint GENERATED ALWAYS AS (f2 * 2) VIRTUAL)
PARTITION BY RANGE ((f3));

Attachment Content-Type Size
v1-0001-virtual-generated-column-can-be-partition-key.patch text/x-patch 6.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Steve Chavez 2025-04-21 03:00:22 Re: Allow database owners to CREATE EVENT TRIGGER
Previous Message Alexander Korotkov 2025-04-21 01:54:08 Re: type cache cleanup improvements