~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/key.h

  • Committer: Monty Taylor
  • Date: 2008-12-06 22:41:03 UTC
  • mto: (656.1.7 devel)
  • mto: This revision was merged to the branch mainline in revision 665.
  • Revision ID: monty@inaugust.com-20081206224103-jdouqwt9hb0f01y1
Moved non-working tests into broken suite for easier running of working tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
21
21
#ifndef DRIZZLED_KEY_H
22
22
#define DRIZZLED_KEY_H
23
23
 
24
 
#include <string>
25
 
#include <boost/dynamic_bitset.hpp>
26
24
 
27
 
#include <drizzled/memory/sql_alloc.h>
 
25
#include <drizzled/sql_alloc.h>
28
26
#include <drizzled/key_part_spec.h>
29
27
#include <drizzled/sql_list.h>
30
28
#include <drizzled/lex_string.h>
31
 
#include <drizzled/sql_string.h>
32
29
#include <drizzled/handler_structs.h>
33
30
 
34
 
namespace drizzled
35
 
{
36
 
 
37
 
namespace memory { class Root; }
38
 
 
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
 
  Keytype type;
 
37
  enum Keytype type;
45
38
  KEY_CREATE_INFO key_create_info;
46
39
  List<Key_part_spec> columns;
47
40
  LEX_STRING name;
48
41
  bool generated;
49
42
 
50
 
  Key(Keytype type_par,
51
 
      const lex_string_t &name_arg,
 
43
  Key(enum Keytype type_par, const LEX_STRING &name_arg,
52
44
      KEY_CREATE_INFO *key_info_arg,
53
 
      bool generated_arg, List<Key_part_spec> &cols) :
54
 
    type(type_par),
55
 
    key_create_info(*key_info_arg),
56
 
    columns(cols),
57
 
    name(name_arg),
58
 
    generated(generated_arg)
 
45
      bool generated_arg, List<Key_part_spec> &cols)
 
46
    :type(type_par), key_create_info(*key_info_arg), columns(cols),
 
47
    name(name_arg), generated(generated_arg)
59
48
  {}
60
 
 
61
 
  Key(Keytype type_par,
62
 
      const char *name_arg,
63
 
      size_t name_len_arg,
64
 
      KEY_CREATE_INFO *key_info_arg,
65
 
      bool generated_arg,
66
 
      List<Key_part_spec> &cols) :
67
 
    type(type_par),
68
 
    key_create_info(*key_info_arg),
69
 
    columns(cols),
 
49
  Key(enum Keytype type_par, const char *name_arg, size_t name_len_arg,
 
50
      KEY_CREATE_INFO *key_info_arg, bool generated_arg,
 
51
      List<Key_part_spec> &cols)
 
52
    :type(type_par), key_create_info(*key_info_arg), columns(cols),
70
53
    generated(generated_arg)
71
54
  {
72
 
    name.str= const_cast<char *>(name_arg);
 
55
    name.str= (char *)name_arg;
73
56
    name.length= name_len_arg;
74
57
  }
75
 
 
 
58
  Key(const Key &rhs, MEM_ROOT *mem_root);
76
59
  virtual ~Key() {}
77
60
  /* Equality comparison of keys (ignoring name) */
78
61
  friend bool foreign_key_prefix(Key *a, Key *b);
 
62
  /**
 
63
    Used to make a clone of this object for ALTER/CREATE TABLE
 
64
    @sa comment for Key_part_spec::clone
 
65
  */
 
66
  virtual Key *clone(MEM_ROOT *mem_root) const
 
67
    { return new (mem_root) Key(*this, mem_root); }
79
68
};
80
69
 
81
70
 
82
 
int find_ref_key(KeyInfo *key, uint32_t key_count, unsigned char *record, Field *field,
 
71
int find_ref_key(KEY *key, uint32_t key_count, unsigned char *record, Field *field,
83
72
                 uint32_t *key_length, uint32_t *keypart);
84
73
/**
85
74
  Copy part of a record that forms a key or key prefix to a buffer.
96
85
  @param key_length  specifies length of all keyparts that will be copied
97
86
*/
98
87
 
99
 
DRIZZLED_API void key_copy(unsigned char *to_key, unsigned char *from_record, KeyInfo *key_info, uint32_t key_length);
 
88
void key_copy(unsigned char *to_key, unsigned char *from_record, KEY *key_info, uint32_t key_length);
100
89
void key_copy(std::basic_string<unsigned char> &to_key,
101
 
              unsigned char *from_record, KeyInfo *key_info, uint32_t key_length);
102
 
void key_restore(unsigned char *to_record, unsigned char *from_key, KeyInfo *key_info,
 
90
              unsigned char *from_record, KEY *key_info, uint32_t key_length);
 
91
void key_restore(unsigned char *to_record, unsigned char *from_key, KEY *key_info,
103
92
                 uint16_t key_length);
104
 
void key_zero_nulls(unsigned char *tuple, KeyInfo *key_info);
 
93
void key_zero_nulls(unsigned char *tuple, KEY *key_info);
105
94
bool key_cmp_if_same(Table *form,const unsigned char *key,uint32_t index,uint32_t key_length);
106
 
void key_unpack(String *to, const Table *form,uint32_t index);
107
 
bool is_key_used(Table *table, uint32_t idx, const boost::dynamic_bitset<>& fields);
108
 
int key_cmp(KeyPartInfo *key_part, const unsigned char *key, uint32_t key_length);
109
 
 
110
 
} /* namespace drizzled */
111
 
 
 
95
void key_unpack(String *to,Table *form,uint32_t index);
 
96
bool is_key_used(Table *table, uint32_t idx, const MY_BITMAP *fields);
 
97
int key_cmp(KEY_PART_INFO *key_part, const unsigned char *key, uint32_t key_length);
 
98
extern "C" int key_rec_cmp(void *key_info, unsigned char *a, unsigned char *b);
112
99
#endif /* DRIZZLED_KEY_H */