Re: pg_dump not properly dumping unlogged partitioned tables

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Steve Baldwin <steve(dot)baldwin(at)gmail(dot)com>
Cc: Quentin de Metz <quentin(at)de(dot)me(dot)tz>, pgsql-novice(at)lists(dot)postgresql(dot)org
Subject: Re: pg_dump not properly dumping unlogged partitioned tables
Date: 2026-07-27 03:24:31
Message-ID: 3716528.1785122671@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Steve Baldwin <steve(dot)baldwin(at)gmail(dot)com> writes:
> Not sure what this means but the v18 docs say that unlogged is not
> supported for partitioned tables, so maybe this was true for v17 but not
> documented.

Yeah, if you try it on v18 or later:

regression=# CREATE UNLOGGED TABLE zde (id bigint) PARTITION BY RANGE(id);
ERROR: partitioned tables cannot be unlogged

v18 pg_dump is aware of this and deliberately suppresses the UNLOGGED
property, reasoning that that beats hitting this failure during
reload. See:

commit e2bab2d792044b55dd092bf1c2be0d570ccb9401
Author: Michael Paquier <michael(at)paquier(dot)xyz>
Date: Thu Oct 3 10:55:02 2024 +0900

Remove support for unlogged on partitioned tables

The following commands were allowed on partitioned tables, with
different effects:
1) ALTER TABLE SET [UN]LOGGED did not issue an error, and did not update
pg_class.relpersistence.
2) CREATE UNLOGGED TABLE was working with pg_class.relpersistence marked
as initially defined, but partitions did not inherit the UNLOGGED
property, which was confusing.

This commit causes the commands mentioned above to fail for partitioned
tables, instead.

pg_dump is tweaked so as partitioned tables marked as UNLOGGED ignore
the option when dumped from older server versions. pgbench needs a
tweak for --unlogged and --partitions=N to ignore the UNLOGGED option on
the partitioned tables created, its partitions still being unlogged.

Author: Michael Paquier
Reviewed-by: Nathan Bossart
Discussion: https://postgr.es/m/ZiiyGFTBNkqcMQi_@paquier.xyz

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Quentin de Metz 2026-07-27 06:26:54 Re: pg_dump not properly dumping unlogged partitioned tables
Previous Message Steve Baldwin 2026-07-26 20:53:12 Re: pg_dump not properly dumping unlogged partitioned tables