Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1glOQh-0002Hp-37 for pgsql-bugs@arkaria.postgresql.org; Mon, 21 Jan 2019 01:31:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1glOQf-00055n-Oc for pgsql-bugs@arkaria.postgresql.org; Mon, 21 Jan 2019 01:31:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1glOQf-00055g-9k for pgsql-bugs@lists.postgresql.org; Mon, 21 Jan 2019 01:31:09 +0000 Received: from mail.webkr.de ([78.47.173.34]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1glOQb-0008Gj-Va for pgsql-bugs@lists.postgresql.org; Mon, 21 Jan 2019 01:31:07 +0000 ARC-Authentication-Results: i=1; rspamd; auth=pass smtp.auth=andre@webkr.de smtp.mailfrom=andre@webkr.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=webkr.de; s=dkim; t=1548034264; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=VZiR3cs++QZsu0GHecsRVqQI3Vd9M6TPEbH/QENm/sk=; b=kZmxjKwqPzNBNDpeFrFtBTh9e4MqQqYRHGyl+77grulZwY19dOfKQkiuHv4K3Pn1X8e9tY Ykf++iu21E8qlxbAwH9tv0kOJqEyg0n/6jckpmJsfh3QtzCX5u3ncpKyAJkQ+VpvipNyM+ PTM+yzy/plmk2sQ4MDQ1Lm+H2T3utQ4= ARC-Seal: i=1; s=dkim; d=webkr.de; t=1548034264; a=rsa-sha256; cv=none; b=f/eOlXAuJx1nyFdeRjzkyOc3gaQUi69MYhaWEgmpTXZqAAINJTHZDLfhmQd0HFjDwGwm5CIHrdYMyrauYG7UKHbGanf+dKHZd5nGrrfc9kGaDYaiOZWNMNO+lXfxxKI+ROeWcO/4ZlVLNaPM+I4b2POhrAl84wDqzam+HMH/A9k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=webkr.de; s=dkim; t=1548034264; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=VZiR3cs++QZsu0GHecsRVqQI3Vd9M6TPEbH/QENm/sk=; b=h+/P0v+PeD0QRvtyE3XZ2QpNOcFofaeRzFpERYLtvSit6gGHZGF+IM6wH7CBRhv2mmz9Pn UZsKUvX1z4NLeoCwnYOHwV76jXsQpISrjKCvRlWvl/wt9CFPWLS+6gdxwTYOJ2tez/lpO6 yYUxSXWC5Zl8KfTtHPT0cPN/5WYv0AE= Received: from andrePC (dslb-002-204-091-075.002.204.pools.vodafone-ip.de [2.204.91.75]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: andre@webkr.de) by mail.webkr.de (Postfix) with ESMTPSA id 174391A0EC1 for ; Mon, 21 Jan 2019 02:31:04 +0100 (CET) From: =?iso-8859-1?Q?Andr=E9_H=E4nsel?= To: Subject: Deferred foreign key and two updates block ALTER TABLE Date: Mon, 21 Jan 2019 02:31:04 +0100 Message-ID: <04ab01d4b128$fa63f510$ef2bdf30$@webkr.de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 thread-index: AdSxKC0QQ2Wc4SMwQXuhcUsfWowQng== Content-Language: de List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi list, this looks like a bug to me, forgive me if it's expected behavior: BEGIN; DROP TABLE IF EXISTS test; DROP TABLE IF EXISTS test_other; CREATE TABLE test( some_column integer NOT NULL, other_id integer NOT NULL ); CREATE TABLE test_other( other_id integer NOT NULL ); ALTER TABLE test_other ADD PRIMARY KEY (other_id); ALTER TABLE test ADD FOREIGN KEY (other_id) REFERENCES test_other DEFERRABLE; INSERT INTO test_other (other_id) VALUES (1); INSERT INTO test (some_column, other_id) VALUES (0, 1); COMMIT; BEGIN; SET CONSTRAINTS ALL DEFERRED; UPDATE test SET some_column =3D 1 WHERE some_column =3D 0; UPDATE test SET some_column =3D 2 WHERE some_column =3D 1; ALTER TABLE test ALTER COLUMN some_column TYPE smallint; COMMIT; Expected result: Both transactions can be committed without error Actual result: ERROR: cannot ALTER TABLE "test" because it has pending trigger events SQL state: 55006 Notes: - It doesn't matter if the UPDATEs are on the same or different colums = that are altered, there is still an error - There is no error if there is just one UPDATE instead of two (this = makes me think this might be a bug) - There is no error if both UPDATEs lead to the same result (when the = second UPDATE is a no-op, like setting some_column =3D 1 again) - There is no error if the foreign key is non-deferrable or currently immediate Regards, Andr=E9