Re: [HACKERS] Function proposal to find the type of a datum

2007-02-02 Thread Kate F
On Fri, Feb/ 2/07 11:37:13AM -0500, Tom Lane wrote: > Kate F <[EMAIL PROTECTED]> writes: > > So, to conclude, we still have a valid use-case (which you explained a > > little more explicitly than I did). Shall I attempt to implement it? > > (that is, type_name_of() which returns TEXT) > > I think

Re: [HACKERS] Function proposal to find the type of a datum

2007-02-02 Thread Tom Lane
Kate F <[EMAIL PROTECTED]> writes: > So, to conclude, we still have a valid use-case (which you explained a > little more explicitly than I did). Shall I attempt to implement it? > (that is, type_name_of() which returns TEXT) I think I'd suggest pg_type_name ... or maybe pg_type_name_of ... also,

Re: [HACKERS] Function proposal to find the type of a datum

2007-02-02 Thread Kate F
On Fri, Feb/ 2/07 11:17:46AM -0500, Tom Lane wrote: > Kate F <[EMAIL PROTECTED]> writes: > > (And whatever the decision regarding ANYELEMENT of, I believe this > > should behave the same as IS OF) > > In the light of morning I think it may be a non-problem. The way that a > plpgsql function with

Re: [HACKERS] Function proposal to find the type of a datum

2007-02-02 Thread Tom Lane
Kate F <[EMAIL PROTECTED]> writes: > (And whatever the decision regarding ANYELEMENT of, I believe this > should behave the same as IS OF) In the light of morning I think it may be a non-problem. The way that a plpgsql function with an ANYELEMENT parameter really works is that on first invocation

Re: [HACKERS] Function proposal to find the type of a datum

2007-02-02 Thread Kate F
On Fri, Feb/ 2/07 09:52:08AM -0500, Tom Lane wrote: > Kate F <[EMAIL PROTECTED]> writes: > > In my case, I am constructing a query (to be exexecuted dynamically) > > wherein I pass along some of the arguments I am given. This query calls > > a function specified by an argument passed to me. If that

Re: [HACKERS] Function proposal to find the type of a datum

2007-02-02 Thread Kate F
On Fri, Feb/ 2/07 10:09:24AM +, Richard Huxton wrote: > Kate F wrote: > >I see my misunderstanding: '2' IS OF (INTEGER) yields false: fine. > >However I was expecting that pg_type_of('2') would return 'INTEGER': it > >wouldn't, of course. So, I understand you here: there would be no > >differen

Re: [HACKERS] Function proposal to find the type of a datum

2007-02-02 Thread Tom Lane
Kate F <[EMAIL PROTECTED]> writes: > In my case, I am constructing a query (to be exexecuted dynamically) > wherein I pass along some of the arguments I am given. This query calls > a function specified by an argument passed to me. If that function is > overloaded, I need to be able to cast its arg

Re: [HACKERS] Function proposal to find the type of a datum

2007-02-02 Thread Richard Huxton
Kate F wrote: I see my misunderstanding: '2' IS OF (INTEGER) yields false: fine. However I was expecting that pg_type_of('2') would return 'INTEGER': it wouldn't, of course. So, I understand you here: there would be no difference between this and IS OF in the way I had imagined. It's not even p

Re: [HACKERS] Function proposal to find the type of a datum

2007-02-02 Thread Kate F
On Fri, Feb/ 2/07 03:06:19AM -0500, Tom Lane wrote: > Kate F <[EMAIL PROTECTED]> writes: > > The difference between OF and this function is that this function is > > pulling the type from the datum, rather than explicitly testing it > > against types the user suggests. If I wanted to find the type

Re: [HACKERS] Function proposal to find the type of a datum

2007-02-02 Thread Tom Lane
Kate F <[EMAIL PROTECTED]> writes: > The difference between OF and this function is that this function is > pulling the type from the datum, rather than explicitly testing it > against types the user suggests. If I wanted to find the type of x > using OF, I would have to check it for all types whic

Re: [HACKERS] Function proposal to find the type of a datum

2007-02-01 Thread Kate F
On Fri, Feb/ 2/07 02:41:15AM -0500, Tom Lane wrote: > > > Meanwhile, I still think the function David proposed is a worthy > > addition (and I still have a user-case for it!), as using just the OF > > operator for something similar, one would have to explictly test > > against every type required.

Re: [HACKERS] Function proposal to find the type of a datum

2007-02-01 Thread Tom Lane
Kate F <[EMAIL PROTECTED]> writes: > ... OF takes a list of types; it needs parentheses: > IF a IS OF (INTEGER) THEN Oh, right, minor detail. > Meanwhile, I still think the function David proposed is a worthy > addition (and I still have a user-case for it!), as using just the OF > operator f

Re: [HACKERS] Function proposal to find the type of a datum

2007-02-01 Thread Kate F
On Fri, Feb/ 2/07 02:17:51AM -0500, Tom Lane wrote: > "Pavel Stehule" <[EMAIL PROTECTED]> writes: > > you can identify type via operator OF. > > > IF a IS OF INTEGER THEN > > RAISE NOTICE 'Parametr a is numeric'; > > Yeah, that is the SQL-standard syntax, but I think our implementation > do

Re: [HACKERS] Function proposal to find the type of a datum

2007-02-01 Thread Tom Lane
"Pavel Stehule" <[EMAIL PROTECTED]> writes: > you can identify type via operator OF. > IF a IS OF INTEGER THEN > RAISE NOTICE 'Parametr a is numeric'; Yeah, that is the SQL-standard syntax, but I think our implementation doesn't work the way Kate would like: if "a" is an ANYELEMENT function

Re: [HACKERS] Function proposal to find the type of a datum

2007-02-01 Thread Pavel Stehule
Hello, you can identify type via operator OF. like: IF a IS OF INTEGER THEN RAISE NOTICE 'Parametr a is numeric'; ELSIF a IS OF varchar THEN RAISE NOTICE 'Parametr a is string'; END IF; Regards Pavel Stehule _ Citite se