| From: | "Brendan Jurd" <direvus(at)gmail(dot)com> |
|---|---|
| To: | "David E(dot) Wheeler" <david(at)kineticode(dot)com> |
| Cc: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "PostgreSQL Hackers" <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Mysterious Bus Error with get_fn_expr_argtype() |
| Date: | 2008-09-02 04:35:55 |
| Message-ID: | 37ed240d0809012135k1a7621d5x2acf18b31c7f9281@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Tue, Sep 2, 2008 at 2:03 PM, David E. Wheeler <david(at)kineticode(dot)com> wrote:
> BTW, anyone have any interest in this function in core? Its purpose is to
> return a string identifying the data type of its argument. It's useful for
> dynamically building queries to pass to PL/pgSQL's EXECUTE statement when
> you don't know the data types of values you're putting into the statement.
>
+1. I've been using a variation on this theme (it returns the type
OID, not a text value) for a couple of years. I find it very helpful
for troubleshooting queries where I need to track the cast/coercion
behaviour.
For the record, my version of the function is simply:
PG_FUNCTION_INFO_V1(gettype);
Datum gettype(PG_FUNCTION_ARGS)
{
PG_RETURN_OID(get_fn_expr_argtype(fcinfo->flinfo, 0));
}
CREATE OR REPLACE FUNCTION gettype(anyelement) RETURNS oid AS
'libname', 'gettype'
LANGUAGE C IMMUTABLE STRICT;
Cheers,
BJ
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Hitoshi Harada | 2008-09-02 04:46:46 | Re: Window functions patch v04 for the September commit fest |
| Previous Message | David E. Wheeler | 2008-09-02 04:03:21 | Re: Mysterious Bus Error with get_fn_expr_argtype() |