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

Function check_quick_select

sql/opt_range.cc:12430–12571  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12428*/
12429
12430static
12431ha_rows check_quick_select(PARAM *param, uint idx, ha_rows limit,
12432 bool index_only,
12433 SEL_ARG *tree, bool update_tbl_stats,
12434 uint *mrr_flags, uint *bufsize, Cost_estimate *cost,
12435 bool *is_ror_scan)
12436{
12437 SEL_ARG_RANGE_SEQ seq;
12438 RANGE_SEQ_IF seq_if=
12439 {NULL, sel_arg_range_seq_init, sel_arg_range_seq_next, 0, 0};
12440 handler *file= param->table->file;
12441 ha_rows rows= HA_POS_ERROR;
12442 uint keynr= param->real_keynr[idx];
12443 DBUG_ENTER("check_quick_select");
12444
12445 /* Range not calculated yet */
12446 param->quick_rows[keynr]= HA_POS_ERROR;
12447
12448 /* Handle cases when we don't have a valid non-empty list of range */
12449 if (!tree)
12450 DBUG_RETURN(HA_POS_ERROR);
12451 if (tree->type == SEL_ARG::IMPOSSIBLE)
12452 DBUG_RETURN(0L);
12453 if (tree->type != SEL_ARG::KEY_RANGE || tree->part != 0)
12454 DBUG_RETURN(HA_POS_ERROR);
12455
12456 seq.keyno= idx;
12457 seq.real_keyno= keynr;
12458 seq.key_parts= param->key[idx];
12459 seq.param= param;
12460 seq.start= tree;
12461
12462 param->range_count=0;
12463 param->max_key_parts=0;
12464
12465 seq.is_ror_scan= TRUE;
12466 if (param->table->key_info[keynr].index_flags & HA_KEY_SCAN_NOT_ROR)
12467 seq.is_ror_scan= FALSE;
12468
12469 *mrr_flags= param->force_default_mrr? HA_MRR_USE_DEFAULT_IMPL: 0;
12470 /*
12471 Pass HA_MRR_SORTED to see if MRR implementation can handle sorting.
12472 */
12473 *mrr_flags|= HA_MRR_NO_ASSOCIATION | HA_MRR_SORTED;
12474
12475 // TODO: param->max_key_parts holds 0 now, and not the #keyparts used.
12476 // Passing wrong second argument to index_flags() makes no difference for
12477 // most storage engines but might be an issue for MyRocks with certain
12478 // datatypes.
12479 // Note that HA_KEYREAD_ONLY implies that this is not a clustered index
12480 if (index_only &&
12481 (file->index_flags(keynr, param->max_key_parts, 1) & HA_KEYREAD_ONLY))
12482 *mrr_flags |= HA_MRR_INDEX_ONLY;
12483
12484 if (param->thd->lex->sql_command != SQLCOM_SELECT)
12485 *mrr_flags |= HA_MRR_USE_DEFAULT_IMPL;
12486
12487 *bufsize= param->thd->variables.mrr_buff_size;

Callers 1

get_key_scans_paramsFunction · 0.85

Calls 10

stat_recordsMethod · 0.80
is_clustering_keyMethod · 0.80
index_flagsMethod · 0.45
set_bitMethod · 0.45
index_blocksMethod · 0.45
row_blocksMethod · 0.45

Tested by

no test coverage detected