~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/heap/hp_update.cc

  • Committer: Brian Aker
  • Date: 2010-01-22 00:53:13 UTC
  • Revision ID: brian@gaz-20100122005313-jmizcbcdi1lt4tcx
Revert db patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
/* Update current record in heap-database */
17
17
 
18
 
#include "heapdef.h"
 
18
#include "heap_priv.h"
19
19
 
20
 
int heap_update(HP_INFO *info, const uchar *old_record, const uchar *new_record)
 
20
int heap_update(HP_INFO *info, const unsigned char *old_record, const unsigned char *new_record)
21
21
{
22
22
  HP_KEYDEF *keydef, *end, *p_lastinx;
23
 
  uchar *pos;
 
23
  unsigned char *pos;
24
24
  bool auto_key_changed= 0;
25
25
  HP_SHARE *share= info->s;
26
 
  uint old_length, new_length;
27
 
  uint old_chunk_count, new_chunk_count;
 
26
  uint32_t old_length, new_length;
 
27
  uint32_t old_chunk_count, new_chunk_count;
28
28
 
29
29
  test_active(info);
30
30
  pos=info->current_ptr;
31
31
 
32
32
  if (info->opt_flag & READ_CHECK_USED && hp_rectest(info,old_record))
33
 
    return(my_errno);                           /* Record changed */
 
33
    return(errno);                              /* Record changed */
34
34
 
35
35
  old_length = hp_get_encoded_data_length(share, old_record, &old_chunk_count);
36
36
  new_length = hp_get_encoded_data_length(share, new_record, &new_chunk_count);
38
38
  if (new_chunk_count > old_chunk_count) {
39
39
    /* extend the old chunkset size as necessary, but do not shrink yet */
40
40
    if (hp_reallocate_chunkset(&share->recordspace, new_chunk_count, pos)) {
41
 
      return(my_errno);                          /* Out of memory or table space */
 
41
      return(errno);                          /* Out of memory or table space */
42
42
    }
43
43
  }
44
 
 
 
44
 
45
45
  if (--(share->records) < share->blength >> 1) share->blength>>= 1;
46
46
  share->changed=1;
47
47
 
70
70
  return(0);
71
71
 
72
72
 err:
73
 
  if (my_errno == HA_ERR_FOUND_DUPP_KEY)
 
73
  if (errno == HA_ERR_FOUND_DUPP_KEY)
74
74
  {
75
75
    info->errkey = (int) (keydef - share->keydef);
76
76
    if (keydef->algorithm == HA_KEY_ALG_BTREE)
80
80
      {
81
81
        if (++(share->records) == share->blength)
82
82
          share->blength+= share->blength;
83
 
        return(my_errno);
 
83
        return(errno);
84
84
      }
85
85
      keydef--;
86
86
    }
104
104
    hp_reallocate_chunkset(&share->recordspace, old_chunk_count, pos);
105
105
  }
106
106
 
107
 
  return(my_errno);
 
107
  return(errno);
108
108
} /* heap_update */