18
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
/* Structs that defines the Table */
23
#ifndef DRIZZLED_TABLE_H
24
#define DRIZZLED_TABLE_H
26
#include <storage/myisam/myisam.h>
24
#include <boost/dynamic_bitset.hpp>
27
26
#include <drizzled/order.h>
28
27
#include <drizzled/filesort_info.h>
29
28
#include <drizzled/natural_join_column.h>
30
29
#include <drizzled/field_iterator.h>
31
#include <mysys/hash.h>
32
#include <drizzled/handler.h>
30
#include <drizzled/cursor.h>
33
31
#include <drizzled/lex_string.h>
34
#include <drizzled/table_list.h>
38
class st_select_lex_unit;
41
class Security_context;
44
/*************************************************************************/
47
class Field_timestamp;
50
typedef enum enum_table_category TABLE_CATEGORY;
52
TABLE_CATEGORY get_table_category(const LEX_STRING *db,
53
const LEX_STRING *name);
56
This structure is shared between different table objects. There is one
57
instance of table share per one table in the database.
60
typedef struct st_table_share
62
st_table_share() {} /* Remove gcc warning */
64
/** Category of this table. */
65
TABLE_CATEGORY table_category;
67
/* hash of field names (contains pointers to elements of field array) */
68
HASH name_hash; /* hash of field names */
70
TYPELIB keynames; /* Pointers to keynames */
71
TYPELIB fieldnames; /* Pointer to fieldnames */
72
TYPELIB *intervals; /* pointer to interval info */
73
pthread_mutex_t mutex; /* For locking the share */
74
pthread_cond_t cond; /* To signal that share is ready */
75
struct st_table_share *next, /* Link to unused shares */
78
/* The following is copied to each Table on OPEN */
80
Field **found_next_number_field;
81
Field *timestamp_field; /* Used only during open */
82
KEY *key_info; /* data of keys in database */
83
uint *blob_field; /* Index to blobs in Field arrray*/
85
unsigned char *default_values; /* row with default values */
86
LEX_STRING comment; /* Comment about table */
87
const CHARSET_INFO *table_charset; /* Default charset of string fields */
91
Key which is used for looking-up table in table cache and in the list
92
of thread's temporary tables. Has the form of:
93
"database_name\0table_name\0" + optional part for temporary tables.
95
Note that all three 'table_cache_key', 'db' and 'table_name' members
96
must be set (and be non-zero) for tables in table cache. They also
97
should correspond to each other.
98
To ensure this one can use set_table_cache() methods.
100
LEX_STRING table_cache_key;
101
LEX_STRING db; /* Pointer to db */
102
LEX_STRING table_name; /* Table name (for open) */
103
LEX_STRING path; /* Path to .frm file (from datadir) */
104
LEX_STRING normalized_path; /* unpack_filename(path) */
105
LEX_STRING connect_string;
108
Set of keys in use, implemented as a Bitmap.
109
Excludes keys disabled by ALTER Table ... DISABLE KEYS.
112
key_map keys_for_keyread;
113
ha_rows min_rows, max_rows; /* create information */
114
uint32_t avg_row_length; /* create information */
115
uint32_t block_size; /* create information */
116
uint32_t version, mysql_version;
117
uint32_t timestamp_offset; /* Set to offset+1 of record */
118
uint32_t reclength; /* Recordlength */
119
uint32_t stored_rec_length; /* Stored record length
120
(no generated-only virtual fields) */
122
plugin_ref db_plugin; /* storage engine plugin */
123
inline handlerton *db_type() const /* table_type for handler */
125
// assert(db_plugin);
126
return db_plugin ? plugin_data(db_plugin, handlerton*) : NULL;
128
enum row_type row_type; /* How rows are stored */
129
enum tmp_table_type tmp_table;
130
enum ha_choice transactional;
131
enum ha_choice page_checksum;
133
uint32_t ref_count; /* How many Table objects uses this */
134
uint32_t open_count; /* Number of tables in open list */
135
uint32_t blob_ptr_size; /* 4 or 8 */
136
uint32_t key_block_size; /* create key_block_size, if used */
137
uint32_t null_bytes, last_null_bit_pos;
138
uint32_t fields; /* Number of fields */
139
uint32_t stored_fields; /* Number of stored fields
140
(i.e. without generated-only ones) */
141
uint32_t rec_buff_length; /* Size of table->record[] buffer */
142
uint32_t keys, key_parts;
143
uint32_t max_key_length, max_unique_length, total_key_length;
144
uint32_t uniques; /* Number of UNIQUE index */
145
uint32_t null_fields; /* number of null fields */
146
uint32_t blob_fields; /* number of blob fields */
147
uint32_t timestamp_field_offset; /* Field number for timestamp field */
148
uint32_t varchar_fields; /* number of varchar fields */
149
uint32_t db_create_options; /* Create options from database */
150
uint32_t db_options_in_use; /* Options in use */
151
uint32_t db_record_offset; /* if HA_REC_IN_SEQ */
152
uint32_t rowid_field_offset; /* Field_nr +1 to rowid field */
153
/* Index of auto-updated TIMESTAMP field in field array */
154
uint32_t primary_key;
155
uint32_t next_number_index; /* autoincrement key number */
156
uint32_t next_number_key_offset; /* autoinc keypart offset in a key */
157
uint32_t next_number_keypart; /* autoinc keypart number in a key */
158
uint32_t error, open_errno, errarg; /* error from open_table_def() */
159
uint32_t column_bitmap_size;
161
uint32_t vfields; /* Number of virtual fields */
162
bool null_field_first;
163
bool db_low_byte_first; /* Portable row format */
165
bool name_lock, replace_with_name_lock;
166
bool waiting_on_cond; /* Protection against free */
167
uint32_t table_map_id; /* for row-based replication */
168
uint64_t table_map_version;
171
Cache for row-based replication table share checks that does not
172
need to be repeated. Possible values are: -1 when cache value is
173
not calculated yet, 0 when table *shall not* be replicated, 1 when
174
table *may* be replicated.
176
int cached_row_logging_check;
179
Set share's table cache key and update its db and table name appropriately.
182
set_table_cache_key()
183
key_buff Buffer with already built table cache key to be
184
referenced from share.
185
key_length Key length.
188
Since 'key_buff' buffer will be referenced from share it should has same
189
life-time as share itself.
190
This method automatically ensures that TABLE_SHARE::table_name/db have
191
appropriate values by using table cache key as their source.
194
void set_table_cache_key(char *key_buff, uint32_t key_length)
196
table_cache_key.str= key_buff;
197
table_cache_key.length= key_length;
199
Let us use the fact that the key is "db/0/table_name/0" + optional
200
part for temporary tables.
202
db.str= table_cache_key.str;
203
db.length= strlen(db.str);
204
table_name.str= db.str + db.length + 1;
205
table_name.length= strlen(table_name.str);
210
Set share's table cache key and update its db and table name appropriately.
213
set_table_cache_key()
214
key_buff Buffer to be used as storage for table cache key
215
(should be at least key_length bytes).
216
key Value for table cache key.
217
key_length Key length.
220
Since 'key_buff' buffer will be used as storage for table cache key
221
it should has same life-time as share itself.
224
void set_table_cache_key(char *key_buff, const char *key, uint32_t key_length)
226
memcpy(key_buff, key, key_length);
227
set_table_cache_key(key_buff, key_length);
230
inline bool honor_global_locks()
232
return (table_category == TABLE_CATEGORY_USER);
235
inline uint32_t get_table_def_version()
243
extern uint32_t refresh_version;
245
typedef struct st_table_field_w_type
250
} TABLE_FIELD_W_TYPE;
252
bool create_myisam_from_heap(Session *session, Table *table,
253
MI_COLUMNDEF *start_recinfo,
254
MI_COLUMNDEF **recinfo,
255
int error, bool ignore_last_dupp_key_error);
261
Table() {} /* Remove gcc warning */
264
inline TABLE_SHARE *getShare() { return s; } /* Get rid of this long term */
265
inline void setShare(TABLE_SHARE *new_share) { s= new_share; } /* Get rid of this long term */
266
inline uint32_t sizeKeys() { return s->keys; }
267
inline uint32_t sizeFields() { return s->fields; }
268
inline uint32_t getRecordLength() { return s->reclength; }
269
inline uint32_t sizeBlobFields() { return s->blob_fields; }
270
inline uint32_t *getBlobField() { return s->blob_field; }
271
inline uint32_t getNullBytes() { return s->null_bytes; }
272
inline uint32_t getNullFields() { return s->null_fields; }
273
inline unsigned char *getDefaultValues() { return s->default_values; }
275
inline bool isNullFieldFirst() { return s->null_field_first; }
276
inline bool isDatabaseLowByteFirst() { return s->db_low_byte_first; } /* Portable row format */
277
inline bool isCrashed() { return s->crashed; }
278
inline bool isNameLock() { return s->name_lock; }
279
inline bool isReplaceWithNameLock() { return s->replace_with_name_lock; }
280
inline bool isWaitingOnCondition() { return s->waiting_on_cond; } /* Protection against free */
282
/* For TMP tables, should be pulled out as a class */
283
void updateCreateInfo(HA_CREATE_INFO *create_info);
284
void setup_tmp_table_column_bitmaps(unsigned char *bitmaps);
285
bool create_myisam_tmp_table(KEY *keyinfo,
286
MI_COLUMNDEF *start_recinfo,
287
MI_COLUMNDEF **recinfo,
289
void free_tmp_table(Session *session);
290
bool open_tmp_table();
291
size_t max_row_length(const unsigned char *data);
292
uint32_t find_shortest_key(const key_map *usable_keys);
293
bool compare_record(Field **ptr);
294
bool compare_record();
296
bool table_check_intact(const uint32_t table_f_count, const TABLE_FIELD_W_TYPE *table_def);
298
/* See if this can be blown away */
299
inline uint32_t getDBStat () { return db_stat; }
300
inline uint32_t setDBStat () { return db_stat; }
301
uint db_stat; /* mode of file as in handler.h */
306
Session *in_use; /* Which thread uses this */
307
Field **field; /* Pointer to fields */
309
unsigned char *record[2]; /* Pointer to records */
310
unsigned char *write_row_record; /* Used as optimisation in
311
Session::write_row */
312
unsigned char *insert_values; /* used by INSERT ... UPDATE */
314
Map of keys that can be used to retrieve all data from this table
315
needed by the query without reading the row.
317
key_map covering_keys;
318
key_map quick_keys, merge_keys;
320
A set of keys that can be used in the query that references this
323
All indexes disabled on the table's TABLE_SHARE (see Table::s) will be
324
subtracted from this set upon instantiation. Thus for any Table t it holds
325
that t.keys_in_use_for_query is a subset of t.s.keys_in_use. Generally we
326
must not introduce any new keys here (see setup_tables).
328
The set is implemented as a bitmap.
330
key_map keys_in_use_for_query;
331
/* Map of keys that can be used to calculate GROUP BY without sorting */
332
key_map keys_in_use_for_group_by;
333
/* Map of keys that can be used to calculate ORDER BY without sorting */
334
key_map keys_in_use_for_order_by;
335
KEY *key_info; /* data of keys in database */
337
Field *next_number_field; /* Set if next_number is activated */
338
Field *found_next_number_field; /* Set on open */
339
Field_timestamp *timestamp_field;
340
Field **vfield; /* Pointer to virtual fields*/
342
TableList *pos_in_table_list;/* Element referring to this table */
344
const char *alias; /* alias or table name */
345
unsigned char *null_flags;
346
my_bitmap_map *bitmap_init_value;
347
MY_BITMAP def_read_set, def_write_set, tmp_set; /* containers */
348
MY_BITMAP *read_set, *write_set; /* Active column sets */
350
The ID of the query that opened and is using this table. Has different
351
meanings depending on the table type.
355
table->query_id is set to session->query_id for the duration of a statement
356
and is reset to 0 once it is closed by the same statement. A non-zero
357
table->query_id means that a statement is using the table even if it's
358
not the current statement (table is in use by some outer statement).
360
Non-temporary tables:
362
Under pre-locked or LOCK TABLES mode: query_id is set to session->query_id
363
for the duration of a statement and is reset to 0 once it is closed by
364
the same statement. A non-zero query_id is used to control which tables
365
in the list of pre-opened and locked tables are actually being used.
370
For each key that has quick_keys.is_set(key) == true: estimate of #records
371
and max #key parts that range access would use.
373
ha_rows quick_rows[MAX_KEY];
375
/* Bitmaps of key parts that =const for the entire join. */
376
key_part_map const_key_parts[MAX_KEY];
378
uint quick_key_parts[MAX_KEY];
379
uint quick_n_ranges[MAX_KEY];
382
Estimate of number of records that satisfy SARGable part of the table
383
condition, or table->file->records if no SARGable condition could be
385
This value is used by join optimizer as an estimate of number of records
386
that will pass the table condition (condition that depends on fields of
387
this table and constants)
389
ha_rows quick_condition_rows;
392
If this table has TIMESTAMP field with auto-set property (pointed by
393
timestamp_field member) then this variable indicates during which
394
operations (insert only/on update/in both cases) we should set this
395
field to current timestamp. If there are no such field in this table
396
or we should not automatically set its value during execution of current
397
statement then the variable contains TIMESTAMP_NO_AUTO_SET (i.e. 0).
399
Value of this variable is set for each statement in open_table() and
400
if needed cleared later in statement processing code (see mysql_update()
403
timestamp_auto_set_type timestamp_field_type;
404
table_map map; /* ID bit of table (1,2,4,8,16...) */
406
uint32_t lock_position; /* Position in DRIZZLE_LOCK.table */
407
uint32_t lock_data_start; /* Start pos. in DRIZZLE_LOCK.locks */
408
uint32_t lock_count; /* Number of locks */
409
uint tablenr,used_fields;
410
uint32_t temp_pool_slot; /* Used by intern temp tables */
411
uint status; /* What's in record[0] */
32
#include <drizzled/table/instance.h>
33
#include <drizzled/atomics.h>
35
#include <drizzled/visibility.h>
40
* Class representing a set of records, either in a temporary,
41
* normal, or derived table.
43
class DRIZZLED_API Table
45
Field **field; /**< Pointer to fields collection */
48
Field **getFields() const
53
Field *getField(uint32_t arg) const
58
void setFields(Field **arg)
63
void setFieldAt(Field *arg, uint32_t arg_pos)
68
Cursor *cursor; /**< Pointer to the storage engine's Cursor managing this table */
74
Table *getNext() const
84
void setNext(Table *arg)
91
getNext()->setPrev(getPrev()); /* remove from used chain */
92
getPrev()->setNext(getNext());
98
Table *getPrev() const
108
void setPrev(Table *arg)
113
boost::dynamic_bitset<> *read_set; /* Active column sets */
114
boost::dynamic_bitset<> *write_set; /* Active column sets */
117
uint32_t db_stat; /**< information about the cursor as in Cursor.h */
119
boost::dynamic_bitset<> def_read_set; /**< Default read set of columns */
120
boost::dynamic_bitset<> def_write_set; /**< Default write set of columns */
121
boost::dynamic_bitset<> tmp_set; /* Not sure about this... */
123
Session *in_use; /**< Pointer to the current session using this object */
124
Session *getSession()
129
unsigned char *getInsertRecord() const
134
unsigned char *getUpdateRecord()
139
unsigned char *record[2]; /**< Pointer to "records" */
140
std::vector<unsigned char> insert_values; /* used by INSERT ... UPDATE */
141
KeyInfo *key_info; /**< data of keys in database */
142
Field *next_number_field; /**< Set if next_number is activated. @TODO What the heck is the difference between this and the next member? */
143
Field *found_next_number_field; /**< Points to the "next-number" field (autoincrement field) */
144
field::Epoch *timestamp_field; /**< Points to the auto-setting timestamp field, if any */
146
TableList *pos_in_table_list; /* Element referring to this table */
149
const char *getAlias() const
151
return _alias.c_str();
159
void setAlias(const char *arg)
165
std::string _alias; /**< alias or table name if no alias */
168
unsigned char *null_flags;
170
uint32_t lock_position; /**< Position in DRIZZLE_LOCK.table */
171
uint32_t lock_data_start; /**< Start pos. in DRIZZLE_LOCK.locks */
172
uint32_t lock_count; /**< Number of locks */
173
uint32_t used_fields;
174
uint32_t status; /* What's in getInsertRecord() */
412
175
/* number of select if it is derived table */
413
uint32_t derived_select_number;
414
int current_lock; /* Type of lock on table */
415
bool copy_blobs; /* copy_blobs when storing */
176
uint32_t derived_select_number;
177
int current_lock; /**< Type of lock on table */
178
bool copy_blobs; /**< Should blobs by copied when storing? */
418
181
0 or JOIN_TYPE_{LEFT|RIGHT}. Currently this is only compared to 0.
443
209
- setting version to 0 - this will force other threads to close
444
210
the instance of this table and wait (this is the same approach
445
211
as used for usual name locks).
446
An exclusively name-locked table currently can have no handler
212
An exclusively name-locked table currently can have no Cursor
447
213
object associated with it (db_stat is always 0), but please do
448
214
not rely on that.
450
216
bool open_placeholder;
451
bool locked_by_logger;
453
217
bool locked_by_name;
455
/* To signal that the table is associated with a HANDLER statement */
456
bool open_by_handler;
458
220
To indicate that a non-null value of the auto_increment field
459
221
was provided by the user or retrieved from the current record.
460
222
Used only in the MODE_NO_AUTO_VALUE_ON_ZERO mode.
462
224
bool auto_increment_field_not_null;
463
bool insert_or_update; /* Can be used by the handler */
464
bool alias_name_used; /* true if table_name is alias */
465
bool get_fields_in_item_tree; /* Signal to fix_field */
467
REGINFO reginfo; /* field connections */
469
filesort_info_st sort;
471
bool fill_item_list(List<Item> *item_list) const;
472
void reset_item_list(List<Item> *item_list) const;
225
bool alias_name_used; /* true if table_name is alias */
228
The ID of the query that opened and is using this table. Has different
229
meanings depending on the table type.
233
table->query_id is set to session->query_id for the duration of a statement
234
and is reset to 0 once it is closed by the same statement. A non-zero
235
table->query_id means that a statement is using the table even if it's
236
not the current statement (table is in use by some outer statement).
238
Non-temporary tables:
240
Under pre-locked or LOCK TABLES mode: query_id is set to session->query_id
241
for the duration of a statement and is reset to 0 once it is closed by
242
the same statement. A non-zero query_id is used to control which tables
243
in the list of pre-opened and locked tables are actually being used.
248
* Estimate of number of records that satisfy SARGable part of the table
249
* condition, or table->cursor->records if no SARGable condition could be
251
* This value is used by join optimizer as an estimate of number of records
252
* that will pass the table condition (condition that depends on fields of
253
* this table and constants)
255
ha_rows quick_condition_rows;
258
If this table has TIMESTAMP field with auto-set property (pointed by
259
timestamp_field member) then this variable indicates during which
260
operations (insert only/on update/in both cases) we should set this
261
field to current timestamp. If there are no such field in this table
262
or we should not automatically set its value during execution of current
263
statement then the variable contains TIMESTAMP_NO_AUTO_SET (i.e. 0).
265
Value of this variable is set for each statement in open_table() and
266
if needed cleared later in statement processing code (see update_query()
269
timestamp_auto_set_type timestamp_field_type;
270
table_map map; ///< ID bit of table (1,2,4,8,16...)
272
RegInfo reginfo; /* field connections */
275
Map of keys that can be used to retrieve all data from this table
276
needed by the query without reading the row.
278
key_map covering_keys;
283
A set of keys that can be used in the query that references this
286
All indexes disabled on the table's TableShare (see Table::s) will be
287
subtracted from this set upon instantiation. Thus for any Table t it holds
288
that t.keys_in_use_for_query is a subset of t.s.keys_in_use. Generally we
289
must not introduce any new keys here (see setup_tables).
291
The set is implemented as a bitmap.
293
key_map keys_in_use_for_query;
295
/* Map of keys that can be used to calculate GROUP BY without sorting */
296
key_map keys_in_use_for_group_by;
298
/* Map of keys that can be used to calculate ORDER BY without sorting */
299
key_map keys_in_use_for_order_by;
302
For each key that has quick_keys.test(key) == true: estimate of #records
303
and max #key parts that range access would use.
305
ha_rows quick_rows[MAX_KEY];
307
/* Bitmaps of key parts that =const for the entire join. */
308
key_part_map const_key_parts[MAX_KEY];
310
uint32_t quick_key_parts[MAX_KEY];
311
uint32_t quick_n_ranges[MAX_KEY];
314
memory::Root mem_root;
318
if (not mem_root.alloc_root_inited())
319
mem_root.init(TABLE_ALLOC_BLOCK_SIZE);
328
unsigned char* alloc(size_t arg)
331
return mem_root.alloc(arg);
334
char* strdup(const char* str_arg, size_t len_arg)
337
return mem_root.strdup(str_arg, len_arg);
345
int report_error(int error);
347
* Free information allocated by openfrm
349
* @param If true if we also want to free table_share
350
* @note this should all be the destructor
352
int delete_table(bool free_share= false);
354
void resetTable(Session *session, TableShare *share, uint32_t db_stat_arg);
357
virtual const TableShare *getShare() const= 0; /* Get rid of this long term */
358
virtual TableShare *getMutableShare()= 0; /* Get rid of this long term */
359
virtual bool hasShare() const= 0; /* Get rid of this long term */
360
virtual void setShare(TableShare *new_share)= 0; /* Get rid of this long term */
362
virtual void release(void)= 0;
364
uint32_t sizeKeys() { return getMutableShare()->sizeKeys(); }
365
uint32_t sizeFields() { return getMutableShare()->sizeFields(); }
366
uint32_t getRecordLength() const { return getShare()->getRecordLength(); }
367
uint32_t sizeBlobFields() { return getMutableShare()->blob_fields; }
368
uint32_t *getBlobField() { return &getMutableShare()->blob_field[0]; }
371
virtual bool hasVariableWidth() const
373
return getShare()->hasVariableWidth(); // We should calculate this.
376
virtual void setVariableWidth(void);
378
Field_blob *getBlobFieldAt(uint32_t arg) const
380
if (arg < getShare()->blob_fields)
381
return (Field_blob*) field[getShare()->blob_field[arg]]; /*NOTE: Using 'Table.field' NOT SharedTable.field. */
385
inline uint8_t getBlobPtrSize() const { return getShare()->sizeBlobPtr(); }
386
inline uint32_t getNullBytes() const { return getShare()->null_bytes; }
387
inline uint32_t getNullFields() const { return getShare()->null_fields; }
388
inline unsigned char *getDefaultValues() { return getMutableShare()->getDefaultValues(); }
389
inline const char *getSchemaName() const { return getShare()->getSchemaName(); }
390
inline const char *getTableName() const { return getShare()->getTableName(); }
392
inline bool isDatabaseLowByteFirst() const { return getShare()->db_low_byte_first; } /* Portable row format */
393
inline bool isNameLock() const { return open_placeholder; }
395
uint32_t index_flags(uint32_t idx) const;
397
inline plugin::StorageEngine *getEngine() const /* table_type for handler */
399
return getShare()->getEngine();
402
Cursor &getCursor() const /* table_type for handler */
408
size_t max_row_length(const unsigned char *data);
409
uint32_t find_shortest_key(const key_map *usable_keys);
410
bool compare_record(Field **ptr);
411
bool records_are_comparable();
412
bool compare_records();
413
/* TODO: the (re)storeRecord's may be able to be further condensed */
415
void storeRecordAsInsert();
416
void storeRecordAsDefault();
417
void restoreRecord();
418
void restoreRecordAsDefault();
422
/* See if this can be blown away */
423
inline uint32_t getDBStat () const { return db_stat; }
426
* Create Item_field for each column in the table.
428
* @param[out] a pointer to an empty list used to store items
432
* Create Item_field object for each column in the table and
433
* initialize it with the corresponding Field. New items are
434
* created in the current Session memory root.
439
* true when out of memory
441
void fill_item_list(List<Item>&) const;
473
442
void clear_column_bitmaps(void);
474
443
void prepare_for_position(void);
475
void mark_columns_used_by_index_no_reset(uint32_t index, MY_BITMAP *map);
444
void mark_columns_used_by_index_no_reset(uint32_t index, boost::dynamic_bitset<>& bitmap);
445
void mark_columns_used_by_index_no_reset(uint32_t index);
476
446
void mark_columns_used_by_index(uint32_t index);
477
447
void restore_column_maps_after_mark_index();
478
448
void mark_auto_increment_column(void);
479
449
void mark_columns_needed_for_update(void);
480
450
void mark_columns_needed_for_delete(void);
481
451
void mark_columns_needed_for_insert(void);
482
void mark_virtual_columns(void);
483
inline void column_bitmaps_set(MY_BITMAP *read_set_arg,
484
MY_BITMAP *write_set_arg)
486
read_set= read_set_arg;
487
write_set= write_set_arg;
489
file->column_bitmaps_signal();
491
inline void column_bitmaps_set_no_signal(MY_BITMAP *read_set_arg,
492
MY_BITMAP *write_set_arg)
494
read_set= read_set_arg;
495
write_set= write_set_arg;
498
void restore_column_map(my_bitmap_map *old);
500
my_bitmap_map *use_all_columns(MY_BITMAP *bitmap);
452
void column_bitmaps_set(boost::dynamic_bitset<>& read_set_arg,
453
boost::dynamic_bitset<>& write_set_arg);
455
void restore_column_map(const boost::dynamic_bitset<>& old);
457
const boost::dynamic_bitset<> use_all_columns(boost::dynamic_bitset<>& map);
501
458
inline void use_all_columns()
503
column_bitmaps_set(&s->all_set, &s->all_set);
460
column_bitmaps_set(getMutableShare()->all_set, getMutableShare()->all_set);
506
463
inline void default_column_bitmaps()
509
466
write_set= &def_write_set;
469
/* Both of the below should go away once we can move this bit to the field objects */
470
inline bool isReadSet(uint32_t index) const
472
return read_set->test(index);
475
inline void setReadSet(uint32_t index)
477
read_set->set(index);
480
inline void setReadSet()
485
inline void clearReadSet(uint32_t index)
487
read_set->reset(index);
490
inline void clearReadSet()
495
inline bool isWriteSet(uint32_t index)
497
return write_set->test(index);
500
inline void setWriteSet(uint32_t index)
502
write_set->set(index);
505
inline void setWriteSet()
510
inline void clearWriteSet(uint32_t index)
512
write_set->reset(index);
515
inline void clearWriteSet()
512
520
/* Is table open or should be treated as such by name-locking? */
513
inline bool is_name_opened() { return db_stat || open_placeholder; }
521
bool is_name_opened() const
523
return db_stat || open_placeholder;
515
527
Is this instance of the table should be reopen or represents a name-lock?
517
inline bool needs_reopen_or_name_lock()
518
{ return s->version != refresh_version; }
520
int report_error(int error);
523
Table *create_virtual_tmp_table(Session *session,
524
List<Create_field> &field_list);
526
typedef struct st_foreign_key_info
528
LEX_STRING *forein_id;
529
LEX_STRING *referenced_db;
530
LEX_STRING *referenced_table;
531
LEX_STRING *update_method;
532
LEX_STRING *delete_method;
533
LEX_STRING *referenced_key_name;
534
List<LEX_STRING> foreign_fields;
535
List<LEX_STRING> referenced_fields;
538
typedef struct st_field_info
541
This is used as column name.
543
const char* field_name;
545
For string-type columns, this is the maximum number of
546
characters. Otherwise, it is the 'display-length' for the column.
548
uint32_t field_length;
550
This denotes data type for the column. For the most part, there seems to
551
be one entry in the enum for each SQL data type, although there seem to
552
be a number of additional entries in the enum.
554
enum enum_field_types field_type;
557
This is used to set column attributes. By default, columns are @c NOT
558
@c NULL and @c SIGNED, and you can deviate from the default
559
by setting the appopriate flags. You can use either one of the flags
560
@c MY_I_S_MAYBE_NULL and @cMY_I_S_UNSIGNED or
561
combine them using the bitwise or operator @c |. Both flags are
564
uint32_t field_flags; // Field atributes(maybe_null, signed, unsigned etc.)
565
const char* old_name;
567
This should be one of @c SKIP_OPEN_TABLE,
568
@c OPEN_FRM_ONLY or @c OPEN_FULL_TABLE.
570
uint32_t open_method;
575
typedef class Item COND;
577
struct ST_SCHEMA_TABLE
579
const char* table_name;
580
ST_FIELD_INFO *fields_info;
581
/* Create information_schema table */
582
Table *(*create_table) (Session *session, TableList *table_list);
583
/* Fill table with data */
584
int (*fill_table) (Session *session, TableList *tables, COND *cond);
585
/* Handle fileds for old SHOW */
586
int (*old_format) (Session *session, struct ST_SCHEMA_TABLE *schema_table);
587
int (*process_table) (Session *session, TableList *tables, Table *table,
588
bool res, LEX_STRING *db_name, LEX_STRING *table_name);
589
int idx_field1, idx_field2;
591
uint32_t i_s_requested_object; /* the object we need to open(Table | VIEW) */
595
#define JOIN_TYPE_LEFT 1
596
#define JOIN_TYPE_RIGHT 2
600
class TMP_TABLE_PARAM;
602
struct Field_translator
609
typedef struct st_changed_table_list
611
struct st_changed_table_list *next;
617
typedef struct st_open_table_list
619
struct st_open_table_list *next;
621
uint32_t in_use,locked;
625
inline void mark_as_null_row(Table *table)
628
table->status|=STATUS_NULL_ROW;
629
memset(table->null_flags, 255, table->s->null_bytes);
529
bool needs_reopen_or_name_lock() const;
532
clean/setup table fields and map.
534
@param table Table structure pointer (which should be setup)
535
@param table_list TableList structure pointer (owner of Table)
536
@param tablenr table number
538
void setup_table_map(TableList *table_list, uint32_t tablenr);
539
inline void mark_as_null_row()
542
status|= STATUS_NULL_ROW;
543
memset(null_flags, 255, getShare()->null_bytes);
546
void free_io_cache();
547
void filesort_free_buffers(bool full= false);
548
void intern_close_table();
550
void print_error(int error, myf errflag) const;
554
key if error because of duplicated keys
556
uint32_t get_dup_key(int error) const
558
cursor->errkey = (uint32_t) -1;
559
if (error == HA_ERR_FOUND_DUPP_KEY || error == HA_ERR_FOREIGN_DUPLICATE_KEY ||
560
error == HA_ERR_FOUND_DUPP_UNIQUE ||
561
error == HA_ERR_DROP_INDEX_FK)
562
cursor->info(HA_STATUS_ERRKEY | HA_STATUS_NO_LOCK);
564
return(cursor->errkey);
568
This is a short term fix. Long term we will used the TableIdentifier to do the actual comparison.
570
bool operator<(const Table &right) const
572
return getShare()->getCacheKey() < right.getShare()->getCacheKey();
575
static bool compare(const Table *a, const Table *b)
580
friend std::ostream& operator<<(std::ostream& output, const Table &table)
582
if (table.getShare())
585
output << table.getShare()->getSchemaName();
587
output << table.getShare()->getTableName();
589
output << table.getShare()->getTableTypeAsString();
594
output << "Table:(has no share)";
597
return output; // for multiple << operators.
601
virtual bool isPlaceHolder(void) const
633
clean/setup table fields and map.
635
@param table Table structure pointer (which should be setup)
636
@param table_list TableList structure pointer (owner of Table)
637
@param tablenr table number
639
void setup_table_map(Table *table, TableList *table_list, uint32_t tablenr);
641
#endif /* DRIZZLED_TABLE_H */
612
* This class defines the information for foreign keys.
619
* This is the constructor with all properties set.
621
* @param[in] in_foreign_id The id of the foreign key
622
* @param[in] in_referenced_db The referenced database name of the foreign key
623
* @param[in] in_referenced_table The referenced table name of the foreign key
624
* @param[in] in_update_method The update method of the foreign key.
625
* @param[in] in_delete_method The delete method of the foreign key.
626
* @param[in] in_referenced_key_name The name of referenced key
627
* @param[in] in_foreign_fields The foreign fields
628
* @param[in] in_referenced_fields The referenced fields
630
ForeignKeyInfo(lex_string_t *in_foreign_id,
631
lex_string_t *in_referenced_db,
632
lex_string_t *in_referenced_table,
633
lex_string_t *in_update_method,
634
lex_string_t *in_delete_method,
635
lex_string_t *in_referenced_key_name,
636
List<lex_string_t> in_foreign_fields,
637
List<lex_string_t> in_referenced_fields)
639
foreign_id(in_foreign_id),
640
referenced_db(in_referenced_db),
641
referenced_table(in_referenced_table),
642
update_method(in_update_method),
643
delete_method(in_delete_method),
644
referenced_key_name(in_referenced_key_name),
645
foreign_fields(in_foreign_fields),
646
referenced_fields(in_referenced_fields)
651
* This is the default constructor. All properties are set to default values for their types.
654
: foreign_id(NULL), referenced_db(NULL), referenced_table(NULL),
655
update_method(NULL), delete_method(NULL), referenced_key_name(NULL)
660
* Gets the foreign id.
662
* @ retval the foreign id
664
const lex_string_t *getForeignId() const
671
* Gets the name of the referenced database.
673
* @ retval the name of the referenced database
675
const lex_string_t *getReferencedDb() const
677
return referenced_db;
682
* Gets the name of the referenced table.
684
* @ retval the name of the referenced table
686
const lex_string_t *getReferencedTable() const
688
return referenced_table;
693
* Gets the update method.
695
* @ retval the update method
697
const lex_string_t *getUpdateMethod() const
699
return update_method;
704
* Gets the delete method.
706
* @ retval the delete method
708
const lex_string_t *getDeleteMethod() const
710
return delete_method;
715
* Gets the name of the referenced key.
717
* @ retval the name of the referenced key
719
const lex_string_t *getReferencedKeyName() const
721
return referenced_key_name;
726
* Gets the foreign fields.
728
* @ retval the foreign fields
730
const List<lex_string_t> &getForeignFields() const
732
return foreign_fields;
737
* Gets the referenced fields.
739
* @ retval the referenced fields
741
const List<lex_string_t> &getReferencedFields() const
743
return referenced_fields;
749
lex_string_t *foreign_id;
751
* The name of the reference database.
753
lex_string_t *referenced_db;
755
* The name of the reference table.
757
lex_string_t *referenced_table;
761
lex_string_t *update_method;
765
lex_string_t *delete_method;
767
* The name of the referenced key.
769
lex_string_t *referenced_key_name;
771
* The foreign fields.
773
List<lex_string_t> foreign_fields;
775
* The referenced fields.
777
List<lex_string_t> referenced_fields;
780
#define JOIN_TYPE_LEFT 1
781
#define JOIN_TYPE_RIGHT 2
783
void free_blobs(Table *table);
784
int set_zone(int nr,int min_zone,int max_zone);
785
uint32_t convert_period_to_month(uint32_t period);
786
uint32_t convert_month_to_period(uint32_t month);
788
int test_if_number(char *str,int *res,bool allow_wildcards);
789
void change_byte(unsigned char *,uint,char,char);
790
void change_double_for_sort(double nr,unsigned char *to);
791
int get_quick_record(optimizer::SqlSelect *select);
793
void find_date(char *pos,uint32_t *vek,uint32_t flag);
794
TYPELIB* convert_strings_to_array_type(char** typelibs, char** end);
795
TYPELIB* typelib(memory::Root&, List<String>&);
796
ulong get_form_pos(int file, unsigned char *head, TYPELIB *save_names);
797
void append_unescaped(String *res, const char *pos, uint32_t length);
799
bool check_column_name(const char *name);
800
bool check_table_name(const char *name, uint32_t length);
802
} /* namespace drizzled */
804
#include <drizzled/table/singular.h>
805
#include <drizzled/table/concurrent.h>