abg / dbsake

Collection of mysql tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dbsake sieve --format=stream + filtering + multiple databases

abg opened this issue · comments

If there are multiple databases and filtering only matches one (or some subset) of these databases, the empty CREATE DATABASE ... / USE <database> sections are still output. If this output is imported into a MySQL database, then empty databases are created which is annoying.

I think here it might make sense to defer output of these "CREATE DATABASE" sections (or the trailing "USE database" sections during final view creation) until at least one table event is output - possibly with an option to --include-empty-databases?

This is complicated in the case of views, since view creation is deferred until the very end of the backup, so if we store the original CREATE DATABASE strings we may have to queue this for all databases. Even for thousands of databases, this isn't a terrible amount of data but still increases the memory footprint. This would be necessary to remember the original character set of the database, at least.