pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David G Johnston <david.g.johnston@gmail.com>
To: pgsql-bugs@postgresql.org
Subject: Re: BUG #11121: Error not properly reported when calling PQputCopyData with a column missing
Date: Mon, 4 Aug 2014 11:38:12 -0700 (PDT)
Message-ID: <1407177492467-5813724.post@n5.nabble.com> (raw)
In-Reply-To: <20140804165107.2707.2545@wrigleys.postgresql.org>
References: <20140804165107.2707.2545@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

menotyou wrote
> The following bug has been logged on the website:
> 
> Bug reference:      11121
> Logged by:          Jay Carlson
> Email address:      

> menotyou@

> PostgreSQL version: 9.3.4
> Operating system:   Windows 7 (64 Bit)
> Description:        
> 
> The short version: After successfully calling calling PQexec to COPY_IN
> from
> STDIN, I noticed calling PQputCopyData with a buffer that does not contain
> all of the required columns and an incorrectly formatted column, an error
> is
> not generated and PQputCopyEnd will not leave PGRES_COPY_IN mode.  An
> error
> for this situation is only ennunciated after PQputCopyData is called again
> AFTER calling PQputCopyEnd.
> 
> THE DETAILS:
> Here is the format of the status_data table:
> ++ test_id: integer
> ++ device_id: integer
> ++ time_stamp: timestamp with time zone
> ++ mem_map_detail_id: integer
> ++ value: text
> 
> First I'm successfully calling PQexec with "COPY status_data (test_id,
> device_id, time_stamp, mem_map_detail_id, value) FROM STDIN"
> 
> ----------------------------------
> PQputCopyData 1: (No error expected)
> If I call PQputCopyData with the following the result is 1 (Success):
> "1\t3\t07/25/2014\t48811\tHey1\n"
> 
> At this point after calling PQgetResult:
> PQresultStatus returns 4 (PGRES_COPY_IN)
> PQerrorMessage returns no error.
> 
> ----------------------------------
> PQputCopyData 2: (Expected Error)
> If I call PQputCopyData with the following (missing the tab before
> "Hey2"),
> the result is 1 (Success):
> "1\t3\t07/25/2014\t48811Hey2\n"
> 
> At this point after calling PQgetResult:
> PQresultStatus returns 4 (PGRES_COPY_IN)
> PQerrorMessage returns no error.
> 
> **An error should have been generated here because we are calling
> PQputCopyData with the incorrect number of columns AND an incorrect format
> for one of the columns.

This is not a bug but improper usage of the API.  In short, both
PQputCopyData and PQputCopyEnd are strictly concerned with data transfer
success/failure.  The data is not guaranteed to be parsed until you attempt
to finish the copy command by executing PQgetResult.

See this earlier discussion for more context and thoughts:

http://postgresql.1045698.n5.nabble.com/PQputCopyData-dont-signal-error-td4302340.html#a5798077

David J.




--
View this message in context: http://postgresql.1045698.n5.nabble.com/BUG-11121-Error-not-properly-reported-when-calling-PQputCopy...
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (2+ messages)

Message-ID: <1407177492467-5813724.post@n5.nabble.com>
Permalink:  ../1407177492467-5813724.post@n5.nabble.com/
Also on:    postgresql.org/message-id/1407177492467-5813724.post@n5.nabble.com

 · 

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-bugs@postgresql.org
  Cc: david.g.johnston@gmail.com
  Subject: Re: BUG #11121: Error not properly reported when calling PQputCopyData with a column missing
  In-Reply-To: <1407177492467-5813724.post@n5.nabble.com>
  References: <20140804165107.2707.2545@wrigleys.postgresql.org> <1407177492467-5813724.post@n5.nabble.com>

* 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