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

Function test_if_subkey

sql/sql_select.cc:27369–27399  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27367*/
27368
27369static uint
27370test_if_subkey(ORDER *order, TABLE *table, uint ref, uint ref_key_parts,
27371 const key_map *usable_keys)
27372{
27373 uint nr;
27374 uint min_length= (uint) ~0;
27375 uint best= MAX_KEY;
27376 KEY_PART_INFO *ref_key_part= table->key_info[ref].key_part;
27377 KEY_PART_INFO *ref_key_part_end= ref_key_part + ref_key_parts;
27378
27379 /*
27380 Find the shortest key that
27381 - produces the required ordering
27382 - has key #ref (up to ref_key_parts) as its subkey.
27383 */
27384 for (nr= 0 ; nr < table->s->keys ; nr++)
27385 {
27386 uint not_used;
27387 if (usable_keys->is_set(nr) &&
27388 table->key_info[nr].key_length < min_length &&
27389 table->key_info[nr].user_defined_key_parts >= ref_key_parts &&
27390 is_subkey(table->key_info[nr].key_part, ref_key_part,
27391 ref_key_part_end) &&
27392 test_if_order_by_key(NULL, order, table, nr, &not_used))
27393 {
27394 min_length= table->key_info[nr].key_length;
27395 best= nr;
27396 }
27397 }
27398 return best;
27399}
27400
27401
27402/**

Callers 1

test_if_skip_sort_orderFunction · 0.85

Calls 3

is_subkeyFunction · 0.85
test_if_order_by_keyFunction · 0.85
is_setMethod · 0.45

Tested by

no test coverage detected