From: Ronan Dunklau <rdunklau@gmail.com>
To: pgsql-bugs@postgresql.org
Subject: pg_dump - foreign table - server name is not quoted
Date: Mon, 28 Nov 2011 14:30:11 +0100
Message-ID: <4ED38CE3.5060503@gmail.com> (raw)
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.
--
Ronan Dunklau
Attachments:bug_dump_fdw.sql (text/x-sql, 262B) download
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" options (filename '/tmp/test');
bug_dump_foreign_server.patch (text/x-patch, 638B) downloaddiff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.cindex 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)
/* 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 "
signature.asc (application/pgp-signature, 489B) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: rdunklau@gmail.com
Subject: Re: pg_dump - foreign table - server name is not quoted
In-Reply-To: <4ED38CE3.5060503@gmail.com>
References: <4ED38CE3.5060503@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox