From ch@rodos.fzk.de Wed Sep 19 08:26:10 2001 Received: from resy5.fzk.de (resy5.fzk.de [141.52.68.8]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f8J8QAe56899 for ; Wed, 19 Sep 2001 04:26:10 -0400 (EDT) (envelope-from ch@rodos.fzk.de) Received: by rodos.fzk.de with ESMTP (8.8.6 (PHNE_17135)/8.7.1) id KAA24357; Wed, 19 Sep 2001 10:25:43 +0200 (METDST) From: Haller Christoph Message-Id: <200109190824.KAA23466@rodos> Subject: Re: Registring a C function in PostgreSQL To: iafmgc@unileon.es (=?iso-8859-1?Q?Miguel_Gonz=E1lez?=) Date: Wed, 19 Sep 2001 10:24:54 METDST Cc: pgsql-sql@postgresql.org In-Reply-To: <001f01c1406c$954f91b0$1301a8c0@uimagen>; from "=?iso-8859-1?Q?Miguel_Gonz=E1lez?=" at Sep 19, 101 4:42 am X-Mailer: Elm [revision: 212.4] X-Archive-Number: 200109/141 X-Sequence-Number: 4819 Did you use the compiler option for generating position independent code (PIC) for use in building shared libraries. Did you use the linker option for creating a shared library - I think you did, the file suffix .so looks that way. I did it several times successfully using commands like CREATE FUNCTION byteatostr(bytea) RETURNS text AS './byteatostr.sl' LANGUAGE 'c'; and it worked. Maybe you should add some more information about what you did in detail. Regards, Christoph From iafmgc@unileon.es Tue Sep 18 22:31:08 2001 Received: from isidoro2.unileon.es (isidoro2.unileon.es [193.146.96.2]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f8IMV8d69390 for ; Tue, 18 Sep 2001 18:31:08 -0400 (EDT) (envelope-from iafmgc@unileon.es) Received: from intergraph (n104111.unileon.es [193.146.104.111]) by isidoro2.unileon.es (8.9.3/8.9.1) with SMTP id UAA25982 for ; Tue, 18 Sep 2001 20:10:10 +0200 (MET DST) Message-ID: <001f01c1406c$954f91b0$1301a8c0@uimagen> From: =?iso-8859-1?Q?Miguel_Gonz=E1lez?= To: "PostgreSQL SQL" Subject: Registring a C function in PostgreSQL Date: Tue, 18 Sep 2001 20:06:04 +0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_001C_01C1407D.58AFCB10" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Archive-Number: 200109/133 X-Sequence-Number: 4805 This is a multi-part message in MIME format. ------=_NextPart_000_001C_01C1407D.58AFCB10 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I have followed the instructions in the Bruje Momjian=B4s book to register a function, and i got this message: ERROR:/load of file /home/postgres/ctof.so failed: /home/postgres/ctof.so ELF file=B4s phentsize not the expected size. What is going on? I have tried to get more documentation about how to use C functions in PostgreSQL, but I cant. Many thanks in advance Miguel ------=_NextPart_000_001C_01C1407D.58AFCB10 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I = have followed=20 the instructions in the Bruje Momjian=B4s book to register a
function, a= nd i=20 got this message:

 ERROR:/load of file /home/postgres/ctof.so= =20 failed: /home/postgres/ctof.so
ELF file=B4s phentsize not the expected= =20 size.

What is going on? I have tried to get more documentation about= how=20 to use C
functions in PostgreSQL, but I cant.

 Many thanks i= n=20 advance

 Miguel


------=_NextPart_000_001C_01C1407D.58AFCB10-- From peter_e@gmx.net Wed Sep 19 08:05:00 2001 Received: from mail1.hub.org (webmail.hub.org [216.126.85.1]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f8J850e47454 for ; Wed, 19 Sep 2001 04:05:00 -0400 (EDT) (envelope-from peter_e@gmx.net) Received: from mailout00.sul.t-online.de (mailout00.sul.t-online.com [194.25.134.16]) by mail1.hub.org (8.11.3/8.11.4) with ESMTP id f8J84vD47374 for ; Wed, 19 Sep 2001 04:04:57 -0400 (EDT) (envelope-from peter_e@gmx.net) Received: from fwd04.sul.t-online.de by mailout00.sul.t-online.de with smtp id 15jcLY-0006Xc-0T; Wed, 19 Sep 2001 10:04:40 +0200 Received: from peter.localdomain (520083510237-0001@[212.185.245.54]) by fmrl04.sul.t-online.com with esmtp id 15jcLM-2B0jmyC; Wed, 19 Sep 2001 10:04:28 +0200 Date: Wed, 19 Sep 2001 10:09:20 +0200 (CEST) From: Peter Eisentraut To: =?iso-8859-1?Q?Miguel_Gonz=E1lez?= cc: PostgreSQL SQL Subject: Re: Registring a C function in PostgreSQL In-Reply-To: <001f01c1406c$954f91b0$1301a8c0@uimagen> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT X-Sender: 520083510237-0001@t-dialin.net X-Archive-Number: 200109/140 X-Sequence-Number: 4818 Miguel González writes: > ERROR:/load of file /home/postgres/ctof.so failed: /home/postgres/ctof.so > ELF file´s phentsize not the expected size. You probably didn't compile or link the code correctly. See the PostgreSQL Programmer's Guide for information. -- Peter Eisentraut peter_e@gmx.net http://funkturm.homeip.net/~peter From iafmgc@unileon.es Wed Sep 19 10:45:53 2001 Received: from isidoro2.unileon.es (isidoro2.unileon.es [193.146.96.2]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f8JAjpe22624 for ; Wed, 19 Sep 2001 06:45:53 -0400 (EDT) (envelope-from iafmgc@unileon.es) Received: from intergraph (n104111.unileon.es [193.146.104.111]) by isidoro2.unileon.es (8.9.3/8.9.1) with SMTP id MAA05391; Wed, 19 Sep 2001 12:45:20 +0200 (MET DST) Message-ID: <002701c140f7$9d75d710$1301a8c0@uimagen> From: =?iso-8859-1?Q?Miguel_Gonz=E1lez?= To: "Haller Christoph" Cc: References: <200109190824.KAA23466@rodos> Subject: Re: Registring a C function in PostgreSQL Date: Wed, 19 Sep 2001 12:41:12 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Archive-Number: 200109/145 X-Sequence-Number: 4823 Many thanks for your answers. The thing that in the Bruce´s book doesnt explain how to compile this kind of functions, anyway I found how to compile it. Now, I am still having problems. I want to create a function to send an email. I pass to the function two arguments: the email to send, and the text to send. First, I tried with pointers to char. It worked when I just create a function called "sendemail()" with no arguments and set inside the text and the email arguments. When I read some more documentation about how to use strings in PostgreSQL, I discovered that I have to use the text type in my C program I just try it but although it worked before, now I doesnt work. This is what I have tried: #include #include "postgres.h" int sendemail(text *email,text *message) { char string_tosend [300]; sprintf(string_tosend,"echo \"%s\" >/tmp/mailtmp.txt \n",VARDATA(message)); system(string_tosend); sprintf(string_tosend,"mail -s \"message from PostgreSQL\" %s To: "Miguel González" Cc: Sent: Wednesday, September 19, 2001 12:24 PM Subject: Re: [SQL] Registring a C function in PostgreSQL > Did you use the compiler option for generating > position independent code (PIC) for use in building > shared libraries. > Did you use the linker option for creating > a shared library - I think you did, the file > suffix .so looks that way. > I did it several times successfully using commands > like > CREATE FUNCTION byteatostr(bytea) RETURNS text > AS './byteatostr.sl' LANGUAGE 'c'; > and it worked. > Maybe you should add some more information about > what you did in detail. > Regards, Christoph >