From af17e338bb4dfbf2ecd6406c0cf240a10f4b1fc1 Mon Sep 17 00:00:00 2001 From: Zsolt Parragi Date: Wed, 18 Nov 2026 17:19:04 +0000 Subject: [PATCH v1 1/3] Quote tablespace options in pg_dumpall pg_dumpall emitted spcoptions with array_to_string(), so names and values went into ALTER TABLESPACE ... SET (...) verbatim. That works for the built-in tablespace options, which are all numeric, but a string value containing a comma, parenthesis or quote produces a broken or different command on restore. Format the array with appendReloptionsArray() instead, as pg_dump does for relation options. --- src/bin/pg_dump/pg_dumpall.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index c53e77c2878..b6c8e0e746b 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -1369,7 +1369,7 @@ dumpTablespaces(PGconn *conn) "pg_catalog.pg_get_userbyid(spcowner) AS spcowner, " "pg_catalog.pg_tablespace_location(oid), " "spcacl, acldefault('t', spcowner) AS acldefault, " - "array_to_string(spcoptions, ', ')," + "spcoptions, " "pg_catalog.shobj_description(oid, 'pg_tablespace') " "FROM pg_catalog.pg_tablespace " "WHERE spcname !~ '^pg_' " @@ -1417,8 +1417,13 @@ dumpTablespaces(PGconn *conn) appendPQExpBufferStr(buf, ";\n"); if (spcoptions && spcoptions[0] != '\0') - appendPQExpBuffer(buf, "ALTER TABLESPACE %s SET (%s);\n", - fspcname, spcoptions); + { + appendPQExpBuffer(buf, "ALTER TABLESPACE %s SET (", fspcname); + if (!appendReloptionsArray(buf, spcoptions, "", + PQclientEncoding(conn), true)) + pg_fatal("could not parse reloptions array"); + appendPQExpBufferStr(buf, ");\n"); + } /* tablespaces can't have initprivs */ -- 2.56.0