~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/hp_rlast.c

Merged vcol stuff.

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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
 
 
16
 
#include "heap_priv.h"
17
 
 
18
 
#include <string.h>
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
#include "heapdef.h"
19
17
 
20
18
        /* Read first record with the current key */
21
19
 
22
 
using namespace drizzled;
23
20
 
24
21
int heap_rlast(HP_INFO *info, unsigned char *record, int inx)
25
22
{
 
23
  HP_SHARE *share=    info->s;
 
24
  HP_KEYDEF *keyinfo= share->keydef + inx;
 
25
 
26
26
  info->lastinx= inx;
 
27
  if (keyinfo->algorithm == HA_KEY_ALG_BTREE)
 
28
  {
 
29
    unsigned char *pos;
 
30
 
 
31
    if ((pos = tree_search_edge(&keyinfo->rb_tree, info->parents,
 
32
                                &info->last_pos, offsetof(TREE_ELEMENT, right))))
 
33
    {
 
34
      memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos), 
 
35
             sizeof(unsigned char*));
 
36
      info->current_ptr = pos;
 
37
      hp_extract_record(share, record, pos);
 
38
      info->update = HA_STATE_AKTIV;
 
39
    }
 
40
    else
 
41
    {
 
42
      my_errno = HA_ERR_END_OF_FILE;
 
43
      return(my_errno);
 
44
    }
 
45
    return(0);
 
46
  }
 
47
  else
27
48
  {
28
49
    info->current_ptr=0;
29
50
    info->current_hash_ptr=0;