Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aK7Qs-0005r8-2n for pgsql-bugs@arkaria.postgresql.org; Fri, 15 Jan 2016 16:41:02 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aK7Qr-0008Eu-LZ for pgsql-bugs@arkaria.postgresql.org; Fri, 15 Jan 2016 16:41:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aJZCh-00028w-0u for pgsql-bugs@postgresql.org; Thu, 14 Jan 2016 04:08:07 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1aJZCd-00080f-JU for pgsql-bugs@postgresql.org; Thu, 14 Jan 2016 04:08:06 +0000 MIME-Version: 1.0 Subject: BUG #13865: PQresultStatus returns PGRES_COPY_OUT instead of PGRES_FATAL_ERROR for certain bad COPY statement To: pgsql-bugs@postgresql.org From: septian.hari@gmail.com Date: Thu, 14 Jan 2016 04:07:19 +0000 Message-ID: <20160114040719.25839.34626@wrigleys.postgresql.org> X-Pg-Spam-Score: -0.3 (/) Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 13865 Logged by: Septian Hari Email address: septian.hari@gmail.com PostgreSQL version: 9.4.5 Operating system: ubuntu 14.04 Description: We notice that for certain bad COPY statement, PQresultStatus will return PGRES_COPY_OUT instead of PGRES_FATAL_ERROR, and subsequently hide the error when using ruby pg gem. Steps to reproduce: $ psql postgres psql (9.5.0, server 9.4.5) Type "help" for help. postgres=# create table xxx (properties json); CREATE TABLE postgres=# insert into xxx values ('{"a": "1\u000023"}'); INSERT 0 1 postgres=# select properties->'a' from xxx; ERROR: unsupported Unicode escape sequence DETAIL: \u0000 cannot be converted to text. CONTEXT: JSON data, line 1: {"a":... $ pry [1] pry(main)> require 'pg' => true [2] pry(main)> conn = PG.connect(dbname: 'postgres') => # [3] pry(main)> conn.exec "copy (select properties->'a' from xxx) to stdout" => # [4] pry(main)> conn.get_copy_data => nil $ PSYCOPG_DEBUG=1 ipython ... In [5]: cur.copy_expert("COPY (SELECT properties->'a' FROM xxx) TO STDOUT", sys.stdout) [4480] curs_execute: pg connection at 0x2eb9bb0 OK [4480] pq_begin_locked: pgconn = 0x2eb9bb0, autocommit = 0, status = 1 [4480] pq_execute_command_locked: pgconn = 0x2eb9bb0, query = BEGIN [4480] pq_execute: executing SYNC query: pgconn = 0x2eb9bb0 [4480] COPY (SELECT properties->'a' FROM xxx) TO STDOUT [4480] pq_execute: entering synchronous DBAPI compatibility mode [4480] pq_fetch: pgstatus = PGRES_COPY_OUT [4480] pq_fetch: data from a COPY TO (no tuples) [4480] psycopg_is_text_file: importing io.TextIOBase [4480] _read_rowcount: PQcmdTuples = [4480] pq_raise: PQresultErrorMessage: err=ERROR: unsupported Unicode escape sequence DETAIL: \u0000 cannot be converted to text. CONTEXT: JSON data, line 1: {"a":... [4480] pq_raise: err2=unsupported Unicode escape sequence DETAIL: \u0000 cannot be converted to text. CONTEXT: JSON data, line 1: {"a":... [4480] pq_fetch: fetching done; check for critical errors --------------------------------------------------------------------------- DataError Traceback (most recent call last) in () ----> 1 cur.copy_expert("COPY (SELECT properties->'a' FROM xxx) TO STDOUT", sys.stdout) DataError: unsupported Unicode escape sequence DETAIL: \u0000 cannot be converted to text. CONTEXT: JSON data, line 1: {"a":.. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs