BUG #19013: When creating a table with the "...LIKE...INCLUDING ALL" construct, REPLICA IDENTITY output is wrong

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: dbman(at)sqlexec(dot)com
Subject: BUG #19013: When creating a table with the "...LIKE...INCLUDING ALL" construct, REPLICA IDENTITY output is wrong
Date: 2025-08-05 21:26:56
Message-ID: 19013-04a5827d56b97202@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 19013
Logged by: Michael Vitale
Email address: dbman(at)sqlexec(dot)com
PostgreSQL version: 17.5
Operating system: CentOS 8 Streams
Description:

Here is a simple schema to test with:
DROP SCHEMA IF EXISTS testing CASCADE;
CREATE SCHEMA testing;
CREATE TABLE testing.notifications
(
id uuid NOT NULL DEFAULT uuid_generate_v4(),
employee_id uuid NOT NULL,
seen_at timestamp with time zone,
created_at timestamp with time zone DEFAULT now(),
last_changed timestamp with time zone NOT NULL DEFAULT now(),
file_id uuid NOT NULL,
conversation_id uuid,
document_id uuid,
message_id uuid,
CONSTRAINT notifications_pkey PRIMARY KEY (id)
) TABLESPACE pg_default;
ALTER TABLE ONLY testing.notifications REPLICA IDENTITY FULL;
ALTER TABLE IF EXISTS testing.notifications OWNER to postgres;

-- Validate table is defined with REPLICA IDENTITY FULL
SELECT n.nspname AS schema_name, c.oid, c.relname AS table_name,
c.relreplident, i.indisreplident, idx_c.relname AS
replica_identity_index_name,
CASE c.relreplident WHEN 'd' THEN 'DEFAULT' WHEN 'n' THEN 'NOTHING' WHEN 'f'
THEN 'FULL' WHEN 'i' THEN 'INDEX' END AS replica_identity_setting
FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace LEFT JOIN
pg_index i ON i.indrelid = c.oid AND i.indisreplident = TRUE LEFT JOIN
pg_class idx_c ON idx_c.oid = i.indexrelid
WHERE n.nspname = 'testing' AND c.relkind = 'r';
schema_name | oid | table_name | relreplident | indisreplident |
replica_identity_index_name | replica_identity_setting
-------------+-------+---------------+--------------+----------------+-----------------------------+--------------------------
testing | 58431 | notifications | f | |
| FULL

-- Create another table using the LIKE construct
CREATE TABLE testing.notifications2 (LIKE testing.notifications INCLUDING
ALL);

-- Run the query again:
SELECT n.nspname AS schema_name, c.oid, c.relname AS table_name,
c.relreplident, i.indisreplident, idx_c.relname AS
replica_identity_index_name,
CASE c.relreplident WHEN 'd' THEN 'DEFAULT' WHEN 'n' THEN 'NOTHING' WHEN 'f'
THEN 'FULL' WHEN 'i' THEN 'INDEX' END AS replica_identity_setting
FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace LEFT JOIN
pg_index i ON i.indrelid = c.oid AND i.indisreplident = TRUE LEFT JOIN
pg_class idx_c ON idx_c.oid = i.indexrelid
WHERE n.nspname = 'testing' AND c.relkind = 'r';
schema_name | oid | table_name | relreplident | indisreplident |
replica_identity_index_name | replica_identity_setting
-------------+-------+----------------+--------------+----------------+-----------------------------+--------------------------
testing | 58431 | notifications | f | |
| FULL
testing | 58439 | notifications2 | d | |
| DEFAULT
(2 rows)

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2025-08-05 23:01:18 Re: BUG #19013: When creating a table with the "...LIKE...INCLUDING ALL" construct, REPLICA IDENTITY output is wrong
Previous Message Masahiko Sawada 2025-08-05 18:00:54 TRAP: failed Assert("outerPlan != NULL") in postgres_fdw.c