390.1.2
by Monty Taylor
Fixed copyright headers in drizzled/ |
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; either version 2 of the License, or
|
|
9 |
* (at your option) any later version.
|
|
10 |
*
|
|
11 |
* This program is distributed in the hope that it will be useful,
|
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
* GNU General Public License for more details.
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License
|
|
17 |
* along with this program; if not, write to the Free Software
|
|
18 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
19 |
*/
|
|
1
by brian
clean slate |
20 |
|
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
21 |
/* Structs that defines the Table */
|
1
by brian
clean slate |
22 |
|
327.1.2
by Brian Aker
Commiting next pass of Table class cleanup. |
23 |
#ifndef DRIZZLED_TABLE_H
|
24 |
#define DRIZZLED_TABLE_H
|
|
25 |
||
992.1.25
by Monty Taylor
Moved myisam to new plugin system. |
26 |
#include <plugin/myisam/myisam.h> |
327.2.3
by Brian Aker
Refactoring of class Table |
27 |
#include <drizzled/order.h> |
28 |
#include <drizzled/filesort_info.h> |
|
327.2.4
by Brian Aker
Refactoring table.h |
29 |
#include <drizzled/natural_join_column.h> |
353
by Brian Aker
Moved Field iterator out to its own definition. |
30 |
#include <drizzled/field_iterator.h> |
520.8.6
by Monty Taylor
Removed handler from common_includes. |
31 |
#include <mysys/hash.h> |
32 |
#include <drizzled/handler.h> |
|
575.4.5
by Monty Taylor
Added lex_string.h header. |
33 |
#include <drizzled/lex_string.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. |
34 |
#include <drizzled/table_list.h> |
798
by Brian Aker
Updated table_share tto its own file (yess, it will eventually go away). |
35 |
#include <drizzled/table_share.h> |
327.1.2
by Brian Aker
Commiting next pass of Table class cleanup. |
36 |
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
37 |
class Item; |
1
by brian
clean slate |
38 |
class Item_subselect; |
848
by Brian Aker
typdef class removal (just... use the name of the class). |
39 |
class Select_Lex_Unit; |
846
by Brian Aker
Removing on typedeffed class. |
40 |
class Select_Lex; |
1
by brian
clean slate |
41 |
class COND_EQUAL; |
42 |
class Security_context; |
|
327.2.4
by Brian Aker
Refactoring table.h |
43 |
class TableList; |
1
by brian
clean slate |
44 |
|
45 |
/*************************************************************************/
|
|
46 |
||
47 |
||
48 |
class Field_timestamp; |
|
49 |
class Field_blob; |
|
50 |
||
51 |
typedef enum enum_table_category TABLE_CATEGORY; |
|
52 |
||
53 |
TABLE_CATEGORY get_table_category(const LEX_STRING *db, |
|
54 |
const LEX_STRING *name); |
|
55 |
||
327.2.3
by Brian Aker
Refactoring of class Table |
56 |
typedef struct st_table_field_w_type |
57 |
{
|
|
58 |
LEX_STRING name; |
|
59 |
LEX_STRING type; |
|
60 |
LEX_STRING cset; |
|
61 |
} TABLE_FIELD_W_TYPE; |
|
62 |
||
1014.2.10
by Monty Taylor
Made REGINFO into RegInfo and responsible for initializing itself. |
63 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
64 |
bool create_myisam_from_heap(Session *session, Table *table, |
327.1.2
by Brian Aker
Commiting next pass of Table class cleanup. |
65 |
MI_COLUMNDEF *start_recinfo, |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
66 |
MI_COLUMNDEF **recinfo, |
327.1.2
by Brian Aker
Commiting next pass of Table class cleanup. |
67 |
int error, bool ignore_last_dupp_key_error); |
68 |
||
327.1.1
by Brian Aker
First pass in encapsulating table (it is now an object, no longer a structure). |
69 |
class Table { |
70 |
public: |
|
1030.1.1
by Brian Aker
Straighten out structures (remove some some dead bits). |
71 |
|
72 |
TableShare *s; |
|
73 |
Field **field; /* Pointer to fields */ |
|
74 |
||
75 |
handler *file; |
|
76 |
Table *next; |
|
77 |
Table *prev; |
|
78 |
||
1030.1.2
by Brian Aker
More alignment for structures |
79 |
MY_BITMAP *read_set; /* Active column sets */ |
80 |
MY_BITMAP *write_set; /* Active column sets */ |
|
81 |
||
82 |
uint32_t tablenr; |
|
1030.1.1
by Brian Aker
Straighten out structures (remove some some dead bits). |
83 |
uint32_t db_stat; /* mode of file as in handler.h */ |
84 |
||
1005.2.5
by Monty Taylor
Merged with trunk. |
85 |
my_bitmap_map *bitmap_init_value; |
86 |
MY_BITMAP def_read_set, def_write_set, tmp_set; /* containers */ |
|
1003.1.12
by Brian Aker
Begin of abstract out the bitmap from direct reference. |
87 |
|
520.1.21
by Brian Aker
THD -> Session rename |
88 |
Session *in_use; /* Which thread uses this */ |
1
by brian
clean slate |
89 |
|
481
by Brian Aker
Remove all of uchar. |
90 |
unsigned char *record[2]; /* Pointer to records */ |
91 |
unsigned char *write_row_record; /* Used as optimisation in |
|
520.1.21
by Brian Aker
THD -> Session rename |
92 |
Session::write_row */
|
481
by Brian Aker
Remove all of uchar. |
93 |
unsigned char *insert_values; /* used by INSERT ... UPDATE */ |
1
by brian
clean slate |
94 |
KEY *key_info; /* data of keys in database */ |
95 |
Field *next_number_field; /* Set if next_number is activated */ |
|
96 |
Field *found_next_number_field; /* Set on open */ |
|
97 |
Field_timestamp *timestamp_field; |
|
98 |
||
327.2.4
by Brian Aker
Refactoring table.h |
99 |
TableList *pos_in_table_list;/* Element referring to this table */ |
327.2.3
by Brian Aker
Refactoring of class Table |
100 |
order_st *group; |
1
by brian
clean slate |
101 |
const char *alias; /* alias or table name */ |
481
by Brian Aker
Remove all of uchar. |
102 |
unsigned char *null_flags; |
1
by brian
clean slate |
103 |
|
482
by Brian Aker
Remove uint. |
104 |
uint32_t lock_position; /* Position in DRIZZLE_LOCK.table */ |
105 |
uint32_t lock_data_start; /* Start pos. in DRIZZLE_LOCK.locks */ |
|
106 |
uint32_t lock_count; /* Number of locks */ |
|
1030.1.2
by Brian Aker
More alignment for structures |
107 |
uint32_t used_fields; |
482
by Brian Aker
Remove uint. |
108 |
uint32_t temp_pool_slot; /* Used by intern temp tables */ |
1030.1.2
by Brian Aker
More alignment for structures |
109 |
uint32_t status; /* What's in record[0] */ |
1
by brian
clean slate |
110 |
/* number of select if it is derived table */
|
482
by Brian Aker
Remove uint. |
111 |
uint32_t derived_select_number; |
1
by brian
clean slate |
112 |
int current_lock; /* Type of lock on table */ |
274
by Brian Aker
my_bool conversion in Table |
113 |
bool copy_blobs; /* copy_blobs when storing */ |
1
by brian
clean slate |
114 |
|
115 |
/*
|
|
116 |
0 or JOIN_TYPE_{LEFT|RIGHT}. Currently this is only compared to 0.
|
|
117 |
If maybe_null !=0, this table is inner w.r.t. some outer join operation,
|
|
118 |
and null_row may be true.
|
|
119 |
*/
|
|
327.1.3
by Brian Aker
Cleaned up depend in Proto utils. Modified int to bool. Put TmpTable class |
120 |
bool maybe_null; |
121 |
||
1
by brian
clean slate |
122 |
/*
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
123 |
If true, the current table row is considered to have all columns set to
|
1
by brian
clean slate |
124 |
NULL, including columns declared as "not null" (see maybe_null).
|
125 |
*/
|
|
274
by Brian Aker
my_bool conversion in Table |
126 |
bool null_row; |
1
by brian
clean slate |
127 |
|
274
by Brian Aker
my_bool conversion in Table |
128 |
bool force_index; |
129 |
bool distinct,const_table,no_rows; |
|
1030.1.2
by Brian Aker
More alignment for structures |
130 |
bool key_read; |
131 |
bool no_keyread; |
|
1
by brian
clean slate |
132 |
/*
|
133 |
Placeholder for an open table which prevents other connections
|
|
134 |
from taking name-locks on this table. Typically used with
|
|
1000.1.3
by Brian Aker
Renamed TABLE_SHARE to TableShare |
135 |
TableShare::version member to take an exclusive name-lock on
|
1
by brian
clean slate |
136 |
this table name -- a name lock that not only prevents other
|
137 |
threads from opening the table, but also blocks other name
|
|
138 |
locks. This is achieved by:
|
|
139 |
- setting open_placeholder to 1 - this will block other name
|
|
140 |
locks, as wait_for_locked_table_name will be forced to wait,
|
|
141 |
see table_is_used for details.
|
|
142 |
- setting version to 0 - this will force other threads to close
|
|
143 |
the instance of this table and wait (this is the same approach
|
|
144 |
as used for usual name locks).
|
|
145 |
An exclusively name-locked table currently can have no handler
|
|
146 |
object associated with it (db_stat is always 0), but please do
|
|
147 |
not rely on that.
|
|
148 |
*/
|
|
274
by Brian Aker
my_bool conversion in Table |
149 |
bool open_placeholder; |
150 |
bool locked_by_name; |
|
151 |
bool no_cache; |
|
1
by brian
clean slate |
152 |
/*
|
153 |
To indicate that a non-null value of the auto_increment field
|
|
154 |
was provided by the user or retrieved from the current record.
|
|
155 |
Used only in the MODE_NO_AUTO_VALUE_ON_ZERO mode.
|
|
156 |
*/
|
|
274
by Brian Aker
my_bool conversion in Table |
157 |
bool auto_increment_field_not_null; |
158 |
bool insert_or_update; /* Can be used by the handler */ |
|
159 |
bool alias_name_used; /* true if table_name is alias */ |
|
160 |
bool get_fields_in_item_tree; /* Signal to fix_field */ |
|
1030.1.2
by Brian Aker
More alignment for structures |
161 |
int report_error(int error); |
162 |
int closefrm(bool free_share); |
|
163 |
||
164 |
/*
|
|
165 |
The ID of the query that opened and is using this table. Has different
|
|
166 |
meanings depending on the table type.
|
|
167 |
||
168 |
Temporary tables:
|
|
169 |
||
170 |
table->query_id is set to session->query_id for the duration of a statement
|
|
171 |
and is reset to 0 once it is closed by the same statement. A non-zero
|
|
172 |
table->query_id means that a statement is using the table even if it's
|
|
173 |
not the current statement (table is in use by some outer statement).
|
|
174 |
||
175 |
Non-temporary tables:
|
|
176 |
||
177 |
Under pre-locked or LOCK TABLES mode: query_id is set to session->query_id
|
|
178 |
for the duration of a statement and is reset to 0 once it is closed by
|
|
179 |
the same statement. A non-zero query_id is used to control which tables
|
|
180 |
in the list of pre-opened and locked tables are actually being used.
|
|
181 |
*/
|
|
182 |
query_id_t query_id; |
|
183 |
||
184 |
/*
|
|
185 |
Estimate of number of records that satisfy SARGable part of the table
|
|
186 |
condition, or table->file->records if no SARGable condition could be
|
|
187 |
constructed.
|
|
188 |
This value is used by join optimizer as an estimate of number of records
|
|
189 |
that will pass the table condition (condition that depends on fields of
|
|
190 |
this table and constants)
|
|
191 |
*/
|
|
192 |
ha_rows quick_condition_rows; |
|
193 |
||
194 |
/*
|
|
195 |
If this table has TIMESTAMP field with auto-set property (pointed by
|
|
196 |
timestamp_field member) then this variable indicates during which
|
|
197 |
operations (insert only/on update/in both cases) we should set this
|
|
198 |
field to current timestamp. If there are no such field in this table
|
|
199 |
or we should not automatically set its value during execution of current
|
|
200 |
statement then the variable contains TIMESTAMP_NO_AUTO_SET (i.e. 0).
|
|
201 |
||
202 |
Value of this variable is set for each statement in open_table() and
|
|
203 |
if needed cleared later in statement processing code (see mysql_update()
|
|
204 |
as example).
|
|
205 |
*/
|
|
206 |
timestamp_auto_set_type timestamp_field_type; |
|
207 |
table_map map; /* ID bit of table (1,2,4,8,16...) */ |
|
1
by brian
clean slate |
208 |
|
1014.2.10
by Monty Taylor
Made REGINFO into RegInfo and responsible for initializing itself. |
209 |
RegInfo reginfo; /* field connections */ |
1030.1.2
by Brian Aker
More alignment for structures |
210 |
|
211 |
/*
|
|
212 |
Map of keys that can be used to retrieve all data from this table
|
|
213 |
needed by the query without reading the row.
|
|
214 |
*/
|
|
215 |
key_map covering_keys; |
|
216 |
||
217 |
||
218 |
key_map quick_keys; |
|
219 |
key_map merge_keys; |
|
220 |
||
221 |
/*
|
|
222 |
A set of keys that can be used in the query that references this
|
|
223 |
table.
|
|
224 |
||
225 |
All indexes disabled on the table's TableShare (see Table::s) will be
|
|
226 |
subtracted from this set upon instantiation. Thus for any Table t it holds
|
|
227 |
that t.keys_in_use_for_query is a subset of t.s.keys_in_use. Generally we
|
|
228 |
must not introduce any new keys here (see setup_tables).
|
|
229 |
||
230 |
The set is implemented as a bitmap.
|
|
231 |
*/
|
|
232 |
key_map keys_in_use_for_query; |
|
233 |
/* Map of keys that can be used to calculate GROUP BY without sorting */
|
|
234 |
key_map keys_in_use_for_group_by; |
|
235 |
/* Map of keys that can be used to calculate ORDER BY without sorting */
|
|
236 |
key_map keys_in_use_for_order_by; |
|
237 |
||
238 |
/*
|
|
239 |
For each key that has quick_keys.test(key) == true: estimate of #records
|
|
240 |
and max #key parts that range access would use.
|
|
241 |
*/
|
|
242 |
ha_rows quick_rows[MAX_KEY]; |
|
243 |
||
244 |
/* Bitmaps of key parts that =const for the entire join. */
|
|
245 |
key_part_map const_key_parts[MAX_KEY]; |
|
246 |
||
247 |
uint32_t quick_key_parts[MAX_KEY]; |
|
248 |
uint32_t quick_n_ranges[MAX_KEY]; |
|
249 |
||
1
by brian
clean slate |
250 |
MEM_ROOT mem_root; |
327.2.3
by Brian Aker
Refactoring of class Table |
251 |
filesort_info_st sort; |
1
by brian
clean slate |
252 |
|
1030.1.2
by Brian Aker
More alignment for structures |
253 |
|
1014.2.8
by Monty Taylor
Less fail. |
254 |
Table() |
1014.2.9
by Monty Taylor
Merged trunk. |
255 |
: s(NULL), field(NULL), |
256 |
file(NULL), next(NULL), prev(NULL), |
|
257 |
read_set(NULL), write_set(NULL), |
|
1014.2.10
by Monty Taylor
Made REGINFO into RegInfo and responsible for initializing itself. |
258 |
tablenr(0), db_stat(0), |
1014.2.9
by Monty Taylor
Merged trunk. |
259 |
bitmap_init_value(NULL), |
260 |
/* TODO: ensure that MY_BITMAP has a constructor for def_read_set, def_write_set and tmp_set */
|
|
261 |
in_use(NULL), |
|
262 |
write_row_record(NULL), insert_values(NULL), key_info(NULL), |
|
1014.2.8
by Monty Taylor
Less fail. |
263 |
next_number_field(NULL), found_next_number_field(NULL), |
1014.2.9
by Monty Taylor
Merged trunk. |
264 |
timestamp_field(NULL), |
265 |
pos_in_table_list(NULL), group(NULL), alias(NULL), null_flags(NULL), |
|
1014.2.8
by Monty Taylor
Less fail. |
266 |
lock_position(0), lock_data_start(0), lock_count(0), |
1014.2.9
by Monty Taylor
Merged trunk. |
267 |
used_fields(0), temp_pool_slot(0), |
1014.2.8
by Monty Taylor
Less fail. |
268 |
status(0), derived_select_number(0), current_lock(F_UNLCK), |
269 |
copy_blobs(false), maybe_null(false), null_row(false), |
|
270 |
force_index(false), distinct(false), const_table(false), |
|
271 |
no_rows(false), key_read(false), no_keyread(false), |
|
1014.2.9
by Monty Taylor
Merged trunk. |
272 |
open_placeholder(false), locked_by_name(false), no_cache(false), |
1014.2.8
by Monty Taylor
Less fail. |
273 |
auto_increment_field_not_null(false), insert_or_update(false), |
1014.2.9
by Monty Taylor
Merged trunk. |
274 |
alias_name_used(false), get_fields_in_item_tree(false), |
275 |
query_id(0), quick_condition_rows(0), |
|
276 |
timestamp_field_type(TIMESTAMP_NO_AUTO_SET), map(0) |
|
1039.1.10
by Brian Aker
Minor formating, change of one name to make grep easier :) |
277 |
{
|
1014.2.8
by Monty Taylor
Less fail. |
278 |
memset(record, 0, sizeof(unsigned char *) * 2); |
1014.2.9
by Monty Taylor
Merged trunk. |
279 |
|
280 |
covering_keys.reset(); |
|
281 |
||
282 |
quick_keys.reset(); |
|
283 |
merge_keys.reset(); |
|
284 |
||
285 |
keys_in_use_for_query.reset(); |
|
286 |
keys_in_use_for_group_by.reset(); |
|
287 |
keys_in_use_for_order_by.reset(); |
|
288 |
||
1014.2.8
by Monty Taylor
Less fail. |
289 |
memset(quick_rows, 0, sizeof(query_id_t) * MAX_KEY); |
290 |
memset(const_key_parts, 0, sizeof(ha_rows) * MAX_KEY); |
|
1014.2.9
by Monty Taylor
Merged trunk. |
291 |
|
1014.2.8
by Monty Taylor
Less fail. |
292 |
memset(quick_key_parts, 0, sizeof(unsigned int) * MAX_KEY); |
293 |
memset(quick_n_ranges, 0, sizeof(unsigned int) * MAX_KEY); |
|
1014.2.9
by Monty Taylor
Merged trunk. |
294 |
|
295 |
init_sql_alloc(&mem_root, TABLE_ALLOC_BLOCK_SIZE, 0); |
|
1014.2.8
by Monty Taylor
Less fail. |
296 |
memset(&sort, 0, sizeof(filesort_info_st)); |
297 |
}
|
|
327.1.1
by Brian Aker
First pass in encapsulating table (it is now an object, no longer a structure). |
298 |
|
1039.1.10
by Brian Aker
Minor formating, change of one name to make grep easier :) |
299 |
void resetTable(Session *session, TableShare *share, uint32_t db_stat_arg) |
1014.2.7
by Monty Taylor
First malloc(Table) stab (doesn't work) |
300 |
{
|
1014.2.8
by Monty Taylor
Less fail. |
301 |
|
1014.2.9
by Monty Taylor
Merged trunk. |
302 |
s= share; |
303 |
field= NULL; |
|
304 |
||
1014.2.8
by Monty Taylor
Less fail. |
305 |
file= NULL; |
306 |
next= NULL; |
|
307 |
prev= NULL; |
|
1014.2.9
by Monty Taylor
Merged trunk. |
308 |
|
309 |
read_set= NULL; |
|
310 |
write_set= NULL; |
|
311 |
||
312 |
tablenr= 0; |
|
313 |
db_stat= db_stat_arg; |
|
314 |
||
315 |
bitmap_init_value= NULL; |
|
316 |
||
317 |
in_use= session; |
|
318 |
memset(record, 0, sizeof(unsigned char *) * 2); |
|
319 |
||
1014.2.8
by Monty Taylor
Less fail. |
320 |
write_row_record= NULL; |
321 |
insert_values= NULL; |
|
322 |
key_info= NULL; |
|
323 |
next_number_field= NULL; |
|
324 |
found_next_number_field= NULL; |
|
325 |
timestamp_field= NULL; |
|
1014.2.9
by Monty Taylor
Merged trunk. |
326 |
|
1014.2.8
by Monty Taylor
Less fail. |
327 |
pos_in_table_list= NULL; |
328 |
group= NULL; |
|
329 |
alias= NULL; |
|
330 |
null_flags= NULL; |
|
331 |
||
332 |
lock_position= 0; |
|
333 |
lock_data_start= 0; |
|
334 |
lock_count= 0; |
|
335 |
used_fields= 0; |
|
336 |
temp_pool_slot= 0; |
|
337 |
status= 0; |
|
338 |
derived_select_number= 0; |
|
339 |
current_lock= F_UNLCK; |
|
340 |
copy_blobs= false; |
|
1014.2.9
by Monty Taylor
Merged trunk. |
341 |
|
1014.2.8
by Monty Taylor
Less fail. |
342 |
maybe_null= false; |
1014.2.9
by Monty Taylor
Merged trunk. |
343 |
|
1014.2.8
by Monty Taylor
Less fail. |
344 |
null_row= false; |
1014.2.9
by Monty Taylor
Merged trunk. |
345 |
|
1014.2.8
by Monty Taylor
Less fail. |
346 |
force_index= false; |
347 |
distinct= false; |
|
348 |
const_table= false; |
|
349 |
no_rows= false; |
|
350 |
key_read= false; |
|
351 |
no_keyread= false; |
|
1014.2.9
by Monty Taylor
Merged trunk. |
352 |
|
1014.2.8
by Monty Taylor
Less fail. |
353 |
open_placeholder= false; |
354 |
locked_by_name= false; |
|
355 |
no_cache= false; |
|
1014.2.9
by Monty Taylor
Merged trunk. |
356 |
|
1014.2.8
by Monty Taylor
Less fail. |
357 |
auto_increment_field_not_null= false; |
358 |
insert_or_update= false; |
|
359 |
alias_name_used= false; |
|
360 |
get_fields_in_item_tree= false; |
|
361 |
||
1014.2.9
by Monty Taylor
Merged trunk. |
362 |
query_id= 0; |
363 |
quick_condition_rows= 0; |
|
364 |
||
365 |
timestamp_field_type= TIMESTAMP_NO_AUTO_SET; |
|
366 |
map= 0; |
|
367 |
||
1014.2.10
by Monty Taylor
Made REGINFO into RegInfo and responsible for initializing itself. |
368 |
reginfo.reset(); |
1014.2.8
by Monty Taylor
Less fail. |
369 |
|
1014.2.9
by Monty Taylor
Merged trunk. |
370 |
covering_keys.reset(); |
1014.2.8
by Monty Taylor
Less fail. |
371 |
|
1014.2.7
by Monty Taylor
First malloc(Table) stab (doesn't work) |
372 |
quick_keys.reset(); |
1014.2.9
by Monty Taylor
Merged trunk. |
373 |
merge_keys.reset(); |
374 |
||
1014.2.7
by Monty Taylor
First malloc(Table) stab (doesn't work) |
375 |
keys_in_use_for_query.reset(); |
1014.2.9
by Monty Taylor
Merged trunk. |
376 |
keys_in_use_for_group_by.reset(); |
377 |
keys_in_use_for_order_by.reset(); |
|
1014.2.7
by Monty Taylor
First malloc(Table) stab (doesn't work) |
378 |
|
1014.2.8
by Monty Taylor
Less fail. |
379 |
memset(quick_rows, 0, sizeof(query_id_t) * MAX_KEY); |
380 |
memset(const_key_parts, 0, sizeof(ha_rows) * MAX_KEY); |
|
1014.2.9
by Monty Taylor
Merged trunk. |
381 |
|
1014.2.8
by Monty Taylor
Less fail. |
382 |
memset(quick_key_parts, 0, sizeof(unsigned int) * MAX_KEY); |
383 |
memset(quick_n_ranges, 0, sizeof(unsigned int) * MAX_KEY); |
|
1014.2.9
by Monty Taylor
Merged trunk. |
384 |
|
385 |
init_sql_alloc(&mem_root, TABLE_ALLOC_BLOCK_SIZE, 0); |
|
1014.2.8
by Monty Taylor
Less fail. |
386 |
memset(&sort, 0, sizeof(filesort_info_st)); |
1014.2.9
by Monty Taylor
Merged trunk. |
387 |
|
1014.2.8
by Monty Taylor
Less fail. |
388 |
|
1014.2.7
by Monty Taylor
First malloc(Table) stab (doesn't work) |
389 |
}
|
1030.1.2
by Brian Aker
More alignment for structures |
390 |
|
1030.1.1
by Brian Aker
Straighten out structures (remove some some dead bits). |
391 |
/* SHARE methods */
|
392 |
inline TableShare *getShare() { return s; } /* Get rid of this long term */ |
|
393 |
inline void setShare(TableShare *new_share) { s= new_share; } /* Get rid of this long term */ |
|
394 |
inline uint32_t sizeKeys() { return s->keys; } |
|
395 |
inline uint32_t sizeFields() { return s->fields; } |
|
396 |
inline uint32_t getRecordLength() { return s->reclength; } |
|
397 |
inline uint32_t sizeBlobFields() { return s->blob_fields; } |
|
398 |
inline uint32_t *getBlobField() { return s->blob_field; } |
|
399 |
inline uint32_t getNullBytes() { return s->null_bytes; } |
|
400 |
inline uint32_t getNullFields() { return s->null_fields; } |
|
401 |
inline unsigned char *getDefaultValues() { return s->default_values; } |
|
402 |
||
403 |
inline bool isDatabaseLowByteFirst() { return s->db_low_byte_first; } /* Portable row format */ |
|
404 |
inline bool isCrashed() { return s->crashed; } |
|
405 |
inline bool isNameLock() { return s->name_lock; } |
|
406 |
inline bool isReplaceWithNameLock() { return s->replace_with_name_lock; } |
|
407 |
inline bool isWaitingOnCondition() { return s->waiting_on_cond; } /* Protection against free */ |
|
408 |
||
409 |
/* For TMP tables, should be pulled out as a class */
|
|
410 |
void updateCreateInfo(HA_CREATE_INFO *create_info); |
|
411 |
void setup_tmp_table_column_bitmaps(unsigned char *bitmaps); |
|
412 |
bool create_myisam_tmp_table(KEY *keyinfo, |
|
413 |
MI_COLUMNDEF *start_recinfo, |
|
414 |
MI_COLUMNDEF **recinfo, |
|
415 |
uint64_t options); |
|
416 |
void free_tmp_table(Session *session); |
|
417 |
bool open_tmp_table(); |
|
418 |
size_t max_row_length(const unsigned char *data); |
|
419 |
uint32_t find_shortest_key(const key_map *usable_keys); |
|
420 |
bool compare_record(Field **ptr); |
|
421 |
bool compare_record(); |
|
422 |
/* TODO: the (re)storeRecord's may be able to be further condensed */
|
|
423 |
void storeRecord(); |
|
424 |
void storeRecordAsInsert(); |
|
425 |
void storeRecordAsDefault(); |
|
426 |
void restoreRecord(); |
|
427 |
void restoreRecordAsDefault(); |
|
428 |
void emptyRecord(); |
|
429 |
bool table_check_intact(const uint32_t table_f_count, const TABLE_FIELD_W_TYPE *table_def); |
|
430 |
||
431 |
/* See if this can be blown away */
|
|
432 |
inline uint32_t getDBStat () { return db_stat; } |
|
433 |
inline uint32_t setDBStat () { return db_stat; } |
|
1
by brian
clean slate |
434 |
bool fill_item_list(List<Item> *item_list) const; |
435 |
void clear_column_bitmaps(void); |
|
436 |
void prepare_for_position(void); |
|
1005.2.3
by Monty Taylor
Further reversion of P. |
437 |
void mark_columns_used_by_index_no_reset(uint32_t index, MY_BITMAP *map); |
1003.1.7
by Brian Aker
Add mark_columns_used_by_index_no_reset() with just index (assumes read_set |
438 |
void mark_columns_used_by_index_no_reset(uint32_t index); |
482
by Brian Aker
Remove uint. |
439 |
void mark_columns_used_by_index(uint32_t index); |
1
by brian
clean slate |
440 |
void restore_column_maps_after_mark_index(); |
441 |
void mark_auto_increment_column(void); |
|
442 |
void mark_columns_needed_for_update(void); |
|
443 |
void mark_columns_needed_for_delete(void); |
|
444 |
void mark_columns_needed_for_insert(void); |
|
1005.2.3
by Monty Taylor
Further reversion of P. |
445 |
inline void column_bitmaps_set(MY_BITMAP *read_set_arg, |
446 |
MY_BITMAP *write_set_arg) |
|
1
by brian
clean slate |
447 |
{
|
448 |
read_set= read_set_arg; |
|
449 |
write_set= write_set_arg; |
|
450 |
}
|
|
354
by Brian Aker
Refactor of Table methods. |
451 |
|
1005.2.3
by Monty Taylor
Further reversion of P. |
452 |
void restore_column_map(my_bitmap_map *old); |
354
by Brian Aker
Refactor of Table methods. |
453 |
|
1005.2.3
by Monty Taylor
Further reversion of P. |
454 |
my_bitmap_map *use_all_columns(MY_BITMAP *bitmap); |
1
by brian
clean slate |
455 |
inline void use_all_columns() |
456 |
{
|
|
457 |
column_bitmaps_set(&s->all_set, &s->all_set); |
|
458 |
}
|
|
354
by Brian Aker
Refactor of Table methods. |
459 |
|
1
by brian
clean slate |
460 |
inline void default_column_bitmaps() |
461 |
{
|
|
462 |
read_set= &def_read_set; |
|
463 |
write_set= &def_write_set; |
|
464 |
}
|
|
354
by Brian Aker
Refactor of Table methods. |
465 |
|
1003.1.12
by Brian Aker
Begin of abstract out the bitmap from direct reference. |
466 |
/* Both of the below should go away once we can move this bit to the field objects */
|
467 |
inline bool isReadSet(uint32_t index) |
|
468 |
{
|
|
1005.2.5
by Monty Taylor
Merged with trunk. |
469 |
return bitmap_is_set(read_set, index); |
1003.1.12
by Brian Aker
Begin of abstract out the bitmap from direct reference. |
470 |
}
|
471 |
||
472 |
inline void setReadSet(uint32_t index) |
|
473 |
{
|
|
1005.2.5
by Monty Taylor
Merged with trunk. |
474 |
bitmap_set_bit(read_set, index); |
1003.1.12
by Brian Aker
Begin of abstract out the bitmap from direct reference. |
475 |
}
|
476 |
||
1005.2.12
by Monty Taylor
Moved some things to the API. |
477 |
inline void setReadSet() |
478 |
{
|
|
479 |
bitmap_set_all(read_set); |
|
480 |
}
|
|
481 |
||
1003.1.12
by Brian Aker
Begin of abstract out the bitmap from direct reference. |
482 |
inline bool isWriteSet(uint32_t index) |
483 |
{
|
|
1005.2.5
by Monty Taylor
Merged with trunk. |
484 |
return bitmap_is_set(write_set, index); |
1003.1.12
by Brian Aker
Begin of abstract out the bitmap from direct reference. |
485 |
}
|
486 |
||
487 |
inline void setWriteSet(uint32_t index) |
|
488 |
{
|
|
1005.2.5
by Monty Taylor
Merged with trunk. |
489 |
bitmap_set_bit(write_set, index); |
1003.1.12
by Brian Aker
Begin of abstract out the bitmap from direct reference. |
490 |
}
|
491 |
||
1005.2.12
by Monty Taylor
Moved some things to the API. |
492 |
inline void setWriteSet() |
493 |
{
|
|
494 |
bitmap_set_all(write_set); |
|
495 |
}
|
|
496 |
||
1
by brian
clean slate |
497 |
/* Is table open or should be treated as such by name-locking? */
|
498 |
inline bool is_name_opened() { return db_stat || open_placeholder; } |
|
499 |
/*
|
|
500 |
Is this instance of the table should be reopen or represents a name-lock?
|
|
501 |
*/
|
|
502 |
inline bool needs_reopen_or_name_lock() |
|
503 |
{ return s->version != refresh_version; } |
|
354
by Brian Aker
Refactor of Table methods. |
504 |
|
934.1.1
by Brian Aker
Moved two functions in classes. |
505 |
/**
|
506 |
clean/setup table fields and map.
|
|
507 |
||
508 |
@param table Table structure pointer (which should be setup)
|
|
509 |
@param table_list TableList structure pointer (owner of Table)
|
|
510 |
@param tablenr table number
|
|
511 |
*/
|
|
512 |
void setup_table_map(TableList *table_list, uint32_t tablenr); |
|
513 |
inline void mark_as_null_row() |
|
514 |
{
|
|
515 |
null_row=1; |
|
516 |
status|=STATUS_NULL_ROW; |
|
517 |
memset(null_flags, 255, s->null_bytes); |
|
518 |
}
|
|
519 |
||
1
by brian
clean slate |
520 |
};
|
521 |
||
575.4.7
by Monty Taylor
More header cleanup. |
522 |
Table *create_virtual_tmp_table(Session *session, |
523 |
List<Create_field> &field_list); |
|
524 |
||
1
by brian
clean slate |
525 |
typedef struct st_foreign_key_info |
526 |
{
|
|
527 |
LEX_STRING *forein_id; |
|
528 |
LEX_STRING *referenced_db; |
|
529 |
LEX_STRING *referenced_table; |
|
530 |
LEX_STRING *update_method; |
|
531 |
LEX_STRING *delete_method; |
|
532 |
LEX_STRING *referenced_key_name; |
|
533 |
List<LEX_STRING> foreign_fields; |
|
534 |
List<LEX_STRING> referenced_fields; |
|
535 |
} FOREIGN_KEY_INFO; |
|
536 |
||
537 |
typedef struct st_field_info |
|
538 |
{
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
539 |
/**
|
540 |
This is used as column name.
|
|
1
by brian
clean slate |
541 |
*/
|
542 |
const char* field_name; |
|
543 |
/**
|
|
544 |
For string-type columns, this is the maximum number of
|
|
545 |
characters. Otherwise, it is the 'display-length' for the column.
|
|
546 |
*/
|
|
482
by Brian Aker
Remove uint. |
547 |
uint32_t field_length; |
1
by brian
clean slate |
548 |
/**
|
549 |
This denotes data type for the column. For the most part, there seems to
|
|
550 |
be one entry in the enum for each SQL data type, although there seem to
|
|
551 |
be a number of additional entries in the enum.
|
|
552 |
*/
|
|
553 |
enum enum_field_types field_type; |
|
554 |
int value; |
|
555 |
/**
|
|
556 |
This is used to set column attributes. By default, columns are @c NOT
|
|
557 |
@c NULL and @c SIGNED, and you can deviate from the default
|
|
558 |
by setting the appopriate flags. You can use either one of the flags
|
|
559 |
@c MY_I_S_MAYBE_NULL and @cMY_I_S_UNSIGNED or
|
|
560 |
combine them using the bitwise or operator @c |. Both flags are
|
|
561 |
defined in table.h.
|
|
562 |
*/
|
|
482
by Brian Aker
Remove uint. |
563 |
uint32_t field_flags; // Field atributes(maybe_null, signed, unsigned etc.) |
1
by brian
clean slate |
564 |
const char* old_name; |
565 |
/**
|
|
566 |
This should be one of @c SKIP_OPEN_TABLE,
|
|
567 |
@c OPEN_FRM_ONLY or @c OPEN_FULL_TABLE.
|
|
568 |
*/
|
|
482
by Brian Aker
Remove uint. |
569 |
uint32_t open_method; |
1
by brian
clean slate |
570 |
} ST_FIELD_INFO; |
571 |
||
572 |
||
327.2.4
by Brian Aker
Refactoring table.h |
573 |
class TableList; |
1
by brian
clean slate |
574 |
typedef class Item COND; |
575 |
||
971.1.68
by Monty Taylor
Renamed ST_SCHEMA_TABLE to InfoSchemaTable. One step down towards making the darned thing a class. (/me shudders) |
576 |
struct InfoSchemaTable |
1
by brian
clean slate |
577 |
{
|
578 |
const char* table_name; |
|
579 |
ST_FIELD_INFO *fields_info; |
|
580 |
/* Create information_schema table */
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
581 |
Table *(*create_table) (Session *session, TableList *table_list); |
1
by brian
clean slate |
582 |
/* Fill table with data */
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
583 |
int (*fill_table) (Session *session, TableList *tables, COND *cond); |
1
by brian
clean slate |
584 |
/* Handle fileds for old SHOW */
|
971.1.68
by Monty Taylor
Renamed ST_SCHEMA_TABLE to InfoSchemaTable. One step down towards making the darned thing a class. (/me shudders) |
585 |
int (*old_format) (Session *session, struct InfoSchemaTable *schema_table); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
586 |
int (*process_table) (Session *session, TableList *tables, Table *table, |
1
by brian
clean slate |
587 |
bool res, LEX_STRING *db_name, LEX_STRING *table_name); |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
588 |
int idx_field1, idx_field2; |
1
by brian
clean slate |
589 |
bool hidden; |
482
by Brian Aker
Remove uint. |
590 |
uint32_t i_s_requested_object; /* the object we need to open(Table | VIEW) */ |
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
591 |
};
|
1
by brian
clean slate |
592 |
|
593 |
||
594 |
#define JOIN_TYPE_LEFT 1
|
|
595 |
#define JOIN_TYPE_RIGHT 2
|
|
596 |
||
597 |
struct st_lex; |
|
598 |
class select_union; |
|
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
599 |
class Tmp_Table_Param; |
1
by brian
clean slate |
600 |
|
601 |
typedef struct st_changed_table_list |
|
602 |
{
|
|
603 |
struct st_changed_table_list *next; |
|
604 |
char *key; |
|
1046.1.6
by Brian Aker
Formatting/style cleanup. |
605 |
uint32_t key_length; |
327.2.4
by Brian Aker
Refactoring table.h |
606 |
} CHANGED_TableList; |
1
by brian
clean slate |
607 |
|
608 |
||
352
by Brian Aker
Merge of Brian's tree to main tree. |
609 |
typedef struct st_open_table_list |
610 |
{
|
|
1
by brian
clean slate |
611 |
struct st_open_table_list *next; |
1046.1.6
by Brian Aker
Formatting/style cleanup. |
612 |
char *db; |
613 |
char *table; |
|
205
by Brian Aker
uint32 -> uin32_t |
614 |
uint32_t in_use,locked; |
327.2.4
by Brian Aker
Refactoring table.h |
615 |
} OPEN_TableList; |
1
by brian
clean slate |
616 |
|
327.2.3
by Brian Aker
Refactoring of class Table |
617 |
|
327.1.2
by Brian Aker
Commiting next pass of Table class cleanup. |
618 |
#endif /* DRIZZLED_TABLE_H */ |