Re: Access to current database from C-language function - Mailing list pgsql-hackers

From Florian Pflug
Subject Re: Access to current database from C-language function
Date
Msg-id 0AF8F9DC-54B4-44B3-B212-50264E3E8A1D@phlo.org
Whole thread Raw
In response to Re: Access to current database from C-language function  (Achim Domma <domma@procoders.net>)
Responses Re: Access to current database from C-language function
List pgsql-hackers
On Jul25, 2011, at 22:31 , Achim Domma wrote:
> Am 25.07.2011 um 14:48 schrieb Florian Pflug:
>> A more low-level API is provided by {heap,index}_{beginscan,endscan}, heap_{insert,update,delete} and index_insert.
However,correct handling of transactions using this API isn't easy - for example, to update a row you'd first have to
findthe latest version of that row, then decide if you're allowed to update it, and finally create a new version. 
>
> I see the problems with the second approach, but that's definitively what I would like to do.

You're in for a lot of work, then. I still suggest that you explain your ultimate goals before you embark on your
endeavor- people might be able to point our easier ways to achieve those. 

> But I'm only interested in reading, which will hopefully make it a bit easier.

Maybe. But note that if you want your code to be correct for all transaction isolation level, you have to be quite
carefuleven when only reading. Especially from postgres 9.1 forward, due to the new true serializability feature of
thatrelease. 

> Could you guide me to a starting point? Assuming my database has a table T with an index I. How do I get access to
thatindex? 

I suggest you start by reading nodeIndexScan.c. This is the code the query executor uses to implement index scans.
However,before you embark on your endeavor. 

best regards,
Florian Pflug



pgsql-hackers by date:

Previous
From: Jim Nasby
Date:
Subject: Re: libedit memory stomp is apparently fixed in OS X Lion
Next
From: David Fetter
Date:
Subject: Re: Update releases