Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 73011673D6C for ; Sun, 25 Mar 2012 20:55:23 -0300 (ADT) Received: from mail-pb0-f46.google.com ([209.85.160.46]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SBxHO-0005Zc-Bc for pgsql-bugs@postgresql.org; Sun, 25 Mar 2012 23:55:22 +0000 Received: by pbcun15 with SMTP id un15so5222512pbc.19 for ; Sun, 25 Mar 2012 16:55:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:subject:from:to:date:content-type:x-mailer :content-transfer-encoding:mime-version:x-gm-message-state; bh=YSrd8BdbA+XxavTFd4tIfhX+uysKXnFU5pgon2e1+vk=; b=E9aaLyTJbpqg9LEqEF1ftMN/OwJqFLK/UAnvH6dYZeSAhfzGATbmXfBrwjsbABL5zf AzBWXGYd1nLQe1NE7oJPNcOajsfPbwcUzGW9Tsd+Uy5jnBxHp8VauEwegLMjgxwpkggh BTPKKS6/Q0GU2k0F+egL+OT47ocgot/Zld98dl+XWoQb+6CFdLUOnP1tOW+w7q1+LN3E O7C8FGhB8MLWjjT0GKQUy26EcCwkv/7KCi9O1m7hNH24bfrU8i/avF/kmVCd7qD+dMRn wsISgK1VPvW4EPK2ssSXZOTVK3YPreDw5o0BDTnpsqSiqcICadjd3jJbmDBZV3qQ1Oeh venA== Received: by 10.68.222.227 with SMTP id qp3mr47933737pbc.137.1332719709229; Sun, 25 Mar 2012 16:55:09 -0700 (PDT) Received: from [192.168.1.102] (c-69-181-249-16.hsd1.ca.comcast.net. [69.181.249.16]) by mx.google.com with ESMTPS id v1sm4910714pbk.10.2012.03.25.16.55.06 (version=SSLv3 cipher=OTHER); Sun, 25 Mar 2012 16:55:08 -0700 (PDT) Message-ID: <1332719709.8251.47.camel@jdavis> Subject: possible bug in COPY ... FROM ... NULL '\0' From: Jeff Davis To: pgsql-bugs@postgresql.org Date: Sun, 25 Mar 2012 16:55:09 -0700 Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.2- Content-Transfer-Encoding: 7bit Mime-Version: 1.0 X-Gm-Message-State: ALoCoQmg4X3gt0DELvbE6hCjT7DQXOviGZL/qYMDX4UrPAiHMbhIKKy5Kms3xvxXzL6OheMOdH2u X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201203/175 X-Sequence-Number: 32736 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