~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.h

few updates and modifications to admin commands

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
20
20
 
21
21
/* Structs that defines the Table */
22
22
 
23
 
 
24
 
 
25
23
#ifndef DRIZZLED_TABLE_H
26
24
#define DRIZZLED_TABLE_H
27
25
 
28
26
#include <string>
29
27
#include <boost/dynamic_bitset.hpp>
30
28
 
31
 
#include <drizzled/order.h>
32
 
#include <drizzled/filesort_info.h>
33
 
#include <drizzled/natural_join_column.h>
34
 
#include <drizzled/field_iterator.h>
35
 
#include <drizzled/cursor.h>
36
 
#include <drizzled/lex_string.h>
37
 
#include <drizzled/table/instance.h>
38
 
#include <drizzled/atomics.h>
39
 
#include <drizzled/query_id.h>
40
 
 
41
 
#include <drizzled/visibility.h>
 
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"
42
39
 
43
40
namespace drizzled
44
41
{
45
42
 
46
 
class COND_EQUAL;
47
 
class Field_blob;
48
43
class Item;
49
44
class Item_subselect;
 
45
class Select_Lex_Unit;
 
46
class Select_Lex;
 
47
class COND_EQUAL;
50
48
class SecurityContext;
51
 
class Select_Lex;
52
 
class Select_Lex_Unit;
53
49
class TableList;
54
 
namespace field { class Epoch; }
55
 
namespace plugin { class StorageEngine; }
 
50
class Field_timestamp;
 
51
class Field_blob;
 
52
 
 
53
extern uint64_t refresh_version;
56
54
 
57
55
typedef enum enum_table_category TABLE_CATEGORY;
58
56
typedef struct st_columndef MI_COLUMNDEF;
61
59
 * Class representing a set of records, either in a temporary, 
62
60
 * normal, or derived table.
63
61
 */
64
 
class DRIZZLED_API Table 
 
62
class Table 
65
63
{
66
64
  Field **field; /**< Pointer to fields collection */
 
65
public:
67
66
 
68
 
public:
69
67
  Field **getFields() const
70
68
  {
71
69
    return field;
87
85
  }
88
86
 
89
87
  Cursor *cursor; /**< Pointer to the storage engine's Cursor managing this table */
90
 
 
91
88
private:
92
89
  Table *next;
93
 
 
94
90
public:
95
91
  Table *getNext() const
96
92
  {
147
143
    return in_use;
148
144
  }
149
145
 
150
 
  unsigned char *getInsertRecord() const
 
146
  unsigned char *getInsertRecord()
151
147
  {
152
148
    return record[0];
153
149
  }
162
158
  KeyInfo  *key_info; /**< data of keys in database */
163
159
  Field *next_number_field; /**< Set if next_number is activated. @TODO What the heck is the difference between this and the next member? */
164
160
  Field *found_next_number_field; /**< Points to the "next-number" field (autoincrement field) */
165
 
  field::Epoch *timestamp_field; /**< Points to the auto-setting timestamp field, if any */
 
161
  Field_timestamp *timestamp_field; /**< Points to the auto-setting timestamp field, if any */
166
162
 
167
163
  TableList *pos_in_table_list; /* Element referring to this table */
168
164
  Order *group;
284
280
    statement then the variable contains TIMESTAMP_NO_AUTO_SET (i.e. 0).
285
281
 
286
282
    Value of this variable is set for each statement in open_table() and
287
 
    if needed cleared later in statement processing code (see update_query()
 
283
    if needed cleared later in statement processing code (see mysql_update()
288
284
    as example).
289
285
  */
290
286
  timestamp_auto_set_type timestamp_field_type;
312
308
    The set is implemented as a bitmap.
313
309
  */
314
310
  key_map keys_in_use_for_query;
315
 
 
316
311
  /* Map of keys that can be used to calculate GROUP BY without sorting */
317
312
  key_map keys_in_use_for_group_by;
318
 
 
319
313
  /* Map of keys that can be used to calculate ORDER BY without sorting */
320
314
  key_map keys_in_use_for_order_by;
321
315
 
414
408
 
415
409
    return NULL;
416
410
  }
417
 
  inline uint8_t getBlobPtrSize() const { return getShare()->sizeBlobPtr(); }
418
 
  inline uint32_t getNullBytes() const { return getShare()->null_bytes; }
419
 
  inline uint32_t getNullFields() const { return getShare()->null_fields; }
 
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; }
420
414
  inline unsigned char *getDefaultValues() { return  getMutableShare()->getDefaultValues(); }
421
415
  inline const char *getSchemaName()  const { return getShare()->getSchemaName(); }
422
416
  inline const char *getTableName()  const { return getShare()->getTableName(); }
423
417
 
424
 
  inline bool isDatabaseLowByteFirst() const { return getShare()->db_low_byte_first; } /* Portable row format */
 
418
  inline bool isDatabaseLowByteFirst() { return getShare()->db_low_byte_first; } /* Portable row format */
425
419
  inline bool isNameLock() const { return open_placeholder; }
426
420
 
427
 
  uint32_t index_flags(uint32_t idx) const;
 
421
  uint32_t index_flags(uint32_t idx) const
 
422
  {
 
423
    return getShare()->storage_engine->index_flags(getShare()->getKeyInfo(idx).algorithm);
 
424
  }
428
425
 
429
426
  inline plugin::StorageEngine *getEngine() const   /* table_type for handler */
430
427
  {
431
 
    return getShare()->getEngine();
 
428
    return getShare()->storage_engine;
432
429
  }
433
430
 
434
431
  Cursor &getCursor() const /* table_type for handler */
499
496
  }
500
497
 
501
498
  /* Both of the below should go away once we can move this bit to the field objects */
502
 
  inline bool isReadSet(uint32_t index) const
 
499
  inline bool isReadSet(uint32_t index)
503
500
  {
504
501
    return read_set->test(index);
505
502
  }
554
551
  {
555
552
    return db_stat || open_placeholder;
556
553
  }
557
 
 
558
554
  /*
559
555
    Is this instance of the table should be reopen or represents a name-lock?
560
556
  */
561
 
  bool needs_reopen_or_name_lock() const;
 
557
  inline bool needs_reopen_or_name_lock()
 
558
  { 
 
559
    return getShare()->getVersion() != refresh_version;
 
560
  }
562
561
 
563
562
  /**
564
563
    clean/setup table fields and map.
579
578
  void filesort_free_buffers(bool full= false);
580
579
  void intern_close_table();
581
580
 
582
 
  void print_error(int error, myf errflag) const;
 
581
  void print_error(int error, myf errflag)
 
582
  {
 
583
    getShare()->storage_engine->print_error(error, errflag, *this);
 
584
  }
583
585
 
584
586
  /**
585
587
    @return
586
588
    key if error because of duplicated keys
587
589
  */
588
 
  uint32_t get_dup_key(int error) const
 
590
  uint32_t get_dup_key(int error)
589
591
  {
590
592
    cursor->errkey  = (uint32_t) -1;
591
593
    if (error == HA_ERR_FOUND_DUPP_KEY || error == HA_ERR_FOREIGN_DUPLICATE_KEY ||
601
603
  */
602
604
  bool operator<(const Table &right) const
603
605
  {
604
 
    return getShare()->getCacheKey() < right.getShare()->getCacheKey();
 
606
    int result= strcasecmp(this->getShare()->getSchemaName(), right.getShare()->getSchemaName());
 
607
 
 
608
    if (result <  0)
 
609
      return true;
 
610
 
 
611
    if (result >  0)
 
612
      return false;
 
613
 
 
614
    result= strcasecmp(this->getShare()->getTableName(), right.getShare()->getTableName());
 
615
 
 
616
    if (result <  0)
 
617
      return true;
 
618
 
 
619
    if (result >  0)
 
620
      return false;
 
621
 
 
622
    if (this->getShare()->getTableProto()->type()  < right.getShare()->getTableProto()->type())
 
623
      return true;
 
624
 
 
625
    return false;
605
626
  }
606
627
 
607
628
  static bool compare(const Table *a, const Table *b)
829
850
namespace optimizer { class SqlSelect; }
830
851
 
831
852
void change_double_for_sort(double nr,unsigned char *to);
 
853
double my_double_round(double value, int64_t dec, bool dec_unsigned,
 
854
                       bool truncate);
832
855
int get_quick_record(optimizer::SqlSelect *select);
833
856
 
834
857
void find_date(char *pos,uint32_t *vek,uint32_t flag);
837
860
ulong get_form_pos(int file, unsigned char *head, TYPELIB *save_names);
838
861
void append_unescaped(String *res, const char *pos, uint32_t length);
839
862
 
840
 
DRIZZLED_API int rename_file_ext(const char * from,const char * to,const char * ext);
 
863
int rename_file_ext(const char * from,const char * to,const char * ext);
841
864
bool check_column_name(const char *name);
 
865
bool check_db_name(Session *session, SchemaIdentifier &schema);
842
866
bool check_table_name(const char *name, uint32_t length);
843
867
 
844
868
} /* namespace drizzled */
845
869
 
846
 
#include <drizzled/table/singular.h>
847
 
#include <drizzled/table/concurrent.h>
 
870
#include "drizzled/table/instance.h"
 
871
#include "drizzled/table/concurrent.h"
848
872
 
849
873
#endif /* DRIZZLED_TABLE_H */