Skip to content

Dump TRIGGER definitions _after_ data #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 21, 2022
Merged

Dump TRIGGER definitions _after_ data #100

merged 1 commit into from
Dec 21, 2022

Conversation

mpdude
Copy link
Member

@mpdude mpdude commented Dec 21, 2022

When the new CSV output mode with the concept of "output drivers" was added in #92, dumping TRIGGER definitions was made an implementation detail of the MySQL output driver. This caused TRIGGER definitions to be dumped right after the CREATE TABLE ... commands, before the actual data INSERT statements.

This potentially breaks the generated SQL files, since a newly created trigger may be relevant for the subsequent INSERT statements; however, MySQL requires that tables used in the trigger are also included in the LOCK TABLES statements.

The aim of this PR is to revert that change, i. e. to dump trigger definitions for a table after the data insert statements for it.

I think it is not necessary to move all trigger definitions to the very end of the output – that is, after all tables have been created and filled with data: A trigger depends on insert/update/deletes for a particular table and is executed only on these events. So, it is not a problem if a trigger refers to a table that has not been created/loaded yet as long as the trigger is not run (and avoiding to run it is the aim of this PR).

@mpdude mpdude merged commit 481b94a into master Dec 21, 2022
@mpdude mpdude deleted the triggers-after-data branch December 21, 2022 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant