Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p2hLt-00045M-RD for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Dec 2022 23:27:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p2hLs-0002mR-A0 for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Dec 2022 23:27:52 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p2hLr-0002mH-Vc for pgsql-hackers@lists.postgresql.org; Tue, 06 Dec 2022 23:27:52 +0000 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1p2hLp-0002mf-Gl for pgsql-hackers@postgresql.org; Tue, 06 Dec 2022 23:27:51 +0000 Received: by mail-pg1-x532.google.com with SMTP id 6so14739826pgm.6 for ; Tue, 06 Dec 2022 15:27:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=n6NpWTicqYnEX7c1nbgVerl9PGrbwPIr7mwAIpIuO50=; b=Gx8eUEqQj6yepl5lZzTcyddI2UCNPaXWIF5bdHdHQGepw7Bh/thr6cR9KTwBpmARt3 3pp2XDPBY/95V+QPMQlfi4C3rstEd7SlrXhDFqKkgHwl3ovyQYU9wKUJ7Q236ZWIMxoD Sd9aWdOix+BFMTpzfrJLxhJB3XzziBpEYLUn9fUv5yVZs+F/rt92O6M5kPTjTK8MrAnb ik6w5IT1PjaA/74RK7fo9vSlAooBgZk/vBk/HBRVw+D5tp03vH2b8VulPzMbyyqTEziw Vs+GbpW//dmDiEVxr2sqXuRJy9MnRnBgHeX1zhqcPHzAzT95mloC8ENtVmV1xAaoF+bX AzXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=n6NpWTicqYnEX7c1nbgVerl9PGrbwPIr7mwAIpIuO50=; b=GNMEBIrBtyOxFYzxUAd4jBeQVl62ZqMz5dnqeuxKjvskDT3RXCZb5JToPr3+U2cszo iQYrCwjAWfI9Na2nl42n0sdSL7NCYf8dUz5UXpwUynZ0s7CfFHOWDSisUOzSEs4xv2W0 KT0Po/Svz5gcVd0Aa3hDJNXR72x3z+MqYXtlt6d8anaNnIrJwUUNj+CRmjH3JBQs/oU4 UZo4vdjZHQbQTn7iaIUHV20nf6WM0lZ+tpyOEatQ+QMTX2MGmQB2EcSEBXRVjITNAL9M PXJzR3MXad+lGvrXij2rVdVxFR95nVZoIixS6I99jIrwqMW+Ux4SsK5YUhMeP69wZDje q6ow== X-Gm-Message-State: ANoB5pm2FJe7m9dtx4M6k/NOE5CotFYmjcxZ9mERv4lY83kdccGw/MXy F6cVRy4hpgugYks08YyFTENKr7U2ekk= X-Google-Smtp-Source: AA0mqf4lrfET8YVPxqhJvxAx3T3aIiS6VeqYMHwWPYsxFcH7bmvLZr6qC4l1w4Jd7ktIPxoOGpUjFw== X-Received: by 2002:a63:230e:0:b0:470:86e3:b93e with SMTP id j14-20020a63230e000000b0047086e3b93emr63084483pgj.337.1670369267188; Tue, 06 Dec 2022 15:27:47 -0800 (PST) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id c6-20020a170902d48600b0017f72a430adsm13197260plg.71.2022.12.06.15.27.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 15:27:46 -0800 (PST) Date: Tue, 6 Dec 2022 15:27:44 -0800 From: Nathan Bossart To: pgsql-hackers@postgresql.org Subject: remove extra space from dumped ALTER DEFAULT PRIVILEGES commands Message-ID: <20221206232744.GA3560301@nathanxps13> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="UlVJffcvxoiEqYs2" Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --UlVJffcvxoiEqYs2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi hackers, pg_dump adds an extra space in ALTER DEFAULT PRIVILEGES commands. AFAICT it's been this way since the command was first introduced (249724c). I've attached a patch to fix it. This is admittedly just a pet peeve, but maybe it is bothering others, too. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com --UlVJffcvxoiEqYs2 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="remove_extra_space.patch" diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c index 9311417f18..694a28f532 100644 --- a/src/bin/pg_dump/dumputils.c +++ b/src/bin/pg_dump/dumputils.c @@ -184,7 +184,9 @@ buildACLCommands(const char *name, const char *subname, const char *nspname, prefix, privs->data, type); if (nspname && *nspname) appendPQExpBuffer(firstsql, "%s.", fmtId(nspname)); - appendPQExpBuffer(firstsql, "%s FROM ", name); + if (name && *name) + appendPQExpBuffer(firstsql, "%s ", name); + appendPQExpBufferStr(firstsql, "FROM "); if (grantee->len == 0) appendPQExpBufferStr(firstsql, "PUBLIC;\n"); else @@ -253,7 +255,9 @@ buildACLCommands(const char *name, const char *subname, const char *nspname, prefix, privs->data, type); if (nspname && *nspname) appendPQExpBuffer(thissql, "%s.", fmtId(nspname)); - appendPQExpBuffer(thissql, "%s TO ", name); + if (name && *name) + appendPQExpBuffer(thissql, "%s ", name); + appendPQExpBufferStr(thissql, "TO "); if (grantee->len == 0) appendPQExpBufferStr(thissql, "PUBLIC;\n"); else @@ -265,7 +269,9 @@ buildACLCommands(const char *name, const char *subname, const char *nspname, prefix, privswgo->data, type); if (nspname && *nspname) appendPQExpBuffer(thissql, "%s.", fmtId(nspname)); - appendPQExpBuffer(thissql, "%s TO ", name); + if (name && *name) + appendPQExpBuffer(thissql, "%s ", name); + appendPQExpBufferStr(thissql, "TO "); if (grantee->len == 0) appendPQExpBufferStr(thissql, "PUBLIC"); else diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index 6656222363..4732ee2e4a 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -563,7 +563,7 @@ my %tests = ( regexp => qr/^ \QALTER DEFAULT PRIVILEGES \E \QFOR ROLE regress_dump_test_role IN SCHEMA dump_test \E - \QGRANT SELECT ON TABLES TO regress_dump_test_role;\E + \QGRANT SELECT ON TABLES TO regress_dump_test_role;\E /xm, like => { %full_runs, %dump_test_schema_runs, section_post_data => 1, }, @@ -582,7 +582,7 @@ my %tests = ( regexp => qr/^ \QALTER DEFAULT PRIVILEGES \E \QFOR ROLE regress_dump_test_role IN SCHEMA dump_test \E - \QGRANT ALL ON FUNCTIONS TO regress_dump_test_role;\E + \QGRANT ALL ON FUNCTIONS TO regress_dump_test_role;\E /xm, like => { %full_runs, %dump_test_schema_runs, section_post_data => 1, }, @@ -600,7 +600,7 @@ my %tests = ( regexp => qr/^ \QALTER DEFAULT PRIVILEGES \E \QFOR ROLE regress_dump_test_role \E - \QREVOKE ALL ON FUNCTIONS FROM PUBLIC;\E + \QREVOKE ALL ON FUNCTIONS FROM PUBLIC;\E /xm, like => { %full_runs, section_post_data => 1, }, unlike => { no_privs => 1, }, @@ -615,10 +615,10 @@ my %tests = ( regexp => qr/^ \QALTER DEFAULT PRIVILEGES \E \QFOR ROLE regress_dump_test_role \E - \QREVOKE ALL ON TABLES FROM regress_dump_test_role;\E\n + \QREVOKE ALL ON TABLES FROM regress_dump_test_role;\E\n \QALTER DEFAULT PRIVILEGES \E \QFOR ROLE regress_dump_test_role \E - \QGRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,VACUUM,ANALYZE,UPDATE ON TABLES TO regress_dump_test_role;\E + \QGRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,VACUUM,ANALYZE,UPDATE ON TABLES TO regress_dump_test_role;\E /xm, like => { %full_runs, section_post_data => 1, }, unlike => { no_privs => 1, }, --UlVJffcvxoiEqYs2--