MCPcopy Create free account
hub / github.com/MariaDB/server / add_fields

Method add_fields

sql/sql_select.cc:22214–22434  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22212
22213
22214bool Create_tmp_table::add_fields(THD *thd,
22215 TABLE *table,
22216 TMP_TABLE_PARAM *param,
22217 List<Item> &fields)
22218{
22219 DBUG_ENTER("Create_tmp_table::add_fields");
22220 DBUG_ASSERT(table);
22221 DBUG_ASSERT(table->field);
22222 DBUG_ASSERT(table->s->blob_field);
22223 DBUG_ASSERT(table->s->reclength == 0);
22224 DBUG_ASSERT(table->s->fields == 0);
22225 DBUG_ASSERT(table->s->blob_fields == 0);
22226
22227 const bool not_all_columns= !(m_select_options & TMP_TABLE_ALL_COLUMNS);
22228 bool distinct_record_structure= m_distinct;
22229 uint fieldnr= 0;
22230 TABLE_SHARE *share= table->s;
22231 Item **copy_func= param->items_to_copy;
22232
22233 MEM_ROOT *mem_root_save= thd->mem_root;
22234 thd->mem_root= &table->mem_root;
22235
22236 List_iterator_fast<Item> li(fields);
22237 Item *item;
22238 Field **tmp_from_field= m_from_field;
22239 while (!m_with_cycle && (item= li++))
22240 if (item->is_in_with_cycle())
22241 {
22242 m_with_cycle= true;
22243 /*
22244 Following distinct_record_structure is (m_distinct || m_with_cycle)
22245
22246 Note: distinct_record_structure can be true even if m_distinct is
22247 false, for example for incr_table in recursive CTE
22248 (see select_union_recursive::create_result_table)
22249 */
22250 distinct_record_structure= true;
22251 }
22252 li.rewind();
22253 while ((item=li++))
22254 {
22255 uint uneven_delta;
22256 current_counter= (((param->hidden_field_count < (fieldnr + 1)) &&
22257 distinct_record_structure &&
22258 (!m_with_cycle || item->is_in_with_cycle())) ?
22259 distinct :
22260 other);
22261 Item::Type type= item->type();
22262 if (type == Item::COPY_STR_ITEM)
22263 {
22264 item= ((Item_copy *)item)->get_item();
22265 type= item->type();
22266 }
22267 if (not_all_columns)
22268 {
22269 if (item->with_sum_func() && type != Item::SUM_FUNC_ITEM)
22270 {
22271 if (item->used_tables() & OUTER_REF_TABLE_BIT)

Callers 1

create_tmp_tableFunction · 0.80

Calls 15

create_tmp_fieldFunction · 0.85
add_fieldFunction · 0.85
is_in_with_cycleMethod · 0.80
with_sum_funcMethod · 0.80
get_arg_countMethod · 0.80
set_argMethod · 0.80
set_maybe_nullMethod · 0.80
rewindMethod · 0.45
typeMethod · 0.45
get_itemMethod · 0.45
used_tablesMethod · 0.45

Tested by

no test coverage detected