| 22051 | */ |
| 22052 | |
| 22053 | TABLE *Create_tmp_table::start(THD *thd, |
| 22054 | TMP_TABLE_PARAM *param, |
| 22055 | const LEX_CSTRING *table_alias) |
| 22056 | { |
| 22057 | MEM_ROOT *mem_root_save, own_root; |
| 22058 | TABLE *table; |
| 22059 | TABLE_SHARE *share; |
| 22060 | uint copy_func_count= param->func_count; |
| 22061 | char *tmpname,path[FN_REFLEN]; |
| 22062 | Field **reg_field; |
| 22063 | uint *blob_field; |
| 22064 | key_part_map *const_key_parts; |
| 22065 | /* Treat sum functions as normal ones when loose index scan is used. */ |
| 22066 | m_save_sum_fields|= param->precomputed_group_by; |
| 22067 | DBUG_ENTER("Create_tmp_table::start"); |
| 22068 | DBUG_PRINT("enter", |
| 22069 | ("table_alias: '%s' distinct: %d save_sum_fields: %d " |
| 22070 | "rows_limit: %lu group: %d", table_alias->str, |
| 22071 | (int) m_distinct, (int) m_save_sum_fields, |
| 22072 | (ulong) m_rows_limit, MY_TEST(m_group))); |
| 22073 | |
| 22074 | if (use_temp_pool && !(test_flags & TEST_KEEP_TMP_TABLES)) |
| 22075 | m_temp_pool_slot = temp_pool_set_next(); |
| 22076 | |
| 22077 | if (m_temp_pool_slot != MY_BIT_NONE) // we got a slot |
| 22078 | snprintf(path, sizeof(path), "%s-%s-%lx-%i", tmp_file_prefix, param->tmp_name, |
| 22079 | current_pid, m_temp_pool_slot); |
| 22080 | else |
| 22081 | { |
| 22082 | /* if we run out of slots or we are not using tempool */ |
| 22083 | LEX_STRING tmp= {path, sizeof(path) }; |
| 22084 | make_tmp_table_name(thd, &tmp, param->tmp_name); |
| 22085 | } |
| 22086 | |
| 22087 | /* |
| 22088 | No need to change table name to lower case as we are only creating |
| 22089 | MyISAM, Aria or HEAP tables here |
| 22090 | */ |
| 22091 | fn_format(path, path, mysql_tmpdir, "", MY_REPLACE_EXT|MY_UNPACK_FILENAME); |
| 22092 | |
| 22093 | if (m_group) |
| 22094 | { |
| 22095 | ORDER **prev= &m_group; |
| 22096 | if (!param->quick_group) |
| 22097 | m_group= 0; // Can't use group key |
| 22098 | else for (ORDER *tmp= m_group ; tmp ; tmp= tmp->next) |
| 22099 | { |
| 22100 | /* Exclude found constant from the list */ |
| 22101 | if ((*tmp->item)->const_item()) |
| 22102 | { |
| 22103 | *prev= tmp->next; |
| 22104 | param->group_parts--; |
| 22105 | continue; |
| 22106 | } |
| 22107 | else |
| 22108 | prev= &(tmp->next); |
| 22109 | /* |
| 22110 | marker == 4 means two things: |
no test coverage detected