-
-
Notifications
You must be signed in to change notification settings - Fork 2k
MDEV-38735 Support --hex-blob option for mysqldump --tab/--dir and mariadb-import to preserve binary data #4610
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
Open
jendis
wants to merge
2
commits into
MariaDB:main
Choose a base branch
from
jendis:hexblob
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,516
−16
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3473,7 +3473,7 @@ static uint get_table_structure(const char *table, const char *db, char *table_t | |
| mysql_free_result(result); | ||
| } | ||
| my_snprintf(query_buff, sizeof(query_buff), | ||
| "select column_name, extra, generation_expression, data_type " | ||
| "select column_name, extra, generation_expression, data_type, character_set_name " | ||
| "from information_schema.columns where table_schema=database() " | ||
| "and table_name=%s order by ordinal_position", | ||
| quote_for_equal(table, temp_buff)); | ||
|
|
@@ -3506,6 +3506,26 @@ static uint get_table_structure(const char *table, const char *db, char *table_t | |
| dynstr_append_checked(&select_field_names_for_header, ", "); | ||
| } | ||
| init=1; | ||
| my_bool is_blob_field= 0; | ||
| /* | ||
| Check if this is a binary/blob field that should be hex-encoded. | ||
| For multi_file_output (--tab/--dir), we need to wrap with HEX() in SELECT. | ||
| Binary fields have character_set_name = NULL or 'binary'. | ||
| */ | ||
| if (opt_hex_blob && multi_file_output && row[3]) | ||
| { | ||
| /* Check for blob/binary types with binary charset */ | ||
| if ((row[4] == NULL || strcmp(row[4], "binary") == 0) && | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you really need to check both the character set and the data type? |
||
| (strcmp(row[3], "binary") == 0 || | ||
| strcmp(row[3], "varbinary") == 0 || | ||
| strcmp(row[3], "tinyblob") == 0 || | ||
| strcmp(row[3], "blob") == 0 || | ||
| strcmp(row[3], "mediumblob") == 0 || | ||
| strcmp(row[3], "longblob") == 0)) | ||
| { | ||
| is_blob_field= 1; | ||
| } | ||
| } | ||
|
|
||
| last_name= quote_name(row[0], name_buff, 0); | ||
| if (opt_dump_history && *versioned && opt_update_history && | ||
|
|
@@ -3520,6 +3540,13 @@ static uint get_table_structure(const char *table, const char *db, char *table_t | |
| dynstr_append_checked(&select_field_names, ") as "); | ||
| dynstr_append_checked(&select_field_names, last_name); | ||
| } | ||
| else if (is_blob_field) | ||
| { | ||
| dynstr_append_checked(&select_field_names, "HEX("); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you have a spacing issue here. please fix. For the full diff. |
||
| dynstr_append_checked(&select_field_names, last_name); | ||
| dynstr_append_checked(&select_field_names, ") AS "); | ||
| dynstr_append_checked(&select_field_names, last_name); | ||
| } | ||
| else | ||
| dynstr_append_checked(&select_field_names, last_name); | ||
| dynstr_append_checked(&insert_field_names, last_name); | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not really is_blob_field, is it? I'd call it is_print_as_hex.