32
32
#include <boost/thread/condition_variable.hpp>
33
33
#include <boost/dynamic_bitset.hpp>
34
34
#include <boost/shared_ptr.hpp>
35
#include <boost/scoped_ptr.hpp>
36
37
#include "drizzled/typelib.h"
37
38
#include "drizzled/memory/root.h"
38
#include "drizzled/message/table.pb.h"
39
#include "drizzled/message.h"
39
40
#include "drizzled/util/string.h"
41
42
#include "drizzled/lex_string.h"
52
53
extern uint64_t refresh_version;
54
const static std::string STANDARD_STRING("STANDARD");
55
const static std::string TEMPORARY_STRING("TEMPORARY");
56
const static std::string INTERNAL_STRING("INTERNAL");
57
const static std::string FUNCTION_STRING("FUNCTION");
58
55
const static std::string NO_PROTOBUFFER_AVAILABLE("NO PROTOBUFFER AVAILABLE");
168
168
std::vector<uint> blob_field; /* Index to blobs in Field arrray*/
170
171
/* hash of field names (contains pointers to elements of field array) */
172
172
typedef boost::unordered_map < std::string, Field **, util::insensitive_hash, util::insensitive_equal_to> FieldMap;
173
173
typedef std::pair< std::string, Field ** > FieldMapPair;
174
174
FieldMap name_hash; /* hash of field names */
176
177
size_t getNamedFieldSize() const
375
380
uint32_t timestamp_offset; /* Set to offset+1 of record */
377
uint32_t reclength; /* Recordlength */
382
uint32_t reclength; /* Recordlength */
383
uint32_t stored_rec_length; /* Stored record length*/
379
uint32_t stored_rec_length; /* Stored record length*/
386
uint32_t sizeStoredRecord() const
388
return stored_rec_length;
381
391
uint32_t getRecordLength() const
400
410
/* Max rows is a hint to HEAP during a create tmp table */
401
411
uint64_t max_rows;
403
message::Table *table_proto;
413
boost::scoped_ptr<message::Table> _table_message;
407
@note Without a table_proto, we assume we are building a STANDARD table.
417
@note Without a _table_message, we assume we are building a STANDARD table.
408
418
This will be modified once we use Identifiers in the Share itself.
410
420
message::Table::TableType getTableType() const
412
return table_proto ? table_proto->type() : message::Table::STANDARD;
422
return getTableMessage() ? getTableMessage()->type() : message::Table::STANDARD;
415
425
const std::string &getTableTypeAsString() const
419
switch (table_proto->type())
422
case message::Table::STANDARD:
423
return STANDARD_STRING;
424
case message::Table::TEMPORARY:
425
return TEMPORARY_STRING;
426
case message::Table::INTERNAL:
427
return INTERNAL_STRING;
428
case message::Table::FUNCTION:
429
return FUNCTION_STRING;
434
return NO_PROTOBUFFER_AVAILABLE;
427
if (getTableMessage())
428
return message::type(getTableMessage()->type());
430
return NO_PROTOBUFFER_AVAILABLE;
438
433
/* This is only used in one location currently */
439
inline message::Table *getTableProto() const
434
inline message::Table *getTableMessage() const
436
return _table_message.get();
439
void setTableMessage(const message::Table &arg)
441
assert(not getTableMessage());
442
_table_message.reset(new(std::nothrow) message::Table(arg));
444
445
const message::Table::Field &field(int32_t field_position) const
447
return table_proto->field(field_position);
450
inline void setTableProto(message::Table *arg)
452
assert(table_proto == NULL);
447
assert(getTableMessage());
448
return getTableMessage()->field(field_position);
456
451
inline bool hasComment() const
458
return (table_proto) ? table_proto->options().has_comment() : false;
453
return (getTableMessage()) ? getTableMessage()->options().has_comment() : false;
461
456
inline const char *getComment()
463
return (table_proto && table_proto->has_options()) ? table_proto->options().comment().c_str() : NULL;
458
return (getTableMessage() && getTableMessage()->has_options()) ? getTableMessage()->options().comment().c_str() : NULL;
466
461
inline uint32_t getCommentLength() const
468
return (table_proto) ? table_proto->options().comment().length() : 0;
463
return (getTableMessage()) ? getTableMessage()->options().comment().length() : 0;
471
466
inline uint64_t getMaxRows() const
596
592
uint32_t next_number_keypart; /* autoinc keypart number in a key */
597
593
uint32_t error, open_errno, errarg; /* error from open_table_def() */
599
596
uint8_t blob_ptr_size; /* 4 or 8 */
599
uint8_t sizeBlobPtr() const
601
return blob_ptr_size;
600
604
bool db_low_byte_first; /* Portable row format */