Re: RelFileNode to Relation

Lists: pgsql-hackers
From: Soroosh Sardari <soroosh(dot)sardari(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: RelFileNode to Relation
Date: 2013-10-19 07:33:51
Message-ID: CAFUsPDaOAogA4XbgW0fQn_TezRZ0TT4ZzP9Ty+Js=xroaiHB+g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Soroosh Sardari <soroosh(dot)sardari(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: RelFileNode to Relation
Date: 2013-10-19 08:23:57
Message-ID: 9372.1382171037@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Soroosh Sardari <soroosh(dot)sardari(at)gmail(dot)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


From: Soroosh Sardari <soroosh(dot)sardari(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: RelFileNode to Relation
Date: 2013-10-19 08:39:29
Message-ID: CAFUsPDYKcYwqYMMfDp=zsBtMZjCWXNSkVWWAJygcF-R_vksHpA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, Oct 19, 2013 at 11:53 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Soroosh Sardari <soroosh(dot)sardari(at)gmail(dot)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