Skip to content

Commit 641f81b

Browse files
committed
cleanup: use my_multi_malloc(), etc
1 parent 5a9484b commit 641f81b

File tree

4 files changed

+29
-45
lines changed

4 files changed

+29
-45
lines changed

sql/sql_parse.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7728,7 +7728,6 @@ void mysql_parse(THD *thd, char *rawbuf, uint length,
77287728
bool is_com_multi,
77297729
bool is_next_command)
77307730
{
7731-
int error __attribute__((unused));
77327731
DBUG_ENTER("mysql_parse");
77337732
DBUG_EXECUTE_IF("parser_debug", turn_parser_debug_on(););
77347733

@@ -7808,6 +7807,7 @@ void mysql_parse(THD *thd, char *rawbuf, uint length,
78087807
(char *) thd->security_ctx->host_or_ip,
78097808
0);
78107809

7810+
int error __attribute__((unused));
78117811
error= mysql_execute_command(thd);
78127812
MYSQL_QUERY_EXEC_DONE(error);
78137813
}

sql/sql_select.cc

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17490,8 +17490,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
1749017490
No need to change table name to lower case as we are only creating
1749117491
MyISAM, Aria or HEAP tables here
1749217492
*/
17493-
fn_format(path, path, mysql_tmpdir, "",
17494-
MY_REPLACE_EXT|MY_UNPACK_FILENAME);
17493+
fn_format(path, path, mysql_tmpdir, "", MY_REPLACE_EXT|MY_UNPACK_FILENAME);
1749517494

1749617495
if (group)
1749717496
{
@@ -18673,14 +18672,10 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo,
1867318672
}
1867418673
}
1867518674

