pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedC Function with Arrays Question
2+ messages / 2 participants
[nested] [flat]
* C Function with Arrays Question
@ 2002-03-26 12:00 Achilleus Mantzios <rnd@gatewaynet.com>
0 siblings, 1 reply; 2+ messages in thread
From: Achilleus Mantzios @ 2002-03-26 12:00 UTC (permalink / raw)
To: pgsql-sql; +Cc: pgsql-general@postgresql.org
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
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: C Function with Arrays Question
@ 2002-03-26 15:33 Tom Lane <tgl@sss.pgh.pa.us>
parent: Achilleus Mantzios <rnd@gatewaynet.com>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2002-03-26 15:33 UTC (permalink / raw)
To: Achilleus Mantzios <rnd@gatewaynet.com>; +Cc: pgsql-general@postgresql.org
Achilleus Mantzios <rnd@gatewaynet.com> writes:
> Is there a way of accessing _float8 (float8[]) values inside of
> a server-side C function??
There are some examples in the "FLOAT AGGREGATE OPERATORS" section of
src/backend/utils/adt/float.c. construct_array() and
deconstruct_array() are the most general answers, but for fixed-width
element types like float8 you can cheat quite a lot.
> /* what happened to palloc in pgsql 7.2??,
Nothing.
> * Also what happened to postgres.h??
Also nothing. Did you do "make install-all-headers"?
regards, tom lane
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2002-03-26 15:33 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-03-26 12:00 C Function with Arrays Question Achilleus Mantzios <rnd@gatewaynet.com>
2002-03-26 15:33 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox