Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1akTt1-0006F3-Oa for pgsql-bugs@arkaria.postgresql.org; Mon, 28 Mar 2016 09:55:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1akTt0-00079p-Jy for pgsql-bugs@arkaria.postgresql.org; Mon, 28 Mar 2016 09:55:02 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1akTsM-0006S5-Un for pgsql-bugs@postgresql.org; Mon, 28 Mar 2016 09:54:23 +0000 Received: from mail.windfish.net ([2001:4801:7824:104:ca47:84ed:ff10:50ea]) by makus.postgresql.org with esmtps (TLS1.1:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1akTsF-00022j-Ko for pgsql-bugs@postgresql.org; Mon, 28 Mar 2016 09:54:21 +0000 Received: by mail.windfish.net (Postfix, from userid 33) id 55963765A8; Mon, 28 Mar 2016 05:54:14 -0400 (EDT) To: "David G. Johnston" Subject: Re: BUG #14048: copy issues with jsonb X-PHP-Originating-Script: 33:rcube.php MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=_da7323185f75581aeb2c65e8f83f0d32" Date: Mon, 28 Mar 2016 05:54:14 -0400 From: Rick Otten Cc: pgsql-bugs@postgresql.org In-Reply-To: References: <20160327150442.2901.36148@wrigleys.postgresql.org> Message-ID: <344e1a258e7d77d25f4d81546f261e66@www.windfish.net> X-Sender: rotten@windfish.net User-Agent: Roundcube Webmail/1.0.3 X-Pg-Spam-Score: -2.9 (--) 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 --=_da7323185f75581aeb2c65e8f83f0d32 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Ok. There are 288K rows in the file that was failing yesterday. I'll play with date ranges until I can narrow it down to a few rows and send it along. I wasn't able to get to trying pgdump yesterday, I'll give it a try today and let you know. What I'm doing manually is exactly what I posted. On 2016-03-27 22:25, David G. Johnston wrote: > On Sun, Mar 27, 2016 at 8:04 AM, wrote: > >> The following bug has been logged on the website: >> >> Bug reference: 14048 >> Logged by: Rick Otten >> Email address: rotten@windfish.net >> PostgreSQL version: 9.5.1 >> Operating system: Ubuntu 14.04 >> Description: >> >> I have a few jsonb columns in a table and I've run into several issues with >> COPY with that column type. I didn't see anything specific about it in the >> to-do list, and Google didn't turn up anyone else specifically complaining, >> so I'm filing it here. I apologize if this is a known issue. >> >> The table is the backend for a web pixel (tracking) service. It has 4 jsonb >> columns which contain variable data about the browser and session. (parsed >> user agent, list of cookies, query parameters, etc...) >> >> I wanted to copy a section of the table from one 9.5.1 database to another. >> >> For some reason the CSV and TEXT format exports do not quote/escape the >> nested JSON very well - after several tries, I gave up on that approach. >> The "copy to" output appears to be too mangled. It was not obvious, at >> first glance, where it is getting confused. > >> ​[...] > >> Meanwhile, I'll use pg_dump to get the rows I need. Hopefully that will be >> able to extract and reload the jsonb data ok. pg_dump hasn't been a problem >> in the past anyway... > > ​I'm reasonably certain pg_dump/pg_restore makes use of "COPY" to perform its work - at least for custom format and plain non-inserts mode​ - so if that works but whatever you are doing manually does not there is some degree of suspicion that what you are doing may be incorrect. > > We really need a sample record and a self-contained script that you can make reproduce this behavior. > > David J. --=_da7323185f75581aeb2c65e8f83f0d32 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=UTF-8

Ok.  There are 288K rows in the file that was failing yesterday. &n= bsp;I'll play with date ranges until I can narrow it down to a few rows and= send it along.

I wasn't able to get to trying pgdump yesterday, I'll give it a try toda= y and let you know.

What I'm doing manually is exactly what I posted.

 

On 2016-03-27 22:25, David G. Johnston wrote:

On Sun, Mar 27, 2016 at= 8:04 AM, <rotten@windfish.net> wrote:
The following bug has been logged on t= he website:

Bug reference:      14048
Log= ged by:          Rick Otten
Email address:&n= bsp;     rotten@windfish= =2Enet
PostgreSQL version: 9.5.1
Operating system:  &n= bsp;Ubuntu 14.04
Description:

I have a few jsonb columns= in a table and I've run into several issues with
COPY with that colu= mn type.  I didn't see anything specific about it in the
to-do l= ist, and Google didn't turn up anyone else specifically complaining,
= so I'm filing it here.  I apologize if this is a known issue.
The table is the backend for a web pixel (tracking) service.  It = has 4 jsonb
columns which contain variable data about the browser and= session.  (parsed
user agent, list of cookies, query parameters= , etc...)

I wanted to copy a section of the table from one 9= =2E5.1 database to another.

For some reason the CSV and TEXT f= ormat exports do not quote/escape the
nested JSON very well - after s= everal tries, I gave up on that approach.
The "copy to" output appear= s to be too mangled.  It was not obvious, at
first glance, where= it is getting confused. 
=E2=80=8B[...]
 

Meanwhile, I'll use pg_dump to = get the rows I need.  Hopefully that will be
able to extract and= reload the jsonb data ok.  pg_dump hasn't been a problem
in the= past anyway...
 
=E2=80=8BI'm reasonably certain pg_dump/pg_restore ma= kes use of "COPY" to perform its work - at least for custom format and plai= n non-inserts mode=E2=80=8B - so if that works but whatever you are doing m= anually does not there is some degree of suspicion that what you are doing = may be incorrect.
 
We really need a sample record and a self-contained s= cript that you can make reproduce this behavior.
 
David J.
 

 

--=_da7323185f75581aeb2c65e8f83f0d32--