Обсуждение: RelFileNode to Relation

Поиск
Список
Период
Сортировка

RelFileNode to Relation

От
Soroosh Sardari
Дата:
Hi

I need to get a Relation instance but I have only a RelFileNode!
I see the relcache.h, only the following function seems helpful

extern Relation RelationIdGetRelation(Oid relationId);

However, there is another problem, In the RelFileNode, only relNode exist and as comment said this is equivalent to pg_class.relfilenode and in some situation relation oid (pg_class.oid) and relation file node are not the same.

So i cant use above function!

Any idea?

Regards,
Soroosh Sardari
Sharif University of Tech.

Re: RelFileNode to Relation

От
Tom Lane
Дата:
Soroosh Sardari <soroosh.sardari@gmail.com> writes:
> I need to get a Relation instance but I have only a RelFileNode!

Why do you think you need to do that?  Such a lookup is inherently the
wrong thing, because relations' relfilenode values are not fixed (unless
you have a lock on the relation, which presumably you don't).
        regards, tom lane



Re: RelFileNode to Relation

От
Soroosh Sardari
Дата:

On Sat, Oct 19, 2013 at 11:53 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Soroosh Sardari <soroosh.sardari@gmail.com> writes:
> I need to get a Relation instance but I have only a RelFileNode!

Why do you think you need to do that?  Such a lookup is inherently the
wrong thing, because relations' relfilenode values are not fixed (unless
you have a lock on the relation, which presumably you don't).

                        regards, tom lane


I know, it's against PG abstraction.
In PG we don't need to know anything about relation in the smgr level. but in my project i want to encrypt
all pages of a particular relation and decrypt it when those pages are fetching back to buffer.

This behavior depends on some relation properties. So in smgropen I must get some knowledge about the relation and all of i have is RelFileNode.

I can not see the pg_class for the relation oid, because smgropen may called before insertion in pg_class.

Soroosh