From: | Louis-David Mitterrand <cunctator(at)apartia(dot)ch> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | forking a process and grabbing web site data from a C trigger? |
Date: | 2000-08-15 09:07:05 |
Message-ID: | 20000815110705.A3616@styx |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
On Sat, Aug 12, 2000 at 01:10:01PM -0400, Tom Lane wrote:
> Louis-David Mitterrand <cunctator(at)apartia(dot)ch> writes:
> >> IMPORTANT: changing the backend's locale on-the-fly is an EXTREMELY
> >> DANGEROUS thing to do, and I strongly recommend that you find another
> >> way to solve your problem.
>
> > The "problem" I am trying to solve is to send e-mail notifications to
> > auction bidders in their own language with the proper number formatting,
> > etc. From what you are saying I'll probably have to move these
> > notifications to the mod_perl layer of the application.
>
> Well, you could fork a subprocess to issue the mail and change locale
> only once you're safely inside the subprocess.
Could you give a minimal example of how forking a subprocess in a PG
trigger is done? Or maybe give a pointer to an existing example?
On an unrelated subject I have to maintain and update a table containing
currency rates for the auction site (URL in .sig):
Table "currency"
Attribute | Type | Modifier
-----------+--------+--------------------
USD | float4 | not null default 1
FRF | float4 |
AUD | float4 |
CAD | float4 |
EUR | float4 |
GBP | float4 |
DEM | float4 |
JPY | float4 |
CHF | float4 |
To update it I wrote a quick perl script that grabs data from Yahoo's
currency web page (attached). This script has to be installed and run as
a cron job, but I'd like to integrate that functionality in the DB
backend as a trigger that performs the data refresh every n'th SELECT on
the table:
- either convert that perl script to C (maybe using libwww and a
regex C library);
- or simpy launch that perl script from the trigger;
The former solution is not easy, and is probably a good programming
exercise, the latter is quick but how would one go about launching a
perl script from C without waiting for its completion?
Thanks in advance,
--
Louis-David Mitterrand - ldm(at)apartia(dot)org - http://www.apartia.org
Parkinson's Law: Work expands to fill the time alloted it.
Attachment | Content-Type | Size |
---|---|---|
get_currency.pl | application/x-perl | 865 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Mount | 2000-08-15 09:15:58 | Re: [SQL] postgresql and java2 |
Previous Message | Tamsin | 2000-08-15 08:16:08 | RE: PostGres and ERwin |
From | Date | Subject | |
---|---|---|---|
Next Message | Kaare Rasmussen | 2000-08-15 09:12:22 | Re: Open Source Database Routs Competition in New Benchmark Tests |
Previous Message | Joe Brenner | 2000-08-15 08:24:59 | Re: Open Source Database Routs Competition in New Benchmark Tests |