Re: massive quotes?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: massive quotes?
Дата
Msg-id 1908.1063316756@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: massive quotes?  (Bruce Momjian <pgman@candle.pha.pa.us>)
Ответы Re: massive quotes?  (Jon Jensen <jon@endpoint.com>)
Список pgsql-hackers
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Yes, that is true.  I didn't like the beginning-of-line requirement for
> here documents for that reason.  However, we are already requiring the
> thing to be at the beginning of the line.  You are saying it is safer to
> make it at the beginnning of a line _and_ have it be something that
> isn't used in SQL, but $$ is used in Perl, so I don't see the big
> advantage either way --- once you say X has to begin at the beginning of
> the line, we are already making things breakable by a newline, no?

But as Jan pointed out, you can choose your string so as not to conflict
with whatever is in the text to be quoted.  So you'd probably *not* use
plain $$ as marker if working with a plperl function.  $$FUNCTION would
have a reasonably good chance of not conflicting, and if by some
chance it did match a line you want in the text, you pick another.

It is possible that we could allow the start marker to be not at the
beginning of its line, which would create structures very very close
to shell here-documents:
CREATE FUNCTION foo() RETURNS int AS $$FUNCTION... text here ...$$FUNCTION

This would be a little more open to typos --- if you leave out the space
so that it reads
CREATE FUNCTION foo() RETURNS int AS$$FUNCTION

then you wrote an identifier, not AS followed by a here-document marker.
But it might be worth defining it that way anyway because of the
similarity to shell notation.  Or maybe I'm assuming too much about
whether the average SQL programmer has ever heard of shell
here-documents.
        regards, tom lane


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

Предыдущее
От: Jon Jensen
Дата:
Сообщение: Re: massive quotes?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: massive quotes?