Thread: postgres launch os applications

postgres launch os applications

From
"Ertel, Steve"
Date:

I am trying to start an OS executable every time that a table is updated.  I know that I should create a trigger on the table, but how do I launch the OS executable.  I have a background in sql server.  In it we would use something like xsp_execute().  I am looking for the equivalent function call in Postgres.
 
Resent this email to group after subscribing to mailing list.
 
Thanks,
Steve

Re: postgres launch os applications

From
"Sean Davis"
Date:
On Tue, Oct 7, 2008 at 1:13 PM, Ertel, Steve <Steve.Ertel@infimatic.com> wrote:
> I am trying to start an OS executable every time that a table is updated.  I
> know that I should create a trigger on the table, but how do I launch the OS
> executable.  I have a background in sql server.  In it we would use
> something like xsp_execute().  I am looking for the equivalent function call
> in Postgres.

You cannot do this with any "trusted" language (which includes
pg/plsql).  However, you can use any of the untrusted languages like
pl/python, pl/perl, pl/java, pl/tcl, etc.  Of course, each of those
languages has its own specifics dealing with starting executables.

Sean

Re: postgres launch os applications

From
"Richard Broersma"
Date:
On Tue, Oct 7, 2008 at 10:34 AM, Sean Davis <sdavis2@mail.nih.gov> wrote:

> You cannot do this with any "trusted" language (which includes
> pg/plsql).  However, you can use any of the untrusted languages like
> pl/python, pl/perl, pl/java, pl/tcl, etc.  Of course, each of those
> languages has its own specifics dealing with starting executables.

To add to this point.  IIRC, these languages are untrusted because
they can trigger events outside the database that cannot be rolled
back in the event of an error.

Another option to might work is using the list notify mechanism.


--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

Re: postgres launch os applications

From
Andreas Kretschmer
Date:
Ertel, Steve <Steve.Ertel@infimatic.com> schrieb:

> I am trying to start an OS executable every time that a table is updated.  I
> know that I should create a trigger on the table, but how do I launch the OS
> executable.  I have a background in sql server.  In it we would use something
> like xsp_execute().  I am looking for the equivalent function call in Postgres.

Write a trigger-function using an untrusted language like pl/perlU. You
can call arbitray commands within an untrusted language. With the
regular trusted languages such plpgsql or so you can't call external
programs.


Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."   (unknown)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°

Re: postgres launch os applications

From
"Sean Davis"
Date:
On Tue, Oct 7, 2008 at 1:38 PM, Richard Broersma
<richard.broersma@gmail.com> wrote:
> On Tue, Oct 7, 2008 at 10:34 AM, Sean Davis <sdavis2@mail.nih.gov> wrote:
>
>> You cannot do this with any "trusted" language (which includes
>> pg/plsql).  However, you can use any of the untrusted languages like
>> pl/python, pl/perl, pl/java, pl/tcl, etc.  Of course, each of those
>> languages has its own specifics dealing with starting executables.
>
> To add to this point.  IIRC, these languages are untrusted because
> they can trigger events outside the database that cannot be rolled
> back in the event of an error.
>
> Another option to might work is using the list notify mechanism.

This is definitely the better option.

Sean

Re: postgres launch os applications

From
mrbuseco@buseco.net
Date:
<span style=3D"font-family:Verdana; color:#000000; font-size:10=
pt;">One could use an embedded SQL C program to update the table, and then =
have thatsame program invoke another executable via exec() or system() =
calls.If you are using Apache and this is an update based on form d=
ata from an HTMLdocument (aren't we all?), one should already be using =
CGI-BIN programming withembedded SQL and be able to fit this right in.<=
br>Matt
<blockquote webmail=3D"1" style=3D"border-left: 2px solid blue; margin-left=
: 8px; padding-left: 8px; font-size: 10pt; color: black; font-family: verda=
na;">
-------- Original Message --------
Subject: Re: [NOVICE] postgres launch os applications
From: Andreas Kretschmer <akretschmer@spamfence.net>
Date: Tue, October 07, 2008 10:39 am
To: pgsql-novice@postgresql.org

Ertel, Steve <Steve.Ertel@infimatic.com> schrieb:

> I am trying to start an OS executable every time that a table is updat=
ed.  I
> know that I should create a trigger on the table, but how do I launch =
the OS
> executable.  I have a background in sql server.  In it we would use so=
mething
> like xsp_execute().  I am looking for the equivalent function call in =
Postgres.

Write a trigger-function using an untrusted language like pl/perlU. You
can call arbitray commands within an untrusted language. With the
regular trusted languages such plpgsql or so you can't call external
programs.


Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."   (unknown)
Kaufbach, Saxony, Germany, Europe.              N 51.05082=C2=B0, E 13.5688=
9=C2=B0

--
Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org)
To make changes to your subscription:
<a href=3D"http://www.postgresql.org/mailpref/pgsql-novice" target=3D"_blan=
k" mce_href=3D"http://www.postgresql.org/mailpref/pgsql-novice">http://www.=
postgresql.org/mailpref/pgsql-novice