MySqlBackup.Net icon indicating copy to clipboard operation
MySqlBackup.Net copied to clipboard

Can the import process include a filtering function, similar to export, supporting views, functions,

Open xintiandi opened this issue 2 months ago • 2 comments

Can the import process include a filtering function, similar to export, supporting views, functions, It is possible to restore certain tables or functions based on one's needs. When a field in the database is set to the TINYINT type with a length of 1, but the actual value is 11, after backup, the value gets truncated and changed to 1, causing the restored value to be incorrect. Is it possible to prevent internal conversion and retain the original value, as Navicat does without any issues

xintiandi avatar Nov 04 '25 17:11 xintiandi

Hi, for the TINYINT type with a length of 1 problem, you can try the connection string option of TreatTinyAsBoolean=false. Example:

Server=localhost;Database=mydb;username=user;password=pass;TreatTinyAsBoolean=false;

About the first task, that is actually quite challenging, but definitely doable!

One of the best entry points to implement this is at line 2562:

void Import_AppendLineAndExecute(string line)

You can inject your customized solution there to detect the SQL before sending it for execution. You can perform something like text pattern recognition (like REGEX) on the SQL to identify which objects (tables, views, functions, etc.) are being processed, then decide whether to execute or skip them based on your filtering criteria.

This approach should work well for most common cases. The main things to watch out for are multi-line statements (especially stored procedures) and dependencies between objects.

adriancs2 avatar Nov 16 '25 13:11 adriancs2

Thank you for your reply. I tried the table filtering function, but it didn't work very well. Especially when restoring large files, such as SQL files over 600MB, using table filtering causes some errors midway, which is not easy to handle. Streaming batch processing can complete the task, but the restore speed is very slow, making it difficult to achieve a perfect solution.

xintiandi avatar Nov 18 '25 04:11 xintiandi