50 typedef std::vector<std::string> StringVector;
53 typedef std::shared_ptr<TableShare> shared_ptr;
54 typedef std::vector <shared_ptr> vector;
56 TableShare(
const identifier::Table::Type type_arg);
62 TableShare(
const identifier::Table::Type type_arg,
64 const char *path_arg= NULL, uint32_t path_length_arg= 0);
66 virtual ~TableShare();
73 bool isTemporaryCategory()
const
84 typedef std::vector<Field *> Fields;
90 const Fields getFields()
const
100 Field ** getFields(
bool)
105 void setFields(uint32_t arg)
110 uint32_t positionFields(Field **arg)
const
112 return (arg - (Field **)&_fields[0]);
115 void pushField(Field *arg)
118 _fields.push_back(arg);
121 Field **found_next_number_field;
124 Field *timestamp_field;
128 Field *getTimestampField() const
130 return timestamp_field;
133 void setTimestampField(Field *arg)
135 timestamp_field= arg;
143 KeyInfo &getKeyInfo(uint32_t arg)
const
145 return key_info[arg];
147 std::vector<uint> blob_field;
151 typedef std::unordered_map<std::string, Field**, util::insensitive_hash, util::insensitive_equal_to> FieldMap;
155 size_t getNamedFieldSize()
const
157 return name_hash.size();
160 Field **getNamedField(
const std::string &arg)
162 return find_ptr2(name_hash, arg);
166 memory::Root mem_root;
168 unsigned char* alloc(
size_t arg)
170 return mem_root.alloc(arg);
178 typedef std::vector<std::string> keynames_t;
180 keynames_t _keynames;
182 void addKeyName(
const std::string& arg)
184 _keynames.push_back(boost::to_upper_copy(arg));
188 uint32_t doesKeyNameExist(
const std::string& arg)
const
190 keynames_t::const_iterator it= find(_keynames.begin(), _keynames.end(), boost::to_upper_copy(arg));
191 return it == _keynames.end() ? UINT32_MAX : it - _keynames.begin();
195 std::vector<TYPELIB> intervals;
201 virtual void unlock()
205 std::vector<unsigned char> default_values;
209 unsigned char *getDefaultValues()
211 return &default_values[0];
213 void resizeDefaultValues(
size_t arg)
215 default_values.resize(arg);
218 const charset_info_st *table_charset;
220 boost::dynamic_bitset<> all_set;
233 identifier::Table::Key private_key_for_cache;
234 std::vector<char> private_normalized_path;
235 drizzled::identifier::Table *table_identifier;
237 str_ref normalized_path;
241 const char *getNormalizedPath()
const
243 return normalized_path.data();
246 const char *getPath()
const
251 const identifier::Table::Key& getCacheKey() const
253 assert(private_key_for_cache.size());
254 return private_key_for_cache;
257 size_t getCacheKeySize()
const
259 return private_key_for_cache.size();
262 str_ref getTableNameRef()
const
264 return str_ref(table_identifier->getTableName());
267 const char *getTableName()
const
269 return table_identifier->getTableName().c_str();
272 str_ref getSchemaNameRef()
const
274 return str_ref(table_identifier->getSchemaName());
277 const char *getSchemaName()
const
279 return table_identifier->getSchemaName().c_str();
282 const drizzled::identifier::Table &getTableIdentifier()
const
284 return *table_identifier;
293 uint64_t getVersion()
const
298 void refreshVersion();
306 uint32_t timestamp_offset;
309 uint32_t stored_rec_length;
312 uint32_t sizeStoredRecord()
const
314 return stored_rec_length;
317 uint32_t getRecordLength()
const
322 void setRecordLength(uint32_t arg)
327 const Field_blob *getBlobFieldAt(uint32_t arg)
const
329 if (arg < blob_fields)
330 return (Field_blob*) _fields[blob_field[arg]];
339 boost::scoped_ptr<message::Table> _table_message;
346 message::Table::TableType getTableType()
const
348 return getTableMessage() ? getTableMessage()->type() : message::Table::STANDARD;
351 const std::string &getTableTypeAsString()
const
353 if (getTableMessage())
354 return message::type(getTableMessage()->type());
356 return NO_PROTOBUFFER_AVAILABLE;
360 inline message::Table *getTableMessage()
const
362 return _table_message.get();
365 void setTableMessage(
const message::Table &arg)
367 assert(not getTableMessage());
368 _table_message.reset(
new message::Table(arg));
371 const message::Table::Field &field(int32_t field_position)
const
373 assert(getTableMessage());
374 return getTableMessage()->field(field_position);
377 inline bool hasComment()
const
379 return getTableMessage() ? getTableMessage()->options().has_comment() :
false;
382 inline const char *getComment()
384 return (getTableMessage() && getTableMessage()->has_options()) ? getTableMessage()->options().comment().c_str() : NULL;
387 inline uint32_t getCommentLength()
const
389 return (getTableMessage()) ? getTableMessage()->options().comment().length() : 0;
392 inline uint64_t getMaxRows()
const
397 inline void setMaxRows(uint64_t arg)
408 plugin::StorageEngine *storage_engine;
409 inline plugin::StorageEngine *db_type() const
411 return storage_engine;
413 inline plugin::StorageEngine *getEngine() const
415 return storage_engine;
419 identifier::Table::Type tmp_table;
422 identifier::Table::Type getType()
const
431 uint32_t getTableCount()
const
436 void incrementTableCount()
443 uint32_t decrementTableCount()
449 uint32_t last_null_bit_pos;
451 uint32_t _field_size;
454 void setFieldSize(uint32_t arg)
459 uint32_t sizeFields()
const
464 uint32_t rec_buff_length;
467 uint32_t sizeKeys()
const
472 uint32_t max_key_length, max_unique_length, total_key_length;
474 uint32_t null_fields;
475 uint32_t blob_fields;
477 bool has_variable_width;
480 bool hasVariableWidth()
const
482 return has_variable_width;
484 void setVariableWidth()
486 has_variable_width=
true;
488 uint32_t db_create_options;
489 uint32_t db_options_in_use;
490 uint32_t db_record_offset;
491 uint32_t rowid_field_offset;
505 uint32_t getPrimaryKey()
const
510 bool hasPrimaryKey()
const
516 uint32_t next_number_index;
517 uint32_t next_number_key_offset;
518 uint32_t next_number_keypart;
519 uint32_t error, open_errno, errarg;
522 uint8_t blob_ptr_size;
525 uint8_t sizeBlobPtr()
const
527 return blob_ptr_size;
530 bool db_low_byte_first;
537 key_map keys_for_keyread;
543 virtual plugin::EventObserverList *getTableObservers()
548 virtual void setTableObservers(plugin::EventObserverList *)
560 void setIdentifier(
const identifier::Table &identifier_arg);
579 void init(
const char *new_table_name,
580 const char *new_path);
583 void open_table_error(
int pass_error,
int db_errno,
int pass_errarg);
587 static TableShare::shared_ptr getShareCreate(Session*,
const identifier::Table&,
int &error);
589 friend std::ostream& operator<<(std::ostream& output,
const TableShare &share)
591 return output <<
"TableShare:(" << share.getSchemaNameRef() <<
", " << share.getTableName() <<
", " << share.getTableTypeAsString() <<
", " << share.getPath() <<
")";
595 friend class drizzled::table::Singular;
597 Field *make_field(
const message::Table::Field &pfield,
599 uint32_t field_length,
601 unsigned char *null_pos,
602 unsigned char null_bit,
604 enum_field_types field_type,
605 const charset_info_st * field_charset,
606 Field::utype unireg_check,
608 const char *field_name);
610 Field *make_field(
const message::Table::Field &pfield,
612 uint32_t field_length,
614 unsigned char *null_pos,
615 unsigned char null_bit,
617 enum_field_types field_type,
618 const charset_info_st * field_charset,
619 Field::utype unireg_check,
621 const char *field_name,
625 int open_table_def(Session& session,
const identifier::Table &identifier);
627 int open_table_from_share(Session *session,
628 const identifier::Table &identifier,
630 uint32_t db_stat, uint32_t ha_open_flags,
633 int open_table_from_share_inner(Session *session,
637 int open_table_cursor_inner(
const identifier::Table &identifier,
638 uint32_t db_stat, uint32_t ha_open_flags,
640 bool &error_reported);
642 bool parse_table_proto(Session& session,
const message::Table &table);
644 virtual bool is_replicated()
const