diff --git a/client/mysqldump.c b/client/mysqldump.c index 4008668b4bc..660de5d72ef 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -2759,86 +2759,66 @@ static int dump_all_tablespaces() static int dump_tablespaces_for_tables(char *db, char **table_names, int tables) { - char *where; + DYNAMIC_STRING where; int r; int i; - - size_t sz= 200+tables*(NAME_LEN*2+3); - where= my_malloc(sz, MYF(MY_WME)); - - if (!where) - return 1; - char name_buff[NAME_LEN*2+3]; + mysql_real_escape_string(mysql, name_buff, db, strlen(db)); - snprintf(where,sz-1, - " AND TABLESPACE_NAME IN (" - "SELECT DISTINCT TABLESPACE_NAME FROM" - " INFORMATION_SCHEMA.PARTITIONS" - " WHERE" - " TABLE_SCHEMA='%s'" - " AND TABLE_NAME IN (", name_buff); + init_dynamic_string(&where, " AND TABLESPACE_NAME IN (" + "SELECT DISTINCT TABLESPACE_NAME FROM" + " INFORMATION_SCHEMA.PARTITIONS" + " WHERE" + " TABLE_SCHEMA='", 256, 1024); + dynstr_append(&where, name_buff); + dynstr_append(&where, "' AND TABLE_NAME IN ("); for (i=0 ; i &field_list, String *str) } -static void store_schema_partitions_record(THD *thd, TABLE *table, - TABLE *show_table, +static void store_schema_partitions_record(THD *thd, TABLE *schema_table, + TABLE *showing_table, partition_element *part_elem, handler *file, uint part_id) { + TABLE* table= schema_table; CHARSET_INFO *cs= system_charset_info; PARTITION_INFO stat_info; TIME time; @@ -3950,8 +3951,7 @@ static void store_schema_partitions_record(THD *thd, TABLE *table, strlen(part_elem->tablespace_name), cs); else { - DBUG_PRINT("info",("FOO")); - char *ts= show_table->file->get_tablespace_name(thd); + char *ts= showing_table->file->get_tablespace_name(thd); if(ts) table->field[24]->store(ts, strlen(ts), cs); else