Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YnF7B-0001VM-2s for pgsql-bugs@arkaria.postgresql.org; Tue, 28 Apr 2015 23:40:33 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YnF7A-0008SM-73 for pgsql-bugs@arkaria.postgresql.org; Tue, 28 Apr 2015 23:40:32 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YnF78-0008SD-4r for pgsql-bugs@postgresql.org; Tue, 28 Apr 2015 23:40:30 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YnF6z-0004Tn-GB for pgsql-bugs@postgresql.org; Tue, 28 Apr 2015 23:40:28 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1YnF6w-0001gl-HV; Tue, 28 Apr 2015 19:40:18 -0400 Date: Tue, 28 Apr 2015 19:40:18 -0400 From: Bruce Momjian To: hans@matfyz.cz Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #12730: pg_dump produces trailing spaces Message-ID: <20150428234018.GE31727@momjian.us> References: <20150202143116.2585.12308@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="KsGdsel6WgEHnImy" Content-Disposition: inline In-Reply-To: <20150202143116.2585.12308@wrigleys.postgresql.org> User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --KsGdsel6WgEHnImy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Feb 2, 2015 at 02:31:16PM +0000, hans@matfyz.cz wrote: > The following bug has been logged on the website: > > Bug reference: 12730 > Logged by: Hans Ginzel > Email address: hans@matfyz.cz > PostgreSQL version: 9.4.0 > Operating system: Centos 6.5 > Description: > > Hello! > > Try > pg_dump --format=p --schema=information_schema --schema-only --file=is.sql > > It seams there are trailing spaces in the comment line > -- Name: sql_implementation_info; Type: TABLE; Schema: information_schema; > Owner: postgres; Tablespace: > > Skip the string '; Tablespace: ' please, if there is no tablespace or put > '-' for the tablespace name in the same way as dash is used for Owner when > the option --no-owner is used. I looked into this issue and found that the pg_dump code doesn't handle cases where the reltablespace == 0 (default). I have modified pg_dump to test for a zero-length string as well, and this suppresses the "Tablespace:" field. Patch attached. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. + --KsGdsel6WgEHnImy Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="pg_dump.diff" diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c new file mode 100644 index ca427de..f9b564e *** a/src/bin/pg_dump/pg_backup_archiver.c --- b/src/bin/pg_dump/pg_backup_archiver.c *************** _printTocEntry(ArchiveHandle *AH, TocEnt *** 3246,3252 **** free(sanitized_schema); free(sanitized_owner); ! if (te->tablespace && !ropt->noTablespace) { char *sanitized_tablespace; --- 3246,3252 ---- free(sanitized_schema); free(sanitized_owner); ! if (te->tablespace && strlen(te->tablespace) > 0 && !ropt->noTablespace) { char *sanitized_tablespace; --KsGdsel6WgEHnImy Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs --KsGdsel6WgEHnImy--