possible bug in COPY ... FROM ... NULL '\0'

Поиск
Список
Период
Сортировка
От Jeff Davis
Тема possible bug in COPY ... FROM ... NULL '\0'
Дата
Msg-id 1332719709.8251.47.camel@jdavis
обсуждение исходный текст
Ответы Re: possible bug in COPY ... FROM ... NULL '\0'  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
The documentation says:

"The specified null string is sent by COPY TO without adding any
backslashes; conversely, COPY FROM matches the input against the null
string before removing backslashes."
  -- http://www.postgresql.org/docs/devel/static/sql-copy.html

Those seem inconsistent with the following behavior:

  postgres=# copy foo to '/tmp/a.copy' null '\0';
  COPY 2
  postgres=# copy foo from '/tmp/a.copy' null '\0';
  ERROR:  invalid byte sequence for encoding "UTF8": 0x00
  CONTEXT:  COPY foo, line 2: "\0"

  $ cat /tmp/a.copy
  1
  \0

COPY TO seems to follow the documentation, inserting the null string
without modification into the output file. COPY FROM seems to de-escape
the input before trying to match it against the null string, leading to
the invalid byte sequence.

standard_conforming_strings is on.

Regards,
    Jeff Davis

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: check_locale() and the empty string
Следующее
От: Tom Lane
Дата:
Сообщение: Re: possible bug in COPY ... FROM ... NULL '\0'