Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 804E9B5DBC4 for ; Tue, 26 Jul 2011 21:42:31 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 54201-07 for ; Wed, 27 Jul 2011 00:42:25 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from io.link-m.de (io.link-m.de [82.135.8.34]) by mail.postgresql.org (Postfix) with ESMTP id 33D81B5DBCE for ; Tue, 26 Jul 2011 21:42:25 -0300 (ADT) Received: from [10.0.2.15] (66-123-14-97.ded.pacbell.net [::ffff:66.123.14.97]) (AUTH: CRAM-MD5 julian@mehnle.net, TLS: TLSv1/SSLv3, 256bits, AES256-SHA) by io.link-m.de with esmtp; Wed, 27 Jul 2011 00:42:23 +0000 id 0000000020566102.000000004E2F5EEF.0000168F From: Julian Mehnle To: pgsql-bugs@postgresql.org Subject: pg_restore silently chokes on object comments/descriptions ending in a backslash Date: Wed, 27 Jul 2011 00:42:18 +0000 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart6349262.yzisiDMvcu"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201107270042.22427.julian@mehnle.net> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.89 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_FILL_THIS_FORM_SHORT=0.01 X-Spam-Level: X-Archive-Number: 201107/184 X-Sequence-Number: 30796 --nextPart6349262.yzisiDMvcu Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I observe the following issue on PostgreSQL 9.0.4 on at least the following platforms: * FreeBSD 6.3 (amd64) `uname -a`: FreeBSD 6.3-STABLE FreeBSD 6.3-STABLE #1: Fri May 30 18:11:4= 7 PDT 2008 root@:/data/obj/data/home//symbols/builddir_amd64= /usr/src/sys/MESSAGING_GATEWAY.amd64_INSTALL amd64 * Mac OS X 10.6.8 (i386) `uname -a`: Darwin joule 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 P= DT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386 i386 * semi-current Debian testing (amd64) `uname -a`: Linux gray 2.6.30-2-amd64 #1 SMP Mon Dec 7 05:21:45 UTC 2009 x86_64 GNU= /Linux If the comment/description of a database object (table, function, etc.) ends in a backslash (which generally works fine otherwise), then pg_restore is unable to completely restore a custom-format dump of the schema. pg_restore does not complain, but silently(!) stops issuing DDL statements to the server starting with the first "COMMENT ON =E2=80=A6" sta= tement that would have set an object comment/description ending in a backslash. Reproduce as follows: $ createdb test0 $ createdb test1 $ psql -c "CREATE TABLE bar (); COMMENT ON TABLE bar IS 'bar\\';" test0 COMMENT $ psql -c "CREATE TABLE foo (); COMMENT ON TABLE foo IS 'foo';" test0 COMMENT $ pg_dump --format custom --file test0.pg_dump --schema-only test0 $ pg_restore -d test1 test0.pg_dump=20 $ psql -c '\dt+' test0 List of relations Schema | Name | Type | Owner | Size | Description=20 --------+------+-------+--------+---------+------------- public | bar | table | julian | 0 bytes | bar\ public | foo | table | julian | 0 bytes | foo (2 rows) =20 $ psql -c '\dt+' test1 List of relations Schema | Name | Type | Owner | Size | Description=20 --------+------+-------+--------+---------+------------- public | bar | table | julian | 0 bytes |=20 (1 row) This also happens with PostgreSQL 8.4. To demonstrate that this is not an academic issue, these are a few functions I have defined, and their comments: List of functions -[ RECORD 1 ]-------+--------------------------------------------------= =2D--------------------- Schema | public Name | escape_are ... : ... Description | escape advanced regexp (ARE) special characters: = =2E*+?|[](){}^$\ -[ RECORD 2 ]-------+--------------------------------------------------= =2D--------------------- Schema | public Name | escape_control ... : ... Description | escape control characters: \a\b\t\n\v\f\r\e\\ -[ RECORD 3 ]-------+--------------------------------------------------= =2D--------------------- Schema | public Name | escape_like ... : ... Description | escape LIKE pattern special characters: %_\ I have worked around the issue by appending a space character to each of those function descriptions. What makes the problem really bad is that it silently renders your custom-format database dumps (which pg_dump creates just fine) useless, which you notice only after you do a restore (without an error being thrown) and your restored database being incomplete. =2DJulian --nextPart6349262.yzisiDMvcu Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEABECAAYFAk4vXuoACgkQwL7PKlBZWjuPcwCfQ+wbtDzhDfMwc44doayJNtPb 2lwAoIgqU9gb1QMuGZSiDjP2N1dZDbb4 =W+vS -----END PGP SIGNATURE----- --nextPart6349262.yzisiDMvcu--