Re: Help requd in writing functions in C and using in Postgres

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Help requd in writing functions in C and using in Postgres
Дата
Msg-id 20060620223220.GA69870@winnie.fuhr.org
обсуждение исходный текст
Ответ на Re: Help requd in writing functions in C and using in Postgres  ("Jasbinder Bali" <jsbali@gmail.com>)
Список pgsql-general
On Tue, Jun 20, 2006 at 02:03:06PM -0400, Jasbinder Bali wrote:
> Does that mean I can't make a function in C that will have all the database
> transactions and then would just be included in the Stored Procedure in
> postgres (though i know there is no concept of stored procs in postgres, its
> all functions that you have in it).

Functions are executed in the context of an outer transaction, so
if you need multiple transactions then you'll have to initiate them
from the client side.  However, as I mentioned, a server-side
function could connect to the database and act as a client, so that
would be one way to execute multiple transactions via a server-side
function.  A possible drawback of doing so is that if the function
is called from a transaction that's later rolled back, the statements
that the function executed over its client connection would have
already been committed and thus wouldn't be rolled back.

> Also when i say include <postgres.h>, my function would not find it coz its
> in some different path altogether. Where exactly is this postgres.h and
> other postgres header files??

The "C-Language Functions" documentation I previously sent explains
how to find include files, but if you use the PGXS build infrastructure
then you don't need to worry about it.

http://www.postgresql.org/docs/8.1/interactive/xfunc-c.html#AEN32313
http://www.postgresql.org/docs/8.1/interactive/xfunc-c.html#DFUNC
http://www.postgresql.org/docs/8.1/interactive/xfunc-c.html#XFUNC-C-PGXS

--
Michael Fuhr

В списке pgsql-general по дате отправления:

Предыдущее
От: simon
Дата:
Сообщение: Re: merge result sets
Следующее
От: "Florian G. Pflug"
Дата:
Сообщение: Re: Adding foreign key constraints without integrity check?