Re: libpq, blocking/nonblocking mechanism

From: Volkan YAZICI <volkan(dot)yazici(at)gmail(dot)com>
To: Terry Lee Tucker <terry(at)esc1(dot)com>
Cc: PostgreSQL Interfaces <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: libpq, blocking/nonblocking mechanism
Date: 2005-06-03 13:55:51
Message-ID: 7104a73705060306553672f56a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Hi,

On 6/1/05, Terry Lee Tucker <terry(at)esc1(dot)com> wrote:
> PQsetnonblocking() causes PQsendQuery to send an sql string to the backend
> and it returns immediately if you have set nonblocking to true. If you have
> not set nonblocking to true, then PQsendQuery behaves just like PQexec; it
> blocks, i.e., it waits for the query, update, delete, or whatever to complete
> before it returns program control back to your program. We set nonblocking to
> True in our application and when the user queries a large table that could
> return thousands of records, we use PQsendQuery instead of PQexec; however,
> if you do that, then you have to use PQconsumeInput and PQisBusy in
> conjunction with a select statement to monitor the backend connection socket
> so you can process the results when the query finishes. Another reason for
> using asynchronous queries is that you can provide a mechanism for the user
> to cancel the operation.

Thanks so much for the explanation.

> Our application is X-Windows based written in C.
> All my examples are C. If you want to see any of it, you can let me know.

I'd be so appreciated to see them.

Regards.

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message David Hinkle 2005-06-03 16:18:25 libpq, PQExecParams and the inserting of binary data
Previous Message Tom Lane 2005-06-03 05:17:16 DBD::Pg performance bites compared to DBD::mysql?