Re: calling a C function from pgsql function

From: Craig Ringer <ringerc(at)ringerc(dot)id(dot)au>
To: tamanna madaan <tamanna(dot)madaan(at)globallogic(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: calling a C function from pgsql function
Date: 2012-08-29 13:35:39
Message-ID: 503E1AAB.8060504@ringerc.id.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 08/29/2012 09:18 PM, tamanna madaan wrote:

> 1. what are the ways to get the value returned by this library function .

You need to wrap the C library function with a PostgreSQL C extension
that uses the fmgr.h APIs, so it's callable from SQL and can return a
result to SQL. See:

http://www.postgresql.org/docs/current/static/xfunc-c.html

> 2. when test1 is called, will it wait for "test1" to return before
> continuing with the next statement in "test" or it will continue with
> the next statement parallely while "test1" is being executed.

The call will return when the C wrapper function returns, so they'll be
executed in series not in parallel.

> 3. Moreover, will test1 be called sequentially in order for all the
> three arguments i.e arg1 first and arg3 in last. Or there can be a
> different order.

The calls will be executed in the order they appear in the PL/PgSQL
function.

--
Craig Ringer

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2012-08-29 13:37:22 Re: calling a C function from pgsql function
Previous Message Chris Angelico 2012-08-29 13:33:05 Re: PQfformat question and retrieving bytea data in C