584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
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
|
|
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 |
#ifndef DRIZZLED_KEY_H
|
|
22 |
#define DRIZZLED_KEY_H
|
|
23 |
||
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
24 |
#include <string> |
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
25 |
|
1253.1.4
by Monty Taylor
Moved sql_alloc into memory. |
26 |
#include "drizzled/memory/sql_alloc.h" |
1237.9.4
by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file. |
27 |
#include "drizzled/key_part_spec.h" |
28 |
#include "drizzled/sql_list.h" |
|
29 |
#include "drizzled/lex_string.h" |
|
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
30 |
#include "drizzled/sql_string.h" |
1237.9.4
by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file. |
31 |
#include "drizzled/handler_structs.h" |
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
32 |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
33 |
namespace drizzled |
34 |
{
|
|
35 |
||
36 |
namespace memory { class Root; } |
|
37 |
||
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
38 |
class Item; |
1237.9.4
by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file. |
39 |
class MyBitmap; |
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
40 |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
41 |
class Key :public memory::SqlAlloc { |
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
42 |
public: |
43 |
enum Keytype { PRIMARY, UNIQUE, MULTIPLE, FOREIGN_KEY}; |
|
44 |
enum Keytype type; |
|
45 |
KEY_CREATE_INFO key_create_info; |
|
46 |
List<Key_part_spec> columns; |
|
47 |
LEX_STRING name; |
|
48 |
bool generated; |
|
49 |
||
50 |
Key(enum Keytype type_par, const LEX_STRING &name_arg, |
|
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) |
|
55 |
{}
|
|
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), |
|
60 |
generated(generated_arg) |
|
61 |
{
|
|
1238.1.4
by Brian Aker
ICC cleanup |
62 |
name.str= const_cast<char *>(name_arg); |
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
63 |
name.length= name_len_arg; |
64 |
}
|
|
934.2.21
by Jay Pipes
Move Key stuff into key.cc and out of session.cc |
65 |
|
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
66 |
virtual ~Key() {} |
67 |
/* Equality comparison of keys (ignoring name) */
|
|
68 |
friend bool foreign_key_prefix(Key *a, Key *b); |
|
69 |
};
|
|
70 |
||
656.1.1
by Monty Taylor
OOOh doggie. Got rid of my_alloca. |
71 |
|
1535
by Brian Aker
Rename of KEY to KeyInfo |
72 |
int find_ref_key(KeyInfo *key, uint32_t key_count, unsigned char *record, Field *field, |
656.1.1
by Monty Taylor
OOOh doggie. Got rid of my_alloca. |
73 |
uint32_t *key_length, uint32_t *keypart); |
74 |
/**
|
|
75 |
Copy part of a record that forms a key or key prefix to a buffer.
|
|
76 |
||
77 |
The function takes a complete table record (as e.g. retrieved by
|
|
78 |
handler::index_read()), and a description of an index on the same table,
|
|
79 |
and extracts the first key_length bytes of the record which are part of a
|
|
80 |
key into to_key. If length == 0 then copy all bytes from the record that
|
|
81 |
form a key.
|
|
82 |
||
83 |
@param to_key buffer that will be used as a key
|
|
84 |
@param from_record full record to be copied from
|
|
85 |
@param key_info descriptor of the index
|
|
86 |
@param key_length specifies length of all keyparts that will be copied
|
|
87 |
*/
|
|
88 |
||
1535
by Brian Aker
Rename of KEY to KeyInfo |
89 |
void key_copy(unsigned char *to_key, unsigned char *from_record, KeyInfo *key_info, uint32_t key_length); |
656.1.1
by Monty Taylor
OOOh doggie. Got rid of my_alloca. |
90 |
void key_copy(std::basic_string<unsigned char> &to_key, |
1535
by Brian Aker
Rename of KEY to KeyInfo |
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, |
|
656.1.1
by Monty Taylor
OOOh doggie. Got rid of my_alloca. |
93 |
uint16_t key_length); |
1535
by Brian Aker
Rename of KEY to KeyInfo |
94 |
void key_zero_nulls(unsigned char *tuple, KeyInfo *key_info); |
656.1.1
by Monty Taylor
OOOh doggie. Got rid of my_alloca. |
95 |
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); |
|
1103.6.2
by Padraig O'Sullivan
Removing references to MY_BITMAP throughout the code base and updating calls |
97 |
bool is_key_used(Table *table, uint32_t idx, const MyBitmap *fields); |
1534
by Brian Aker
Remove of KeyPartInfo |
98 |
int key_cmp(KeyPartInfo *key_part, const unsigned char *key, uint32_t key_length); |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
99 |
|
100 |
} /* namespace drizzled */ |
|
101 |
||
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
102 |
#endif /* DRIZZLED_KEY_H */ |