Subject Re: [Firebird-Architect] rfc: TRUNCATE TABLE
Author Adriano dos Santos Fernandes
Roman Rokytskyy escreveu:
>> Why? Other DDL statements also perform the most important work in DFW,
>> but you proposed to have the appropriate AFTER triggers for them. As far
>> as I see, the only thing that differs for TRUNCATE is that both BEFORE
>> and AFTER triggers will be semantically equivalent, as there are no
>> metadata modifications during the statement execution that could be seen
>> in the AFTER trigger.
>>
Having a AFTER TRUNCATE trigger accessing a truncated table and be able
to read/write data to it seems dangerous to me. And that data will be
lost later.

This is not just a problem of DDL triggers, but any statement running
after a TRUNCATE on the same transaction.

Perhaps, we should block access to them before the commit? In this case,
AFTER have no more/different value than BEFORE.

>
> Not 100% correct. If the TRUNCATE fails during the execution, the AFTER
> trigger won't be fired, so any action there won't be executed.
But with proposed DDL triggers AFTER triggers will be fired. So all
possible verifications should be done early.


Adriano