Re: Shared Objects (Dynamic loading)

From: "Jasbinder Bali" <jsbali(at)gmail(dot)com>
To: "Michael Fuhr" <mike(at)fuhr(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Shared Objects (Dynamic loading)
Date: 2006-08-24 19:46:00
Message-ID: a47902760608241246t66b6f6ecl2ad411bfa08656f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice

Hi,
The way we use ECPG for the database related activites while working with
C, what do i need to look up if i'm using perl.
As alot of people have pointed out that perl is the best language to use
while dealing with email parsing.
We have the perl code ready to parse the email.
Just wondering what would be the best method to deal with database
(postgresql) calls from the perl code.

Thanks and regards,
Jas

On 8/24/06, Michael Fuhr <mike(at)fuhr(dot)org> wrote:
>
> On Thu, Aug 24, 2006 at 01:03:43AM -0400, Jasbinder Bali wrote:
> > CREATE OR REPLACE FUNCTION sp_trigger_raw_email(int4, text)
> > RETURNS bool AS
> > '/usr/local/pgsql/jsbali/parser', 'parse_email'
> > LANGUAGE 'c' VOLATILE STRICT;
> > ALTER FUNCTION sp_trigger_raw_email(int4,text ) OWNER TO postgres;
> >
> > function parse_email(int caseno, char *rawemail)
> > populates a few global variables first and then
> > call another function parse_header().
> > function parse_header() makes use of the global variables and then
> using
> > ECPG stores values in a table in the database.
>
> Is there a reason this server-side code is using ECPG instead of SPI?
>
> http://www.postgresql.org/docs/8.1/interactive/spi.html
>
> > My question is, when we try to make use of a specific function of a
> shared
> > object dynamically loaded as show above, then
> > would that function be able to access all global variables populated
> > elsewhere in the program or all the global variables can't be accessed
> > inside that function of the shared object.
>
> A function should be able to access any global symbol and any static
> symbol in the same object file. Are you having trouble doing so?
>
> > Also, in the above function definition,
> > the signature of parse_email function is
> > parse_email(int, char*) and i am passing (int4 , text) to int as seen in
> the
> > function code pasted above.
> > Is text in pgsql going to match with char* or i should use some other
> > datatype?
>
> See "C-Language Functions" in the documentation, in particular what
> it says about version 1 calling conventions.
>
> http://www.postgresql.org/docs/8.1/interactive/xfunc-c.html
>
> Is there a reason you're coding in C instead of a higher-level
> language like PL/Perl? If you're parsing email messages then coding
> in Perl, Python, Ruby, etc., would probably be easier than C.
>
> --
> Michael Fuhr
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rajarshi Guha 2006-08-24 20:06:47 Re: getting around 'out of memory' errors
Previous Message Cleber 2006-08-24 19:43:41 unsubscrible

Browse pgsql-novice by date

  From Date Subject
Next Message Frank Finner 2006-08-24 20:10:58 Re: Shared Objects (Dynamic loading)
Previous Message Bruno Wolff III 2006-08-24 19:01:10 Re: matching empty column