Re: Problem with oids for table names getting out of sync?

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: Problem with oids for table names getting out of sync?
Дата
Msg-id 20070405141830.GA8702@alvh.no-ip.org
обсуждение исходный текст
Ответ на Re: Problem with oids for table names getting out of sync?  (omar <omar2@omnicode.com>)
Ответы Re: Problem with oids for table names getting out of sync?
Список pgsql-general
omar wrote:
>
> >>SELECT relfilenode, relname FROM pg_class WHERE relname !~ '^(pg_|sql_)'
> >>AND relkind = 'r'
> >>
> >            Oid o = PQftable(_res, i);
> >
> >
> >Um ... are you laboring under some delusion about relfilenode being the
> >same as relation OID?
> >
> >
> Apparently I am.  libpq docs claim that "You can query the system table
> pg_class to determine exactly which table is referenced." for PQftable.
> I query pg_class and the only column that looks remotely like a unique
> oid is relfilenode.

select oid, relname from pg_class where ...

relfilenode is just the file name given to the table, which is the same
as the OID when the table is just created, but changes after certain
operations (CLUSTER, TRUNCATE, REINDEX for indexes, maybe others)

--
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

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

Предыдущее
От: Scott Ribe
Дата:
Сообщение: Re: Using C# to create stored procedures
Следующее
От: Jaime Silvela
Дата:
Сообщение: Crash recovery