summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/mysqldump.c37
-rw-r--r--client/mysqltest.c35
2 files changed, 42 insertions, 30 deletions
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 1f520243c7c..b2bf23c3e3a 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -539,6 +539,12 @@ static void write_footer(FILE *sql_file)
}
} /* write_footer */
+static void free_table_ent(char *key)
+
+{
+ my_free((gptr) key, MYF(0));
+}
+
byte* get_table_key(const char *entry, uint *length,
my_bool not_used __attribute__((unused)))
@@ -550,8 +556,9 @@ byte* get_table_key(const char *entry, uint *length,
void init_table_rule_hash(HASH* h)
{
- if(hash_init(h, charset_info, 16, 0, 0,
- (hash_get_key) get_table_key, 0, 0))
+ if (hash_init(h, charset_info, 16, 0, 0,
+ (hash_get_key) get_table_key,
+ (hash_free_key) free_table_ent, 0))
exit(EX_EOM);
}
@@ -806,7 +813,8 @@ static void DB_error(MYSQL *mysql, const char *when)
SYNOPSIS
mysql_query_with_error_report()
mysql_con connection to use
- res if non zero, result will be put there with mysql_store_result
+ res if non zero, result will be put there with
+ mysql_store_result()
query query to send to server
RETURN VALUES
@@ -958,13 +966,14 @@ static char *quote_name(const char *name, char *buff, my_bool force)
return buff;
} /* quote_name */
+
/*
Quote a table name so it can be used in "SHOW TABLES LIKE <tabname>"
SYNOPSIS
- quote_for_like
- name - name of the table
- buff - quoted name of the table
+ quote_for_like()
+ name name of the table
+ buff quoted name of the table
DESCRIPTION
Quote \, _, ' and % characters
@@ -980,7 +989,6 @@ static char *quote_name(const char *name, char *buff, my_bool force)
Example: "t\1" => "t\\\\1"
*/
-
static char *quote_for_like(const char *name, char *buff)
{
char *to= buff;
@@ -1690,7 +1698,7 @@ static void dump_table(uint numFields, char *table)
}
/* Check that there are any fields in the table */
- if(numFields == 0)
+ if (numFields == 0)
{
if (verbose)
fprintf(stderr,
@@ -2446,7 +2454,6 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
DYNAMIC_STRING lock_tables_query;
HASH dump_tables;
char *table_name;
-
DBUG_ENTER("dump_selected_tables");
if (init_dumping(db))
@@ -2454,15 +2461,16 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
/* Init hash table for storing the actual name of tables to dump */
if (hash_init(&dump_tables, charset_info, 16, 0, 0,
- (hash_get_key) get_table_key, 0, 0))
+ (hash_get_key) get_table_key, (hash_free_key) free_table_ent,
+ 0))
exit(EX_EOM);
init_dynamic_string(&lock_tables_query, "LOCK TABLES ", 256, 1024);
for (; tables > 0 ; tables-- , table_names++)
{
/* the table name passed on commandline may be wrong case */
- if (!get_actual_table_name( *table_names,
- new_table_name, sizeof(new_table_name) ))
+ if (!get_actual_table_name(*table_names,
+ new_table_name, sizeof(new_table_name)))
{
/* Add found table name to lock_tables_query */
if (lock_tables)
@@ -2509,7 +2517,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
{
table_name= hash_element(&dump_tables, i);
DBUG_PRINT("info",("Dumping table %s", table_name));
- numrows = get_table_structure(table_name, db);
+ numrows= get_table_structure(table_name, db);
dump_table(numrows, table_name);
}
@@ -2926,6 +2934,7 @@ int main(int argc, char **argv)
{
compatible_mode_normal_str[0]= 0;
default_charset= (char *)mysql_universal_client_charset;
+ bzero((char*) &ignore_table, sizeof(ignore_table));
MY_INIT("mysqldump");
if (get_options(&argc, &argv))
@@ -2984,6 +2993,8 @@ err:
if (md_result_file != stdout)
my_fclose(md_result_file, MYF(0));
my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
+ if (hash_inited(&ignore_table))
+ hash_free(&ignore_table);
if (extended_insert)
dynstr_free(&extended_row);
if (insert_pat_inited)
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 65f8c9358c2..67fa931a3f3 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -994,28 +994,29 @@ static void do_exec(struct st_query* q)
error= pclose(res_file);
if (error != 0)
{
- uint status= WEXITSTATUS(error);
- if(q->abort_on_error)
+ uint status= WEXITSTATUS(error), i;
+ my_bool ok= 0;
+
+ if (q->abort_on_error)
die("At line %u: command \"%s\" failed", start_lineno, cmd);
- else
+
+ DBUG_PRINT("info",
+ ("error: %d, status: %d", error, status));
+ for (i=0 ; (uint) i < q->expected_errors ; i++)
{
- bool ok= 0;
- uint i;
DBUG_PRINT("info",
("error: %d, status: %d", error, status));
- for (i=0 ; (uint) i < q->expected_errors ; i++)
- {
- DBUG_PRINT("info", ("expected error: %d", q->expected_errno[i].code.errnum));
- if ((q->expected_errno[i].type == ERR_ERRNO) &&
- (q->expected_errno[i].code.errnum == status))
- ok= 1;
- verbose_msg("At line %u: command \"%s\" failed with expected error: %d",
- start_lineno, cmd, status);
- }
- if (!ok)
- die("At line: %u: command \"%s\" failed with wrong error: %d",
- start_lineno, cmd, status);
+ DBUG_PRINT("info", ("expected error: %d",
+ q->expected_errno[i].code.errnum));
+ if ((q->expected_errno[i].type == ERR_ERRNO) &&
+ (q->expected_errno[i].code.errnum == status))
+ ok= 1;
+ verbose_msg("At line %u: command \"%s\" failed with expected error: %d",
+ start_lineno, cmd, status);
}
+ if (!ok)
+ die("At line: %u: command \"%s\" failed with wrong error: %d",
+ start_lineno, cmd, status);
}
else if (q->expected_errno[0].type == ERR_ERRNO &&
q->expected_errno[0].code.errnum != 0)