X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (mx2.hub.org [200.46.204.254]) by postgresql.org (Postfix) with ESMTP id 0C2D811F65C2 for ; Thu, 13 Apr 2006 13:06:49 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: -1.807 X-Spam-Level: X-Spam-Status: No, score=-1.807 required=5 tests=[AWL=-0.592, BAYES_00=-2.599, SPF_SOFTFAIL=1.384] Received: from postgresql.org ([200.46.204.71]) by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) with ESMTP id vBqi2UOOn2pe for ; Thu, 13 Apr 2006 13:06:41 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) by postgresql.org (Postfix) with ESMTP id CA12211F717B for ; Thu, 13 Apr 2006 13:03:00 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1FU4HY-0002lQ-00; Thu, 13 Apr 2006 12:02:56 -0400 To: Martijn van Oosterhout Cc: Greg Stark , Dave Page , pgsql-hackers@postgresql.org, Hiroshi Inoue Subject: Re: Practical impediment to supporting multiple SSL libraries References: <20060413113405.GF7362@svana.org> <87ek01ik26.fsf@stark.xeocode.com> <20060413153220.GJ7362@svana.org> In-Reply-To: <20060413153220.GJ7362@svana.org> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 13 Apr 2006 12:02:56 -0400 Message-ID: <87zmiph39r.fsf@stark.xeocode.com> Lines: 48 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200604/513 X-Sequence-Number: 82236 Martijn van Oosterhout 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