Re: Regarding PQputline and PQendcopy - Mailing list pgsql-hackers

From soni de
Subject Re: Regarding PQputline and PQendcopy
Date
Msg-id 9f2e40a90611290432g162940edib19bd19f54cabcae@mail.gmail.com
Whole thread Raw
In response to Regarding PQputline and PQendcopy  ("soni de" <soni.de@gmail.com>)
Responses Re: Regarding PQputline and PQendcopy  (Richard Huxton <dev@archonet.com>)
Re: Regarding PQputline and PQendcopy  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
Any response?

On 11/29/06, soni de <soni.de@gmail.com> wrote:

Hello,

 

We are using PQputline function for copying data to database

Postgres version 7.2.4

 

Following is the code snapshot:

 

We are taking data from one database, 100 records at time and storing that records in string array "strArr"

After filling "strArr", we are passing this string array to PQputline as follows:

 

            res = PQexec(conn, "COPY <tablename> from STDIN");

PQclear(res);

i = 0; 

while(true) {

  status = PQputline(conn,strArr[i]); //contains one row of data

  if(status != 0) {

    cout<<endl<<"Unable to send string: "<< strArr[i] <<endl;

    if (status == EOF) {

            cout<<endl<<"status is EOF"<<endl;

    }

  }

  i++;

  if(i > 100) {

      break;

  }

}

status = PQputline(conn, "\\.\n"); // terminator line

status = PQendcopy(conn); 

 

 

Sometime above code works fine but at sometime PQputline returns EOF and code goes in hang state for PQendcopy function.

How to recognize, why PQputline sends EOF?

Please provide me some help regarding what action must be taken when PQputline returns EOF or PQputline unable to send the line to server.

Also how to avoid the hang state of postgres server in PQendcopy function

 

 

Thanks,

Soni


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: VPATH problems in ECPG again
Next
From: Alvaro Herrera
Date:
Subject: Re: VPATH problems in ECPG again