Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VJVNw-0007nj-TQ for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Sep 2013 21:22:09 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VJVNw-000512-Bs for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Sep 2013 21:22:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VJVNv-00050w-O9 for pgsql-bugs@postgresql.org; Tue, 10 Sep 2013 21:22:07 +0000 Received: from hrndva-omtalb.mail.rr.com ([71.74.56.122]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VJVNo-0006kR-NX for pgsql-bugs@postgresql.org; Tue, 10 Sep 2013 21:22:07 +0000 X-Authority-Analysis: v=2.0 cv=fJG7LOme c=1 sm=0 a=xT1NN10MiB3dBhq6XB+wNA==:17 a=km55SyTYzpkA:10 a=SdOL7bFiyKQA:10 a=EC8GF4nu22QA:10 a=-mruROzA8e8A:10 a=IkcTkHD0fZMA:10 a=uFSowBjAAAAA:8 a=KGjhK52YXX0A:10 a=iP9CSetCmcQA:10 a=VjsGMlLwUkatgM5HaxcA:9 a=QEXdDO2ut3YA:10 a=xT1NN10MiB3dBhq6XB+wNA==:117 X-Cloudmark-Score: 0 X-Authenticated-User: X-Originating-IP: 173.171.87.170 Received: from [173.171.87.170] ([173.171.87.170:39982] helo=[192.168.100.7]) by hrndva-oedge04.mail.rr.com (envelope-from ) (ecelerity 2.2.3.46 r()) with ESMTP id 9E/30-27973-67D8F225; Tue, 10 Sep 2013 21:21:58 +0000 Message-ID: <522F8D76.8010400@freedomcircle.com> Date: Tue, 10 Sep 2013 17:21:58 -0400 From: Joe Abbate User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130828 Icedove/17.0.8 MIME-Version: 1.0 To: pgsql-bugs@postgresql.org Subject: Spaces before newlines in view definitions in 9.3 X-Enigmail-Version: 1.5.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 Example test code: $ psql pyrseas_testdb psql (9.3.0) Type "help" for help. pyrseas_testdb=# create table t1 (c1 int, c2 text); CREATE TABLE pyrseas_testdb=# create view v1 as select * from t1; CREATE VIEW pyrseas_testdb=# \d+ v1 View "public.v1" Column | Type | Modifiers | Storage | Description --------+---------+-----------+----------+------------- c1 | integer | | plain | c2 | text | | extended | View definition: SELECT t1.c1, t1.c2 FROM t1; It may not be immediately obvious but there is a space after the "t1.c1," and before the first newline. In 9.2 and previous releases, the view definition is: SELECT t1.c1, t1.c2 FROM t1; If there are more columns, there's an extra space for each except the last one, e.g., (with _ denoting a trailing space): SELECT t2.c1,_ t2.c2,_ t2.c3,_ t2.c4 FROM t2; The problem is that the string comes back, e.g., from pg_get_viewdef() with those extra spaces before the newlines, e.g., " SELECT t1.c1, \n t1.c3 * 2 AS mc3\n FROM t1; and YAML has a way displaying a text string nicely so that it can be recovered when it's read back, but it *doesn't* work if there are invisible characters such as tabs or spaces before a newline because obviously one can't tell how many or of what kind they are. Note: This applies to both views and materialized views. I believe the reformatting of view text (breaking each column on a separate line) was done to improve readability but it has the side effect of making the text unreadable if processed via a YAML utility such as Pyrseas dbtoyaml (since YAML then quotes the entire string and even breaks it down further with extra backslashes). Regards, Joe -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs