Re: massive quotes? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: massive quotes?
Date
Msg-id 1908.1063316756@sss.pgh.pa.us
Whole thread Raw
In response to Re: massive quotes?  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: massive quotes?
List 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 by date:

Previous
From: Jon Jensen
Date:
Subject: Re: massive quotes?
Next
From: Tom Lane
Date:
Subject: Re: massive quotes?