872
866
these items are stored in the temporary table.
874
868
if (param->precomputed_group_by)
875
870
copy_func_count+= param->sum_func_count;
877
if (!multi_alloc_root(&own_root,
878
&table, sizeof(*table),
879
®_field, sizeof(Field*) * (field_count+1),
880
&default_field, sizeof(Field*) * (field_count),
881
&blob_field, sizeof(uint32_t)*(field_count+1),
882
&from_field, sizeof(Field*)*field_count,
883
©_func, sizeof(*copy_func)*(copy_func_count+1),
884
¶m->keyinfo, sizeof(*param->keyinfo),
886
sizeof(*key_part_info)*(param->group_parts+1),
887
¶m->start_recinfo,
888
sizeof(*param->recinfo)*(field_count*2+4),
889
&tmpname, (uint32_t) strlen(path)+1,
890
&group_buff, (group && ! using_unique_constraint ?
891
param->group_length : 0),
892
&bitmaps, bitmap_buffer_size(field_count)*2,
873
memory::Root own_root(TABLE_ALLOC_BLOCK_SIZE);
875
if (not own_root.multi_alloc_root(0, &tmpname, (uint32_t) strlen(path)+1, NULL))
880
strcpy(tmpname, path);
882
TableShareInstance *share= session->getTemporaryShare(tmpname); // This will not go into the tableshare cache, so no key is used.
884
if (not share->getMemRoot()->multi_alloc_root(0, ®_field, sizeof(Field*) * (field_count+1),
885
&default_field, sizeof(Field*) * (field_count),
886
&blob_field, sizeof(uint32_t)*(field_count+1),
887
&from_field, sizeof(Field*)*field_count,
888
©_func, sizeof(*copy_func)*(copy_func_count+1),
889
¶m->keyinfo, sizeof(*param->keyinfo),
890
&key_part_info, sizeof(*key_part_info)*(param->group_parts+1),
891
¶m->start_recinfo, sizeof(*param->recinfo)*(field_count*2+4),
892
&group_buff, (group && ! using_unique_constraint ?
893
param->group_length : 0),
894
&bitmaps, bitmap_buffer_size(field_count)*2,
897
899
/* CopyField belongs to Tmp_Table_Param, allocate it in Session mem_root */
898
900
if (!(param->copy_field= copy= new (session->mem_root) CopyField[field_count]))
900
own_root.free_root(MYF(0));
903
904
param->items_to_copy= copy_func;
904
strcpy(tmpname,path);
905
905
/* make table according to fields */
907
memset(table, 0, sizeof(*table));
907
table= share->getTable();
908
909
memset(reg_field, 0, sizeof(Field*)*(field_count+1));
909
910
memset(default_field, 0, sizeof(Field*) * (field_count));
910
911
memset(from_field, 0, sizeof(Field*)*field_count);
912
share= &table->_table_share;
914
913
table->mem_root= own_root;
915
914
mem_root_save= session->mem_root;
916
915
session->mem_root= &table->mem_root;
1480
1478
uint32_t null_pack_length; /* NULL representation array length */
1481
1479
uint32_t *blob_field;
1482
1480
unsigned char *bitmaps;
1483
TableInstance *table;
1486
if (!multi_alloc_root(session->mem_root,
1487
&table, sizeof(*table),
1488
&field, (field_count + 1) * sizeof(Field*),
1489
&blob_field, (field_count+1) *sizeof(uint32_t),
1490
&bitmaps, bitmap_buffer_size(field_count)*2,
1483
TableShareInstance *share= getTemporaryShare(); // This will not go into the tableshare cache, so no key is used.
1485
if (! share->getMemRoot()->multi_alloc_root(0, &field, (field_count + 1) * sizeof(Field*),
1486
&blob_field, (field_count+1) *sizeof(uint32_t),
1487
&bitmaps, bitmap_buffer_size(field_count)*2,
1494
memset(table, 0, sizeof(*table));
1495
share= &table->_table_share;
1493
table= share->getTable();
1496
1494
table->field= field;
1498
1495
share->blob_field= blob_field;
1499
1496
share->fields= field_count;
1500
1497
share->blob_ptr_size= portable_sizeof_char_ptr;
1888
1886
memset(null_flags, 255, s->null_bytes);
1902
insert_values(NULL),
1904
next_number_field(NULL),
1905
found_next_number_field(NULL),
1906
timestamp_field(NULL),
1907
pos_in_table_list(NULL),
1916
derived_select_number(0),
1917
current_lock(F_UNLCK),
1927
open_placeholder(false),
1928
locked_by_name(false),
1930
auto_increment_field_not_null(false),
1931
alias_name_used(false),
1933
quick_condition_rows(0),
1934
timestamp_field_type(TIMESTAMP_NO_AUTO_SET),
1900
insert_values(NULL),
1902
next_number_field(NULL),
1903
found_next_number_field(NULL),
1904
timestamp_field(NULL),
1905
pos_in_table_list(NULL),
1914
derived_select_number(0),
1915
current_lock(F_UNLCK),
1925
open_placeholder(false),
1926
locked_by_name(false),
1928
auto_increment_field_not_null(false),
1929
alias_name_used(false),
1931
quick_condition_rows(0),
1932
timestamp_field_type(TIMESTAMP_NO_AUTO_SET),
1935
memset(&def_read_set, 0, sizeof(MyBitmap)); /**< Default read set of columns */
1936
memset(&def_write_set, 0, sizeof(MyBitmap)); /**< Default write set of columns */
1937
memset(&tmp_set, 0, sizeof(MyBitmap)); /* Not sure about this... */
1937
1939
record[0]= (unsigned char *) 0;
1938
1940
record[1]= (unsigned char *) 0;
1940
1943
covering_keys.reset();
1942
1944
quick_keys.reset();
1943
1945
merge_keys.reset();