Re: standard_conforming_strings and pg_escape_string()

Поиск
Список
Период
Сортировка
От Conrad Lender
Тема Re: standard_conforming_strings and pg_escape_string()
Дата
Msg-id 49F0F5DA.5090803@gmail.com
обсуждение исходный текст
Ответ на Re: standard_conforming_strings and pg_escape_string()  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: standard_conforming_strings and pg_escape_string()  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Tom,

thanks for your reply.

On 24/04/09 00:56, Tom Lane wrote:
>>   if ($escWildcards) {
>>     $str = strtr($str, array("%" => '\%', "_" => '\_'));
>>   }
>>   return "E'" . pg_escape_string($str) . "'";
>
> The above cannot possibly work.  pg_escape_string is generating what it
> supposes to be a normal string literal, and then you are sticking an 'E'
> on the front which changes the escaping rules.  It is not the function's
> fault that this fails.

I'm afraid I don't understand why it fails (it appears to work, at
least). I have to enclose the result of pg_escape_string() in single
quotes to get a string literal, and if I don't add the "E" in front, I
see warnings in the server log about "nonstandard use of \\ in a string
literal" (standard_conforming_strings is off, escape_string_warning is on).

I could disable the warnings, of course, but I suppose they are there
for a reason.


Thanks,
  - Conrad

В списке pgsql-general по дате отправления:

Предыдущее
От: Adam Ruth
Дата:
Сообщение:
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: need help for PostgreSQL consistency check mechanism