~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.h

  • Committer: Brian Aker
  • Date: 2010-12-02 05:20:13 UTC
  • mto: This revision was merged to the branch mainline in revision 1968.
  • Revision ID: brian@tangent.org-20101202052013-idifz62qat1ayhsn
Style change around session list.

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>
27
28
 
28
29
#include "drizzled/order.h"
29
30
#include "drizzled/filesort_info.h"
32
33
#include "drizzled/cursor.h"
33
34
#include "drizzled/lex_string.h"
34
35
#include "drizzled/table_list.h"
35
 
#include "drizzled/table_share.h"
 
36
#include "drizzled/definition/table.h"
36
37
#include "drizzled/atomics.h"
37
38
#include "drizzled/query_id.h"
38
39
 
54
55
typedef enum enum_table_category TABLE_CATEGORY;
55
56
typedef struct st_columndef MI_COLUMNDEF;
56
57
 
57
 
bool create_myisam_from_heap(Session *session, Table *table,
58
 
                             MI_COLUMNDEF *start_recinfo,
59
 
                             MI_COLUMNDEF **recinfo,
60
 
                             int error, bool ignore_last_dupp_key_error);
61
 
 
62
58
/**
63
59
 * Class representing a set of records, either in a temporary, 
64
60
 * normal, or derived table.
65
61
 */
66
62
class Table 
67
63
{
68
 
public:
69
 
 
70
 
  TableShare *s; /**< Pointer to the shared metadata about the table */
71
64
  Field **field; /**< Pointer to fields collection */
 
65
public:
 
66
 
 
67
  Field **getFields() const
 
68
  {
 
69
    return field;
 
70
  }
 
71
 
 
72
  Field *getField(uint32_t arg) const
 
73
  {
 
74
    return field[arg];
 
75
  }
 
76
 
 
77
  void setFields(Field **arg)
 
78
  {
 
79
    field= arg;
 
80
  }
 
81
 
 
82
  void setFieldAt(Field *arg, uint32_t arg_pos)
 
83
  {
 
84
    field[arg_pos]= arg;
 
85
  }
72
86
 
73
87
  Cursor *cursor; /**< Pointer to the storage engine's Cursor managing this table */
 
88
private:
74
89
  Table *next;
 
90
public:
 
91
  Table *getNext() const
 
92
  {
 
93
    return next;
 
94
  }
 
95
 
 
96
  Table **getNextPtr()
 
97
  {
 
98
    return &next;
 
99
  }
 
100
 
 
101
  void setNext(Table *arg)
 
102
  {
 
103
    next= arg;
 
104
  }
 
105
 
 
106
  void unlink()
 
107
  {
 
108
    getNext()->setPrev(getPrev());              /* remove from used chain */
 
109
    getPrev()->setNext(getNext());
 
110
  }
 
111
 
 
112
private:
75
113
  Table *prev;
76
 
 
77
 
  MyBitmap *read_set; /* Active column sets */
78
 
  MyBitmap *write_set; /* Active column sets */
 
114
public:
 
115
  Table *getPrev() const
 
116
  {
 
117
    return prev;
 
118
  }
 
119
 
 
120
  Table **getPrevPtr()
 
121
  {
 
122
    return &prev;
 
123
  }
 
124
 
 
125
  void setPrev(Table *arg)
 
126
  {
 
127
    prev= arg;
 
128
  }
 
129
 
 
130
  boost::dynamic_bitset<> *read_set; /* Active column sets */
 
131
  boost::dynamic_bitset<> *write_set; /* Active column sets */
79
132
 
80
133
  uint32_t tablenr;
81
134
  uint32_t db_stat; /**< information about the cursor as in Cursor.h */
82
135
 
83
 
  MyBitmap def_read_set; /**< Default read set of columns */
84
 
  MyBitmap def_write_set; /**< Default write set of columns */
85
 
  MyBitmap tmp_set; /* Not sure about this... */
 
136
  boost::dynamic_bitset<> def_read_set; /**< Default read set of columns */
 
137
  boost::dynamic_bitset<> def_write_set; /**< Default write set of columns */
 
138
  boost::dynamic_bitset<> tmp_set; /* Not sure about this... */
86
139
 
87
140
  Session *in_use; /**< Pointer to the current session using this object */
88
141
  Session *getSession()
90
143
    return in_use;
91
144
  }
92
145
 
 
146
  unsigned char *getInsertRecord()
 
147
  {
 
148
    return record[0];
 
149
  }
 
150
 
 
151
  unsigned char *getUpdateRecord()
 
152
  {
 
153
    return record[1];
 
154
  }
 
155
 
93
156
  unsigned char *record[2]; /**< Pointer to "records" */
94
 
  unsigned char *insert_values; /* used by INSERT ... UPDATE */
95
 
  KEY  *key_info; /**< data of keys in database */
 
157
  std::vector<unsigned char> insert_values; /* used by INSERT ... UPDATE */
 
158
  KeyInfo  *key_info; /**< data of keys in database */
96
159
  Field *next_number_field; /**< Set if next_number is activated. @TODO What the heck is the difference between this and the next member? */
97
160
  Field *found_next_number_field; /**< Points to the "next-number" field (autoincrement field) */
98
161
  Field_timestamp *timestamp_field; /**< Points to the auto-setting timestamp field, if any */
99
162
 
100
163
  TableList *pos_in_table_list; /* Element referring to this table */
101
 
  order_st *group;
102
 
  const char *alias; /**< alias or table name if no alias */
 
164
  Order *group;
 
165
  
 
166
  const char *getAlias() const
 
167
  {
 
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:
 
184
 
103
185
  unsigned char *null_flags;
104
186
 
105
187
  uint32_t lock_position; /**< Position in DRIZZLE_LOCK.table */
106
188
  uint32_t lock_data_start; /**< Start pos. in DRIZZLE_LOCK.locks */
107
189
  uint32_t lock_count; /**< Number of locks */
108
190
  uint32_t used_fields;
109
 
  uint32_t status; /* What's in record[0] */
 
191
  uint32_t status; /* What's in getInsertRecord() */
110
192
  /* number of select if it is derived table */
111
193
  uint32_t derived_select_number;
112
194
  int current_lock; /**< Type of lock on table */
126
208
  bool null_row;
127
209
 
128
210
  bool force_index;
129
 
  bool distinct,const_table,no_rows;
 
211
  bool distinct;
 
212
  bool const_table;
 
213
  bool no_rows;
130
214
  bool key_read;
131
215
  bool no_keyread;
132
216
  /*
241
325
  uint32_t quick_key_parts[MAX_KEY];
242
326
  uint32_t quick_n_ranges[MAX_KEY];
243
327
 
 
328
private:
244
329
  memory::Root mem_root;
245
 
  filesort_info_st sort;
 
330
 
 
331
  void init_mem_root()
 
332
  {
 
333
    init_sql_alloc(&mem_root, TABLE_ALLOC_BLOCK_SIZE, 0);
 
334
  }
 
335
public:
 
336
  memory::Root *getMemRoot()
 
337
  {
 
338
    if (not mem_root.alloc_root_inited())
 
339
    {
 
340
      init_mem_root();
 
341
    }
 
342
 
 
343
    return &mem_root;
 
344
  }
 
345
 
 
346
  void *alloc_root(size_t arg)
 
347
  {
 
348
    if (not mem_root.alloc_root_inited())
 
349
    {
 
350
      init_mem_root();
 
351
    }
 
352
 
 
353
    return mem_root.alloc_root(arg);
 
354
  }
 
355
 
 
356
  char *strmake_root(const char *str_arg, size_t len_arg)
 
357
  {
 
358
    if (not mem_root.alloc_root_inited())
 
359
    {
 
360
      init_mem_root();
 
361
    }
 
362
 
 
363
    return mem_root.strmake_root(str_arg, len_arg);
 
364
  }
 
365
 
 
366
  filesort_info sort;
246
367
 
247
368
  Table();
 
369
  virtual ~Table();
248
370
 
249
371
  int report_error(int error);
250
372
  /**
251
373
   * Free information allocated by openfrm
252
374
   *
253
375
   * @param If true if we also want to free table_share
 
376
   * @note this should all be the destructor
254
377
   */
255
 
  int closefrm(bool free_share);
 
378
  int delete_table(bool free_share= false);
256
379
 
257
380
  void resetTable(Session *session, TableShare *share, uint32_t db_stat_arg);
258
381
 
259
382
  /* SHARE methods */
260
 
  inline const TableShare *getShare() const { assert(s); return s; } /* Get rid of this long term */
261
 
  inline void setShare(TableShare *new_share) { s= new_share; } /* Get rid of this long term */
262
 
  inline uint32_t sizeKeys() { return s->keys; }
263
 
  inline uint32_t sizeFields() { return s->fields; }
264
 
  inline uint32_t getRecordLength() { return s->reclength; }
265
 
  inline uint32_t sizeBlobFields() { return s->blob_fields; }
266
 
  inline uint32_t *getBlobField() { return s->blob_field; }
267
 
  inline uint32_t getNullBytes() { return s->null_bytes; }
268
 
  inline uint32_t getNullFields() { return s->null_fields; }
269
 
  inline unsigned char *getDefaultValues() { return s->default_values; }
270
 
 
271
 
  inline bool isDatabaseLowByteFirst() { return s->db_low_byte_first; } /* Portable row format */
272
 
  inline bool isNameLock() { return s->name_lock; }
273
 
  inline bool isReplaceWithNameLock() { return s->replace_with_name_lock; }
274
 
  inline bool isWaitingOnCondition() { return s->waiting_on_cond; } /* Protection against free */
 
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]; }
 
395
 
 
396
public:
 
397
  virtual bool hasVariableWidth() const
 
398
  {
 
399
    return getShare()->hasVariableWidth(); // We should calculate this.
 
400
  }
 
401
 
 
402
  virtual void setVariableWidth(void);
 
403
 
 
404
  Field_blob *getBlobFieldAt(uint32_t arg) const
 
405
  {
 
406
    if (arg < getShare()->blob_fields)
 
407
      return (Field_blob*) field[getShare()->blob_field[arg]]; /*NOTE: Using 'Table.field' NOT SharedTable.field. */
 
408
 
 
409
    return NULL;
 
410
  }
 
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; }
 
414
  inline unsigned char *getDefaultValues() { return  getMutableShare()->getDefaultValues(); }
 
415
  inline const char *getSchemaName()  const { return getShare()->getSchemaName(); }
 
416
  inline const char *getTableName()  const { return getShare()->getTableName(); }
 
417
 
 
418
  inline bool isDatabaseLowByteFirst() { return getShare()->db_low_byte_first; } /* Portable row format */
 
419
  inline bool isNameLock() const { return open_placeholder; }
275
420
 
276
421
  uint32_t index_flags(uint32_t idx) const
277
422
  {
278
 
    return s->storage_engine->index_flags(s->key_info[idx].algorithm);
 
423
    return getShare()->storage_engine->index_flags(getShare()->getKeyInfo(idx).algorithm);
279
424
  }
280
425
 
281
 
  inline plugin::StorageEngine *getEngine() const       /* table_type for handler */
 
426
  inline plugin::StorageEngine *getEngine() const   /* table_type for handler */
282
427
  {
283
 
    return s->storage_engine;
 
428
    return getShare()->storage_engine;
284
429
  }
285
430
 
286
 
  Cursor &getCursor() const     /* table_type for handler */
 
431
  Cursor &getCursor() const /* table_type for handler */
287
432
  {
288
433
    assert(cursor);
289
434
    return *cursor;
290
435
  }
291
436
 
292
 
  /* For TMP tables, should be pulled out as a class */
293
 
  void updateCreateInfo(message::Table *table_proto);
294
 
  void setup_tmp_table_column_bitmaps(unsigned char *bitmaps);
295
 
  bool create_myisam_tmp_table(KEY *keyinfo,
296
 
                               MI_COLUMNDEF *start_recinfo,
297
 
                               MI_COLUMNDEF **recinfo,
298
 
                               uint64_t options);
299
 
  void free_tmp_table(Session *session);
300
 
  bool open_tmp_table();
301
437
  size_t max_row_length(const unsigned char *data);
302
438
  uint32_t find_shortest_key(const key_map *usable_keys);
303
439
  bool compare_record(Field **ptr);
310
446
  void restoreRecordAsDefault();
311
447
  void emptyRecord();
312
448
 
 
449
 
313
450
  /* See if this can be blown away */
314
451
  inline uint32_t getDBStat () { return db_stat; }
315
452
  inline uint32_t setDBStat () { return db_stat; }
332
469
  bool fill_item_list(List<Item> *item_list) const;
333
470
  void clear_column_bitmaps(void);
334
471
  void prepare_for_position(void);
335
 
  void mark_columns_used_by_index_no_reset(uint32_t index, MyBitmap *map);
 
472
  void mark_columns_used_by_index_no_reset(uint32_t index, boost::dynamic_bitset<>& bitmap);
336
473
  void mark_columns_used_by_index_no_reset(uint32_t index);
337
474
  void mark_columns_used_by_index(uint32_t index);
338
475
  void restore_column_maps_after_mark_index();
340
477
  void mark_columns_needed_for_update(void);
341
478
  void mark_columns_needed_for_delete(void);
342
479
  void mark_columns_needed_for_insert(void);
343
 
  inline void column_bitmaps_set(MyBitmap *read_set_arg,
344
 
                                 MyBitmap *write_set_arg)
345
 
  {
346
 
    read_set= read_set_arg;
347
 
    write_set= write_set_arg;
348
 
  }
349
 
 
350
 
  void restore_column_map(my_bitmap_map *old);
351
 
 
352
 
  my_bitmap_map *use_all_columns(MyBitmap *bitmap);
 
480
  void column_bitmaps_set(boost::dynamic_bitset<>& read_set_arg,
 
481
                          boost::dynamic_bitset<>& write_set_arg);
 
482
 
 
483
  void restore_column_map(const boost::dynamic_bitset<>& old);
 
484
 
 
485
  const boost::dynamic_bitset<> use_all_columns(boost::dynamic_bitset<>& map);
353
486
  inline void use_all_columns()
354
487
  {
355
 
    column_bitmaps_set(&s->all_set, &s->all_set);
 
488
    column_bitmaps_set(getMutableShare()->all_set, getMutableShare()->all_set);
356
489
  }
357
490
 
358
491
  inline void default_column_bitmaps()
364
497
  /* Both of the below should go away once we can move this bit to the field objects */
365
498
  inline bool isReadSet(uint32_t index)
366
499
  {
367
 
    return read_set->isBitSet(index);
 
500
    return read_set->test(index);
368
501
  }
369
502
 
370
503
  inline void setReadSet(uint32_t index)
371
504
  {
372
 
    read_set->setBit(index);
 
505
    read_set->set(index);
373
506
  }
374
507
 
375
508
  inline void setReadSet()
376
509
  {
377
 
    read_set->setAll();
 
510
    read_set->set();
378
511
  }
379
512
 
380
513
  inline void clearReadSet(uint32_t index)
381
514
  {
382
 
    read_set->clearBit(index);
 
515
    read_set->reset(index);
383
516
  }
384
517
 
385
518
  inline void clearReadSet()
386
519
  {
387
 
    read_set->clearAll();
 
520
    read_set->reset();
388
521
  }
389
522
 
390
523
  inline bool isWriteSet(uint32_t index)
391
524
  {
392
 
    return write_set->isBitSet(index);
 
525
    return write_set->test(index);
393
526
  }
394
527
 
395
528
  inline void setWriteSet(uint32_t index)
396
529
  {
397
 
    write_set->setBit(index);
 
530
    write_set->set(index);
398
531
  }
399
532
 
400
533
  inline void setWriteSet()
401
534
  {
402
 
    write_set->setAll();
 
535
    write_set->set();
403
536
  }
404
537
 
405
538
  inline void clearWriteSet(uint32_t index)
406
539
  {
407
 
    write_set->clearBit(index);
 
540
    write_set->reset(index);
408
541
  }
409
542
 
410
543
  inline void clearWriteSet()
411
544
  {
412
 
    write_set->clearAll();
 
545
    write_set->reset();
413
546
  }
414
547
 
415
548
  /* Is table open or should be treated as such by name-locking? */
422
555
  */
423
556
  inline bool needs_reopen_or_name_lock()
424
557
  { 
425
 
    return s->version != refresh_version;
 
558
    return getShare()->getVersion() != refresh_version;
426
559
  }
427
560
 
428
561
  /**
437
570
  {
438
571
    null_row= 1;
439
572
    status|= STATUS_NULL_ROW;
440
 
    memset(null_flags, 255, s->null_bytes);
 
573
    memset(null_flags, 255, getShare()->null_bytes);
441
574
  }
442
575
 
443
 
  bool renameAlterTemporaryTable(TableIdentifier &identifier);
444
576
  void free_io_cache();
445
577
  void filesort_free_buffers(bool full= false);
446
578
  void intern_close_table();
447
579
 
448
580
  void print_error(int error, myf errflag)
449
581
  {
450
 
    s->storage_engine->print_error(error, errflag, *this);
 
582
    getShare()->storage_engine->print_error(error, errflag, *this);
451
583
  }
452
584
 
453
585
  /**
499
631
 
500
632
  friend std::ostream& operator<<(std::ostream& output, const Table &table)
501
633
  {
502
 
    output << "Table:(";
503
 
    output << table.getShare()->getSchemaName();
504
 
    output << ", ";
505
 
    output <<  table.getShare()->getTableName();
506
 
    output << ", ";
507
 
    output <<  table.getShare()->getTableTypeAsString();
508
 
    output << ")";
 
634
    if (table.getShare())
 
635
    {
 
636
      output << "Table:(";
 
637
      output << table.getShare()->getSchemaName();
 
638
      output << ", ";
 
639
      output <<  table.getShare()->getTableName();
 
640
      output << ", ";
 
641
      output <<  table.getShare()->getTableTypeAsString();
 
642
      output << ")";
 
643
    }
 
644
    else
 
645
    {
 
646
      output << "Table:(has no share)";
 
647
    }
509
648
 
510
649
    return output;  // for multiple << operators.
511
650
  }
512
651
 
 
652
public:
 
653
  virtual bool isPlaceHolder(void) const
 
654
  {
 
655
    return false;
 
656
  }
513
657
};
514
658
 
515
 
Table *create_virtual_tmp_table(Session *session, List<CreateField> &field_list);
516
 
 
517
 
typedef struct st_foreign_key_info
 
659
/**
 
660
 * @class
 
661
 *  ForeignKeyInfo
 
662
 *
 
663
 * @brief
 
664
 *  This class defines the information for foreign keys.
 
665
 */
 
666
class ForeignKeyInfo
518
667
{
519
 
  LEX_STRING *forein_id;
520
 
  LEX_STRING *referenced_db;
521
 
  LEX_STRING *referenced_table;
522
 
  LEX_STRING *update_method;
523
 
  LEX_STRING *delete_method;
524
 
  LEX_STRING *referenced_key_name;
525
 
  List<LEX_STRING> foreign_fields;
526
 
  List<LEX_STRING> referenced_fields;
527
 
} FOREIGN_KEY_INFO;
528
 
 
529
 
 
 
668
public:
 
669
    /**
 
670
     * @brief
 
671
     *  This is the constructor with all properties set.
 
672
     *
 
673
     * @param[in] in_foreign_id The id of the foreign key
 
674
     * @param[in] in_referenced_db The referenced database name of the foreign key
 
675
     * @param[in] in_referenced_table The referenced table name of the foreign key
 
676
     * @param[in] in_update_method The update method of the foreign key.
 
677
     * @param[in] in_delete_method The delete method of the foreign key.
 
678
     * @param[in] in_referenced_key_name The name of referenced key
 
679
     * @param[in] in_foreign_fields The foreign fields
 
680
     * @param[in] in_referenced_fields The referenced fields
 
681
     */
 
682
    ForeignKeyInfo(LEX_STRING *in_foreign_id,
 
683
                   LEX_STRING *in_referenced_db,
 
684
                   LEX_STRING *in_referenced_table,
 
685
                   LEX_STRING *in_update_method,
 
686
                   LEX_STRING *in_delete_method,
 
687
                   LEX_STRING *in_referenced_key_name,
 
688
                   List<LEX_STRING> in_foreign_fields,
 
689
                   List<LEX_STRING> in_referenced_fields)
 
690
    :
 
691
      foreign_id(in_foreign_id),
 
692
      referenced_db(in_referenced_db),
 
693
      referenced_table(in_referenced_table),
 
694
      update_method(in_update_method),
 
695
      delete_method(in_delete_method),
 
696
      referenced_key_name(in_referenced_key_name),
 
697
      foreign_fields(in_foreign_fields),
 
698
      referenced_fields(in_referenced_fields)
 
699
    {}
 
700
 
 
701
    /**
 
702
     * @brief
 
703
     *  This is the default constructor. All properties are set to default values for their types.
 
704
     */
 
705
    ForeignKeyInfo()
 
706
    : foreign_id(NULL), referenced_db(NULL), referenced_table(NULL),
 
707
      update_method(NULL), delete_method(NULL), referenced_key_name(NULL)
 
708
    {}
 
709
 
 
710
    /**
 
711
     * @brief
 
712
     *  Gets the foreign id.
 
713
     *
 
714
     * @ retval  the foreign id
 
715
     */
 
716
    const LEX_STRING *getForeignId() const
 
717
    {
 
718
        return foreign_id;
 
719
    }
 
720
 
 
721
    /**
 
722
     * @brief
 
723
     *  Gets the name of the referenced database.
 
724
     *
 
725
     * @ retval  the name of the referenced database
 
726
     */
 
727
    const LEX_STRING *getReferencedDb() const
 
728
    {
 
729
        return referenced_db;
 
730
    }
 
731
 
 
732
    /**
 
733
     * @brief
 
734
     *  Gets the name of the referenced table.
 
735
     *
 
736
     * @ retval  the name of the referenced table
 
737
     */
 
738
    const LEX_STRING *getReferencedTable() const
 
739
    {
 
740
        return referenced_table;
 
741
    }
 
742
 
 
743
    /**
 
744
     * @brief
 
745
     *  Gets the update method.
 
746
     *
 
747
     * @ retval  the update method
 
748
     */
 
749
    const LEX_STRING *getUpdateMethod() const
 
750
    {
 
751
        return update_method;
 
752
    }
 
753
 
 
754
    /**
 
755
     * @brief
 
756
     *  Gets the delete method.
 
757
     *
 
758
     * @ retval  the delete method
 
759
     */
 
760
    const LEX_STRING *getDeleteMethod() const
 
761
    {
 
762
        return delete_method;
 
763
    }
 
764
 
 
765
    /**
 
766
     * @brief
 
767
     *  Gets the name of the referenced key.
 
768
     *
 
769
     * @ retval  the name of the referenced key
 
770
     */
 
771
    const LEX_STRING *getReferencedKeyName() const
 
772
    {
 
773
        return referenced_key_name;
 
774
    }
 
775
 
 
776
    /**
 
777
     * @brief
 
778
     *  Gets the foreign fields.
 
779
     *
 
780
     * @ retval  the foreign fields
 
781
     */
 
782
    const List<LEX_STRING> &getForeignFields() const
 
783
    {
 
784
        return foreign_fields;
 
785
    }
 
786
 
 
787
    /**
 
788
     * @brief
 
789
     *  Gets the referenced fields.
 
790
     *
 
791
     * @ retval  the referenced fields
 
792
     */
 
793
    const List<LEX_STRING> &getReferencedFields() const
 
794
    {
 
795
        return referenced_fields;
 
796
    }
 
797
private:
 
798
    /**
 
799
     * The foreign id.
 
800
     */
 
801
    LEX_STRING *foreign_id;
 
802
    /**
 
803
     * The name of the reference database.
 
804
     */
 
805
    LEX_STRING *referenced_db;
 
806
    /**
 
807
     * The name of the reference table.
 
808
     */
 
809
    LEX_STRING *referenced_table;
 
810
    /**
 
811
     * The update method.
 
812
     */
 
813
    LEX_STRING *update_method;
 
814
    /**
 
815
     * The delete method.
 
816
     */
 
817
    LEX_STRING *delete_method;
 
818
    /**
 
819
     * The name of the referenced key.
 
820
     */
 
821
    LEX_STRING *referenced_key_name;
 
822
    /**
 
823
     * The foreign fields.
 
824
     */
 
825
    List<LEX_STRING> foreign_fields;
 
826
    /**
 
827
     * The referenced fields.
 
828
     */
 
829
    List<LEX_STRING> referenced_fields;
 
830
};
530
831
 
531
832
class TableList;
532
833
 
533
 
#define JOIN_TYPE_LEFT  1
534
 
#define JOIN_TYPE_RIGHT 2
 
834
#define JOIN_TYPE_LEFT  1
 
835
#define JOIN_TYPE_RIGHT 2
535
836
 
536
837
struct st_lex;
537
838
class select_union;
538
839
class Tmp_Table_Param;
539
840
 
540
 
struct open_table_list_st
541
 
{
542
 
  std::string   db;
543
 
  std::string   table;
544
 
  uint32_t in_use;
545
 
  uint32_t locked;
546
 
 
547
 
  open_table_list_st() :
548
 
    in_use(0),
549
 
    locked(0)
550
 
  { }
551
 
 
552
 
};
553
 
 
554
 
TableShare *alloc_table_share(TableList *table_list, char *key,
555
 
                               uint32_t key_length);
556
 
int open_table_def(Session& session, TableIdentifier &identifier, TableShare *share);
557
 
void open_table_error(TableShare *share, int error, int db_errno, int errarg);
558
 
int open_table_from_share(Session *session, TableShare *share, const char *alias,
559
 
                          uint32_t db_stat, uint32_t ha_open_flags,
560
 
                          Table *outparam);
561
841
void free_blobs(Table *table);
562
842
int set_zone(int nr,int min_zone,int max_zone);
563
843
uint32_t convert_period_to_month(uint32_t period);
568
848
 
569
849
namespace optimizer { class SqlSelect; }
570
850
 
571
 
ha_rows filesort(Session *session,
572
 
                 Table *form,
573
 
                 st_sort_field *sortorder,
574
 
                 uint32_t s_length,
575
 
                 optimizer::SqlSelect *select,
576
 
                 ha_rows max_rows,
577
 
                 bool sort_positions,
578
 
                 ha_rows *examined_rows);
579
 
 
580
 
void filesort_free_buffers(Table *table, bool full);
581
851
void change_double_for_sort(double nr,unsigned char *to);
582
852
double my_double_round(double value, int64_t dec, bool dec_unsigned,
583
853
                       bool truncate);
587
857
TYPELIB *convert_strings_to_array_type(char * *typelibs, char * *end);
588
858
TYPELIB *typelib(memory::Root *mem_root, List<String> &strings);
589
859
ulong get_form_pos(int file, unsigned char *head, TYPELIB *save_names);
590
 
ulong next_io_size(ulong pos);
591
860
void append_unescaped(String *res, const char *pos, uint32_t length);
592
861
 
593
862
int rename_file_ext(const char * from,const char * to,const char * ext);
594
863
bool check_column_name(const char *name);
595
 
bool check_db_name(SchemaIdentifier &schema);
 
864
bool check_db_name(Session *session, SchemaIdentifier &schema);
596
865
bool check_table_name(const char *name, uint32_t length);
597
866
 
598
867
} /* namespace drizzled */
599
868
 
 
869
#include "drizzled/table/instance.h"
 
870
#include "drizzled/table/concurrent.h"
 
871
 
600
872
#endif /* DRIZZLED_TABLE_H */