Received: from u1.abs.net (root@u1.abs.net [207.114.0.131]) by hub.org (8.9.1/8.9.1) with ESMTP id PAA24498 for ; Tue, 17 Nov 1998 15:58:53 -0500 (EST) (envelope-from daveh@insightdist.com) Received: from insightdist.com (root@localhost) by u1.abs.net (8.9.0/8.9.0) with UUCP id PAA05084 for pgsql-hackers@hub.org; Tue, 17 Nov 1998 15:47:46 -0500 (EST) Received: from ceodev by insightdist.com (AIX 3.2/UCB 5.64/4.03) id AA18723; Tue, 17 Nov 1998 13:30:01 -0500 Received: from daveh by ceodev (AIX 4.1/UCB 5.64/4.03) id AA57728; Tue, 17 Nov 1998 13:29:17 -0500 Message-Id: <3651C172.97D59F6B@insightdist.com> Date: Tue, 17 Nov 1998 13:33:23 -0500 From: David Hartwig Organization: Insight Distribution Systems X-Mailer: Mozilla 4.5 [en] (Win98; I) X-Accept-Language: en Mime-Version: 1.0 To: Michael Meskes Cc: pgsql-hackers@hub.org Subject: Re: [HACKERS] PREPARE References: <000501be119e$6c16efa0$8a14f7d0@taral.dobiecenter.com> <19981117101824.C2181@usa.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Michael Meskes wrote: > On Mon, Nov 16, 1998 at 02:19:32PM -0600, Taral wrote: > > separate stages. Are we also planning to support PREPARE? If so, we should > > co-ordinate the effort, since the full COSQS support will require pulling > > apart pg_parse_and_plan(). > > Hopefully. I'm still holding back PREPARE for ecpg until I can think of a > good solution. The best of course would be in the backend. Hmm, how do ODBC > and JDBC solve this? Speaking for ODBC, we keep the PREPARE'd statement in a malloc'ed buffer in the driver. The fun part is that we must support a set of API calls which request things like the number of parameters, and result set, column info. We get the parameter count by simply counting the parameter markers. To get the column info, we send the statement to the backend, retrieve the column info and discard any returned rows. Not very elegant nor inefficient. But it works ok. This functionality should be handled by the backend. May I suggest a protocol that will allow this typical interchange. send PREPARE(statement) receive stmt_handle send GET_PARAM_COUNT(stmt_handle) receive param_count for i = 1 to param_count send DESCRIBE_PARAMETER(stmt_handle, i); -- include: type, nullability, scale, & precision receive parameter description. end for send GET_COLUMN_COUNT(stmt_handle); receive column_count for i = 1 to column_count send DESCRIBE_COLUMN(stmt_handle, i); -- included: tablename, column name, column alias, type, nullability, scale & precision receive column description. end for -- There are other column info attributes worth sending such as: owner, searchable, signed/unsigned, updateable, case sensitive & autoincrement -- I will be quite content if we get the main ones specified above. for n set of parameters for i = 1 to param_count send PUT_DATA(stmt_handle, i, param_data[i]) end for send EXECUTE(stmt_handle) receive result set end for send FREE(stmt_handle)