Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u4LnR-0010fd-6x for pgsql-general@arkaria.postgresql.org; Mon, 14 Apr 2025 15:32:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1u4LnO-002JdJ-U4 for pgsql-general@arkaria.postgresql.org; Mon, 14 Apr 2025 15:32:27 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u4LnO-002Jai-Ia for pgsql-general@lists.postgresql.org; Mon, 14 Apr 2025 15:32:27 +0000 Received: from fout-a1-smtp.messagingengine.com ([103.168.172.144]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1u4LnN-0002cP-0N for pgsql-general@lists.postgresql.org; Mon, 14 Apr 2025 15:32:26 +0000 Received: from phl-compute-02.internal (phl-compute-02.phl.internal [10.202.2.42]) by mailfout.phl.internal (Postfix) with ESMTP id 4AF3413801DE; Mon, 14 Apr 2025 11:32:24 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Mon, 14 Apr 2025 11:32:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1744644744; x=1744731144; bh=k80MQe5AeFQBM/AUdCLfi3sVE/i7T7pPlHRx5th3mB8=; b= A2402Mf2J3qrKvdns0WEO8TQFeCmCod7auEZz0CpS7HGI4CghSWpW+ZkRRjSmtIJ dWimSRsOR2A1Q0DFy/4tUQ24H6qNsIKgTPBvoqs+Bm1cPUZlddo5hS0VJpbwDLcA tyLQZY7cazp4SfX3QSFJPyzVbMc7mIGZ0i2G6JG7cEEm8W3iyyagSAOVrXMoWLPg AujJcf/KJsLYR6CfsK9FjG4zpA/78IvFqqObQ/3XHwKV+ALLZ7mISftYAII9G91P AJnCzPZICIVDjyXjTVDFL+r7Gxw3+r2ZRG761q0WL+LSXdsFsFo9PKHfJ2ek8Gz5 AfctY2IlDAkdUZsbVYE3ug== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1744644744; x= 1744731144; bh=k80MQe5AeFQBM/AUdCLfi3sVE/i7T7pPlHRx5th3mB8=; b=E VhIEIo89p/ACrmSMKWk8y9pw5klBRGPvVB8JRWsFpzkvgtFYWokAoWAK3xFlE89r rKLe3WOY1jF0pOdPffWdcDCMAbCfI0uSgY/wu9uZRUXofyHg7kkLbtq/g1K4r4bM hiFGui/n8e4H/ZAjJeEm1JKnRZDiVyPGspSYQHc0lCMzYKi0ZBonJxkZ62ZkmaH3 9YKkfIzpWT8K51lMxYG9X9nJzZXvUqrWAHnpyLXay1ZnVApEponUJKtxZvCLxPMx 0VRmhcTEnrvX9lRZwqN13OGU6T+Vx7HUFyd8UNUJ0BmmMSw01w79+VkdG0lcYFey a+R+2UQfPD/V2Ri5lM4+A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvvddtledvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddt vdejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvh gvrhesrghklhgrvhgvrhdrtghomheqnecuggftrfgrthhtvghrnhepgfdufeekhfevfeel veeiueevhedvuddukeduvddvlefhueeuieejtdeuvdevvdeunecuffhomhgrihhnpehpoh hsthhgrhgvshhqlhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhep mhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmpd hnsggprhgtphhtthhopeegpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehjihhm ihhssehgmhigrdhnvghtpdhrtghpthhtoheplhgruhhrvghniidrrghlsggvsegthigsvg hrthgvtgdrrghtpdhrtghpthhtohepthhglhesshhsshdrphhghhdrphgrrdhushdprhgt phhtthhopehpghhsqhhlqdhgvghnvghrrghlsehlihhsthhsrdhpohhsthhgrhgvshhqlh drohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 14 Apr 2025 11:32:23 -0400 (EDT) Message-ID: <3b2467c2-3af2-438a-87e6-81e6653ffd0e@aklaver.com> Date: Mon, 14 Apr 2025 08:32:22 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: TRUNCATE ONLY with foreign keys and triggers disabled To: Dimitrios Apostolou Cc: Laurenz Albe , Tom Lane , pgsql-general@lists.postgresql.org References: <1257959.1744641901@sss.pgh.pa.us> <6776dc7beaf591a684d089db4c77407b7a2866c4.camel@cybertec.at> <376367c8-1baf-3e64-9363-15fa24265b6c@gmx.net> Content-Language: en-US From: Adrian Klaver In-Reply-To: <376367c8-1baf-3e64-9363-15fa24265b6c@gmx.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 4/14/25 08:20, Dimitrios Apostolou wrote: > On Mon, 14 Apr 2025, Adrian Klaver wrote: > >> On 4/14/25 08:07, Laurenz Albe wrote: >>>  On Mon, 2025-04-14 at 17:05 +0200, Dimitrios Apostolou wrote: >>>>  I meant the *referencing* table has just been >>>>  populated. I'm trying to delete the *referenced* table and I get the >>>>  error. >>> >>>  That would break the foreign key constraint, right? >>>  PostgreSQL cannot allow that. >> >> I believe the OP is disabling all triggers including system ones if I >> follow >> correctly and possibly running a foul of; >> >> https://www.postgresql.org/docs/current/sql-altertable.html >> >> " Disabling or enabling internally generated constraint triggers requires >> superuser privileges; it should be done with caution since of course the >> integrity of the constraint cannot be guaranteed if the triggers are not >> executed." > > Exactly that. I learned this from pg_restore --disable-triggers, as a way > to speed-up insertion. > > Since triggers are disabled, I assumed that postgresql shouldn't care > about referential integrity in TRUNCATE. I'm going to say the depends on order of execution. Without seeing the code changes you have done there is really no way to determine what the exact issue is. > > > Dimitris > -- Adrian Klaver adrian.klaver@aklaver.com