21
#ifndef DRIZZLED_KEY_H
22
#define DRIZZLED_KEY_H
25
24
#include <boost/dynamic_bitset.hpp>
27
#include "drizzled/memory/sql_alloc.h"
28
#include "drizzled/key_part_spec.h"
29
#include "drizzled/sql_list.h"
30
#include "drizzled/lex_string.h"
31
#include "drizzled/sql_string.h"
32
#include "drizzled/handler_structs.h"
26
#include <drizzled/memory/sql_alloc.h>
27
#include <drizzled/key_part_spec.h>
28
#include <drizzled/sql_list.h>
29
#include <drizzled/lex_string.h>
30
#include <drizzled/sql_string.h>
31
#include <drizzled/handler_structs.h>
41
40
class Key :public memory::SqlAlloc {
43
42
enum Keytype { PRIMARY, UNIQUE, MULTIPLE, FOREIGN_KEY};
45
44
KEY_CREATE_INFO key_create_info;
46
45
List<Key_part_spec> columns;
50
Key(enum Keytype type_par, const LEX_STRING &name_arg,
50
const lex_string_t &name_arg,
51
51
KEY_CREATE_INFO *key_info_arg,
52
bool generated_arg, List<Key_part_spec> &cols)
53
:type(type_par), key_create_info(*key_info_arg), columns(cols),
54
name(name_arg), generated(generated_arg)
52
bool generated_arg, List<Key_part_spec> &cols) :
54
key_create_info(*key_info_arg),
57
generated(generated_arg)
56
Key(enum Keytype type_par, const char *name_arg, size_t name_len_arg,
57
KEY_CREATE_INFO *key_info_arg, bool generated_arg,
58
List<Key_part_spec> &cols)
59
:type(type_par), key_create_info(*key_info_arg), columns(cols),
63
KEY_CREATE_INFO *key_info_arg,
65
List<Key_part_spec> &cols) :
67
key_create_info(*key_info_arg),
60
69
generated(generated_arg)
62
71
name.str= const_cast<char *>(name_arg);
86
95
@param key_length specifies length of all keyparts that will be copied
89
void key_copy(unsigned char *to_key, unsigned char *from_record, KeyInfo *key_info, uint32_t key_length);
98
DRIZZLED_API void key_copy(unsigned char *to_key, unsigned char *from_record, KeyInfo *key_info, uint32_t key_length);
90
99
void key_copy(std::basic_string<unsigned char> &to_key,
91
100
unsigned char *from_record, KeyInfo *key_info, uint32_t key_length);
92
101
void key_restore(unsigned char *to_record, unsigned char *from_key, KeyInfo *key_info,
93
102
uint16_t key_length);
94
103
void key_zero_nulls(unsigned char *tuple, KeyInfo *key_info);
95
104
bool key_cmp_if_same(Table *form,const unsigned char *key,uint32_t index,uint32_t key_length);
96
void key_unpack(String *to,Table *form,uint32_t index);
105
void key_unpack(String *to, const Table *form,uint32_t index);
97
106
bool is_key_used(Table *table, uint32_t idx, const boost::dynamic_bitset<>& fields);
98
107
int key_cmp(KeyPartInfo *key_part, const unsigned char *key, uint32_t key_length);
100
109
} /* namespace drizzled */
102
#endif /* DRIZZLED_KEY_H */