PREPARE and parameter types (Re: [INTERFACES] DBD::PostgreSQL) - Mailing list pgsql-hackers

From Tom Lane
Subject PREPARE and parameter types (Re: [INTERFACES] DBD::PostgreSQL)
Date
Msg-id 118.1037638710@sss.pgh.pa.us
Whole thread Raw
Responses Re: PREPARE and parameter types (Re: [INTERFACES] DBD::PostgreSQL)  (David Wheeler <david@wheeler.net>)
Re: PREPARE and parameter types (Re: [INTERFACES] DBD::PostgreSQL)  (Neil Conway <neilc@samurai.com>)
List pgsql-hackers
David Wheeler <david@wheeler.net> 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


pgsql-hackers by date:

Previous
From: "Zeugswetter Andreas SB SD"
Date:
Subject: Re: [GENERAL] DECLARE CURSOR
Next
From: David Wheeler
Date:
Subject: Re: PREPARE and parameter types (Re: [INTERFACES] DBD::PostgreSQL)