| From: | Omar Eljumaily <omar2(at)omnicode(dot)com> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Problem with oids for table names getting out of sync? |
| Date: | 2007-04-05 14:55:05 |
| Message-ID: | 46150DC9.1090606@omnicode.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Alvaro and Tom, thanks so much. I was getting worried that I was going
to have to ask my customers to dump and restore periodically, ugh. I
think I need to learn a bit more about postgresql internals to help me
with my project. Not thinking about selecting for oids is kind of
embarrassing.
Thanks,
Omar
Alvaro Herrera wrote:
> 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)
>
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2007-04-05 14:55:55 | Re: Print database name |
| Previous Message | Tom Lane | 2007-04-05 14:45:12 | Re: Cron'd dumpall failing? |