Skip site navigation (1) Skip section navigation (2)

Re: [GENERAL] Shared Objects (Dynamic loading)

From: "Jasbinder Bali" <jsbali(at)gmail(dot)com>
To: "Michael Fuhr" <mike(at)fuhr(dot)org>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: [GENERAL] Shared Objects (Dynamic loading)
Date: 2006-08-24 06:51:50
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-generalpgsql-novice
Well, the server side code is in ECPG because thats the easiest choice i
could see.
I really don't know how difficult or beneficial would SPI be. Haven't heard
of SPI before.
I was under the impression that ECPG and libpg are the only two choices a
developer has in postgresql for database related activities.

I am using char in postgres function as an analogue for char* in C. Is this
The link that you gave says varchar* in C has varchar as its analogue in

Thanks and regards,

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'
> > 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?
> > 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.
> 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


pgsql-novice by date

Next:From: Jasbinder BaliDate: 2006-08-24 07:29:55
Subject: Re: [GENERAL] Shared Objects (Dynamic loading)
Previous:From: Michael FuhrDate: 2006-08-24 05:41:50
Subject: Re: Shared Objects (Dynamic loading)

pgsql-general by date

Next:From: Michael FuhrDate: 2006-08-24 06:59:54
Subject: Re: Inserting Data
Previous:From: Michael FuhrDate: 2006-08-24 06:08:40
Subject: Re: Inserting Data

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group