diff --git a/client/mysqldump.c b/client/mysqldump.c index 212baca6be8..a9fe3f8e1fa 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1441,6 +1441,7 @@ static void free_resources() if (md_result_file && md_result_file != stdout) my_fclose(md_result_file, MYF(0)); my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR)); + my_free(current_host, MYF(MY_ALLOW_ZERO_PTR)); if (hash_inited(&ignore_table)) hash_free(&ignore_table); if (extended_insert) @@ -4222,7 +4223,7 @@ static char *get_actual_table_name(const char *old_table_name, MEM_ROOT *root) } mysql_free_result(table_res); } - DBUG_PRINT("exit", ("new_table_name: %s", name)); + DBUG_PRINT("exit", ("new_table_name: %s", val_or_null(name))); DBUG_RETURN(name); } @@ -4818,6 +4819,7 @@ static my_bool get_view_structure(char *table, char* db) field= mysql_fetch_field_direct(table_res, 0); if (strcmp(field->name, "View") != 0) { + mysql_free_result(table_res); switch_character_set_results(mysql, default_charset); verbose_msg("-- It's base table, skipped\n"); DBUG_RETURN(0); @@ -4827,8 +4829,10 @@ static my_bool get_view_structure(char *table, char* db) if (path) { if (!(sql_file= open_sql_file_for_table(table, O_WRONLY))) + { + mysql_free_result(table_res); DBUG_RETURN(1); - + } write_header(sql_file, db); } diff --git a/client/mysqltest.cc b/client/mysqltest.cc index e89f87758c6..a6bfc72070c 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -541,7 +541,7 @@ public: { DBUG_ENTER("LogFile::open"); DBUG_PRINT("enter", ("dir: '%s', name: '%s'", - dir, name)); + val_or_null(dir), val_or_null(name))); if (!name) { m_file= stdout; diff --git a/include/my_global.h b/include/my_global.h index a32db3c87b6..9d9daf5aa1a 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -90,6 +90,9 @@ #define IF_WIN(A,B) (B) #endif +/* Make it easier to print null strings */ +#define val_or_null(A) ((A) ? (const char*) (A) : "(null)") + #ifndef EMBEDDED_LIBRARY #ifdef WITH_NDB_BINLOG #define HAVE_NDB_BINLOG 1 diff --git a/sql/handler.cc b/sql/handler.cc index b7903468b69..e455523d508 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -3865,7 +3865,8 @@ ha_find_files(THD *thd,const char *db,const char *path, int error= 0; DBUG_ENTER("ha_find_files"); DBUG_PRINT("enter", ("db: '%s' path: '%s' wild: '%s' dir: %d", - db, path, wild ? wild : "NULL", dir)); + val_or_null(db), val_or_null(path), + val_or_null(wild), dir)); st_find_files_args args= {db, path, wild, dir, files}; plugin_foreach(thd, find_files_handlerton, diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 94be8a5f240..b4a0e5c4c7d 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -1539,12 +1539,9 @@ bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch) Security_context *sctx= thd->security_ctx; ulong db_access= sctx->db_access; CHARSET_INFO *db_default_cl; - DBUG_ENTER("mysql_change_db"); - DBUG_PRINT("enter",("name: '%s'", new_db_name->str)); - if (new_db_name == NULL || - new_db_name->length == 0) + if (new_db_name->length == 0) { if (force_switch) { @@ -1553,8 +1550,7 @@ bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch) after loading stored program. The thing is that loading of stored program can happen when there is no current database. - TODO: actually, new_db_name and new_db_name->str seem to be always - non-NULL. In case of stored program, new_db_name->str == "" and + In case of stored program, new_db_name->str == "" and new_db_name->length == 0. */ @@ -1569,6 +1565,7 @@ bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch) DBUG_RETURN(TRUE); } } + DBUG_PRINT("enter",("name: '%s'", new_db_name->str)); if (is_schema_db(new_db_name->str, new_db_name->length)) { diff --git a/sql/sql_show.cc b/sql/sql_show.cc index a288cad88d7..6f59f54fe11 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -3563,9 +3563,9 @@ int fill_schema_schemata(THD *thd, TABLE_LIST *tables, COND *cond) if (get_lookup_field_values(thd, cond, tables, &lookup_field_vals)) DBUG_RETURN(0); - DBUG_PRINT("INDEX VALUES",("db_name='%s', table_name='%s'", - lookup_field_vals.db_value.str, - lookup_field_vals.table_value.str)); + DBUG_PRINT("INDEX VALUES",("db_name: %s table_name: %s", + val_or_null(lookup_field_vals.db_value.str), + val_or_null(lookup_field_vals.table_value.str))); if (make_db_list(thd, &db_names, &lookup_field_vals, &with_i_schema)) DBUG_RETURN(1); diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index 8a30467f16c..e013440ecca 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -489,6 +489,9 @@ int ha_tina::encode_quote(uchar *buf) ptr= attribute.ptr(); end_ptr= attribute.length() + ptr; + if (buffer.realloc(attribute.length()*2+2)) + return 0; // Failure + buffer.append('"'); while (ptr < end_ptr)