Re: psql/pg_dump vs. dollar signs in identifiers

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Jim C(dot) Nasby" <decibel(at)decibel(dot)org>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: psql/pg_dump vs. dollar signs in identifiers
Date: 2007-07-09 20:15:35
Message-ID: 871wfh9vvc.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Jim C. Nasby" <decibel(at)decibel(dot)org> writes:

> Unless you're doing muti-line regex, what's the point of a $ anywhere
> but the end of the expression? Am I missing something? Likewise with ^.

Leaving out the backslashes, you can do things like (foo$|baz|qux)(baz|qux|)
to say that all 9 combinations of those two tokens are valid except that foo
must be followed by the empty second half.

But it can always be refactored into something more normal like
(foo|((baz|qux)(baz|qux)?))

> I'm inclined to escape $ as Tom suggested.

Yeah, I have a tendency to look for the most obscure counter-example if only
to be sure I really understand precisely how obscure it is. I do agree that
it's not a realistic concern. Especially since I never even realized we
handled regexps here at all :)

IIRC some regexp engines don't actually treat $ specially except at the end of
the regexp at all. Tom's just suggesting doing the same thing here where
complicated regexps are even *less* likely and dollars as literals more.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Gregory Stark 2007-07-09 21:38:24 Re: PQescapeBytea* version for parameters
Previous Message Jim C. Nasby 2007-07-09 19:57:09 Re: psql/pg_dump vs. dollar signs in identifiers