newline conversion in SQL command strings

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема newline conversion in SQL command strings
Дата
Msg-id 1348109763.10816.13.camel@vanquo.pezone.net
обсуждение исходный текст
Ответы Re: newline conversion in SQL command strings  (Heikki Linnakangas <hlinnakangas@vmware.com>)
Список pgsql-hackers
I have received a number of bug reports about plsh choking on
Windows-style line endings.  The problem is that the user uses some
Windows-based tool or other to execute an SQL command line this:

CREATE FUNCTION foo() RETURNS something<CR><LF>
LANGUAGE plsh<CR><LF>
AS $$<CR><LF>
#!/bin/sh<CR><LF>
<CR><LF>
do something<CR><LF>
do something<CR><LF>
$$;<CR><LF>

which (apparently, I don't have Windows handy) creates a function with
the prosrc body of

'<CR><LF>
#!/bin/sh<CR><LF>
<CR><LF>
do something<CR><LF>
do something<CR><LF>
'

But executing this fails because Unix shells reject <CR> characters in
inappropriate places as syntax errors.

I don't know how to handle that.  It would be unfortunate to have the
behavior of a function depend on the kind of client used to create or
modify it.

I suppose the other more mainstream PLs don't expose that problem so
much because the interpreters can handle either kind of line ending.
But there could still be functional differences if for example a line
ending is embedded into a string constant.

Ideas?





В списке pgsql-hackers по дате отправления:

Предыдущее
От: Florian.Schoppmann@emc.com (Florian Schoppmann)
Дата:
Сообщение: Re: Invalid optimization of VOLATILE function in WHERE clause?
Следующее
От: Kohei KaiGai
Дата:
Сообщение: Re: 64-bit API for large object