aboutsummaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2024-10-03 10:55:02 +0900
committerMichael Paquier <michael@paquier.xyz>2024-10-03 10:55:02 +0900
commite2bab2d792044b55dd092bf1c2be0d570ccb9401 (patch)
tree70897e26c0eb4149b32ece395e6ec86e28b38504 /src/bin
parent554d3a18f36264eeb1333655b8ddcd929befa6ec (diff)
downloadpostgresql-e2bab2d792044b55dd092bf1c2be0d570ccb9401.tar.gz
postgresql-e2bab2d792044b55dd092bf1c2be0d570ccb9401.zip
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
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/pg_dump/pg_dump.c7
-rw-r--r--src/bin/pgbench/pgbench.c2
2 files changed, 7 insertions, 2 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 4dfb7d1abe4..1b47c388ced 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -15915,8 +15915,13 @@ dumpTableSchema(Archive *fout, const TableInfo *tbinfo)
binary_upgrade_set_pg_class_oids(fout, q,
tbinfo->dobj.catId.oid);
+ /*
+ * PostgreSQL 18 has disabled UNLOGGED for partitioned tables, so
+ * ignore it when dumping if it was set in this case.
+ */
appendPQExpBuffer(q, "CREATE %s%s %s",
- tbinfo->relpersistence == RELPERSISTENCE_UNLOGGED ?
+ (tbinfo->relpersistence == RELPERSISTENCE_UNLOGGED &&
+ tbinfo->relkind != RELKIND_PARTITIONED_TABLE) ?
"UNLOGGED " : "",
reltypename,
qualrelname);
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index 61618f2e188..e658d060add 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -4865,7 +4865,7 @@ initCreateTables(PGconn *con)
/* Construct new create table statement. */
printfPQExpBuffer(&query, "create%s table %s(%s)",
- unlogged_tables ? " unlogged" : "",
+ (unlogged_tables && partition_method == PART_NONE) ? " unlogged" : "",
ddl->table,
(scale >= SCALE_32BIT_THRESHOLD) ? ddl->bigcols : ddl->smcols);