-
Notifications
You must be signed in to change notification settings - Fork 5
MDEV-21786 mysqldump will forget sequence definition details on --no-… #3
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
base: 10.3
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ | |
** 10 Jun 2003: SET NAMES and --no-set-names by Alexander Barkov | ||
*/ | ||
|
||
#define DUMP_VERSION "10.17" | ||
#define DUMP_VERSION "10.18" | ||
|
||
#include <my_global.h> | ||
#include <my_sys.h> | ||
|
@@ -83,6 +83,7 @@ | |
#define IGNORE_NONE 0x00 /* no ignore */ | ||
#define IGNORE_DATA 0x01 /* don't dump data for this table */ | ||
#define IGNORE_INSERT_DELAYED 0x02 /* table doesn't support INSERT DELAYED */ | ||
#define IGNORE_SEQUENCE_TABLE 0x04 /* catch the SEQUENCE*/ | ||
|
||
/* Chars needed to store LONGLONG, excluding trailing '\0'. */ | ||
#define LONGLONG_LEN 20 | ||
|
@@ -2738,7 +2739,56 @@ static inline my_bool general_log_or_slow_log_tables(const char *db, | |
!my_strcasecmp(charset_info, table, "slow_log") || | ||
!my_strcasecmp(charset_info, table, "transaction_registry")); | ||
} | ||
/* | ||
get_sequence_structure-- retrievs sequence structure, prints out corresponding | ||
CREATE statement | ||
ARGS | ||
seq - sequence name | ||
db - db name | ||
*/ | ||
|
||
static void get_sequence_structure(const char *seq, const char *db) | ||
{ | ||
|
||
char table_buff[NAME_LEN*2+3]; | ||
char *result_seq; | ||
FILE *sql_file= md_result_file; | ||
MYSQL_RES *result; | ||
MYSQL_ROW row; | ||
|
||
DBUG_ENTER("get_sequence_structure"); | ||
DBUG_PRINT("enter", ("db: %s sequence: %s", db, seq)); | ||
|
||
verbose_msg("-- Retrieving sequence structure for %s...\n", seq); | ||
|
||
result_seq= quote_name(seq, table_buff, 1); | ||
// Sequences as tables share same flags | ||
if (!opt_no_create_info) | ||
{ | ||
char buff[20+FN_REFLEN]; | ||
my_snprintf(buff, sizeof(buff), "SHOW CREATE SEQUENCE %s", result_seq); | ||
if (mysql_query_with_error_report(mysql, &result, buff)) | ||
{ | ||
DBUG_VOID_RETURN; | ||
} | ||
|
||
print_comment(sql_file, 0, | ||
"\n--\n-- Sequence structure for %s\n--\n\n", | ||
fix_for_comment(result_seq)); | ||
if (opt_drop) | ||
{ | ||
fprintf(sql_file, "DROP SEQUENCE IF EXISTS %s;\n", result_seq); | ||
check_io(sql_file); | ||
} | ||
|
||
row= mysql_fetch_row(result); | ||
fprintf(sql_file, "%s;\n", row[1]); | ||
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. what do you thing about using 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. I'm bit confused with the syntax which is a bit unclear 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. prior to this change, with |
||
|
||
// Sequences will not use inserts, so no need for REPLACE and LOCKS | ||
mysql_free_result(result); | ||
} | ||
DBUG_VOID_RETURN; | ||
} | ||
/* | ||
get_table_structure -- retrievs database structure, prints out corresponding | ||
CREATE statement and fills out insert_pat if the table is the type we will | ||
|
@@ -3720,6 +3770,14 @@ static void dump_table(char *table, char *db, const uchar *hash_key, size_t len) | |
MYSQL_ROW row; | ||
DBUG_ENTER("dump_table"); | ||
|
||
/* | ||
Check does table has a sequence structure and if has apply different sql queries | ||
*/ | ||
if (check_if_ignore_table(table, table_type) & IGNORE_SEQUENCE_TABLE) | ||
{ | ||
get_sequence_structure(table, db); | ||
DBUG_VOID_RETURN; | ||
} | ||
/* | ||
Make sure you get the create table info before the following check for | ||
--no-data flag below. Otherwise, the create table info won't be printed. | ||
|
@@ -5688,7 +5746,7 @@ char check_if_ignore_table(const char *table_name, char *table_type) | |
/* Check memory for quote_for_like() */ | ||
DBUG_ASSERT(2*sizeof(table_name) < sizeof(show_name_buff)); | ||
my_snprintf(buff, sizeof(buff), | ||
"SELECT engine FROM INFORMATION_SCHEMA.TABLES " | ||
"SELECT engine, table_type FROM INFORMATION_SCHEMA.TABLES " | ||
"WHERE table_schema = DATABASE() AND table_name = %s", | ||
quote_for_equal(table_name, show_name_buff)); | ||
if (mysql_query_with_error_report(mysql, &res, buff)) | ||
|
@@ -5728,7 +5786,8 @@ char check_if_ignore_table(const char *table_name, char *table_type) | |
strcmp(table_type,"MEMORY")) | ||
result= IGNORE_INSERT_DELAYED; | ||
} | ||
|
||
if (!strcmp(row[1],"SEQUENCE")) | ||
result|= IGNORE_SEQUENCE_TABLE; | ||
/* | ||
If these two types, we do want to skip dumping the table | ||
*/ | ||
|
Uh oh!
There was an error while loading. Please reload this page.