mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Merge with 4.0.17
BitKeeper/etc/logging_ok: auto-union Build-tools/Do-compile: Auto merged acinclude.m4: Auto merged configure.in: Auto merged dbug/dbug.c: Auto merged include/config-win.h: Auto merged include/my_base.h: Auto merged include/my_global.h: Auto merged include/my_pthread.h: Auto merged include/my_sys.h: Auto merged include/mysql.h: Auto merged include/mysql_com.h: Auto merged innobase/lock/lock0lock.c: Auto merged innobase/row/row0ins.c: Auto merged innobase/row/row0sel.c: Auto merged innobase/row/row0umod.c: Auto merged innobase/row/row0upd.c: Auto merged myisam/ft_boolean_search.c: Auto merged myisam/mi_check.c: Auto merged myisam/mi_dbug.c: Auto merged myisam/mi_open.c: Auto merged mysql-test/r/auto_increment.result: Auto merged mysql-test/r/bdb.result: Auto merged mysql-test/r/func_op.result: Auto merged Build-tools/Bootstrap: Merge with 4.0 client/mysql.cc: Merge with 4.0 client/mysqldump.c: Merge with 4.0 client/mysqltest.c: Use local version innobase/btr/btr0cur.c: Merge with 4.0 (Heikki should check if we should remove btr_cur_update_sec_rec_in_place() libmysql/libmysql.c: Merge with 4.0 libmysqld/lib_sql.cc: Merge with 4.0 myisam/mi_key.c: Merge with 4.0 myisam/mi_search.c: Merge with 4.0 mysql-test/r/binary.result: Merge with 4.0 mysql-test/r/func_group.result: Merge with 4.0 mysql-test/r/func_str.result: Merge with 4.0 mysql-test/r/func_time.result: Merge with 4.0 mysql-test/r/group_by.result: Merge with 4.0 mysql-test/r/handler.result: Merge with 4.0 mysql-test/r/innodb.result: Merge with 4.0 mysql-test/r/insert.result: Merge with 4.0 mysql-test/r/join_outer.result: Merge with 4.0 mysql-test/r/loaddata.result: Merge with 4.0 mysql-test/r/lowercase_table.result: Merge with 4.0 mysql-test/r/multi_update.result: Merge with 4.0 mysql-test/r/mysqldump.result: Merge with 4.0 mysql-test/r/query_cache.result: Merge with 4.0 mysql-test/r/rpl_max_relay_size.result: Merge with 4.0 mysql-test/r/rpl_rotate_logs.result: Merge with 4.0 mysql-test/r/rpl_trunc_binlog.result: Merge with 4.0 mysql-test/r/select_found.result: Merge with 4.0 mysql-test/r/symlink.result: Merge with 4.0 mysql-test/r/truncate.result: Merge with 4.0 mysql-test/r/type_blob.result: Merge with 4.0 mysql-test/r/type_datetime.result: Merge with 4.0 mysql-test/r/type_decimal.result: Merge with 4.0 mysql-test/r/type_enum.result: Merge with 4.0 mysql-test/r/type_timestamp.result: Merge with 4.0 mysql-test/r/union.result: Merge with 4.0 mysql-test/t/auto_increment.test: Merge with 4.0 mysql-test/t/bdb.test: Merge with 4.0 mysql-test/t/func_group.test: Merge with 4.0 mysql-test/t/func_op.test: Merge with 4.0 mysql-test/t/func_str.test: Merge with 4.0 mysql-test/t/func_time.test: Merge with 4.0 mysql-test/t/group_by.test: Merge with 4.0 mysql-test/t/handler.test: Merge with 4.0 mysql-test/t/innodb.test: Merge with 4.0 mysql-test/t/insert.test: Merge with 4.0 mysql-test/t/join_outer.test: Merge with 4.0 mysql-test/t/limit.test: Merge with 4.0 mysql-test/t/loaddata.test: Merge with 4.0 mysql-test/t/lowercase_table.test: Merge with 4.0 mysql-test/t/multi_update.test: Merge with 4.0 mysql-test/t/mysqldump.test: Merge with 4.0 mysql-test/t/query_cache.test: Merge with 4.0 mysql-test/t/rpl_log_pos.test: Merge with 4.0 mysql-test/t/rpl_max_relay_size.test: Merge with 4.0 mysql-test/t/rpl_rotate_logs.test: Merge with 4.0 mysql-test/t/rpl_trunc_binlog.test: Merge with 4.0 mysql-test/t/select_found.test: Merge with 4.0 mysql-test/t/symlink.test: Merge with 4.0 mysql-test/t/truncate.test: Merge with 4.0 mysql-test/t/type_blob.test: Merge with 4.0 mysql-test/t/type_datetime.test: Merge with 4.0 mysql-test/t/type_decimal.test: Merge with 4.0 mysql-test/t/type_enum.test: Merge with 4.0 mysql-test/t/type_timestamp.test: Merge with 4.0 mysql-test/t/union.test: Merge with 4.0 mysys/charset.c: Merge with 4.0 mysys/my_init.c: Merge with 4.0 mysys/my_symlink.c: Merge with 4.0 mysys/my_thr_init.c: Merge with 4.0 regex/reginit.c: Merge with 4.0 sql/field.cc: Change fix_datetime() to print errors sql/field.h: Merge with 4.0 sql/ha_innodb.cc: Merge with 4.0 sql/item.cc: Merge with 4.0 sql/item.h: Merge with 4.0 sql/item_cmpfunc.cc: Merge with 4.0 sql/item_func.cc: Merge with 4.0 sql/item_func.h: Merge with 4.0 sql/item_strfunc.cc: Merge with 4.0 sql/item_strfunc.h: Merge with 4.0 sql/item_sum.cc: Merge with 4.0 sql/item_sum.h: Merge with 4.0 sql/item_timefunc.cc: Merge with 4.0 sql/lex.h: Merge with 4.0 sql/log.cc: Merge with 4.0 sql/log_event.cc: Merge with 4.0 sql/log_event.h: Merge with 4.0 sql/mysql_priv.h: Merge with 4.0 sql/mysqld.cc: Merge with 4.0 sql/nt_servc.cc: Merge with 4.0 sql/opt_range.cc: Merge with 4.0 sql/records.cc: Merge with 4.0 sql/repl_failsafe.cc: Merge with 4.0 sql/slave.cc: Merge with 4.0 sql/sql_acl.cc: Merge with 4.0 sql/sql_analyse.cc: Merge with 4.0 sql/sql_base.cc: Merge with 4.0 sql/sql_cache.cc: Merge with 4.0 sql/sql_class.h: Merge with 4.0 sql/sql_db.cc: Merge with 4.0 sql/sql_delete.cc: Merge with 4.0 sql/sql_insert.cc: Merge with 4.0 sql/sql_load.cc: Merge with 4.0 sql/sql_parse.cc: Merge with 4.0 sql/sql_rename.cc: Merge with 4.0 sql/sql_select.cc: Merge with 4.0 sql/sql_show.cc: Merge with 4.0 sql/sql_table.cc: Merge with 4.0 sql/sql_update.cc: Merge with 4.0 sql/sql_yacc.yy: Merge with 4.0 sql/table.cc: Merge with 4.0 sql/table.h: Merge with 4.0 sql/time.cc: Merge with 4.0 sql/uniques.cc: Merge with 4.0 strings/ctype-tis620.c: Merge with 4.0 strings/strto.c: Merge with 4.0 support-files/mysql.server.sh: Merge with 4.0 support-files/mysql.spec.sh: Merge with 4.0
This commit is contained in:
@ -37,7 +37,7 @@
|
||||
** 10 Jun 2003: SET NAMES and --no-set-names by Alexander Barkov
|
||||
*/
|
||||
|
||||
#define DUMP_VERSION "10.3"
|
||||
#define DUMP_VERSION "10.4"
|
||||
|
||||
#include <my_global.h>
|
||||
#include <my_sys.h>
|
||||
@ -81,7 +81,7 @@ static my_bool verbose=0,tFlag=0,cFlag=0,dFlag=0,quick= 1, extended_insert= 1,
|
||||
opt_alldbs=0,opt_create_db=0,opt_first_slave=0,opt_set_names=0,
|
||||
opt_autocommit=0,opt_master_data,opt_disable_keys=1,opt_xml=0,
|
||||
opt_delete_master_logs=0, tty_password=0,
|
||||
opt_single_transaction=0;
|
||||
opt_single_transaction=0, opt_comments= 0;
|
||||
static MYSQL mysql_connection,*sock=0;
|
||||
static char insert_pat[12 * 1024],*opt_password=0,*current_user=0,
|
||||
*current_host=0,*path=0,*fields_terminated=0,
|
||||
@ -280,12 +280,15 @@ static struct my_option my_long_options[] =
|
||||
NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, "",
|
||||
(gptr*) &max_allowed_packet, (gptr*) &max_allowed_packet, 0,
|
||||
GET_ULONG, REQUIRED_ARG, 24*1024*1024, 4096, 1024*1024L*1024L,
|
||||
MALLOC_OVERHEAD, 1024, 0},
|
||||
GET_ULONG, REQUIRED_ARG, 24*1024*1024, 4096,
|
||||
(longlong) 2L*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
|
||||
{"net_buffer_length", OPT_NET_BUFFER_LENGTH, "",
|
||||
(gptr*) &net_buffer_length, (gptr*) &net_buffer_length, 0,
|
||||
GET_ULONG, REQUIRED_ARG, 1024*1024L-1025, 4096, 16*1024L*1024L,
|
||||
MALLOC_OVERHEAD-1024, 1024, 0},
|
||||
{"comments", 'i', "Write additional information.",
|
||||
(gptr*) &opt_comments, (gptr*) &opt_comments, 0, GET_BOOL, NO_ARG,
|
||||
1, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@ -302,6 +305,8 @@ static int init_dumping(char *);
|
||||
static int dump_databases(char **);
|
||||
static int dump_all_databases();
|
||||
static char *quote_name(const char *name, char *buff, my_bool force);
|
||||
static const char *check_if_ignore_table(const char *table_name);
|
||||
|
||||
|
||||
static void print_version(void)
|
||||
{
|
||||
@ -345,7 +350,7 @@ static void write_header(FILE *sql_file, char *db_name)
|
||||
fputs("<?xml version=\"1.0\"?>\n", sql_file);
|
||||
fputs("<mysqldump>\n", sql_file);
|
||||
}
|
||||
else
|
||||
else if (opt_comments)
|
||||
{
|
||||
fprintf(sql_file, "-- MySQL dump %s\n--\n", DUMP_VERSION);
|
||||
fprintf(sql_file, "-- Host: %s Database: %s\n",
|
||||
@ -656,6 +661,23 @@ static char *quote_name(const char *name, char *buff, my_bool force)
|
||||
} /* quote_name */
|
||||
|
||||
|
||||
|
||||
static char *quote_for_like(const char *name, char *buff)
|
||||
{
|
||||
char *to= buff;
|
||||
*to++= '\'';
|
||||
while (*name)
|
||||
{
|
||||
if (*name == '\'' || *name == '_' || *name == '\\' || *name == '%')
|
||||
*to++= '\\';
|
||||
*to++= *name++;
|
||||
}
|
||||
to[0]= '\'';
|
||||
to[1]= 0;
|
||||
return buff;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Quote and print a string.
|
||||
|
||||
@ -854,7 +876,8 @@ static uint getTableStructure(char *table, char* db)
|
||||
}
|
||||
write_header(sql_file, db);
|
||||
}
|
||||
fprintf(sql_file, "\n--\n-- Table structure for table %s\n--\n\n",
|
||||
if (!opt_xml && opt_comments)
|
||||
fprintf(sql_file, "\n--\n-- Table structure for table %s\n--\n\n",
|
||||
result_table);
|
||||
if (opt_drop)
|
||||
fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n", opt_quoted_table);
|
||||
@ -930,7 +953,7 @@ static uint getTableStructure(char *table, char* db)
|
||||
}
|
||||
write_header(sql_file, db);
|
||||
}
|
||||
if (!opt_xml)
|
||||
if (!opt_xml && opt_comments)
|
||||
fprintf(sql_file, "\n--\n-- Table structure for table %s\n--\n\n",
|
||||
result_table);
|
||||
if (opt_drop)
|
||||
@ -1067,16 +1090,9 @@ static uint getTableStructure(char *table, char* db)
|
||||
/* Get MySQL specific create options */
|
||||
if (create_options)
|
||||
{
|
||||
ulong len= strlen(table);
|
||||
char *tmp= (char*) my_malloc(len * 2 + 1, MYF(MY_WME));
|
||||
if (!tmp)
|
||||
{
|
||||
ignore_errors= 0;
|
||||
safe_exit(EX_MYSQLERR);
|
||||
}
|
||||
mysql_real_escape_string(&mysql_connection, tmp, table, len);
|
||||
sprintf(buff,"show table status like \"%s\"", tmp);
|
||||
my_free(tmp, MYF(MY_WME));
|
||||
char show_name_buff[FN_REFLEN];
|
||||
sprintf(buff,"show table status like %s",
|
||||
quote_for_like(table, show_name_buff));
|
||||
if (mysql_query(sock, buff))
|
||||
{
|
||||
if (mysql_errno(sock) != ER_PARSE_ERROR)
|
||||
@ -1191,11 +1207,23 @@ static void dumpTable(uint numFields, char *table)
|
||||
MYSQL_FIELD *field;
|
||||
MYSQL_ROW row;
|
||||
ulong rownr, row_break, total_length, init_length;
|
||||
const char *table_type;
|
||||
|
||||
result_table= quote_name(table,table_buff, 1);
|
||||
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)
|
||||
fprintf(stderr, "-- Sending SELECT query...\n");
|
||||
result_table= quote_name(table,table_buff, 1);
|
||||
opt_quoted_table= quote_name(table, table_buff2, 0);
|
||||
if (path)
|
||||
{
|
||||
char filename[FN_REFLEN], tmp_path[FN_REFLEN];
|
||||
@ -1234,14 +1262,14 @@ static void dumpTable(uint numFields, char *table)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!opt_xml)
|
||||
if (!opt_xml && opt_comments)
|
||||
fprintf(md_result_file,"\n--\n-- Dumping data for table %s\n--\n",
|
||||
result_table);
|
||||
sprintf(query, "SELECT /*!40001 SQL_NO_CACHE */ * FROM %s",
|
||||
result_table);
|
||||
if (where)
|
||||
{
|
||||
if (!opt_xml)
|
||||
if (!opt_xml && opt_comments)
|
||||
fprintf(md_result_file,"-- WHERE: %s\n",where);
|
||||
strxmov(strend(query), " WHERE ",where,NullS);
|
||||
}
|
||||
@ -1337,11 +1365,23 @@ static void dumpTable(uint numFields, char *table)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* change any strings ("inf","nan",..) into NULL */
|
||||
/* change any strings ("inf", "-inf", "nan") into NULL */
|
||||
char *ptr = row[i];
|
||||
dynstr_append(&extended_row,
|
||||
(!my_isalpha(charset_info,*ptr)) ?
|
||||
ptr : "NULL");
|
||||
if (my_isalpha(charset_info, *ptr) || (*ptr == '-' &&
|
||||
my_isalpha(charset_info, ptr[1])))
|
||||
dynstr_append(&extended_row, "NULL");
|
||||
else
|
||||
{
|
||||
if (field->type == FIELD_TYPE_DECIMAL)
|
||||
{
|
||||
/* add " signs around */
|
||||
dynstr_append(&extended_row, "\"");
|
||||
dynstr_append(&extended_row, ptr);
|
||||
dynstr_append(&extended_row, "\"");
|
||||
}
|
||||
else
|
||||
dynstr_append(&extended_row, ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1373,7 +1413,7 @@ static void dumpTable(uint numFields, char *table)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* change any strings ("inf","nan",..) into NULL */
|
||||
/* change any strings ("inf", "-inf", "nan") into NULL */
|
||||
char *ptr = row[i];
|
||||
if (opt_xml)
|
||||
{
|
||||
@ -1383,9 +1423,19 @@ static void dumpTable(uint numFields, char *table)
|
||||
md_result_file);
|
||||
fputs("</field>\n", md_result_file);
|
||||
}
|
||||
else
|
||||
fputs((!my_isalpha(charset_info,*ptr)) ?
|
||||
ptr : "NULL", md_result_file);
|
||||
else if (my_isalpha(charset_info, *ptr) ||
|
||||
(*ptr == '-' && my_isalpha(charset_info, ptr[1])))
|
||||
fputs("NULL", md_result_file);
|
||||
else if (field->type == FIELD_TYPE_DECIMAL)
|
||||
{
|
||||
/* add " signs around */
|
||||
fputs("\"", md_result_file);
|
||||
fputs(ptr, md_result_file);
|
||||
fputs("\"", md_result_file);
|
||||
}
|
||||
else
|
||||
fputs(ptr, md_result_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1533,8 +1583,8 @@ static int init_dumping(char *database)
|
||||
*/
|
||||
char quoted_database_buf[64*2+3];
|
||||
char *qdatabase= quote_name(database,quoted_database_buf,opt_quoted);
|
||||
|
||||
fprintf(md_result_file,"\n--\n-- Current Database: %s\n--\n", qdatabase);
|
||||
if (opt_comments)
|
||||
fprintf(md_result_file,"\n--\n-- Current Database: %s\n--\n", qdatabase);
|
||||
if (!opt_create_db)
|
||||
{
|
||||
char qbuf[256];
|
||||
@ -1730,6 +1780,61 @@ static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row,
|
||||
} /* print_value */
|
||||
|
||||
|
||||
/*
|
||||
Check if we the table is one of the table types that should be ignored:
|
||||
MRG_ISAM, MRG_MYISAM
|
||||
|
||||
SYNOPSIS
|
||||
check_if_ignore_table()
|
||||
table_name Table name to check
|
||||
|
||||
GLOBAL VARIABLES
|
||||
sock MySQL socket
|
||||
verbose Write warning messages
|
||||
|
||||
RETURN
|
||||
0 Table should be backuped
|
||||
# Type of table (that should be skipped)
|
||||
*/
|
||||
|
||||
static const char *check_if_ignore_table(const char *table_name)
|
||||
{
|
||||
char buff[FN_REFLEN+80], show_name_buff[FN_REFLEN];
|
||||
MYSQL_RES *res;
|
||||
MYSQL_ROW row;
|
||||
const char *result= 0;
|
||||
|
||||
sprintf(buff,"show table status like %s",
|
||||
quote_for_like(table_name, show_name_buff));
|
||||
if (mysql_query(sock, buff))
|
||||
{
|
||||
if (mysql_errno(sock) != ER_PARSE_ERROR)
|
||||
{ /* If old MySQL version */
|
||||
if (verbose)
|
||||
fprintf(stderr,
|
||||
"-- Warning: Couldn't get status information for table %s (%s)\n",
|
||||
table_name,mysql_error(sock));
|
||||
return 0; /* assume table is ok */
|
||||
}
|
||||
}
|
||||
if (!(res= mysql_store_result(sock)) ||
|
||||
!(row= mysql_fetch_row(res)))
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Error: Couldn't read status information for table %s (%s)\n",
|
||||
table_name, mysql_error(sock));
|
||||
if (res)
|
||||
mysql_free_result(res);
|
||||
return 0; /* assume table is ok */
|
||||
}
|
||||
if (strcmp(row[1], (result= "MRG_MyISAM")) &&
|
||||
strcmp(row[1], (result= "MRG_ISAM")))
|
||||
result= 0;
|
||||
mysql_free_result(res);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
MYSQL_ROW row;
|
||||
@ -1799,8 +1904,9 @@ int main(int argc, char **argv)
|
||||
row = mysql_fetch_row(master);
|
||||
if (row && row[0] && row[1])
|
||||
{
|
||||
fprintf(md_result_file,
|
||||
"\n--\n-- Position to start replication from\n--\n\n");
|
||||
if (opt_comments)
|
||||
fprintf(md_result_file,
|
||||
"\n--\n-- Position to start replication from\n--\n\n");
|
||||
fprintf(md_result_file,
|
||||
"CHANGE MASTER TO MASTER_LOG_FILE='%s', \
|
||||
MASTER_LOG_POS=%s ;\n",row[0],row[1]);
|
||||
|
Reference in New Issue
Block a user