Commit 8864a9b3 authored by patg@krsna.patg.net's avatar patg@krsna.patg.net

BUG #7815

Changes per serg to http://lists.mysql.com/internals/30281

Re-enabled --delayed-insert
parent 6f693ae6
...@@ -70,6 +70,11 @@ ...@@ -70,6 +70,11 @@
/* Size of buffer for dump's select query */ /* Size of buffer for dump's select query */
#define QUERY_LENGTH 1536 #define QUERY_LENGTH 1536
/* ignore table flags */
#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 */
static char *add_load_option(char *ptr, const char *object, static char *add_load_option(char *ptr, const char *object,
const char *statement); const char *statement);
static ulong find_set(TYPELIB *lib, const char *x, uint length, static ulong find_set(TYPELIB *lib, const char *x, uint length,
...@@ -209,9 +214,7 @@ static struct my_option my_long_options[] = ...@@ -209,9 +214,7 @@ static struct my_option my_long_options[] =
{"default-character-set", OPT_DEFAULT_CHARSET, {"default-character-set", OPT_DEFAULT_CHARSET,
"Set the default character set.", (gptr*) &default_charset, "Set the default character set.", (gptr*) &default_charset,
(gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"delayed-insert", OPT_DELAYED, "Insert rows with INSERT DELAYED; " {"delayed-insert", OPT_DELAYED, "Insert rows with INSERT DELAYED; ",
"currently ignored because of http://bugs.mysql.com/bug.php?id=7815 "
"but will be re-enabled later",
(gptr*) &opt_delayed, (gptr*) &opt_delayed, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, (gptr*) &opt_delayed, (gptr*) &opt_delayed, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0}, 0, 0},
{"delete-master-logs", OPT_DELETE_MASTER_LOGS, {"delete-master-logs", OPT_DELETE_MASTER_LOGS,
...@@ -411,7 +414,7 @@ static int init_dumping(char *); ...@@ -411,7 +414,7 @@ static int init_dumping(char *);
static int dump_databases(char **); static int dump_databases(char **);
static int dump_all_databases(); static int dump_all_databases();
static char *quote_name(const char *name, char *buff, my_bool force); static char *quote_name(const char *name, char *buff, my_bool force);
static const char *check_if_ignore_table(const char *table_name); char check_if_ignore_table(const char *table_name, char *table_type);
static char *primary_key_fields(const char *table_name); static char *primary_key_fields(const char *table_name);
static my_bool get_view_structure(char *table, char* db); static my_bool get_view_structure(char *table, char* db);
static my_bool dump_all_views_in_db(char *database); static my_bool dump_all_views_in_db(char *database);
...@@ -720,25 +723,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -720,25 +723,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
} }
break; break;
} }
#ifndef REMOVE_THIS_CODE_WHEN_FIX_BUG_7815
case (int) OPT_DELAYED:
/*
Because of http://bugs.mysql.com/bug.php?id=7815, we disable
--delayed-insert; when the bug gets fixed by checking the storage engine
(using the table definition cache) before printing INSERT DELAYED, we
can correct the option's description and re-enable it again (scheduled
for later 5.0 or 5.1 versions).
It's ok to do the if() below as get_one_option is called after
opt_delayed is set.
*/
if (opt_delayed)
{
fprintf(stderr, "Warning: ignoring --delayed-insert (as explained "
"in the output of 'mysqldump --help').\n");
opt_delayed= 0;
}
break;
#endif
} }
return 0; return 0;
} }
...@@ -1280,19 +1264,27 @@ static uint dump_routines_for_db (char *db) ...@@ -1280,19 +1264,27 @@ static uint dump_routines_for_db (char *db)
} }
/* /*
getTableStructure -- retrievs database structure, prints out corresponding get_table_structure -- retrievs database structure, prints out corresponding
CREATE statement and fills out insert_pat. CREATE statement and fills out insert_pat if the table is the type we will
be dumping.
ARGS
table - table name
db - db name
table_type - table type ie "InnoDB"
ignore_flag - what we must particularly ignore - see IGNORE_ defines above
RETURN RETURN
number of fields in table, 0 if error number of fields in table, 0 if error
*/ */
static uint get_table_structure(char *table, char *db) static uint get_table_structure(char *table, char *db, char *table_type,
char *ignore_flag)
{ {
MYSQL_RES *tableRes; MYSQL_RES *tableRes;
MYSQL_ROW row; MYSQL_ROW row;
my_bool init=0; my_bool init=0;
uint numFields; uint num_fields;
char *result_table, *opt_quoted_table; char *result_table, *opt_quoted_table;
const char *insert_option; const char *insert_option;
char name_buff[NAME_LEN+3],table_buff[NAME_LEN*2+3]; char name_buff[NAME_LEN+3],table_buff[NAME_LEN*2+3];
...@@ -1300,18 +1292,30 @@ static uint get_table_structure(char *table, char *db) ...@@ -1300,18 +1292,30 @@ static uint get_table_structure(char *table, char *db)
char query_buff[512]; char query_buff[512];
FILE *sql_file = md_result_file; FILE *sql_file = md_result_file;
int len; int len;
DBUG_ENTER("get_table_structure"); DBUG_ENTER("get_table_structure");
DBUG_PRINT("enter", ("db: %s, table: %s", db, table)); DBUG_PRINT("enter", ("db: %s, table: %s", db, table));
if (!insert_pat_inited) *ignore_flag= check_if_ignore_table(table, table_type);
if (opt_delayed && (*ignore_flag & IGNORE_INSERT_DELAYED))
if (verbose)
fprintf(stderr,
"-- Unable to use delayed inserts for table '%s' because it's of\
type %s\n", table, table_type);
if (!(*ignore_flag & IGNORE_DATA))
{ {
if (!insert_pat_inited)
insert_pat_inited= init_dynamic_string(&insert_pat, "", 1024, 1024); insert_pat_inited= init_dynamic_string(&insert_pat, "", 1024, 1024);
}
else else
dynstr_set(&insert_pat, ""); dynstr_set(&insert_pat, "");
}
insert_option= ((opt_delayed && opt_ignore) ? " DELAYED IGNORE " : insert_option= ((opt_delayed && opt_ignore &&
opt_delayed ? " DELAYED " : !(*ignore_flag & IGNORE_INSERT_DELAYED)) ?
" DELAYED IGNORE " :
opt_delayed && !(*ignore_flag & IGNORE_INSERT_DELAYED) ? " DELAYED " :
opt_ignore ? " IGNORE " : ""); opt_ignore ? " IGNORE " : "");
if (verbose) if (verbose)
...@@ -1321,7 +1325,8 @@ static uint get_table_structure(char *table, char *db) ...@@ -1321,7 +1325,8 @@ static uint get_table_structure(char *table, char *db)
"SET OPTION SQL_QUOTE_SHOW_CREATE=%d", "SET OPTION SQL_QUOTE_SHOW_CREATE=%d",
(opt_quoted || opt_keywords)); (opt_quoted || opt_keywords));
if (!create_options) if (!create_options)
strmov(query_buff+len, "/*!40102 ,SQL_MODE=concat(@@sql_mode, _utf8 ',NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS') */"); strmov(query_buff+len,
"/*!40102 ,SQL_MODE=concat(@@sql_mode, _utf8 ',NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS') */");
result_table= quote_name(table, table_buff, 1); result_table= quote_name(table, table_buff, 1);
opt_quoted_table= quote_name(table, table_buff2, 0); opt_quoted_table= quote_name(table, table_buff2, 0);
...@@ -1442,6 +1447,13 @@ static uint get_table_structure(char *table, char *db) ...@@ -1442,6 +1447,13 @@ static uint get_table_structure(char *table, char *db)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
/*
if *ignore_flag & IGNORE_DATA is true, then we don't build up insert statements
for the table's data. Note: in subsequent lines of code, this test will
have to be performed each time we are appending to insert_pat.
*/
if (!(*ignore_flag & IGNORE_DATA))
{
dynstr_append_mem(&insert_pat, "INSERT ", 7); dynstr_append_mem(&insert_pat, "INSERT ", 7);
dynstr_append(&insert_pat, insert_option); dynstr_append(&insert_pat, insert_option);
dynstr_append_mem(&insert_pat, "INTO ", 5); dynstr_append_mem(&insert_pat, "INTO ", 5);
...@@ -1456,20 +1468,21 @@ static uint get_table_structure(char *table, char *db) ...@@ -1456,20 +1468,21 @@ static uint get_table_structure(char *table, char *db)
if (!extended_insert) if (!extended_insert)
dynstr_append_mem(&insert_pat, "(", 1); dynstr_append_mem(&insert_pat, "(", 1);
} }
}
while ((row=mysql_fetch_row(tableRes))) while ((row=mysql_fetch_row(tableRes)))
{ {
if (init) if (init)
{ {
if (opt_complete_insert) if (opt_complete_insert && !(*ignore_flag & IGNORE_DATA))
dynstr_append_mem(&insert_pat, ", ", 2); dynstr_append_mem(&insert_pat, ", ", 2);
} }
init=1; init=1;
if (opt_complete_insert) if (opt_complete_insert && !(*ignore_flag & IGNORE_DATA))
dynstr_append(&insert_pat, dynstr_append(&insert_pat,
quote_name(row[SHOW_FIELDNAME], name_buff, 0)); quote_name(row[SHOW_FIELDNAME], name_buff, 0));
} }
numFields = (uint) mysql_num_rows(tableRes); num_fields= (uint) mysql_num_rows(tableRes);
mysql_free_result(tableRes); mysql_free_result(tableRes);
} }
else else
...@@ -1515,20 +1528,21 @@ static uint get_table_structure(char *table, char *db) ...@@ -1515,20 +1528,21 @@ static uint get_table_structure(char *table, char *db)
check_io(sql_file); check_io(sql_file);
} }
if (!(*ignore_flag & IGNORE_DATA))
{
dynstr_append_mem(&insert_pat, "INSERT ", 7); dynstr_append_mem(&insert_pat, "INSERT ", 7);
dynstr_append(&insert_pat, insert_option); dynstr_append(&insert_pat, insert_option);
dynstr_append_mem(&insert_pat, "INTO ", 5); dynstr_append_mem(&insert_pat, "INTO ", 5);
dynstr_append(&insert_pat, result_table); dynstr_append(&insert_pat, result_table);
if (opt_complete_insert) if (opt_complete_insert)
{
dynstr_append_mem(&insert_pat, " (", 2); dynstr_append_mem(&insert_pat, " (", 2);
}
else else
{ {
dynstr_append_mem(&insert_pat, " VALUES ", 8); dynstr_append_mem(&insert_pat, " VALUES ", 8);
if (!extended_insert) if (!extended_insert)
dynstr_append_mem(&insert_pat, "(", 1); dynstr_append_mem(&insert_pat, "(", 1);
} }
}
while ((row=mysql_fetch_row(tableRes))) while ((row=mysql_fetch_row(tableRes)))
{ {
...@@ -1540,11 +1554,11 @@ static uint get_table_structure(char *table, char *db) ...@@ -1540,11 +1554,11 @@ static uint get_table_structure(char *table, char *db)
fputs(",\n",sql_file); fputs(",\n",sql_file);
check_io(sql_file); check_io(sql_file);
} }
if (opt_complete_insert) if (opt_complete_insert && !(*ignore_flag & IGNORE_DATA))
dynstr_append_mem(&insert_pat, ", ", 2); dynstr_append_mem(&insert_pat, ", ", 2);
} }
init=1; init=1;
if (opt_complete_insert) if (opt_complete_insert && !(*ignore_flag & IGNORE_DATA))
dynstr_append(&insert_pat, dynstr_append(&insert_pat,
quote_name(row[SHOW_FIELDNAME], name_buff, 0)); quote_name(row[SHOW_FIELDNAME], name_buff, 0));
if (!tFlag) if (!tFlag)
...@@ -1575,7 +1589,7 @@ static uint get_table_structure(char *table, char *db) ...@@ -1575,7 +1589,7 @@ static uint get_table_structure(char *table, char *db)
check_io(sql_file); check_io(sql_file);
} }
} }
numFields = (uint) mysql_num_rows(tableRes); num_fields = (uint) mysql_num_rows(tableRes);
mysql_free_result(tableRes); mysql_free_result(tableRes);
if (!tFlag) if (!tFlag)
{ {
...@@ -1684,9 +1698,7 @@ static uint get_table_structure(char *table, char *db) ...@@ -1684,9 +1698,7 @@ static uint get_table_structure(char *table, char *db)
else else
{ {
if (opt_xml) if (opt_xml)
{
print_xml_row(sql_file, "options", tableRes, &row); print_xml_row(sql_file, "options", tableRes, &row);
}
else else
{ {
fputs("/*!",sql_file); fputs("/*!",sql_file);
...@@ -1707,7 +1719,7 @@ continue_xml: ...@@ -1707,7 +1719,7 @@ continue_xml:
check_io(sql_file); check_io(sql_file);
} }
} }
if (opt_complete_insert) if (opt_complete_insert && !(*ignore_flag & IGNORE_DATA))
{ {
dynstr_append_mem(&insert_pat, ") VALUES ", 9); dynstr_append_mem(&insert_pat, ") VALUES ", 9);
if (!extended_insert) if (!extended_insert)
...@@ -1719,7 +1731,7 @@ continue_xml: ...@@ -1719,7 +1731,7 @@ continue_xml:
write_footer(sql_file); write_footer(sql_file);
my_fclose(sql_file, MYF(MY_WME)); my_fclose(sql_file, MYF(MY_WME));
} }
DBUG_RETURN(numFields); DBUG_RETURN(num_fields);
} /* get_table_structure */ } /* get_table_structure */
...@@ -1844,20 +1856,40 @@ static char *alloc_query_str(ulong size) ...@@ -1844,20 +1856,40 @@ static char *alloc_query_str(ulong size)
/* /*
** dump_table saves database contents as a series of INSERT statements.
SYNOPSIS
dump_table()
dump_table saves database contents as a series of INSERT statements.
ARGS
table - table name
db - db name
RETURNS
void
*/ */
static void dump_table(uint numFields, char *table) static void dump_table(char *table, char *db)
{ {
char ignore_flag;
char query_buf[QUERY_LENGTH], *end, buff[256],table_buff[NAME_LEN+3]; char query_buf[QUERY_LENGTH], *end, buff[256],table_buff[NAME_LEN+3];
char table_type[NAME_LEN];
char *result_table, table_buff2[NAME_LEN*2+3], *opt_quoted_table; char *result_table, table_buff2[NAME_LEN*2+3], *opt_quoted_table;
char *query= query_buf; char *query= query_buf;
int error= 0;
ulong rownr, row_break, total_length, init_length;
uint num_fields;
MYSQL_RES *res; MYSQL_RES *res;
MYSQL_FIELD *field; MYSQL_FIELD *field;
MYSQL_ROW row; MYSQL_ROW row;
ulong rownr, row_break, total_length, init_length; DBUG_ENTER("dump_table");
const char *table_type;
int error= 0; /*
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.
*/
num_fields= get_table_structure(table, db, (char *)&table_type, &ignore_flag);
/* Check --no-data flag */ /* Check --no-data flag */
if (dFlag) if (dFlag)
...@@ -1866,31 +1898,35 @@ static void dump_table(uint numFields, char *table) ...@@ -1866,31 +1898,35 @@ static void dump_table(uint numFields, char *table)
fprintf(stderr, fprintf(stderr,
"-- Skipping dump data for table '%s', --no-data was used\n", "-- Skipping dump data for table '%s', --no-data was used\n",
table); table);
return; DBUG_VOID_RETURN;
} }
DBUG_PRINT("info", ("ignore_flag %x num_fields %d", ignore_flag, num_fields));
/*
If the table type is a merge table or any type that has to be
_completely_ ignored and no data dumped
*/
if (ignore_flag & IGNORE_DATA)
{
if (verbose)
fprintf(stderr,
"-- Skipping data for table '%s' because it's of type %s\n",
table, table_type);
DBUG_VOID_RETURN;
}
/* Check that there are any fields in the table */ /* Check that there are any fields in the table */
if (numFields == 0) if (num_fields == 0)
{ {
if (verbose) if (verbose)
fprintf(stderr, fprintf(stderr,
"-- Skipping dump data for table '%s', it has no fields\n", "-- Skipping dump data for table '%s', it has no fields\n",
table); table);
return; DBUG_VOID_RETURN;
} }
result_table= quote_name(table,table_buff, 1); result_table= quote_name(table,table_buff, 1);
opt_quoted_table= quote_name(table, table_buff2, 0); opt_quoted_table= quote_name(table, table_buff2, 0);
/* Check table type */
if ((table_type= check_if_ignore_table(table)))
{
if (verbose)
fprintf(stderr,
"-- Skipping data for table '%s' because it's of type %s\n",
table, table_type);
return;
}
if (verbose) if (verbose)
fprintf(stderr, "-- Sending SELECT query...\n"); fprintf(stderr, "-- Sending SELECT query...\n");
...@@ -1934,7 +1970,7 @@ static void dump_table(uint numFields, char *table) ...@@ -1934,7 +1970,7 @@ static void dump_table(uint numFields, char *table)
if (mysql_real_query(sock, query, (uint) (end - query))) if (mysql_real_query(sock, query, (uint) (end - query)))
{ {
DB_error(sock, "when executing 'SELECT INTO OUTFILE'"); DB_error(sock, "when executing 'SELECT INTO OUTFILE'");
return; DBUG_VOID_RETURN;
} }
} }
else else
...@@ -1989,7 +2025,7 @@ static void dump_table(uint numFields, char *table) ...@@ -1989,7 +2025,7 @@ static void dump_table(uint numFields, char *table)
DB_error(sock, "when retrieving data from server"); DB_error(sock, "when retrieving data from server");
if (verbose) if (verbose)
fprintf(stderr, "-- Retrieving rows...\n"); fprintf(stderr, "-- Retrieving rows...\n");
if (mysql_num_fields(res) != numFields) if (mysql_num_fields(res) != num_fields)
{ {
fprintf(stderr,"%s: Error in field count for table: %s ! Aborting.\n", fprintf(stderr,"%s: Error in field count for table: %s ! Aborting.\n",
my_progname, result_table); my_progname, result_table);
...@@ -2288,13 +2324,13 @@ static void dump_table(uint numFields, char *table) ...@@ -2288,13 +2324,13 @@ static void dump_table(uint numFields, char *table)
if (query != query_buf) if (query != query_buf)
my_free(query, MYF(MY_ALLOW_ZERO_PTR)); my_free(query, MYF(MY_ALLOW_ZERO_PTR));
} }
return; DBUG_VOID_RETURN;
err: err:
if (query != query_buf) if (query != query_buf)
my_free(query, MYF(MY_ALLOW_ZERO_PTR)); my_free(query, MYF(MY_ALLOW_ZERO_PTR));
safe_exit(error); safe_exit(error);
return; DBUG_VOID_RETURN;
} /* dump_table */ } /* dump_table */
...@@ -2495,8 +2531,7 @@ static int dump_all_tables_in_db(char *database) ...@@ -2495,8 +2531,7 @@ static int dump_all_tables_in_db(char *database)
char *end= strmov(afterdot, table); char *end= strmov(afterdot, table);
if (include_table(hash_key, end - hash_key)) if (include_table(hash_key, end - hash_key))
{ {
numrows = get_table_structure(table, database); dump_table(table,database);
dump_table(numrows,table);
my_free(order_by, MYF(MY_ALLOW_ZERO_PTR)); my_free(order_by, MYF(MY_ALLOW_ZERO_PTR));
order_by= 0; order_by= 0;
if (opt_dump_triggers && ! opt_xml && if (opt_dump_triggers && ! opt_xml &&
...@@ -2630,7 +2665,7 @@ static int get_actual_table_name(const char *old_table_name, ...@@ -2630,7 +2665,7 @@ static int get_actual_table_name(const char *old_table_name,
static int dump_selected_tables(char *db, char **table_names, int tables) static int dump_selected_tables(char *db, char **table_names, int tables)
{ {
uint numrows, i; uint i;
char table_buff[NAME_LEN*+3]; char table_buff[NAME_LEN*+3];
char new_table_name[NAME_LEN]; char new_table_name[NAME_LEN];
DYNAMIC_STRING lock_tables_query; DYNAMIC_STRING lock_tables_query;
...@@ -2699,8 +2734,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables) ...@@ -2699,8 +2734,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
{ {
table_name= hash_element(&dump_tables, i); table_name= hash_element(&dump_tables, i);
DBUG_PRINT("info",("Dumping table %s", table_name)); DBUG_PRINT("info",("Dumping table %s", table_name));
numrows= get_table_structure(table_name, db); dump_table(table_name,db);
dump_table(numrows, table_name);
if (opt_dump_triggers && if (opt_dump_triggers &&
mysql_get_server_version(sock) >= 50009) mysql_get_server_version(sock) >= 50009)
dump_triggers_for_table(table_name, db); dump_triggers_for_table(table_name, db);
...@@ -2899,28 +2933,37 @@ static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row, ...@@ -2899,28 +2933,37 @@ static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row,
/* /*
Check if we the table is one of the table types that should be ignored:
MRG_ISAM, MRG_MYISAM
SYNOPSIS SYNOPSIS
Check if we the table is one of the table types that should be ignored:
MRG_ISAM, MRG_MYISAM, if opt_delayed, if that table supports delayed inserts.
If the table should be altogether ignored, it returns a TRUE, FALSE if it
should not be ignored. If the user has selected to use INSERT DELAYED, it
sets the value of the bool pointer supports_delayed_inserts to 0 if not
supported, 1 if it is supported.
ARGS
check_if_ignore_table() check_if_ignore_table()
table_name Table name to check table_name Table name to check
table_type Type of table
GLOBAL VARIABLES GLOBAL VARIABLES
sock MySQL socket sock MySQL socket
verbose Write warning messages verbose Write warning messages
RETURN RETURN
0 Table should be backuped char (bit value) See IGNORE_ values at top
# Type of table (that should be skipped)
*/ */
static const char *check_if_ignore_table(const char *table_name) char check_if_ignore_table(const char *table_name, char *table_type)
{ {
bool result= IGNORE_NONE;
char buff[FN_REFLEN+80], show_name_buff[FN_REFLEN]; char buff[FN_REFLEN+80], show_name_buff[FN_REFLEN];
MYSQL_RES *res; MYSQL_RES *res;
MYSQL_ROW row; MYSQL_ROW row;
const char *result= 0; DBUG_ENTER("check_if_ignore_table");
/* Check memory for quote_for_like() */ /* Check memory for quote_for_like() */
DBUG_ASSERT(2*sizeof(table_name) < sizeof(show_name_buff)); DBUG_ASSERT(2*sizeof(table_name) < sizeof(show_name_buff));
...@@ -2934,7 +2977,7 @@ static const char *check_if_ignore_table(const char *table_name) ...@@ -2934,7 +2977,7 @@ static const char *check_if_ignore_table(const char *table_name)
fprintf(stderr, fprintf(stderr,
"-- Warning: Couldn't get status information for table %s (%s)\n", "-- Warning: Couldn't get status information for table %s (%s)\n",
table_name,mysql_error(sock)); table_name,mysql_error(sock));
return 0; /* assume table is ok */ DBUG_RETURN(IGNORE_NONE); /* assume table is ok */
} }
} }
if (!(row= mysql_fetch_row(res))) if (!(row= mysql_fetch_row(res)))
...@@ -2943,18 +2986,38 @@ static const char *check_if_ignore_table(const char *table_name) ...@@ -2943,18 +2986,38 @@ static const char *check_if_ignore_table(const char *table_name)
"Error: Couldn't read status information for table %s (%s)\n", "Error: Couldn't read status information for table %s (%s)\n",
table_name, mysql_error(sock)); table_name, mysql_error(sock));
mysql_free_result(res); mysql_free_result(res);
return 0; /* assume table is ok */ DBUG_RETURN(IGNORE_NONE); /* assume table is ok */
} }
if (!(row[1])) if (!(row[1]))
result= "VIEW"; strcpy(table_type,"VIEW");
else else
{ {
if (strcmp(row[1], (result= "MRG_MyISAM")) && /*
strcmp(row[1], (result= "MRG_ISAM"))) If the table type matches any of these, we do support delayed inserts.
result= 0; Note: we do not want to skip dumping this table if if is not one of
these types, but we do want to use delayed inserts in the dump if
the table type is _NOT_ one of these types
*/
sprintf(table_type, "%s",row[1]);
if (opt_delayed)
{
if (strcmp(table_type,"MyISAM") &&
strcmp(table_type,"ISAM") &&
strcmp(table_type,"ARCHIVE") &&
strcmp(table_type,"HEAP") &&
strcmp(table_type,"MEMORY"))
result= IGNORE_INSERT_DELAYED;
}
/*
If these two types, we do want to skip dumping the table
*/
if (!dFlag &&
(!strcmp(table_type,"MRG_MyISAM") || !strcmp(table_type,"MRG_ISAM")))
result= IGNORE_DATA;
} }
mysql_free_result(res); mysql_free_result(res);
return result; DBUG_RETURN(result);
} }
/* /*
......
drop table if exists t1;
Warnings:
Note 1051 Unknown table 't1'
drop table if exists t2;
Warnings:
Note 1051 Unknown table 't2'
drop table if exists t3;
Warnings:
Note 1051 Unknown table 't3'
drop table if exists t4;
Warnings:
Note 1051 Unknown table 't4'
drop table if exists t5;
Warnings:
Note 1051 Unknown table 't5'
drop table if exists t6;
Warnings:
Note 1051 Unknown table 't6'
create table t1 (id int(8), name varchar(32));
create table t2 (id int(8), name varchar(32)) ENGINE="MyISAM";
create table t3 (id int(8), name varchar(32)) ENGINE="MEMORY";
create table t4 (id int(8), name varchar(32)) ENGINE="HEAP";
create table t5 (id int(8), name varchar(32)) ENGINE="ARCHIVE";
create table t6 (id int(8), name varchar(32)) ENGINE="InnoDB";
insert into t1 values (1, 'first value');
insert into t1 values (2, 'first value');
insert into t1 values (3, 'first value');
insert into t1 values (4, 'first value');
insert into t1 values (5, 'first value');
insert into t2 values (1, 'first value');
insert into t2 values (2, 'first value');
insert into t2 values (3, 'first value');
insert into t2 values (4, 'first value');
insert into t2 values (5, 'first value');
insert into t3 values (1, 'first value');
insert into t3 values (2, 'first value');
insert into t3 values (3, 'first value');
insert into t3 values (4, 'first value');
insert into t3 values (5, 'first value');
insert into t4 values (1, 'first value');
insert into t4 values (2, 'first value');
insert into t4 values (3, 'first value');
insert into t4 values (4, 'first value');
insert into t4 values (5, 'first value');
insert into t5 values (1, 'first value');
insert into t5 values (2, 'first value');
insert into t5 values (3, 'first value');
insert into t5 values (4, 'first value');
insert into t5 values (5, 'first value');
insert into t6 values (1, 'first value');
insert into t6 values (2, 'first value');
insert into t6 values (3, 'first value');
insert into t6 values (4, 'first value');
insert into t6 values (5, 'first value');
select * from t1;
id name
1 first value
2 first value
3 first value
4 first value
5 first value
select * from t2;
id name
1 first value
2 first value
3 first value
4 first value
5 first value
select * from t3;
id name
1 first value
2 first value
3 first value
4 first value
5 first value
select * from t4;
id name
1 first value
2 first value
3 first value
4 first value
5 first value
select * from t5;
id name
1 first value
2 first value
3 first value
4 first value
5 first value
select * from t6;
id name
1 first value
2 first value
3 first value
4 first value
5 first value
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `test`;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`id` int(8) default NULL,
`name` varchar(32) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t1` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `t2`;
CREATE TABLE `t2` (
`id` int(8) default NULL,
`name` varchar(32) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t2` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
DROP TABLE IF EXISTS `t3`;
CREATE TABLE `t3` (
`id` int(8) default NULL,
`name` varchar(32) default NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t3` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t3` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t3` ENABLE KEYS */;
DROP TABLE IF EXISTS `t4`;
CREATE TABLE `t4` (
`id` int(8) default NULL,
`name` varchar(32) default NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t4` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t4` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t4` ENABLE KEYS */;
DROP TABLE IF EXISTS `t5`;
CREATE TABLE `t5` (
`id` int(8) default NULL,
`name` varchar(32) default NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t5` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t5` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t5` ENABLE KEYS */;
DROP TABLE IF EXISTS `t6`;
CREATE TABLE `t6` (
`id` int(8) default NULL,
`name` varchar(32) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t6` DISABLE KEYS */;
INSERT IGNORE INTO `t6` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t6` ENABLE KEYS */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `test`;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`id` int(8) default NULL,
`name` varchar(32) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT DELAYED INTO `t1` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `t2`;
CREATE TABLE `t2` (
`id` int(8) default NULL,
`name` varchar(32) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
INSERT DELAYED INTO `t2` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
DROP TABLE IF EXISTS `t3`;
CREATE TABLE `t3` (
`id` int(8) default NULL,
`name` varchar(32) default NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t3` DISABLE KEYS */;
INSERT DELAYED INTO `t3` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t3` ENABLE KEYS */;
DROP TABLE IF EXISTS `t4`;
CREATE TABLE `t4` (
`id` int(8) default NULL,
`name` varchar(32) default NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t4` DISABLE KEYS */;
INSERT DELAYED INTO `t4` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t4` ENABLE KEYS */;
DROP TABLE IF EXISTS `t5`;
CREATE TABLE `t5` (
`id` int(8) default NULL,
`name` varchar(32) default NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t5` DISABLE KEYS */;
INSERT DELAYED INTO `t5` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t5` ENABLE KEYS */;
DROP TABLE IF EXISTS `t6`;
CREATE TABLE `t6` (
`id` int(8) default NULL,
`name` varchar(32) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t6` DISABLE KEYS */;
INSERT INTO `t6` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t6` ENABLE KEYS */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
drop table t1;
drop table t2;
drop table t3;
drop table t4;
drop table t5;
drop table t6;
...@@ -614,9 +614,7 @@ CREATE TABLE `t1` ( ...@@ -614,9 +614,7 @@ CREATE TABLE `t1` (
/*!40000 ALTER TABLE `t1` DISABLE KEYS */; /*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE; INSERT DELAYED IGNORE INTO `t1` VALUES (1),(2),(3),(4),(5),(6);
INSERT IGNORE INTO `t1` VALUES (1),(2),(3),(4),(5),(6);
UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */; /*!40000 ALTER TABLE `t1` ENABLE KEYS */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
......
# Embedded server doesn't support external clients
--source include/not_embedded.inc
--source include/have_innodb.inc
--source include/have_archive.inc
--disable-warnings
drop table if exists t1;
drop table if exists t2;
drop table if exists t3;
drop table if exists t4;
drop table if exists t5;
drop table if exists t6;
--enable-warnings
create table t1 (id int(8), name varchar(32));
create table t2 (id int(8), name varchar(32)) ENGINE="MyISAM";
create table t3 (id int(8), name varchar(32)) ENGINE="MEMORY";
create table t4 (id int(8), name varchar(32)) ENGINE="HEAP";
create table t5 (id int(8), name varchar(32)) ENGINE="ARCHIVE";
create table t6 (id int(8), name varchar(32)) ENGINE="InnoDB";
insert into t1 values (1, 'first value');
insert into t1 values (2, 'first value');
insert into t1 values (3, 'first value');
insert into t1 values (4, 'first value');
insert into t1 values (5, 'first value');
insert into t2 values (1, 'first value');
insert into t2 values (2, 'first value');
insert into t2 values (3, 'first value');
insert into t2 values (4, 'first value');
insert into t2 values (5, 'first value');
insert into t3 values (1, 'first value');
insert into t3 values (2, 'first value');
insert into t3 values (3, 'first value');
insert into t3 values (4, 'first value');
insert into t3 values (5, 'first value');
insert into t4 values (1, 'first value');
insert into t4 values (2, 'first value');
insert into t4 values (3, 'first value');
insert into t4 values (4, 'first value');
insert into t4 values (5, 'first value');
insert into t5 values (1, 'first value');
insert into t5 values (2, 'first value');
insert into t5 values (3, 'first value');
insert into t5 values (4, 'first value');
insert into t5 values (5, 'first value');
insert into t6 values (1, 'first value');
insert into t6 values (2, 'first value');
insert into t6 values (3, 'first value');
insert into t6 values (4, 'first value');
insert into t6 values (5, 'first value');
select * from t1;
select * from t2;
select * from t3;
select * from t4;
select * from t5;
select * from t6;
--exec $MYSQL_DUMP --skip-comments --delayed-insert --insert-ignore --databases test
--exec $MYSQL_DUMP --skip-comments --delayed-insert --databases test
drop table t1;
drop table t2;
drop table t3;
drop table t4;
drop table t5;
drop table t6;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment