Re: massive quotes?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Jon Jensen <jon(at)endpoint(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: massive quotes?
Date: 2003-09-11 21:45:56
Message-ID: 1908.1063316756@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-09-11 21:50:05 Re: massive quotes?
Previous Message Jon Jensen 2003-09-11 21:42:32 Re: massive quotes?