Dollar quoting inside a regex bracket expression

Поиск
Список
Период
Сортировка
От David Fetter
Тема Dollar quoting inside a regex bracket expression
Дата
Msg-id 20040927022945.GA24896@fetter.org
обсуждение исходный текст
Ответы Re: Dollar quoting inside a regex bracket expression  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: "Aleksey Fedorchenko"
Дата:
Сообщение: Re: BUG #1266: Improper unique constraint / MVCCactivitieswithin single transaction - addendum
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Dollar quoting inside a regex bracket expression