From 791c0396740cbfede55bf496b30d6e7a28cd9bed Mon Sep 17 00:00:00 2001 From: roman khapov Date: Sat, 31 Oct 2026 14:49:51 +0500 Subject: [PATCH] pgbench: honor --unlogged-tables for non-partitioned tables with --partitions Since e2bab2d7920 prevented unlogged partitioned parents from being created, the UNLOGGED tweak was silently disabled for all tables when --partitions was used, including the plain tables pgbench_branches, pgbench_tellers and pgbench_history. Keep the exception for pgbench_accounts, which cannot be unlogged as a partitioned parent. pgbench_branches is another required exception: with --foreign-keys the permanent accounts parent references it, and constraints on permanent tables may reference only permanent tables. All the other foreign keys are fine, as constraints on unlogged tables may reference permanent and unlogged tables alike, so pgbench_tellers and pgbench_history are still created unlogged. Co-authored-by: Kirill Reshke --- src/bin/pgbench/pgbench.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index 06c43fd6942..cedb93b3041 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -4963,7 +4963,10 @@ initCreateTables(PGconn *con) /* Construct new create table statement. */ printfPQExpBuffer(&query, "create%s table %s(%s)", - (unlogged_tables && partition_method == PART_NONE) ? " unlogged" : "", + (unlogged_tables && + (partition_method == PART_NONE || + (strcmp(ddl->table, "pgbench_accounts") != 0 && + strcmp(ddl->table, "pgbench_branches") != 0))) ? " unlogged" : "", ddl->table, (scale >= SCALE_32BIT_THRESHOLD) ? ddl->bigcols : ddl->smcols); -- 2.50.1 (Apple Git-155)