public inbox for [email protected]
help / color / mirror / Atom feedRe: TRUNCATE ONLY with foreign keys and triggers disabled
2+ messages / 2 participants
[nested] [flat]
* Re: TRUNCATE ONLY with foreign keys and triggers disabled
@ 2025-04-14 15:32 Adrian Klaver <[email protected]>
2025-04-14 16:09 ` Re: TRUNCATE ONLY with foreign keys and triggers disabled Dimitrios Apostolou <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Adrian Klaver @ 2025-04-14 15:32 UTC (permalink / raw)
To: Dimitrios Apostolou <[email protected]>; +Cc: Laurenz Albe <[email protected]>; Tom Lane <[email protected]>; [email protected]
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
[email protected]
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: TRUNCATE ONLY with foreign keys and triggers disabled
2025-04-14 15:32 Re: TRUNCATE ONLY with foreign keys and triggers disabled Adrian Klaver <[email protected]>
@ 2025-04-14 16:09 ` Dimitrios Apostolou <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Dimitrios Apostolou @ 2025-04-14 16:09 UTC (permalink / raw)
To: Adrian Klaver <[email protected]>; +Cc: Laurenz Albe <[email protected]>; Tom Lane <[email protected]>; [email protected]
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:
>>>> 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.
Sent patch here:
https://www.postgresql.org/message-id/flat/4589087c-ec6f-4407-1f82-6cb2e681ac0a%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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2025-04-14 16:09 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-04-14 15:32 Re: TRUNCATE ONLY with foreign keys and triggers disabled Adrian Klaver <[email protected]>
2025-04-14 16:09 ` Dimitrios Apostolou <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox