~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.h

  • Committer: Vijay Samuel
  • Date: 2010-09-10 21:03:37 UTC
  • mto: (1757.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1758.
  • Revision ID: vijay@vijay-20100910210337-rf7c2ymawtqj6tkv
Merge added utf 8 tamil test case suite and test case for creating a database in tamil.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#define DRIZZLED_TABLE_H
25
25
 
26
26
#include <string>
27
 
#include <boost/dynamic_bitset.hpp>
28
27
 
29
28
#include "drizzled/order.h"
30
29
#include "drizzled/filesort_info.h"
61
60
 */
62
61
class Table 
63
62
{
64
 
  TableShare *_share; /**< Pointer to the shared metadata about the table */
 
63
public:
 
64
  TableShare *s; /**< Pointer to the shared metadata about the table */
65
65
 
 
66
private:
66
67
  Field **field; /**< Pointer to fields collection */
67
68
public:
68
69
 
129
130
    prev= arg;
130
131
  }
131
132
 
132
 
  boost::dynamic_bitset<> *read_set; /* Active column sets */
133
 
  boost::dynamic_bitset<> *write_set; /* Active column sets */
 
133
  MyBitmap *read_set; /* Active column sets */
 
134
  MyBitmap *write_set; /* Active column sets */
134
135
 
135
136
  uint32_t tablenr;
136
137
  uint32_t db_stat; /**< information about the cursor as in Cursor.h */
137
138
 
138
 
  boost::dynamic_bitset<> def_read_set; /**< Default read set of columns */
139
 
  boost::dynamic_bitset<> def_write_set; /**< Default write set of columns */
140
 
  boost::dynamic_bitset<> tmp_set; /* Not sure about this... */
 
139
  MyBitmap def_read_set; /**< Default read set of columns */
 
140
  MyBitmap def_write_set; /**< Default write set of columns */
 
141
  MyBitmap tmp_set; /* Not sure about this... */
141
142
 
142
143
  Session *in_use; /**< Pointer to the current session using this object */
143
144
  Session *getSession()
353
354
    return mem_root.strmake_root(str_arg, len_arg);
354
355
  }
355
356
 
356
 
  filesort_info sort;
 
357
  filesort_info_st sort;
357
358
 
358
359
  Table();
359
360
  virtual ~Table() { };
370
371
  void resetTable(Session *session, TableShare *share, uint32_t db_stat_arg);
371
372
 
372
373
  /* SHARE methods */
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
 
  inline bool hasShare() const { return _share ? true : false ; } /* Get rid of this long term */
376
 
  inline void setShare(TableShare *new_share) { _share= new_share; } /* Get rid of this long term */
377
 
  inline uint32_t sizeKeys() { return _share->sizeKeys(); }
378
 
  inline uint32_t sizeFields() { return _share->sizeFields(); }
379
 
  inline uint32_t getRecordLength() const { return _share->getRecordLength(); }
380
 
  inline uint32_t sizeBlobFields() { return _share->blob_fields; }
381
 
  inline uint32_t *getBlobField() { return &_share->blob_field[0]; }
 
374
  inline const TableShare *getShare() const { assert(s); return s; } /* Get rid of this long term */
 
375
  inline bool hasShare() const { return s ? true : false ; } /* Get rid of this long term */
 
376
  inline TableShare *getMutableShare() { assert(s); return s; } /* Get rid of this long term */
 
377
  inline void setShare(TableShare *new_share) { s= new_share; } /* Get rid of this long term */
 
378
  inline uint32_t sizeKeys() { return s->sizeKeys(); }
 
379
  inline uint32_t sizeFields() { return s->sizeFields(); }
 
380
  inline uint32_t getRecordLength() const { return s->getRecordLength(); }
 
381
  inline uint32_t sizeBlobFields() { return s->blob_fields; }
 
382
  inline uint32_t *getBlobField() { return &s->blob_field[0]; }
382
383
 
383
384
  Field_blob *getBlobFieldAt(uint32_t arg) const
384
385
  {
385
 
    if (arg < getShare()->blob_fields)
386
 
      return (Field_blob*) field[getShare()->blob_field[arg]]; /*NOTE: Using 'Table.field' NOT SharedTable.field. */
 
386
    if (arg < s->blob_fields)
 
387
      return (Field_blob*) field[s->blob_field[arg]]; /*NOTE: Using 'Table.field' NOT SharedTable.field. */
387
388
 
388
389
    return NULL;
389
390
  }
390
 
  inline uint8_t getBlobPtrSize() { return getShare()->blob_ptr_size; }
391
 
  inline uint32_t getNullBytes() { return getShare()->null_bytes; }
392
 
  inline uint32_t getNullFields() { return getShare()->null_fields; }
393
 
  inline unsigned char *getDefaultValues() { return  getMutableShare()->getDefaultValues(); }
394
 
  inline const char *getSchemaName()  const { return getShare()->getSchemaName(); }
395
 
  inline const char *getTableName()  const { return getShare()->getTableName(); }
 
391
  inline uint8_t getBlobPtrSize() { return s->blob_ptr_size; }
 
392
  inline uint32_t getNullBytes() { return s->null_bytes; }
 
393
  inline uint32_t getNullFields() { return s->null_fields; }
 
394
  inline unsigned char *getDefaultValues() { return  s->getDefaultValues(); }
 
395
  inline const char *getSchemaName()  const { return s->getSchemaName(); }
 
396
  inline const char *getTableName()  const { return s->getTableName(); }
396
397
 
397
 
  inline bool isDatabaseLowByteFirst() { return getShare()->db_low_byte_first; } /* Portable row format */
398
 
  inline bool isNameLock() const { return getShare()->isNameLock(); }
399
 
  inline bool isReplaceWithNameLock() { return getShare()->replace_with_name_lock; }
 
398
  inline bool isDatabaseLowByteFirst() { return s->db_low_byte_first; } /* Portable row format */
 
399
  inline bool isNameLock() const { return s->isNameLock(); }
 
400
  inline bool isReplaceWithNameLock() { return s->replace_with_name_lock; }
400
401
 
401
402
  uint32_t index_flags(uint32_t idx) const
402
403
  {
403
 
    return getShare()->storage_engine->index_flags(getShare()->getKeyInfo(idx).algorithm);
 
404
    return s->storage_engine->index_flags(s->getKeyInfo(idx).algorithm);
404
405
  }
405
406
 
406
407
  inline plugin::StorageEngine *getEngine() const   /* table_type for handler */
407
408
  {
408
 
    return getShare()->storage_engine;
 
409
    return s->storage_engine;
409
410
  }
410
411
 
411
412
  Cursor &getCursor() const /* table_type for handler */
415
416
  }
416
417
 
417
418
  /* For TMP tables, should be pulled out as a class */
418
 
  void setup_tmp_table_column_bitmaps();
 
419
  void setup_tmp_table_column_bitmaps(unsigned char *bitmaps);
