Re: Handling of \ in array data display

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: Handling of \ in array data display
Дата
Msg-id 20060818223217.GA32181@alvh.no-ip.org
обсуждение исходный текст
Ответ на Handling of \ in array data display  (Josh Berkus <josh@agliodbs.com>)
Ответы Re: Handling of \ in array data display  (Josh Berkus <josh@agliodbs.com>)
Список pgsql-bugs
Josh Berkus wrote:

> When saving \ escaped values into text array fields, the \ is escaped when
> displaying the contents of the array, leading to an appearance that the
> correct data was not saved:
>
> scratch=# create table test_arr ( tarr text[] );
> CREATE TABLE
> scratch=# insert into test_arr values ( array['x\y','x\\y','x y'] );
> INSERT 5695623 1
> scratch=# select * from test_arr;
>        tarr
> -------------------
>  {xy,"x\\y","x y"}
> (1 row)

> scratch=# select tarr[2] from test_arr;
>  tarr
> ------
>  x\y
> (1 row)

tarr[1] does not have a \, because it was eaten by the parser (so \y is
the same as a plain y).  tarr[2] does have a single backslash, which for
output purposes is shown escaped with another backslash when part of an
array, but unescaped when not.  I'm not sure if this qualifies as a bug
or not.

You can pass the array back and it will be valid, but amusingly you must
escape tarr[2] before passing it back.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

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

Предыдущее
От: Josh Berkus
Дата:
Сообщение: Handling of \ in array data display
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: Handling of \ in array data display