pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedFunctions for arrays !!!!
2+ messages / 2 participants
[nested] [flat]
* Functions for arrays !!!!
@ 1999-05-07 14:56 Carlos Peralta Ramirez <cperalta@hera.inf.ucv.cl>
1999-05-08 14:49 ` Re: [SQL] Functions for arrays !!!! Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 2+ messages in thread
From: Carlos Peralta Ramirez @ 1999-05-07 14:56 UTC (permalink / raw)
To: pgsql-novice <pgsql-novice@hub.org>; pgsql-hackers <pgsql-hackers@postgresql.org>; pgsql-sql; pgsql-general <pgsql-general@postgresql.org>
Hi,
I´m trying of to make a function that receive two arguments :
- An array of int4
- A int4
The target of this function is to evaluate if the numeric argument is or
not into of the array !!!!!
/* If anybody know of some predefined function that has the same target,
tell me !!!*/
The code is following (tester.c)->
#include <pgsql/postgres.h>
#include <stdio.h>
bool tester(int4 o[],int4 a){
int i;
for(i=0;o[i]!=0;i++)
if (o[i]==a)
return('t');
return('f');
}
then I compile the code
gcc -c tester.c /*Thanks to */
gcc -shared -o tester.so tester.o /*Michael J. Davis*/
, and get tester.so
I create the function in PostgreSQL ->
dbtest=>create function tester(_int4,int4) returns bool as
'$path/tester.so' language 'c';
CREATE
But when try to use it, ->
dbtest=>select tester('{1,2,3,4}',3);
ERROR: stat failed on file tester.so
/*Here I hope a 't' */
I don´t know what´s happens !!!!!
Carlos Peralta Ramírez !!!!!
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [SQL] Functions for arrays !!!!
1999-05-07 14:56 Functions for arrays !!!! Carlos Peralta Ramirez <cperalta@hera.inf.ucv.cl>
@ 1999-05-08 14:49 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 1999-05-08 14:49 UTC (permalink / raw)
To: Carlos Peralta Ramirez <cperalta@hera.inf.ucv.cl>; +Cc: pgsql-novice <pgsql-novice@hub.org>; pgsql-sql; pgsql-general <pgsql-general@postgreSQL.org>
Carlos Peralta Ramirez <cperalta@hera.inf.ucv.cl> writes:
> I create the function in PostgreSQL ->
> dbtest=>create function tester(_int4,int4) returns bool as
> '$path/tester.so' language 'c';
> CREATE
> But when try to use it, ->
> dbtest=>select tester('{1,2,3,4}',3);
> ERROR: stat failed on file tester.so
> I don´t know what´s happens !!!!!
Looks like Postgres couldn't find the .so file to load it.
(The error message is sadly incomplete --- maybe I'll look to see
if it can be improved.)
When you wrote '$path/tester.so' above, were you being literal or
did you mean to indicate that you filled in an appropriate path?
All the examples you might see of that notation in Postgres are
in shell scripts where a variable like $path will get expanded;
if you typed it in by hand then you have to supply the complete
path by hand. Look at the entry for the tester function in the
pg_proc table to see what pathname the system has recorded...
regards, tom lane
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~1999-05-08 14:49 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-05-07 14:56 Functions for arrays !!!! Carlos Peralta Ramirez <cperalta@hera.inf.ucv.cl>
1999-05-08 14:49 ` 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