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

Re: executing OS programs from pg

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Gevik babakhani" <gevik(at)xs4all(dot)nl>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: executing OS programs from pg
Date: 2005-06-03 19:16:29
Message-ID: 12059.1117826189@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
"Gevik babakhani" <gevik(at)xs4all(dot)nl> writes:
> Does anyone know how to execute an OS command from pgsql. I would like to
> create a trigger that op on firing would run/execute an external program.

Use any of the "untrusted" PLs to execute system() or the like.

Whether this is a good idea or not is a different question --- there are
excellent reasons why it is a *bad* idea to execute outside-the-database
actions from within a trigger.  Mainly that the actions won't be undone
if the transaction later rolls back, and now your database state is
inconsistent with outside-the-database state.  See the list archives for
many past discussions of this point and safer ways to design your
application.

(BTW, this is hardly material for -hackers.)

			regards, tom lane

In response to

pgsql-hackers by date

Next:From: Bruno Wolff IIIDate: 2005-06-03 19:24:51
Subject: Re: O_DIRECT for WAL writes
Previous:From: Luke LonerganDate: 2005-06-03 19:14:19
Subject: Re: NOLOGGING option, or ?

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