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 1u4MNT-001753-Rm for pgsql-general@arkaria.postgresql.org; Mon, 14 Apr 2025 16:09:44 +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 1u4MNR-002hsT-0n for pgsql-general@arkaria.postgresql.org; Mon, 14 Apr 2025 16:09:41 +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 1u4MNQ-002hsH-KX for pgsql-general@lists.postgresql.org; Mon, 14 Apr 2025 16:09:41 +0000 Received: from mout.gmx.net ([212.227.17.21]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1u4MNO-0002rk-2U for pgsql-general@lists.postgresql.org; Mon, 14 Apr 2025 16:09:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1744646972; x=1745251772; i=jimis@gmx.net; bh=zRX63okhUvIy95XrhX2ObefuwTz9od5XcvSLASgtciI=; h=X-UI-Sender-Class:Date:From:To:cc:Subject:In-Reply-To:Message-ID: References:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=ooKLqmXtazxnE5UwNMOgCvliDnD+0Iv+nhY4xupbjWkNr+9uTT2skrfBDtY8jGQS vgi4+9p8f+wHFuhAVcQCeWSy6jn6snkJTR8RXBm58orDjjw+j9vJn/e/Jol+u5mrp cbXK5l0Q+iYXQeam7JNHzrmU8k4SDgB+xSi5EQaH04OGVg8CY+YOvwKuOllbxLG7A hs2lA19lfIthn5oomc25lFalteD3G0Rp3+MGg4YbriHY2N1v8MlQcv7XbWKHbIDnA fQwmBymNaNhPlhL6FNZ46nBrZ6i8XURxUNiuAslu3GWZJnbOdKgfVK6JyZsDTuP69 384IgCAgztwrclFfrA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [10.9.70.81] ([185.55.106.54]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mel81-1tTvd03A1t-00cGoa; Mon, 14 Apr 2025 18:09:31 +0200 Date: Mon, 14 Apr 2025 18:09:30 +0200 (CEST) From: Dimitrios Apostolou To: Adrian Klaver cc: Laurenz Albe , Tom Lane , pgsql-general@lists.postgresql.org Subject: Re: TRUNCATE ONLY with foreign keys and triggers disabled In-Reply-To: <3b2467c2-3af2-438a-87e6-81e6653ffd0e@aklaver.com> Message-ID: <40e61dac-9903-2d45-0dd5-4d848106e7a0@gmx.net> References: <1257959.1744641901@sss.pgh.pa.us> <6776dc7beaf591a684d089db4c77407b7a2866c4.camel@cybertec.at> <376367c8-1baf-3e64-9363-15fa24265b6c@gmx.net> <3b2467c2-3af2-438a-87e6-81e6653ffd0e@aklaver.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="0-516259503-1744646971=:483477" X-Provags-ID: V03:K1:AVFePqnG2u9OUKR9AA8ERbMmFelhYUhxmuSQjfBrYLbU6/36x1i uR5malUejM9LKhS6oYo7bVMoIJlEc31wrSYC37Eu4bWuq/5655pfF+sNn8hdIqCHlanc3+i UEq+I0AUddc1oRdOsIBw+dfQ1Gjv9nbKj8GkLPT6LpVG5jdZ7QxHjy8MYCj3qDu97yFCNFN G5SWUrcLk4cQL+cvS8BzA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:NUUvyQrDXyM=;oI+J7XHVZFx04fuEOjCf0i65NOw QsBJgQvs6rM2BbCNeKzm5jY8Nn2d4Kq2+T/+oQNiVX60zv+epHimPi20/khvC7GM1riCHe74s PcfoK6kC8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ksSnuhz5xTo/t L6FlbwkVEv5ogAJUDRvO89iq6yx3EW/Rt6qap/Pfyieqmnp5Jfmvdf55GfPQ90w0s+2oX0x4T +ufLw+6KZdVzuSjTYC6KCECR+yqGqapoa4BZXAElbflRlIU9oO+za4ZYm9Dvm/zihoVv4bxR0 aoUCKVqGgpt04UhySGwYJeJvprebKUcbXKMDw7imZNHNXl8S7RoxyJ1LHKZEAbSsGKmddtX7X 1IfdTw01M9PHZEQwsnxc/iz7vzUio1V0t8F5NtH/K2eVF5JpbWFU+Dc7J2vFTMTVq7XfKguXm eLoXHcVjK0VhfpgaYi8Jkfek04rY= List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --0-516259503-1744646971=:483477 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable On Mon, 14 Apr 2025, Adrian Klaver wrote: > 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: >>>> =C2=A0On Mon, 2025-04-14 at 17:05 +0200, Dimitrios Apostolou wrote: >>>>> =C2=A0I meant the *referencing* table has just been >>>>> =C2=A0populated. I'm trying to delete the *referenced* table and I = get the >>>>> =C2=A0error. >>>> >>>> =C2=A0That would break the foreign key constraint, right? >>>> =C2=A0PostgreSQL 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 requ= ires >>> 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 c= ode > changes you have done there is really no way to determine what the exact > issue is. Sent patch here: https://www.postgresql.org/message-id/flat/4589087c-ec6f-4407-1f82-6cb2e68= 1ac0a%40gmx.net The reason I first sent here (pgsql-general) is that I wondered if the error is just an implementation shortcoming without deeper reasons, thus it would be achievable to try to fix it myself. Dimitris --0-516259503-1744646971=:483477--