~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/heapdef.h

  • Committer: Jay Pipes
  • Date: 2008-09-11 16:03:22 UTC
  • mto: (383.5.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 386.
  • Revision ID: jay@mysql.com-20080911160322-vrl0k1djo6q6ytv1
Removed SQL_MODE variances from comment_table.test and ensured correct error thrown when a comment that is too long was input.  After moving to proto buffer definition for table, the 2048 length will go away.

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 */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
/* This file is included in all heap-files */
17
 
#ifndef PLUGIN_MEMORY_HEAP_PRIV_H
18
 
#define PLUGIN_MEMORY_HEAP_PRIV_H
19
 
 
20
 
#include "config.h"
21
 
#include <drizzled/base.h>
22
 
 
23
 
#include "drizzled/internal/my_sys.h"
24
 
#include "drizzled/charset_info.h"
25
 
#include "drizzled/internal/my_pthread.h"
 
17
#ifndef HEAPDEF_H
 
18
#define HEAPDEF_H
 
19
 
 
20
#include <drizzled/base.h>              /* This includes global */
 
21
C_MODE_START
 
22
#include <mysys/my_pthread.h>
26
23
#include "heap.h"                       /* Structs & some defines */
27
 
#include "drizzled/tree.h"
28
 
#include <list>
29
 
 
30
 
#include <boost/thread/mutex.hpp>
 
24
#include <mysys/my_tree.h>
31
25
 
32
26
/*
33
27
  When allocating keys /rows in the internal block structure, do it
37
31
  as possible and keep memory consumption down.
38
32
*/
39
33
 
 
34
#define HP_MIN_RECORDS_IN_BLOCK 16
 
35
#define HP_MAX_RECORDS_IN_BLOCK 8192
 
36
 
40
37
#define CHUNK_STATUS_DELETED 0    /* this chunk has been deleted and can be reused */
41
38
#define CHUNK_STATUS_ACTIVE  1    /* this chunk represents the first part of a live record */
42
39
#define CHUNK_STATUS_LINKED  2    /* this chunk is a continuation from another chunk (part of chunkset) */
43
40
 
44
41
        /* Some extern variables */
45
42
 
46
 
extern std::list<HP_SHARE *> heap_share_list;
47
 
extern std::list<HP_INFO *> heap_open_list;
 
43
extern LIST *heap_open_list,*heap_share_list;
48
44
 
49
45
#define test_active(info) \
50
46
if (!(info->update & HA_STATE_AKTIV))\
51
 
{ errno=HA_ERR_NO_ACTIVE_RECORD; return(-1); }
 
47
{ my_errno=HA_ERR_NO_ACTIVE_RECORD; return(-1); }
52
48
#define hp_find_hash(A,B) ((HASH_INFO*) hp_find_block((A),(B)))
53
49
 
54
50
        /* Find pos for record and update it in info->current_ptr */
55
 
#define hp_find_record(info,pos) (info)->current_ptr= hp_find_block(&(info)->getShare()->recordspace.block,pos)
 
51
#define hp_find_record(info,pos) (info)->current_ptr= hp_find_block(&(info)->s->recordspace.block,pos)
56
52
 
57
53
#define get_chunk_status(info,ptr) (ptr[(info)->offset_status])
58
54
 
61
57
typedef struct st_hp_hash_info
62
58
{
63
59
  struct st_hp_hash_info *next_key;
64
 
  unsigned char *ptr_to_rec;
 
60
  uchar *ptr_to_rec;
65
61
} HASH_INFO;
66
62
 
 
63
typedef struct {
 
64
  HA_KEYSEG *keyseg;
 
65
  uint key_length;
 
66
  uint search_flag;
 
67
} heap_rb_param;
 
68
      
67
69
        /* Prototypes for intern functions */
68
70
 
69
71
extern HP_SHARE *hp_find_named_heap(const char *name);
70
 
extern int hp_rectest(HP_INFO *info,const unsigned char *old);
71
 
extern unsigned char *hp_find_block(HP_BLOCK *info,uint32_t pos);
 
72
extern int hp_rectest(HP_INFO *info,const uchar *old);
 
73
extern uchar *hp_find_block(HP_BLOCK *info,uint32_t pos);
72
74
extern int hp_get_new_block(HP_BLOCK *info, size_t* alloc_length);
73
75
extern void hp_free(HP_SHARE *info);
74
 
extern unsigned char *hp_free_level(HP_BLOCK *block,uint32_t level,HP_PTRS *pos,
75
 
                                    unsigned char *last_pos);
 
76
extern uchar *hp_free_level(HP_BLOCK *block,uint level,HP_PTRS *pos,
 
77
                           uchar *last_pos);
76
78
extern int hp_write_key(HP_INFO *info, HP_KEYDEF *keyinfo,
77
 
                        const unsigned char *record, unsigned char *recpos);
 
79
                        const uchar *record, uchar *recpos);
 
80
extern int hp_rb_write_key(HP_INFO *info, HP_KEYDEF *keyinfo, 
 
81
                           const uchar *record, uchar *recpos);
 
82
extern int hp_rb_delete_key(HP_INFO *info,HP_KEYDEF *keyinfo,
 
83
                            const uchar *record,uchar *recpos,int flag);
78
84
extern int hp_delete_key(HP_INFO *info,HP_KEYDEF *keyinfo,
79
 
                         const unsigned char *record,unsigned char *recpos,int flag);
 
85
                         const uchar *record,uchar *recpos,int flag);
80
86
extern HASH_INFO *_heap_find_hash(HP_BLOCK *block,uint32_t pos);
81
 
extern unsigned char *hp_search(HP_INFO *info,HP_KEYDEF *keyinfo,const unsigned char *key,
82
 
                       uint32_t nextflag);
83
 
extern unsigned char *hp_search_next(HP_INFO *info, HP_KEYDEF *keyinfo,
84
 
                            const unsigned char *key, HASH_INFO *pos);
85
 
extern uint32_t hp_rec_hashnr(HP_KEYDEF *keyinfo,const unsigned char *rec);
 
87
extern uchar *hp_search(HP_INFO *info,HP_KEYDEF *keyinfo,const uchar *key,
 
88
                       uint nextflag);
 
89
extern uchar *hp_search_next(HP_INFO *info, HP_KEYDEF *keyinfo,
 
90
                            const uchar *key, HASH_INFO *pos);
 
91
extern uint32_t hp_hashnr(HP_KEYDEF *keyinfo,const uchar *key);
 
92
extern uint32_t hp_rec_hashnr(HP_KEYDEF *keyinfo,const uchar *rec);
86
93
extern uint32_t hp_mask(uint32_t hashnr,uint32_t buffmax,uint32_t maxlength);
87
94
extern void hp_movelink(HASH_INFO *pos,HASH_INFO *next_link,
88
95
                         HASH_INFO *newlink);
89
 
extern int hp_rec_key_cmp(HP_KEYDEF *keydef,const unsigned char *rec1,
90
 
                          const unsigned char *rec2,
 
96
extern int hp_rec_key_cmp(HP_KEYDEF *keydef,const uchar *rec1,
 
97
                          const uchar *rec2,
91
98
                          bool diff_if_only_endspace_difference);
92
 
extern void hp_make_key(HP_KEYDEF *keydef,unsigned char *key,const unsigned char *rec);
93
 
extern bool hp_if_null_in_key(HP_KEYDEF *keyinfo, const unsigned char *record);
94
 
extern int hp_close(HP_INFO *info);
 
99
extern int hp_key_cmp(HP_KEYDEF *keydef,const uchar *rec,
 
100
                      const uchar *key);
 
101
extern void hp_make_key(HP_KEYDEF *keydef,uchar *key,const uchar *rec);
 
102
extern uint hp_rb_make_key(HP_KEYDEF *keydef, uchar *key,
 
103
                           const uchar *rec, uchar *recpos);
 
104
extern uint hp_rb_key_length(HP_KEYDEF *keydef, const uchar *key);
 
105
extern uint hp_rb_null_key_length(HP_KEYDEF *keydef, const uchar *key);
 
106
extern uint hp_rb_var_key_length(HP_KEYDEF *keydef, const uchar *key);
 
107
extern bool hp_if_null_in_key(HP_KEYDEF *keyinfo, const uchar *record);
 
108
extern int hp_close(register HP_INFO *info);
95
109
extern void hp_clear(HP_SHARE *info);
 
110
extern void hp_clear_keys(HP_SHARE *info);
 
111
extern uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old,
 
112
                           key_part_map keypart_map);
96
113
 
97
114
   /* Chunkset management (alloc/free/encode/decode) functions */
98
 
 
99
 
extern unsigned char *hp_allocate_chunkset(HP_DATASPACE *info, uint32_t chunk_count);
100
 
extern void hp_free_chunks(HP_DATASPACE *info, unsigned char *pos);
 
115
 
 
116
extern uchar *hp_allocate_chunkset(HP_DATASPACE *info, uint chunk_count);
 
117
extern int hp_reallocate_chunkset(HP_DATASPACE *info, uint chunk_count, uchar* pos);
 
118
extern void hp_free_chunks(HP_DATASPACE *info, uchar *pos);
101
119
extern void hp_clear_dataspace(HP_DATASPACE *info);
102
 
 
103
 
extern uint32_t hp_get_encoded_data_length(HP_SHARE *info, const unsigned char *record, uint32_t *chunk_count);
104
 
extern void hp_copy_record_data_to_chunkset(HP_SHARE *info, const unsigned char *record, unsigned char *pos);
105
 
extern void hp_extract_record(HP_SHARE *info, unsigned char *record, const unsigned char *pos);
106
 
extern bool hp_compare_record_data_to_chunkset(HP_SHARE *info, const unsigned char *record, unsigned char *pos);
107
 
 
108
 
extern boost::mutex THR_LOCK_heap;
109
 
 
110
 
#endif /* PLUGIN_MEMORY_HEAP_PRIV_H */
 
120
 
 
121
extern uint hp_get_encoded_data_length(HP_SHARE *info, const uchar *record, uint *chunk_count);
 
122
extern void hp_copy_record_data_to_chunkset(HP_SHARE *info, const uchar *record, uchar *pos);
 
123
extern void hp_extract_record(HP_SHARE *info, uchar *record, const uchar *pos);
 
124
extern uint hp_process_record_data_to_chunkset(HP_SHARE *info, const uchar *record, uchar *pos, uint is_compare);
 
125
 
 
126
 
 
127
 
 
128
extern pthread_mutex_t THR_LOCK_heap;
 
129
C_MODE_END
 
130
 
 
131
#endif /* HEAPDEF_H */