--- mysql-3.23.46/client/mysqldump.c Fri Dec 28 07:09:23 2001 +++ mysql-g-3.23.46/client/mysqldump.c Fri Dec 28 06:20:29 2001 @@ -37,7 +37,7 @@ ** Tõnu Samuel **/ -#define DUMP_VERSION "8.16" +#define DUMP_VERSION "8.17" #include #include @@ -151,7 +151,7 @@ }; static void safe_exit(int error); -static void write_heder(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, const char *prefix,const char *name, int string_value); @@ -269,7 +269,7 @@ } /* usage */ -static void write_heder(FILE *sql_file, char *db_name) +static void write_header(FILE *sql_file, char *db_name) { fprintf(sql_file, "# MySQL dump %s\n#\n", DUMP_VERSION); fprintf(sql_file, "# Host: %s Database: %s\n", @@ -279,7 +279,7 @@ fprintf(sql_file, "# Server version\t%s\n", mysql_get_server_info(&mysql_connection)); return; -} /* write_heder */ +} /* write_header */ static int get_options(int *argc,char ***argv) @@ -638,7 +638,7 @@ safe_exit(EX_MYSQLERR); DBUG_RETURN(0); } - write_heder(sql_file, db); + write_header(sql_file, db); } fprintf(sql_file, "\n#\n# Table structure for table '%s'\n#\n\n", table); if (opt_drop) @@ -654,6 +654,8 @@ { fprintf(stderr, "%s: Can't get info about table: '%s'\nerror: %s\n", my_progname, table, mysql_error(sock)); + if (path) + my_fclose(sql_file, MYF(MY_WME)); safe_exit(EX_MYSQLERR); DBUG_RETURN(0); } @@ -708,10 +710,10 @@ O_WRONLY, MYF(MY_WME)); if (!sql_file) /* If file couldn't be opened */ { - safe_exit(EX_MYSQLERR); - DBUG_RETURN(0); + safe_exit(EX_MYSQLERR); + DBUG_RETURN(0); } - write_heder(sql_file, db); + write_header(sql_file, db); } fprintf(sql_file, "\n#\n# Table structure for table '%s'\n#\n\n", table); if (opt_drop) @@ -772,7 +774,7 @@ { fprintf(stderr, "%s: Can't get keys for table '%s' (%s)\n", my_progname, table, mysql_error(sock)); - if (sql_file != stdout) + if (path) my_fclose(sql_file, MYF(MY_WME)); safe_exit(EX_MYSQLERR); DBUG_RETURN(0); @@ -1352,19 +1354,19 @@ if (dbConnect(current_host, current_user, opt_password)) exit(EX_MYSQLERR); if (!path) - write_heder(md_result_file, *argv); + write_header(md_result_file, *argv); - if (opt_first_slave) - { - lock_tables=0; /* No other locks needed */ - if (mysql_query(sock, "FLUSH TABLES WITH READ LOCK")) - { - my_printf_error(0, "Error: Couldn't execute 'FLUSH TABLES WITH READ LOCK': %s", - MYF(0), mysql_error(sock)); - my_end(0); - return(first_error); - } - } + if (opt_first_slave) + { + lock_tables=0; /* No other locks needed */ + if (mysql_query(sock, "FLUSH TABLES WITH READ LOCK")) + { + my_printf_error(0, "Error: Couldn't execute 'FLUSH TABLES WITH READ LOCK': %s", + MYF(0), mysql_error(sock)); + my_end(0); + return(first_error); + } + } if (opt_alldbs) dump_all_databases(); /* Only one database and selected table(s) */