SPI_prepare for semi-unknown types

From: Alex Pilosov <alex(at)pilosoft(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: SPI_prepare for semi-unknown types
Date: 2001-06-22 04:33:19
Message-ID: Pine.BSO.4.10.10106220008300.29168-100000@spider.pilosoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Is there a way to call SPI_prepare in case the precise datatype is not
known?

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).

I understand that SPI_execute uses pg_parse_and_rewrite to do the actual
parsing and binding of function OIDs to the argument types. I'm looking at
transformExpr in parser/parse_expr.c, it seems to be the only place that
actually does it.

There, I'm not sure how would it handle the case where paramtype is
specified as 'char', but it actually may need to be cast to 'text' for
execution. I guess I can find out by just trying it, just wanted to ask
first. :)

Ideally, I would like to be able to say "I don't know what this parameter
is like, treat it like it would be treated coming in a fully-formed query
(i.e. using CSTRING conversions)", but I'm not sure if its possible.

Thanks to anyone who can offer some help.

-alex

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Olivier PRENANT 2001-06-22 07:53:56 Re: psql+openssl+uniware7
Previous Message Lincoln Yeoh 2001-06-22 04:13:52 Re: Multiple Indexing, performance impact