C Function with Arrays Question - Mailing list pgsql-general

From Achilleus Mantzios
Subject C Function with Arrays Question
Date
Msg-id 02032614000004.09965@pc216
Whole thread Raw
Responses Re: C Function with Arrays Question
List pgsql-general
Hi,
Is there a way of accessing _float8 (float8[]) values inside of
a server-side C function??

For instance imagine:

# \d formulatest
           Table "formulatest"
 Column  |        Type        | Modifiers
---------+--------------------+-----------
 formula | double precision[] |

# insert into formulatest values('{2.3,3.3}');
# insert into formulatest values('{4.3,5.3}');

and then write a C function named formula

float8 *formula(x,formarray)
float8 *x;
_float8 *formarray; /* This is serious part of the question!! */
{
    float8 *result = (float8 *) malloc(sizeof(float8));
    /* what happened to palloc in pgsql 7.2??,
    * Also what happened to postgres.h??
    */

    *result = *formarray[0];
    return result;
/* This is pseudo code to demonstrate the question */
}

Thanx.

P.S.

7.2 runs quite stable on my Linux 2.4.7.
JDBC built without a problem, and also supports Arrays (at least one
dimension for sure).

--
Achilleus Mantzios
S/W Engineer
IT dept
Dynacom Tankers Mngmt
tel:    +30-10-8981112
fax:    +30-10-8981877
email:  it@dynacomtm.com
        rnd@gatewaynet.com


pgsql-general by date:

Previous
From: "Gyorgy Molnar"
Date:
Subject: PL/pgsql return more than one values
Next
From: "Arsalan Zaidi"
Date:
Subject: Speed diff cause by multi-byte support