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 1hlwA5-0008JN-72 for pgsql-general@arkaria.postgresql.org; Fri, 12 Jul 2019 14:04:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hlwA3-0003Vo-Pf for pgsql-general@arkaria.postgresql.org; Fri, 12 Jul 2019 14:04:31 +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 1hlwA3-0003Uf-C9 for pgsql-general@lists.postgresql.org; Fri, 12 Jul 2019 14:04:31 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hlwA1-0007PP-0e for pgsql-general@postgresql.org; Fri, 12 Jul 2019 14:04:30 +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 x6CE4PbN026584; Fri, 12 Jul 2019 10:04:25 -0400 From: Tom Lane To: =?UTF-8?Q?Emanuel_Ara=C3=BAjo?= cc: pgsql-general@postgresql.org Subject: Re: disable and enable trigger all when a foreign keys In-reply-to: References: Comments: In-reply-to =?UTF-8?Q?Emanuel_Ara=C3=BAjo?= message dated "Fri, 12 Jul 2019 10:46:53 -0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <26582.1562940264.1@sss.pgh.pa.us> Date: Fri, 12 Jul 2019 10:04:25 -0400 Message-ID: <26583.1562940265@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =?UTF-8?Q?Emanuel_Ara=C3=BAjo?= writes: > This is a situation when we needed fill a new store data in a family env. > When I run "alter table a disable trigger all;" ... the foreign key > "a_id_b_fkey" was disabled to, its ok, but I needed run a load data into > tables "a"and "b" and table a exists a tuple that not exists in column id_b > -> (references b(id)). > When finished, the command "alter table a enable trigger all" was executed > but not alert or broken, why? Cause orphan record is there. > This behavior is common or when doing "enable trigger all" PostgreSQL > whould show me a error or a warning? Well, yeah, DISABLE TRIGGER ALL defeats enforcement of FK constraints. That's why you have to be superuser to use it[1]. Perhaps disabling only user triggers would have been the way to do what you want. regards, tom lane [1] The general assumption in PG is that superusers know what they're doing.