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