SPI_prepare for semi-unknown types
От | Alex Pilosov |
---|---|
Тема | SPI_prepare for semi-unknown types |
Дата | |
Msg-id | Pine.BSO.4.10.10106220008300.29168-100000@spider.pilosoft.com обсуждение исходный текст |
Ответы |
Re: SPI_prepare for semi-unknown types
|
Список | 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
В списке pgsql-hackers по дате отправления: