| 27104 | */ |
| 27105 | |
| 27106 | static Item * |
| 27107 | part_of_refkey(TABLE *table,Field *field) |
| 27108 | { |
| 27109 | JOIN_TAB *join_tab= table->reginfo.join_tab; |
| 27110 | if (!join_tab) |
| 27111 | return (Item*) 0; // field from outer non-select (UPDATE,...) |
| 27112 | |
| 27113 | uint ref_parts= join_tab->ref.key_parts; |
| 27114 | if (ref_parts) /* if it's ref/eq_ref/ref_or_null */ |
| 27115 | { |
| 27116 | uint key= join_tab->ref.key; |
| 27117 | KEY *key_info= join_tab->get_keyinfo_by_key_no(key); |
| 27118 | KEY_PART_INFO *key_part= key_info->key_part; |
| 27119 | |
| 27120 | for (uint part=0 ; part < ref_parts ; part++,key_part++) |
| 27121 | { |
| 27122 | if (field->eq(key_part->field)) |
| 27123 | { |
| 27124 | /* |
| 27125 | Found the field in the key. Check that |
| 27126 | 1. ref_or_null doesn't alternate this component between a value and |
| 27127 | a NULL |
| 27128 | 2. index fully covers the key |
| 27129 | */ |
| 27130 | if (part != join_tab->ref.null_ref_part && // (1) |
| 27131 | !(key_part->key_part_flag & HA_PART_KEY_SEG)) // (2) |
| 27132 | { |
| 27133 | return join_tab->ref.items[part]; |
| 27134 | } |
| 27135 | break; |
| 27136 | } |
| 27137 | } |
| 27138 | } |
| 27139 | return (Item*) 0; |
| 27140 | } |
| 27141 | |
| 27142 | |
| 27143 | /** |