12
12
You should have received a copy of the GNU General Public License
13
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
16
#include "heap_priv.h"
25
25
int heap_rprev(HP_INFO *info, unsigned char *record)
27
27
unsigned char *pos;
28
HP_SHARE *share=info->getShare();
28
HP_SHARE *share=info->s;
29
29
HP_KEYDEF *keyinfo;
31
31
if (info->lastinx < 0)
32
32
return(errno=HA_ERR_WRONG_INDEX);
33
33
keyinfo = share->keydef + info->lastinx;
34
if (keyinfo->algorithm == HA_KEY_ALG_BTREE)
36
heap_rb_param custom_arg;
39
pos = (unsigned char *)tree_search_next(&keyinfo->rb_tree,
41
offsetof(TREE_ELEMENT, right),
42
offsetof(TREE_ELEMENT, left));
45
custom_arg.keyseg = keyinfo->seg;
46
custom_arg.key_length = keyinfo->length;
47
custom_arg.search_flag = SEARCH_SAME;
48
pos = (unsigned char *)tree_search_key(&keyinfo->rb_tree,
49
info->lastkey, info->parents,
56
memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos),
57
sizeof(unsigned char*));
58
info->current_ptr = pos;
62
errno = HA_ERR_KEY_NOT_FOUND;
35
67
if (info->current_ptr || (info->update & HA_STATE_NEXT_FOUND))
37
69
if ((info->update & HA_STATE_DELETED))
38
pos= hp_search(info, share->keydef + info->lastinx, &info->lastkey[0], 3);
70
pos= hp_search(info, share->keydef + info->lastinx, info->lastkey, 3);
40
pos= hp_search(info, share->keydef + info->lastinx, &info->lastkey[0], 2);
72
pos= hp_search(info, share->keydef + info->lastinx, info->lastkey, 2);