419
420
  bool create_myisam_tmp_table(KeyInfo *keyinfo,
420
421
                               MI_COLUMNDEF *start_recinfo,
421
422
                               MI_COLUMNDEF **recinfo,
456
457
  bool fill_item_list(List<Item> *item_list) const;
457
458
  void clear_column_bitmaps(void);
458
459
  void prepare_for_position(void);
459
 
  void mark_columns_used_by_index_no_reset(uint32_t index, boost::dynamic_bitset<>& bitmap);
 
460
  void mark_columns_used_by_index_no_reset(uint32_t index, MyBitmap *map);
460
461
  void mark_columns_used_by_index_no_reset(uint32_t index);
461
462
  void mark_columns_used_by_index(uint32_t index);
462
463
  void restore_column_maps_after_mark_index();
464
465
  void mark_columns_needed_for_update(void);
465
466
  void mark_columns_needed_for_delete(void);
466
467
  void mark_columns_needed_for_insert(void);
467
 
  void column_bitmaps_set(boost::dynamic_bitset<>& read_set_arg,
468
 
                          boost::dynamic_bitset<>& write_set_arg);
469
 
 
470
 
  void restore_column_map(const boost::dynamic_bitset<>& old);
471
 
 
472
 
  const boost::dynamic_bitset<> use_all_columns(boost::dynamic_bitset<>& map);
 
468
  inline void column_bitmaps_set(MyBitmap *read_set_arg,
 
469
                                 MyBitmap *write_set_arg)
 
470
  {
 
471
    read_set= read_set_arg;
 
472
    write_set= write_set_arg;
 
473
  }
 
474
 
 
475
  void restore_column_map(my_bitmap_map *old);
 
476
 
 
477
  my_bitmap_map *use_all_columns(MyBitmap *bitmap);
473
478
  inline void use_all_columns()
474
479
  {
475
 
    column_bitmaps_set(getMutableShare()->all_set, getMutableShare()->all_set);
 
480
    column_bitmaps_set(&s->all_set, &s->all_set);
476
481
  }
477
482
 
478
483
  inline void default_column_bitmaps()
484
489
  /* Both of the below should go away once we can move this bit to the field objects */
485
490
  inline bool isReadSet(uint32_t index)
486
491
  {
487
 
    return read_set->test(index);
 
492
    return read_set->isBitSet(index);
488
493
  }
489
494
 
490
495
  inline void setReadSet(uint32_t index)
491
496
  {
492
 
    read_set->set(index);
 
497
    read_set->setBit(index);
493
498
  }
494
499
 
495
500
  inline void setReadSet()
496
501
  {
497
 
    read_set->set();
 
502
    read_set->setAll();
498
503
  }
499
504
 
500
505
  inline void clearReadSet(uint32_t index)
501
506
  {
502
 
    read_set->reset(index);
 
507
    read_set->clearBit(index);
503
508
  }
504
509
 
505
510
  inline void clearReadSet()
506
511
  {
507
 
    read_set->reset();
 
512
    read_set->clearAll();
508
513
  }
509
514
 
510
515
  inline bool isWriteSet(uint32_t index)
511
516
  {
512
 
    return write_set->test(index);
 
517
    return write_set->isBitSet(index);
513
518
  }
514
519
 
515
520
  inline void setWriteSet(uint32_t index)
516
521
  {
517
 
    write_set->set(index);
 
522
    write_set->setBit(index);
518
523
  }
519
524
 
520
525
  inline void setWriteSet()
521
526
  {
522
 
    write_set->set();
 
527
    write_set->setAll();
523
528
  }
524
529
 
525
530
  inline void clearWriteSet(uint32_t index)
526
531
  {
527
 
    write_set->reset(index);
 
532
    write_set->clearBit(index);
528
533
  }
529
534
 
530
535
  inline void clearWriteSet()
531
536
  {
532
 
    write_set->reset();
 
537
    write_set->clearAll();
533
538
  }
534
539
 
535
540
  /* Is table open or should be treated as such by name-locking? */
542
547
  */
543
548
  inline bool needs_reopen_or_name_lock()
544
549
  { 
545
 
    return getShare()->getVersion() != refresh_version;
 
550
    return s->getVersion() != refresh_version;
546
551
  }
547
552
 
548
553
  /**
557
562
  {
558
563
    null_row= 1;
559
564
    status|= STATUS_NULL_ROW;
560
 
    memset(null_flags, 255, getShare()->null_bytes);
 
565
    memset(null_flags, 255, s->null_bytes);
561
566
  }
562
567
 
563
568
  void free_io_cache();
566
571
 
567
572
  void print_error(int error, myf errflag)
568
573
  {
569
 
    getShare()->storage_engine->print_error(error, errflag, *this);
 
574
    s->storage_engine->print_error(error, errflag, *this);
570
575
  }
571
576
 
572
577
  /**
821
826
class select_union;
822
827
class Tmp_Table_Param;
823
828
 
 
829
struct open_table_list_st
 
830
{
 
831
  std::string   db;
 
832
  std::string   table;
 
833
  uint32_t in_use;
 
834
  uint32_t locked;
 
835
 
 
836
  open_table_list_st() :
 
837
    in_use(0),
 
838
    locked(0)
 
839
  { }
 
840
 
 
841
};
 
842
 
824
843
void free_blobs(Table *table);
825
844
int set_zone(int nr,int min_zone,int max_zone);
826
845
uint32_t convert_period_to_month(uint32_t period);