~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.h

  • Committer: Padraig O'Sullivan
  • Date: 2010-02-11 20:01:37 UTC
  • mto: (1300.3.1 query-as-string)
  • mto: This revision was merged to the branch mainline in revision 1307.
  • Revision ID: osullivan.padraig@gmail.com-20100211200137-kx0nmgy8hke3snid
Updated the calls to dtrace probes to use the c_str() pointer from query in Session

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