~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/mi_rprev.cc

  • Committer: Monty Taylor
  • Date: 2010-10-15 17:18:02 UTC
  • mto: (1859.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1860.
  • Revision ID: mordred@inaugust.com-20101015171802-qhk6zyfhrkvprr1n
Added support for registering regular sys_var instances via module::Context.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
15
 
16
 
#include "myisamdef.h"
 
16
#include "myisam_priv.h"
17
17
 
18
18
        /*
19
19
           Read previous row with the same key as previous read
22
22
           based on the position of the last used key!
23
23
        */
24
24
 
25
 
int mi_rprev(MI_INFO *info, uchar *buf, int inx)
 
25
int mi_rprev(MI_INFO *info, unsigned char *buf, int inx)
26
26
{
27
27
  int error,changed;
28
 
  register uint flag;
 
28
  register uint32_t flag;
29
29
  MYISAM_SHARE *share=info->s;
30
30
 
31
31
  if ((inx = _mi_check_index(info,inx)) < 0)
32
 
    return(my_errno);
 
32
    return(errno);
33
33
  flag=SEARCH_SMALLER;                          /* Read previous */
34
34
  if (info->lastpos == HA_OFFSET_ERROR && info->update & HA_STATE_NEXT_FOUND)
35
35
    flag=0;                                     /* Read last */
36
36
 
37
37
  if (fast_mi_readinfo(info))
38
 
    return(my_errno);
 
38
    return(errno);
39
39
  changed=_mi_test_if_changed(info);
40
 
  if (share->concurrent_insert)
41
 
    rw_rdlock(&share->key_root_lock[inx]);
42
40
  if (!flag)
43
41
    error=_mi_search_last(info, share->keyinfo+inx,
44
42
                          share->state.key_root[inx]);
64
62
          break;
65
63
      }
66
64
    }
67
 
    rw_unlock(&share->key_root_lock[inx]);
68
65
  }
69
66
  info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
70
67
  info->update|= HA_STATE_PREV_FOUND;
71
68
  if (error)
72
69
  {
73
 
    if (my_errno == HA_ERR_KEY_NOT_FOUND)
74
 
      my_errno=HA_ERR_END_OF_FILE;
 
70
    if (errno == HA_ERR_KEY_NOT_FOUND)
 
71
      errno=HA_ERR_END_OF_FILE;
75
72
  }
76
73
  else if (!buf)
77
74
  {
78
 
    return(info->lastpos==HA_OFFSET_ERROR ? my_errno : 0);
 
75
    return(info->lastpos==HA_OFFSET_ERROR ? errno : 0);
79
76
  }
80
77
  else if (!(*info->read_record)(info,info->lastpos,buf))
81
78
  {
82
79
    info->update|= HA_STATE_AKTIV;              /* Record is read */
83
80
    return(0);
84
81
  }
85
 
  return(my_errno);
 
82
  return(errno);
86
83
} /* mi_rprev */