~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2011-01-13 07:03:39 UTC
  • mfrom: (2077.1.3 drizzle)
  • Revision ID: brian@gir-3-20110113070339-bnfp4yvngb6frhru
Merge in all of the fixes for definition to instance.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
  instance of table share per one table in the database.
24
24
*/
25
25
 
26
 
#ifndef DRIZZLED_DEFINITION_TABLE_H
27
 
#define DRIZZLED_DEFINITION_TABLE_H
 
26
#ifndef DRIZZLED_TABLE_INSTANCE_BASE_H
 
27
#define DRIZZLED_TABLE_INSTANCE_BASE_H
28
28
 
29
29
#include <string>
30
30
 
38
38
#include "drizzled/message/table.pb.h"
39
39
#include "drizzled/util/string.h"
40
40
 
 
41
#include "drizzled/lex_string.h"
 
42
#include "drizzled/key_map.h"
 
43
 
41
44
#include "drizzled/table/cache.h"
 
45
 
 
46
#include <drizzled/field.h>
 
47
 
42
48
 
43
49
namespace drizzled
44
50
{
54
60
namespace plugin
55
61
{
56
62
class EventObserverList;
 
63
class StorageEngine;
57
64
}
58
65
 
59
66
namespace table {
60
 
class Instance;
 
67
class Singular;
61
68
}
62
69
 
63
70
class Field_blob;
80
87
             const TableIdentifier &identifier,
81
88
             char *path_arg= NULL, uint32_t path_length_arg= 0); // Shares for cache
82
89
 
83
 
  ~TableShare();
 
90
  virtual ~TableShare();
84
91
 
85
92
private:
86
93
  /** Category of this table. */
87
94
  enum_table_category table_category;
88
95
 
89
96
public:
90
 
 
91
97
  bool isTemporaryCategory() const
92
98
  {
93
99
    return (table_category == TABLE_CATEGORY_TEMPORARY);
102
108
  typedef std::vector<Field *> Fields;
103
109
private:
104
110
  Fields _fields;
 
111
 
105
112
public:
106
113
  const Fields getFields() const
107
114
  {
207
214
                   arg.begin(), ::toupper);
208
215
    _keynames.push_back(arg);
209
216
  }
 
217
 
210
218
public:
211
219
  bool doesKeyNameExist(const char *name_arg, uint32_t name_length, uint32_t &position) const
212
220
  {
234
242
private:
235
243
  std::vector<TYPELIB> intervals;                       /* pointer to interval info */
236
244
 
237
 
  boost::mutex mutex;                /* For locking the share  */
238
 
  boost::condition_variable cond;                       /* To signal that share is ready */
239
 
 
240
 
 
241
 
  void lock()
242
 
  {
243
 
    mutex.lock();
244
 
  }
245
 
 
246
 
  void unlock()
247
 
  {
248
 
    mutex.unlock();
249
 
  }
250
 
 
 
245
public:
 
246
  virtual void lock()
 
247
  { }
 
248
 
 
249
  virtual void unlock()
 
250
  { }
 
251
 
 
252
private:
251
253
  std::vector<unsigned char> default_values;            /* row with default values */
 
254
 
252
255
public:
253
256
  // @note This needs to be made to be const in the future
254
257
  unsigned char *getDefaultValues()
260
263
    default_values.resize(arg);
261
264
  }
262
265
 
263
 
  const CHARSET_INFO *table_charset; /* Default charset of string fields */
 
266
  const charset_info_st *table_charset; /* Default charset of string fields */
264
267
 
265
268
  boost::dynamic_bitset<> all_set;
266
269
 
501
504
  }
502
505
 
503
506
private:
504
 
  uint32_t ref_count;       /* How many Table objects uses this */
 
507
  uint32_t _ref_count;       /* How many Table objects uses this */
505
508
 
506
509
public:
507
510
  uint32_t getTableCount() const
508
511
  {
509
 
    return ref_count;
 
512
    return _ref_count;
510
513
  }
511
514
 
512
515
  void incrementTableCount()
513
516
  {
514
517
    lock();
515
 
    ref_count++;
 
518
    _ref_count++;
516
519
    unlock();
517
520
  }
518
521
 
 
522
  uint32_t decrementTableCount()
 
523
  {
 
524
    return --_ref_count;
 
525
  }
 
526
 
519
527
  uint32_t null_bytes;
520
528
  uint32_t last_null_bit_pos;
521
529
private:
649
657
 
650
658
  void open_table_error(int pass_error, int db_errno, int pass_errarg);
651
659
 
652
 
  static void release(TableShare *share);
653
 
  static void release(TableShare::shared_ptr &share);
654
 
  static void release(const TableIdentifier &identifier);
655
660
  static TableShare::shared_ptr getShareCreate(Session *session, 
656
661
                                               const TableIdentifier &identifier,
657
662
                                               int &error);
672
677
  }
673
678
 
674
679
protected:
675
 
  friend class drizzled::table::Instance;
 
680
  friend class drizzled::table::Singular;
676
681
 
677
682
  Field *make_field(const message::Table::Field &pfield,
678
683
                    unsigned char *ptr,
682
687
                    unsigned char null_bit,
683
688
                    uint8_t decimals,
684
689
                    enum_field_types field_type,
685
 
                    const CHARSET_INFO * field_charset,
 
690
                    const charset_info_st * field_charset,
686
691
                    Field::utype unireg_check,
687
692
                    TYPELIB *interval,
688
693
                    const char *field_name);
695
700
                    unsigned char null_bit,
696
701
                    uint8_t decimals,
697
702
                    enum_field_types field_type,
698
 
                    const CHARSET_INFO * field_charset,
 
703
                    const charset_info_st * field_charset,
699
704
                    Field::utype unireg_check,
700
705
                    TYPELIB *interval,
701
706
                    const char *field_name, 
726
731
 
727
732
} /* namespace drizzled */
728
733
 
729
 
#endif /* DRIZZLED_DEFINITION_TABLE_H */
 
734
#endif /* DRIZZLED_TABLE_INSTANCE_BASE_H */