Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vev8V-0001kN-UC for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Nov 2013 23:06:44 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Vev8V-0006Sn-Dh for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Nov 2013 23:06:43 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vev8U-0006Sg-C7 for pgsql-bugs@postgresql.org; Fri, 08 Nov 2013 23:06:42 +0000 Received: from cdptpa-outbound-snat.email.rr.com ([107.14.166.226] helo=cdptpa-oedge-vip.email.rr.com) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vev8K-0007VK-JC for pgsql-bugs@postgresql.org; Fri, 08 Nov 2013 23:06:39 +0000 Received: from [173.171.87.170] ([173.171.87.170:57868] helo=[192.168.100.7]) by cdptpa-oedge01 (envelope-from ) (ecelerity 3.5.0.35861 r(Momo-dev:tip)) with ESMTP id A3/0D-02506-67E6D725; Fri, 08 Nov 2013 23:06:31 +0000 Message-ID: <527D6E76.3040308@freedomcircle.com> Date: Fri, 08 Nov 2013 18:06:30 -0500 From: Joe Abbate User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130922 Icedove/17.0.9 MIME-Version: 1.0 To: Tom Lane CC: pgsql-bugs@postgresql.org, Andrew Dunstan Subject: Re: Spaces before newlines in view definitions in 9.3 References: <522F8D76.8010400@freedomcircle.com> <30611.1383949494@sss.pgh.pa.us> In-Reply-To: <30611.1383949494@sss.pgh.pa.us> X-Enigmail-Version: 1.5.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-RR-Connecting-IP: 107.14.168.118:25 X-Cloudmark-Score: 0 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 Hello Tom, On 08/11/13 17:24, Tom Lane wrote: > Joe Abbate writes: >> 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; > > Yeah, this was changed by commit 2f582f76b1945929ff07116cd4639747ce9bb8a1, > which added newlines to the output without making any attempt to suppress > the spaces that had been printed before. > >> 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. > > Hm. I am not sure whether to consider that a significant complaint or > not, because in reality the ruleutils code has been pretty sloppy about > trailing whitespace ever since it grew any "pretty printing" capability > at all. Looking for trailing whitespace in the ruleutils regression test, > I find it in "UNION ALL" and "INSERT ... VALUES" constructs, which were > that way long before that patch, and there are probably more cases that > don't happen to get exercised by the regression tests. That patch > certainly made things worse, but it's not like pre-9.3 output was > YAML-safe. > > Having said that, this seems relatively easy to fix by adjusting > appendContextKeyword to delete any trailing spaces that are immediately > before the newline it inserts. AFAICS that's the only place in ruleutils > that inserts newlines that might follow a space. get_target_list also > needs to do that when transposing a newline-started field value into the > main buffer; but that complexity is offset because it no longer need > consider the possibility of spaces before said newline. I've tested the > attached patch and it seems to do what's wanted (note: I didn't bother > including the regression test output changes in the patch, as they're > bulky and boring). > > I think that this is a reasonable thing to fix, but I'm not sure > if we ought to back-patch it into 9.3 or not. The pretty-printing > change evidently broke your use-case but I'm thinking you weren't > pushing it very hard. Agreed it's not a significant complaint, just an extra annoyance --made more visible because for Pyrseas 0.7 we added nicer view text formatting rather than outputting what pg_get_viewdef gave us, no matter how ugly and long the resulting quoted string looked like. Our tests generally compare SQL texts in a "forgiving" manner, particularly when it comes to whitespace. However, the problem was introduced in 9.3 and broke some of our view tests (and analogous matview tests derived from them). It's not a big deal if you don't backpatch to 9.3, but it would help, since some of our tests now read: if ("postgres version" < 90300): fmt = "(%s%s %s%s )" else: fmt = "( %s\n %s\n %s\n %s\n)" That would probably require yet another branch for 9.4 and later. Best 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