~mysql/mysql-server/mysql-6.0

« back to all changes in this revision

Viewing changes to heap/hp_rnext.c

Merge with 4.0.3
Some simple optimzations, more comments and indentation changes.
Add ` around database in 'use database' in binary log.
Moved max_error_count and max_warning_count to variables struct.
Removed SHOW_WARNS_COUNT and SHOW_ERRORS_COUNT calls.
Changed string functions to use character set of first string argument as default return characterset
(Each string function can change the above assumption if needed)

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
{
23
23
  byte *pos;
24
24
  HP_SHARE *share=info->s;
 
25
  HP_KEYDEF *keyinfo;
25
26
  DBUG_ENTER("heap_rnext");
26
27
  
27
28
  if (info->lastinx < 0)
28
29
    DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX);
29
30
 
30
 
  if (info->current_hash_ptr)
31
 
    pos= _hp_search_next(info,share->keydef+info->lastinx, info->lastkey,
32
 
                         info->current_hash_ptr);
 
31
  keyinfo = share->keydef + info->lastinx;
 
32
  if (keyinfo->algorithm == HA_KEY_ALG_BTREE)
 
33
  {
 
34
    heap_rb_param custom_arg;
 
35
 
 
36
    if (info->last_pos)
 
37
      pos = tree_search_next(&keyinfo->rb_tree, &info->last_pos,
 
38
                             offsetof(TREE_ELEMENT, left),
 
39
                             offsetof(TREE_ELEMENT, right));
 
40
    else
 
41
    {
 
42
      custom_arg.keyseg = keyinfo->seg;
 
43
      custom_arg.key_length = info->lastkey_len;
 
44
      custom_arg.search_flag = SEARCH_SAME | SEARCH_FIND;
 
45
      pos = tree_search_key(&keyinfo->rb_tree, info->lastkey, info->parents, 
 
46
                           &info->last_pos, info->last_find_flag, &custom_arg);
 
47
    }
 
48
    if (pos)
 
49
    {
 
50
      memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos), 
 
51
             sizeof(byte*));
 
52
      info->current_ptr = pos;
 
53
    }
 
54
    else
 
55
    {
 
56
      my_errno = HA_ERR_KEY_NOT_FOUND;
 
57
    }
 
58
  }
33
59
  else
34
60
  {
35
 
    if (!info->current_ptr && (info->update & HA_STATE_NEXT_FOUND))
 
61
    if (info->current_hash_ptr)
 
62
      pos= hp_search_next(info, keyinfo, info->lastkey,
 
63
                           info->current_hash_ptr);
 
64
    else
36
65
    {
37
 
      pos=0;                                    /* Read next after last */
38
 
      my_errno=HA_ERR_KEY_NOT_FOUND;
 
66
      if (!info->current_ptr && (info->update & HA_STATE_NEXT_FOUND))
 
67
      {
 
68
        pos=0;                                  /* Read next after last */
 
69
        my_errno=HA_ERR_KEY_NOT_FOUND;
 
70
      }
 
71
      else if (!info->current_ptr)              /* Deleted or first call */
 
72
        pos= hp_search(info, keyinfo, info->lastkey, 0);
 
73
      else
 
74
        pos= hp_search(info, keyinfo, info->lastkey, 1);
39
75
    }
40
 
    else if (!info->current_ptr)                /* Deleted or first call */
41
 
      pos= _hp_search(info,share->keydef+info->lastinx, info->lastkey, 0);
42
 
    else
43
 
      pos= _hp_search(info,share->keydef+info->lastinx, info->lastkey, 1);
44
76
  }
45
 
 
46
77
  if (!pos)
47
78
  {
48
79
    info->update=HA_STATE_NEXT_FOUND;           /* For heap_rprev */