| 25524 | */ |
| 25525 | |
| 25526 | static int |
| 25527 | join_read_last_key(JOIN_TAB *tab) |
| 25528 | { |
| 25529 | int error; |
| 25530 | TABLE *table= tab->table; |
| 25531 | |
| 25532 | if (!table->file->inited && |
| 25533 | unlikely((error= table->file->ha_index_init(tab->ref.key, tab->sorted)))) |
| 25534 | { |
| 25535 | (void) report_error(table, error); |
| 25536 | return 1; |
| 25537 | } |
| 25538 | |
| 25539 | if (unlikely(cp_buffer_from_ref(tab->join->thd, table, &tab->ref))) |
| 25540 | return -1; |
| 25541 | if (unlikely((error= |
| 25542 | table->file->prepare_index_key_scan_map(tab->ref.key_buff, |
| 25543 | make_prev_keypart_map(tab->ref.key_parts)))) ) |
| 25544 | { |
| 25545 | report_error(table,error); |
| 25546 | return -1; |
| 25547 | } |
| 25548 | |
| 25549 | /* |
| 25550 | Tell the storage engine what the range endpoint is so that it can stop |
| 25551 | scanning once it has hit that point. |
| 25552 | */ |
| 25553 | key_range range_endpoint |
| 25554 | { |
| 25555 | tab->ref.key_buff, |
| 25556 | tab->ref.key_length, |
| 25557 | make_prev_keypart_map(tab->ref.key_parts), |
| 25558 | HA_READ_PREFIX_LAST |
| 25559 | }; |
| 25560 | table->file->set_end_range(&range_endpoint, handler::RANGE_SCAN_DESC); |
| 25561 | |
| 25562 | if (unlikely((error= |
| 25563 | table->file->ha_index_read_map(table->record[0], |
| 25564 | tab->ref.key_buff, |
| 25565 | make_prev_keypart_map(tab->ref.key_parts), |
| 25566 | HA_READ_PREFIX_LAST)))) |
| 25567 | { |
| 25568 | if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE) |
| 25569 | return report_error(table, error); |
| 25570 | return -1; /* purecov: inspected */ |
| 25571 | } |
| 25572 | return 0; |
| 25573 | } |
| 25574 | |
| 25575 | |
| 25576 | /* ARGSUSED */ |
nothing calls this directly
no test coverage detected