pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pg_dump - foreign table - server name is not quoted
4+ messages / 2 participants
[nested] [flat]

* pg_dump - foreign table - server name is not quoted
@ 2011-11-28 13:30 Ronan Dunklau <rdunklau@gmail.com>
  2011-11-28 16:51 ` Re: pg_dump - foreign table - server name is not quoted Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Ronan Dunklau @ 2011-11-28 13:30 UTC (permalink / raw)
  To: pgsql-bugs

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) download 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) /* 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 ^ permalink raw reply [nested|flat] 4+ messages in thread

* Re: pg_dump - foreign table - server name is not quoted
  2011-11-28 13:30 pg_dump - foreign table - server name is not quoted Ronan Dunklau <rdunklau@gmail.com>
@ 2011-11-28 16:51 ` Tom Lane <tgl@sss.pgh.pa.us>
  2011-11-28 17:08   ` Re: pg_dump - foreign table - server name is not quoted Ronan Dunklau <rdunklau@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2011-11-28 16:51 UTC (permalink / raw)
  To: Ronan Dunklau <rdunklau@gmail.com>; +Cc: pgsql-bugs

Ronan Dunklau <rdunklau@gmail.com> writes:
> When dumping foreign tables, the server name is not properly quoted,
> which leads to unrestorable dumps.

Clearly a bug.

> Please look at the attached test case and the proposed patch.

I think this patch is not in keeping with typical coding practices in
pg_dump.  Usually we prefer to retrieve names from the server as-is,
then apply fmtId() when printing them --- this is more flexible than
having possibly-pre-quoted names in pg_dump's internal state.

Will fix it the latter way.  Thanks for the report!

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pg_dump - foreign table - server name is not quoted
  2011-11-28 13:30 pg_dump - foreign table - server name is not quoted Ronan Dunklau <rdunklau@gmail.com>
  2011-11-28 16:51 ` Re: pg_dump - foreign table - server name is not quoted Tom Lane <tgl@sss.pgh.pa.us>
@ 2011-11-28 17:08   ` Ronan Dunklau <rdunklau@gmail.com>
  2011-11-28 17:53     ` Re: pg_dump - foreign table - server name is not quoted Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Ronan Dunklau @ 2011-11-28 17:08 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thanks for the response.

How will this bug be handled with regards to releases ?

If the fix is going to take a while to be released, we could rename
our servers to valid names but we would prefer not to.

Regards,

- -- 
Ronan Dunklau
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)

iQEcBAEBAgAGBQJO08ABAAoJECTYLCgFy323h48H/2J88BTXgkKGjU6XQE+xkPiA
Ma9ekqsuPSYLzOv/j2lubK0P0M8CYdxgzAGQsMvhj7QZZFNhBsjBKI1fhIpxNwWw
B6/T9FRPTBS7lo2iurxK2TAcdoP2Vw76q/Nwja2DQLrwUXTztfwbP+DTTB/l0CmW
XF7BF5kS8wTnvqkqmQJaFPNefsoqh9OpyTroX0g+ul8cn9ZO3HwHtYDk1spQp3HQ
qPNAwiJaKMwnsAGqjH0qSiqtoHrSU7RxbDcKaUslI56Ba82JFD+FUErPEtuQA/q4
uX+bFgZz1K2+96s6+0ZdSccBDLCB/1o/zXAQrmJmTLUNbs9O+iSuG1v6OUMY2p0=
=QCSp
-----END PGP SIGNATURE-----



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pg_dump - foreign table - server name is not quoted
  2011-11-28 13:30 pg_dump - foreign table - server name is not quoted Ronan Dunklau <rdunklau@gmail.com>
  2011-11-28 16:51 ` Re: pg_dump - foreign table - server name is not quoted Tom Lane <tgl@sss.pgh.pa.us>
  2011-11-28 17:08   ` Re: pg_dump - foreign table - server name is not quoted Ronan Dunklau <rdunklau@gmail.com>
@ 2011-11-28 17:53     ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2011-11-28 17:53 UTC (permalink / raw)
  To: Ronan Dunklau <rdunklau@gmail.com>; +Cc: pgsql-bugs

Ronan Dunklau <rdunklau@gmail.com> writes:
> How will this bug be handled with regards to releases ?

It'll be fixed in next week's releases.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2011-11-28 17:53 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-11-28 13:30 pg_dump - foreign table - server name is not quoted Ronan Dunklau <rdunklau@gmail.com>
2011-11-28 16:51 ` Tom Lane <tgl@sss.pgh.pa.us>
2011-11-28 17:08   ` Ronan Dunklau <rdunklau@gmail.com>
2011-11-28 17:53     ` Tom Lane <tgl@sss.pgh.pa.us>

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