Skip site navigation (1) Skip section navigation (2)

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

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: possible bug in COPY ... FROM ... NULL '\0'
Date: 2012-03-25 23:55:09
Message-ID: 1332719709.8251.47.camel@jdavis (view raw, whole thread or download thread mbox)
Lists: 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."

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

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.

	Jeff Davis


pgsql-bugs by date

Next:From: kontaktDate: 2012-03-26 00:00:05
Subject: BUG #6556: earthdistance module has lacking documentation
Previous:From: Tom LaneDate: 2012-03-25 21:06:46
Subject: Re: check_locale() and the empty string

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group