23
23
#ifndef DRIZZLED_TABLE_H
24
24
#define DRIZZLED_TABLE_H
26
#include <storage/myisam/myisam.h>
27
#include <drizzled/order.h>
28
#include <drizzled/filesort_info.h>
29
#include <drizzled/natural_join_column.h>
30
#include <drizzled/nested_join.h>
31
#include <drizzled/field_iterator.h>
33
class Item; /* Needed by order_st */
26
#include <plugin/myisam/myisam.h>
27
#include <mysys/hash.h>
28
#include <mysys/my_bitmap.h>
29
#include "drizzled/order.h"
30
#include "drizzled/filesort_info.h"
31
#include "drizzled/natural_join_column.h"
32
#include "drizzled/field_iterator.h"
33
#include "drizzled/handler.h"
34
#include "drizzled/lex_string.h"
35
#include "drizzled/table_list.h"
36
#include "drizzled/table_share.h"
34
43
class Item_subselect;
35
class st_select_lex_unit;
44
class Select_Lex_Unit;
38
47
class Security_context;
41
/*************************************************************************/
45
NO_TMP_TABLE, NON_TRANSACTIONAL_TMP_TABLE, TRANSACTIONAL_TMP_TABLE,
46
INTERNAL_TMP_TABLE, SYSTEM_TMP_TABLE, TMP_TABLE_FRM_FILE_ONLY
49
bool mysql_frm_type(THD *thd, char *path, enum legacy_db_type *dbt);
52
enum release_type { RELEASE_NORMAL, RELEASE_WAIT_FOR_DROP };
55
Values in this enum are used to indicate how a tables TIMESTAMP field
56
should be treated. It can be set to the current timestamp on insert or
58
WARNING: The values are used for bit operations. If you change the
59
enum, you must keep the bitwise relation of the values. For example:
60
(int) TIMESTAMP_AUTO_SET_ON_BOTH must be equal to
61
(int) TIMESTAMP_AUTO_SET_ON_INSERT | (int) TIMESTAMP_AUTO_SET_ON_UPDATE.
62
We use an enum here so that the debugger can display the value names.
64
enum timestamp_auto_set_type
66
TIMESTAMP_NO_AUTO_SET= 0, TIMESTAMP_AUTO_SET_ON_INSERT= 1,
67
TIMESTAMP_AUTO_SET_ON_UPDATE= 2, TIMESTAMP_AUTO_SET_ON_BOTH= 3
69
#define clear_timestamp_auto_bits(_target_, _bits_) \
70
(_target_)= (enum timestamp_auto_set_type)((int)(_target_) & ~(int)(_bits_))
72
49
class Field_timestamp;
76
Category of table found in the table share.
78
enum enum_table_category
83
TABLE_UNKNOWN_CATEGORY=0,
87
The table is visible only in the session.
89
- FLUSH TABLES WITH READ LOCK
90
- SET GLOBAL READ_ONLY = ON
91
do not apply to this table.
92
Note that LOCK Table t FOR READ/WRITE
93
can be used on temporary tables.
94
Temporary tables are not part of the table cache.
96
TABLE_CATEGORY_TEMPORARY=1,
100
These tables do honor:
101
- LOCK Table t FOR READ/WRITE
102
- FLUSH TABLES WITH READ LOCK
103
- SET GLOBAL READ_ONLY = ON
104
User tables are cached in the table cache.
106
TABLE_CATEGORY_USER=2,
109
Information schema tables.
110
These tables are an interface provided by the system
111
to inspect the system metadata.
112
These tables do *not* honor:
113
- LOCK Table t FOR READ/WRITE
114
- FLUSH TABLES WITH READ LOCK
115
- SET GLOBAL READ_ONLY = ON
116
as there is no point in locking explicitely
117
an INFORMATION_SCHEMA table.
118
Nothing is directly written to information schema tables.
119
Note that this value is not used currently,
120
since information schema tables are not shared,
121
but implemented as session specific temporary tables.
124
TODO: Fixing the performance issues of I_S will lead
125
to I_S tables in the table cache, which should use
128
TABLE_CATEGORY_INFORMATION
130
52
typedef enum enum_table_category TABLE_CATEGORY;
132
TABLE_CATEGORY get_table_category(const LEX_STRING *db,
133
const LEX_STRING *name);
136
This structure is shared between different table objects. There is one
137
instance of table share per one table in the database.
140
typedef struct st_table_share
142
st_table_share() {} /* Remove gcc warning */
144
/** Category of this table. */
145
TABLE_CATEGORY table_category;
147
/* hash of field names (contains pointers to elements of field array) */
148
HASH name_hash; /* hash of field names */
150
TYPELIB keynames; /* Pointers to keynames */
151
TYPELIB fieldnames; /* Pointer to fieldnames */
152
TYPELIB *intervals; /* pointer to interval info */
153
pthread_mutex_t mutex; /* For locking the share */
154
pthread_cond_t cond; /* To signal that share is ready */
155
struct st_table_share *next, /* Link to unused shares */
158
/* The following is copied to each Table on OPEN */
160
Field **found_next_number_field;
161
Field *timestamp_field; /* Used only during open */
162
KEY *key_info; /* data of keys in database */
163
uint *blob_field; /* Index to blobs in Field arrray*/
165
unsigned char *default_values; /* row with default values */
166
LEX_STRING comment; /* Comment about table */
167
const CHARSET_INFO *table_charset; /* Default charset of string fields */
171
Key which is used for looking-up table in table cache and in the list
172
of thread's temporary tables. Has the form of:
173
"database_name\0table_name\0" + optional part for temporary tables.
175
Note that all three 'table_cache_key', 'db' and 'table_name' members
176
must be set (and be non-zero) for tables in table cache. They also
177
should correspond to each other.
178
To ensure this one can use set_table_cache() methods.
180
LEX_STRING table_cache_key;
181
LEX_STRING db; /* Pointer to db */
182
LEX_STRING table_name; /* Table name (for open) */
183
LEX_STRING path; /* Path to .frm file (from datadir) */
184
LEX_STRING normalized_path; /* unpack_filename(path) */
185
LEX_STRING connect_string;
188
Set of keys in use, implemented as a Bitmap.
189
Excludes keys disabled by ALTER Table ... DISABLE KEYS.
192
key_map keys_for_keyread;
193
ha_rows min_rows, max_rows; /* create information */
194
uint32_t avg_row_length; /* create information */
195
uint32_t block_size; /* create information */
196
uint32_t version, mysql_version;
197
uint32_t timestamp_offset; /* Set to offset+1 of record */
198
uint32_t reclength; /* Recordlength */
200
plugin_ref db_plugin; /* storage engine plugin */
201
inline handlerton *db_type() const /* table_type for handler */
203
// assert(db_plugin);
204
return db_plugin ? plugin_data(db_plugin, handlerton*) : NULL;
206
enum row_type row_type; /* How rows are stored */
207
enum tmp_table_type tmp_table;
208
enum ha_choice transactional;
209
enum ha_choice page_checksum;
211
uint32_t ref_count; /* How many Table objects uses this */
212
uint32_t open_count; /* Number of tables in open list */
213
uint32_t blob_ptr_size; /* 4 or 8 */
214
uint32_t key_block_size; /* create key_block_size, if used */
215
uint32_t null_bytes, last_null_bit_pos;
216
uint32_t fields; /* Number of fields */
217
uint32_t rec_buff_length; /* Size of table->record[] buffer */
218
uint32_t keys, key_parts;
219
uint32_t max_key_length, max_unique_length, total_key_length;
220
uint32_t uniques; /* Number of UNIQUE index */
221
uint32_t null_fields; /* number of null fields */
222
uint32_t blob_fields; /* number of blob fields */
223
uint32_t timestamp_field_offset; /* Field number for timestamp field */
224
uint32_t varchar_fields; /* number of varchar fields */
225
uint32_t db_create_options; /* Create options from database */
226
uint32_t db_options_in_use; /* Options in use */
227
uint32_t db_record_offset; /* if HA_REC_IN_SEQ */
228
uint32_t rowid_field_offset; /* Field_nr +1 to rowid field */
229
/* Index of auto-updated TIMESTAMP field in field array */
230
uint32_t primary_key;
231
uint32_t next_number_index; /* autoincrement key number */
232
uint32_t next_number_key_offset; /* autoinc keypart offset in a key */
233
uint32_t next_number_keypart; /* autoinc keypart number in a key */
234
uint32_t error, open_errno, errarg; /* error from open_table_def() */
235
uint32_t column_bitmap_size;
236
unsigned char frm_version;
237
bool null_field_first;
238
bool db_low_byte_first; /* Portable row format */
240
bool name_lock, replace_with_name_lock;
241
bool waiting_on_cond; /* Protection against free */
242
uint32_t table_map_id; /* for row-based replication */
243
uint64_t table_map_version;
246
Cache for row-based replication table share checks that does not
247
need to be repeated. Possible values are: -1 when cache value is
248
not calculated yet, 0 when table *shall not* be replicated, 1 when
249
table *may* be replicated.
251
int cached_row_logging_check;
254
Set share's table cache key and update its db and table name appropriately.
257
set_table_cache_key()
258
key_buff Buffer with already built table cache key to be
259
referenced from share.
260
key_length Key length.
263
Since 'key_buff' buffer will be referenced from share it should has same
264
life-time as share itself.
265
This method automatically ensures that TABLE_SHARE::table_name/db have
266
appropriate values by using table cache key as their source.
269
void set_table_cache_key(char *key_buff, uint32_t key_length)
271
table_cache_key.str= key_buff;
272
table_cache_key.length= key_length;
274
Let us use the fact that the key is "db/0/table_name/0" + optional
275
part for temporary tables.
277
db.str= table_cache_key.str;
278
db.length= strlen(db.str);
279
table_name.str= db.str + db.length + 1;
280
table_name.length= strlen(table_name.str);
285
Set share's table cache key and update its db and table name appropriately.
288
set_table_cache_key()
289
key_buff Buffer to be used as storage for table cache key
290
(should be at least key_length bytes).
291
key Value for table cache key.
292
key_length Key length.
295
Since 'key_buff' buffer will be used as storage for table cache key
296
it should has same life-time as share itself.
299
void set_table_cache_key(char *key_buff, const char *key, uint32_t key_length)
301
memcpy(key_buff, key, key_length);
302
set_table_cache_key(key_buff, key_length);
305
inline bool honor_global_locks()
307
return (table_category == TABLE_CATEGORY_USER);
310
inline uint32_t get_table_def_version()
318
extern uint32_t refresh_version;
320
/* Information for one open table */
328
typedef struct st_table_field_w_type
333
} TABLE_FIELD_W_TYPE;
335
bool create_myisam_from_heap(THD *thd, Table *table,
54
bool create_myisam_from_heap(Session *session, Table *table,
336
55
MI_COLUMNDEF *start_recinfo,
337
MI_COLUMNDEF **recinfo,
56
MI_COLUMNDEF **recinfo,
338
57
int error, bool ignore_last_dupp_key_error);
60
* Class representing a set of records, either in a temporary,
61
* normal, or derived table.
344
Table() {} /* Remove gcc warning */
347
inline TABLE_SHARE *getShare() { return s; } /* Get rid of this long term */
348
inline void setShare(TABLE_SHARE *new_share) { s= new_share; } /* Get rid of this long term */
349
inline uint32_t sizeKeys() { return s->keys; }
350
inline uint32_t sizeFields() { return s->fields; }
351
inline uint32_t getRecordLength() { return s->reclength; }
352
inline uint32_t sizeBlobFields() { return s->blob_fields; }
353
inline uint32_t *getBlobField() { return s->blob_field; }
354
inline uint32_t getNullBytes() { return s->null_bytes; }
355
inline uint32_t getNullFields() { return s->null_fields; }
356
inline unsigned char *getDefaultValues() { return s->default_values; }
358
inline bool isNullFieldFirst() { return s->null_field_first; }
359
inline bool isDatabaseLowByteFirst() { return s->db_low_byte_first; } /* Portable row format */
360
inline bool isCrashed() { return s->crashed; }
361
inline bool isNameLock() { return s->name_lock; }
362
inline bool isReplaceWithNameLock() { return s->replace_with_name_lock; }
363
inline bool isWaitingOnCondition() { return s->waiting_on_cond; } /* Protection against free */
365
/* For TMP tables, should be pulled out as a class */
366
void updateCreateInfo(HA_CREATE_INFO *create_info);
367
void setup_tmp_table_column_bitmaps(unsigned char *bitmaps);
368
bool create_myisam_tmp_table(KEY *keyinfo,
369
MI_COLUMNDEF *start_recinfo,
370
MI_COLUMNDEF **recinfo,
372
void free_tmp_table(THD *thd);
373
bool open_tmp_table();
374
size_t max_row_length(const unsigned char *data);
375
uint32_t find_shortest_key(const key_map *usable_keys);
376
bool compare_record(Field **ptr);
377
bool compare_record();
379
bool table_check_intact(const uint32_t table_f_count, const TABLE_FIELD_W_TYPE *table_def);
381
/* See if this can be blown away */
382
inline uint32_t getDBStat () { return db_stat; }
383
inline uint32_t setDBStat () { return db_stat; }
384
uint db_stat; /* mode of file as in handler.h */
389
THD *in_use; /* Which thread uses this */
390
Field **field; /* Pointer to fields */
392
unsigned char *record[2]; /* Pointer to records */
393
unsigned char *write_row_record; /* Used as optimisation in
395
unsigned char *insert_values; /* used by INSERT ... UPDATE */
397
Map of keys that can be used to retrieve all data from this table
398
needed by the query without reading the row.
400
key_map covering_keys;
401
key_map quick_keys, merge_keys;
403
A set of keys that can be used in the query that references this
406
All indexes disabled on the table's TABLE_SHARE (see Table::s) will be
407
subtracted from this set upon instantiation. Thus for any Table t it holds
408
that t.keys_in_use_for_query is a subset of t.s.keys_in_use. Generally we
409
must not introduce any new keys here (see setup_tables).
411
The set is implemented as a bitmap.
413
key_map keys_in_use_for_query;
414
/* Map of keys that can be used to calculate GROUP BY without sorting */
415
key_map keys_in_use_for_group_by;
416
/* Map of keys that can be used to calculate ORDER BY without sorting */
417
key_map keys_in_use_for_order_by;
418
KEY *key_info; /* data of keys in database */
420
Field *next_number_field; /* Set if next_number is activated */
421
Field *found_next_number_field; /* Set on open */
422
Field_timestamp *timestamp_field;
424
TableList *pos_in_table_list;/* Element referring to this table */
67
TableShare *s; /**< Pointer to the shared metadata about the table */
68
Field **field; /**< Pointer to fields collection */
70
handler *file; /**< Pointer to the storage engine's handler managing this table */
74
MyBitmap *read_set; /* Active column sets */
75
MyBitmap *write_set; /* Active column sets */
78
uint32_t db_stat; /**< information about the file as in handler.h */
80
MyBitmap def_read_set; /**< Default read set of columns */
81
MyBitmap def_write_set; /**< Default write set of columns */
82
MyBitmap tmp_set; /* Not sure about this... */
84
Session *in_use; /**< Pointer to the current session using this object */
86
unsigned char *record[2]; /**< Pointer to "records" */
87
unsigned char *insert_values; /* used by INSERT ... UPDATE */
88
KEY *key_info; /**< data of keys in database */
89
Field *next_number_field; /**< Set if next_number is activated. @TODO What the heck is the difference between this and the next member? */
90
Field *found_next_number_field; /**< Points to the "next-number" field (autoincrement field) */
91
Field_timestamp *timestamp_field; /**< Points to the auto-setting timestamp field, if any */
93
TableList *pos_in_table_list; /* Element referring to this table */
426
const char *alias; /* alias or table name */
427
unsigned char *null_flags;
428
my_bitmap_map *bitmap_init_value;
429
MY_BITMAP def_read_set, def_write_set, tmp_set; /* containers */
430
MY_BITMAP *read_set, *write_set; /* Active column sets */
432
The ID of the query that opened and is using this table. Has different
433
meanings depending on the table type.
437
table->query_id is set to thd->query_id for the duration of a statement
438
and is reset to 0 once it is closed by the same statement. A non-zero
439
table->query_id means that a statement is using the table even if it's
440
not the current statement (table is in use by some outer statement).
442
Non-temporary tables:
444
Under pre-locked or LOCK TABLES mode: query_id is set to thd->query_id
445
for the duration of a statement and is reset to 0 once it is closed by
446
the same statement. A non-zero query_id is used to control which tables
447
in the list of pre-opened and locked tables are actually being used.
452
For each key that has quick_keys.is_set(key) == true: estimate of #records
453
and max #key parts that range access would use.
455
ha_rows quick_rows[MAX_KEY];
457
/* Bitmaps of key parts that =const for the entire join. */
458
key_part_map const_key_parts[MAX_KEY];
460
uint quick_key_parts[MAX_KEY];
461
uint quick_n_ranges[MAX_KEY];
464
Estimate of number of records that satisfy SARGable part of the table
465
condition, or table->file->records if no SARGable condition could be
467
This value is used by join optimizer as an estimate of number of records
468
that will pass the table condition (condition that depends on fields of
469
this table and constants)
471
ha_rows quick_condition_rows;
474
If this table has TIMESTAMP field with auto-set property (pointed by
475
timestamp_field member) then this variable indicates during which
476
operations (insert only/on update/in both cases) we should set this
477
field to current timestamp. If there are no such field in this table
478
or we should not automatically set its value during execution of current
479
statement then the variable contains TIMESTAMP_NO_AUTO_SET (i.e. 0).
481
Value of this variable is set for each statement in open_table() and
482
if needed cleared later in statement processing code (see mysql_update()
485
timestamp_auto_set_type timestamp_field_type;
486
table_map map; /* ID bit of table (1,2,4,8,16...) */
488
uint32_t lock_position; /* Position in DRIZZLE_LOCK.table */
489
uint32_t lock_data_start; /* Start pos. in DRIZZLE_LOCK.locks */
490
uint32_t lock_count; /* Number of locks */
491
uint tablenr,used_fields;
492
uint32_t temp_pool_slot; /* Used by intern temp tables */
493
uint status; /* What's in record[0] */
95
const char *alias; /**< alias or table name if no alias */
96
unsigned char *null_flags;
98
uint32_t lock_position; /**< Position in DRIZZLE_LOCK.table */
99
uint32_t lock_data_start; /**< Start pos. in DRIZZLE_LOCK.locks */
100
uint32_t lock_count; /**< Number of locks */
101
uint32_t used_fields;
102
uint32_t status; /* What's in record[0] */
494
103
/* number of select if it is derived table */
495
uint32_t derived_select_number;
496
int current_lock; /* Type of lock on table */
497
bool copy_blobs; /* copy_blobs when storing */
104
uint32_t derived_select_number;
105
int current_lock; /**< Type of lock on table */
106
bool copy_blobs; /**< Should blobs by copied when storing? */
500
109
0 or JOIN_TYPE_{LEFT|RIGHT}. Currently this is only compared to 0.
530
140
not rely on that.
532
142
bool open_placeholder;
533
bool locked_by_logger;
535
143
bool locked_by_name;
537
/* To signal that the table is associated with a HANDLER statement */
538
bool open_by_handler;
540
146
To indicate that a non-null value of the auto_increment field
541
147
was provided by the user or retrieved from the current record.
542
148
Used only in the MODE_NO_AUTO_VALUE_ON_ZERO mode.
544
150
bool auto_increment_field_not_null;
545
bool insert_or_update; /* Can be used by the handler */
546
bool alias_name_used; /* true if table_name is alias */
547
bool get_fields_in_item_tree; /* Signal to fix_field */
549
REGINFO reginfo; /* field connections */
151
bool alias_name_used; /* true if table_name is alias */
154
The ID of the query that opened and is using this table. Has different
155
meanings depending on the table type.
159
table->query_id is set to session->query_id for the duration of a statement
160
and is reset to 0 once it is closed by the same statement. A non-zero
161
table->query_id means that a statement is using the table even if it's
162
not the current statement (table is in use by some outer statement).
164
Non-temporary tables:
166
Under pre-locked or LOCK TABLES mode: query_id is set to session->query_id
167
for the duration of a statement and is reset to 0 once it is closed by
168
the same statement. A non-zero query_id is used to control which tables
169
in the list of pre-opened and locked tables are actually being used.
174
Estimate of number of records that satisfy SARGable part of the table
175
condition, or table->file->records if no SARGable condition could be
177
This value is used by join optimizer as an estimate of number of records
178
that will pass the table condition (condition that depends on fields of
179
this table and constants)
181
ha_rows quick_condition_rows;
184
If this table has TIMESTAMP field with auto-set property (pointed by
185
timestamp_field member) then this variable indicates during which
186
operations (insert only/on update/in both cases) we should set this
187
field to current timestamp. If there are no such field in this table
188
or we should not automatically set its value during execution of current
189
statement then the variable contains TIMESTAMP_NO_AUTO_SET (i.e. 0).
191
Value of this variable is set for each statement in open_table() and
192
if needed cleared later in statement processing code (see mysql_update()
195
timestamp_auto_set_type timestamp_field_type;
196
table_map map; /* ID bit of table (1,2,4,8,16...) */
198
RegInfo reginfo; /* field connections */
201
Map of keys that can be used to retrieve all data from this table
202
needed by the query without reading the row.
204
key_map covering_keys;
209
A set of keys that can be used in the query that references this
212
All indexes disabled on the table's TableShare (see Table::s) will be
213
subtracted from this set upon instantiation. Thus for any Table t it holds
214
that t.keys_in_use_for_query is a subset of t.s.keys_in_use. Generally we
215
must not introduce any new keys here (see setup_tables).
217
The set is implemented as a bitmap.
219
key_map keys_in_use_for_query;
220
/* Map of keys that can be used to calculate GROUP BY without sorting */
221
key_map keys_in_use_for_group_by;
222
/* Map of keys that can be used to calculate ORDER BY without sorting */
223
key_map keys_in_use_for_order_by;
226
For each key that has quick_keys.test(key) == true: estimate of #records
227
and max #key parts that range access would use.
229
ha_rows quick_rows[MAX_KEY];
231
/* Bitmaps of key parts that =const for the entire join. */
232
key_part_map const_key_parts[MAX_KEY];
234
uint32_t quick_key_parts[MAX_KEY];
235
uint32_t quick_n_ranges[MAX_KEY];
550
237
MEM_ROOT mem_root;
551
238
filesort_info_st sort;
253
next_number_field(NULL),
254
found_next_number_field(NULL),
255
timestamp_field(NULL),
256
pos_in_table_list(NULL),
265
derived_select_number(0),
266
current_lock(F_UNLCK),
276
open_placeholder(false),
277
locked_by_name(false),
279
auto_increment_field_not_null(false),
280
alias_name_used(false),
282
quick_condition_rows(0),
283
timestamp_field_type(TIMESTAMP_NO_AUTO_SET),
286
record[0]= (unsigned char *) 0;
287
record[1]= (unsigned char *) 0;
289
covering_keys.reset();
294
keys_in_use_for_query.reset();
295
keys_in_use_for_group_by.reset();
296
keys_in_use_for_order_by.reset();
298
memset(quick_rows, 0, sizeof(query_id_t) * MAX_KEY);
299
memset(const_key_parts, 0, sizeof(ha_rows) * MAX_KEY);
301
memset(quick_key_parts, 0, sizeof(unsigned int) * MAX_KEY);
302
memset(quick_n_ranges, 0, sizeof(unsigned int) * MAX_KEY);
304
init_sql_alloc(&mem_root, TABLE_ALLOC_BLOCK_SIZE, 0);
305
memset(&sort, 0, sizeof(filesort_info_st));
308
int report_error(int error);
309
int closefrm(bool free_share);
311
void resetTable(Session *session, TableShare *share, uint32_t db_stat_arg)
324
db_stat= db_stat_arg;
327
record[0]= (unsigned char *) 0;
328
record[1]= (unsigned char *) 0;
332
next_number_field= NULL;
333
found_next_number_field= NULL;
334
timestamp_field= NULL;
336
pos_in_table_list= NULL;
346
derived_select_number= 0;
347
current_lock= F_UNLCK;
361
open_placeholder= false;
362
locked_by_name= false;
365
auto_increment_field_not_null= false;
366
alias_name_used= false;
369
quick_condition_rows= 0;
371
timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
376
covering_keys.reset();
381
keys_in_use_for_query.reset();
382
keys_in_use_for_group_by.reset();
383
keys_in_use_for_order_by.reset();
385
memset(quick_rows, 0, sizeof(query_id_t) * MAX_KEY);
386
memset(const_key_parts, 0, sizeof(ha_rows) * MAX_KEY);
388
memset(quick_key_parts, 0, sizeof(unsigned int) * MAX_KEY);
389
memset(quick_n_ranges, 0, sizeof(unsigned int) * MAX_KEY);
391
init_sql_alloc(&mem_root, TABLE_ALLOC_BLOCK_SIZE, 0);
392
memset(&sort, 0, sizeof(filesort_info_st));
396
inline TableShare *getShare() { return s; } /* Get rid of this long term */
397
inline void setShare(TableShare *new_share) { s= new_share; } /* Get rid of this long term */
398
inline uint32_t sizeKeys() { return s->keys; }
399
inline uint32_t sizeFields() { return s->fields; }
400
inline uint32_t getRecordLength() { return s->reclength; }
401
inline uint32_t sizeBlobFields() { return s->blob_fields; }
402
inline uint32_t *getBlobField() { return s->blob_field; }
403
inline uint32_t getNullBytes() { return s->null_bytes; }
404
inline uint32_t getNullFields() { return s->null_fields; }
405
inline unsigned char *getDefaultValues() { return s->default_values; }
407
inline bool isDatabaseLowByteFirst() { return s->db_low_byte_first; } /* Portable row format */
408
inline bool isCrashed() { return s->crashed; }
409
inline bool isNameLock() { return s->name_lock; }
410
inline bool isReplaceWithNameLock() { return s->replace_with_name_lock; }
411
inline bool isWaitingOnCondition() { return s->waiting_on_cond; } /* Protection against free */
413
/* For TMP tables, should be pulled out as a class */
414
void updateCreateInfo(HA_CREATE_INFO *create_info,
415
drizzled::message::Table *table_proto);
416
void setup_tmp_table_column_bitmaps(unsigned char *bitmaps);
417
bool create_myisam_tmp_table(KEY *keyinfo,
418
MI_COLUMNDEF *start_recinfo,
419
MI_COLUMNDEF **recinfo,
421
void free_tmp_table(Session *session);
422
bool open_tmp_table();
423
size_t max_row_length(const unsigned char *data);
424
uint32_t find_shortest_key(const key_map *usable_keys);
425
bool compare_record(Field **ptr);
426
bool compare_record();
427
/* TODO: the (re)storeRecord's may be able to be further condensed */
429
void storeRecordAsInsert();
430
void storeRecordAsDefault();
431
void restoreRecord();
432
void restoreRecordAsDefault();
435
/* See if this can be blown away */
436
inline uint32_t getDBStat () { return db_stat; }
437
inline uint32_t setDBStat () { return db_stat; }
553
438
bool fill_item_list(List<Item> *item_list) const;
554
void reset_item_list(List<Item> *item_list) const;
555
439
void clear_column_bitmaps(void);
556
440
void prepare_for_position(void);
557
void mark_columns_used_by_index_no_reset(uint32_t index, MY_BITMAP *map);
441
void mark_columns_used_by_index_no_reset(uint32_t index, MyBitmap *map);
442
void mark_columns_used_by_index_no_reset(uint32_t index);
558
443
void mark_columns_used_by_index(uint32_t index);
559
444
void restore_column_maps_after_mark_index();
560
445
void mark_auto_increment_column(void);
561
446
void mark_columns_needed_for_update(void);
562
447
void mark_columns_needed_for_delete(void);
563
448
void mark_columns_needed_for_insert(void);
564
inline void column_bitmaps_set(MY_BITMAP *read_set_arg,
565
MY_BITMAP *write_set_arg)
567
read_set= read_set_arg;
568
write_set= write_set_arg;
570
file->column_bitmaps_signal();
572
inline void column_bitmaps_set_no_signal(MY_BITMAP *read_set_arg,
573
MY_BITMAP *write_set_arg)
575
read_set= read_set_arg;
576
write_set= write_set_arg;
449
inline void column_bitmaps_set(MyBitmap *read_set_arg,
450
MyBitmap *write_set_arg)
452
read_set= read_set_arg;
453
write_set= write_set_arg;
456
* Find field in table, no side effects, only purpose is to check for field
457
* in table object and get reference to the field if found.
459
* @param Name of field searched for
462
* 0 field is not found
464
* non-0 pointer to field
466
Field *find_field_in_table_sef(const char *name);
579
468
void restore_column_map(my_bitmap_map *old);
581
my_bitmap_map *use_all_columns(MY_BITMAP *bitmap);
470
my_bitmap_map *use_all_columns(MyBitmap *bitmap);
582
471
inline void use_all_columns()
584
473
column_bitmaps_set(&s->all_set, &s->all_set);