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.
You mentioned that the postgres crashes. Did you mean it caused a Segmentation fault or something else like PANIC?
If possible, can you share a core dump in that case?
Also, can you share any errors that you see in logs when postgres crashes?