Commit 4aa5270d authored by unknown's avatar unknown

Merge mysql.com:/users/lthalmann/bkroot/mysql-5.0

into  mysql.com:/users/lthalmann/bk/MERGE/mysql-5.0-merge


sql/ha_ndbcluster.cc:
  Auto merged
parents 3435f614 151fe0cf
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
** AUTHOR: Igor Romanenko (igor@frog.kiev.ua) ** AUTHOR: Igor Romanenko (igor@frog.kiev.ua)
** DATE: December 3, 1994 ** DATE: December 3, 1994
** WARRANTY: None, expressed, impressed, implied ** WARRANTY: None, expressed, impressed, implied
** or other ** or other
** STATUS: Public domain ** STATUS: Public domain
** Adapted and optimized for MySQL by ** Adapted and optimized for MySQL by
** Michael Widenius, Sinisa Milivojevic, Jani Tolonen ** Michael Widenius, Sinisa Milivojevic, Jani Tolonen
...@@ -77,22 +77,22 @@ ...@@ -77,22 +77,22 @@
#define IGNORE_INSERT_DELAYED 0x02 /* table doesn't support INSERT DELAYED */ #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,
char **err_pos, uint *err_len); char **err_pos, uint *err_len);
static char *alloc_query_str(ulong size); static char *alloc_query_str(ulong size);
static char *field_escape(char *to,const char *from,uint length); static char *field_escape(char *to,const char *from,uint length);
static my_bool verbose=0,tFlag=0,dFlag=0,quick= 1, extended_insert= 1, static my_bool verbose=0,tFlag=0,dFlag=0,quick= 1, extended_insert= 1,
lock_tables=1,ignore_errors=0,flush_logs=0, lock_tables=1,ignore_errors=0,flush_logs=0,
opt_drop=1,opt_keywords=0,opt_lock=1,opt_compress=0, opt_drop=1,opt_keywords=0,opt_lock=1,opt_compress=0,
opt_delayed=0,create_options=1,opt_quoted=0,opt_databases=0, opt_delayed=0,create_options=1,opt_quoted=0,opt_databases=0,
opt_alldbs=0,opt_create_db=0,opt_lock_all_tables=0, opt_alldbs=0,opt_create_db=0,opt_lock_all_tables=0,
opt_set_charset=0, opt_set_charset=0,
opt_autocommit=0,opt_disable_keys=1,opt_xml=0, opt_autocommit=0,opt_disable_keys=1,opt_xml=0,
opt_delete_master_logs=0, tty_password=0, opt_delete_master_logs=0, tty_password=0,
opt_single_transaction=0, opt_comments= 0, opt_compact= 0, opt_single_transaction=0, opt_comments= 0, opt_compact= 0,
opt_hex_blob=0, opt_order_by_primary=0, opt_ignore=0, opt_hex_blob=0, opt_order_by_primary=0, opt_ignore=0,
opt_complete_insert= 0, opt_drop_database= 0, opt_complete_insert= 0, opt_drop_database= 0,
opt_dump_triggers= 0, opt_routines=0, opt_tz_utc=1; opt_dump_triggers= 0, opt_routines=0, opt_tz_utc=1;
static ulong opt_max_allowed_packet, opt_net_buffer_length; static ulong opt_max_allowed_packet, opt_net_buffer_length;
...@@ -129,8 +129,8 @@ static const char *mysql_universal_client_charset= ...@@ -129,8 +129,8 @@ static const char *mysql_universal_client_charset=
static char *default_charset; static char *default_charset;
static CHARSET_INFO *charset_info= &my_charset_latin1; static CHARSET_INFO *charset_info= &my_charset_latin1;
const char *default_dbug_option="d:t:o,/tmp/mysqldump.trace"; const char *default_dbug_option="d:t:o,/tmp/mysqldump.trace";
/* do we met VIEWs during tables scaning */ /* have we seen any VIEWs during table scanning? */
my_bool was_views= 0; my_bool seen_views= 0;
const char *compatible_mode_names[]= const char *compatible_mode_names[]=
{ {
...@@ -149,7 +149,7 @@ const char *compatible_mode_names[]= ...@@ -149,7 +149,7 @@ const char *compatible_mode_names[]=
(1<<10) /* ANSI */\ (1<<10) /* ANSI */\
) )
TYPELIB compatible_mode_typelib= {array_elements(compatible_mode_names) - 1, TYPELIB compatible_mode_typelib= {array_elements(compatible_mode_names) - 1,
"", compatible_mode_names, NULL}; "", compatible_mode_names, NULL};
HASH ignore_table; HASH ignore_table;
...@@ -276,7 +276,7 @@ static struct my_option my_long_options[] = ...@@ -276,7 +276,7 @@ static struct my_option my_long_options[] =
{"lines-terminated-by", OPT_LTB, "Lines in the i.file are terminated by ...", {"lines-terminated-by", OPT_LTB, "Lines in the i.file are terminated by ...",
(gptr*) &lines_terminated, (gptr*) &lines_terminated, 0, GET_STR, (gptr*) &lines_terminated, (gptr*) &lines_terminated, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"lock-all-tables", 'x', "Locks all tables across all databases. This " {"lock-all-tables", 'x', "Locks all tables across all databases. This "
"is achieved by taking a global read lock for the duration of the whole " "is achieved by taking a global read lock for the duration of the whole "
"dump. Automatically turns --single-transaction and --lock-tables off.", "dump. Automatically turns --single-transaction and --lock-tables off.",
(gptr*) &opt_lock_all_tables, (gptr*) &opt_lock_all_tables, 0, GET_BOOL, NO_ARG, (gptr*) &opt_lock_all_tables, (gptr*) &opt_lock_all_tables, 0, GET_BOOL, NO_ARG,
...@@ -297,7 +297,7 @@ static struct my_option my_long_options[] = ...@@ -297,7 +297,7 @@ static struct my_option my_long_options[] =
GET_UINT, OPT_ARG, 0, 0, MYSQL_OPT_MASTER_DATA_COMMENTED_SQL, 0, 0, 0}, GET_UINT, OPT_ARG, 0, 0, MYSQL_OPT_MASTER_DATA_COMMENTED_SQL, 0, 0, 0},
{"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, "", {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, "",
(gptr*) &opt_max_allowed_packet, (gptr*) &opt_max_allowed_packet, 0, (gptr*) &opt_max_allowed_packet, (gptr*) &opt_max_allowed_packet, 0,
GET_ULONG, REQUIRED_ARG, 24*1024*1024, 4096, GET_ULONG, REQUIRED_ARG, 24*1024*1024, 4096,
(longlong) 2L*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0}, (longlong) 2L*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
{"net_buffer_length", OPT_NET_BUFFER_LENGTH, "", {"net_buffer_length", OPT_NET_BUFFER_LENGTH, "",
(gptr*) &opt_net_buffer_length, (gptr*) &opt_net_buffer_length, 0, (gptr*) &opt_net_buffer_length, (gptr*) &opt_net_buffer_length, 0,
...@@ -411,8 +411,8 @@ static const char *load_default_groups[]= { "mysqldump","client",0 }; ...@@ -411,8 +411,8 @@ static const char *load_default_groups[]= { "mysqldump","client",0 };
static void safe_exit(int error); static void safe_exit(int error);
static void write_header(FILE *sql_file, char *db_name); static void write_header(FILE *sql_file, char *db_name);
static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row, static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row,
const char *prefix,const char *name, const char *prefix,const char *name,
int string_value); int string_value);
static int dump_selected_tables(char *db, char **table_names, int tables); static int dump_selected_tables(char *db, char **table_names, int tables);
static int dump_all_tables_in_db(char *db); static int dump_all_tables_in_db(char *db);
static int init_dumping(char *); static int init_dumping(char *);
...@@ -428,10 +428,10 @@ static my_bool dump_all_views_in_db(char *database); ...@@ -428,10 +428,10 @@ static my_bool dump_all_views_in_db(char *database);
/* /*
exit with message if ferror(file) exit with message if ferror(file)
SYNOPSIS SYNOPSIS
check_io() check_io()
file - checked file file - checked file
*/ */
void check_io(FILE *file) void check_io(FILE *file)
...@@ -456,7 +456,7 @@ static void short_usage_sub(void) ...@@ -456,7 +456,7 @@ static void short_usage_sub(void)
{ {
printf("Usage: %s [OPTIONS] database [tables]\n", my_progname); printf("Usage: %s [OPTIONS] database [tables]\n", my_progname);
printf("OR %s [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]\n", printf("OR %s [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]\n",
my_progname); my_progname);
printf("OR %s [OPTIONS] --all-databases [OPTIONS]\n", my_progname); printf("OR %s [OPTIONS] --all-databases [OPTIONS]\n", my_progname);
NETWARE_SET_SCREEN_MODE(1); NETWARE_SET_SCREEN_MODE(1);
} }
...@@ -501,12 +501,12 @@ static void write_header(FILE *sql_file, char *db_name) ...@@ -501,12 +501,12 @@ static void write_header(FILE *sql_file, char *db_name)
{ {
fprintf(sql_file, "-- MySQL dump %s\n--\n", DUMP_VERSION); fprintf(sql_file, "-- MySQL dump %s\n--\n", DUMP_VERSION);
fprintf(sql_file, "-- Host: %s Database: %s\n", fprintf(sql_file, "-- Host: %s Database: %s\n",
current_host ? current_host : "localhost", db_name ? db_name : current_host ? current_host : "localhost", db_name ? db_name :
""); "");
fputs("-- ------------------------------------------------------\n", fputs("-- ------------------------------------------------------\n",
sql_file); sql_file);
fprintf(sql_file, "-- Server version\t%s\n", fprintf(sql_file, "-- Server version\t%s\n",
mysql_get_server_info(&mysql_connection)); mysql_get_server_info(&mysql_connection));
} }
if (opt_set_charset) if (opt_set_charset)
fprintf(sql_file, fprintf(sql_file,
...@@ -529,10 +529,10 @@ static void write_header(FILE *sql_file, char *db_name) ...@@ -529,10 +529,10 @@ static void write_header(FILE *sql_file, char *db_name)
"); ");
} }
fprintf(sql_file, fprintf(sql_file,
"/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='%s%s%s' */;\n" "/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='%s%s%s' */;\n"
"/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;\n", "/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;\n",
path?"":"NO_AUTO_VALUE_ON_ZERO",compatible_mode_normal_str[0]==0?"":",", path?"":"NO_AUTO_VALUE_ON_ZERO",compatible_mode_normal_str[0]==0?"":",",
compatible_mode_normal_str); compatible_mode_normal_str);
check_io(sql_file); check_io(sql_file);
} }
} /* write_header */ } /* write_header */
...@@ -563,7 +563,7 @@ static void write_footer(FILE *sql_file) ...@@ -563,7 +563,7 @@ static void write_footer(FILE *sql_file)
"/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;\n" "/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;\n"
"/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;\n"); "/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;\n");
fprintf(sql_file, fprintf(sql_file,
"/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;\n"); "/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;\n");
fputs("\n", sql_file); fputs("\n", sql_file);
check_io(sql_file); check_io(sql_file);
} }
...@@ -577,7 +577,7 @@ static void free_table_ent(char *key) ...@@ -577,7 +577,7 @@ static void free_table_ent(char *key)
byte* get_table_key(const char *entry, uint *length, byte* get_table_key(const char *entry, uint *length,
my_bool not_used __attribute__((unused))) my_bool not_used __attribute__((unused)))
{ {
*length= strlen(entry); *length= strlen(entry);
return (byte*) entry; return (byte*) entry;
...@@ -594,7 +594,7 @@ void init_table_rule_hash(HASH* h) ...@@ -594,7 +594,7 @@ void init_table_rule_hash(HASH* h)
static my_bool static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)), get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument) char *argument)
{ {
switch (optid) { switch (optid) {
#ifdef __NETWARE__ #ifdef __NETWARE__
...@@ -608,9 +608,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -608,9 +608,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *start=argument; char *start=argument;
my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR)); my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
opt_password=my_strdup(argument,MYF(MY_FAE)); opt_password=my_strdup(argument,MYF(MY_FAE));
while (*argument) *argument++= 'x'; /* Destroy argument */ while (*argument) *argument++= 'x'; /* Destroy argument */
if (*start) if (*start)
start[1]=0; /* Cut length of argument */ start[1]=0; /* Cut length of argument */
tty_password= 0; tty_password= 0;
} }
else else
...@@ -618,7 +618,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -618,7 +618,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break; break;
case 'r': case 'r':
if (!(md_result_file = my_fopen(argument, O_WRONLY | FILE_BINARY, if (!(md_result_file = my_fopen(argument, O_WRONLY | FILE_BINARY,
MYF(MY_WME)))) MYF(MY_WME))))
exit(1); exit(1);
break; break;
case 'W': case 'W':
...@@ -639,7 +639,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -639,7 +639,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case 'V': print_version(); exit(0); case 'V': print_version(); exit(0);
case 'X': case 'X':
opt_xml = 1; opt_xml = 1;
extended_insert= opt_drop= opt_lock= extended_insert= opt_drop= opt_lock=
opt_disable_keys= opt_autocommit= opt_create_db= 0; opt_disable_keys= opt_autocommit= opt_create_db= 0;
break; break;
case 'I': case 'I':
...@@ -692,36 +692,36 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -692,36 +692,36 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
opt_set_charset= 0; opt_set_charset= 0;
opt_compatible_mode_str= argument; opt_compatible_mode_str= argument;
opt_compatible_mode= find_set(&compatible_mode_typelib, opt_compatible_mode= find_set(&compatible_mode_typelib,
argument, strlen(argument), argument, strlen(argument),
&err_ptr, &err_len); &err_ptr, &err_len);
if (err_len) if (err_len)
{ {
strmake(buff, err_ptr, min(sizeof(buff), err_len)); strmake(buff, err_ptr, min(sizeof(buff), err_len));
fprintf(stderr, "Invalid mode to --compatible: %s\n", buff); fprintf(stderr, "Invalid mode to --compatible: %s\n", buff);
exit(1); exit(1);
} }
#if !defined(DBUG_OFF) #if !defined(DBUG_OFF)
{ {
uint size_for_sql_mode= 0; uint size_for_sql_mode= 0;
const char **ptr; const char **ptr;
for (ptr= compatible_mode_names; *ptr; ptr++) for (ptr= compatible_mode_names; *ptr; ptr++)
size_for_sql_mode+= strlen(*ptr); size_for_sql_mode+= strlen(*ptr);
size_for_sql_mode+= sizeof(compatible_mode_names)-1; size_for_sql_mode+= sizeof(compatible_mode_names)-1;
DBUG_ASSERT(sizeof(compatible_mode_normal_str)>=size_for_sql_mode); DBUG_ASSERT(sizeof(compatible_mode_normal_str)>=size_for_sql_mode);
} }
#endif #endif
mode= opt_compatible_mode; mode= opt_compatible_mode;
for (i= 0, mode= opt_compatible_mode; mode; mode>>= 1, i++) for (i= 0, mode= opt_compatible_mode; mode; mode>>= 1, i++)
{ {
if (mode & 1) if (mode & 1)
{ {
end= strmov(end, compatible_mode_names[i]); end= strmov(end, compatible_mode_names[i]);
end= strmov(end, ","); end= strmov(end, ",");
} }
} }
if (end!=compatible_mode_normal_str) if (end!=compatible_mode_normal_str)
end[-1]= 0; end[-1]= 0;
/* /*
Set charset to the default compiled value if it hasn't Set charset to the default compiled value if it hasn't
been reset yet by --default-character-set=xxx. been reset yet by --default-character-set=xxx.
*/ */
...@@ -733,8 +733,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -733,8 +733,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
{ {
if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0) if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0)
{ {
fprintf(stderr, "Unknown option to protocol: %s\n", argument); fprintf(stderr, "Unknown option to protocol: %s\n", argument);
exit(1); exit(1);
} }
break; break;
} }
...@@ -760,12 +760,12 @@ static int get_options(int *argc, char ***argv) ...@@ -760,12 +760,12 @@ static int get_options(int *argc, char ***argv)
*mysql_params->p_net_buffer_length= opt_net_buffer_length; *mysql_params->p_net_buffer_length= opt_net_buffer_length;
if (opt_delayed) if (opt_delayed)
opt_lock=0; /* Can't have lock with delayed */ opt_lock=0; /* Can't have lock with delayed */
if (!path && (enclosed || opt_enclosed || escaped || lines_terminated || if (!path && (enclosed || opt_enclosed || escaped || lines_terminated ||
fields_terminated)) fields_terminated))
{ {
fprintf(stderr, fprintf(stderr,
"%s: You must use option --tab with --fields-...\n", my_progname); "%s: You must use option --tab with --fields-...\n", my_progname);
return(1); return(1);
} }
...@@ -777,7 +777,7 @@ static int get_options(int *argc, char ***argv) ...@@ -777,7 +777,7 @@ static int get_options(int *argc, char ***argv)
fprintf(stderr, "%s: You can't use --single-transaction and " fprintf(stderr, "%s: You can't use --single-transaction and "
"--lock-all-tables at the same time.\n", my_progname); "--lock-all-tables at the same time.\n", my_progname);
return(1); return(1);
} }
if (opt_master_data) if (opt_master_data)
opt_lock_all_tables= !opt_single_transaction; opt_lock_all_tables= !opt_single_transaction;
if (opt_single_transaction || opt_lock_all_tables) if (opt_single_transaction || opt_lock_all_tables)
...@@ -790,13 +790,13 @@ static int get_options(int *argc, char ***argv) ...@@ -790,13 +790,13 @@ static int get_options(int *argc, char ***argv)
if ((opt_databases || opt_alldbs) && path) if ((opt_databases || opt_alldbs) && path)
{ {
fprintf(stderr, fprintf(stderr,
"%s: --databases or --all-databases can't be used with --tab.\n", "%s: --databases or --all-databases can't be used with --tab.\n",
my_progname); my_progname);
return(1); return(1);
} }
if (strcmp(default_charset, charset_info->csname) && if (strcmp(default_charset, charset_info->csname) &&
!(charset_info= get_charset_by_csname(default_charset, !(charset_info= get_charset_by_csname(default_charset,
MY_CS_PRIMARY, MYF(MY_WME)))) MY_CS_PRIMARY, MYF(MY_WME))))
exit(1); exit(1);
if ((*argc < 1 && !opt_alldbs) || (*argc > 0 && opt_alldbs)) if ((*argc < 1 && !opt_alldbs) || (*argc > 0 && opt_alldbs))
{ {
...@@ -816,7 +816,7 @@ static void DB_error(MYSQL *mysql, const char *when) ...@@ -816,7 +816,7 @@ static void DB_error(MYSQL *mysql, const char *when)
{ {
DBUG_ENTER("DB_error"); DBUG_ENTER("DB_error");
my_printf_error(0,"Got error: %d: %s %s", MYF(0), my_printf_error(0,"Got error: %d: %s %s", MYF(0),
mysql_errno(mysql), mysql_error(mysql), when); mysql_errno(mysql), mysql_error(mysql), when);
safe_exit(EX_MYSQLERR); safe_exit(EX_MYSQLERR);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} /* DB_error */ } /* DB_error */
...@@ -830,14 +830,14 @@ static void DB_error(MYSQL *mysql, const char *when) ...@@ -830,14 +830,14 @@ static void DB_error(MYSQL *mysql, const char *when)
mysql_query_with_error_report() mysql_query_with_error_report()
mysql_con connection to use mysql_con connection to use
res if non zero, result will be put there with res if non zero, result will be put there with
mysql_store_result() mysql_store_result()
query query to send to server query query to send to server
RETURN VALUES RETURN VALUES
0 query sending and (if res!=0) result reading went ok 0 query sending and (if res!=0) result reading went ok
1 error 1 error
*/ */
static int mysql_query_with_error_report(MYSQL *mysql_con, MYSQL_RES **res, static int mysql_query_with_error_report(MYSQL *mysql_con, MYSQL_RES **res,
const char *query) const char *query)
{ {
...@@ -869,7 +869,7 @@ static FILE* open_sql_file_for_table(const char* table) ...@@ -869,7 +869,7 @@ static FILE* open_sql_file_for_table(const char* table)
char filename[FN_REFLEN], tmp_path[FN_REFLEN]; char filename[FN_REFLEN], tmp_path[FN_REFLEN];
convert_dirname(tmp_path,path,NullS); convert_dirname(tmp_path,path,NullS);
res= my_fopen(fn_format(filename, table, tmp_path, ".sql", 4), res= my_fopen(fn_format(filename, table, tmp_path, ".sql", 4),
O_WRONLY, MYF(MY_WME)); O_WRONLY, MYF(MY_WME));
return res; return res;
} }
...@@ -904,7 +904,7 @@ static int dbConnect(char *host, char *user,char *passwd) ...@@ -904,7 +904,7 @@ static int dbConnect(char *host, char *user,char *passwd)
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
if (opt_use_ssl) if (opt_use_ssl)
mysql_ssl_set(&mysql_connection, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, mysql_ssl_set(&mysql_connection, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
opt_ssl_capath, opt_ssl_cipher); opt_ssl_capath, opt_ssl_cipher);
mysql_options(&mysql_connection,MYSQL_OPT_SSL_VERIFY_SERVER_CERT, mysql_options(&mysql_connection,MYSQL_OPT_SSL_VERIFY_SERVER_CERT,
(char*)&opt_ssl_verify_server_cert); (char*)&opt_ssl_verify_server_cert);
#endif #endif
...@@ -933,7 +933,7 @@ static int dbConnect(char *host, char *user,char *passwd) ...@@ -933,7 +933,7 @@ static int dbConnect(char *host, char *user,char *passwd)
*/ */
sock->reconnect= 0; sock->reconnect= 0;
my_snprintf(buff, sizeof(buff), "/*!40100 SET @@SQL_MODE='%s' */", my_snprintf(buff, sizeof(buff), "/*!40100 SET @@SQL_MODE='%s' */",
compatible_mode_normal_str); compatible_mode_normal_str);
if (mysql_query_with_error_report(sock, 0, buff)) if (mysql_query_with_error_report(sock, 0, buff))
{ {
mysql_close(sock); mysql_close(sock);
...@@ -941,7 +941,7 @@ static int dbConnect(char *host, char *user,char *passwd) ...@@ -941,7 +941,7 @@ static int dbConnect(char *host, char *user,char *passwd)
return 1; return 1;
} }
/* /*
set time_zone to UTC to allow dumping date types between servers with set time_zone to UTC to allow dumping date types between servers with
different time zone settings different time zone settings
*/ */
if (opt_tz_utc) if (opt_tz_utc)
...@@ -975,8 +975,8 @@ static void unescape(FILE *file,char *pos,uint length) ...@@ -975,8 +975,8 @@ static void unescape(FILE *file,char *pos,uint length)
DBUG_ENTER("unescape"); DBUG_ENTER("unescape");
if (!(tmp=(char*) my_malloc(length*2+1, MYF(MY_WME)))) if (!(tmp=(char*) my_malloc(length*2+1, MYF(MY_WME))))
{ {
ignore_errors=0; /* Fatal error */ ignore_errors=0; /* Fatal error */
safe_exit(EX_MYSQLERR); /* Force exit */ safe_exit(EX_MYSQLERR); /* Force exit */
} }
mysql_real_escape_string(&mysql_connection, tmp, pos, length); mysql_real_escape_string(&mysql_connection, tmp, pos, length);
fputc('\'', file); fputc('\'', file);
...@@ -1003,13 +1003,13 @@ static my_bool test_if_special_chars(const char *str) ...@@ -1003,13 +1003,13 @@ static my_bool test_if_special_chars(const char *str)
/* /*
quote_name(name, buff, force) quote_name(name, buff, force)
Quotes char string, taking into account compatible mode Quotes char string, taking into account compatible mode
Args Args
name Unquoted string containing that which will be quoted name Unquoted string containing that which will be quoted
buff The buffer that contains the quoted value, also returned buff The buffer that contains the quoted value, also returned
force Flag to make it ignore 'test_if_special_chars' force Flag to make it ignore 'test_if_special_chars'
Returns Returns
...@@ -1082,13 +1082,13 @@ static char *quote_for_like(const char *name, char *buff) ...@@ -1082,13 +1082,13 @@ static char *quote_for_like(const char *name, char *buff)
/* /*
Quote and print a string. Quote and print a string.
SYNOPSIS SYNOPSIS
print_quoted_xml() print_quoted_xml()
output - output file output - output file
str - string to print str - string to print
len - its length len - its length
DESCRIPTION DESCRIPTION
Quote '<' '>' '&' '\"' chars and print a string to the xml_file. Quote '<' '>' '&' '\"' chars and print a string to the xml_file.
*/ */
...@@ -1096,7 +1096,7 @@ static char *quote_for_like(const char *name, char *buff) ...@@ -1096,7 +1096,7 @@ static char *quote_for_like(const char *name, char *buff)
static void print_quoted_xml(FILE *xml_file, const char *str, ulong len) static void print_quoted_xml(FILE *xml_file, const char *str, ulong len)
{ {
const char *end; const char *end;
for (end= str + len; str != end; str++) for (end= str + len; str != end; str++)
{ {
switch (*str) { switch (*str) {
...@@ -1123,15 +1123,15 @@ static void print_quoted_xml(FILE *xml_file, const char *str, ulong len) ...@@ -1123,15 +1123,15 @@ static void print_quoted_xml(FILE *xml_file, const char *str, ulong len)
/* /*
Print xml tag with one attribute. Print xml tag with one attribute.
SYNOPSIS SYNOPSIS
print_xml_tag1() print_xml_tag1()
xml_file - output file xml_file - output file
sbeg - line beginning sbeg - line beginning
stag_atr - tag and attribute stag_atr - tag and attribute
sval - value of attribute sval - value of attribute
send - line ending send - line ending
DESCRIPTION DESCRIPTION
Print tag with one attribute to the xml_file. Format is: Print tag with one attribute to the xml_file. Format is:
sbeg<stag_atr="sval">send sbeg<stag_atr="sval">send
...@@ -1141,8 +1141,8 @@ static void print_quoted_xml(FILE *xml_file, const char *str, ulong len) ...@@ -1141,8 +1141,8 @@ static void print_quoted_xml(FILE *xml_file, const char *str, ulong len)
*/ */
static void print_xml_tag1(FILE * xml_file, const char* sbeg, static void print_xml_tag1(FILE * xml_file, const char* sbeg,
const char* stag_atr, const char* sval, const char* stag_atr, const char* sval,
const char* send) const char* send)
{ {
fputs(sbeg, xml_file); fputs(sbeg, xml_file);
fputs("<", xml_file); fputs("<", xml_file);
...@@ -1160,11 +1160,11 @@ static void print_xml_tag1(FILE * xml_file, const char* sbeg, ...@@ -1160,11 +1160,11 @@ static void print_xml_tag1(FILE * xml_file, const char* sbeg,
SYNOPSIS SYNOPSIS
print_xml_null_tag() print_xml_null_tag()
xml_file - output file xml_file - output file
sbeg - line beginning sbeg - line beginning
stag_atr - tag and attribute stag_atr - tag and attribute
sval - value of attribute sval - value of attribute
send - line ending send - line ending
DESCRIPTION DESCRIPTION
Print tag with one attribute to the xml_file. Format is: Print tag with one attribute to the xml_file. Format is:
...@@ -1194,11 +1194,11 @@ static void print_xml_null_tag(FILE * xml_file, const char* sbeg, ...@@ -1194,11 +1194,11 @@ static void print_xml_null_tag(FILE * xml_file, const char* sbeg,
SYNOPSIS SYNOPSIS
print_xml_row() print_xml_row()
xml_file - output file xml_file - output file
row_name - xml tag name row_name - xml tag name
tableRes - query result tableRes - query result
row - result row row - result row
DESCRIPTION DESCRIPTION
Print tag with many attribute to the xml_file. Format is: Print tag with many attribute to the xml_file. Format is:
\t\t<row_name Atr1="Val1" Atr2="Val2"... /> \t\t<row_name Atr1="Val1" Atr2="Val2"... />
...@@ -1207,7 +1207,7 @@ static void print_xml_null_tag(FILE * xml_file, const char* sbeg, ...@@ -1207,7 +1207,7 @@ static void print_xml_null_tag(FILE * xml_file, const char* sbeg,
*/ */
static void print_xml_row(FILE *xml_file, const char *row_name, static void print_xml_row(FILE *xml_file, const char *row_name,
MYSQL_RES *tableRes, MYSQL_ROW *row) MYSQL_RES *tableRes, MYSQL_ROW *row)
{ {
uint i; uint i;
MYSQL_FIELD *field; MYSQL_FIELD *field;
...@@ -1324,7 +1324,7 @@ static uint dump_routines_for_db(char *db) ...@@ -1324,7 +1324,7 @@ static uint dump_routines_for_db(char *db)
*/ */
definer_begin= strstr(row[2], " DEFINER"); definer_begin= strstr(row[2], " DEFINER");
if (definer_begin) if (definer_begin)
{ {
char *definer_end= strstr(definer_begin, " PROCEDURE"); char *definer_end= strstr(definer_begin, " PROCEDURE");
...@@ -1388,7 +1388,7 @@ static uint dump_routines_for_db(char *db) ...@@ -1388,7 +1388,7 @@ static uint dump_routines_for_db(char *db)
ARGS ARGS
table - table name table - table name
db - db name db - db name
table_type - table type ie "InnoDB" table_type - table type, e.g. "MyISAM" or "InnoDB", but also "VIEW"
ignore_flag - what we must particularly ignore - see IGNORE_ defines above ignore_flag - what we must particularly ignore - see IGNORE_ defines above
RETURN RETURN
...@@ -1400,10 +1400,10 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -1400,10 +1400,10 @@ static uint get_table_structure(char *table, char *db, char *table_type,
{ {
my_bool init=0, delayed, write_data, complete_insert; my_bool init=0, delayed, write_data, complete_insert;
my_ulonglong num_fields; my_ulonglong 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];
char table_buff2[NAME_LEN*2+3], query_buff[512]; char table_buff2[NAME_LEN*2+3], query_buff[512];
FILE *sql_file = md_result_file; FILE *sql_file = md_result_file;
int len; int len;
MYSQL_RES *result; MYSQL_RES *result;
...@@ -1473,21 +1473,30 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -1473,21 +1473,30 @@ static uint get_table_structure(char *table, char *db, char *table_type,
{ {
if (!(sql_file= open_sql_file_for_table(table))) if (!(sql_file= open_sql_file_for_table(table)))
{ {
safe_exit(EX_MYSQLERR); safe_exit(EX_MYSQLERR);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
write_header(sql_file, db); write_header(sql_file, db);
} }
if (!opt_xml && opt_comments) if (!opt_xml && opt_comments)
{ {
if (strcmp (table_type, "VIEW") == 0) /* view */
fprintf(sql_file, "\n--\n-- Temporary table structure for view %s\n--\n\n",
result_table);
else
fprintf(sql_file, "\n--\n-- Table structure for table %s\n--\n\n", fprintf(sql_file, "\n--\n-- Table structure for table %s\n--\n\n",
result_table); result_table);
check_io(sql_file); check_io(sql_file);
} }
if (opt_drop) if (opt_drop)
{ {
fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n", opt_quoted_table); /*
check_io(sql_file); Even if the "table" is a view, we do a DROP TABLE here. The
view-specific code below fills in the DROP VIEW.
*/
fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",
opt_quoted_table);
check_io(sql_file);
} }
result= mysql_store_result(sock); result= mysql_store_result(sock);
...@@ -1500,7 +1509,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -1500,7 +1509,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
mysql_free_result(result); mysql_free_result(result);
/* /*
Create a table with the same name as the view and with columns of Create a table with the same name as the view and with columns of
the same name in order to satisfy views that depend on this view. the same name in order to satisfy views that depend on this view.
The table will be removed when the actual view is created. The table will be removed when the actual view is created.
...@@ -1524,10 +1533,13 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -1524,10 +1533,13 @@ static uint get_table_structure(char *table, char *db, char *table_type,
{ {
if (opt_drop) if (opt_drop)
{ {
/*
We have already dropped any table of the same name
above, so here we just drop the view.
*/
fprintf(sql_file, "/*!50001 DROP VIEW IF EXISTS %s*/;\n", fprintf(sql_file, "/*!50001 DROP VIEW IF EXISTS %s*/;\n",
opt_quoted_table); opt_quoted_table);
fprintf(sql_file, "/*!50001 DROP TABLE IF EXISTS %s*/;\n",
opt_quoted_table);
check_io(sql_file); check_io(sql_file);
} }
...@@ -1554,7 +1566,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -1554,7 +1566,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
} }
mysql_free_result(result); mysql_free_result(result);
was_views= 1; seen_views= 1;
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -1564,11 +1576,11 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -1564,11 +1576,11 @@ static uint get_table_structure(char *table, char *db, char *table_type,
mysql_free_result(result); mysql_free_result(result);
} }
my_snprintf(query_buff, sizeof(query_buff), "show fields from %s", my_snprintf(query_buff, sizeof(query_buff), "show fields from %s",
result_table); result_table);
if (mysql_query_with_error_report(sock, &result, query_buff)) if (mysql_query_with_error_report(sock, &result, query_buff))
{ {
if (path) if (path)
my_fclose(sql_file, MYF(MY_WME)); my_fclose(sql_file, MYF(MY_WME));
safe_exit(EX_MYSQLERR); safe_exit(EX_MYSQLERR);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -1621,7 +1633,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -1621,7 +1633,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
my_progname, mysql_error(sock)); my_progname, mysql_error(sock));
my_snprintf(query_buff, sizeof(query_buff), "show fields from %s", my_snprintf(query_buff, sizeof(query_buff), "show fields from %s",
result_table); result_table);
if (mysql_query_with_error_report(sock, &result, query_buff)) if (mysql_query_with_error_report(sock, &result, query_buff))
{ {
safe_exit(EX_MYSQLERR); safe_exit(EX_MYSQLERR);
...@@ -1635,18 +1647,18 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -1635,18 +1647,18 @@ static uint get_table_structure(char *table, char *db, char *table_type,
{ {
if (!(sql_file= open_sql_file_for_table(table))) if (!(sql_file= open_sql_file_for_table(table)))
{ {
safe_exit(EX_MYSQLERR); safe_exit(EX_MYSQLERR);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
write_header(sql_file, db); write_header(sql_file, db);
} }
if (!opt_xml && opt_comments) if (!opt_xml && opt_comments)
fprintf(sql_file, "\n--\n-- Table structure for table %s\n--\n\n", fprintf(sql_file, "\n--\n-- Table structure for table %s\n--\n\n",
result_table); result_table);
if (opt_drop) if (opt_drop)
fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n", result_table); fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n", result_table);
if (!opt_xml) if (!opt_xml)
fprintf(sql_file, "CREATE TABLE %s (\n", result_table); fprintf(sql_file, "CREATE TABLE %s (\n", result_table);
else else
print_xml_tag1(sql_file, "\t", "table_structure name=", table, "\n"); print_xml_tag1(sql_file, "\t", "table_structure name=", table, "\n");
check_io(sql_file); check_io(sql_file);
...@@ -1674,10 +1686,10 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -1674,10 +1686,10 @@ static uint get_table_structure(char *table, char *db, char *table_type,
if (init) if (init)
{ {
if (!opt_xml && !tFlag) if (!opt_xml && !tFlag)
{ {
fputs(",\n",sql_file); fputs(",\n",sql_file);
check_io(sql_file); check_io(sql_file);
} }
if (complete_insert) if (complete_insert)
dynstr_append_mem(&insert_pat, ", ", 2); dynstr_append_mem(&insert_pat, ", ", 2);
} }
...@@ -1687,30 +1699,30 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -1687,30 +1699,30 @@ static uint get_table_structure(char *table, char *db, char *table_type,
quote_name(row[SHOW_FIELDNAME], name_buff, 0)); quote_name(row[SHOW_FIELDNAME], name_buff, 0));
if (!tFlag) if (!tFlag)
{ {
if (opt_xml) if (opt_xml)
{ {
print_xml_row(sql_file, "field", result, &row); print_xml_row(sql_file, "field", result, &row);
continue; continue;
} }
if (opt_keywords) if (opt_keywords)
fprintf(sql_file, " %s.%s %s", result_table, fprintf(sql_file, " %s.%s %s", result_table,
quote_name(row[SHOW_FIELDNAME],name_buff, 0), quote_name(row[SHOW_FIELDNAME],name_buff, 0),
row[SHOW_TYPE]); row[SHOW_TYPE]);
else else
fprintf(sql_file, " %s %s", quote_name(row[SHOW_FIELDNAME], fprintf(sql_file, " %s %s", quote_name(row[SHOW_FIELDNAME],
name_buff, 0), name_buff, 0),
row[SHOW_TYPE]); row[SHOW_TYPE]);
if (row[SHOW_DEFAULT]) if (row[SHOW_DEFAULT])
{ {
fputs(" DEFAULT ", sql_file); fputs(" DEFAULT ", sql_file);
unescape(sql_file, row[SHOW_DEFAULT], lengths[SHOW_DEFAULT]); unescape(sql_file, row[SHOW_DEFAULT], lengths[SHOW_DEFAULT]);
} }
if (!row[SHOW_NULL][0]) if (!row[SHOW_NULL][0])
fputs(" NOT NULL", sql_file); fputs(" NOT NULL", sql_file);
if (row[SHOW_EXTRA][0]) if (row[SHOW_EXTRA][0])
fprintf(sql_file, " %s",row[SHOW_EXTRA]); fprintf(sql_file, " %s",row[SHOW_EXTRA]);
check_io(sql_file); check_io(sql_file);
} }
} }
num_fields= mysql_num_rows(result); num_fields= mysql_num_rows(result);
...@@ -1730,9 +1742,9 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -1730,9 +1742,9 @@ static uint get_table_structure(char *table, char *db, char *table_type,
goto continue_xml; goto continue_xml;
} }
fprintf(stderr, "%s: Can't get keys for table %s (%s)\n", fprintf(stderr, "%s: Can't get keys for table %s (%s)\n",
my_progname, result_table, mysql_error(sock)); my_progname, result_table, mysql_error(sock));
if (path) if (path)
my_fclose(sql_file, MYF(MY_WME)); my_fclose(sql_file, MYF(MY_WME));
safe_exit(EX_MYSQLERR); safe_exit(EX_MYSQLERR);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -1744,102 +1756,102 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -1744,102 +1756,102 @@ static uint get_table_structure(char *table, char *db, char *table_type,
{ {
if (atoi(row[3]) == 1) if (atoi(row[3]) == 1)
{ {
keynr++; keynr++;
#ifdef FORCE_PRIMARY_KEY #ifdef FORCE_PRIMARY_KEY
if (atoi(row[1]) == 0 && primary_key == INT_MAX) if (atoi(row[1]) == 0 && primary_key == INT_MAX)
primary_key=keynr; primary_key=keynr;
#endif #endif
if (!strcmp(row[2],"PRIMARY")) if (!strcmp(row[2],"PRIMARY"))
{ {
primary_key=keynr; primary_key=keynr;
break; break;
} }
} }
} }
mysql_data_seek(result,0); mysql_data_seek(result,0);
keynr=0; keynr=0;
while ((row= mysql_fetch_row(result))) while ((row= mysql_fetch_row(result)))
{ {
if (opt_xml) if (opt_xml)
{ {
print_xml_row(sql_file, "key", result, &row); print_xml_row(sql_file, "key", result, &row);
continue; continue;
} }
if (atoi(row[3]) == 1) if (atoi(row[3]) == 1)
{ {
if (keynr++) if (keynr++)
putc(')', sql_file); putc(')', sql_file);
if (atoi(row[1])) /* Test if duplicate key */ if (atoi(row[1])) /* Test if duplicate key */
/* Duplicate allowed */ /* Duplicate allowed */
fprintf(sql_file, ",\n KEY %s (",quote_name(row[2],name_buff,0)); fprintf(sql_file, ",\n KEY %s (",quote_name(row[2],name_buff,0));
else if (keynr == primary_key) else if (keynr == primary_key)
fputs(",\n PRIMARY KEY (",sql_file); /* First UNIQUE is primary */ fputs(",\n PRIMARY KEY (",sql_file); /* First UNIQUE is primary */
else else
fprintf(sql_file, ",\n UNIQUE %s (",quote_name(row[2],name_buff, fprintf(sql_file, ",\n UNIQUE %s (",quote_name(row[2],name_buff,
0)); 0));
} }
else else
putc(',', sql_file); putc(',', sql_file);
fputs(quote_name(row[4], name_buff, 0), sql_file); fputs(quote_name(row[4], name_buff, 0), sql_file);
if (row[7]) if (row[7])
fprintf(sql_file, " (%s)",row[7]); /* Sub key */ fprintf(sql_file, " (%s)",row[7]); /* Sub key */
check_io(sql_file); check_io(sql_file);
} }
if (!opt_xml) if (!opt_xml)
{ {
if (keynr) if (keynr)
putc(')', sql_file); putc(')', sql_file);
fputs("\n)",sql_file); fputs("\n)",sql_file);
check_io(sql_file); check_io(sql_file);
} }
/* Get MySQL specific create options */ /* Get MySQL specific create options */
if (create_options) if (create_options)
{ {
char show_name_buff[NAME_LEN*2+2+24]; char show_name_buff[NAME_LEN*2+2+24];
/* Check memory for quote_for_like() */ /* Check memory for quote_for_like() */
my_snprintf(buff, sizeof(buff), "show table status like %s", my_snprintf(buff, sizeof(buff), "show table status like %s",
quote_for_like(table, show_name_buff)); quote_for_like(table, show_name_buff));
if (mysql_query_with_error_report(sock, &result, buff)) if (mysql_query_with_error_report(sock, &result, buff))
{ {
if (mysql_errno(sock) != ER_PARSE_ERROR) if (mysql_errno(sock) != ER_PARSE_ERROR)
{ /* If old MySQL version */ { /* If old MySQL version */
if (verbose) if (verbose)
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",
result_table,mysql_error(sock)); result_table,mysql_error(sock));
} }
} }
else if (!(row= mysql_fetch_row(result))) else if (!(row= mysql_fetch_row(result)))
{ {
fprintf(stderr, fprintf(stderr,
"Error: Couldn't read status information for table %s (%s)\n", "Error: Couldn't read status information for table %s (%s)\n",
result_table,mysql_error(sock)); result_table,mysql_error(sock));
} }
else else
{ {
if (opt_xml) if (opt_xml)
print_xml_row(sql_file, "options", result, &row); print_xml_row(sql_file, "options", result, &row);
else else
{ {
fputs("/*!",sql_file); fputs("/*!",sql_file);
print_value(sql_file,result,row,"engine=","Engine",0); print_value(sql_file,result,row,"engine=","Engine",0);
print_value(sql_file,result,row,"","Create_options",0); print_value(sql_file,result,row,"","Create_options",0);
print_value(sql_file,result,row,"comment=","Comment",1); print_value(sql_file,result,row,"comment=","Comment",1);
fputs(" */",sql_file); fputs(" */",sql_file);
check_io(sql_file); check_io(sql_file);
} }
} }
mysql_free_result(result); /* Is always safe to free */ mysql_free_result(result); /* Is always safe to free */
} }
continue_xml: continue_xml:
if (!opt_xml) if (!opt_xml)
fputs(";\n", sql_file); fputs(";\n", sql_file);
else else
fputs("\t</table_structure>\n", sql_file); fputs("\t</table_structure>\n", sql_file);
check_io(sql_file); check_io(sql_file);
} }
} }
...@@ -1871,8 +1883,8 @@ continue_xml: ...@@ -1871,8 +1883,8 @@ continue_xml:
static void dump_triggers_for_table (char *table, char *db) static void dump_triggers_for_table (char *table, char *db)
{ {
char *result_table; char *result_table;
char name_buff[NAME_LEN*4+3], table_buff[NAME_LEN*2+3]; char name_buff[NAME_LEN*4+3], table_buff[NAME_LEN*2+3];
char query_buff[512]; char query_buff[512];
uint old_opt_compatible_mode=opt_compatible_mode; uint old_opt_compatible_mode=opt_compatible_mode;
FILE *sql_file = md_result_file; FILE *sql_file = md_result_file;
...@@ -1921,7 +1933,7 @@ DELIMITER ;;\n"); ...@@ -1921,7 +1933,7 @@ DELIMITER ;;\n");
uint host_name_len; uint host_name_len;
char host_name_str[HOSTNAME_LENGTH + 1]; char host_name_str[HOSTNAME_LENGTH + 1];
char quoted_host_name_str[HOSTNAME_LENGTH * 2 + 3]; char quoted_host_name_str[HOSTNAME_LENGTH * 2 + 3];
parse_user(row[7], strlen(row[7]), user_name_str, &user_name_len, parse_user(row[7], strlen(row[7]), user_name_str, &user_name_len,
host_name_str, &host_name_len); host_name_str, &host_name_len);
...@@ -1937,7 +1949,7 @@ DELIMITER ;;\n"); ...@@ -1937,7 +1949,7 @@ DELIMITER ;;\n");
row[4], /* Timing */ row[4], /* Timing */
row[1], /* Event */ row[1], /* Event */
result_table, result_table,
(strchr(" \t\n\r", *(row[3]))) ? "" : " ", (strchr(" \t\n\r", *(row[3]))) ? "" : " ",
row[3] /* Statement */); row[3] /* Statement */);
} }
if (mysql_num_rows(result)) if (mysql_num_rows(result))
...@@ -1946,7 +1958,7 @@ DELIMITER ;;\n"); ...@@ -1946,7 +1958,7 @@ DELIMITER ;;\n");
"/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;\n"); "/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;\n");
mysql_free_result(result); mysql_free_result(result);
/* /*
make sure to set back opt_compatible mode to make sure to set back opt_compatible mode to
original value original value
*/ */
opt_compatible_mode=old_opt_compatible_mode; opt_compatible_mode=old_opt_compatible_mode;
...@@ -1954,7 +1966,7 @@ DELIMITER ;;\n"); ...@@ -1954,7 +1966,7 @@ DELIMITER ;;\n");
} }
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)
{ {
if (object) if (object)
{ {
...@@ -1993,7 +2005,7 @@ static char *field_escape(char *to,const char *from,uint length) ...@@ -1993,7 +2005,7 @@ static char *field_escape(char *to,const char *from,uint length)
else else
{ {
if (*from == '\'' && !end_backslashes) if (*from == '\'' && !end_backslashes)
*to++= *from; /* We want a duplicate of "'" for MySQL */ *to++= *from; /* We want a duplicate of "'" for MySQL */
end_backslashes=0; end_backslashes=0;
} }
} }
...@@ -2010,8 +2022,8 @@ static char *alloc_query_str(ulong size) ...@@ -2010,8 +2022,8 @@ static char *alloc_query_str(ulong size)
if (!(query= (char*) my_malloc(size, MYF(MY_WME)))) if (!(query= (char*) my_malloc(size, MYF(MY_WME))))
{ {
ignore_errors= 0; /* Fatal error */ ignore_errors= 0; /* Fatal error */
safe_exit(EX_MYSQLERR); /* Force exit */ safe_exit(EX_MYSQLERR); /* Force exit */
} }
return query; return query;
} }
...@@ -2040,11 +2052,11 @@ static void dump_table(char *table, char *db) ...@@ -2040,11 +2052,11 @@ static void dump_table(char *table, char *db)
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; int error= 0;
ulong rownr, row_break, total_length, init_length; ulong rownr, row_break, total_length, init_length;
uint num_fields; uint num_fields;
MYSQL_RES *res; MYSQL_RES *res;
MYSQL_FIELD *field; MYSQL_FIELD *field;
MYSQL_ROW row; MYSQL_ROW row;
DBUG_ENTER("dump_table"); DBUG_ENTER("dump_table");
/* /*
...@@ -2053,13 +2065,19 @@ static void dump_table(char *table, char *db) ...@@ -2053,13 +2065,19 @@ static void dump_table(char *table, char *db)
*/ */
num_fields= get_table_structure(table, db, table_type, &ignore_flag); num_fields= get_table_structure(table, db, table_type, &ignore_flag);
/*
The "table" could be a view. If so, we don't do anything here.
*/
if (strcmp (table_type, "VIEW") == 0)
return;
/* Check --no-data flag */ /* Check --no-data flag */
if (dFlag) if (dFlag)
{ {
if (verbose) if (verbose)
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);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -2074,8 +2092,8 @@ static void dump_table(char *table, char *db) ...@@ -2074,8 +2092,8 @@ static void dump_table(char *table, char *db)
{ {
if (verbose) if (verbose)
fprintf(stderr, fprintf(stderr,
"-- Warning: Skipping data for table '%s' because it's of type %s\n", "-- Warning: Skipping data for table '%s' because it's of type %s\n",
table, table_type); table, table_type);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
/* Check that there are any fields in the table */ /* Check that there are any fields in the table */
...@@ -2083,8 +2101,8 @@ static void dump_table(char *table, char *db) ...@@ -2083,8 +2101,8 @@ static void dump_table(char *table, char *db)
{ {
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);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -2100,11 +2118,11 @@ static void dump_table(char *table, char *db) ...@@ -2100,11 +2118,11 @@ static void dump_table(char *table, char *db)
my_load_path(tmp_path, tmp_path, NULL); my_load_path(tmp_path, tmp_path, NULL);
fn_format(filename, table, tmp_path, ".txt", 4); fn_format(filename, table, tmp_path, ".txt", 4);
my_delete(filename, MYF(0)); /* 'INTO OUTFILE' doesn't work, if my_delete(filename, MYF(0)); /* 'INTO OUTFILE' doesn't work, if
filename wasn't deleted */ filename wasn't deleted */
to_unix_path(filename); to_unix_path(filename);
my_snprintf(query, QUERY_LENGTH, my_snprintf(query, QUERY_LENGTH,
"SELECT /*!40001 SQL_NO_CACHE */ * INTO OUTFILE '%s'", "SELECT /*!40001 SQL_NO_CACHE */ * INTO OUTFILE '%s'",
filename); filename);
end= strend(query); end= strend(query);
if (fields_terminated || enclosed || opt_enclosed || escaped) if (fields_terminated || enclosed || opt_enclosed || escaped)
...@@ -2141,12 +2159,12 @@ static void dump_table(char *table, char *db) ...@@ -2141,12 +2159,12 @@ static void dump_table(char *table, char *db)
if (!opt_xml && opt_comments) if (!opt_xml && opt_comments)
{ {
fprintf(md_result_file,"\n--\n-- Dumping data for table %s\n--\n", fprintf(md_result_file,"\n--\n-- Dumping data for table %s\n--\n",
result_table); result_table);
check_io(md_result_file); check_io(md_result_file);
} }
my_snprintf(query, QUERY_LENGTH, my_snprintf(query, QUERY_LENGTH,
"SELECT /*!40001 SQL_NO_CACHE */ * FROM %s", "SELECT /*!40001 SQL_NO_CACHE */ * FROM %s",
result_table); result_table);
if (where || order_by) if (where || order_by)
{ {
query = alloc_query_str((ulong) (strlen(query) + 1 + query = alloc_query_str((ulong) (strlen(query) + 1 +
...@@ -2194,7 +2212,7 @@ static void dump_table(char *table, char *db) ...@@ -2194,7 +2212,7 @@ static void dump_table(char *table, char *db)
if (mysql_num_fields(res) != num_fields) 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);
error= EX_CONSCHECK; error= EX_CONSCHECK;
goto err; goto err;
} }
...@@ -2202,7 +2220,7 @@ static void dump_table(char *table, char *db) ...@@ -2202,7 +2220,7 @@ static void dump_table(char *table, char *db)
if (opt_disable_keys) if (opt_disable_keys)
{ {
fprintf(md_result_file, "\n/*!40000 ALTER TABLE %s DISABLE KEYS */;\n", fprintf(md_result_file, "\n/*!40000 ALTER TABLE %s DISABLE KEYS */;\n",
opt_quoted_table); opt_quoted_table);
check_io(md_result_file); check_io(md_result_file);
} }
if (opt_lock) if (opt_lock)
...@@ -2211,7 +2229,7 @@ static void dump_table(char *table, char *db) ...@@ -2211,7 +2229,7 @@ static void dump_table(char *table, char *db)
check_io(md_result_file); check_io(md_result_file);
} }
total_length= opt_net_buffer_length; /* Force row break */ total_length= opt_net_buffer_length; /* Force row break */
row_break=0; row_break=0;
rownr=0; rownr=0;
init_length=(uint) insert_pat.length+4; init_length=(uint) insert_pat.length+4;
...@@ -2231,15 +2249,15 @@ static void dump_table(char *table, char *db) ...@@ -2231,15 +2249,15 @@ static void dump_table(char *table, char *db)
rownr++; rownr++;
if (!extended_insert && !opt_xml) if (!extended_insert && !opt_xml)
{ {
fputs(insert_pat.str,md_result_file); fputs(insert_pat.str,md_result_file);
check_io(md_result_file); check_io(md_result_file);
} }
mysql_field_seek(res,0); mysql_field_seek(res,0);
if (opt_xml) if (opt_xml)
{ {
fputs("\t<row>\n", md_result_file); fputs("\t<row>\n", md_result_file);
check_io(md_result_file); check_io(md_result_file);
} }
for (i = 0; i < mysql_num_fields(res); i++) for (i = 0; i < mysql_num_fields(res); i++)
...@@ -2247,21 +2265,21 @@ static void dump_table(char *table, char *db) ...@@ -2247,21 +2265,21 @@ static void dump_table(char *table, char *db)
int is_blob; int is_blob;
ulong length= lengths[i]; ulong length= lengths[i];
if (!(field = mysql_fetch_field(res))) if (!(field = mysql_fetch_field(res)))
{ {
my_snprintf(query, QUERY_LENGTH, my_snprintf(query, QUERY_LENGTH,
"%s: Not enough fields from table %s! Aborting.\n", "%s: Not enough fields from table %s! Aborting.\n",
my_progname, result_table); my_progname, result_table);
fputs(query,stderr); fputs(query,stderr);
error= EX_CONSCHECK; error= EX_CONSCHECK;
goto err; goto err;
} }
/* /*
63 is my_charset_bin. If charsetnr is not 63, 63 is my_charset_bin. If charsetnr is not 63,
we have not a BLOB but a TEXT column. we have not a BLOB but a TEXT column.
we'll dump in hex only BLOB columns. we'll dump in hex only BLOB columns.
*/ */
is_blob= (opt_hex_blob && field->charsetnr == 63 && is_blob= (opt_hex_blob && field->charsetnr == 63 &&
(field->type == MYSQL_TYPE_BIT || (field->type == MYSQL_TYPE_BIT ||
field->type == MYSQL_TYPE_STRING || field->type == MYSQL_TYPE_STRING ||
...@@ -2271,36 +2289,36 @@ static void dump_table(char *table, char *db) ...@@ -2271,36 +2289,36 @@ static void dump_table(char *table, char *db)
field->type == MYSQL_TYPE_LONG_BLOB || field->type == MYSQL_TYPE_LONG_BLOB ||
field->type == MYSQL_TYPE_MEDIUM_BLOB || field->type == MYSQL_TYPE_MEDIUM_BLOB ||
field->type == MYSQL_TYPE_TINY_BLOB)) ? 1 : 0; field->type == MYSQL_TYPE_TINY_BLOB)) ? 1 : 0;
if (extended_insert) if (extended_insert)
{ {
if (i == 0) if (i == 0)
dynstr_set(&extended_row,"("); dynstr_set(&extended_row,"(");
else else
dynstr_append(&extended_row,","); dynstr_append(&extended_row,",");
if (row[i]) if (row[i])
{ {
if (length) if (length)
{ {
if (!IS_NUM_FIELD(field)) if (!IS_NUM_FIELD(field))
{ {
/* /*
"length * 2 + 2" is OK for both HEX and non-HEX modes: "length * 2 + 2" is OK for both HEX and non-HEX modes:
- In HEX mode we need exactly 2 bytes per character - In HEX mode we need exactly 2 bytes per character
plus 2 bytes for '0x' prefix. plus 2 bytes for '0x' prefix.
- In non-HEX mode we need up to 2 bytes per character, - In non-HEX mode we need up to 2 bytes per character,
plus 2 bytes for leading and trailing '\'' characters. plus 2 bytes for leading and trailing '\'' characters.
*/ */
if (dynstr_realloc(&extended_row,length * 2+2)) if (dynstr_realloc(&extended_row,length * 2+2))
{ {
fputs("Aborting dump (out of memory)",stderr); fputs("Aborting dump (out of memory)",stderr);
error= EX_EOM; error= EX_EOM;
goto err; goto err;
} }
if (opt_hex_blob && is_blob) if (opt_hex_blob && is_blob)
{ {
dynstr_append(&extended_row, "0x"); dynstr_append(&extended_row, "0x");
extended_row.length+= mysql_hex_string(extended_row.str + extended_row.length+= mysql_hex_string(extended_row.str +
extended_row.length, extended_row.length,
row[i], length); row[i], length);
extended_row.str[extended_row.length]= '\0'; extended_row.str[extended_row.length]= '\0';
...@@ -2315,94 +2333,94 @@ static void dump_table(char *table, char *db) ...@@ -2315,94 +2333,94 @@ static void dump_table(char *table, char *db)
extended_row.str[extended_row.length]='\0'; extended_row.str[extended_row.length]='\0';
dynstr_append(&extended_row,"'"); dynstr_append(&extended_row,"'");
} }
} }
else else
{ {
/* change any strings ("inf", "-inf", "nan") into NULL */ /* change any strings ("inf", "-inf", "nan") into NULL */
char *ptr = row[i]; char *ptr = row[i];
if (my_isalpha(charset_info, *ptr) || (*ptr == '-' && if (my_isalpha(charset_info, *ptr) || (*ptr == '-' &&
my_isalpha(charset_info, ptr[1]))) my_isalpha(charset_info, ptr[1])))
dynstr_append(&extended_row, "NULL"); dynstr_append(&extended_row, "NULL");
else else
{ {
if (field->type == FIELD_TYPE_DECIMAL) if (field->type == FIELD_TYPE_DECIMAL)
{ {
/* add " signs around */ /* add " signs around */
dynstr_append(&extended_row, "'"); dynstr_append(&extended_row, "'");
dynstr_append(&extended_row, ptr); dynstr_append(&extended_row, ptr);
dynstr_append(&extended_row, "'"); dynstr_append(&extended_row, "'");
} }
else else
dynstr_append(&extended_row, ptr); dynstr_append(&extended_row, ptr);
} }
} }
} }
else else
dynstr_append(&extended_row,"''"); dynstr_append(&extended_row,"''");
} }
else if (dynstr_append(&extended_row,"NULL")) else if (dynstr_append(&extended_row,"NULL"))
{ {
fputs("Aborting dump (out of memory)",stderr); fputs("Aborting dump (out of memory)",stderr);
error= EX_EOM; error= EX_EOM;
goto err; goto err;
} }
} }
else else
{ {
if (i && !opt_xml) if (i && !opt_xml)
{ {
fputc(',', md_result_file); fputc(',', md_result_file);
check_io(md_result_file); check_io(md_result_file);
} }
if (row[i]) if (row[i])
{ {
if (!IS_NUM_FIELD(field)) if (!IS_NUM_FIELD(field))
{ {
if (opt_xml) if (opt_xml)
{ {
print_xml_tag1(md_result_file, "\t\t", "field name=", print_xml_tag1(md_result_file, "\t\t", "field name=",
field->name, ""); field->name, "");
print_quoted_xml(md_result_file, row[i], length); print_quoted_xml(md_result_file, row[i], length);
fputs("</field>\n", md_result_file); fputs("</field>\n", md_result_file);
} }
else if (opt_hex_blob && is_blob && length) else if (opt_hex_blob && is_blob && length)
{ {
/* sakaik got the idea to to provide blob's in hex notation. */ /* sakaik got the idea to to provide blob's in hex notation. */
char *ptr= row[i], *end= ptr + length; char *ptr= row[i], *end= ptr + length;
fputs("0x", md_result_file); fputs("0x", md_result_file);
for (; ptr < end ; ptr++) for (; ptr < end ; ptr++)
fprintf(md_result_file, "%02X", *((uchar *)ptr)); fprintf(md_result_file, "%02X", *((uchar *)ptr));
} }
else else
unescape(md_result_file, row[i], length); unescape(md_result_file, row[i], length);
} }
else else
{ {
/* change any strings ("inf", "-inf", "nan") into NULL */ /* change any strings ("inf", "-inf", "nan") into NULL */
char *ptr = row[i]; char *ptr = row[i];
if (opt_xml) if (opt_xml)
{ {
print_xml_tag1(md_result_file, "\t\t", "field name=", print_xml_tag1(md_result_file, "\t\t", "field name=",
field->name, ""); field->name, "");
fputs(!my_isalpha(charset_info, *ptr) ? ptr: "NULL", fputs(!my_isalpha(charset_info, *ptr) ? ptr: "NULL",
md_result_file); md_result_file);
fputs("</field>\n", md_result_file); fputs("</field>\n", md_result_file);
} }
else if (my_isalpha(charset_info, *ptr) || else if (my_isalpha(charset_info, *ptr) ||
(*ptr == '-' && my_isalpha(charset_info, ptr[1]))) (*ptr == '-' && my_isalpha(charset_info, ptr[1])))
fputs("NULL", md_result_file); fputs("NULL", md_result_file);
else if (field->type == FIELD_TYPE_DECIMAL) else if (field->type == FIELD_TYPE_DECIMAL)
{ {
/* add " signs around */ /* add " signs around */
fputc('\'', md_result_file); fputc('\'', md_result_file);
fputs(ptr, md_result_file); fputs(ptr, md_result_file);
fputc('\'', md_result_file); fputc('\'', md_result_file);
} }
else else
fputs(ptr, md_result_file); fputs(ptr, md_result_file);
} }
} }
else else
{ {
/* The field value is NULL */ /* The field value is NULL */
if (!opt_xml) if (!opt_xml)
...@@ -2412,61 +2430,61 @@ static void dump_table(char *table, char *db) ...@@ -2412,61 +2430,61 @@ static void dump_table(char *table, char *db)
field->name, "\n"); field->name, "\n");
} }
check_io(md_result_file); check_io(md_result_file);
} }
} }
if (opt_xml) if (opt_xml)
{ {
fputs("\t</row>\n", md_result_file); fputs("\t</row>\n", md_result_file);
check_io(md_result_file); check_io(md_result_file);
} }
if (extended_insert) if (extended_insert)
{ {
ulong row_length; ulong row_length;
dynstr_append(&extended_row,")"); dynstr_append(&extended_row,")");
row_length = 2 + extended_row.length; row_length = 2 + extended_row.length;
if (total_length + row_length < opt_net_buffer_length) if (total_length + row_length < opt_net_buffer_length)
{ {
total_length += row_length; total_length += row_length;
fputc(',',md_result_file); /* Always row break */ fputc(',',md_result_file); /* Always row break */
fputs(extended_row.str,md_result_file); fputs(extended_row.str,md_result_file);
} }
else else
{ {
if (row_break) if (row_break)
fputs(";\n", md_result_file); fputs(";\n", md_result_file);
row_break=1; /* This is first row */ row_break=1; /* This is first row */
fputs(insert_pat.str,md_result_file); fputs(insert_pat.str,md_result_file);
fputs(extended_row.str,md_result_file); fputs(extended_row.str,md_result_file);
total_length = row_length+init_length; total_length = row_length+init_length;
} }
check_io(md_result_file); check_io(md_result_file);
} }
else if (!opt_xml) else if (!opt_xml)
{ {
fputs(");\n", md_result_file); fputs(");\n", md_result_file);
check_io(md_result_file); check_io(md_result_file);
} }
} }
/* XML - close table tag and supress regular output */ /* XML - close table tag and supress regular output */
if (opt_xml) if (opt_xml)
fputs("\t</table_data>\n", md_result_file); fputs("\t</table_data>\n", md_result_file);
else if (extended_insert && row_break) else if (extended_insert && row_break)
fputs(";\n", md_result_file); /* If not empty table */ fputs(";\n", md_result_file); /* If not empty table */
fflush(md_result_file); fflush(md_result_file);
check_io(md_result_file); check_io(md_result_file);
if (mysql_errno(sock)) if (mysql_errno(sock))
{ {
my_snprintf(query, QUERY_LENGTH, my_snprintf(query, QUERY_LENGTH,
"%s: Error %d: %s when dumping table %s at row: %ld\n", "%s: Error %d: %s when dumping table %s at row: %ld\n",
my_progname, my_progname,
mysql_errno(sock), mysql_errno(sock),
mysql_error(sock), mysql_error(sock),
result_table, result_table,
rownr); rownr);
fputs(query,stderr); fputs(query,stderr);
error= EX_CONSCHECK; error= EX_CONSCHECK;
goto err; goto err;
...@@ -2479,7 +2497,7 @@ static void dump_table(char *table, char *db) ...@@ -2479,7 +2497,7 @@ static void dump_table(char *table, char *db)
if (opt_disable_keys) if (opt_disable_keys)
{ {
fprintf(md_result_file,"/*!40000 ALTER TABLE %s ENABLE KEYS */;\n", fprintf(md_result_file,"/*!40000 ALTER TABLE %s ENABLE KEYS */;\n",
opt_quoted_table); opt_quoted_table);
check_io(md_result_file); check_io(md_result_file);
} }
if (opt_autocommit) if (opt_autocommit)
...@@ -2538,7 +2556,7 @@ static int dump_all_databases() ...@@ -2538,7 +2556,7 @@ static int dump_all_databases()
if (dump_all_tables_in_db(row[0])) if (dump_all_tables_in_db(row[0]))
result=1; result=1;
} }
if (was_views) if (seen_views)
{ {
if (mysql_query(sock, "SHOW DATABASES") || if (mysql_query(sock, "SHOW DATABASES") ||
!(tableres = mysql_store_result(sock))) !(tableres = mysql_store_result(sock)))
...@@ -2567,7 +2585,7 @@ static int dump_databases(char **db_names) ...@@ -2567,7 +2585,7 @@ static int dump_databases(char **db_names)
if (dump_all_tables_in_db(*db)) if (dump_all_tables_in_db(*db))
result=1; result=1;
} }
if (!result && was_views) if (!result && seen_views)
{ {
for (db= db_names ; *db ; db++) for (db= db_names ; *db ; db++)
{ {
...@@ -2583,26 +2601,26 @@ static int init_dumping(char *database) ...@@ -2583,26 +2601,26 @@ static int init_dumping(char *database)
{ {
if (mysql_get_server_version(sock) >= 50003 && if (mysql_get_server_version(sock) >= 50003 &&
!my_strcasecmp(&my_charset_latin1, database, "information_schema")) !my_strcasecmp(&my_charset_latin1, database, "information_schema"))
return 1; return 1;
if (mysql_select_db(sock, database)) if (mysql_select_db(sock, database))
{ {
DB_error(sock, "when selecting the database"); DB_error(sock, "when selecting the database");
return 1; /* If --force */ return 1; /* If --force */
} }
if (!path && !opt_xml) if (!path && !opt_xml)
{ {
if (opt_databases || opt_alldbs) if (opt_databases || opt_alldbs)
{ {
/* /*
length of table name * 2 (if name contains quotes), 2 quotes and 0 length of table name * 2 (if name contains quotes), 2 quotes and 0
*/ */
char quoted_database_buf[64*2+3]; char quoted_database_buf[64*2+3];
char *qdatabase= quote_name(database,quoted_database_buf,opt_quoted); char *qdatabase= quote_name(database,quoted_database_buf,opt_quoted);
if (opt_comments) if (opt_comments)
{ {
fprintf(md_result_file,"\n--\n-- Current Database: %s\n--\n", qdatabase); fprintf(md_result_file,"\n--\n-- Current Database: %s\n--\n", qdatabase);
check_io(md_result_file); check_io(md_result_file);
} }
if (!opt_create_db) if (!opt_create_db)
{ {
...@@ -2610,9 +2628,9 @@ static int init_dumping(char *database) ...@@ -2610,9 +2628,9 @@ static int init_dumping(char *database)
MYSQL_ROW row; MYSQL_ROW row;
MYSQL_RES *dbinfo; MYSQL_RES *dbinfo;
my_snprintf(qbuf, sizeof(qbuf), my_snprintf(qbuf, sizeof(qbuf),
"SHOW CREATE DATABASE IF NOT EXISTS %s", "SHOW CREATE DATABASE IF NOT EXISTS %s",
qdatabase); qdatabase);
if (mysql_query(sock, qbuf) || !(dbinfo = mysql_store_result(sock))) if (mysql_query(sock, qbuf) || !(dbinfo = mysql_store_result(sock)))
{ {
...@@ -2621,22 +2639,22 @@ static int init_dumping(char *database) ...@@ -2621,22 +2639,22 @@ static int init_dumping(char *database)
fprintf(md_result_file, fprintf(md_result_file,
"\n/*!40000 DROP DATABASE IF EXISTS %s;*/\n", "\n/*!40000 DROP DATABASE IF EXISTS %s;*/\n",
qdatabase); qdatabase);
fprintf(md_result_file, fprintf(md_result_file,
"\nCREATE DATABASE /*!32312 IF NOT EXISTS*/ %s;\n", "\nCREATE DATABASE /*!32312 IF NOT EXISTS*/ %s;\n",
qdatabase); qdatabase);
} }
else else
{ {
if (opt_drop_database) if (opt_drop_database)
fprintf(md_result_file, fprintf(md_result_file,
"\n/*!40000 DROP DATABASE IF EXISTS %s*/;\n", "\n/*!40000 DROP DATABASE IF EXISTS %s*/;\n",
qdatabase); qdatabase);
row = mysql_fetch_row(dbinfo); row = mysql_fetch_row(dbinfo);
if (row[1]) if (row[1])
{ {
fprintf(md_result_file,"\n%s;\n",row[1]); fprintf(md_result_file,"\n%s;\n",row[1]);
} }
} }
} }
fprintf(md_result_file,"\nUSE %s;\n", qdatabase); fprintf(md_result_file,"\nUSE %s;\n", qdatabase);
check_io(md_result_file); check_io(md_result_file);
...@@ -2741,8 +2759,6 @@ static my_bool dump_all_views_in_db(char *database) ...@@ -2741,8 +2759,6 @@ static my_bool dump_all_views_in_db(char *database)
uint numrows; uint numrows;
char table_buff[NAME_LEN*2+3]; char table_buff[NAME_LEN*2+3];
if (init_dumping(database))
return 1;
if (opt_xml) if (opt_xml)
print_xml_tag1(md_result_file, "", "database name=", database, "\n"); print_xml_tag1(md_result_file, "", "database name=", database, "\n");
if (lock_tables) if (lock_tables)
...@@ -2801,7 +2817,7 @@ static char *get_actual_table_name(const char *old_table_name, MEM_ROOT *root) ...@@ -2801,7 +2817,7 @@ static char *get_actual_table_name(const char *old_table_name, MEM_ROOT *root)
/* Check memory for quote_for_like() */ /* Check memory for quote_for_like() */
DBUG_ASSERT(2*sizeof(old_table_name) < sizeof(show_name_buff)); DBUG_ASSERT(2*sizeof(old_table_name) < sizeof(show_name_buff));
my_snprintf(query, sizeof(query), "SHOW TABLES LIKE %s", my_snprintf(query, sizeof(query), "SHOW TABLES LIKE %s",
quote_for_like(old_table_name, show_name_buff)); quote_for_like(old_table_name, show_name_buff));
if (mysql_query_with_error_report(sock, 0, query)) if (mysql_query_with_error_report(sock, 0, query))
{ {
...@@ -2896,7 +2912,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables) ...@@ -2896,7 +2912,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
} }
/* Dump each selected view */ /* Dump each selected view */
if (was_views) if (seen_views)
{ {
for (pos= dump_tables; pos < end; pos++) for (pos= dump_tables; pos < end; pos++)
get_view_structure(*pos, db); get_view_structure(*pos, db);
...@@ -2946,14 +2962,14 @@ static int do_show_master_status(MYSQL *mysql_con) ...@@ -2946,14 +2962,14 @@ static int do_show_master_status(MYSQL *mysql_con)
"recovery from\n--\n\n"); "recovery from\n--\n\n");
fprintf(md_result_file, fprintf(md_result_file,
"%sCHANGE MASTER TO MASTER_LOG_FILE='%s', MASTER_LOG_POS=%s;\n", "%sCHANGE MASTER TO MASTER_LOG_FILE='%s', MASTER_LOG_POS=%s;\n",
comment_prefix, row[0], row[1]); comment_prefix, row[0], row[1]);
check_io(md_result_file); check_io(md_result_file);
} }
else if (!ignore_errors) else if (!ignore_errors)
{ {
/* SHOW MASTER STATUS reports nothing and --force is not enabled */ /* SHOW MASTER STATUS reports nothing and --force is not enabled */
my_printf_error(0, "Error: Binlogging on server not active", my_printf_error(0, "Error: Binlogging on server not active",
MYF(0)); MYF(0));
mysql_free_result(master); mysql_free_result(master);
return 1; return 1;
} }
...@@ -2973,7 +2989,7 @@ static int do_flush_tables_read_lock(MYSQL *mysql_con) ...@@ -2973,7 +2989,7 @@ static int do_flush_tables_read_lock(MYSQL *mysql_con)
and most client connections are stalled. Of course, if a second long and most client connections are stalled. Of course, if a second long
update starts between the two FLUSHes, we have that bad stall. update starts between the two FLUSHes, we have that bad stall.
*/ */
return return
( mysql_query_with_error_report(mysql_con, 0, "FLUSH TABLES") || ( mysql_query_with_error_report(mysql_con, 0, "FLUSH TABLES") ||
mysql_query_with_error_report(mysql_con, 0, mysql_query_with_error_report(mysql_con, 0,
"FLUSH TABLES WITH READ LOCK") ); "FLUSH TABLES WITH READ LOCK") );
...@@ -3015,7 +3031,7 @@ static int start_transaction(MYSQL *mysql_con, my_bool consistent_read_now) ...@@ -3015,7 +3031,7 @@ static int start_transaction(MYSQL *mysql_con, my_bool consistent_read_now)
static ulong find_set(TYPELIB *lib, const char *x, uint length, static ulong find_set(TYPELIB *lib, const char *x, uint length,
char **err_pos, uint *err_len) char **err_pos, uint *err_len)
{ {
const char *end= x + length; const char *end= x + length;
ulong found= 0; ulong found= 0;
...@@ -3057,10 +3073,10 @@ static ulong find_set(TYPELIB *lib, const char *x, uint length, ...@@ -3057,10 +3073,10 @@ static ulong find_set(TYPELIB *lib, const char *x, uint length,
/* Print a value with a prefix on file */ /* Print a value with a prefix on file */
static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row, static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row,
const char *prefix, const char *name, const char *prefix, const char *name,
int string_value) int string_value)
{ {
MYSQL_FIELD *field; MYSQL_FIELD *field;
mysql_field_seek(result, 0); mysql_field_seek(result, 0);
for ( ; (field = mysql_fetch_field(result)) ; row++) for ( ; (field = mysql_fetch_field(result)) ; row++)
...@@ -3069,18 +3085,18 @@ static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row, ...@@ -3069,18 +3085,18 @@ static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row,
{ {
if (row[0] && row[0][0] && strcmp(row[0],"0")) /* Skip default */ if (row[0] && row[0][0] && strcmp(row[0],"0")) /* Skip default */
{ {
fputc(' ',file); fputc(' ',file);
fputs(prefix, file); fputs(prefix, file);
if (string_value) if (string_value)
unescape(file,row[0],(uint) strlen(row[0])); unescape(file,row[0],(uint) strlen(row[0]));
else else
fputs(row[0], file); fputs(row[0], file);
check_io(file); check_io(file);
return; return;
} }
} }
} }
return; /* This shouldn't happen */ return; /* This shouldn't happen */
} /* print_value */ } /* print_value */
...@@ -3091,19 +3107,19 @@ static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row, ...@@ -3091,19 +3107,19 @@ 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: 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. 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 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 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 sets the value of the bool pointer supports_delayed_inserts to 0 if not
supported, 1 if it is supported. supported, 1 if it is supported.
ARGS 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 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
char (bit value) See IGNORE_ values at top char (bit value) See IGNORE_ values at top
...@@ -3120,23 +3136,23 @@ char check_if_ignore_table(const char *table_name, char *table_type) ...@@ -3120,23 +3136,23 @@ char check_if_ignore_table(const char *table_name, char *table_type)
/* 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));
my_snprintf(buff, sizeof(buff), "show table status like %s", my_snprintf(buff, sizeof(buff), "show table status like %s",
quote_for_like(table_name, show_name_buff)); quote_for_like(table_name, show_name_buff));
if (mysql_query_with_error_report(sock, &res, buff)) if (mysql_query_with_error_report(sock, &res, buff))
{ {
if (mysql_errno(sock) != ER_PARSE_ERROR) if (mysql_errno(sock) != ER_PARSE_ERROR)
{ /* If old MySQL version */ { /* If old MySQL version */
if (verbose) if (verbose)
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));
DBUG_RETURN(result); /* assume table is ok */ DBUG_RETURN(result); /* assume table is ok */
} }
} }
if (!(row= mysql_fetch_row(res))) if (!(row= mysql_fetch_row(res)))
{ {
fprintf(stderr, fprintf(stderr,
"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);
DBUG_RETURN(result); /* assume table is ok */ DBUG_RETURN(result); /* assume table is ok */
} }
...@@ -3199,8 +3215,8 @@ static char *primary_key_fields(const char *table_name) ...@@ -3199,8 +3215,8 @@ static char *primary_key_fields(const char *table_name)
uint result_length = 0; uint result_length = 0;
char *result = 0; char *result = 0;
my_snprintf(show_keys_buff, sizeof(show_keys_buff), my_snprintf(show_keys_buff, sizeof(show_keys_buff),
"SHOW KEYS FROM %s", table_name); "SHOW KEYS FROM %s", table_name);
if (mysql_query(sock, show_keys_buff) || if (mysql_query(sock, show_keys_buff) ||
!(res = mysql_store_result(sock))) !(res = mysql_store_result(sock)))
{ {
...@@ -3276,7 +3292,7 @@ static int replace(DYNAMIC_STRING *ds_str, ...@@ -3276,7 +3292,7 @@ static int replace(DYNAMIC_STRING *ds_str,
if (!start) if (!start)
return 1; return 1;
init_dynamic_string(&ds_tmp, "", init_dynamic_string(&ds_tmp, "",
ds_str->length + replace_len, 256); ds_str->length + replace_len, 256);
dynstr_append_mem(&ds_tmp, ds_str->str, start - ds_str->str); dynstr_append_mem(&ds_tmp, ds_str->str, start - ds_str->str);
dynstr_append_mem(&ds_tmp, replace_str, replace_len); dynstr_append_mem(&ds_tmp, replace_str, replace_len);
dynstr_append(&ds_tmp, start + search_len); dynstr_append(&ds_tmp, start + search_len);
...@@ -3304,9 +3320,9 @@ static my_bool get_view_structure(char *table, char* db) ...@@ -3304,9 +3320,9 @@ static my_bool get_view_structure(char *table, char* db)
MYSQL_RES *table_res; MYSQL_RES *table_res;
MYSQL_ROW row; MYSQL_ROW row;
MYSQL_FIELD *field; MYSQL_FIELD *field;
char *result_table, *opt_quoted_table; char *result_table, *opt_quoted_table;
char table_buff[NAME_LEN*2+3]; char table_buff[NAME_LEN*2+3];
char table_buff2[NAME_LEN*2+3]; char table_buff2[NAME_LEN*2+3];
char query[QUERY_LENGTH]; char query[QUERY_LENGTH];
FILE *sql_file = md_result_file; FILE *sql_file = md_result_file;
DBUG_ENTER("get_view_structure"); DBUG_ENTER("get_view_structure");
...@@ -3319,7 +3335,7 @@ static my_bool get_view_structure(char *table, char* db) ...@@ -3319,7 +3335,7 @@ static my_bool get_view_structure(char *table, char* db)
#ifdef NOT_REALLY_USED_YET #ifdef NOT_REALLY_USED_YET
sprintf(insert_pat,"SET OPTION SQL_QUOTE_SHOW_CREATE=%d", sprintf(insert_pat,"SET OPTION SQL_QUOTE_SHOW_CREATE=%d",
(opt_quoted || opt_keywords)); (opt_quoted || opt_keywords));
#endif #endif
result_table= quote_name(table, table_buff, 1); result_table= quote_name(table, table_buff, 1);
...@@ -3354,7 +3370,7 @@ static my_bool get_view_structure(char *table, char* db) ...@@ -3354,7 +3370,7 @@ static my_bool get_view_structure(char *table, char* db)
if (!opt_xml && opt_comments) if (!opt_xml && opt_comments)
{ {
fprintf(sql_file, "\n--\n-- View structure for view %s\n--\n\n", fprintf(sql_file, "\n--\n-- Final view structure for view %s\n--\n\n",
result_table); result_table);
check_io(sql_file); check_io(sql_file);
} }
...@@ -3435,7 +3451,7 @@ static my_bool get_view_structure(char *table, char* db) ...@@ -3435,7 +3451,7 @@ static my_bool get_view_structure(char *table, char* db)
char quoted_host_name_str[HOSTNAME_LENGTH * 2 + 3]; char quoted_host_name_str[HOSTNAME_LENGTH * 2 + 3];
parse_user(row[1], lengths[1], user_name_str, &user_name_len, parse_user(row[1], lengths[1], user_name_str, &user_name_len,
host_name_str, &host_name_len); host_name_str, &host_name_len);
ptr= search_buf; ptr= search_buf;
search_len= search_len=
......
...@@ -2570,14 +2570,14 @@ do not allow the discard. We also reserve the data dictionary latch. */ ...@@ -2570,14 +2570,14 @@ do not allow the discard. We also reserve the data dictionary latch. */
} }
} }
funct_exit: funct_exit:
trx_commit_for_mysql(trx);
row_mysql_unlock_data_dictionary(trx); row_mysql_unlock_data_dictionary(trx);
if (graph) { if (graph) {
que_graph_free(graph); que_graph_free(graph);
} }
trx_commit_for_mysql(trx);
trx->op_info = ""; trx->op_info = "";
return((int) err); return((int) err);
...@@ -2707,10 +2707,10 @@ row_import_tablespace_for_mysql( ...@@ -2707,10 +2707,10 @@ row_import_tablespace_for_mysql(
} }
funct_exit: funct_exit:
row_mysql_unlock_data_dictionary(trx);
trx_commit_for_mysql(trx); trx_commit_for_mysql(trx);
row_mysql_unlock_data_dictionary(trx);
trx->op_info = ""; trx->op_info = "";
return((int) err); return((int) err);
...@@ -3398,6 +3398,8 @@ fputs(" InnoDB: You are trying to drop table ", stderr); ...@@ -3398,6 +3398,8 @@ fputs(" InnoDB: You are trying to drop table ", stderr);
} }
funct_exit: funct_exit:
trx_commit_for_mysql(trx);
if (locked_dictionary) { if (locked_dictionary) {
row_mysql_unlock_data_dictionary(trx); row_mysql_unlock_data_dictionary(trx);
} }
...@@ -3408,8 +3410,6 @@ funct_exit: ...@@ -3408,8 +3410,6 @@ funct_exit:
que_graph_free(graph); que_graph_free(graph);
trx_commit_for_mysql(trx);
trx->op_info = ""; trx->op_info = "";
#ifndef UNIV_HOTBACKUP #ifndef UNIV_HOTBACKUP
...@@ -3488,10 +3488,10 @@ loop: ...@@ -3488,10 +3488,10 @@ loop:
} }
} }
row_mysql_unlock_data_dictionary(trx);
trx_commit_for_mysql(trx); trx_commit_for_mysql(trx);
row_mysql_unlock_data_dictionary(trx);
trx->op_info = ""; trx->op_info = "";
return(err); return(err);
...@@ -3905,6 +3905,8 @@ row_rename_table_for_mysql( ...@@ -3905,6 +3905,8 @@ row_rename_table_for_mysql(
} }
} }
funct_exit: funct_exit:
trx_commit_for_mysql(trx);
if (!recovering_temp_table) { if (!recovering_temp_table) {
row_mysql_unlock_data_dictionary(trx); row_mysql_unlock_data_dictionary(trx);
} }
...@@ -3917,8 +3919,6 @@ funct_exit: ...@@ -3917,8 +3919,6 @@ funct_exit:
mem_heap_free(heap); mem_heap_free(heap);
} }
trx_commit_for_mysql(trx);
trx->op_info = ""; trx->op_info = "";
return((int) err); return((int) err);
......
...@@ -1064,11 +1064,12 @@ row_sel_try_search_shortcut( ...@@ -1064,11 +1064,12 @@ row_sel_try_search_shortcut(
ut_ad(plan->pcur.latch_mode == node->latch_mode); ut_ad(plan->pcur.latch_mode == node->latch_mode);
plan->n_rows_fetched++; plan->n_rows_fetched++;
ret = SEL_FOUND;
func_exit: func_exit:
if (UNIV_LIKELY_NULL(heap)) { if (UNIV_LIKELY_NULL(heap)) {
mem_heap_free(heap); mem_heap_free(heap);
} }
return(SEL_FOUND); return(ret);
} }
/************************************************************************* /*************************************************************************
......
...@@ -1458,7 +1458,6 @@ UNLOCK TABLES; ...@@ -1458,7 +1458,6 @@ UNLOCK TABLES;
/*!40000 ALTER TABLE `t2` ENABLE KEYS */; /*!40000 ALTER TABLE `t2` ENABLE KEYS */;
DROP TABLE IF EXISTS `v2`; DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/; /*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 CREATE TABLE `v2` ( /*!50001 CREATE TABLE `v2` (
`a` varchar(30) `a` varchar(30)
) */; ) */;
...@@ -1764,7 +1763,6 @@ UNLOCK TABLES; ...@@ -1764,7 +1763,6 @@ UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */; /*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `v1`; DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/; /*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 CREATE TABLE `v1` ( /*!50001 CREATE TABLE `v1` (
`a` int(11) `a` int(11)
) */; ) */;
...@@ -1822,7 +1820,6 @@ UNLOCK TABLES; ...@@ -1822,7 +1820,6 @@ UNLOCK TABLES;
/*!40000 ALTER TABLE `t2` ENABLE KEYS */; /*!40000 ALTER TABLE `t2` ENABLE KEYS */;
DROP TABLE IF EXISTS `v2`; DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/; /*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 CREATE TABLE `v2` ( /*!50001 CREATE TABLE `v2` (
`a` varchar(30) `a` varchar(30)
) */; ) */;
...@@ -1915,7 +1912,6 @@ UNLOCK TABLES; ...@@ -1915,7 +1912,6 @@ UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */; /*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `v1`; DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/; /*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 CREATE TABLE `v1` ( /*!50001 CREATE TABLE `v1` (
`a` int(11), `a` int(11),
`b` int(11), `b` int(11),
...@@ -1923,13 +1919,11 @@ DROP TABLE IF EXISTS `v1`; ...@@ -1923,13 +1919,11 @@ DROP TABLE IF EXISTS `v1`;
) */; ) */;
DROP TABLE IF EXISTS `v2`; DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/; /*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 CREATE TABLE `v2` ( /*!50001 CREATE TABLE `v2` (
`a` int(11) `a` int(11)
) */; ) */;
DROP TABLE IF EXISTS `v3`; DROP TABLE IF EXISTS `v3`;
/*!50001 DROP VIEW IF EXISTS `v3`*/; /*!50001 DROP VIEW IF EXISTS `v3`*/;
/*!50001 DROP TABLE IF EXISTS `v3`*/;
/*!50001 CREATE TABLE `v3` ( /*!50001 CREATE TABLE `v3` (
`a` int(11), `a` int(11),
`b` int(11), `b` int(11),
...@@ -2490,7 +2484,6 @@ UNLOCK TABLES; ...@@ -2490,7 +2484,6 @@ UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */; /*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `v0`; DROP TABLE IF EXISTS `v0`;
/*!50001 DROP VIEW IF EXISTS `v0`*/; /*!50001 DROP VIEW IF EXISTS `v0`*/;
/*!50001 DROP TABLE IF EXISTS `v0`*/;
/*!50001 CREATE TABLE `v0` ( /*!50001 CREATE TABLE `v0` (
`a` int(11), `a` int(11),
`b` varchar(32), `b` varchar(32),
...@@ -2498,7 +2491,6 @@ DROP TABLE IF EXISTS `v0`; ...@@ -2498,7 +2491,6 @@ DROP TABLE IF EXISTS `v0`;
) */; ) */;
DROP TABLE IF EXISTS `v1`; DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/; /*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 CREATE TABLE `v1` ( /*!50001 CREATE TABLE `v1` (
`a` int(11), `a` int(11),
`b` varchar(32), `b` varchar(32),
...@@ -2506,16 +2498,11 @@ DROP TABLE IF EXISTS `v1`; ...@@ -2506,16 +2498,11 @@ DROP TABLE IF EXISTS `v1`;
) */; ) */;
DROP TABLE IF EXISTS `v2`; DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/; /*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 CREATE TABLE `v2` ( /*!50001 CREATE TABLE `v2` (
`a` int(11), `a` int(11),
`b` varchar(32), `b` varchar(32),
`c` varchar(32) `c` varchar(32)
) */; ) */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `test`;
/*!50001 DROP TABLE IF EXISTS `v0`*/; /*!50001 DROP TABLE IF EXISTS `v0`*/;
/*!50001 DROP VIEW IF EXISTS `v0`*/; /*!50001 DROP VIEW IF EXISTS `v0`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50001 CREATE ALGORITHM=UNDEFINED */
...@@ -2770,3 +2757,62 @@ p CREATE DEFINER=`root`@`localhost` PROCEDURE `p`() ...@@ -2770,3 +2757,62 @@ p CREATE DEFINER=`root`@`localhost` PROCEDURE `p`()
select 42 select 42
drop function f; drop function f;
drop procedure p; drop procedure p;
create database mysqldump_test_db;
use mysqldump_test_db;
create table t1 (id int);
create view v1 as select * from t1;
insert into t1 values (1232131);
insert into t1 values (4711);
insert into t1 values (3231);
insert into t1 values (0815);
/*!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 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!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 */;
/*!40000 DROP DATABASE IF EXISTS `mysqldump_test_db`*/;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqldump_test_db` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `mysqldump_test_db`;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`id` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
INSERT INTO `t1` VALUES (1232131),(4711),(3231),(815);
UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 CREATE TABLE `v1` (
`id` int(11)
) */;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v1` AS select `t1`.`id` AS `id` from `t1` */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!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 view v1;
drop table t1;
drop database mysqldump_test_db;
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
drop database if exists test1;
create database test1;
use test1;
CREATE TABLE `t1` (
`id` int(10) unsigned NOT NULL auto_increment,
`fname` varchar(100) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
INSERT INTO `t1` VALUES (1, 'blablabla');
CREATE TABLE `t2` (
`id` int(10) NOT NULL auto_increment,
`comment` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=3 ;
INSERT INTO `t2` VALUES (1, 'testtest 1');
INSERT INTO `t2` VALUES (2, 'test 2');
CREATE PROCEDURE simpleproc3 ()
NOT DETERMINISTIC
BEGIN
INSERT INTO t1 (fname) (SELECT t2.comment FROM t2 WHERE t2.id = '1');
INSERT INTO t1 (fname) VALUES('test');
END
$
CALL simpleproc3();
select * from t2;
id comment
1 testtest 1
2 test 2
TRUNCATE TABLE `t1`;
CALL simpleproc3();
select * from t1;
id fname
1 testtest 1
2 test
use test1;
select * from t1;
id fname
1 testtest 1
2 test
drop database test1;
drop database test1;
...@@ -485,6 +485,10 @@ set sql_mode=2097152; ...@@ -485,6 +485,10 @@ set sql_mode=2097152;
select @@sql_mode; select @@sql_mode;
@@sql_mode @@sql_mode
STRICT_TRANS_TABLES STRICT_TRANS_TABLES
set sql_mode=4194304;
select @@sql_mode;
@@sql_mode
STRICT_ALL_TABLES
set sql_mode=16384+(65536*4); set sql_mode=16384+(65536*4);
select @@sql_mode; select @@sql_mode;
@@sql_mode @@sql_mode
......
...@@ -2196,3 +2196,16 @@ drop table t2, t1; ...@@ -2196,3 +2196,16 @@ drop table t2, t1;
# #
--error ER_TABLE_CANT_HANDLE_SPKEYS --error ER_TABLE_CANT_HANDLE_SPKEYS
create table t1 (g geometry not null, spatial gk(g)) engine=innodb; create table t1 (g geometry not null, spatial gk(g)) engine=innodb;
#######################################################################
# #
# Please, DO NOT TOUCH this file as well as the innodb.result file. #
# These files are to be modified ONLY BY INNOBASE guys. #
# #
# Use innodb_mysql.[test|result] files instead. #
# #
# If nevertheless you need to make some changes here, please, forward #
# your commit message To: dev@innodb.com Cc: dev-innodb@mysql.com #
# (otherwise your changes may be erased). #
# #
#######################################################################
...@@ -1161,3 +1161,20 @@ show create procedure p; ...@@ -1161,3 +1161,20 @@ show create procedure p;
drop function f; drop function f;
drop procedure p; drop procedure p;
#
# BUG#17201 Spurious 'DROP DATABASE' in output,
# also confusion between tables and views.
# Example code from Markus Popp
create database mysqldump_test_db;
use mysqldump_test_db;
create table t1 (id int);
create view v1 as select * from t1;
insert into t1 values (1232131);
insert into t1 values (4711);
insert into t1 values (3231);
insert into t1 values (0815);
--exec $MYSQL_DUMP --skip-comments --add-drop-database --databases mysqldump_test_db
drop view v1;
drop table t1;
drop database mysqldump_test_db;
#
# Test of auto_increment
# BUG#11932
#
# Bug reported that master and slave get out of sync after TRUNCATE
# TABLE.
#
# Test supplied by Are Casilla
source include/master-slave.inc;
--disable_warnings
connection master;
drop database if exists test1;
--enable_warnings
create database test1;
use test1;
CREATE TABLE `t1` (
`id` int(10) unsigned NOT NULL auto_increment,
`fname` varchar(100) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
INSERT INTO `t1` VALUES (1, 'blablabla');
CREATE TABLE `t2` (
`id` int(10) NOT NULL auto_increment,
`comment` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=3 ;
INSERT INTO `t2` VALUES (1, 'testtest 1');
INSERT INTO `t2` VALUES (2, 'test 2');
DELIMITER $;
CREATE PROCEDURE simpleproc3 ()
NOT DETERMINISTIC
BEGIN
INSERT INTO t1 (fname) (SELECT t2.comment FROM t2 WHERE t2.id = '1');
INSERT INTO t1 (fname) VALUES('test');
END
$
DELIMITER ;$
CALL simpleproc3();
select * from t2;
TRUNCATE TABLE `t1`;
CALL simpleproc3();
select * from t1;
save_master_pos;
connection slave;
sync_with_master;
use test1;
select * from t1;
drop database test1;
connection master;
drop database test1;
...@@ -258,6 +258,9 @@ drop table t1, t2; ...@@ -258,6 +258,9 @@ drop table t1, t2;
select @@sql_mode; select @@sql_mode;
set sql_mode=2097152; set sql_mode=2097152;
select @@sql_mode; select @@sql_mode;
# BUG#14675
set sql_mode=4194304;
select @@sql_mode;
set sql_mode=16384+(65536*4); set sql_mode=16384+(65536*4);
select @@sql_mode; select @@sql_mode;
--error 1231 --error 1231
......
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