From: Boulat Khakimov <boulat@inet-interactif.com>
To: pgsql-sql@postgresql.org
To: pgsql-docs@postgresql.org
Subject: Extending PostgreSQL Using C
Date: Mon, 05 Mar 2001 17:00:31 -0500
Message-ID: <3AA40C7F.D56684AF@inet-interactif.com> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-docs@postgresql.org
Cc: boulat@inet-interactif.com, pgsql-sql@postgresql.org
Subject: Re: Extending PostgreSQL Using C
In-Reply-To: <3AA40C7F.D56684AF@inet-interactif.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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