[NOVICE] get error message of COPY command after using PQputCopyEnd - Mailing list pgsql-novice

From bronstein87
Subject [NOVICE] get error message of COPY command after using PQputCopyEnd
Date
Msg-id 1485294047205-5940769.post@n3.nabble.com
Whole thread Raw
Responses Re: [NOVICE] get error message of COPY command after using PQputCopyEnd  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-novice
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-tp5940769.html
Sent from the PostgreSQL - novice mailing list archive at Nabble.com.


pgsql-novice by date:

Previous
From: bronstein87
Date:
Subject: [NOVICE] get error message of COPY command after using PQputCopyEnd
Next
From: Tom Lane
Date:
Subject: Re: [NOVICE] get error message of COPY command after using PQputCopyEnd