Received: from actarg.com (host25.actarg.com [209.180.91.25] (may be forged)) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id eB8NZCZ21692 for ; Fri, 8 Dec 2000 18:35:12 -0500 (EST) (envelope-from kyle@actarg.com) Received: from chi.actarg.com (IDENT:root@chi.actarg.com [192.168.2.16]) by actarg.com (8.9.3/8.9.3) with ESMTP id QAA01712; Fri, 8 Dec 2000 16:35:22 -0700 Received: from actarg.com (IDENT:kyle@localhost [127.0.0.1]) by chi.actarg.com (8.9.3/8.9.3) with ESMTP id QAA09127; Fri, 8 Dec 2000 16:35:21 -0700 Message-ID: <3A317038.CBE9B378@actarg.com> Date: Fri, 08 Dec 2000 16:35:21 -0700 From: Kyle Organization: Action Target Inc. X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.2.12-20 i686) X-Accept-Language: en MIME-Version: 1.0 To: Bryan Field-Elliot CC: pgsql-sql@postgresql.org Subject: Re: "drop constraint trigger" on PostgreSQL References: <01c401c0615a$dc2ad780$54ed90cc@netmeme.org> Content-Type: multipart/mixed; boundary="------------DC64707B563543886EB7EBD8" X-Archive-Number: 200012/64 X-Sequence-Number: 395 This is a multi-part message in MIME format. --------------DC64707B563543886EB7EBD8 Content-Type: multipart/alternative; boundary="------------CCB32DE5933DCFC8E4E6F4D4" --------------CCB32DE5933DCFC8E4E6F4D4 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Bryan Field-Elliot wrote: > Searching the archives, it seems you once tried to find out how to > "drop constraint trigger" on PostgreSQL; did you ever figure it > out? Thank you,Bryan I wrote the following function and installed it in my database. I can then call it with a select (yuk) to drop a constraint trigger: -- Drop all constraint triggers with a given constraint name -- calling sequence: drop_contrig(constrname) create function drop_contrig(text) returns text as ' set d(tgname) {} spi_exec -array d "select c.relname,t.tgname from pg_class c, pg_trigger t where c.oid = t.tgrelid and tgconstrname = \'$1\'" { spi_exec "drop trigger \\"$d(tgname)\\" on $d(relname)" } if {$d(tgname) == {}} {return "No constraint trigger $1 found"} return "Drop trigger $d(tgname) on $d(relname)" ' LANGUAGE 'pltcl'; --------------CCB32DE5933DCFC8E4E6F4D4 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Bryan Field-Elliot wrote:
Searching the archives, it seems you once tried to find out how to "drop constraint trigger" on PostgreSQL; did you ever figure it out? Thank you,Bryan


I wrote the following function and installed it in my database.  I can then call it with a select (yuk) to drop a constraint trigger:

-- Drop all constraint triggers with a given constraint name
-- calling sequence: drop_contrig(constrname)
create function drop_contrig(text) returns text as '
    set d(tgname) {}
    spi_exec -array d "select c.relname,t.tgname from pg_class c, pg_trigger t where c.oid = t.tgrelid and tgconstrname = \'$1\'" {
        spi_exec "drop trigger \\"$d(tgname)\\" on $d(relname)"
    }
    if {$d(tgname) == {}} {return "No constraint trigger $1 found"}
    return "Drop trigger $d(tgname) on $d(relname)"
    ' LANGUAGE 'pltcl';
 
  --------------CCB32DE5933DCFC8E4E6F4D4-- --------------DC64707B563543886EB7EBD8 Content-Type: text/x-vcard; charset=us-ascii; name="kyle.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Kyle Content-Disposition: attachment; filename="kyle.vcf" begin:vcard n:Bateman;Kyle x-mozilla-html:FALSE org:Action Target Inc. adr:;;;;;; version:2.1 email;internet:kyle@actarg.com title:President x-mozilla-cpt:;0 fn:Kyle Bateman end:vcard --------------DC64707B563543886EB7EBD8--