Skip to content

Commit 2af3336

Browse files
committed
Remove extra space from dumped ALTER DEFAULT PRIVILEGES.
Author: Nathan Bossart Discussion: https://postgr.es/m/20221206232744.GA3560301@nathanxps13
1 parent 45f5c81 commit 2af3336

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/bin/pg_dump/dumputils.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ buildACLCommands(const char *name, const char *subname, const char *nspname,
184184
prefix, privs->data, type);
185185
if (nspname && *nspname)
186186
appendPQExpBuffer(firstsql, "%s.", fmtId(nspname));
187-
appendPQExpBuffer(firstsql, "%s FROM ", name);
187+
if (name && *name)
188+
appendPQExpBuffer(firstsql, "%s ", name);
189+
appendPQExpBufferStr(firstsql, "FROM ");
188190
if (grantee->len == 0)
189191
appendPQExpBufferStr(firstsql, "PUBLIC;\n");
190192
else
@@ -253,7 +255,9 @@ buildACLCommands(const char *name, const char *subname, const char *nspname,
253255
prefix, privs->data, type);
254256
if (nspname && *nspname)
255257
appendPQExpBuffer(thissql, "%s.", fmtId(nspname));
256-
appendPQExpBuffer(thissql, "%s TO ", name);
258+
if (name && *name)
259+
appendPQExpBuffer(thissql, "%s ", name);
260+
appendPQExpBufferStr(thissql, "TO ");
257261
if (grantee->len == 0)
258262
appendPQExpBufferStr(thissql, "PUBLIC;\n");
259263
else
@@ -265,7 +269,9 @@ buildACLCommands(const char *name, const char *subname, const char *nspname,
265269
prefix, privswgo->data, type);
266270
if (nspname && *nspname)
267271
appendPQExpBuffer(thissql, "%s.", fmtId(nspname));
268-
appendPQExpBuffer(thissql, "%s TO ", name);
272+
if (name && *name)
273+
appendPQExpBuffer(thissql, "%s ", name);
274+
appendPQExpBufferStr(thissql, "TO ");
269275
if (grantee->len == 0)
270276
appendPQExpBufferStr(thissql, "PUBLIC");
271277
else

src/bin/pg_dump/t/002_pg_dump.pl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@
563563
regexp => qr/^
564564
\QALTER DEFAULT PRIVILEGES \E
565565
\QFOR ROLE regress_dump_test_role IN SCHEMA dump_test \E
566-
\QGRANT SELECT ON TABLES TO regress_dump_test_role;\E
566+
\QGRANT SELECT ON TABLES TO regress_dump_test_role;\E
567567
/xm,
568568
like =>
569569
{ %full_runs, %dump_test_schema_runs, section_post_data => 1, },
@@ -582,7 +582,7 @@
582582
regexp => qr/^
583583
\QALTER DEFAULT PRIVILEGES \E
584584
\QFOR ROLE regress_dump_test_role IN SCHEMA dump_test \E
585-
\QGRANT ALL ON FUNCTIONS TO regress_dump_test_role;\E
585+
\QGRANT ALL ON FUNCTIONS TO regress_dump_test_role;\E
586586
/xm,
587587
like =>
588588
{ %full_runs, %dump_test_schema_runs, section_post_data => 1, },
@@ -600,7 +600,7 @@
600600
regexp => qr/^
601601
\QALTER DEFAULT PRIVILEGES \E
602602
\QFOR ROLE regress_dump_test_role \E
603-
\QREVOKE ALL ON FUNCTIONS FROM PUBLIC;\E
603+
\QREVOKE ALL ON FUNCTIONS FROM PUBLIC;\E
604604
/xm,
605605
like => { %full_runs, section_post_data => 1, },
606606
unlike => { no_privs => 1, },
@@ -615,10 +615,10 @@
615615
regexp => qr/^
616616
\QALTER DEFAULT PRIVILEGES \E
617617
\QFOR ROLE regress_dump_test_role \E
618-
\QREVOKE ALL ON TABLES FROM regress_dump_test_role;\E\n
618+
\QREVOKE ALL ON TABLES FROM regress_dump_test_role;\E\n
619619
\QALTER DEFAULT PRIVILEGES \E
620620
\QFOR ROLE regress_dump_test_role \E
621-
\QGRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,VACUUM,ANALYZE,UPDATE ON TABLES TO regress_dump_test_role;\E
621+
\QGRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,VACUUM,ANALYZE,UPDATE ON TABLES TO regress_dump_test_role;\E
622622
/xm,
623623
like => { %full_runs, section_post_data => 1, },
624624
unlike => { no_privs => 1, },

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy