~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.h

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

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
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
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
 
23
25
#ifndef DRIZZLED_TABLE_H
24
26
#define DRIZZLED_TABLE_H
25
27
 
33
35
#include "drizzled/cursor.h"
34
36
#include "drizzled/lex_string.h"
35
37
#include "drizzled/table_list.h"
36
 
#include "drizzled/definition/table.h"
 
38
#include "drizzled/table/instance.h"
37
39
#include "drizzled/atomics.h"
38
40
#include "drizzled/query_id.h"
39
41
 
 
42
#include "drizzled/visibility.h"
 
43
 
40
44
namespace drizzled
41
45
{
42
46
 
 
47
class COND_EQUAL;
 
48
class Field_blob;
43
49
class Item;
44
50
class Item_subselect;
 
51
class SecurityContext;
 
52
class Select_Lex;
45
53
class Select_Lex_Unit;
46
 
class Select_Lex;
47
 
class COND_EQUAL;
48
 
class SecurityContext;
49
54
class TableList;
50
 
class Field_timestamp;
51
 
class Field_blob;
52
 
 
53
 
extern uint64_t refresh_version;
 
55
namespace field { class Epoch; }
 
56
namespace plugin { class StorageEngine; }
54
57
 
55
58
typedef enum enum_table_category TABLE_CATEGORY;
56
59
typedef struct st_columndef MI_COLUMNDEF;
59
62
 * Class representing a set of records, either in a temporary, 
60
63
 * normal, or derived table.
61
64
 */
62
 
class Table 
 
65
class DRIZZLED_API Table 
63
66
{
64
67
  Field **field; /**< Pointer to fields collection */
 
68
 
65
69
public:
66
 
 
67
70
  Field **getFields() const
68
71
  {
69
72
    return field;
85
88
  }
86
89
 
87
90
  Cursor *cursor; /**< Pointer to the storage engine's Cursor managing this table */
 
91
 
88
92
private:
89
93
  Table *next;
 
94
 
90
95
public:
91
96
  Table *getNext() const
92
97
  {
143
148
    return in_use;
144
149
  }
145
150
 
146
 
  unsigned char *getInsertRecord()
 
151
  unsigned char *getInsertRecord() const
147
152
  {
148
153
    return record[0];
149
154
  }
158
163
  KeyInfo  *key_info; /**< data of keys in database */
159
164
  Field *next_number_field; /**< Set if next_number is activated. @TODO What the heck is the difference between this and the next member? */
160
165
  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 */
 
166
  field::Epoch *timestamp_field; /**< Points to the auto-setting timestamp field, if any */
162
167
 
163
168
  TableList *pos_in_table_list; /* Element referring to this table */
164
169
  Order *group;
280
285
    statement then the variable contains TIMESTAMP_NO_AUTO_SET (i.e. 0).
281
286
 
282
287
    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()
 
288
    if needed cleared later in statement processing code (see update_query()
284
289
    as example).
285
290
  */
286
291
  timestamp_auto_set_type timestamp_field_type;
308
313
    The set is implemented as a bitmap.
309
314
  */
310
315
  key_map keys_in_use_for_query;
 
316
 
311
317
  /* Map of keys that can be used to calculate GROUP BY without sorting */
312
318
  key_map keys_in_use_for_group_by;
 
319
 
313
320
  /* Map of keys that can be used to calculate ORDER BY without sorting */
314
321
  key_map keys_in_use_for_order_by;
315
322
 
408
415
 
409
416
    return NULL;
410
417
  }
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; }
 
418
  inline uint8_t getBlobPtrSize() const { return getShare()->sizeBlobPtr(); }
 
419
  inline uint32_t getNullBytes() const { return getShare()->null_bytes; }
 
420
  inline uint32_t getNullFields() const { return getShare()->null_fields; }
414
421
  inline unsigned char *getDefaultValues() { return  getMutableShare()->getDefaultValues(); }
415
422
  inline const char *getSchemaName()  const { return getShare()->getSchemaName(); }
416
423
  inline const char *getTableName()  const { return getShare()->getTableName(); }
417
424
 
418
 
  inline bool isDatabaseLowByteFirst() { return getShare()->db_low_byte_first; } /* Portable row format */
 
425
  inline bool isDatabaseLowByteFirst() const { return getShare()->db_low_byte_first; } /* Portable row format */
419
426
  inline bool isNameLock() const { return open_placeholder; }
420
427
 
421
 
  uint32_t index_flags(uint32_t idx) const
422
 
  {
423
 
    return getShare()->storage_engine->index_flags(getShare()->getKeyInfo(idx).algorithm);
424
 
  }
 
428
  uint32_t index_flags(uint32_t idx) const;
425
429
 
426
430
  inline plugin::StorageEngine *getEngine() const   /* table_type for handler */
427
431
  {
428
 
    return getShare()->storage_engine;
 
432
    return getShare()->getEngine();
429
433
  }
430
434
 
431
435
  Cursor &getCursor() const /* table_type for handler */
437
441
  size_t max_row_length(const unsigned char *data);
438
442
  uint32_t find_shortest_key(const key_map *usable_keys);
439
443
  bool compare_record(Field **ptr);
440
 
  bool compare_record();
 
444
  bool records_are_comparable();
 
445
  bool compare_records();
441
446
  /* TODO: the (re)storeRecord's may be able to be further condensed */
442
447
  void storeRecord();
443
448
  void storeRecordAsInsert();
550
555
  {
551
556
    return db_stat || open_placeholder;
552
557
  }
 
558
 
553
559
  /*
554
560
    Is this instance of the table should be reopen or represents a name-lock?
555
561
  */
556
 
  inline bool needs_reopen_or_name_lock()
557
 
  { 
558
 
    return getShare()->getVersion() != refresh_version;
559
 
  }
 
562
  bool needs_reopen_or_name_lock() const;
560
563
 
561
564
  /**
562
565
    clean/setup table fields and map.
577
580
  void filesort_free_buffers(bool full= false);
578
581
  void intern_close_table();
579
582
 
580
 
  void print_error(int error, myf errflag)
581
 
  {
582
 
    getShare()->storage_engine->print_error(error, errflag, *this);
583
 
  }
 
583
  void print_error(int error, myf errflag) const;
584
584
 
585
585
  /**
586
586
    @return
587
587
    key if error because of duplicated keys
588
588
  */
589
 
  uint32_t get_dup_key(int error)
 
589
  uint32_t get_dup_key(int error) const
590
590
  {
591
591
    cursor->errkey  = (uint32_t) -1;
592
592
    if (error == HA_ERR_FOUND_DUPP_KEY || error == HA_ERR_FOREIGN_DUPLICATE_KEY ||
602
602
  */
603
603
  bool operator<(const Table &right) const
604
604
  {
605
 
    int result= strcasecmp(this->getShare()->getSchemaName(), right.getShare()->getSchemaName());
606
 
 
607
 
    if (result <  0)
608
 
      return true;
609
 
 
610
 
    if (result >  0)
611
 
      return false;
612
 
 
613
 
    result= strcasecmp(this->getShare()->getTableName(), right.getShare()->getTableName());
614
 
 
615
 
    if (result <  0)
616
 
      return true;
617
 
 
618
 
    if (result >  0)
619
 
      return false;
620
 
 
621
 
    if (this->getShare()->getTableProto()->type()  < right.getShare()->getTableProto()->type())
622
 
      return true;
623
 
 
624
 
    return false;
 
605
    return getShare()->getCacheKey() < right.getShare()->getCacheKey();
625
606
  }
626
607
 
627
608
  static bool compare(const Table *a, const Table *b)
849
830
namespace optimizer { class SqlSelect; }
850
831
 
851
832
void change_double_for_sort(double nr,unsigned char *to);
852
 
double my_double_round(double value, int64_t dec, bool dec_unsigned,
853
 
                       bool truncate);
854
833
int get_quick_record(optimizer::SqlSelect *select);
855
834
 
856
835
void find_date(char *pos,uint32_t *vek,uint32_t flag);
859
838
ulong get_form_pos(int file, unsigned char *head, TYPELIB *save_names);
860
839
void append_unescaped(String *res, const char *pos, uint32_t length);
861
840
 
862
 
int rename_file_ext(const char * from,const char * to,const char * ext);
 
841
DRIZZLED_API int rename_file_ext(const char * from,const char * to,const char * ext);
863
842
bool check_column_name(const char *name);
864
 
bool check_db_name(Session *session, SchemaIdentifier &schema);
 
843
bool check_db_name(Session *session, identifier::Schema &schema);
865
844
bool check_table_name(const char *name, uint32_t length);
866
845
 
867
846
} /* namespace drizzled */
868
847
 
869
 
#include "drizzled/table/instance.h"
 
848
#include "drizzled/table/singular.h"
870
849
#include "drizzled/table/concurrent.h"
871
850
 
872
851
#endif /* DRIZZLED_TABLE_H */