Re: Inability to cast regclass is too restrictive

Поиск
Список
Период
Сортировка
От Joe Conway
Тема Re: Inability to cast regclass is too restrictive
Дата
Msg-id 41675769.6020600@joeconway.com
обсуждение исходный текст
Ответ на Inability to cast regclass is too restrictive  (Oliver Elphick <olly@lfix.co.uk>)
Список pgsql-hackers
Oliver Elphick wrote:
> 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.
> 
> This seems overly restrictive.  Would there be a problem in allowing
> regclass() to be cast to text?
> 

I agree (I've been frustrated by this myself before), but for a 
workaround, see the following:

create or replace function any2text(anyelement) returns text as'
begin return $1;
end
' language plpgsql;

select any2text(1255::oid::regclass) || ' is the relname in text';            ?column?
-------------------------------- pg_proc is the relname in text
(1 row)

HTH,

Joe


В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Dann Corbit"
Дата:
Сообщение: Re: APR 1.0 released
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: Allow change of kerberos service name without recompilation