Re: Inability to cast regclass is too restrictive

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Inability to cast regclass is too restrictive
Date: 2004-10-09 06:18:56
Message-ID: 1097302736.30202.951.camel@linda
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, 2004-10-09 at 05:35, Tom Lane wrote:
> Oliver Elphick <olly(at)lfix(dot)co(dot)uk> writes:
> > I tried to use regclass() in a plpgsql function to derive a tablename
> > from its oid so as to build a command string, but I am unable to use the
> > value returned because it cannot be cast to anything. Therefore I will
> > have to use a complex query on the catalog to do the same work.
>
> Hmm? plpgsql is about as permissive as you can get on this point.
> Just assign the result to a variable of the desired type, and it will
> do it if the textual representations are at all compatible. Example:
>
> regression=# create function foo(oid) returns text as '
...
>
> I'm on record that we should allow (explicit) casting to and from text
> for all types, using the types' I/O functions to implement it. But
> plpgsql already provides essentially that mechanism in its assignment
> operations. You just hafta do the explicit assignment...

Thanks for the example. I was trying to do

cmd = ''SELECT * FROM '' || regclass(someoid);

--
Oliver Elphick olly(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
"Every good gift and every perfect gift is from above,
and cometh down from the Father of lights, with whom
is no variableness, neither shadow of turning."
James 1:17

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Davie 2004-10-09 06:45:57 Re: [BUGS] BUG #1270: stack overflow in thread in fe_getauthname
Previous Message Tom Lane 2004-10-09 05:06:58 Re: [BUGS] BUG #1270: stack overflow in thread in fe_getauthname