eq_ref access handler but generalized a bit to support TABLE and TABLE_REF not from the join_tab. See join_read_key for detailed synopsis. */
| 25365 | not from the join_tab. See join_read_key for detailed synopsis. |
| 25366 | */ |
| 25367 | int join_read_key2(THD *thd, JOIN_TAB *tab, TABLE *table, TABLE_REF *table_ref) |
| 25368 | { |
| 25369 | int error; |
| 25370 | if (!table->file->inited) |
| 25371 | { |
| 25372 | error= table->file->ha_index_init(table_ref->key, tab ? tab->sorted : TRUE); |
| 25373 | if (unlikely(error)) |
| 25374 | { |
| 25375 | (void) report_error(table, error); |
| 25376 | return 1; |
| 25377 | } |
| 25378 | } |
| 25379 | |
| 25380 | /* |
| 25381 | The following is needed when one makes ref (or eq_ref) access from row |
| 25382 | comparisons: one must call row->bring_value() to get the new values. |
| 25383 | */ |
| 25384 | if (tab && tab->bush_children) |
| 25385 | { |
| 25386 | TABLE_LIST *emb_sj_nest= tab->bush_children->start->emb_sj_nest; |
| 25387 | emb_sj_nest->sj_subq_pred->left_exp()->bring_value(); |
| 25388 | } |
| 25389 | |
| 25390 | /* TODO: Why don't we do "Late NULLs Filtering" here? */ |
| 25391 | |
| 25392 | if (cmp_buffer_with_ref(thd, table, table_ref) || |
| 25393 | (table->status & (STATUS_GARBAGE | STATUS_NO_PARENT | STATUS_NULL_ROW))) |
| 25394 | { |
| 25395 | if (table_ref->key_err) |
| 25396 | { |
| 25397 | table->status=STATUS_NOT_FOUND; |
| 25398 | return -1; |
| 25399 | } |
| 25400 | /* |
| 25401 | Moving away from the current record. Unlock the row |
| 25402 | in the handler if it did not match the partial WHERE. |
| 25403 | */ |
| 25404 | if (tab && tab->ref.has_record && tab->ref.use_count == 0) |
| 25405 | { |
| 25406 | tab->read_record.table->file->unlock_row(); |
| 25407 | table_ref->has_record= FALSE; |
| 25408 | } |
| 25409 | error=table->file->ha_index_read_map(table->record[0], |
| 25410 | table_ref->key_buff, |
| 25411 | make_prev_keypart_map(table_ref->key_parts), |
| 25412 | HA_READ_KEY_EXACT); |
| 25413 | if (unlikely(error) && |
| 25414 | error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE) |
| 25415 | return report_error(table, error); |
| 25416 | |
| 25417 | if (likely(!error)) |
| 25418 | { |
| 25419 | table_ref->has_record= TRUE; |
| 25420 | table_ref->use_count= 1; |
| 25421 | } |
| 25422 | } |
| 25423 | else if (table->status == 0) |
| 25424 | { |
no test coverage detected