question about relation_open - Mailing list pgsql-hackers

From Giampaolo Capelli
Subject question about relation_open
Date
Msg-id CAJ=H7uyBuUTsc0xmkJhuNA+X8LDYzM__nkm+ZvRfsReNjsbF4Q@mail.gmail.com
Whole thread Raw
Responses Re: question about relation_open
Re: question about relation_open
List pgsql-hackers
Hi there,
I'm trying to write an extension to study the internals of Postgresql, and I face a server crash after calling the function relation_open.

I want to call the function ReadBufferExtended
to get the raw data of a given buffer
and I've read in some examples that I need to call relation_open
first, in order to get a Relation variable and also lock the relation.

The function relation_open returns a non NULL pointer in my extension, but then the last line in the following snippet crashes postgres.

Relation rel;
rel = relation_open(relid, AccessShareLock);

Assert(rel != NULL);
Assert(rel->rd_rel != NULL);
Assert(rel->rd_id != NULL);
elog(INFO, "rel->rd_id not null");
Oid rd_id = rel->rd_id;


Could somebody please help me understand what I'm doing wrong?
(Sorry if this is not the correct mailing list)

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: AIO v2.2
Next
From: Dean Rasheed
Date:
Subject: Re: [PATCH] Add get_bytes() and set_bytes() functions