Re: newline conversion in SQL command strings - Mailing list pgsql-hackers

From Tom Lane
Subject Re: newline conversion in SQL command strings
Date
Msg-id 12733.1348169659@sss.pgh.pa.us
Whole thread Raw
In response to Re: newline conversion in SQL command strings  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: newline conversion in SQL command strings  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
Andrew Dunstan <andrew@dunslane.net> writes:
> On 09/20/2012 09:12 AM, Peter Eisentraut wrote:
>> It has been proposed that the plsh handler should strip the CRs before
>> execution.  But I don't think that is a correct solution, because that
>> is user data which could be relevant.  It could be the case, for
>> example, that plsh is run on a Windows host with a particular shell that
>> requires CRLF line endings.

> I confess I find it hard to take plsh terribly seriously,

Perhaps, but the general problem remains, for any language whose
interpreter is unforgiving about line endings.

However, I think the problem is insoluble as Peter has stated it.
His original complaint was 

> ... It would be unfortunate to have the
> behavior of a function depend on the kind of client used to create or
> modify it.

but I don't see a way to reconcile that with the notion that CRs might
be user data.  Either you think they're significant, in which case you
should retain the function body as presented, or you think they aren't,
in which case you might as well strip them.

I lean to the position that you're best off stripping them, given that
the lines are to be fed to a Unix shell.  The argument about some other
shell possibly requiring them seems pretty tenuous.  (IOW, I think that
the PL-specific code is exactly the place to be making such decisions.
I don't want Postgres' generic function support making any decisions
about whether CRs in function bodies are significant, because that
decision could be language-specific.)
        regards, tom lane



pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: newline conversion in SQL command strings
Next
From: Pavel Stehule
Date:
Subject: Re: ToDo: allow to get a number of processed rows by COPY statement [Review of Patch]