Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 17926475E6F for ; Mon, 18 Nov 2002 11:58:26 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 4B682475DC8 for ; Mon, 18 Nov 2002 11:58:25 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id gAIGwUhR000119; Mon, 18 Nov 2002 11:58:30 -0500 (EST) To: David Wheeler Cc: pgsql-hackers@postgreSQL.org Subject: PREPARE and parameter types (Re: [INTERFACES] DBD::PostgreSQL) In-reply-to: References: Comments: In-reply-to David Wheeler message dated "Mon, 18 Nov 2002 08:27:33 -0800" Date: Mon, 18 Nov 2002 11:58:30 -0500 Message-ID: <118.1037638710@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/773 X-Sequence-Number: 31989 David Wheeler writes: > On Monday, November 18, 2002, at 08:19 AM, Tom Lane wrote: >> There are various ways to retrieve the datatypes of the columns of a >> table, but I'm not sure how that helps you to determine the parameter >> types for an arbitrary SQL command to be prepared. Are you assuming >> a specific structure of the command you want to prepare? > Ouch, good point. I don't want to go there. It's a shame, really, but > in light of this requirement, I don't see how PostgreSQL prepared > statements can be supported by the DBI. Pity; I was really looking > forward to the performance boost. Thinking about this, it occurs to me that there's no good reason why we couldn't allow parameter symbols ($n) to be considered type UNKNOWN initially. The type interpretation algorithms would then treat them just like quoted literal constants. After parsing finishes, PREPARE could scan the tree to see what type each symbol had been cast to. (You'd have to raise an error if multiple appearances of the same symbol had been cast to different types, but that'd be an uncommon case.) This form of PREPARE would presumably need some way of reporting back the types it had determined for the symbols; anyone have a feeling for the appropriate API for that? regards, tom lane