Search Postgresql Archives

Re: v9.1, DROP TRIGGER IF EXISTS behaving oddly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 01/14/2016 01:47 PM, Williamson, Michael wrote:
Please excuse my mistake.

We were dropping a view that had the trigger on it beforehand, then in
trying to re-build the entire schema had scripts that attempted to drop
trigger if they existed before re-creating the view and triggers.  I
over-sanitized the example I posted and made it unclear.

I did some more testing and DROP TRIGGER IF EXISTS indeed works as
expected if the table/view is there and the trigger is not there.

As a follow-up, it would be nice if "IF EXISTS" could apply to either
the trigger or the relation it is applied to, as I don't think a
trigger can't exist without a relation to apply it to.

That is the part Tom and David where trying to explain to me and I was not getting, the behavior has changed.

Some testing revealed this:

test=# select version();
version
----------------------------------------------------------------------------------------------------------------------------------
PostgreSQL 9.0.20 on i686-pc-linux-gnu, compiled by GCC gcc (SUSE Linux) 4.8.1 20130909 [gcc-4_8-branch revision 202388], 32-bit
(1 row)


test=# drop trigger if exists test_trg on test_tbl;
ERROR:  relation "test_tbl" does not exist


test=# select version();
version
-----------------------------------------------------------------------------------------------------------------------------
PostgreSQL 9.4.5 on i686-pc-linux-gnu, compiled by gcc (SUSE Linux) 4.8.3 20140627 [gcc-4_8-branch revision 212064], 32-bit
(1 row)


test=# drop trigger if exists test_trg on test_tbl;
NOTICE:  relation "test_tbl" does not exist, skipping
DROP TRIGGER

In either case though IF EXISTS did the right thing, so I am wondering if upgrading to a more recent version of 9.1 will help you.



Michael





--
Adrian Klaver
adrian.klaver@xxxxxxxxxxx


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux