~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.h

  • Committer: Olaf van der Spek
  • Date: 2011-03-23 10:31:37 UTC
  • mto: (2247.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 2248.
  • Revision ID: olafvdspek@gmail.com-20110323103137-lwevis2tfchgu18u
Propogate return void

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
/* Structs that defines the Table */
22
22
 
23
 
#ifndef DRIZZLED_TABLE_H
24
 
#define DRIZZLED_TABLE_H
 
23
 
 
24
 
 
25
#pragma once
25
26
 
26
27
#include <string>
27
28
#include <boost/dynamic_bitset.hpp>
28
29
 
29
 
#include "drizzled/order.h"
30
 
#include "drizzled/filesort_info.h"
31
 
#include "drizzled/natural_join_column.h"
32
 
#include "drizzled/field_iterator.h"
33
 
#include "drizzled/cursor.h"
34
 
#include "drizzled/lex_string.h"
35
 
#include "drizzled/table_list.h"
36
 
#include "drizzled/definition/table.h"
37
 
#include "drizzled/atomics.h"
38
 
#include "drizzled/query_id.h"
39
 
 
40
 
namespace drizzled
41
 
{
42
 
 
 
30
#include <drizzled/order.h>
 
31
#include <drizzled/filesort_info.h>
 
32
#include <drizzled/natural_join_column.h>
 
33
#include <drizzled/field_iterator.h>
 
34
#include <drizzled/cursor.h>
 
35
#include <drizzled/lex_string.h>
 
36
#include <drizzled/table/instance.h>
 
37
#include <drizzled/atomics.h>
 
38
 
 
39
#include <drizzled/visibility.h>
 
40
 
 
41
namespace drizzled {
 
42
 
 
43
class COND_EQUAL;
 
44
class Field_blob;
43
45
class Item;
44
46
class Item_subselect;
 
47
class SecurityContext;
 
48
class Select_Lex;
45
49
class Select_Lex_Unit;
46
 
class Select_Lex;
47
 
class COND_EQUAL;
48
 
class SecurityContext;
49
50
class TableList;
50
 
class Field_timestamp;
51
 
class Field_blob;
52
 
 
53
 
extern uint64_t refresh_version;
 
51
namespace field { class Epoch; }
 
52
namespace plugin { class StorageEngine; }
54
53
 
55
54
typedef enum enum_table_category TABLE_CATEGORY;
56
55
typedef struct st_columndef MI_COLUMNDEF;
 
56
typedef uint64_t query_id_t;
57
57
 
58
58
/**
59
59
 * Class representing a set of records, either in a temporary, 
60
60
 * normal, or derived table.
61
61
 */
62
 
class Table 
 
62
class DRIZZLED_API Table 
63
63
{
64
64
  Field **field; /**< Pointer to fields collection */
 
65
 
65
66
public:
66
 
 
67
67
  Field **getFields() const
68
68
  {
69
69
    return field;
85
85
  }
86
86
 
87
87
  Cursor *cursor; /**< Pointer to the storage engine's Cursor managing this table */
 
88
 
88
89
private:
89
90
  Table *next;
 
91
 
90
92
public:
91
93
  Table *getNext() const
92
94
  {
143
145
    return in_use;
144
146
  }
145
147
 
146
 
  unsigned char *getInsertRecord()
 
148
  unsigned char *getInsertRecord() const
147
149
  {
148
150
    return record[0];
149
151
  }
158
160
  KeyInfo  *key_info; /**< data of keys in database */
159
161
  Field *next_number_field; /**< Set if next_number is activated. @TODO What the heck is the difference between this and the next member? */
160
162
  Field *found_next_number_field; /**< Points to the "next-number" field (autoincrement field) */
161
 
  Field_timestamp *timestamp_field; /**< Points to the auto-setting timestamp field, if any */
 
163
  field::Epoch *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
166
  Order *group;
280
282
    statement then the variable contains TIMESTAMP_NO_AUTO_SET (i.e. 0).
281
283
 
282
284
    Value of this variable is set for each statement in open_table() and
283
 
    if needed cleared later in statement processing code (see mysql_update()
 
285
    if needed cleared later in statement processing code (see update_query()
284
286
    as example).
285
287
  */
286
288
  timestamp_auto_set_type timestamp_field_type;
308
310
    The set is implemented as a bitmap.
309
311
  */
310
312
  key_map keys_in_use_for_query;
 
313
 
311
314
  /* Map of keys that can be used to calculate GROUP BY without sorting */
312
315
  key_map keys_in_use_for_group_by;
 
316
 
313
317
  /* Map of keys that can be used to calculate ORDER BY without sorting */
314
318
  key_map keys_in_use_for_order_by;
315
319
 
408
412
 
409
413
    return NULL;
410
414
  }
411
 
  inline uint8_t getBlobPtrSize() { return getShare()->blob_ptr_size; }
412
 
  inline uint32_t getNullBytes() { return getShare()->null_bytes; }
413
 
  inline uint32_t getNullFields() { return getShare()->null_fields; }
 
415
  inline uint8_t getBlobPtrSize() const { return getShare()->sizeBlobPtr(); }
 
416
  inline uint32_t getNullBytes() const { return getShare()->null_bytes; }
 
417
  inline uint32_t getNullFields() const { return getShare()->null_fields; }
414
418
  inline unsigned char *getDefaultValues() { return  getMutableShare()->getDefaultValues(); }
415
419
  inline const char *getSchemaName()  const { return getShare()->getSchemaName(); }
416
420
  inline const char *getTableName()  const { return getShare()->getTableName(); }
417
421
 
418
 
  inline bool isDatabaseLowByteFirst() { return getShare()->db_low_byte_first; } /* Portable row format */
 
422
  inline bool isDatabaseLowByteFirst() const { return getShare()->db_low_byte_first; } /* Portable row format */
419
423
  inline bool isNameLock() const { return open_placeholder; }
420
424
 
421
 
  uint32_t index_flags(uint32_t idx) const
422
 
  {
423
 
    return getShare()->storage_engine->index_flags(getShare()->getKeyInfo(idx).algorithm);
424
 
  }
 
425
  uint32_t index_flags(uint32_t idx) const;
425
426
 
426
427
  inline plugin::StorageEngine *getEngine() const   /* table_type for handler */
427
428
  {
428
 
    return getShare()->storage_engine;
 
429
    return getShare()->getEngine();
429
430
  }
430
431
 
431
432
  Cursor &getCursor() const /* table_type for handler */
467
468
   * @retval
468
469
   *  true when out of memory
469
470
   */
470
 
  bool fill_item_list(List<Item> *item_list) const;
 
471
  void fill_item_list(List<Item>&) const;
471
472
  void clear_column_bitmaps(void);
472
473
  void prepare_for_position(void);
473
474
  void mark_columns_used_by_index_no_reset(uint32_t index, boost::dynamic_bitset<>& bitmap);
496
497
  }
497
498
 
498
499
  /* Both of the below should go away once we can move this bit to the field objects */
499
 
  inline bool isReadSet(uint32_t index)
 
500
  inline bool isReadSet(uint32_t index) const
500
501
  {
501
502
    return read_set->test(index);
502
503
  }
551
552
  {
552
553
    return db_stat || open_placeholder;
553
554
  }
 
555
 
554
556
  /*
555
557
    Is this instance of the table should be reopen or represents a name-lock?
556
558
  */
557
 
  inline bool needs_reopen_or_name_lock()
558
 
  { 
559
 
    return getShare()->getVersion() != refresh_version;
560
 
  }
 
559
  bool needs_reopen_or_name_lock() const;
561
560
 
562
561
  /**
563
562
    clean/setup table fields and map.
578
577
  void filesort_free_buffers(bool full= false);
579
578
  void intern_close_table();
580
579
 
581
 
  void print_error(int error, myf errflag)
582
 
  {
583
 
    getShare()->storage_engine->print_error(error, errflag, *this);
584
 
  }
 
580
  void print_error(int error, myf errflag) const;
585
581
 
586
582
  /**
587
583
    @return
588
584
    key if error because of duplicated keys
589
585
  */
590
 
  uint32_t get_dup_key(int error)
 
586
  uint32_t get_dup_key(int error) const
591
587
  {
592
588
    cursor->errkey  = (uint32_t) -1;
593
589
    if (error == HA_ERR_FOUND_DUPP_KEY || error == HA_ERR_FOREIGN_DUPLICATE_KEY ||
831
827
namespace optimizer { class SqlSelect; }
832
828
 
833
829
void change_double_for_sort(double nr,unsigned char *to);
834
 
double my_double_round(double value, int64_t dec, bool dec_unsigned,
835
 
                       bool truncate);
836
830
int get_quick_record(optimizer::SqlSelect *select);
837
831
 
838
832
void find_date(char *pos,uint32_t *vek,uint32_t flag);
841
835
ulong get_form_pos(int file, unsigned char *head, TYPELIB *save_names);
842
836
void append_unescaped(String *res, const char *pos, uint32_t length);
843
837
 
844
 
int rename_file_ext(const char * from,const char * to,const char * ext);
 
838
DRIZZLED_API int rename_file_ext(const char * from,const char * to,const char * ext);
845
839
bool check_column_name(const char *name);
846
 
bool check_db_name(Session *session, SchemaIdentifier &schema);
847
840
bool check_table_name(const char *name, uint32_t length);
848
841
 
849
842
} /* namespace drizzled */
850
843
 
851
 
#include "drizzled/table/instance.h"
852
 
#include "drizzled/table/concurrent.h"
 
844
#include <drizzled/table/singular.h>
 
845
#include <drizzled/table/concurrent.h>
853
846
 
854
 
#endif /* DRIZZLED_TABLE_H */