BUG #18645: Change between 16 and 17 when attaching partitions and the root tbl has identity col

Started by PG Bug reporting formover 1 year ago1 messagesbugs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following bug has been logged on the website:

Bug reference: 18645
Logged by: nick j
Email address: nick@innsenroute.com
PostgreSQL version: 17.0
Operating system: win11
Description:

In v16, the following succeeded:

CREATE TABLE IF NOT EXISTS public.foo
(
device_key uuid NOT NULL,
message_created_date_time timestamp with time zone NOT NULL DEFAULT
CURRENT_TIMESTAMP,
message_id bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1
START 1 MINVALUE 1 MAXVALUE 9223372036854775807 CACHE 1 )
) PARTITION BY LIST (device_key);

create table foo_1 (like foo including all);
alter table foo attach partition foo_1 for values in
('A1BBF163-6375-4C3D-8846-CDFABCBA7580');

create table foo_2 (like foo including all);
alter table foo attach partition foo_2 for values in
('B1BBF163-6375-4C3D-8846-CDFABCBA7580');

In v17, this throws the following exception:

ERROR: The new partition may not contain an identity column.table "foo_1"
being attached contains an identity column "message_id"

Switching to: create table foo_2 (like foo including all excluding
identity); works.

This first surfaced when attempting to upgrade a v16 cluster to v17 via
pg_upgrade.