Re: Getting table name/tuple from OID

Поиск
Список
Период
Сортировка
От uwcssa
Тема Re: Getting table name/tuple from OID
Дата
Msg-id f2f562510511111952q417e0646p89d9b889fd01b5c9@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Getting table name/tuple from OID  (Marek Lewczuk <newsy@lewczuk.com>)
Список pgsql-hackers
Thanks for the quick reply. I made a mistake last time by asking the question:
actually, i would like to know how to get the OID from a table name or operator name.
 
For example, ">" is 512 while "="  is 96.   and some table has the magic relid of 20078, say.
How could I find out the OID by giving the (full qualified) name of a table or an operator?
 
I need this since I want to build a query plan from external and I need to know the OID
in order to manually create the query plan. Thanks.
 
 

> I am interested in the answer as well -- how to get a table name (or
> an operator name)
> from an OID.    the parser must know how to do this, but the segment
> of code is hard
> to locate.
>
CREATE OR REPLACE FUNCTION gettablename(__oid oid)
  RETURNS "varchar" AS
$BODY$
SELECT (_sna.nspname || '.' || _tna.relname) AS tableQualifiedName FROM
pg_class _tna, pg_namespace _sna WHERE _tna.oid = $1 AND _sna.oid =
_tna.relnamespace;
$BODY$
  LANGUAGE 'sql' IMMUTABLE;
ALTER FUNCTION gettablename(__oid oid) OWNER TO root;



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

Предыдущее
От: Rod Taylor
Дата:
Сообщение: Re: MERGE vs REPLACE
Следующее
От: Matteo Beccati
Дата:
Сообщение: Re: MERGE vs REPLACE