Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g9dPZ-0001Pd-Mk for pgsql-bugs@arkaria.postgresql.org; Mon, 08 Oct 2018 21:49:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g9dPX-0001D5-HJ for pgsql-bugs@arkaria.postgresql.org; Mon, 08 Oct 2018 21:49:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g9dPX-0001Cy-BR for pgsql-bugs@lists.postgresql.org; Mon, 08 Oct 2018 21:49:55 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g9dPQ-00021N-Va for pgsql-bugs@postgresql.org; Mon, 08 Oct 2018 21:49:54 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w98Lnjcs024594; Mon, 8 Oct 2018 17:49:45 -0400 From: Tom Lane To: "Finnerty, Jim" cc: "pgsql-bugs@postgresql.org" Subject: Re: IMMEDIATE constraint enforcement does not comply with the SQL standard In-reply-to: References: Comments: In-reply-to "Finnerty, Jim" message dated "Mon, 08 Oct 2018 21:35:46 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <24592.1539035385.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 08 Oct 2018 17:49:45 -0400 Message-ID: <24593.1539035385@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "Finnerty, Jim" writes: > PostgreSQL executes AFTER triggers (and constraints) in alphabetical ord= er according to the name assigned to the trigger at creation time; therefo= re, PostgreSQL permits IMMEDIATE foreign key constraints to be deferred un= til after AFTER triggers are fired if their name sorts lower than =E2=80=9C= RI_ConstraintTrigger=E2=80=9D. This is a violation of the standard. We consider that a feature, not a bug. If you want standard-compliant behavior, don't name your triggers that way. On the other hand, if you'd like to get something done before FK constraints fire, you have the option to do so. (I think this is documented somewhere. If not, there's an opportunity for documentation improvement.) The fact that the sort is plain ASCII means that "RI_ConstraintTrigger" sorts before any lower-case trigger name, so the issue is not as large as it might otherwise seem. regards, tom lane