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

Method init

sql/sql_expression_cache.cc:95–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93*/
94
95void Expression_cache_tmptable::init()
96{
97 List_iterator<Item> li(items);
98 Item_iterator_list it(li);
99 uint field_counter;
100 LEX_CSTRING cache_table_name= { STRING_WITH_LEN("subquery-cache-table") };
101 DBUG_ENTER("Expression_cache_tmptable::init");
102 DBUG_ASSERT(!inited);
103 inited= TRUE;
104 cache_table= NULL;
105
106 if (items.elements == 0)
107 {
108 DBUG_PRINT("info", ("All parameters were removed by optimizer."));
109 DBUG_VOID_RETURN;
110 }
111
112 /* add result field */
113 items.push_front(val);
114
115 cache_table_param.init();
116 /* dependent items and result */
117 cache_table_param.field_count= cache_table_param.func_count= items.elements;
118 /* postpone table creation to index description */
119 cache_table_param.skip_create_table= 1;
120
121 if (!(cache_table= create_tmp_table(table_thd, &cache_table_param,
122 items, (ORDER*) NULL,
123 FALSE, TRUE,
124 ((table_thd->variables.option_bits |
125 TMP_TABLE_ALL_COLUMNS) &
126 ~TMP_TABLE_FORCE_MYISAM),
127 HA_POS_ERROR,
128 &cache_table_name,
129 TRUE)))
130 {
131 DBUG_PRINT("error", ("create_tmp_table failed, caching switched off"));
132 DBUG_VOID_RETURN;
133 }
134
135 if (cache_table->s->db_type() != heap_hton)
136 {
137 DBUG_PRINT("error", ("we need only heap table"));
138 goto error;
139 }
140
141 field_counter= 1;
142
143 if (cache_table->alloc_keys(1) ||
144 cache_table->add_tmp_key(0, items.elements - 1, &field_enumerator,
145 (uchar*)&field_counter, TRUE) ||
146 ref.tmp_table_index_lookup_init(table_thd, cache_table->key_info, it,
147 TRUE, 1 /* skip result field*/))
148 {
149 DBUG_PRINT("error", ("creating index failed"));
150 goto error;
151 }
152 cache_table->s->keys= 1;

Callers

nothing calls this directly

Calls 7

create_tmp_tableFunction · 0.85
open_tmp_tableFunction · 0.85
db_typeMethod · 0.80
alloc_keysMethod · 0.80
add_tmp_keyMethod · 0.80
push_frontMethod · 0.45

Tested by

no test coverage detected