65
TableShare *s; /**< Pointer to the shared metadata about the table */
64
67
Field **field; /**< Pointer to fields collection */
67
Field **getFields() const
72
Field *getField(uint32_t arg) const
77
void setFields(Field **arg)
82
void setFieldAt(Field *arg, uint32_t arg_pos)
87
69
Cursor *cursor; /**< Pointer to the storage engine's Cursor managing this table */
91
Table *getNext() const
101
void setNext(Table *arg)
108
getNext()->setPrev(getPrev()); /* remove from used chain */
109
getPrev()->setNext(getNext());
115
Table *getPrev() const
125
void setPrev(Table *arg)
130
boost::dynamic_bitset<> *read_set; /* Active column sets */
131
boost::dynamic_bitset<> *write_set; /* Active column sets */
73
MyBitmap *read_set; /* Active column sets */
74
MyBitmap *write_set; /* Active column sets */
134
77
uint32_t db_stat; /**< information about the cursor as in Cursor.h */
136
boost::dynamic_bitset<> def_read_set; /**< Default read set of columns */
137
boost::dynamic_bitset<> def_write_set; /**< Default write set of columns */
138
boost::dynamic_bitset<> tmp_set; /* Not sure about this... */
79
MyBitmap def_read_set; /**< Default read set of columns */
80
MyBitmap def_write_set; /**< Default write set of columns */
81
MyBitmap tmp_set; /* Not sure about this... */
140
83
Session *in_use; /**< Pointer to the current session using this object */
141
84
Session *getSession()
146
unsigned char *getInsertRecord()
151
unsigned char *getUpdateRecord()
156
89
unsigned char *record[2]; /**< Pointer to "records" */
157
std::vector<unsigned char> insert_values; /* used by INSERT ... UPDATE */
90
unsigned char *insert_values; /* used by INSERT ... UPDATE */
158
91
KeyInfo *key_info; /**< data of keys in database */
159
92
Field *next_number_field; /**< Set if next_number is activated. @TODO What the heck is the difference between this and the next member? */
160
93
Field *found_next_number_field; /**< Points to the "next-number" field (autoincrement field) */
161
94
Field_timestamp *timestamp_field; /**< Points to the auto-setting timestamp field, if any */
163
96
TableList *pos_in_table_list; /* Element referring to this table */
166
const char *getAlias() const
168
return _alias.c_str();
176
void setAlias(const char *arg)
182
std::string _alias; /**< alias or table name if no alias */
98
const char *alias; /**< alias or table name if no alias */
185
99
unsigned char *null_flags;
187
101
uint32_t lock_position; /**< Position in DRIZZLE_LOCK.table */
188
102
uint32_t lock_data_start; /**< Start pos. in DRIZZLE_LOCK.locks */
189
103
uint32_t lock_count; /**< Number of locks */
190
104
uint32_t used_fields;
191
uint32_t status; /* What's in getInsertRecord() */
105
uint32_t status; /* What's in record[0] */
192
106
/* number of select if it is derived table */
193
107
uint32_t derived_select_number;
194
108
int current_lock; /**< Type of lock on table */
375
287
* @param If true if we also want to free table_share
376
288
* @note this should all be the destructor
378
int delete_table(bool free_share= false);
290
int delete_table(bool free_share);
380
292
void resetTable(Session *session, TableShare *share, uint32_t db_stat_arg);
382
294
/* SHARE methods */
383
virtual const TableShare *getShare() const= 0; /* Get rid of this long term */
384
virtual TableShare *getMutableShare()= 0; /* Get rid of this long term */
385
virtual bool hasShare() const= 0; /* Get rid of this long term */
386
virtual void setShare(TableShare *new_share)= 0; /* Get rid of this long term */
388
virtual void release(void)= 0;
390
uint32_t sizeKeys() { return getMutableShare()->sizeKeys(); }
391
uint32_t sizeFields() { return getMutableShare()->sizeFields(); }
392
uint32_t getRecordLength() const { return getShare()->getRecordLength(); }
393
uint32_t sizeBlobFields() { return getMutableShare()->blob_fields; }
394
uint32_t *getBlobField() { return &getMutableShare()->blob_field[0]; }
397
virtual bool hasVariableWidth() const
399
return getShare()->hasVariableWidth(); // We should calculate this.
402
virtual void setVariableWidth(void);
404
Field_blob *getBlobFieldAt(uint32_t arg) const
406
if (arg < getShare()->blob_fields)
407
return (Field_blob*) field[getShare()->blob_field[arg]]; /*NOTE: Using 'Table.field' NOT SharedTable.field. */
411
inline uint8_t getBlobPtrSize() { return getShare()->blob_ptr_size; }
412
inline uint32_t getNullBytes() { return getShare()->null_bytes; }
413
inline uint32_t getNullFields() { return getShare()->null_fields; }
414
inline unsigned char *getDefaultValues() { return getMutableShare()->getDefaultValues(); }
415
inline const char *getSchemaName() const { return getShare()->getSchemaName(); }
416
inline const char *getTableName() const { return getShare()->getTableName(); }
418
inline bool isDatabaseLowByteFirst() { return getShare()->db_low_byte_first; } /* Portable row format */
419
inline bool isNameLock() const { return open_placeholder; }
295
inline const TableShare *getShare() const { assert(s); return s; } /* Get rid of this long term */
296
inline TableShare *getMutableShare() { assert(s); return s; } /* Get rid of this long term */
297
inline void setShare(TableShare *new_share) { s= new_share; } /* Get rid of this long term */
298
inline uint32_t sizeKeys() { return s->keys; }
299
inline uint32_t sizeFields() { return s->fields; }
300
inline uint32_t getRecordLength() { return s->reclength; }
301
inline uint32_t sizeBlobFields() { return s->blob_fields; }
302
inline uint32_t *getBlobField() { return s->blob_field; }
303
inline uint32_t getNullBytes() { return s->null_bytes; }
304
inline uint32_t getNullFields() { return s->null_fields; }
305
inline unsigned char *getDefaultValues() { return s->default_values; }
307
inline bool isDatabaseLowByteFirst() { return s->db_low_byte_first; } /* Portable row format */
308
inline bool isNameLock() { return s->name_lock; }
309
inline bool isReplaceWithNameLock() { return s->replace_with_name_lock; }
310
inline bool isWaitingOnCondition() { return s->waiting_on_cond; } /* Protection against free */
421
312
uint32_t index_flags(uint32_t idx) const
423
return getShare()->storage_engine->index_flags(getShare()->getKeyInfo(idx).algorithm);
314
return s->storage_engine->index_flags(s->key_info[idx].algorithm);
426
317
inline plugin::StorageEngine *getEngine() const /* table_type for handler */
428
return getShare()->storage_engine;
319
return s->storage_engine;
431
322
Cursor &getCursor() const /* table_type for handler */
328
/* For TMP tables, should be pulled out as a class */
329
void setup_tmp_table_column_bitmaps(unsigned char *bitmaps);
330
bool create_myisam_tmp_table(KeyInfo *keyinfo,
331
MI_COLUMNDEF *start_recinfo,
332
MI_COLUMNDEF **recinfo,
334
void free_tmp_table(Session *session);
335
bool open_tmp_table();
437
336
size_t max_row_length(const unsigned char *data);
438
337
uint32_t find_shortest_key(const key_map *usable_keys);
439
338
bool compare_record(Field **ptr);
440
bool records_are_comparable();
441
bool compare_records();
339
bool compare_record();
442
340
/* TODO: the (re)storeRecord's may be able to be further condensed */
443
341
void storeRecord();
444
342
void storeRecordAsInsert();
470
367
bool fill_item_list(List<Item> *item_list) const;
471
368
void clear_column_bitmaps(void);
472
369
void prepare_for_position(void);
473
void mark_columns_used_by_index_no_reset(uint32_t index, boost::dynamic_bitset<>& bitmap);
370
void mark_columns_used_by_index_no_reset(uint32_t index, MyBitmap *map);
474
371
void mark_columns_used_by_index_no_reset(uint32_t index);
475
372
void mark_columns_used_by_index(uint32_t index);
476
373
void restore_column_maps_after_mark_index();
478
375
void mark_columns_needed_for_update(void);
479
376
void mark_columns_needed_for_delete(void);
480
377
void mark_columns_needed_for_insert(void);
481
void column_bitmaps_set(boost::dynamic_bitset<>& read_set_arg,
482
boost::dynamic_bitset<>& write_set_arg);
484
void restore_column_map(const boost::dynamic_bitset<>& old);
486
const boost::dynamic_bitset<> use_all_columns(boost::dynamic_bitset<>& map);
378
inline void column_bitmaps_set(MyBitmap *read_set_arg,
379
MyBitmap *write_set_arg)
381
read_set= read_set_arg;
382
write_set= write_set_arg;
385
void restore_column_map(my_bitmap_map *old);
387
my_bitmap_map *use_all_columns(MyBitmap *bitmap);
487
388
inline void use_all_columns()
489
column_bitmaps_set(getMutableShare()->all_set, getMutableShare()->all_set);
390
column_bitmaps_set(&s->all_set, &s->all_set);
492
393
inline void default_column_bitmaps()
498
399
/* Both of the below should go away once we can move this bit to the field objects */
499
400
inline bool isReadSet(uint32_t index)
501
return read_set->test(index);
402
return read_set->isBitSet(index);
504
405
inline void setReadSet(uint32_t index)
506
read_set->set(index);
407
read_set->setBit(index);
509
410
inline void setReadSet()
514
415
inline void clearReadSet(uint32_t index)
516
read_set->reset(index);
417
read_set->clearBit(index);
519
420
inline void clearReadSet()
422
read_set->clearAll();
524
425
inline bool isWriteSet(uint32_t index)
526
return write_set->test(index);
427
return write_set->isBitSet(index);
529
430
inline void setWriteSet(uint32_t index)
531
write_set->set(index);
432
write_set->setBit(index);
534
435
inline void setWriteSet()
539
440
inline void clearWriteSet(uint32_t index)
541
write_set->reset(index);
442
write_set->clearBit(index);
544
445
inline void clearWriteSet()
447
write_set->clearAll();
549
450
/* Is table open or should be treated as such by name-locking? */
573
474
status|= STATUS_NULL_ROW;
574
memset(null_flags, 255, getShare()->null_bytes);
475
memset(null_flags, 255, s->null_bytes);
478
bool renameAlterTemporaryTable(TableIdentifier &identifier);
577
479
void free_io_cache();
578
480
void filesort_free_buffers(bool full= false);
579
481
void intern_close_table();
581
483
void print_error(int error, myf errflag)
583
getShare()->storage_engine->print_error(error, errflag, *this);
485
s->storage_engine->print_error(error, errflag, *this);
614
535
friend std::ostream& operator<<(std::ostream& output, const Table &table)
616
if (table.getShare())
619
output << table.getShare()->getSchemaName();
621
output << table.getShare()->getTableName();
623
output << table.getShare()->getTableTypeAsString();
628
output << "Table:(has no share)";
538
output << table.getShare()->getSchemaName();
540
output << table.getShare()->getTableName();
542
output << table.getShare()->getTableTypeAsString();
631
545
return output; // for multiple << operators.
549
bool is_placeholder_created;
635
virtual bool isPlaceHolder(void) const
554
return is_placeholder_created;
831
762
namespace optimizer { class SqlSelect; }
764
ha_rows filesort(Session *session,
766
st_sort_field *sortorder,
768
optimizer::SqlSelect *select,
771
ha_rows *examined_rows);
773
void filesort_free_buffers(Table *table, bool full);
833
774
void change_double_for_sort(double nr,unsigned char *to);
834
775
double my_double_round(double value, int64_t dec, bool dec_unsigned,
839
780
TYPELIB *convert_strings_to_array_type(char * *typelibs, char * *end);
840
781
TYPELIB *typelib(memory::Root *mem_root, List<String> &strings);
841
782
ulong get_form_pos(int file, unsigned char *head, TYPELIB *save_names);
783
ulong next_io_size(ulong pos);
842
784
void append_unescaped(String *res, const char *pos, uint32_t length);
844
786
int rename_file_ext(const char * from,const char * to,const char * ext);
845
787
bool check_column_name(const char *name);
846
bool check_db_name(Session *session, SchemaIdentifier &schema);
788
bool check_db_name(SchemaIdentifier &schema);
847
789
bool check_table_name(const char *name, uint32_t length);
849
791
} /* namespace drizzled */
851
#include "drizzled/table/instance.h"
852
#include "drizzled/table/concurrent.h"
854
793
#endif /* DRIZZLED_TABLE_H */