pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Jurka <books@ejurka.com>
To: James William Pye <lists@jwp.name>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@postgresql.org
Cc: Matthew Wakeling <matthew@flymine.org>
Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: Maciek Sakrejda <msakrejda@truviso.com>
Cc: Samuel Gendler <sgendler@ideasculptor.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: [HACKERS] Trouble with COPY IN
Date: Fri, 6 Aug 2010 19:31:45 -0400 (EDT)
Message-ID: <alpine.BSO.2.00.1008061927300.17860@leary.csoft.net> (raw)
In-Reply-To: <BDD3690F-8290-4FC4-B6DE-1ED6E5558D83@jwp.name>
References: <alpine.DEB.2.00.1007161753160.8895@aragorn.flymine.org>
	<alpine.DEB.2.00.1007201114080.8895@aragorn.flymine.org>
	<alpine.DEB.2.00.1007201128560.8895@aragorn.flymine.org>
	<AANLkTinVNt56ZuxRf0KNgBR-kJPN1NkTgDkHY2DXIPQr@mail.gmail.com>
	<alpine.DEB.2.00.1007201229110.8895@aragorn.flymine.org>
	<alpine.DEB.2.00.1007201422270.8895@aragorn.flymine.org>
	<4C4562C50200002500033951@gw.wicourts.gov>
	<alpine.DEB.2.00.1007201452360.8895@aragorn.flymine.org>
	<alpine.DEB.2.00.1007201507500.8895@aragorn.flymine.org>
	<alpine.BSO.2.00.1007201455220.5084@leary.csoft.net>
	<alpine.BSO.2.00.1007221723230.16703@leary.csoft.net>
	<9143.1279892435@sss.pgh.pa.us>
	<4C499E26.4060307@ejurka.com>
	<9653.1279894296@sss.pgh.pa.us>
	<7E743A09-D012-4BBB-9B87-24CA1DF51015@jwp.name>
	<alpine.BSO.2.00.1007251041530.16933@leary.csof t.net>
	<41218459-EDA4-4005-B791-2392991150AC@jwp.name>
	<alpine.BSO.2.00.1007281249290.9018@leary.csoft.net>
	<BDD3690F-8290-4FC4-B6DE-1ED6E5558D83@jwp.name>



On Wed, 28 Jul 2010, James William Pye wrote:

> Not directly regarding your patch, but while the discussion is in the 
> general area. I think it would be wise to throw an error when non-empty 
> CopyData messages are received after CopyData(EOF). Chances are that the 
> user is making a mistake and should be notified of it.
>

As this is also the direction that Tom Lane indicated we should go, here 
is a patch which errors out after receiving any more copy data past the 
EOF marker.  This also fixes the protocol problem I previously brought up 
because the act of checking to see if there is any more data does ensure 
that if there isn't any more data in the current buffer, that we wait for 
the client to provide CopyDone/Fail.

Kris Jurka

Attachments:

binary-copy-end-v2.patch (text/plain, 1.2K) download *** a/src/backend/commands/copy.c --- b/src/backend/commands/copy.c *************** *** 2058,2069 **** CopyFrom(CopyState cstate) int16 fld_count; ListCell *cur; ! if (!CopyGetInt16(cstate, &fld_count) || ! fld_count == -1) { done = true; break; } if (fld_count != attr_count) ereport(ERROR, --- 2058,2090 ---- int16 fld_count; ListCell *cur; ! if (!CopyGetInt16(cstate, &fld_count)) { done = true; break; } + + if (fld_count == -1) + { + /* + * Reached EOF. In protocol version 3, we must wait for + * the protocol end of copy (CopyDone/Fail). If we + * receive any more copy data after EOF, complain. + */ + if (cstate->copy_dest == COPY_NEW_FE) + { + int8 unused; + if (CopyGetData(cstate, &unused, sizeof(unused), sizeof(unused))) + { + ereport(ERROR, + (errcode(ERRCODE_BAD_COPY_FILE_FORMAT), + errmsg("received copy data after EOF marker"))); + } else { + done = true; + break; + } + } + } if (fld_count != attr_count) ereport(ERROR,

view thread (48+ messages)  latest in thread

Message-ID: <alpine.BSO.2.00.1008061927300.17860@leary.csoft.net>
Permalink:  ../alpine.BSO.2.00.1008061927300.17860@leary.csoft.net/
Also on:    postgresql.org/message-id/alpine.BSO.2.00.1008061927300.17860@leary.csoft.net

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: books@ejurka.com, lists@jwp.name, tgl@sss.pgh.pa.us, pgsql-hackers@postgresql.org, matthew@flymine.org, Kevin.Grittner@wicourts.gov, msakrejda@truviso.com, sgendler@ideasculptor.com
  Subject: Re: [HACKERS] Trouble with COPY IN
  In-Reply-To: <alpine.BSO.2.00.1008061927300.17860@leary.csoft.net>
  References: <alpine.DEB.2.00.1007161753160.8895@aragorn.flymine.org> <alpine.DEB.2.00.1007201114080.8895@aragorn.flymine.org> <alpine.DEB.2.00.1007201128560.8895@aragorn.flymine.org> <AANLkTinVNt56ZuxRf0KNgBR-kJPN1NkTgDkHY2DXIPQr@mail.gmail.com> <alpine.DEB.2.00.1007201229110.8895@aragorn.flymine.org> <alpine.DEB.2.00.1007201422270.8895@aragorn.flymine.org> <4C4562C50200002500033951@gw.wicourts.gov> <alpine.DEB.2.00.1007201452360.8895@aragorn.flymine.org> <alpine.DEB.2.00.1007201507500.8895@aragorn.flymine.org> <alpine.BSO.2.00.1007201455220.5084@leary.csoft.net> <alpine.BSO.2.00.1007221723230.16703@leary.csoft.net> <9143.1279892435@sss.pgh.pa.us> <4C499E26.4060307@ejurka.com> <9653.1279894296@sss.pgh.pa.us> <7E743A09-D012-4BBB-9B87-24CA1DF51015@jwp.name> <41218459-EDA4-4005-B791-2392991150AC@jwp.name> <alpine.BSO.2.00.1007281249290.9018@leary.csoft.net> <BDD3690F-8290-4FC4-B6DE-1ED6E5558D83@jwp.name> <alpine.BSO.2.00.1008061927300.17860@leary.csoft.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox