21
21
/* Structs that defines the Table */
25
23
#ifndef DRIZZLED_TABLE_H
26
24
#define DRIZZLED_TABLE_H
29
#include <boost/dynamic_bitset.hpp>
26
#include <storage/myisam/myisam.h>
31
27
#include <drizzled/order.h>
32
28
#include <drizzled/filesort_info.h>
33
29
#include <drizzled/natural_join_column.h>
34
30
#include <drizzled/field_iterator.h>
35
#include <drizzled/cursor.h>
31
#include <mysys/hash.h>
32
#include <drizzled/handler.h>
36
33
#include <drizzled/lex_string.h>
37
#include <drizzled/table/instance.h>
38
#include <drizzled/atomics.h>
39
#include <drizzled/query_id.h>
41
#include <drizzled/visibility.h>
34
#include <drizzled/table_list.h>
38
class st_select_lex_unit;
41
class Security_context;
44
/*************************************************************************/
47
class Field_timestamp;
50
class SecurityContext;
52
class Select_Lex_Unit;
54
namespace field { class Epoch; }
55
namespace plugin { class StorageEngine; }
57
50
typedef enum enum_table_category TABLE_CATEGORY;
58
typedef struct st_columndef MI_COLUMNDEF;
61
* Class representing a set of records, either in a temporary,
62
* normal, or derived table.
64
class DRIZZLED_API Table
66
Field **field; /**< Pointer to fields collection */
69
Field **getFields() const
74
Field *getField(uint32_t arg) const
79
void setFields(Field **arg)
84
void setFieldAt(Field *arg, uint32_t arg_pos)
89
Cursor *cursor; /**< Pointer to the storage engine's Cursor managing this table */
95
Table *getNext() const
105
void setNext(Table *arg)
112
getNext()->setPrev(getPrev()); /* remove from used chain */
113
getPrev()->setNext(getNext());
119
Table *getPrev() const
129
void setPrev(Table *arg)
134
boost::dynamic_bitset<> *read_set; /* Active column sets */
135
boost::dynamic_bitset<> *write_set; /* Active column sets */
138
uint32_t db_stat; /**< information about the cursor as in Cursor.h */
140
boost::dynamic_bitset<> def_read_set; /**< Default read set of columns */
141
boost::dynamic_bitset<> def_write_set; /**< Default write set of columns */
142
boost::dynamic_bitset<> tmp_set; /* Not sure about this... */
144
Session *in_use; /**< Pointer to the current session using this object */
145
Session *getSession()
150
unsigned char *getInsertRecord() const
155
unsigned char *getUpdateRecord()
160
unsigned char *record[2]; /**< Pointer to "records" */
161
std::vector<unsigned char> insert_values; /* used by INSERT ... UPDATE */
162
KeyInfo *key_info; /**< data of keys in database */
163
Field *next_number_field; /**< Set if next_number is activated. @TODO What the heck is the difference between this and the next member? */
164
Field *found_next_number_field; /**< Points to the "next-number" field (autoincrement field) */
165
field::Epoch *timestamp_field; /**< Points to the auto-setting timestamp field, if any */
167
TableList *pos_in_table_list; /* Element referring to this table */
170
const char *getAlias() const
172
return _alias.c_str();
180
void setAlias(const char *arg)
186
std::string _alias; /**< alias or table name if no alias */
189
unsigned char *null_flags;
191
uint32_t lock_position; /**< Position in DRIZZLE_LOCK.table */
192
uint32_t lock_data_start; /**< Start pos. in DRIZZLE_LOCK.locks */
193
uint32_t lock_count; /**< Number of locks */
194
uint32_t used_fields;
195
uint32_t status; /* What's in getInsertRecord() */
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] */
196
412
/* number of select if it is derived table */
197
uint32_t derived_select_number;
198
int current_lock; /**< Type of lock on table */
199
bool copy_blobs; /**< Should blobs by copied when storing? */
413
uint32_t derived_select_number;
414
int current_lock; /* Type of lock on table */
415
bool copy_blobs; /* copy_blobs when storing */
202
418
0 or JOIN_TYPE_{LEFT|RIGHT}. Currently this is only compared to 0.
230
443
- setting version to 0 - this will force other threads to close
231
444
the instance of this table and wait (this is the same approach
232
445
as used for usual name locks).
233
An exclusively name-locked table currently can have no Cursor
446
An exclusively name-locked table currently can have no handler
234
447
object associated with it (db_stat is always 0), but please do
235
448
not rely on that.
237
450
bool open_placeholder;
451
bool locked_by_logger;
238
453
bool locked_by_name;
455
/* To signal that the table is associated with a HANDLER statement */
456
bool open_by_handler;
241
458
To indicate that a non-null value of the auto_increment field
242
459
was provided by the user or retrieved from the current record.
243
460
Used only in the MODE_NO_AUTO_VALUE_ON_ZERO mode.
245
462
bool auto_increment_field_not_null;
246
bool alias_name_used; /* true if table_name is alias */
249
The ID of the query that opened and is using this table. Has different
250
meanings depending on the table type.
254
table->query_id is set to session->query_id for the duration of a statement
255
and is reset to 0 once it is closed by the same statement. A non-zero
256
table->query_id means that a statement is using the table even if it's
257
not the current statement (table is in use by some outer statement).
259
Non-temporary tables:
261
Under pre-locked or LOCK TABLES mode: query_id is set to session->query_id
262
for the duration of a statement and is reset to 0 once it is closed by
263
the same statement. A non-zero query_id is used to control which tables
264
in the list of pre-opened and locked tables are actually being used.
269
* Estimate of number of records that satisfy SARGable part of the table
270
* condition, or table->cursor->records if no SARGable condition could be
272
* This value is used by join optimizer as an estimate of number of records
273
* that will pass the table condition (condition that depends on fields of
274
* this table and constants)
276
ha_rows quick_condition_rows;
279
If this table has TIMESTAMP field with auto-set property (pointed by
280
timestamp_field member) then this variable indicates during which
281
operations (insert only/on update/in both cases) we should set this
282
field to current timestamp. If there are no such field in this table
283
or we should not automatically set its value during execution of current
284
statement then the variable contains TIMESTAMP_NO_AUTO_SET (i.e. 0).
286
Value of this variable is set for each statement in open_table() and
287
if needed cleared later in statement processing code (see update_query()
290
timestamp_auto_set_type timestamp_field_type;
291
table_map map; ///< ID bit of table (1,2,4,8,16...)
293
RegInfo reginfo; /* field connections */
296
Map of keys that can be used to retrieve all data from this table
297
needed by the query without reading the row.
299
key_map covering_keys;
304
A set of keys that can be used in the query that references this
307
All indexes disabled on the table's TableShare (see Table::s) will be
308
subtracted from this set upon instantiation. Thus for any Table t it holds
309
that t.keys_in_use_for_query is a subset of t.s.keys_in_use. Generally we
310
must not introduce any new keys here (see setup_tables).
312
The set is implemented as a bitmap.
314
key_map keys_in_use_for_query;
316
/* Map of keys that can be used to calculate GROUP BY without sorting */
317
key_map keys_in_use_for_group_by;
319
/* Map of keys that can be used to calculate ORDER BY without sorting */
320
key_map keys_in_use_for_order_by;
323
For each key that has quick_keys.test(key) == true: estimate of #records
324
and max #key parts that range access would use.
326
ha_rows quick_rows[MAX_KEY];
328
/* Bitmaps of key parts that =const for the entire join. */
329
key_part_map const_key_parts[MAX_KEY];
331
uint32_t quick_key_parts[MAX_KEY];
332
uint32_t quick_n_ranges[MAX_KEY];
335
memory::Root mem_root;
339
init_sql_alloc(&mem_root, TABLE_ALLOC_BLOCK_SIZE, 0);
342
memory::Root *getMemRoot()
344
if (not mem_root.alloc_root_inited())
352
void *alloc_root(size_t arg)
354
if (not mem_root.alloc_root_inited())
359
return mem_root.alloc_root(arg);
362
char *strmake_root(const char *str_arg, size_t len_arg)
364
if (not mem_root.alloc_root_inited())
369
return mem_root.strmake_root(str_arg, len_arg);
377
int report_error(int error);
379
* Free information allocated by openfrm
381
* @param If true if we also want to free table_share
382
* @note this should all be the destructor
384
int delete_table(bool free_share= false);
386
void resetTable(Session *session, TableShare *share, uint32_t db_stat_arg);
389
virtual const TableShare *getShare() const= 0; /* Get rid of this long term */
390
virtual TableShare *getMutableShare()= 0; /* Get rid of this long term */
391
virtual bool hasShare() const= 0; /* Get rid of this long term */
392
virtual void setShare(TableShare *new_share)= 0; /* Get rid of this long term */
394
virtual void release(void)= 0;
396
uint32_t sizeKeys() { return getMutableShare()->sizeKeys(); }
397
uint32_t sizeFields() { return getMutableShare()->sizeFields(); }
398
uint32_t getRecordLength() const { return getShare()->getRecordLength(); }
399
uint32_t sizeBlobFields() { return getMutableShare()->blob_fields; }
400
uint32_t *getBlobField() { return &getMutableShare()->blob_field[0]; }
403
virtual bool hasVariableWidth() const
405
return getShare()->hasVariableWidth(); // We should calculate this.
408
virtual void setVariableWidth(void);
410
Field_blob *getBlobFieldAt(uint32_t arg) const
412
if (arg < getShare()->blob_fields)
413
return (Field_blob*) field[getShare()->blob_field[arg]]; /*NOTE: Using 'Table.field' NOT SharedTable.field. */
417
inline uint8_t getBlobPtrSize() const { return getShare()->sizeBlobPtr(); }
418
inline uint32_t getNullBytes() const { return getShare()->null_bytes; }
419
inline uint32_t getNullFields() const { return getShare()->null_fields; }
420
inline unsigned char *getDefaultValues() { return getMutableShare()->getDefaultValues(); }
421
inline const char *getSchemaName() const { return getShare()->getSchemaName(); }
422
inline const char *getTableName() const { return getShare()->getTableName(); }
424
inline bool isDatabaseLowByteFirst() const { return getShare()->db_low_byte_first; } /* Portable row format */
425
inline bool isNameLock() const { return open_placeholder; }
427
uint32_t index_flags(uint32_t idx) const;
429
inline plugin::StorageEngine *getEngine() const /* table_type for handler */
431
return getShare()->getEngine();
434
Cursor &getCursor() const /* table_type for handler */
440
size_t max_row_length(const unsigned char *data);
441
uint32_t find_shortest_key(const key_map *usable_keys);
442
bool compare_record(Field **ptr);
443
bool records_are_comparable();
444
bool compare_records();
445
/* TODO: the (re)storeRecord's may be able to be further condensed */
447
void storeRecordAsInsert();
448
void storeRecordAsDefault();
449
void restoreRecord();
450
void restoreRecordAsDefault();
454
/* See if this can be blown away */
455
inline uint32_t getDBStat () { return db_stat; }
456
inline uint32_t setDBStat () { return db_stat; }
458
* Create Item_field for each column in the table.
460
* @param[out] a pointer to an empty list used to store items
464
* Create Item_field object for each column in the table and
465
* initialize it with the corresponding Field. New items are
466
* created in the current Session memory root.
471
* true when out of memory
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;
473
471
bool fill_item_list(List<Item> *item_list) const;
472
void reset_item_list(List<Item> *item_list) const;
474
473
void clear_column_bitmaps(void);
475
474
void prepare_for_position(void);
476
void mark_columns_used_by_index_no_reset(uint32_t index, boost::dynamic_bitset<>& bitmap);
477
void mark_columns_used_by_index_no_reset(uint32_t index);
475
void mark_columns_used_by_index_no_reset(uint32_t index, MY_BITMAP *map);
478
476
void mark_columns_used_by_index(uint32_t index);
479
477
void restore_column_maps_after_mark_index();
480
478
void mark_auto_increment_column(void);
481
479
void mark_columns_needed_for_update(void);
482
480
void mark_columns_needed_for_delete(void);
483
481
void mark_columns_needed_for_insert(void);
484
void column_bitmaps_set(boost::dynamic_bitset<>& read_set_arg,
485
boost::dynamic_bitset<>& write_set_arg);
487
void restore_column_map(const boost::dynamic_bitset<>& old);
489
const boost::dynamic_bitset<> use_all_columns(boost::dynamic_bitset<>& map);
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);
490
501
inline void use_all_columns()
492
column_bitmaps_set(getMutableShare()->all_set, getMutableShare()->all_set);
503
column_bitmaps_set(&s->all_set, &s->all_set);
495
506
inline void default_column_bitmaps()
498
509
write_set= &def_write_set;
501
/* Both of the below should go away once we can move this bit to the field objects */
502
inline bool isReadSet(uint32_t index) const
504
return read_set->test(index);
507
inline void setReadSet(uint32_t index)
509
read_set->set(index);
512
inline void setReadSet()
517
inline void clearReadSet(uint32_t index)
519
read_set->reset(index);
522
inline void clearReadSet()
527
inline bool isWriteSet(uint32_t index)
529
return write_set->test(index);
532
inline void setWriteSet(uint32_t index)
534
write_set->set(index);
537
inline void setWriteSet()
542
inline void clearWriteSet(uint32_t index)
544
write_set->reset(index);
547
inline void clearWriteSet()
552
512
/* Is table open or should be treated as such by name-locking? */
553
inline bool is_name_opened()
555
return db_stat || open_placeholder;
513
inline bool is_name_opened() { return db_stat || open_placeholder; }
559
515
Is this instance of the table should be reopen or represents a name-lock?
561
bool needs_reopen_or_name_lock() const;
564
clean/setup table fields and map.
566
@param table Table structure pointer (which should be setup)
567
@param table_list TableList structure pointer (owner of Table)
568
@param tablenr table number
570
void setup_table_map(TableList *table_list, uint32_t tablenr);
571
inline void mark_as_null_row()
574
status|= STATUS_NULL_ROW;
575
memset(null_flags, 255, getShare()->null_bytes);
578
void free_io_cache();
579
void filesort_free_buffers(bool full= false);
580
void intern_close_table();
582
void print_error(int error, myf errflag) const;
586
key if error because of duplicated keys
588
uint32_t get_dup_key(int error) const
590
cursor->errkey = (uint32_t) -1;
591
if (error == HA_ERR_FOUND_DUPP_KEY || error == HA_ERR_FOREIGN_DUPLICATE_KEY ||
592
error == HA_ERR_FOUND_DUPP_UNIQUE ||
593
error == HA_ERR_DROP_INDEX_FK)
594
cursor->info(HA_STATUS_ERRKEY | HA_STATUS_NO_LOCK);
596
return(cursor->errkey);
600
This is a short term fix. Long term we will used the TableIdentifier to do the actual comparison.
602
bool operator<(const Table &right) const
604
return getShare()->getCacheKey() < right.getShare()->getCacheKey();
607
static bool compare(const Table *a, const Table *b)
612
friend std::ostream& operator<<(std::ostream& output, const Table &table)
614
if (table.getShare())
617
output << table.getShare()->getSchemaName();
619
output << table.getShare()->getTableName();
621
output << table.getShare()->getTableTypeAsString();
626
output << "Table:(has no share)";
629
return output; // for multiple << operators.
633
virtual bool isPlaceHolder(void) const
644
* This class defines the information for foreign keys.
651
* This is the constructor with all properties set.
653
* @param[in] in_foreign_id The id of the foreign key
654
* @param[in] in_referenced_db The referenced database name of the foreign key
655
* @param[in] in_referenced_table The referenced table name of the foreign key
656
* @param[in] in_update_method The update method of the foreign key.
657
* @param[in] in_delete_method The delete method of the foreign key.
658
* @param[in] in_referenced_key_name The name of referenced key
659
* @param[in] in_foreign_fields The foreign fields
660
* @param[in] in_referenced_fields The referenced fields
662
ForeignKeyInfo(LEX_STRING *in_foreign_id,
663
LEX_STRING *in_referenced_db,
664
LEX_STRING *in_referenced_table,
665
LEX_STRING *in_update_method,
666
LEX_STRING *in_delete_method,
667
LEX_STRING *in_referenced_key_name,
668
List<LEX_STRING> in_foreign_fields,
669
List<LEX_STRING> in_referenced_fields)
671
foreign_id(in_foreign_id),
672
referenced_db(in_referenced_db),
673
referenced_table(in_referenced_table),
674
update_method(in_update_method),
675
delete_method(in_delete_method),
676
referenced_key_name(in_referenced_key_name),
677
foreign_fields(in_foreign_fields),
678
referenced_fields(in_referenced_fields)
683
* This is the default constructor. All properties are set to default values for their types.
686
: foreign_id(NULL), referenced_db(NULL), referenced_table(NULL),
687
update_method(NULL), delete_method(NULL), referenced_key_name(NULL)
692
* Gets the foreign id.
694
* @ retval the foreign id
696
const LEX_STRING *getForeignId() const
703
* Gets the name of the referenced database.
705
* @ retval the name of the referenced database
707
const LEX_STRING *getReferencedDb() const
709
return referenced_db;
714
* Gets the name of the referenced table.
716
* @ retval the name of the referenced table
718
const LEX_STRING *getReferencedTable() const
720
return referenced_table;
725
* Gets the update method.
727
* @ retval the update method
729
const LEX_STRING *getUpdateMethod() const
731
return update_method;
736
* Gets the delete method.
738
* @ retval the delete method
740
const LEX_STRING *getDeleteMethod() const
742
return delete_method;
747
* Gets the name of the referenced key.
749
* @ retval the name of the referenced key
751
const LEX_STRING *getReferencedKeyName() const
753
return referenced_key_name;
758
* Gets the foreign fields.
760
* @ retval the foreign fields
762
const List<LEX_STRING> &getForeignFields() const
764
return foreign_fields;
769
* Gets the referenced fields.
771
* @ retval the referenced fields
773
const List<LEX_STRING> &getReferencedFields() const
775
return referenced_fields;
781
LEX_STRING *foreign_id;
783
* The name of the reference database.
785
LEX_STRING *referenced_db;
787
* The name of the reference table.
789
LEX_STRING *referenced_table;
793
LEX_STRING *update_method;
797
LEX_STRING *delete_method;
799
* The name of the referenced key.
801
LEX_STRING *referenced_key_name;
803
* The foreign fields.
805
List<LEX_STRING> foreign_fields;
807
* The referenced fields.
809
List<LEX_STRING> referenced_fields;
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;
814
#define JOIN_TYPE_LEFT 1
815
#define JOIN_TYPE_RIGHT 2
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
818
599
class select_union;
819
class Tmp_Table_Param;
821
void free_blobs(Table *table);
822
int set_zone(int nr,int min_zone,int max_zone);
823
uint32_t convert_period_to_month(uint32_t period);
824
uint32_t convert_month_to_period(uint32_t month);
826
int test_if_number(char *str,int *res,bool allow_wildcards);
827
void change_byte(unsigned char *,uint,char,char);
829
namespace optimizer { class SqlSelect; }
831
void change_double_for_sort(double nr,unsigned char *to);
832
int get_quick_record(optimizer::SqlSelect *select);
834
void find_date(char *pos,uint32_t *vek,uint32_t flag);
835
TYPELIB *convert_strings_to_array_type(char * *typelibs, char * *end);
836
TYPELIB *typelib(memory::Root *mem_root, List<String> &strings);
837
ulong get_form_pos(int file, unsigned char *head, TYPELIB *save_names);
838
void append_unescaped(String *res, const char *pos, uint32_t length);
840
DRIZZLED_API int rename_file_ext(const char * from,const char * to,const char * ext);
841
bool check_column_name(const char *name);
842
bool check_table_name(const char *name, uint32_t length);
844
} /* namespace drizzled */
846
#include <drizzled/table/singular.h>
847
#include <drizzled/table/concurrent.h>
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);
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);
849
641
#endif /* DRIZZLED_TABLE_H */