steve k wrote
> Am I to understand then that I should expect no error feedback if copy
> fails because of something like attempting to insert alphabetic into a
> numeric?  
> I apologize for my ignorance, but all my return codes were always
> successful (PGRES_COMMAND_OK) even if nothing was copied due to garbage
> data.  Also, calling PQgetResult never returned any information either
> because everything was always PGRES_COMMAND_OK.  
> If that's what is supposed to happen then I have completely missed the
> boat and apologize for wasting everyone's time.  

In your example you successfully sent an error message to the server and so
PQputCopyEnd does not report an error since it did what it was asked to do. 
Later, when you finish the copy and ask for the error message, you probably
will get the same message that you sent here but you may get a different one
depending on whether the server encountered any other errors before you sent
the explicit error.  Regardless of the message you are guaranteed to get
back an error after calling PQgetResult.

It seems to me that you need to supply a simple C program - along with a
test file that you expect to fail - that never reports an error so that
others may evaluate actual code.  The likelihood of this NOT being human
error is small so we really have to see your actual code since that is most
probably the culprit.

Note that, as Tom mentioned, psql is open source.  If you are trying to
duplicate its behavior in your own code you should probably look to see what
it does.  The fact that you get the proper errors in some cases means that
the server is quite obviously capable of working in the manner you desire
and thus the client - again your specific software - it where any issue
likely resides.

Again, from what I'm reading PQputCopy(Data|End) will not report on data
parsing issues.  You will only see those after issuing PQgetResult - which
is noted in the last paragraph of the PQputCopyEnd documentation excerpt you
provided.  The "put" commands only report whether the sending of the data
was successful.

David J.

View this message in context:
Sent from the PostgreSQL - hackers mailing list archive at

Sent via pgsql-hackers mailing list (
To make changes to your subscription:

Reply via email to