Implement CSV output mode#92
Merged
Merged
Conversation
f7c50f2 to
dfb88b3
Compare
24f8ec3 to
f7c8089
Compare
359a77d to
e03aa43
Compare
mpdude
added a commit
that referenced
this pull request
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements a new output mode for CSV files.
The new command option
--output-csv=...enables CSV output mode, and must be given the path to a directory. The output mode will create.csvfiles in the given directory, named according to the dumped tables.This output format does not support output redirection from
stdoutas the default MySQL SQL format does.CSV files will be created only for tables that contain data. In other words,
schematype dumps will skip the table in question. Also, dumping views/triggers makes no sense for CSV files, they will be skipped as well.How to best write binary (BLOB) data and/or NULL values in CSV files is probably highly controversial. For now, we'll just go with the
0x...hex literals supported by MySQL. Maybe having binary data in CSV files is not a sane idea in the first place.Co-authored-by: Matthias Pigulla [email protected]