pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedarrays as input parameter for c functions
4+ messages / 3 participants
[nested] [flat]
* arrays as input parameter for c functions
@ 2002-07-12 09:58 Alexaki Sofia <alexaki@ics.forth.gr>
0 siblings, 1 reply; 4+ messages in thread
From: Alexaki Sofia @ 2002-07-12 09:58 UTC (permalink / raw)
To: pgsql-interfaces
Hello,
I want to add a c function in PostgreSQL (7.2.1)
Is it possible the input parametrs othe function to be
arrays of text (i.e., text *temp[10])?
If it's possible how can I call such a function?
thank you in advance,
Sofia
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: arrays as input parameter for c functions
@ 2002-07-12 13:43 Tom Lane <tgl@sss.pgh.pa.us>
parent: Alexaki Sofia <alexaki@ics.forth.gr>
0 siblings, 1 reply; 4+ messages in thread
From: Tom Lane @ 2002-07-12 13:43 UTC (permalink / raw)
To: Alexaki Sofia <alexaki@ics.forth.gr>; +Cc: pgsql-interfaces
Alexaki Sofia <alexaki@ics.forth.gr> writes:
> I want to add a c function in PostgreSQL (7.2.1)
> Is it possible the input parametrs othe function to be
> arrays of text (i.e., text *temp[10])?
You can certainly make the function take a "text[]", but it's not
going to be spoon-fed to you as a C array; you'll need to break down
the array value yourself. See deconstruct_array. (The aggregate
support functions for numeric avg/stddev/etc might be useful examples
of interpreting and constructing arrays of varlena datums.)
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: arrays as input parameter for c functions
@ 2002-07-12 14:32 Alexaki Sofia <alexaki@ics.forth.gr>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Alexaki Sofia @ 2002-07-12 14:32 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-interfaces
thank you for your answer.
Could you tell me how such a function is it called?
Let's say that the function is test(text[])
how can I call this function from a sql command, i.e., what
will be teh value of the input parameters?
select test(?????????)
Sofia
On Fri, 12 Jul 2002, Tom Lane wrote:
> Alexaki Sofia <alexaki@ics.forth.gr> writes:
> > I want to add a c function in PostgreSQL (7.2.1)
> > Is it possible the input parametrs othe function to be
> > arrays of text (i.e., text *temp[10])?
>
> You can certainly make the function take a "text[]", but it's not
> going to be spoon-fed to you as a C array; you'll need to break down
> the array value yourself. See deconstruct_array. (The aggregate
> support functions for numeric avg/stddev/etc might be useful examples
> of interpreting and constructing arrays of varlena datums.)
>
> regards, tom lane
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: arrays as input parameter for c functions
@ 2002-07-12 15:57 Joe Conway <mail@joeconway.com>
parent: Alexaki Sofia <alexaki@ics.forth.gr>
0 siblings, 0 replies; 4+ messages in thread
From: Joe Conway @ 2002-07-12 15:57 UTC (permalink / raw)
To: Alexaki Sofia <alexaki@ics.forth.gr>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-interfaces
Alexaki Sofia wrote:
> thank you for your answer.
>
> Could you tell me how such a function is it called?
>
> Let's say that the function is test(text[])
> how can I call this function from a sql command, i.e., what
> will be teh value of the input parameters?
>
> select test(?????????)
>
See contrib/dblink in CVS HEAD, specifically dblink_build_sql_insert(),
dblink_build_sql_delete(), or dblink_build_sql_update(). These functions
accept text arrays (and int2vector) as input. In the README there are
usage examples.
HTH,
Joe
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2002-07-12 15:57 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-07-12 09:58 arrays as input parameter for c functions Alexaki Sofia <alexaki@ics.forth.gr>
2002-07-12 13:43 ` Tom Lane <tgl@sss.pgh.pa.us>
2002-07-12 14:32 ` Alexaki Sofia <alexaki@ics.forth.gr>
2002-07-12 15:57 ` Joe Conway <mail@joeconway.com>
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