00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #pragma once
00022
00023 #include <string>
00024 #include <boost/dynamic_bitset.hpp>
00025
00026 #include <drizzled/memory/sql_alloc.h>
00027 #include <drizzled/key_part_spec.h>
00028 #include <drizzled/sql_list.h>
00029 #include <drizzled/lex_string.h>
00030 #include <drizzled/sql_string.h>
00031 #include <drizzled/handler_structs.h>
00032
00033 namespace drizzled {
00034
00035 class Key : public memory::SqlAlloc
00036 {
00037 public:
00038 enum Keytype { PRIMARY, UNIQUE, MULTIPLE, FOREIGN_KEY };
00039 Keytype type;
00040 KEY_CREATE_INFO key_create_info;
00041 List<Key_part_spec> columns;
00042 str_ref name;
00043 bool generated;
00044
00045 Key(Keytype type_par, str_ref name_arg, KEY_CREATE_INFO *key_info_arg, bool generated_arg, List<Key_part_spec> &cols) :
00046 type(type_par),
00047 key_create_info(*key_info_arg),
00048 columns(cols),
00049 name(name_arg),
00050 generated(generated_arg)
00051 {}
00052
00053 virtual ~Key() {}
00054
00055 friend bool foreign_key_prefix(Key *a, Key *b);
00056 };
00057
00058
00059 int find_ref_key(KeyInfo *key, uint32_t key_count, unsigned char *record, Field *field, uint32_t *key_length, uint32_t *keypart);
00075 DRIZZLED_API void key_copy(unsigned char *to_key, unsigned char *from_record, KeyInfo *key_info, uint32_t key_length);
00076 void key_copy(std::basic_string<unsigned char> &to_key, unsigned char *from_record, KeyInfo *key_info, uint32_t key_length);
00077 void key_restore(unsigned char *to_record, unsigned char *from_key, KeyInfo *key_info, uint16_t key_length);
00078 void key_zero_nulls(unsigned char *tuple, KeyInfo *key_info);
00079 bool key_cmp_if_same(Table *form,const unsigned char *key,uint32_t index,uint32_t key_length);
00080 void key_unpack(String *to, const Table *form,uint32_t index);
00081 bool is_key_used(Table *table, uint32_t idx, const boost::dynamic_bitset<>& fields);
00082 int key_cmp(KeyPartInfo *key_part, const unsigned char *key, uint32_t key_length);
00083
00084 }