pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: eem21@cam.ac.uk
Cc: pgsql-interfaces@postgreSQL.org
Subject: Re: [INTERFACES] Asynchronous connect using libpq
Date: Sun, 18 Jul 1999 10:43:21 -0400
Message-ID: <4364.932309001@sss.pgh.pa.us> (raw)
In-Reply-To: <E115oQi-00068b-00@red.csi.cam.ac.uk>

eem21@cam.ac.uk writes:
> I need non-blocking versions of PQconnectdb and PQreset in libpq,
> analogous to the asynchronous query processing functions (PQsendQuery
> et al).

Gonna have to write them yourself, I'm afraid.  PQconnect is actually
a rather long sequence, involving completing an authentication protocol
with the server and then sending a few standard setup commands.
See libpq/fe-connect.c.

PQreset just closes the connection and then invokes PQconnect.

> I am willing to write these, if no one else has time to do so, but would
> appreciate some input before I get started.

For maintainability, there'd need to be just one copy of the setup code
not two, so you'd want to do something similar to the way I implemented
the async query processing: write the async code and then replace the
synchronous routines with simple loops that call the async version.

Turning the bottom part of connectDB() plus PQsetenv() into a state
machine would be a fairly straightforward way of making this happen.
connectDB is nearly there already, you'd just need to move the loop
up to its caller.

Probably the most serious problem you'd have to consider before diving
into this is that on most platforms, both gethostbyname() and connect()
can involve nontrivial delays, and I know of no portable way to replace
them with asynchronous operations.  If you can live with a DNS lookup
delay then you can probably live with the other delays, and if you can't
then it's not clear you would have a workable solution when you got done
anyway :-(.

			regards, tom lane



view thread (5+ messages)  latest in thread

Message-ID: <4364.932309001@sss.pgh.pa.us>
Permalink:  ../4364.932309001@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/4364.932309001@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: tgl@sss.pgh.pa.us, eem21@cam.ac.uk
  Subject: Re: [INTERFACES] Asynchronous connect using libpq
  In-Reply-To: <4364.932309001@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox