Re: massive quotes? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: massive quotes?
Date
Msg-id 5326.1063331924@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:
> ... 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?

Keep in mind that we have two different requirements: the quote start
marker has to be recognizable while we are parsing SQL (or possibly
plpgsql) code.  The quote end marker has to be recognizable while we are
scanning text that could be almost anything.

The cute thing about the here-document solution to this problem is that
you can choose the quote end marker on a case-by-case basis.  So you can
always pick something that won't conflict with anything that's actually
in the text you need to quote.

If we try to go with fixed markers (like {' ... }' and some other ideas
that were floated today), then we lose that flexibility, and we're up
against the losing game of trying to pick an end-marker that won't cause
problems in any programming language anywhere (not to mention possible
uses of the quoting mechanism for arbitrary string literals that aren't
even function bodies).  

I'm not wedded to the "$$FOO" idea in particular, but I do think we want
to go with a solution that allows a variable end-marker.
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Matthew T. O'Connor"
Date:
Subject: Re: Another small bug (pg_autovacuum)
Next
From: Bruce Momjian
Date:
Subject: Re: Win32 native port