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>
37
#include <drizzled/memory/root.h>
38
#include <drizzled/message.h>
39
#include <drizzled/util/string.h>
41
#include <drizzled/lex_string.h>
42
#include <drizzled/key_map.h>
36
#include "drizzled/typelib.h"
37
#include "drizzled/memory/root.h"
38
#include "drizzled/message/table.pb.h"
39
#include "drizzled/util/string.h"
41
#include "drizzled/lex_string.h"
42
#include "drizzled/key_map.h"
44
#include <drizzled/table/cache.h>
44
#include "drizzled/table/cache.h"
46
46
#include <drizzled/field.h>
52
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");
52
58
const static std::string NO_PROTOBUFFER_AVAILABLE("NO PROTOBUFFER AVAILABLE");
165
168
std::vector<uint> blob_field; /* Index to blobs in Field arrray*/
168
170
/* hash of field names (contains pointers to elements of field array) */
169
172
typedef boost::unordered_map < std::string, Field **, util::insensitive_hash, util::insensitive_equal_to> FieldMap;
170
173
typedef std::pair< std::string, Field ** > FieldMapPair;
171
174
FieldMap name_hash; /* hash of field names */
174
176
size_t getNamedFieldSize() const
358
358
uint64_t version;
361
360
uint64_t getVersion() const
366
void refreshVersion();
365
void refreshVersion()
367
version= refresh_version;
368
370
void resetVersion()
374
375
uint32_t timestamp_offset; /* Set to offset+1 of record */
376
uint32_t reclength; /* Recordlength */
377
uint32_t stored_rec_length; /* Stored record length*/
377
uint32_t reclength; /* Recordlength */
380
uint32_t sizeStoredRecord() const
382
return stored_rec_length;
379
uint32_t stored_rec_length; /* Stored record length*/
385
381
uint32_t getRecordLength() const
404
400
/* Max rows is a hint to HEAP during a create tmp table */
405
401
uint64_t max_rows;
407
boost::scoped_ptr<message::Table> _table_message;
403
message::Table *table_proto;
411
@note Without a _table_message, we assume we are building a STANDARD table.
407
@note Without a table_proto, we assume we are building a STANDARD table.
412
408
This will be modified once we use Identifiers in the Share itself.
414
410
message::Table::TableType getTableType() const
416
return getTableMessage() ? getTableMessage()->type() : message::Table::STANDARD;
412
return table_proto ? table_proto->type() : message::Table::STANDARD;
419
415
const std::string &getTableTypeAsString() const
421
if (getTableMessage())
422
return message::type(getTableMessage()->type());
424
return NO_PROTOBUFFER_AVAILABLE;
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
438
/* This is only used in one location currently */
428
inline message::Table *getTableMessage() const
430
return _table_message.get();
433
void setTableMessage(const message::Table &arg)
435
assert(not getTableMessage());
436
_table_message.reset(new(std::nothrow) message::Table(arg));
439
inline message::Table *getTableProto() const
439
444
const message::Table::Field &field(int32_t field_position) const
441
assert(getTableMessage());
442
return getTableMessage()->field(field_position);
447
return table_proto->field(field_position);
450
inline void setTableProto(message::Table *arg)
452
assert(table_proto == NULL);
445
456
inline bool hasComment() const
447
return (getTableMessage()) ? getTableMessage()->options().has_comment() : false;
458
return (table_proto) ? table_proto->options().has_comment() : false;
450
461
inline const char *getComment()
452
return (getTableMessage() && getTableMessage()->has_options()) ? getTableMessage()->options().comment().c_str() : NULL;
463
return (table_proto && table_proto->has_options()) ? table_proto->options().comment().c_str() : NULL;
455
466
inline uint32_t getCommentLength() const
457
return (getTableMessage()) ? getTableMessage()->options().comment().length() : 0;
468
return (table_proto) ? table_proto->options().comment().length() : 0;
460
471
inline uint64_t getMaxRows() const
586
596
uint32_t next_number_keypart; /* autoinc keypart number in a key */
587
597
uint32_t error, open_errno, errarg; /* error from open_table_def() */
590
599
uint8_t blob_ptr_size; /* 4 or 8 */
593
uint8_t sizeBlobPtr() const
595
return blob_ptr_size;
598
600
bool db_low_byte_first; /* Portable row format */
608
610
event_observers is a class containing all the event plugins that have
609
611
registered an interest in this table.
611
virtual plugin::EventObserverList *getTableObservers()
614
plugin::EventObserverList *event_observers;
616
plugin::EventObserverList *getTableObservers()
618
return event_observers;
616
virtual void setTableObservers(plugin::EventObserverList *)
621
void setTableObservers(plugin::EventObserverList *observers)
623
event_observers= observers;
620
627
Set share's identifier information.
647
654
void init(const char *new_table_name,
648
655
const char *new_path);
651
658
void open_table_error(int pass_error, int db_errno, int pass_errarg);
655
660
static TableShare::shared_ptr getShareCreate(Session *session,
656
661
const identifier::Table &identifier,
720
725
bool &error_reported);
722
bool parse_table_proto(Session& session, message::Table &table);
727
int parse_table_proto(Session& session, message::Table &table);
724
virtual bool replicate() const
730
int inner_parse_table_proto(Session& session, message::Table &table);
730
733
} /* namespace drizzled */