I'm trying to get an error after sending wrong buffer by PQputCopyData.
I do everything according to the documentation:
PGconn* conn=PQconnectdb(qPrintable(conninfo));
if (PQstatus(conn) != CONNECTION_OK)
{
...
}
PQsetClientEncoding(conn,"WIN1251");
PGresult* res=PQexec(conn,"COPY ksv FROM STDIN);
ExecStatusType status= PQresultStatus(res);
PQclear(res);
if(status!=PGRES_COPY_IN)
{
...
}
int
copyStatus=PQputCopyData(conn,bufferToWrite,strlen(bufferToWrite));//
bufferToWrite is wrong
cout()<<copyStatus; // returns 1
const char* error=NULL;
int copyStatusEnd=PQputCopyEnd(conn,error);
cout()<<copyStatusEnd;// returns 1
if(error!=NULL) // error is NULL
{
...
}
PGresult* result=PQgetResult(conn); // so, here im calling pqgetresult
to get error
ExecStatusType status2= PQresultStatus(result);
if(status2==PGRES_COMMAND_OK) // and status2 is really PGRES_COMMAND_OK
{
...
}
char * error1= PQresultErrorMessage(result);
cout()<<error1; // here null
char* error2 =PQerrorMessage(conn);
cout()<<error2; // here null
so, pqgetresult do not return any error. what im doing wrong?
--
View this message in context:
http://postgresql.nabble.com/get-error-message-of-COPY-command-after-using-PQputCopyEnd-tp5940767.html
Sent from the PostgreSQL - novice mailing list archive at Nabble.com.