Re: Escaping special characters

Поиск
Список
Период
Сортировка
От Daniel Verite
Тема Re: Escaping special characters
Дата
Msg-id b9b176fc-de94-423b-b3ec-b1ba0025766f@mm
обсуждение исходный текст
Ответ на Escaping special characters  (Neanderthelle Jones <elle@view.net.au>)
Список pgsql-general
    Neanderthelle Jones wrote:

> About the string "Smith \& Jones".
>
> According to the documentation,
>
> INSERT INTO thing (name) VALUES ('Smith E'\\'& Jones');
>
> must work.  But it doesn't.  So, double the enclosed quotes:
>
> INSERT INTO thing (name) VALUES ('Smith E''\\''& Jones');

The E can't be inside the string, it must appear before the quote
starting the string.

But first, you need to choose a setting for
standard_conforming_strings, especially if you're concerned with
compatibility against future versions. Either your session has
standard_conforming_strings set to ON or set to OFF. This is what
defines which characters have to be quoted and how.

if OFF you must escape the backslash:
test=> set standard_conforming_strings=off;
SET
test=> select E'Smith \\& Jones';
    ?column?
----------------
 Smith \& Jones
(1 row)

if ON you don't:
test=> set standard_conforming_strings=on;
SET
test=> select 'Smith \& Jones';
    ?column?
----------------
 Smith \& Jones
(1 row)

ON is supposed to become the default at some point in the future.

Cordialement,
--
 Daniel

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: different results for large objects
Следующее
От: Subha Ramakrishnan
Дата:
Сообщение: Uploading data to postgresql database