31
32
#include <boost/thread/condition_variable.hpp>
32
33
#include <boost/dynamic_bitset.hpp>
33
34
#include <boost/shared_ptr.hpp>
34
#include <boost/scoped_ptr.hpp>
36
#include <drizzled/memory/root.h>
37
#include <drizzled/message.h>
38
#include <drizzled/util/string.h>
39
#include <drizzled/lex_string.h>
40
#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"
41
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");
45
58
const static std::string NO_PROTOBUFFER_AVAILABLE("NO PROTOBUFFER AVAILABLE");
62
class EventObserverList;
49
74
typedef std::vector<std::string> StringVector;
146
168
std::vector<uint> blob_field; /* Index to blobs in Field arrray*/
149
170
/* hash of field names (contains pointers to elements of field array) */
150
172
typedef boost::unordered_map < std::string, Field **, util::insensitive_hash, util::insensitive_equal_to> FieldMap;
151
173
typedef std::pair< std::string, Field ** > FieldMapPair;
152
174
FieldMap name_hash; /* hash of field names */
155
176
size_t getNamedFieldSize() const
339
358
uint64_t version;
342
360
uint64_t getVersion() const
347
void refreshVersion();
365
void refreshVersion()
367
version= refresh_version;
349
370
void resetVersion()
355
375
uint32_t timestamp_offset; /* Set to offset+1 of record */
357
uint32_t reclength; /* Recordlength */
358
uint32_t stored_rec_length; /* Stored record length*/
377
uint32_t reclength; /* Recordlength */
361
uint32_t sizeStoredRecord() const
363
return stored_rec_length;
379
uint32_t stored_rec_length; /* Stored record length*/
366
381
uint32_t getRecordLength() const
385
400
/* Max rows is a hint to HEAP during a create tmp table */
386
401
uint64_t max_rows;
388
boost::scoped_ptr<message::Table> _table_message;
403
message::Table *table_proto;
392
@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.
393
408
This will be modified once we use Identifiers in the Share itself.
395
410
message::Table::TableType getTableType() const
397
return getTableMessage() ? getTableMessage()->type() : message::Table::STANDARD;
412
return table_proto ? table_proto->type() : message::Table::STANDARD;
400
415
const std::string &getTableTypeAsString() const
402
if (getTableMessage())
403
return message::type(getTableMessage()->type());
405
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;
408
438
/* This is only used in one location currently */
409
inline message::Table *getTableMessage() const
411
return _table_message.get();
414
void setTableMessage(const message::Table &arg)
416
assert(not getTableMessage());
417
_table_message.reset(new message::Table(arg));
439
inline message::Table *getTableProto() const
420
444
const message::Table::Field &field(int32_t field_position) const
422
assert(getTableMessage());
423
return getTableMessage()->field(field_position);
447
return table_proto->field(field_position);
450
inline void setTableProto(message::Table *arg)
452
assert(table_proto == NULL);
426
456
inline bool hasComment() const
428
return getTableMessage() ? getTableMessage()->options().has_comment() : false;
458
return (table_proto) ? table_proto->options().has_comment() : false;
431
461
inline const char *getComment()
433
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;
436
466
inline uint32_t getCommentLength() const
438
return (getTableMessage()) ? getTableMessage()->options().comment().length() : 0;
468
return (table_proto) ? table_proto->options().comment().length() : 0;
441
471
inline uint64_t getMaxRows() const
567
596
uint32_t next_number_keypart; /* autoinc keypart number in a key */
568
597
uint32_t error, open_errno, errarg; /* error from open_table_def() */
571
599
uint8_t blob_ptr_size; /* 4 or 8 */
574
uint8_t sizeBlobPtr() const
576
return blob_ptr_size;
579
600
bool db_low_byte_first; /* Portable row format */
589
610
event_observers is a class containing all the event plugins that have
590
611
registered an interest in this table.
592
virtual plugin::EventObserverList *getTableObservers()
614
plugin::EventObserverList *event_observers;
616
plugin::EventObserverList *getTableObservers()
618
return event_observers;
597
virtual void setTableObservers(plugin::EventObserverList *)
621
void setTableObservers(plugin::EventObserverList *observers)
623
event_observers= observers;
601
627
Set share's identifier information.
628
654
void init(const char *new_table_name,
629
655
const char *new_path);
632
658
void open_table_error(int pass_error, int db_errno, int pass_errarg);
636
660
static TableShare::shared_ptr getShareCreate(Session *session,
637
661
const identifier::Table &identifier,
701
725
bool &error_reported);
703
bool parse_table_proto(Session& session, const message::Table &table);
727
int parse_table_proto(Session& session, message::Table &table);
705
virtual bool is_replicated() const
730
int inner_parse_table_proto(Session& session, message::Table &table);
711
733
} /* namespace drizzled */
735
#endif /* DRIZZLED_TABLE_INSTANCE_BASE_H */