| From: | Rémi Cura <remi(dot)cura(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL General <pgsql-general(at)postgresql(dot)org> |
| Subject: | reading array[text] in C extension function |
| Date: | 2014-01-15 18:20:37 |
| Message-ID: | CAJvUf_vSzN6qS0YAmv-qW1569N5Zg-XM3jsHvx_TSxdGBL7AKQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Hey,
I'm trying to use an array of text as input in a C function in a custom
extension.
the prototype of the sql function is :
CREATE OR REPLACE FUNCTION pc_subset( dimensions TEXT[])
it is called like :
pc_subset( ARRAY['X'::text,'Y'::text])
and the C function trying to read the text array (converting it to cstring
) :
text ** vals;
char ** cstring_array;
nelems = ARR_DIMS(arrptr)[0];
vals = (text**) ARR_DATA_PTR(arrptr);
cstring_array = (char **) pcalloc(nelems * sizeof(char * ) );
for (i3=0;i3<nelems;i3++)
{
cstring_array[i3] = text_to_cstring( vals[i3]);
elog(INFO, "elem %d of dim_array : %s\n",i3,cstring_array[i3]);
}
I crashes postgres because of a segfault.
Any help appreciated =)
Cheers,
Rémi-C
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alan Nilsson | 2014-01-15 20:10:27 | Re: pg_basebackup failing |
| Previous Message | Oleg Bartunov | 2014-01-15 17:58:22 | Re: Need Help to implement Proximity search feature |