Thread: RelFileNode to Relation

RelFileNode to Relation

From
Soroosh Sardari
Date:
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

From
Tom Lane
Date:
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

From
Soroosh Sardari
Date:
<div dir="ltr"><br /><div class="gmail_extra"><div class="gmail_quote">On Sat, Oct 19, 2013 at 11:53 AM, Tom Lane <span
dir="ltr"><<ahref="mailto:tgl@sss.pgh.pa.us" target="_blank">tgl@sss.pgh.pa.us</a>></span> wrote:<br
/><blockquoteclass="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div
class="im">SorooshSardari <<a href="mailto:soroosh.sardari@gmail.com">soroosh.sardari@gmail.com</a>> writes:<br
/>> I need to get a Relation instance but I have only a RelFileNode!<br /><br /></div>Why do you think you need to
dothat?  Such a lookup is inherently the<br /> wrong thing, because relations' relfilenode values are not fixed
(unless<br/> you have a lock on the relation, which presumably you don't).<br /><br />                         regards,
tomlane<br /></blockquote></div><br /></div><div class="gmail_extra"><br /></div><div class="gmail_extra"
style="style">Iknow, it's against PG abstraction.</div><div class="gmail_extra" style="style">In PG we don't need to
knowanything about relation in the smgr level. but in my project i want to encrypt</div><div class="gmail_extra"
style="style">allpages of a particular relation and decrypt it when those pages are fetching back to buffer.</div><div
class="gmail_extra"style="style"><br /></div><div class="gmail_extra" style="style">This behavior depends on some
relationproperties. So in smgropen I must get some knowledge about the relation and all of i have is
RelFileNode.</div><divclass="gmail_extra" style="style"><br /></div><div class="gmail_extra" style="style">I can not
seethe pg_class for the relation oid, because smgropen may called before insertion in pg_class.</div><div
class="gmail_extra"style="style"><br /></div><div class="gmail_extra" style="style">Soroosh</div></div>