SPI/backend equivalent of extended-query Describe(statement)? - Mailing list pgsql-hackers

From Chapman Flack
Subject SPI/backend equivalent of extended-query Describe(statement)?
Date
Msg-id 5AF91ACF.30706@anastigmatix.net
Whole thread Raw
Responses Re: SPI/backend equivalent of extended-query Describe(statement)?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
The longer version of $subject is: how would one go about, in the
backend using SPI (or SPI and maybe other server APIs as needed),
obtaining the same inferred parameter information that a front-end
client can get with the Describe (statement variant) extended-query
message?

I ask because I've stumbled on this 14½ year old (earliest days!) comment
in PL/Java's PreparedStatement.getParameterMetaData():

* Due to the design of the <code>SPI_prepare</code>, it is currently
* impossible to obtain the correct parameter meta data before all the
* parameters have been set, hence a ParameterMetaData obtained prior to
* setting the paramteres will have all parameters set to the default type
* {@link Types#VARCHAR}.
* Once the parameters have been set, a fair attempt is made to generate this
* object based on the supplied values.

Apparently it seemed difficult at the time to implement a
getParameterMetaData that could tell you the thing you want to know
(what parameter types are expected so you can supply them), but less
difficult to implement something that can't tell you until you've
supplied them and then tells you what you supplied. Problem solved,
in a way that's entertaining but a little short on utility. :)

I'll admit that in my own perusal of the SPI docs, I don't see an
obvious advertised way to get that information about a prepared
statement, either. But the information has to exist somewhere, and
a remote client is able to ask for it, so where should I be looking
for the means of retrieving it in the backend?

-Chap


pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: Needless additional partition check in INSERT?
Next
From: Amit Langote
Date:
Subject: Re: Incorrect comment in get_partition_dispatch_recurse