Hi,
Im writing a C function for PG to do one way encryption using crypt.
Here is the source code
#include <ctype.h>
#include <unistd.h>
#include "postgres.h"
#include "utils/builtins.h"
text *encrypt(text *string){
text *ret;
int m;
if ((string == (text *) NULL) || ((m = VARSIZE(string) -
VARHDRSZ) <= 0))
return string;
ret = (text *) palloc(20);
ret = (text *) crypt(string,"AB");
return ret;
}
then I compile it like so:
gcc -I/usr/src/postgresql-7.0.3/src/include \
-I/usr/src/postgresql-7.0.3/src/backend -O2 -Wall
-Wmissing-prototypes \
-Wmissing-declarations \
-I/usr/src/postgresql-7.0.3/src/interfaces/libpq \
-I/usr/src/postgresql-7.0.3/src/include -fpic -c -o encrypt.o
encrypt.c
gcc -shared -o encrypt.so encrypt.o
rm encrypt.o
then in PG, I do the following
test=> CREATE FUNCTION encrypt(text)
test->RETURNS text
test->AS '/[full path here]/encrypt.so'
test->LANGUAGE 'C';
CREATE
Now when I try
test=> SELECT encrypt('Blah');
it gives me this error
ERROR: Can't find function encrypt in file /[full path here]/encrypt.so
Why do I get this error????
Any ideas?
Regards,
Boulat Khakimov
--
Nothing Like the Sun