~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/key.h

  • Committer: devananda
  • Date: 2009-07-01 17:38:47 UTC
  • mto: (1093.1.7 captain)
  • mto: This revision was merged to the branch mainline in revision 1095.
  • Revision ID: devananda.vdv@gmail.com-20090701173847-3n3mbtessg5ff35e
refactored function/benchmark into plugin/benchmark

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#ifndef DRIZZLED_KEY_H
22
22
#define DRIZZLED_KEY_H
23
23
 
24
 
#include <string>
25
 
#include <boost/dynamic_bitset.hpp>
26
 
 
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"
33
 
 
34
 
namespace drizzled
35
 
{
36
 
 
37
 
namespace memory { class Root; }
 
24
 
 
25
#include <drizzled/sql_alloc.h>
 
26
#include <drizzled/key_part_spec.h>
 
27
#include <drizzled/sql_list.h>
 
28
#include <drizzled/lex_string.h>
 
29
#include <drizzled/handler_structs.h>
38
30
 
39
31
class Item;
 
32
typedef struct st_mem_root MEM_ROOT;
40
33
 
41
 
class Key :public memory::SqlAlloc {
 
34
class Key :public Sql_alloc {
42
35
public:
43
36
  enum Keytype { PRIMARY, UNIQUE, MULTIPLE, FOREIGN_KEY};
44
37
  enum Keytype type;
59
52
    :type(type_par), key_create_info(*key_info_arg), columns(cols),
60
53
    generated(generated_arg)
61
54
  {
62
 
    name.str= const_cast<char *>(name_arg);
 
55
    name.str= (char *)name_arg;
63
56
    name.length= name_len_arg;
64
57
  }
65
58
 
 
59
  /**
 
60
   * Construct an (almost) deep copy of this key. Only those
 
61
   * elements that are known to never change are not copied.
 
62
   * If out of memory, a partial copy is returned and an error is set
 
63
   * in Session.
 
64
   */
 
65
  Key(const Key &rhs, MEM_ROOT *mem_root);
66
66
  virtual ~Key() {}
67
67
  /* Equality comparison of keys (ignoring name) */
68
68
  friend bool foreign_key_prefix(Key *a, Key *b);
 
69
  /**
 
70
    Used to make a clone of this object for ALTER/CREATE TABLE
 
71
    @sa comment for Key_part_spec::clone
 
72
  */
 
73
  virtual Key *clone(MEM_ROOT *mem_root) const
 
74
    { return new (mem_root) Key(*this, mem_root); }
69
75
};
70
76
 
71
77
 
72
 
int find_ref_key(KeyInfo *key, uint32_t key_count, unsigned char *record, Field *field,
 
78
int find_ref_key(KEY *key, uint32_t key_count, unsigned char *record, Field *field,
73
79
                 uint32_t *key_length, uint32_t *keypart);
74
80
/**
75
81
  Copy part of a record that forms a key or key prefix to a buffer.
86
92
  @param key_length  specifies length of all keyparts that will be copied
87
93
*/
88
94
 
89
 
void key_copy(unsigned char *to_key, unsigned char *from_record, KeyInfo *key_info, uint32_t key_length);
 
95
void key_copy(unsigned char *to_key, unsigned char *from_record, KEY *key_info, uint32_t key_length);
90
96
void key_copy(std::basic_string<unsigned char> &to_key,
91
 
              unsigned char *from_record, KeyInfo *key_info, uint32_t key_length);
92
 
void key_restore(unsigned char *to_record, unsigned char *from_key, KeyInfo *key_info,
 
97
              unsigned char *from_record, KEY *key_info, uint32_t key_length);
 
98
void key_restore(unsigned char *to_record, unsigned char *from_key, KEY *key_info,
93
99
                 uint16_t key_length);
94
 
void key_zero_nulls(unsigned char *tuple, KeyInfo *key_info);
 
100
void key_zero_nulls(unsigned char *tuple, KEY *key_info);
95
101
bool key_cmp_if_same(Table *form,const unsigned char *key,uint32_t index,uint32_t key_length);
96
102
void key_unpack(String *to,Table *form,uint32_t index);
97
 
bool is_key_used(Table *table, uint32_t idx, const boost::dynamic_bitset<>& fields);
98
 
int key_cmp(KeyPartInfo *key_part, const unsigned char *key, uint32_t key_length);
99
 
 
100
 
} /* namespace drizzled */
101
 
 
 
103
bool is_key_used(Table *table, uint32_t idx, const MY_BITMAP *fields);
 
104
int key_cmp(KEY_PART_INFO *key_part, const unsigned char *key, uint32_t key_length);
 
105
extern "C" int key_rec_cmp(void *key_info, unsigned char *a, unsigned char *b);
102
106
#endif /* DRIZZLED_KEY_H */