18676-
if (unlikely((error= maria_create(share->path.str,
18677-
file_type,
18678-
share->keys, &keydef,
18679-
(uint) (*recinfo-start_recinfo),
18680-
start_recinfo,
18681-
share->uniques, &uniquedef,
18682-
&create_info,
18683-
create_flags))))
18675+
if (unlikely((error= maria_create(share->path.str, file_type, share->keys,
18676+
&keydef, (uint) (*recinfo-start_recinfo),
18677+
start_recinfo, share->uniques, &uniquedef,
18678+
&create_info, create_flags))))
1868418679
{
1868518680
table->file->print_error(error,MYF(0)); /* purecov: inspected */
1868618681
table->db_stat=0;
@@ -18881,8 +18876,7 @@ create_internal_tmp_table_from_heap(THD *thd, TABLE *table,
1888118876
if (is_duplicate)
1888218877
*is_duplicate= FALSE;
1888318878

18884-
if (table->s->db_type() != heap_hton ||
18885-
error != HA_ERR_RECORD_FILE_FULL)
18879+
if (table->s->db_type() != heap_hton || error != HA_ERR_RECORD_FILE_FULL)
1888618880
{
1888718881
/*
1888818882
We don't want this error to be converted to a warning, e.g. in case of

sql/sql_show.cc

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8165,7 +8165,7 @@ mark_all_fields_used_in_query(THD *thd,
81658165
0<decimals<10 and 0<=length<100 .
81668166
81678167
@param
8168-
thd thread handler
8168+
thd thread handler
81698169
81708170
@param table_list Used to pass I_S table information(fields info, tables
81718171
parameters etc) and table name.
@@ -8332,11 +8332,10 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
83328332
tmp_table_param->schema_table= 1;
83338333
SELECT_LEX *select_lex= thd->lex->current_select;
83348334
bool keep_row_order= is_show_command(thd);
8335-
if (!(table= create_tmp_table(thd, tmp_table_param,
8336-
field_list, (ORDER*) 0, 0, 0,
8337-
(select_lex->options | thd->variables.option_bits |
8338-
TMP_TABLE_ALL_COLUMNS), HA_POS_ERROR,
8339-
&table_list->alias, false, keep_row_order)))
8335+
if (!(table= create_tmp_table(thd, tmp_table_param, field_list, (ORDER*) 0, 0,
8336+
0, (select_lex->options | thd->variables.option_bits |
8337+
TMP_TABLE_ALL_COLUMNS), HA_POS_ERROR,
8338+
&table_list->alias, false, keep_row_order)))
83408339
DBUG_RETURN(0);
83418340
my_bitmap_map* bitmaps=
83428341
(my_bitmap_map*) thd->alloc(bitmap_buffer_size(field_count));
@@ -8794,10 +8793,10 @@ bool optimize_schema_tables_reads(JOIN *join)
87948793
cond= tab->cache_select->cond;
87958794
}
87968795
if (optimize_for_get_all_tables(thd, table_list, cond))
8797-
DBUG_RETURN(TRUE); // Handle OOM
8796+
DBUG_RETURN(1); // Handle OOM
87988797
}
87998798
}
8800-
DBUG_RETURN(FALSE);
8799+
DBUG_RETURN(0);
88018800
}
88028801

88038802

@@ -8862,13 +8861,10 @@ bool get_schema_tables_result(JOIN *join,
88628861
continue;
88638862

88648863
/*
8865-
If schema table is already processed and
8866-
the statement is not a subselect then
8867-
we don't need to fill this table again.
8868-
If schema table is already processed and
8869-
schema_table_state != executed_place then
8870-
table is already processed and
8871-
we should skip second data processing.
8864+
If schema table is already processed and the statement is not a
8865+
subselect then we don't need to fill this table again. If schema table
8866+
is already processed and schema_table_state != executed_place then
8867+
table is already processed and we should skip second data processing.
88728868
*/
88738869
if (table_list->schema_table_state &&
88748870
(!is_subselect || table_list->schema_table_state != executed_place))
@@ -8930,8 +8926,7 @@ bool get_schema_tables_result(JOIN *join,
89308926
It also means that an audit plugin cannot process the error correctly
89318927
either. See also thd->clear_error()
89328928
*/
8933-
thd->get_stmt_da()->push_warning(thd,
8934-
thd->get_stmt_da()->sql_errno(),
8929+
thd->get_stmt_da()->push_warning(thd, thd->get_stmt_da()->sql_errno(),
89358930
thd->get_stmt_da()->get_sqlstate(),
89368931
Sql_condition::WARN_LEVEL_ERROR,
89378932
thd->get_stmt_da()->message());

storage/heap/ha_heap.cc

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,8 @@
2626
#include "ha_heap.h"
2727
#include "sql_base.h" // enum_tdc_remove_table_type
2828

29-
static handler *heap_create_handler(handlerton *hton,
30-
TABLE_SHARE *table,
31-
MEM_ROOT *mem_root);
32-
static int
33-
heap_prepare_hp_create_info(TABLE *table_arg, bool internal_table,
34-
HP_CREATE_INFO *hp_create_info);
29+
static handler *heap_create_handler(handlerton *, TABLE_SHARE *, MEM_ROOT *);
30+
static int heap_prepare_hp_create_info(TABLE *, bool, HP_CREATE_INFO *);
3531

3632

3733
int heap_panic(handlerton *hton, ha_panic_function flag)
@@ -603,28 +599,27 @@ ha_rows ha_heap::records_in_range(uint inx, key_range *min_key,
603599
}
604600

605601

606-
static int
607-
heap_prepare_hp_create_info(TABLE *table_arg, bool internal_table,
608-
HP_CREATE_INFO *hp_create_info)
602+
static int heap_prepare_hp_create_info(TABLE *table_arg, bool internal_table,
603+
HP_CREATE_INFO *hp_create_info)
609604
{
610-
uint key, parts, mem_per_row= 0, keys= table_arg->s->keys;
605+
TABLE_SHARE *share= table_arg->s;
606+
uint key, parts, mem_per_row= 0, keys= share->keys;
611607
uint auto_key= 0, auto_key_type= 0;
612608
ha_rows max_rows;
613609
HP_KEYDEF *keydef;
614610
HA_KEYSEG *seg;
615-
TABLE_SHARE *share= table_arg->s;
616611
bool found_real_auto_increment= 0;
617612

618613
bzero(hp_create_info, sizeof(*hp_create_info));
619614

620615
for (key= parts= 0; key < keys; key++)
621616
parts+= table_arg->key_info[key].user_defined_key_parts;
622617

623-
if (!(keydef= (HP_KEYDEF*) my_malloc(keys * sizeof(HP_KEYDEF) +
624-
parts * sizeof(HA_KEYSEG),
625-
MYF(MY_WME | MY_THREAD_SPECIFIC))))
618+
if (!my_multi_malloc(MYF(MY_WME | MY_THREAD_SPECIFIC),
619+
&keydef, keys * sizeof(HP_KEYDEF),
620+
&seg, parts * sizeof(HA_KEYSEG),
621+
NULL))
626622
return my_errno;
627-
seg= reinterpret_cast<HA_KEYSEG*>(keydef + keys);
628623
for (key= 0; key < keys; key++)
629624
{
630625
KEY *pos= table_arg->key_info+key;

0 commit comments

Comments
 (0)