~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table/instance/base.h

  • Committer: Brian Aker
  • Date: 2011-02-03 20:32:09 UTC
  • mfrom: (2139.1.4 drizzle-build)
  • Revision ID: brian@tangent.org-20110203203209-r1t4knmy15x5n1w2
Rollup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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>
35
36
 
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"
40
41
 
41
42
#include "drizzled/lex_string.h"
51
52
 
52
53
extern uint64_t refresh_version;
53
54
 
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");
59
56
 
60
57
namespace plugin
106
103
 
107
104
  /* The following is copied to each Table on OPEN */
108
105
  typedef std::vector<Field *> Fields;
 
106
 
109
107
private:
110
108
  Fields _fields;
111
109
 
141
139
    _fields.push_back(arg);
142
140
  }
143
141
 
144
 
 
145
142
  Field **found_next_number_field;
 
143
 
146
144
private:
147
145
  Field *timestamp_field;               /* Used only during open */
 
146
 
148
147
public:
149
148
 
150
149
  Field *getTimestampField() const               /* Used only during open */
160
159
 
161
160
private:
162
161
  KeyInfo  *key_info;                   /* data of keys in database */
 
162
 
163
163
public:
164
164
  KeyInfo &getKeyInfo(uint32_t arg) const
165
165
  {
167
167
  }
168
168
  std::vector<uint>     blob_field;                     /* Index to blobs in Field arrray*/
169
169
 
 
170
private:
170
171
  /* hash of field names (contains pointers to elements of field array) */
171
 
private:
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 */
 
175
 
175
176
public:
176
177
  size_t getNamedFieldSize() const
177
178
  {
284
285
  LEX_STRING table_name;                /* Table name (for open) */
285
286
  LEX_STRING path;      /* Path to table (from datadir) */
286
287
  LEX_STRING normalized_path;           /* unpack_filename(path) */
 
288
 
287
289
public:
288
290
 
289
291
  const char *getNormalizedPath() const
319
321
    normalized_path.str= str_arg;
320
322
    normalized_path.length= size_arg;
321
323
  }
 
324
 
322
325
public:
323
326
 
324
327
  const char *getTableName() const
356
359
 
357
360
private:
358
361
  uint64_t   version;
 
362
 
359
363
public:
360
364
  uint64_t getVersion() const
361
365
  {
372
376
    version= 0;
373
377
  }
374
378
 
 
379
private:
375
380
  uint32_t   timestamp_offset;          /* Set to offset+1 of record */
376
 
private:
377
 
  uint32_t   reclength;                 /* Recordlength */
 
381
 
 
382
  uint32_t reclength;                   /* Recordlength */
 
383
  uint32_t stored_rec_length;         /* Stored record length*/
 
384
 
378
385
public:
379
 
  uint32_t   stored_rec_length;         /* Stored record length*/
 
386
  uint32_t sizeStoredRecord() const
 
387
  {
 
388
    return stored_rec_length;
 
389
  }
380
390
 
381
391
  uint32_t getRecordLength() const
382
392
  {
400
410
  /* Max rows is a hint to HEAP during a create tmp table */
401
411
  uint64_t max_rows;
402
412
 
403
 
  message::Table *table_proto;
 
413
  boost::scoped_ptr<message::Table> _table_message;
 
414
 
404
415
public:
405
 
 
406
416
  /*
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.
409
419
  */
410
420
  message::Table::TableType getTableType() const
411
421
  {
412
 
    return table_proto ? table_proto->type() : message::Table::STANDARD;
 
422
    return getTableMessage() ? getTableMessage()->type() : message::Table::STANDARD;
413
423
  }
414
424
 
415
425
  const std::string &getTableTypeAsString() const
416
426
  {
417
 
    if (table_proto)
418
 
    {
419
 
      switch (table_proto->type())
420
 
      {
421
 
      default:
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;
430
 
      }
431
 
    }
432
 
    else
433
 
    {
434
 
      return NO_PROTOBUFFER_AVAILABLE;
435
 
    }
 
427
    if (getTableMessage())
 
428
      return message::type(getTableMessage()->type());
 
429
 
 
430
    return NO_PROTOBUFFER_AVAILABLE;
436
431
  }
437
432
 
438
433
  /* This is only used in one location currently */
439
 
  inline message::Table *getTableProto() const
440
 
  {
441
 
    return table_proto;
 
434
  inline message::Table *getTableMessage() const
 
435
  {
 
436
    return _table_message.get();
 
437
  }
 
438
 
 
439
  void setTableMessage(const message::Table &arg)
 
440
  {
 
441
    assert(not getTableMessage());
 
442
    _table_message.reset(new(std::nothrow) message::Table(arg));
442
443
  }
443
444
 
444
445
  const message::Table::Field &field(int32_t field_position) const
445
446
  {
446
 
    assert(table_proto);
447
 
    return table_proto->field(field_position);
448
 
  }
449
 
 
450
 
  inline void setTableProto(message::Table *arg)
451
 
  {
452
 
    assert(table_proto == NULL);
453
 
    table_proto= arg;
 
447
    assert(getTableMessage());
 
448
    return getTableMessage()->field(field_position);
454
449
  }
455
450
 
456
451
  inline bool hasComment() const
457
452
  {
458
 
    return (table_proto) ?  table_proto->options().has_comment() : false; 
 
453
    return (getTableMessage()) ?  getTableMessage()->options().has_comment() : false; 
459
454
  }
460
455
 
461
456
  inline const char *getComment()
462
457
  {
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; 
464
459
  }
465
460
 
466
461
  inline uint32_t getCommentLength() const
467
462
  {
468
 
    return (table_proto) ? table_proto->options().comment().length() : 0; 
 
463
    return (getTableMessage()) ? getTableMessage()->options().comment().length() : 0; 
469
464
  }
470
465
 
471
466
  inline uint64_t getMaxRows() const
554
549
  uint32_t blob_fields;                 /* number of blob fields */
555
550
private:
556
551
  bool has_variable_width;                  /* number of varchar fields */
 
552
 
557
553
public:
558
554
  bool hasVariableWidth() const
559
555
  {
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() */
598
594
 
 
595
private:
599
596
  uint8_t blob_ptr_size;                        /* 4 or 8 */
 
597
 
 
598
public:
 
599
  uint8_t sizeBlobPtr() const
 
600
  {
 
601
    return blob_ptr_size;
 
602
  }
 
603
 
600
604
  bool db_low_byte_first;               /* Portable row format */
601
605
 
602
606
  /*