~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.h

  • Committer: Padraig O'Sullivan
  • Date: 2010-10-16 19:31:35 UTC
  • mto: (1859.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1860.
  • Revision ID: osullivan.padraig@gmail.com-20101016193135-75fdbfizty54g9of
Replaced a uint8_t member with a standard bitset since it was being used as a bitset....

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include "drizzled/cursor.h"
34
34
#include "drizzled/lex_string.h"
35
35
#include "drizzled/table_list.h"
36
 
#include "drizzled/definition/table.h"
 
36
#include "drizzled/table_share.h"
37
37
#include "drizzled/atomics.h"
38
38
#include "drizzled/query_id.h"
39
39
 
61
61
 */
62
62
class Table 
63
63
{
 
64
  TableShare *_share; /**< Pointer to the shared metadata about the table */
 
65
 
64
66
  Field **field; /**< Pointer to fields collection */
65
67
public:
66
68
 
161
163
  Field_timestamp *timestamp_field; /**< Points to the auto-setting timestamp field, if any */
162
164
 
163
165
  TableList *pos_in_table_list; /* Element referring to this table */
164
 
  Order *group;
 
166
  order_st *group;
165
167
  
166
168
  const char *getAlias() const
167
169
  {
168
 
    return _alias.c_str();
169
 
  }
170
 
 
171
 
  void clearAlias()
172
 
  {
173
 
    _alias.clear();
174
 
  }
175
 
 
176
 
  void setAlias(const char *arg)
177
 
  {
178
 
    _alias= arg;
179
 
  }
180
 
 
181
 
private:
182
 
  std::string _alias; /**< alias or table name if no alias */
183
 
public:
 
170
    return alias;
 
171
  }
 
172
 
 
173
  const char *alias; /**< alias or table name if no alias */
184
174
 
185
175
  unsigned char *null_flags;
186
176
 
366
356
  filesort_info sort;
367
357
 
368
358
  Table();
369
 
  virtual ~Table();
 
359
  virtual ~Table() { };
370
360
 
371
361
  int report_error(int error);
372
362
  /**
380
370
  void resetTable(Session *session, TableShare *share, uint32_t db_stat_arg);
381
371
 
382
372
  /* SHARE methods */
383
 
  virtual const TableShare *getShare() const= 0; /* Get rid of this long term */
384
 
  virtual TableShare *getMutableShare()= 0; /* Get rid of this long term */
385
 
  virtual bool hasShare() const= 0; /* Get rid of this long term */
386
 
  virtual void setShare(TableShare *new_share)= 0; /* Get rid of this long term */
387
 
 
388
 
  virtual void release(void)= 0;
389
 
 
390
 
  uint32_t sizeKeys() { return getMutableShare()->sizeKeys(); }
391
 
  uint32_t sizeFields() { return getMutableShare()->sizeFields(); }
392
 
  uint32_t getRecordLength() const { return getShare()->getRecordLength(); }
393
 
  uint32_t sizeBlobFields() { return getMutableShare()->blob_fields; }
394
 
  uint32_t *getBlobField() { return &getMutableShare()->blob_field[0]; }
 
373
  virtual const TableShare *getShare() const { assert(_share); return _share; } /* Get rid of this long term */
 
374
  virtual TableShare *getMutableShare() { assert(_share); return _share; } /* Get rid of this long term */
 
375
  bool hasShare() const { return _share ? true : false ; } /* Get rid of this long term */
 
376
  virtual void setShare(TableShare *new_share) { _share= new_share; } /* Get rid of this long term */
 
377
  uint32_t sizeKeys() { return _share->sizeKeys(); }
 
378
  uint32_t sizeFields() { return _share->sizeFields(); }
 
379
  uint32_t getRecordLength() const { return _share->getRecordLength(); }
 
380
  uint32_t sizeBlobFields() { return _share->blob_fields; }
 
381
  uint32_t *getBlobField() { return &_share->blob_field[0]; }
395
382
 
396
383
public:
397
384
  virtual bool hasVariableWidth() const
416
403
  inline const char *getTableName()  const { return getShare()->getTableName(); }
417
404
 
418
405
  inline bool isDatabaseLowByteFirst() { return getShare()->db_low_byte_first; } /* Portable row format */
419
 
  inline bool isNameLock() const { return open_placeholder; }
 
406
  inline bool isNameLock() const { return getShare()->isNameLock(); }
 
407
  inline bool isReplaceWithNameLock() { return getShare()->replace_with_name_lock; }
420
408
 
421
409
  uint32_t index_flags(uint32_t idx) const
422
410
  {
437
425
  size_t max_row_length(const unsigned char *data);
438
426
  uint32_t find_shortest_key(const key_map *usable_keys);
439
427
  bool compare_record(Field **ptr);
440
 
  bool records_are_comparable();
441
 
  bool compare_records();
 
428
  bool compare_record();
442
429
  /* TODO: the (re)storeRecord's may be able to be further condensed */
443
430
  void storeRecord();
444
431
  void storeRecordAsInsert();
447
434
  void restoreRecordAsDefault();
448
435
  void emptyRecord();
449
436
 
450
 
 
451
437
  /* See if this can be blown away */
452
438
  inline uint32_t getDBStat () { return db_stat; }
453
439
  inline uint32_t setDBStat () { return db_stat; }
603
589
  */
604
590
  bool operator<(const Table &right) const
605
591
  {
606
 
    return getShare()->getCacheKey() < right.getShare()->getCacheKey();
 
592
    int result= strcasecmp(this->getShare()->getSchemaName(), right.getShare()->getSchemaName());
 
593
 
 
594
    if (result <  0)
 
595
      return true;
 
596
 
 
597
    if (result >  0)
 
598
      return false;
 
599
 
 
600
    result= strcasecmp(this->getShare()->getTableName(), right.getShare()->getTableName());
 
601
 
 
602
    if (result <  0)
 
603
      return true;
 
604
 
 
605
    if (result >  0)
 
606
      return false;
 
607
 
 
608
    if (this->getShare()->getTableProto()->type()  < right.getShare()->getTableProto()->type())
 
609
      return true;
 
610
 
 
611
    return false;
607
612
  }
608
613
 
609
614
  static bool compare(const Table *a, const Table *b)
613
618
 
614
619
  friend std::ostream& operator<<(std::ostream& output, const Table &table)
615
620
  {
616
 
    if (table.getShare())
617
 
    {
618
 
      output << "Table:(";
619
 
      output << table.getShare()->getSchemaName();
620
 
      output << ", ";
621
 
      output <<  table.getShare()->getTableName();
622
 
      output << ", ";
623
 
      output <<  table.getShare()->getTableTypeAsString();
624
 
      output << ")";
625
 
    }
626
 
    else
627
 
    {
628
 
      output << "Table:(has no share)";
629
 
    }
 
621
    output << "Table:(";
 
622
    output << table.getShare()->getSchemaName();
 
623
    output << ", ";
 
624
    output <<  table.getShare()->getTableName();
 
625
    output << ", ";
 
626
    output <<  table.getShare()->getTableTypeAsString();
 
627
    output << ")";
630
628
 
631
629
    return output;  // for multiple << operators.
632
630
  }
830
828
 
831
829
namespace optimizer { class SqlSelect; }
832
830
 
 
831
ha_rows filesort(Session *session,
 
832
                 Table *form,
 
833
                 SortField *sortorder,
 
834
                 uint32_t s_length,
 
835
                 optimizer::SqlSelect *select,
 
836
                 ha_rows max_rows,
 
837
                 bool sort_positions,
 
838
                 ha_rows *examined_rows);
 
839
 
 
840
void filesort_free_buffers(Table *table, bool full);
833
841
void change_double_for_sort(double nr,unsigned char *to);
834
842
double my_double_round(double value, int64_t dec, bool dec_unsigned,
835
843
                       bool truncate);
839
847
TYPELIB *convert_strings_to_array_type(char * *typelibs, char * *end);
840
848
TYPELIB *typelib(memory::Root *mem_root, List<String> &strings);
841
849
ulong get_form_pos(int file, unsigned char *head, TYPELIB *save_names);
 
850
ulong next_io_size(ulong pos);
842
851
void append_unescaped(String *res, const char *pos, uint32_t length);
843
852
 
844
853
int rename_file_ext(const char * from,const char * to,const char * ext);