24 #include <boost/dynamic_bitset.hpp>
26 #include <drizzled/order.h>
27 #include <drizzled/filesort_info.h>
28 #include <drizzled/natural_join_column.h>
29 #include <drizzled/field_iterator.h>
30 #include <drizzled/cursor.h>
31 #include <drizzled/lex_string.h>
32 #include <drizzled/table/instance.h>
33 #include <drizzled/atomics.h>
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)
74 Table *getNext()
const
84 void setNext(Table *arg)
91 getNext()->setPrev(getPrev());
92 getPrev()->setNext(getNext());
98 Table *getPrev()
const
108 void setPrev(Table *arg)
113 boost::dynamic_bitset<> *read_set;
114 boost::dynamic_bitset<> *write_set;
121 boost::dynamic_bitset<> tmp_set;
129 unsigned char *getInsertRecord()
const
134 unsigned char *getUpdateRecord()
139 unsigned char *record[2];
140 std::vector<unsigned char> insert_values;
149 const char *getAlias()
const
151 return _alias.c_str();
159 void setAlias(
const char *arg)
168 unsigned char *null_flags;
173 uint32_t used_fields;
176 uint32_t derived_select_number;
216 bool open_placeholder;
224 bool auto_increment_field_not_null;
225 bool alias_name_used;
269 timestamp_auto_set_type timestamp_field_type;
278 key_map covering_keys;
293 key_map keys_in_use_for_query;
296 key_map keys_in_use_for_group_by;
299 key_map keys_in_use_for_order_by;
305 ha_rows quick_rows[MAX_KEY];
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];
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);
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;
358 virtual TableShare *getMutableShare()= 0;
359 virtual bool hasShare()
const= 0;
360 virtual void setShare(TableShare *new_share)= 0;
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();
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]];
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; }
393 inline bool isNameLock()
const {
return open_placeholder; }
395 uint32_t index_flags(uint32_t idx)
const;
397 inline plugin::StorageEngine *getEngine() const
399 return getShare()->getEngine();
402 Cursor &getCursor() const
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();
415 void storeRecordAsInsert();
416 void storeRecordAsDefault();
417 void restoreRecord();
418 void restoreRecordAsDefault();
423 inline uint32_t getDBStat ()
const {
return db_stat; }
441 void fill_item_list(List<Item>&)
const;
442 void clear_column_bitmaps(
void);
443 void prepare_for_position(
void);
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);
446 void mark_columns_used_by_index(uint32_t index);
447 void restore_column_maps_after_mark_index();
448 void mark_auto_increment_column(
void);
449 void mark_columns_needed_for_update(
void);
450 void mark_columns_needed_for_delete(
void);
451 void mark_columns_needed_for_insert(
void);
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);
458 inline void use_all_columns()
460 column_bitmaps_set(getMutableShare()->all_set, getMutableShare()->all_set);
463 inline void default_column_bitmaps()
465 read_set= &def_read_set;
466 write_set= &def_write_set;
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()
521 bool is_name_opened()
const
523 return db_stat || open_placeholder;
529 bool needs_reopen_or_name_lock()
const;
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;
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);
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)";
601 virtual bool isPlaceHolder(
void)
const
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);
793 void find_date(
char *pos,uint32_t *vek,uint32_t flag);
794 TYPELIB* convert_strings_to_array_type(
char** typelibs,
char** end);
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*);
800 bool check_table_name(
str_ref);
804 #include <drizzled/table/singular.h>
805 #include <drizzled/table/concurrent.h>