Re: [HACKERS] Access to current database from C-language function

2011-08-02 Thread Achim Domma
Am 01.08.2011 um 21:37 schrieb Merlin Moncure: I think David is probably right and this can be handled in pure sql simply and easily (perhaps in a function, perhaps not). The SPI interface is great, but the sql and plpgsql languages are very powerful and should always be preferred over a C

Re: [HACKERS] Access to current database from C-language function

2011-08-01 Thread Achim Domma
Am 26.07.2011 um 00:40 schrieb Florian Pflug: 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

Re: [HACKERS] Access to current database from C-language function

2011-08-01 Thread Florian Pflug
On Aug1, 2011, at 13:23 , Achim Domma wrote: I have tables which store two integer IDs and a floating point rank. So the table MyTable might have these columns: EntityID - int PropertyID - int Rank - float My algorithm needs to retrieve EntityID-Rank-Pairs for some given PropertyIDs.

Re: [HACKERS] Access to current database from C-language function

2011-08-01 Thread David Fetter
On Mon, Aug 01, 2011 at 01:23:26PM +0200, Achim Domma wrote: Am 26.07.2011 um 00:40 schrieb Florian Pflug: 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},

Re: [HACKERS] Access to current database from C-language function

2011-08-01 Thread Robert Haas
On Mon, Aug 1, 2011 at 11:04 AM, David Fetter da...@fetter.org wrote: SQL is Turing-complete, so the chances are excellent that it's possible to express that algorithm in it. ;) Look into common table expressions for iteration/recursion, and windowing functions, commonly used for time series.

Re: [HACKERS] Access to current database from C-language function

2011-08-01 Thread Merlin Moncure
On Mon, Aug 1, 2011 at 10:18 AM, Robert Haas robertmh...@gmail.com wrote: On Mon, Aug 1, 2011 at 11:04 AM, David Fetter da...@fetter.org wrote: SQL is Turing-complete, so the chances are excellent that it's possible to express that algorithm in it. ;) Look into common table expressions for

[HACKERS] Access to current database from C-language function

2011-07-25 Thread Achim Domma
Hi, I have read http://www.postgresql.org/docs/9.1/static/xfunc-c.html and my idea is, to write a C function which returns a set of rows. To generate the result set, I would like to access indexes directly using the information I found at http://www.postgresql.org/docs/9.1/static/indexam.html.

Re: [HACKERS] Access to current database from C-language function

2011-07-25 Thread Florian Pflug
On Jul25, 2011, at 13:40 , Achim Domma wrote: I have read http://www.postgresql.org/docs/9.1/static/xfunc-c.html and my idea is, to write a C function which returns a set of rows. To generate the result set, I would like to access indexes directly using the information I found at

Re: [HACKERS] Access to current database from C-language function

2011-07-25 Thread Achim Domma
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 find the

Re: [HACKERS] Access to current database from C-language function

2011-07-25 Thread Florian Pflug
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,