Re: Function proposal to find the type of a datum

From: Kate F <kate(at)cats(dot)meow(dot)at>
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Function proposal to find the type of a datum
Date: 2007-02-02 16:04:57
Message-ID: 20070202160457.GD390@cats.meow.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Feb/ 2/07 10:09:24AM +0000, 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
> >difference between this and IS OF in the way I had imagined.
>
> It's not even possible to have a function that determines the type of a
> value given that we have overlapping types. How do you know that "2"
> isn't an int8 rather than int4, or numeric, or just text. What about
> 'now'? That's a valid timestamp as well as text.

Yes, quite. I understand this; I'd just misunderstood what
get_fn_expr_argtype() did.

> Now, if we had an can_be_cast_to(TEXT-VAL,TYPE) that would at least let
> you check against a pre-determined list of types. The only way I know of
> at present is to trap an exception if it fails.

That's exactly what I'm doing, currently.

> I think you're going to have to store your arguments with their types.

I may do!

Regards,

--
Kate

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2007-02-02 16:10:37 Re: --enable-debug does not work with gcc
Previous Message Neil Conway 2007-02-02 15:54:44 Re: Enums patch v2