Re: calling a shell script from pl/pgsql

From: Jan Wieck <JanWieck(at)Yahoo(dot)com>
To: Jeff Barrett <jbarrett(at)familynetwork(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: calling a shell script from pl/pgsql
Date: 2001-09-11 07:08:31
Message-ID: 200109110708.f8B78VV01263@saturn.jw.home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Jeff Barrett wrote:
> Thanks for the suggestions.
>
> I am running 7.1.2 and going to 7.1.3 soon.
>
> If I use pl/tclu or pl/perlu I can call this executable from within the
> code?
>
> I have a signifigant limitation, I cannot duplicate the action of the
> programs I want to call in a program I write within postgres, I need to call
> the executable (In this one case it is a shell script but I have others
> where it is a binary).

That's kind of a fuzzy explanation. If this "action" of your
programs in any way affects data, that should be part of the
triggers transaction, then what you want to do is broken by
design.

In detail, if the external program you're calling from the
trigger connects to the database, updates it and terminates,
the transaction that fired the trigger can still rollback,
discarding all changes that caused the trigger to get fired.
Thus, the database should look like the trigger never got
fired - but how do you undo the changes of your external
program? It connected to the database, did it's updates,
committed and terminated. You'll have no chance to undo that.

So if you really intend to do what it smells like, you're
better off moving all the "external program"s logic into some
function inside of the database, and call it from the
external program as well as the trigger.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Kevin Way 2001-09-11 08:04:52 table inheritance and foreign key troubles
Previous Message Gledatelj 2001-09-11 06:33:30 Re: Combine query views into one SQL string