X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F0277558AF for ; Sun, 13 Mar 2005 15:56:49 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62575-10 for ; Sun, 13 Mar 2005 15:56:41 +0000 (GMT) Received: from itapoa.terra.com.br (itapoa.terra.com.br [200.154.55.227]) by svr1.postgresql.org (Postfix) with ESMTP id D66E25659C for ; Sun, 13 Mar 2005 15:56:39 +0000 (GMT) Received: from talara.terra.com.br (talara.terra.com.br [200.154.55.136]) by itapoa.terra.com.br (Postfix) with ESMTP id B298D30CC2D for ; Sun, 13 Mar 2005 12:56:43 -0300 (BRT) X-Terra-Karma: -2% X-Terra-Hash: 675e541ea115c0f3fb9eaac46a24389b Received: from rmsmnote (unknown [200.168.176.149]) (authenticated user rodrmigu) by talara.terra.com.br (Postfix) with ESMTP id 687B23C00B for ; Sun, 13 Mar 2005 12:56:43 -0300 (BRT) From: "Rodrigo Moreno" To: Subject: How to use PQconsumeInput and PQisBusy correctly ? Date: Sun, 13 Mar 2005 12:56:32 -0300 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Thread-Index: AcUn5TndHQNU5+/MSwSVWvDwdfecng== Message-Id: <20050313155643.687B23C00B@talara.terra.com.br> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.032 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST X-Spam-Level: * X-Archive-Number: 200503/35 X-Sequence-Number: 5364 Hi all, What's the right way to use pqconsumeinput and pqisbusy ? The below code could be used to do that ? Thanks a Lot Rodrigo Moreno PS: Please don't worry if some code is wrong, I do not test this code yeat. void query(PGconn *conn, const char *stmt) { PGresult *res; int nFields; int i,j; int send; send = PQsendQuery(conn, stmt); if (PQconsumeInput(conn)) { while (PQisBusy(conn)) { printf("."); sleep(500); PQconsumeInput(conn); } res = PQgetResult(conn); if (PQresultStatus(res) != PGRES_TUPLES_OK) { fprintf(stderr, "failed: %s", PQerrorMessage(conn)); PQclear(res); exit_nicely(conn); } nFields = PQnfields(res); for (i = 0; i < nFields; i++) printf("%-15s", PQfname(res, i)); printf("\n\n"); for (i = 0; i < PQntuples(res); i++) { for (j = 0; j < nFields; j++) printf("%-15s", PQgetvalue(res, i, j)); printf("\n"); } PQclear(res); } }