Re: Getting table name/tuple from OID

From: uwcssa <uwcssa(at)gmail(dot)com>
To: Marek Lewczuk <newsy(at)lewczuk(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Getting table name/tuple from OID
Date: 2005-11-12 03:52:00
Message-ID: f2f562510511111952q417e0646p89d9b889fd01b5c9@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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;
>
>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Yann Michel 2005-11-12 06:04:58 CONNECT BY PRIOR
Previous Message Rod Taylor 2005-11-12 03:07:07 Re: MERGE vs REPLACE