pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alan Graham <alan.graham@infonetsystems.com.au>
To: pgsql-admin@postgresql.org
Subject: Re: Trigger to call an external program
Date: 07 Dec 2003 17:16:30 +0800
Message-ID: <1070788590.13415.22.camel@bart.graham.fdns.net> (raw)
In-Reply-To: <200312051945.35792.peter_e@gmx.net>
References: <1070550790.3133.8.camel@bart.graham.fdns.net>
	<20031204073059.P66123@megazone.bigpanda.com>
	<200312051945.35792.peter_e@gmx.net>

Thanks for this Peter.  I got it working by putting in the changes
suggested by Stephan and adding errno.h

However, I can't get any triggers to work.  I'm new to postgresql, and
to triggers, so it's got to be something I'm doing wrong.  

The test.sql script only half works.  The behaviour is the same on the
7.2.1 system, and on the 7.3.4 systems that I've hacked, so I don't
*think* that I've introduced a problem.

Using a pgplsh function works.  The test script first creates a function
shtest then runs it.  This works.  The second part of the script,
creating the function shtrigger, works.  The create of the trigger
testtrigger works, ie, I can see the created trigger in the table
pg_trigger.  But the 3 inserts insert the data correctly, but there is
no sign that the trigger is being fired off. I've tried various
functions to be fired as triggers, the simplest was 
CREATE FUNCTION alantrigger() RETURNS opaque AS
'#!/bin/bash
echo "Hello world"
exit 0
' LANGUAGE 'plsh';
but none of them seem to have any effect.

The output of test.sql (on the 7.3.4 system) is as follows:
bash-2.05a$ psql -f test.sql
DROP FUNCTION
CREATE FUNCTION
      shtest
-------------------
 One: foo Two: bar
(1 row)
 
psql:test.sql:12: ERROR:  shtest: this is an error
DROP FUNCTION
CREATE FUNCTION
DROP TABLE
CREATE TABLE
psql:test.sql:29: NOTICE:  CreateTrigger: changing return type of
function shtrigger() from OPAQUE to TRIGGER
CREATE TRIGGER
INSERT 56863 1
INSERT 56864 1
INSERT 56865 1
cat: /home/e-smith/files/users/infonet/voodoo-pgplsh-test: No such file
or directory
rm: cannot remove
`/home/e-smith/files/users/infonet/voodoo-pgplsh-test': No such file or
directory

I made 2 minor changes to the script.  I put a CASCADE into the drop
function so it would drop the trigger as well,, and removed the drop
trigger statement.

Any thoughts as to how I can debug this further are greatly
appreciated.  I'm not sure what to try next.

Thanks

Alan Graham

On Sat, 2003-12-06 at 02:51, Peter Eisentraut wrote:
> On Thursday 04 December 2003 16:36, Stephan Szabo wrote:
> > > I thought I was onto a winner with pgplsh, but I can't get it to
> > > compile with 7.3.4, although it compiled beautifully with 7.2.1.
> >
> > It takes a little bit of work to get pgplsh to compile for my devel
> > system (notably that I needed to make sure the server includes were
> > in the -I path and had to make a few more changes noted below).
> >
> > I removed the if (DebugLvl > 1) lines and needed to change
> > elog(DEBUG, lines to one of the new DEBUG levels (I chose DEBUG2). 
> > After that it seemed to compile.
> 
> I'll try to make new "releases" over the weekend that compile properly 
> for the various PostgreSQL versions that are around.





view thread (6+ messages)

Message-ID: <1070788590.13415.22.camel@bart.graham.fdns.net>
Permalink:  ../1070788590.13415.22.camel@bart.graham.fdns.net/
Also on:    postgresql.org/message-id/1070788590.13415.22.camel@bart.graham.fdns.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: alan.graham@infonetsystems.com.au
  Subject: Re: Trigger to call an external program
  In-Reply-To: <1070788590.13415.22.camel@bart.graham.fdns.net>
  References: <1070550790.3133.8.camel@bart.graham.fdns.net> <20031204073059.P66123@megazone.bigpanda.com> <200312051945.35792.peter_e@gmx.net> <1070788590.13415.22.camel@bart.graham.fdns.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox