drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
drizzled/key.h
1/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 *
4 * Copyright (C) 2008 Sun Microsystems, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20
21#pragma once
22
23#include <string>
24#include <boost/dynamic_bitset.hpp>
25
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>
32
33namespace drizzled {
34
35class KeyPartInfo;
36
37class Key : public memory::SqlAlloc
38{
39public:
40 enum Keytype { PRIMARY, UNIQUE, MULTIPLE, FOREIGN_KEY };
41 Keytype type;
42 KEY_CREATE_INFO key_create_info;
43 List<Key_part_spec> columns;
44 str_ref name;
45 bool generated;
46
47 Key(Keytype type_par, str_ref name_arg, KEY_CREATE_INFO *key_info_arg, bool generated_arg, List<Key_part_spec> &cols) :
48 type(type_par),
49 key_create_info(*key_info_arg),
50 columns(cols),
51 name(name_arg),
52 generated(generated_arg)
53 {}
54
55 virtual ~Key() {}
56 /* Equality comparison of keys (ignoring name) */
57 friend bool foreign_key_prefix(Key *a, Key *b);
58};
59
60
61int find_ref_key(KeyInfo *key, uint32_t key_count, unsigned char *record, Field *field, uint32_t *key_length, uint32_t *keypart);
76
77DRIZZLED_API void key_copy(unsigned char *to_key, unsigned char *from_record, KeyInfo *key_info, uint32_t key_length);
78void key_copy(std::basic_string<unsigned char> &to_key, unsigned char *from_record, KeyInfo *key_info, uint32_t key_length);
79void key_restore(unsigned char *to_record, unsigned char *from_key, KeyInfo *key_info, uint16_t key_length);
80void key_zero_nulls(unsigned char *tuple, KeyInfo *key_info);
81bool key_cmp_if_same(Table *form,const unsigned char *key,uint32_t index,uint32_t key_length);
82void key_unpack(String *to, const Table *form,uint32_t index);
83bool is_key_used(Table *table, uint32_t idx, const boost::dynamic_bitset<>& fields);
84int key_cmp(KeyPartInfo *key_part, const unsigned char *key, uint32_t key_length);
85
86} /* namespace drizzled */
TODO: Rename this file - func.h is stupid.
void key_zero_nulls(unsigned char *tuple, KeyInfo *key_info)
int key_cmp(KeyPartInfo *key_part, const unsigned char *key, uint32_t key_length)
bool key_cmp_if_same(Table *table, const unsigned char *key, uint32_t idx, uint32_t key_length)
#define DRIZZLED_API
Definition visibility.h:38