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

Method put_value

sql/sql_expression_cache.cc:262–325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

260*/
261
262my_bool Expression_cache_tmptable::put_value(Item *value)
263{
264 int error;
265 DBUG_ENTER("Expression_cache_tmptable::put_value");
266 DBUG_ASSERT(inited);
267
268 if (!cache_table)
269 {
270 DBUG_PRINT("info", ("No table so behave as we successfully put value"));
271 DBUG_RETURN(FALSE);
272 }
273
274 *(items.head_ref())= value;
275 fill_record(table_thd, cache_table, cache_table->field, items, true, true,
276 true);
277 if (unlikely(table_thd->is_error()))
278 goto err2;
279
280 if (unlikely((error=
281 cache_table->file->ha_write_tmp_row(cache_table->record[0]))))
282 {
283 /* create_myisam_from_heap will generate error if needed */
284 if (cache_table->file->is_fatal_error(error, HA_CHECK_DUP) &&
285 error != HA_ERR_RECORD_FILE_FULL)
286 goto err;
287 else
288 {
289 double hit_rate= ((double)hit / ((double)hit + miss));
290 DBUG_ASSERT(miss > 0);
291 if (hit_rate < EXPCACHE_MIN_HIT_RATE_FOR_MEM_TABLE)
292 {
293 DBUG_PRINT("info", ("hit rate is not so good to keep the cache"));
294 disable_cache();
295 DBUG_RETURN(FALSE);
296 }
297 else if (hit_rate < EXPCACHE_MIN_HIT_RATE_FOR_DISK_TABLE)
298 {
299 DBUG_PRINT("info", ("hit rate is not so good to go to disk"));
300 if (cache_table->file->ha_delete_all_rows() ||
301 cache_table->file->ha_write_tmp_row(cache_table->record[0]))
302 goto err;
303 }
304 else
305 {
306 if (create_internal_tmp_table_from_heap(table_thd, cache_table,
307 cache_table_param.start_recinfo,
308 &cache_table_param.recinfo,
309 error, 1, NULL))
310 goto err2;
311 }
312 }
313 }
314 cache_table->status= 0; /* cache_table->record contains an existed record */
315 ref.has_record= TRUE; /* the same as above */
316 DBUG_PRINT("info", ("has_record: TRUE status: 0"));
317
318 DBUG_RETURN(FALSE);
319

Callers 1

cacheMethod · 0.80

Calls 7

fill_recordFunction · 0.85
ha_delete_all_rowsMethod · 0.80
head_refMethod · 0.45
is_errorMethod · 0.45
is_fatal_errorMethod · 0.45
print_errorMethod · 0.45

Tested by

no test coverage detected