Re: MAC line ends strange issue

From: Dave Page <dpage(at)pgadmin(dot)org>
To: Michal Kozusznik <kozusznik(dot)michal(at)ifortuna(dot)cz>
Cc: "pgadmin-support(at)postgresql(dot)org" <pgadmin-support(at)postgresql(dot)org>
Subject: Re: MAC line ends strange issue
Date: 2013-08-22 13:24:24
Message-ID: CA+OCxowS2W5SoquiuS1S4ycSGB4YpBveL304V6+zQk=OJtJ4Rw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support

On Wed, Aug 21, 2013 at 2:43 PM, Michal Kozusznik
<kozusznik(dot)michal(at)ifortuna(dot)cz> wrote:
> On 21.8.2013 15:18, Dave Page wrote:
>
> Something is changed during storing function definition to db. You may open
> existing, properly looking function in sql editor, change EOLs to MAC, and
> hit F5. After that, refresh function in object tree - the function will
> contain quotes instead of $body$.

No, the quotes aren't stored in the DB. pgAdmin figures them out when
it reconstructs the SQL.

> We have 8.4 server. Maybe version comparison fails.

I doubt you'd even be able to connect without a ton of errors if that
were the case.

> I'm attaching the log for following operations:
> - refreshing function in tree (select function and hit F5)
> - open the function (properly looking) function by using Scripts/Create
> script from context menu (before it, EOLs has been set to Unix format)
> - changing EOL format to MAC
> - storing function by hitting F5
> - refreshing function in tree (select function and hit F5)
>
> Ha... To fix the function appearance, it is enough to switch back to Unix
> EOLs. Replacing quotes by $$ is not needed.

I was able to reproduce this eventually, and the issue occurs because
the quoting function is designed to use dollar quoting if the string
(the function body in this case) contains a ' or \n, and regular
quoting otherwise. When you select the Mac line end option (which you
almost certainly shouldn't - that's *classic* Mac line ends; OS X uses
Unix line ends), the quoting function doesn't think that dollar
quoting is required.

The attached patch fixes it for me - any see any reasons why this
might be a bad idea?

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Attachment Content-Type Size
mac-line-ends.diff application/octet-stream 497 bytes

In response to

Browse pgadmin-support by date

  From Date Subject
Next Message pico truncado 2013-08-22 19:39:05 help
Previous Message Michal Kozusznik 2013-08-21 13:43:01 Re: MAC line ends strange issue