Skip site navigation (1) Skip section navigation (2)

Re: Function proposal to find the type of a datum

From: Kate F <kate(at)cats(dot)meow(dot)at>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Function proposal to find the type of a datum
Date: 2007-02-02 07:31:13
Message-ID: 20070202073113.GA390@cats.meow.at (view raw or flat)
Thread:
Lists: pgsql-hackers
On Fri, Feb/ 2/07 02:17:51AM -0500, Tom Lane wrote:
> "Pavel Stehule" <pavel(dot)stehule(at)hotmail(dot)com> 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
> parameter then (I think) only IS OF ANYELEMENT would succeed.  Would it
> conform to the SQL spec for the test to "look through" ANYELEMENT to the
> actual parameter type?  Would it be reasonably implementable to do that?

Well, actually, I discussed this on IRC with Pavel, and for the above I
have syntax error at or near "INTEGER". My guess was that the grammar
changed as an unintentional side-effect of some other change. He corrected
his suggestion: OF takes a list of types; it needs parentheses:

    IF a IS OF (INTEGER) THEN

This operator would look wonderful for my particular needs, were it not
that it has completely different semantics! It appears to test to see
what a datum actually *is* (in my case TEXT), rather than what it may
be parsed as (in my case, INTEGER).


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.

Thank you,

-- 
Kate


In response to

pgsql-hackers by date

Next:From: Tom LaneDate: 2007-02-02 07:41:15
Subject: Re: Function proposal to find the type of a datum
Previous:From: Tom LaneDate: 2007-02-02 07:17:51
Subject: Re: Function proposal to find the type of a datum

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group