Re: newline conversion in SQL command strings

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: newline conversion in SQL command strings
Date: 2012-09-20 19:34:19
Message-ID: 12733.1348169659@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2012-09-20 19:53:07 Re: ToDo: allow to get a number of processed rows by COPY statement [Review of Patch]
Previous Message Andrew Dunstan 2012-09-20 19:23:36 Re: newline conversion in SQL command strings