Обсуждение: Re: "drop constraint trigger" on PostgreSQL

Поиск
Список
Период
Сортировка

Re: "drop constraint trigger" on PostgreSQL

От
Kyle
Дата:
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';
 
 

Вложения