Dollar quoting inside a regex bracket expression - Mailing list pgsql-bugs

From David Fetter
Subject Dollar quoting inside a regex bracket expression
Date
Msg-id 20040927022945.GA24896@fetter.org
Whole thread Raw
Responses Re: Dollar quoting inside a regex bracket expression
List pgsql-bugs
Kind people,

I was checking edge cases with dollar quoting, and ran across
something I don't quite understand.  This is in CVS TIP as of this
afternoon.  The two functions below are different only in that inside
the regex bracket expression, the first uses \\ to indicate a literal
\, while the second attempts to use $qq$\$qq$ for the same thing.  Is
this a bug?  A feature that needs documenting?  Some obvious thing
I've missed?

TIA for help on this.

------------------------------
--                          --
--  This does as expected:  --
--                          --
------------------------------

test=# CREATE OR REPLACE FUNCTION has_bad_chars(text) RETURNS BOOLEAN
AS $function$
test$#     SELECT $1 ~ $q$[\t\r\n\v|\\]$q$;
test$# $function$ LANGUAGE SQL;
CREATE FUNCTION
test=# select has_bad_chars($$\t$$);
 has_bad_chars
---------------
 t
(1 row)

----------------------
--                  --
--  This does not.  --
--                  --
----------------------
CREATE OR REPLACE FUNCTION has_bad_chars(text) RETURNS BOOLEAN
AS $function$
     SELECT $1 ~ $q$[\t\r\n\v|$qq$\$qq$]$q$;
$function$ LANGUAGE SQL;
CREATE FUNCTION
SELECT has_bad_chars($$\t$$);
 has_bad_chars
---------------
 f
(1 row)


--
David Fetter david@fetter.org http://fetter.org/
phone: +1 510 893 6100   mobile: +1 415 235 3778

Remember to vote!

pgsql-bugs by date:

Previous
From: "Aleksey Fedorchenko"
Date:
Subject: Re: BUG #1266: Improper unique constraint / MVCCactivitieswithin single transaction - addendum
Next
From: Tom Lane
Date:
Subject: Re: Dollar quoting inside a regex bracket expression