Re: SPI_prepare for semi-unknown types - Mailing list pgsql-hackers

From Tom Lane
Subject Re: SPI_prepare for semi-unknown types
Date
Msg-id 3257.993217121@sss.pgh.pa.us
Whole thread Raw
In response to SPI_prepare for semi-unknown types  (Alex Pilosov <alex@pilosoft.com>)
List pgsql-hackers
Alex Pilosov <alex@pilosoft.com> writes:
> Example, having a statement like 'select count(*) from foo where
> fieldname=$1' where I know that $1 is a stringish type and it _should_ be
> convertable using xxx_in (CString-to-datum conversion functions), however,
> I do not know the precise type (could be name or varchar or text).

Declare the parameter as text, and then coerce what you are given to
text before you execute the statement.  You don't get any free
adaptation to new datatypes in an already-completed plan.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Ed Loehr
Date:
Subject: Re: [GENERAL] Call for alpha testing: planner statistics revisions
Next
From: Tom Lane
Date:
Subject: Re: psql+openssl+uniware7