Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 7A54219B3F28 for ; Mon, 28 Nov 2011 09:36:35 -0400 (AST) Received: from mail-qw0-f46.google.com ([209.85.216.46]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RV1Nr-0006SA-Eg for pgsql-bugs@postgresql.org; Mon, 28 Nov 2011 13:36:35 +0000 Received: by qadc14 with SMTP id c14so1122326qad.19 for ; Mon, 28 Nov 2011 05:36:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :x-enigmail-version:content-type; bh=dmwi+V3LddUJUmUnFleictE1GU4g9XL7fvZOUMqkYK8=; b=lTVy6H/IPvwarvNyItpnE0MLt42WWKtxX5bZzkVAyaDISdAcYef6XD9LOzubFcFZ6B 5R1DaYBo0nRlI2fbCrkf3I5AVoBKYcM7ImtZUovqksKDDKXuph6tD+fD6e+9IB9T8rPf jFZs8oCZe9du5LY7XugmmjY8PS7SqOKN1SSgU= Received: by 10.224.203.202 with SMTP id fj10mr19228738qab.66.1322487383038; Mon, 28 Nov 2011 05:36:23 -0800 (PST) Received: from [192.168.0.120] (vev69-1-82-232-219-95.fbx.proxad.net. [82.232.219.95]) by mx.google.com with ESMTPS id h9sm10209393qac.13.2011.11.28.05.36.21 (version=SSLv3 cipher=OTHER); Mon, 28 Nov 2011 05:36:22 -0800 (PST) Message-ID: <4ED38CE3.5060503@gmail.com> Date: Mon, 28 Nov 2011 14:30:11 +0100 From: Ronan Dunklau User-Agent: Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111108 Thunderbird/8.0 MIME-Version: 1.0 To: pgsql-bugs@postgresql.org Subject: pg_dump - foreign table - server name is not quoted X-Enigmail-Version: 1.3.3 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig878F5F957FD20FDA659A3CAC" X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201111/190 X-Sequence-Number: 31785 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig878F5F957FD20FDA659A3CAC Content-Type: multipart/mixed; boundary="------------020300010507080908010003" This is a multi-part message in MIME format. --------------020300010507080908010003 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hello. I noticed what I think is a bug in pg_dump. When dumping foreign tables, the server name is not properly quoted, which leads to unrestorable dumps. eg, a foreign table attached to a foreign server named "file-test" is dumped as: CREATE FOREIGN TABLE "test-table" ( col1 integer ) SERVER file-test OPTIONS (filename '/tmp/test'); Please look at the attached test case and the proposed patch. Thank you. --=20 Ronan Dunklau --------------020300010507080908010003 Content-Type: text/x-sql; name="bug_dump_fdw.sql" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="bug_dump_fdw.sql" create database test_dump_foreign_server; \connect test_dump_foreign_server ; create extension file_fdw; create server "file-test" foreign data wrapper file_fdw; create foreign table "test-table" (col1 integer) server "file-test" optio= ns (filename '/tmp/test'); --------------020300010507080908010003 Content-Type: text/x-patch; name="bug_dump_foreign_server.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="bug_dump_foreign_server.patch" diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index ec932e4..1068b6a 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -12303,7 +12303,8 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)= =20 /* retrieve name of foreign server and generic options */ appendPQExpBuffer(query, - "SELECT fs.srvname, array_to_string(ARRAY(" + "SELECT quote_ident(fs.srvname) as srvname," + "array_to_string(ARRAY(" " SELECT quote_ident(option_name) || ' ' || " " quote_literal(option_value)" " FROM pg_options_to_table(ftoptions)), ', ') AS ftoptions " --------------020300010507080908010003-- --------------enig878F5F957FD20FDA659A3CAC Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (GNU/Linux) iQEcBAEBAgAGBQJO04zsAAoJECTYLCgFy323CMwIAJIqjWKskSLwSHQBofeWYShL 4swSp5/WAZ143n3FYa1s+UQRkQXlNQjeRUpaXpMXLdoNJ2JbjkfgBeX/YIa8TdPD mYoq5LxftI6ElFrQydRj3fCFcwcwgGcoTSgWuf+IxMOq33TvKIkMDXOepUqvfmcO RYE/xTRRHlgg22tn1lFOJCFc6c4a6dCRzlUf3n2DwLyJY1OWj6pZhLPhztXhPu0u ygoeVWANglkc7jXLOxVqiacbTeKuEoPzG8ESv/6H3MKgTBY03TGHk+Kgxatz6qJU 2PKP+ClsZibcujl+ztZJ/OeTq6WHOK4VlLQHQftTQhUq0SSemJdkWJ17ENzyV2I= =c5TW -----END PGP SIGNATURE----- --------------enig878F5F957FD20FDA659A3CAC--