Re: Practical impediment to supporting multiple SSL libraries

From: Greg Stark <gsstark(at)mit(dot)edu>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: Greg Stark <gsstark(at)mit(dot)edu>, Dave Page <dpage(at)vale-housing(dot)co(dot)uk>, pgsql-hackers(at)postgresql(dot)org, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
Subject: Re: Practical impediment to supporting multiple SSL libraries
Date: 2006-04-13 16:02:56
Message-ID: 87zmiph39r.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:

> On Thu, Apr 13, 2006 at 11:14:57AM -0400, Greg Stark wrote:
> > That could be useful for applications but I think a driver really wants to
> > retain control of the flow of control. To make use of a callback it would have
> > to have an awkward dance of calling whatever function gives libpq license to
> > call the callback, having the callback stuff the data in a temporary space,
> > then checking for new data in the temporary space, and returning it to the
> > user.
>
> We have an asyncronous interface. I was thinking like:
>
> sub mycallback(res,data)
> {
> /* stuff data in memory structure */
> if( row_count > 5 )
> gotenough = TRUE;
> }
>
> If you set non-blocking you can even go off and do other things while
> waiting. No need for temporary space...
>
> Does this seem too complex?

There's nothing wrong with a callback interface for applications. They can
generally have the callback function update the display or output to a file or
whatever they're planning to do with the data.

However drivers don't generally work that way. Drivers have functions like:

$q = prepare("select ...");
$q->execute();
while ($row = $q->fetch()) {
print $row->{column};
}

To handle that using a callback interface would require that $q->fetch invoke
some kind of pqCheckForData() which would upcall to the callback with the
available data. The callback would have to stuff the data somewhere. Then
fetch() would check to see if there was data there and return it to the user.

It's doable but dealing with this impedance mismatch between the interfaces
necessitates extra steps. That means extra copying and extra function calls.

--
greg

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2006-04-13 16:09:03 Re: Practical impediment to supporting multiple SSL libraries
Previous Message Tom Lane 2006-04-13 15:56:38 Re: Practical impediment to supporting multiple SSL libraries