pg.ddx.io pgsql-general@postgresql.org mailing list archivehelp / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Simon Kissane <skissane@medallia.com>
To: pgsql-general@postgresql.org
Subject: Re: cannot CREATE INDEX because it has pending trigger events
Date: Tue, 27 Aug 2019 09:59:20 +0200
Message-ID: <5af9d5d6ce2c3fa1d86aa755fe880044f0b1f098.camel@cybertec.at> (raw)
In-Reply-To: <B3E9F42B-4AD8-47EC-8E40-D96F2F906787@medallia.com>
References: <B3E9F42B-4AD8-47EC-8E40-D96F2F906787@medallia.com>
On Tue, 2019-08-27 at 12:00 +1000, Simon Kissane wrote:
> We have an application that works fine with Postgres 9.6, but fails
> with this error when we try installing it against 11.5
>
> I simplified the problem down to the following reproduce script:
>
> BEGIN TRANSACTION;
> CREATE TABLE resource (resource_id BIGINT NOT NULL PRIMARY KEY,
> resource_type BIGINT NOT NULL);
> ALTER TABLE ONLY resource ADD CONSTRAINT resource_type_fk FOREIGN KEY
> (resource_type) REFERENCES resource (resource_id) DEFERRABLE
> INITIALLY DEFERRED;
> INSERT INTO resource (resource_id,resource_type) values (1,1);
> INSERT INTO resource (resource_id,resource_type) values (2,1);
> INSERT INTO resource (resource_id,resource_type) values (3,2);
> CREATE UNIQUE INDEX IF NOT EXISTS resource_type_2_singleton ON
> resource (resource_type) WHERE resource_type=2;
> COMMIT;
>
> That script works fine in Postgres 9.6, but run it against 11.5 you
> get the error:
>
> ERROR: cannot CREATE INDEX "resource" because it has pending trigger
> events
> STATEMENT: CREATE UNIQUE INDEX IF NOT EXISTS
> resource_type_2_singleton ON resource (resource_type) WHERE
> resource_type=2;
This is fallout of commit 0d1885266630:
https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=0d1885266630eee1de5c43af463fe2b921451...
This commit is the fix for a bug:
https://www.postgresql.org/message-id/flat/A737B7A37273E048B164557ADEF4A58B53A4DC9A%40ntex2010i.host...
This might be a false positive hit or not, I am not certain.
Maybe the check is not required for AFTER triggers.
Anyway, the problem can be avoided by running
SET CONSTRAINTS resource_type_fk IMMEDIATE;
right before the CREATE INDEX, so I don't think it is a real problem.
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com
view thread (4+ messages) latest in thread
Message-ID: <5af9d5d6ce2c3fa1d86aa755fe880044f0b1f098.camel@cybertec.at> Permalink: ../5af9d5d6ce2c3fa1d86aa755fe880044f0b1f098.camel@cybertec.at/ Also on: postgresql.org/message-id/5af9d5d6ce2c3fa1d86aa755fe880044f0b1f098.camel@cybertec.at ·
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-general@postgresql.org Cc: laurenz.albe@cybertec.at, skissane@medallia.com Subject: Re: cannot CREATE INDEX because it has pending trigger events In-Reply-To: <5af9d5d6ce2c3fa1d86aa755fe880044f0b1f098.camel@cybertec.at> References: <B3E9F42B-4AD8-47EC-8E40-D96F2F906787@medallia.com> <5af9d5d6ce2c3fa1d86aa755fe880044f0b1f098.camel@cybertec.at> * 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