Re: [HACKERS] Mysterious Bus Error with get_fn_expr_argtype()

2008-09-02 Thread David E. Wheeler
On Sep 1, 2008, at 22:31, Brendan Jurd wrote: Oh, another thing: it shouldn't be STRICT. Nulls have perfectly good types. Agreed. Barring any further comments/objections, I'll go ahead and prepare a patch to add this to core. So it will return a text representation or an Oid? Best,

Re: [HACKERS] Mysterious Bus Error with get_fn_expr_argtype()

2008-09-02 Thread Martijn van Oosterhout
On Tue, Sep 02, 2008 at 08:58:04AM -0700, David E. Wheeler wrote: Barring any further comments/objections, I'll go ahead and prepare a patch to add this to core. So it will return a text representation or an Oid? Hopefully regtype. The function doesn't need changing, but then users can get a

Re: [HACKERS] Mysterious Bus Error with get_fn_expr_argtype()

2008-09-02 Thread David E. Wheeler
On Sep 2, 2008, at 08:58, David E. Wheeler wrote: On Sep 1, 2008, at 22:31, Brendan Jurd wrote: Oh, another thing: it shouldn't be STRICT. Nulls have perfectly good types. Agreed. Barring any further comments/objections, I'll go ahead and prepare a patch to add this to core. So it

Re: [HACKERS] Mysterious Bus Error with get_fn_expr_argtype()

2008-09-02 Thread David E. Wheeler
On Sep 2, 2008, at 10:43, David E. Wheeler wrote: Looks like regtype displays as an integer. So how about pg_regtypeof() and pg_typeof()? Sorry, make that: PG_FUNCTION_INFO_V1(pg_regtypeof); Datum pg_regtypeof(PG_FUNCTION_ARGS) { PG_RETURN_OID(get_fn_expr_argtype(fcinfo-flinfo, 0)); }

Re: [HACKERS] Mysterious Bus Error with get_fn_expr_argtype()

2008-09-02 Thread Tom Lane
David E. Wheeler [EMAIL PROTECTED] writes: Looks like regtype displays as an integer. Better try that again. regression=# select 1043::regtype; regtype --- character varying (1 row) regression=# I see no need for two functions here.

Re: [HACKERS] Mysterious Bus Error with get_fn_expr_argtype()

2008-09-02 Thread David E. Wheeler
On Sep 2, 2008, at 11:06, Tom Lane wrote: Better try that again. regression=# select 1043::regtype; regtype --- character varying (1 row) regression=# I see no need for two functions here. Oh. I tried: try=# select 1::regtype; regtype - 1 I had assumed that

Re: [HACKERS] Mysterious Bus Error with get_fn_expr_argtype()

2008-09-01 Thread Tom Lane
David E. Wheeler [EMAIL PROTECTED] writes: Here's the complete code: Looks like you forgot PG_FUNCTION_INFO_V1(), so what's being passed to this isn't an fcinfo ... regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes

Re: [HACKERS] Mysterious Bus Error with get_fn_expr_argtype()

2008-09-01 Thread David E. Wheeler
On Sep 1, 2008, at 16:55, Tom Lane wrote: David E. Wheeler [EMAIL PROTECTED] writes: Here's the complete code: Looks like you forgot PG_FUNCTION_INFO_V1(), so what's being passed to this isn't an fcinfo ... Bah! I knew I had to be missing something really fundamental. Thanks Tom. BTW,

Re: [HACKERS] Mysterious Bus Error with get_fn_expr_argtype()

2008-09-01 Thread Brendan Jurd
On Tue, Sep 2, 2008 at 2:03 PM, David E. Wheeler [EMAIL PROTECTED] 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

Re: [HACKERS] Mysterious Bus Error with get_fn_expr_argtype()

2008-09-01 Thread Neil Conway
On Mon, Sep 1, 2008 at 9:35 PM, Brendan Jurd [EMAIL PROTECTED] wrote: +1. I've been using a variation on this theme (it returns the type OID, not a text value) for a couple of years. Returning regtype seems like the natural choice. -Neil -- Sent via pgsql-hackers mailing list

Re: [HACKERS] Mysterious Bus Error with get_fn_expr_argtype()

2008-09-01 Thread Tom Lane
Neil Conway [EMAIL PROTECTED] writes: On Mon, Sep 1, 2008 at 9:35 PM, Brendan Jurd [EMAIL PROTECTED] wrote: +1. I've been using a variation on this theme (it returns the type OID, not a text value) for a couple of years. Returning regtype seems like the natural choice. I was just about to

Re: [HACKERS] Mysterious Bus Error with get_fn_expr_argtype()

2008-09-01 Thread Brendan Jurd
On Tue, Sep 2, 2008 at 2:57 PM, Tom Lane [EMAIL PROTECTED] wrote: Neil Conway [EMAIL PROTECTED] writes: Returning regtype seems like the natural choice. I was just about to say the same. Yes. In fact, the way I typically use the function is to write gettype(whatever)::regtype. I was too