| 24442 | */ |
| 24443 | |
| 24444 | enum_nested_loop_state |
| 24445 | sub_select_cache(JOIN *join, JOIN_TAB *join_tab, bool end_of_records) |
| 24446 | { |
| 24447 | enum_nested_loop_state rc; |
| 24448 | JOIN_CACHE *cache= join_tab->cache; |
| 24449 | int err; |
| 24450 | DBUG_ENTER("sub_select_cache"); |
| 24451 | |
| 24452 | /* |
| 24453 | This function cannot be called if join_tab has no associated join |
| 24454 | buffer |
| 24455 | */ |
| 24456 | DBUG_ASSERT(cache != NULL); |
| 24457 | |
| 24458 | join_tab->cache->reset_join(join); |
| 24459 | |
| 24460 | if (end_of_records) |
| 24461 | { |
| 24462 | rc= cache->join_records(FALSE); |
| 24463 | if (rc == NESTED_LOOP_OK || rc == NESTED_LOOP_NO_MORE_ROWS || |
| 24464 | rc == NESTED_LOOP_QUERY_LIMIT) |
| 24465 | rc= sub_select(join, join_tab, end_of_records); |
| 24466 | DBUG_RETURN(rc); |
| 24467 | } |
| 24468 | if (unlikely(join->thd->check_killed())) |
| 24469 | { |
| 24470 | /* The user has aborted the execution of the query */ |
| 24471 | DBUG_RETURN(NESTED_LOOP_KILLED); |
| 24472 | } |
| 24473 | join_tab->jbuf_loops_tracker->on_scan_init(); |
| 24474 | |
| 24475 | if (!(err= test_if_use_dynamic_range_scan(join_tab))) |
| 24476 | { |
| 24477 | if (!cache->put_record()) |
| 24478 | DBUG_RETURN(NESTED_LOOP_OK); |
| 24479 | /* |
| 24480 | We has decided that after the record we've just put into the buffer |
| 24481 | won't add any more records. Now try to find all the matching |
| 24482 | extensions for all records in the buffer. |
| 24483 | */ |
| 24484 | rc= cache->join_records(FALSE); |
| 24485 | DBUG_RETURN(rc); |
| 24486 | } |
| 24487 | |
| 24488 | if (err < 0) |
| 24489 | DBUG_RETURN(NESTED_LOOP_ERROR); |
| 24490 | |
| 24491 | /* |
| 24492 | TODO: Check whether we really need the call below and we can't do |
| 24493 | without it. If it's not the case remove it. |
| 24494 | */ |
| 24495 | rc= cache->join_records(TRUE); |
| 24496 | if (rc == NESTED_LOOP_OK || rc == NESTED_LOOP_NO_MORE_ROWS || |
| 24497 | rc == NESTED_LOOP_QUERY_LIMIT) |
| 24498 | rc= sub_select(join, join_tab, end_of_records); |
| 24499 | DBUG_RETURN(rc); |
| 24500 | } |
| 24501 |
nothing calls this directly
no test coverage detected