Re: Mysterious Bus Error with get_fn_expr_argtype() - Mailing list pgsql-hackers

From Brendan Jurd
Subject Re: Mysterious Bus Error with get_fn_expr_argtype()
Date
Msg-id 37ed240d0809012135k1a7621d5x2acf18b31c7f9281@mail.gmail.com
Whole thread Raw
In response to Re: Mysterious Bus Error with get_fn_expr_argtype()  ("David E. Wheeler" <david@kineticode.com>)
List pgsql-hackers
On Tue, Sep 2, 2008 at 2:03 PM, David E. Wheeler <david@kineticode.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


pgsql-hackers by date:

Previous
From: "David E. Wheeler"
Date:
Subject: Re: Mysterious Bus Error with get_fn_expr_argtype()
Next
From: "Hitoshi Harada"
Date:
Subject: Re: Window functions patch v04 for the September commit fest