pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Extending PostgreSQL Using C
6+ messages / 4 participants
[nested] [flat]

* Extending PostgreSQL Using C
@ 2001-03-05 22:00 Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-05 23:23 ` Re: Extending PostgreSQL Using C Tom Lane <tgl@sss.pgh.pa.us>
  2001-03-07 16:48 ` Re: Extending PostgreSQL Using C Hannu Krosing <hannu@tm.ee>
  0 siblings, 2 replies; 6+ messages in thread

From: Boulat Khakimov @ 2001-03-05 22:00 UTC (permalink / raw)
  To: pgsql-sql@postgresql.org; pgsql-docs

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



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Extending PostgreSQL Using C
  2001-03-05 22:00 Extending PostgreSQL Using C Boulat Khakimov <boulat@inet-interactif.com>
@ 2001-03-05 23:23 ` Tom Lane <tgl@sss.pgh.pa.us>
  2001-03-05 23:57   ` Re: Extending PostgreSQL Using C Boulat Khakimov <boulat@inet-interactif.com>
  1 sibling, 1 reply; 6+ messages in thread

From: Tom Lane @ 2001-03-05 23:23 UTC (permalink / raw)
  To: Boulat Khakimov <boulat@inet-interactif.com>; +Cc: pgsql-sql@postgresql.org; pgsql-docs

Boulat Khakimov <boulat@inet-interactif.com> writes:
> ERROR:  Can't find function encrypt in file /[full path here]/encrypt.so 
> Why do I get this error????

Offhand I see nothing wrong with your procedure.  Try running 'nm' on
the .so file to see what symbols it says the .so defines.

What platform is this on, anyway?

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Extending PostgreSQL Using C
  2001-03-05 22:00 Extending PostgreSQL Using C Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-05 23:23 ` Re: Extending PostgreSQL Using C Tom Lane <tgl@sss.pgh.pa.us>
@ 2001-03-05 23:57   ` Boulat Khakimov <boulat@inet-interactif.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Boulat Khakimov @ 2001-03-05 23:57 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-sql@postgresql.org; pgsql-docs

Tom Lane wrote:
> 
> Boulat Khakimov <boulat@inet-interactif.com> writes:
> > ERROR:  Can't find function encrypt in file /[full path here]/encrypt.so
> > Why do I get this error????
> 
> Offhand I see nothing wrong with your procedure.  Try running 'nm' on
> the .so file to see what symbols it says the .so defines.
> 
> What platform is this on, anyway?


Linux 2.2.18 #23 Tue Feb 6 13:21:15 EST 2001 i686 unknown


Regards,
Boulat
          

-- 
Nothing Like the Sun



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Extending PostgreSQL Using C
  2001-03-05 22:00 Extending PostgreSQL Using C Boulat Khakimov <boulat@inet-interactif.com>
@ 2001-03-07 16:48 ` Hannu Krosing <hannu@tm.ee>
  2001-03-07 16:55   ` Re: Extending PostgreSQL Using C Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 1 reply; 6+ messages in thread

From: Hannu Krosing @ 2001-03-07 16:48 UTC (permalink / raw)
  To: Boulat Khakimov <boulat@inet-interactif.com>; +Cc: pgsql-sql@postgresql.org; pgsql-docs


Boulat Khakimov wrote:

> Hi,
> 
> Im writing a C function for PG to do one way encryption using crypt.
> Here is the source code
> 
> 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?

Can _postgres_ user read /[full path here]/encrypt.so ?

---------------
Hannu




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Extending PostgreSQL Using C
  2001-03-05 22:00 Extending PostgreSQL Using C Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-07 16:48 ` Re: Extending PostgreSQL Using C Hannu Krosing <hannu@tm.ee>
@ 2001-03-07 16:55   ` Tom Lane <tgl@sss.pgh.pa.us>
  2001-03-07 18:54     ` Re: Extending PostgreSQL Using C Nishad Prakash <prakashn@uci.edu>
  0 siblings, 1 reply; 6+ messages in thread

From: Tom Lane @ 2001-03-07 16:55 UTC (permalink / raw)
  To: Hannu Krosing <hannu@tm.ee>; +Cc: Boulat Khakimov <boulat@inet-interactif.com>; pgsql-sql@postgresql.org; pgsql-docs

Hannu Krosing <hannu@tm.ee> writes:
> Boulat Khakimov wrote:
>> ERROR:  Can't find function encrypt in file /[full path here]/encrypt.so 

> Can _postgres_ user read /[full path here]/encrypt.so ?

Presumably so.  If he were unable to load the .so file, he'd be getting
a different error message.  This message indicates that he got past the
load step, but dl_sym is unable to resolve the symbol "encrypt".

I asked about the symbol names shown by nm(1), but got no answer ...

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Extending PostgreSQL Using C
  2001-03-05 22:00 Extending PostgreSQL Using C Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-07 16:48 ` Re: Extending PostgreSQL Using C Hannu Krosing <hannu@tm.ee>
  2001-03-07 16:55   ` Re: Extending PostgreSQL Using C Tom Lane <tgl@sss.pgh.pa.us>
@ 2001-03-07 18:54     ` Nishad Prakash <prakashn@uci.edu>
  0 siblings, 0 replies; 6+ messages in thread

From: Nishad Prakash @ 2001-03-07 18:54 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Hannu Krosing <hannu@tm.ee>; Boulat Khakimov <boulat@inet-interactif.com>; pgsql-sql@postgresql.org; pgsql-docs

On Wed, 7 Mar 2001, Tom Lane wrote:

> Hannu Krosing <hannu@tm.ee> writes:
> > Boulat Khakimov wrote:
> >> ERROR:  Can't find function encrypt in file /[full path here]/encrypt.so
>
> > Can _postgres_ user read /[full path here]/encrypt.so ?
>
> Presumably so.  If he were unable to load the .so file, he'd be getting
> a different error message.  This message indicates that he got past the
> load step, but dl_sym is unable to resolve the symbol "encrypt".
>
> I asked about the symbol names shown by nm(1), but got no answer ...

It should be noted that encrypt() is a function already declared in
unistd.h, which the OP is including.  Could that be causing some problem
since the OP is using the same name?

Nishad
-- 
"Underneath the concrete, the dream is still alive" -- Talking Heads





^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2001-03-07 18:54 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-03-05 22:00 Extending PostgreSQL Using C Boulat Khakimov <boulat@inet-interactif.com>
2001-03-05 23:23 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-03-05 23:57   ` Boulat Khakimov <boulat@inet-interactif.com>
2001-03-07 16:48 ` Hannu Krosing <hannu@tm.ee>
2001-03-07 16:55   ` Tom Lane <tgl@sss.pgh.pa.us>
2001-03-07 18:54     ` Nishad Prakash <prakashn@uci.edu>

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