X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id ADF92D1B46E for ; Fri, 5 Dec 2003 09:46:14 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 18406-06 for ; Fri, 5 Dec 2003 05:45:44 -0400 (AST) Received: from bettong.westnet.com.au (bettong.westnet.com.au [203.10.1.8]) by svr1.postgresql.org (Postfix) with ESMTP id E797DD1B44A for ; Fri, 5 Dec 2003 05:45:40 -0400 (AST) Received: from localhost (bettong [127.0.0.1]) by localhost (Postfix) with ESMTP id 7598D60153 for ; Fri, 5 Dec 2003 17:45:41 +0800 (WST) Received: from bart.graham.fdns.net (dsl-202-72-174-99.wa.westnet.com.au [202.72.174.99]) by bettong.westnet.com.au (Postfix) with ESMTP id 1ABFF600FE for ; Fri, 5 Dec 2003 17:45:41 +0800 (WST) Subject: Re: Trigger to call an external program From: Alan Graham To: pgsql-admin@postgresql.org In-Reply-To: References: <1070550790.3133.8.camel@bart.graham.fdns.net> Content-Type: text/plain Organization: Message-Id: <1070617650.2670.8.camel@bart.graham.fdns.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2-1mdk Date: 05 Dec 2003 17:47:30 +0800 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/50 X-Sequence-Number: 11558 I'll try the fix and compile of pgplsh, as suggested by Stephan. (thanks :-) I'd assumed that the errors I was seeing were indicative of much larger compatibility problems. Just shows what "Assume" does :-) As you say, using trigger worries me, because of rollbacks. I'd thought of using NOTIFY, but the limited docs I could find suggested that it wouldn't be fine grained enough to replicate every transaction. Also (and this was more of an issue), I couldn't work out how to LISTEN in Python. Could you point me to some docos or examples of an external python script LISTENing for a NOTIFY? Thanks for your help Alan Graham On Thu, 2003-12-04 at 23:43, Peter Childs wrote: > On Thu, 4 Dec 2003, Alan Graham wrote: > > > I'm doing a low cost, low performance roll your own replication project, > > between various offices around Australia. The replication is > > asynchronous, and peer to peer. I've looked at the various replication > > projects, and for one reason or another, they're too hard. > > Agreed. > > > > > My design uses jabber as middleware, using python scripts to do the hard > > work. However, it depends on triggers calling my python scripts to > > work. I can't find a way to call an external script from a trigger. > > I've searched the archives, and found a few other people asking the same > > question, but no answers (apart from the odd sanctimonious "well you > > shouldn't be doing that..." :-). > > I've just done that. The problem is that the trigger gets fired > even if the query then gets rolled back. So its best to use notify. I > orignally wrote the trigger in python but after finding a bug in the > python scripting for postgres 7.3 I gave up and rewrote in in C its faster > anyway :) My demon script is not bug free however....I want it to inform > users about database changes not for replication however.... so it uses > mu-conference and broardcasts the queries to anyone listening. > > > > > 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. > > > > Using python as a trigger language also seems to be a non-starter, > > because the restricted python environment isn't yet working. > > > > So... Is there an easy way to call a script from a trigger? > > > > Thanks > > > > Alan Graham > > > > -- > > Alan Graham > > > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 9: the planner will ignore your desire to choose an index scan if your > > joining column's datatypes do not match > > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster -- Alan Graham