~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.h

  • Committer: Brian Aker
  • Date: 2008-10-06 06:47:29 UTC
  • Revision ID: brian@tangent.org-20081006064729-2i9mhjkzyvow9xsm
RemoveĀ uint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#ifndef DRIZZLED_TABLE_H
24
24
#define DRIZZLED_TABLE_H
25
25
 
26
 
#include <string>
27
 
 
28
 
#include "drizzled/order.h"
29
 
#include "drizzled/filesort_info.h"
30
 
#include "drizzled/natural_join_column.h"
31
 
#include "drizzled/field_iterator.h"
32
 
#include "drizzled/cursor.h"
33
 
#include "drizzled/lex_string.h"
34
 
#include "drizzled/table_list.h"
35
 
#include "drizzled/table_share.h"
36
 
#include "drizzled/atomics.h"
37
 
#include "drizzled/query_id.h"
38
 
 
39
 
namespace drizzled
40
 
{
41
 
 
42
 
class Item;
 
26
#include <storage/myisam/myisam.h>
 
27
#include <drizzled/order.h>
 
28
#include <drizzled/filesort_info.h>
 
29
#include <drizzled/natural_join_column.h>
 
30
#include <drizzled/nested_join.h>
 
31
#include <drizzled/field_iterator.h>
 
32
 
 
33
class Item;                             /* Needed by order_st */
43
34
class Item_subselect;
44
 
class Select_Lex_Unit;
45
 
class Select_Lex;
 
35
class st_select_lex_unit;
 
36
class st_select_lex;
46
37
class COND_EQUAL;
47
 
class SecurityContext;
 
38
class Security_context;
48
39
class TableList;
 
40
 
 
41
/*************************************************************************/
 
42
 
 
43
enum tmp_table_type
 
44
{
 
45
  NO_TMP_TABLE, NON_TRANSACTIONAL_TMP_TABLE, TRANSACTIONAL_TMP_TABLE,
 
46
  INTERNAL_TMP_TABLE, SYSTEM_TMP_TABLE, TMP_TABLE_FRM_FILE_ONLY
 
47
};
 
48
 
 
49
bool mysql_frm_type(THD *thd, char *path, enum legacy_db_type *dbt);
 
50
 
 
51
 
 
52
enum release_type { RELEASE_NORMAL, RELEASE_WAIT_FOR_DROP };
 
53
 
 
54
/*
 
55
  Values in this enum are used to indicate how a tables TIMESTAMP field
 
56
  should be treated. It can be set to the current timestamp on insert or
 
57
  update or both.
 
58
  WARNING: The values are used for bit operations. If you change the
 
59
  enum, you must keep the bitwise relation of the values. For example:
 
60
  (int) TIMESTAMP_AUTO_SET_ON_BOTH must be equal to
 
61
  (int) TIMESTAMP_AUTO_SET_ON_INSERT | (int) TIMESTAMP_AUTO_SET_ON_UPDATE.
 
62
  We use an enum here so that the debugger can display the value names.
 
63
*/
 
64
enum timestamp_auto_set_type
 
65
{
 
66
  TIMESTAMP_NO_AUTO_SET= 0, TIMESTAMP_AUTO_SET_ON_INSERT= 1,
 
67
  TIMESTAMP_AUTO_SET_ON_UPDATE= 2, TIMESTAMP_AUTO_SET_ON_BOTH= 3
 
68
};
 
69
#define clear_timestamp_auto_bits(_target_, _bits_) \
 
70
  (_target_)= (enum timestamp_auto_set_type)((int)(_target_) & ~(int)(_bits_))
 
71
 
49
72
class Field_timestamp;
50
73
class Field_blob;
51
74
 
52
 
extern uint64_t refresh_version;
53
 
 
 
75
/**
 
76
  Category of table found in the table share.
 
77
*/
 
78
enum enum_table_category
 
79
{
 
80
  /**
 
81
    Unknown value.
 
82
  */
 
83
  TABLE_UNKNOWN_CATEGORY=0,
 
84
 
 
85
  /**
 
86
    Temporary table.
 
87
    The table is visible only in the session.
 
88
    Therefore,
 
89
    - FLUSH TABLES WITH READ LOCK
 
90
    - SET GLOBAL READ_ONLY = ON
 
91
    do not apply to this table.
 
92
    Note that LOCK Table t FOR READ/WRITE
 
93
    can be used on temporary tables.
 
94
    Temporary tables are not part of the table cache.
 
95
  */
 
96
  TABLE_CATEGORY_TEMPORARY=1,
 
97
 
 
98
  /**
 
99
    User table.
 
100
    These tables do honor:
 
101
    - LOCK Table t FOR READ/WRITE
 
102
    - FLUSH TABLES WITH READ LOCK
 
103
    - SET GLOBAL READ_ONLY = ON
 
104
    User tables are cached in the table cache.
 
105
  */
 
106
  TABLE_CATEGORY_USER=2,
 
107
 
 
108
  /**
 
109
    Information schema tables.
 
110
    These tables are an interface provided by the system
 
111
    to inspect the system metadata.
 
112
    These tables do *not* honor:
 
113
    - LOCK Table t FOR READ/WRITE
 
114
    - FLUSH TABLES WITH READ LOCK
 
115
    - SET GLOBAL READ_ONLY = ON
 
116
    as there is no point in locking explicitely
 
117
    an INFORMATION_SCHEMA table.
 
118
    Nothing is directly written to information schema tables.
 
119
    Note that this value is not used currently,
 
120
    since information schema tables are not shared,
 
121
    but implemented as session specific temporary tables.
 
122
  */
 
123
  /*
 
124
    TODO: Fixing the performance issues of I_S will lead
 
125
    to I_S tables in the table cache, which should use
 
126
    this table type.
 
127
  */
 
128
  TABLE_CATEGORY_INFORMATION
 
129
};
54
130
typedef enum enum_table_category TABLE_CATEGORY;
55
 
typedef struct st_columndef MI_COLUMNDEF;
56
 
 
57
 
bool create_myisam_from_heap(Session *session, Table *table,
 
131
 
 
132
TABLE_CATEGORY get_table_category(const LEX_STRING *db,
 
133
                                  const LEX_STRING *name);
 
134
 
 
135
/*
 
136
  This structure is shared between different table objects. There is one
 
137
  instance of table share per one table in the database.
 
138
*/
 
139
 
 
140
typedef struct st_table_share
 
141
{
 
142
  st_table_share() {}                    /* Remove gcc warning */
 
143
 
 
144
  /** Category of this table. */
 
145
  TABLE_CATEGORY table_category;
 
146
 
 
147
  /* hash of field names (contains pointers to elements of field array) */
 
148
  HASH  name_hash;                      /* hash of field names */
 
149
  MEM_ROOT mem_root;
 
150
  TYPELIB keynames;                     /* Pointers to keynames */
 
151
  TYPELIB fieldnames;                   /* Pointer to fieldnames */
 
152
  TYPELIB *intervals;                   /* pointer to interval info */
 
153
  pthread_mutex_t mutex;                /* For locking the share  */
 
154
  pthread_cond_t cond;                  /* To signal that share is ready */
 
155
  struct st_table_share *next,          /* Link to unused shares */
 
156
    **prev;
 
157
 
 
158
  /* The following is copied to each Table on OPEN */
 
159
  Field **field;
 
160
  Field **found_next_number_field;
 
161
  Field *timestamp_field;               /* Used only during open */
 
162
  KEY  *key_info;                       /* data of keys in database */
 
163
  uint  *blob_field;                    /* Index to blobs in Field arrray*/
 
164
 
 
165
  unsigned char *default_values;                /* row with default values */
 
166
  LEX_STRING comment;                   /* Comment about table */
 
167
  const CHARSET_INFO *table_charset; /* Default charset of string fields */
 
168
 
 
169
  MY_BITMAP all_set;
 
170
  /*
 
171
    Key which is used for looking-up table in table cache and in the list
 
172
    of thread's temporary tables. Has the form of:
 
173
      "database_name\0table_name\0" + optional part for temporary tables.
 
174
 
 
175
    Note that all three 'table_cache_key', 'db' and 'table_name' members
 
176
    must be set (and be non-zero) for tables in table cache. They also
 
177
    should correspond to each other.
 
178
    To ensure this one can use set_table_cache() methods.
 
179
  */
 
180
  LEX_STRING table_cache_key;
 
181
  LEX_STRING db;                        /* Pointer to db */
 
182
  LEX_STRING table_name;                /* Table name (for open) */
 
183
  LEX_STRING path;      /* Path to .frm file (from datadir) */
 
184
  LEX_STRING normalized_path;           /* unpack_filename(path) */
 
185
  LEX_STRING connect_string;
 
186
 
 
187
  /*
 
188
     Set of keys in use, implemented as a Bitmap.
 
189
     Excludes keys disabled by ALTER Table ... DISABLE KEYS.
 
190
  */
 
191
  key_map keys_in_use;
 
192
  key_map keys_for_keyread;
 
193
  ha_rows min_rows, max_rows;           /* create information */
 
194
  uint32_t   avg_row_length;            /* create information */
 
195
  uint32_t   block_size;                   /* create information */
 
196
  uint32_t   version, mysql_version;
 
197
  uint32_t   timestamp_offset;          /* Set to offset+1 of record */
 
198
  uint32_t   reclength;                 /* Recordlength */
 
199
 
 
200
  plugin_ref db_plugin;                 /* storage engine plugin */
 
201
  inline handlerton *db_type() const    /* table_type for handler */
 
202
  {
 
203
    // assert(db_plugin);
 
204
    return db_plugin ? plugin_data(db_plugin, handlerton*) : NULL;
 
205
  }
 
206
  enum row_type row_type;               /* How rows are stored */
 
207
  enum tmp_table_type tmp_table;
 
208
  enum ha_choice transactional;
 
209
  enum ha_choice page_checksum;
 
210
 
 
211
  uint32_t ref_count;                       /* How many Table objects uses this */
 
212
  uint32_t open_count;                  /* Number of tables in open list */
 
213
  uint32_t blob_ptr_size;                       /* 4 or 8 */
 
214
  uint32_t key_block_size;                      /* create key_block_size, if used */
 
215
  uint32_t null_bytes, last_null_bit_pos;
 
216
  uint32_t fields;                              /* Number of fields */
 
217
  uint32_t rec_buff_length;                 /* Size of table->record[] buffer */
 
218
  uint32_t keys, key_parts;
 
219
  uint32_t max_key_length, max_unique_length, total_key_length;
 
220
  uint32_t uniques;                         /* Number of UNIQUE index */
 
221
  uint32_t null_fields;                 /* number of null fields */
 
222
  uint32_t blob_fields;                 /* number of blob fields */
 
223
  uint32_t timestamp_field_offset;              /* Field number for timestamp field */
 
224
  uint32_t varchar_fields;                  /* number of varchar fields */
 
225
  uint32_t db_create_options;           /* Create options from database */
 
226
  uint32_t db_options_in_use;           /* Options in use */
 
227
  uint32_t db_record_offset;            /* if HA_REC_IN_SEQ */
 
228
  uint32_t rowid_field_offset;          /* Field_nr +1 to rowid field */
 
229
  /* Index of auto-updated TIMESTAMP field in field array */
 
230
  uint32_t primary_key;
 
231
  uint32_t next_number_index;               /* autoincrement key number */
 
232
  uint32_t next_number_key_offset;          /* autoinc keypart offset in a key */
 
233
  uint32_t next_number_keypart;             /* autoinc keypart number in a key */
 
234
  uint32_t error, open_errno, errarg;       /* error from open_table_def() */
 
235
  uint32_t column_bitmap_size;
 
236
  unsigned char frm_version;
 
237
  bool null_field_first;
 
238
  bool db_low_byte_first;               /* Portable row format */
 
239
  bool crashed;
 
240
  bool name_lock, replace_with_name_lock;
 
241
  bool waiting_on_cond;                 /* Protection against free */
 
242
  uint32_t table_map_id;                   /* for row-based replication */
 
243
  uint64_t table_map_version;
 
244
 
 
245
  /*
 
246
    Cache for row-based replication table share checks that does not
 
247
    need to be repeated. Possible values are: -1 when cache value is
 
248
    not calculated yet, 0 when table *shall not* be replicated, 1 when
 
249
    table *may* be replicated.
 
250
  */
 
251
  int cached_row_logging_check;
 
252
 
 
253
  /*
 
254
    Set share's table cache key and update its db and table name appropriately.
 
255
 
 
256
    SYNOPSIS
 
257
      set_table_cache_key()
 
258
        key_buff    Buffer with already built table cache key to be
 
259
                    referenced from share.
 
260
        key_length  Key length.
 
261
 
 
262
    NOTES
 
263
      Since 'key_buff' buffer will be referenced from share it should has same
 
264
      life-time as share itself.
 
265
      This method automatically ensures that TABLE_SHARE::table_name/db have
 
266
      appropriate values by using table cache key as their source.
 
267
  */
 
268
 
 
269
  void set_table_cache_key(char *key_buff, uint32_t key_length)
 
270
  {
 
271
    table_cache_key.str= key_buff;
 
272
    table_cache_key.length= key_length;
 
273
    /*
 
274
      Let us use the fact that the key is "db/0/table_name/0" + optional
 
275
      part for temporary tables.
 
276
    */
 
277
    db.str=            table_cache_key.str;
 
278
    db.length=         strlen(db.str);
 
279
    table_name.str=    db.str + db.length + 1;
 
280
    table_name.length= strlen(table_name.str);
 
281
  }
 
282
 
 
283
 
 
284
  /*
 
285
    Set share's table cache key and update its db and table name appropriately.
 
286
 
 
287
    SYNOPSIS
 
288
      set_table_cache_key()
 
289
        key_buff    Buffer to be used as storage for table cache key
 
290
                    (should be at least key_length bytes).
 
291
        key         Value for table cache key.
 
292
        key_length  Key length.
 
293
 
 
294
    NOTE
 
295
      Since 'key_buff' buffer will be used as storage for table cache key
 
296
      it should has same life-time as share itself.
 
297
  */
 
298
 
 
299
  void set_table_cache_key(char *key_buff, const char *key, uint32_t key_length)
 
300
  {
 
301
    memcpy(key_buff, key, key_length);
 
302
    set_table_cache_key(key_buff, key_length);
 
303
  }
 
304
 
 
305
  inline bool honor_global_locks()
 
306
  {
 
307
    return (table_category == TABLE_CATEGORY_USER);
 
308
  }
 
309
 
 
310
  inline uint32_t get_table_def_version()
 
311
  {
 
312
    return table_map_id;
 
313
  }
 
314
 
 
315
} TABLE_SHARE;
 
316
 
 
317
 
 
318
extern uint32_t refresh_version;
 
319
 
 
320
/* Information for one open table */
 
321
enum index_hint_type
 
322
{
 
323
  INDEX_HINT_IGNORE,
 
324
  INDEX_HINT_USE,
 
325
  INDEX_HINT_FORCE
 
326
};
 
327
 
 
328
typedef struct st_table_field_w_type
 
329
{
 
330
  LEX_STRING name;
 
331
  LEX_STRING type;
 
332
  LEX_STRING cset;
 
333
} TABLE_FIELD_W_TYPE;
 
334
 
 
335
bool create_myisam_from_heap(THD *thd, Table *table,
58
336
                             MI_COLUMNDEF *start_recinfo,
59
 
                             MI_COLUMNDEF **recinfo,
 
337
                             MI_COLUMNDEF **recinfo, 
60
338
                             int error, bool ignore_last_dupp_key_error);
61
339
 
62
 
/**
63
 
 * Class representing a set of records, either in a temporary, 
64
 
 * normal, or derived table.
65
 
 */
66
 
class Table 
67
 
{
 
340
class Table {
 
341
 
68
342
public:
69
 
 
70
 
  TableShare *s; /**< Pointer to the shared metadata about the table */
71
 
  Field **field; /**< Pointer to fields collection */
72
 
 
73
 
  Cursor *cursor; /**< Pointer to the storage engine's Cursor managing this table */
74
 
  Table *next;
75
 
  Table *prev;
76
 
 
77
 
  MyBitmap *read_set; /* Active column sets */
78
 
  MyBitmap *write_set; /* Active column sets */
79
 
 
80
 
  uint32_t tablenr;
81
 
  uint32_t db_stat; /**< information about the cursor as in Cursor.h */
82
 
 
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... */
86
 
 
87
 
  Session *in_use; /**< Pointer to the current session using this object */
88
 
  Session *getSession()
89
 
  {
90
 
    return in_use;
91
 
  }
92
 
 
93
 
  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 */
96
 
  Field *next_number_field; /**< Set if next_number is activated. @TODO What the heck is the difference between this and the next member? */
97
 
  Field *found_next_number_field; /**< Points to the "next-number" field (autoincrement field) */
98
 
  Field_timestamp *timestamp_field; /**< Points to the auto-setting timestamp field, if any */
99
 
 
100
 
  TableList *pos_in_table_list; /* Element referring to this table */
 
343
  TABLE_SHARE   *s;
 
344
  Table() {}                               /* Remove gcc warning */
 
345
 
 
346
  /* SHARE methods */
 
347
  inline TABLE_SHARE *getShare() { return s; } /* Get rid of this long term */
 
348
  inline void setShare(TABLE_SHARE *new_share) { s= new_share; } /* Get rid of this long term */
 
349
  inline uint32_t sizeKeys() { return s->keys; }
 
350
  inline uint32_t sizeFields() { return s->fields; }
 
351
  inline uint32_t getRecordLength() { return s->reclength; }
 
352
  inline uint32_t sizeBlobFields() { return s->blob_fields; }
 
353
  inline uint32_t *getBlobField() { return s->blob_field; }
 
354
  inline uint32_t getNullBytes() { return s->null_bytes; }
 
355
  inline uint32_t getNullFields() { return s->null_fields; }
 
356
  inline unsigned char *getDefaultValues() { return s->default_values; }
 
357
 
 
358
  inline bool isNullFieldFirst() { return s->null_field_first; }
 
359
  inline bool isDatabaseLowByteFirst() { return s->db_low_byte_first; }         /* Portable row format */
 
360
  inline bool isCrashed() { return s->crashed; }
 
361
  inline bool isNameLock() { return s->name_lock; } 
 
362
  inline bool isReplaceWithNameLock() { return s->replace_with_name_lock; }
 
363
  inline bool isWaitingOnCondition() { return s->waiting_on_cond; }                 /* Protection against free */
 
364
 
 
365
  /* For TMP tables, should be pulled out as a class */
 
366
  void updateCreateInfo(HA_CREATE_INFO *create_info);
 
367
  void setup_tmp_table_column_bitmaps(unsigned char *bitmaps);
 
368
  bool create_myisam_tmp_table(KEY *keyinfo, 
 
369
                               MI_COLUMNDEF *start_recinfo,
 
370
                               MI_COLUMNDEF **recinfo, 
 
371
                               uint64_t options);
 
372
  void free_tmp_table(THD *thd);
 
373
  bool open_tmp_table();
 
374
  size_t max_row_length(const unsigned char *data);
 
375
  uint32_t find_shortest_key(const key_map *usable_keys);
 
376
  bool compare_record(Field **ptr);
 
377
  bool compare_record();
 
378
 
 
379
  bool table_check_intact(const uint32_t table_f_count, const TABLE_FIELD_W_TYPE *table_def);
 
380
 
 
381
  /* See if this can be blown away */
 
382
  inline uint32_t getDBStat () { return db_stat; }
 
383
  inline uint32_t setDBStat () { return db_stat; }
 
384
  uint          db_stat;                /* mode of file as in handler.h */
 
385
 
 
386
  handler       *file;
 
387
  Table *next, *prev;
 
388
 
 
389
  THD   *in_use;                        /* Which thread uses this */
 
390
  Field **field;                        /* Pointer to fields */
 
391
 
 
392
  unsigned char *record[2];                     /* Pointer to records */
 
393
  unsigned char *write_row_record;              /* Used as optimisation in
 
394
                                           THD::write_row */
 
395
  unsigned char *insert_values;                  /* used by INSERT ... UPDATE */
 
396
  /* 
 
397
    Map of keys that can be used to retrieve all data from this table 
 
398
    needed by the query without reading the row.
 
399
  */
 
400
  key_map covering_keys;
 
401
  key_map quick_keys, merge_keys;
 
402
  /*
 
403
    A set of keys that can be used in the query that references this
 
404
    table.
 
405
 
 
406
    All indexes disabled on the table's TABLE_SHARE (see Table::s) will be 
 
407
    subtracted from this set upon instantiation. Thus for any Table t it holds
 
408
    that t.keys_in_use_for_query is a subset of t.s.keys_in_use. Generally we 
 
409
    must not introduce any new keys here (see setup_tables).
 
410
 
 
411
    The set is implemented as a bitmap.
 
412
  */
 
413
  key_map keys_in_use_for_query;
 
414
  /* Map of keys that can be used to calculate GROUP BY without sorting */
 
415
  key_map keys_in_use_for_group_by;
 
416
  /* Map of keys that can be used to calculate ORDER BY without sorting */
 
417
  key_map keys_in_use_for_order_by;
 
418
  KEY  *key_info;                       /* data of keys in database */
 
419
 
 
420
  Field *next_number_field;             /* Set if next_number is activated */
 
421
  Field *found_next_number_field;       /* Set on open */
 
422
  Field_timestamp *timestamp_field;
 
423
 
 
424
  TableList *pos_in_table_list;/* Element referring to this table */
101
425
  order_st *group;
102
 
  const char *alias; /**< alias or table name if no alias */
103
 
  unsigned char *null_flags;
104
 
 
105
 
  uint32_t lock_position; /**< Position in DRIZZLE_LOCK.table */
106
 
  uint32_t lock_data_start; /**< Start pos. in DRIZZLE_LOCK.locks */
107
 
  uint32_t lock_count; /**< Number of locks */
108
 
  uint32_t used_fields;
109
 
  uint32_t status; /* What's in record[0] */
 
426
  const char    *alias;                   /* alias or table name */
 
427
  unsigned char         *null_flags;
 
428
  my_bitmap_map *bitmap_init_value;
 
429
  MY_BITMAP     def_read_set, def_write_set, tmp_set; /* containers */
 
430
  MY_BITMAP     *read_set, *write_set;          /* Active column sets */
 
431
  /*
 
432
   The ID of the query that opened and is using this table. Has different
 
433
   meanings depending on the table type.
 
434
 
 
435
   Temporary tables:
 
436
 
 
437
   table->query_id is set to thd->query_id for the duration of a statement
 
438
   and is reset to 0 once it is closed by the same statement. A non-zero
 
439
   table->query_id means that a statement is using the table even if it's
 
440
   not the current statement (table is in use by some outer statement).
 
441
 
 
442
   Non-temporary tables:
 
443
 
 
444
   Under pre-locked or LOCK TABLES mode: query_id is set to thd->query_id
 
445
   for the duration of a statement and is reset to 0 once it is closed by
 
446
   the same statement. A non-zero query_id is used to control which tables
 
447
   in the list of pre-opened and locked tables are actually being used.
 
448
  */
 
449
  query_id_t    query_id;
 
450
 
 
451
  /* 
 
452
    For each key that has quick_keys.is_set(key) == true: estimate of #records
 
453
    and max #key parts that range access would use.
 
454
  */
 
455
  ha_rows       quick_rows[MAX_KEY];
 
456
 
 
457
  /* Bitmaps of key parts that =const for the entire join. */
 
458
  key_part_map  const_key_parts[MAX_KEY];
 
459
 
 
460
  uint          quick_key_parts[MAX_KEY];
 
461
  uint          quick_n_ranges[MAX_KEY];
 
462
 
 
463
  /* 
 
464
    Estimate of number of records that satisfy SARGable part of the table
 
465
    condition, or table->file->records if no SARGable condition could be
 
466
    constructed.
 
467
    This value is used by join optimizer as an estimate of number of records
 
468
    that will pass the table condition (condition that depends on fields of 
 
469
    this table and constants)
 
470
  */
 
471
  ha_rows       quick_condition_rows;
 
472
 
 
473
  /*
 
474
    If this table has TIMESTAMP field with auto-set property (pointed by
 
475
    timestamp_field member) then this variable indicates during which
 
476
    operations (insert only/on update/in both cases) we should set this
 
477
    field to current timestamp. If there are no such field in this table
 
478
    or we should not automatically set its value during execution of current
 
479
    statement then the variable contains TIMESTAMP_NO_AUTO_SET (i.e. 0).
 
480
 
 
481
    Value of this variable is set for each statement in open_table() and
 
482
    if needed cleared later in statement processing code (see mysql_update()
 
483
    as example).
 
484
  */
 
485
  timestamp_auto_set_type timestamp_field_type;
 
486
  table_map     map;                    /* ID bit of table (1,2,4,8,16...) */
 
487
 
 
488
  uint32_t          lock_position;          /* Position in DRIZZLE_LOCK.table */
 
489
  uint32_t          lock_data_start;        /* Start pos. in DRIZZLE_LOCK.locks */
 
490
  uint32_t          lock_count;             /* Number of locks */
 
491
  uint          tablenr,used_fields;
 
492
  uint32_t          temp_pool_slot;             /* Used by intern temp tables */
 
493
  uint          status;                 /* What's in record[0] */
110
494
  /* number of select if it is derived table */
111
 
  uint32_t derived_select_number;
112
 
  int current_lock; /**< Type of lock on table */
113
 
  bool copy_blobs; /**< Should blobs by copied when storing? */
 
495
  uint32_t          derived_select_number;
 
496
  int           current_lock;           /* Type of lock on table */
 
497
  bool copy_blobs;                      /* copy_blobs when storing */
114
498
 
115
499
  /*
116
500
    0 or JOIN_TYPE_{LEFT|RIGHT}. Currently this is only compared to 0.
120
504
  bool maybe_null;
121
505
 
122
506
  /*
123
 
    If true, the current table row is considered to have all columns set to
 
507
    If true, the current table row is considered to have all columns set to 
124
508
    NULL, including columns declared as "not null" (see maybe_null).
125
509
  */
126
510
  bool null_row;
127
511
 
128
512
  bool force_index;
129
513
  bool distinct,const_table,no_rows;
130
 
  bool key_read;
131
 
  bool no_keyread;
 
514
  bool key_read, no_keyread;
132
515
  /*
133
516
    Placeholder for an open table which prevents other connections
134
517
    from taking name-locks on this table. Typically used with
135
 
    TableShare::version member to take an exclusive name-lock on
 
518
    TABLE_SHARE::version member to take an exclusive name-lock on
136
519
    this table name -- a name lock that not only prevents other
137
520
    threads from opening the table, but also blocks other name
138
521
    locks. This is achieved by:
142
525
    - setting version to 0 - this will force other threads to close
143
526
      the instance of this table and wait (this is the same approach
144
527
      as used for usual name locks).
145
 
    An exclusively name-locked table currently can have no Cursor
 
528
    An exclusively name-locked table currently can have no handler
146
529
    object associated with it (db_stat is always 0), but please do
147
530
    not rely on that.
148
531
  */
149
532
  bool open_placeholder;
 
533
  bool locked_by_logger;
 
534
  bool no_replicate;
150
535
  bool locked_by_name;
151
536
  bool no_cache;
 
537
  /* To signal that the table is associated with a HANDLER statement */
 
538
  bool open_by_handler;
152
539
  /*
153
540
    To indicate that a non-null value of the auto_increment field
154
541
    was provided by the user or retrieved from the current record.
155
542
    Used only in the MODE_NO_AUTO_VALUE_ON_ZERO mode.
156
543
  */
157
544
  bool auto_increment_field_not_null;
158
 
  bool alias_name_used; /* true if table_name is alias */
159
 
 
160
 
  /*
161
 
   The ID of the query that opened and is using this table. Has different
162
 
   meanings depending on the table type.
163
 
 
164
 
   Temporary tables:
165
 
 
166
 
   table->query_id is set to session->query_id for the duration of a statement
167
 
   and is reset to 0 once it is closed by the same statement. A non-zero
168
 
   table->query_id means that a statement is using the table even if it's
169
 
   not the current statement (table is in use by some outer statement).
170
 
 
171
 
   Non-temporary tables:
172
 
 
173
 
   Under pre-locked or LOCK TABLES mode: query_id is set to session->query_id
174
 
   for the duration of a statement and is reset to 0 once it is closed by
175
 
   the same statement. A non-zero query_id is used to control which tables
176
 
   in the list of pre-opened and locked tables are actually being used.
177
 
  */
178
 
  query_id_t query_id;
179
 
 
180
 
  /**
181
 
   * Estimate of number of records that satisfy SARGable part of the table
182
 
   * condition, or table->cursor->records if no SARGable condition could be
183
 
   * constructed.
184
 
   * This value is used by join optimizer as an estimate of number of records
185
 
   * that will pass the table condition (condition that depends on fields of
186
 
   * this table and constants)
187
 
   */
188
 
  ha_rows quick_condition_rows;
189
 
 
190
 
  /*
191
 
    If this table has TIMESTAMP field with auto-set property (pointed by
192
 
    timestamp_field member) then this variable indicates during which
193
 
    operations (insert only/on update/in both cases) we should set this
194
 
    field to current timestamp. If there are no such field in this table
195
 
    or we should not automatically set its value during execution of current
196
 
    statement then the variable contains TIMESTAMP_NO_AUTO_SET (i.e. 0).
197
 
 
198
 
    Value of this variable is set for each statement in open_table() and
199
 
    if needed cleared later in statement processing code (see mysql_update()
200
 
    as example).
201
 
  */
202
 
  timestamp_auto_set_type timestamp_field_type;
203
 
  table_map map; ///< ID bit of table (1,2,4,8,16...)
204
 
 
205
 
  RegInfo reginfo; /* field connections */
206
 
 
207
 
  /*
208
 
    Map of keys that can be used to retrieve all data from this table
209
 
    needed by the query without reading the row.
210
 
  */
211
 
  key_map covering_keys;
212
 
  key_map quick_keys;
213
 
  key_map merge_keys;
214
 
 
215
 
  /*
216
 
    A set of keys that can be used in the query that references this
217
 
    table.
218
 
 
219
 
    All indexes disabled on the table's TableShare (see Table::s) will be
220
 
    subtracted from this set upon instantiation. Thus for any Table t it holds
221
 
    that t.keys_in_use_for_query is a subset of t.s.keys_in_use. Generally we
222
 
    must not introduce any new keys here (see setup_tables).
223
 
 
224
 
    The set is implemented as a bitmap.
225
 
  */
226
 
  key_map keys_in_use_for_query;
227
 
  /* Map of keys that can be used to calculate GROUP BY without sorting */
228
 
  key_map keys_in_use_for_group_by;
229
 
  /* Map of keys that can be used to calculate ORDER BY without sorting */
230
 
  key_map keys_in_use_for_order_by;
231
 
 
232
 
  /*
233
 
    For each key that has quick_keys.test(key) == true: estimate of #records
234
 
    and max #key parts that range access would use.
235
 
  */
236
 
  ha_rows quick_rows[MAX_KEY];
237
 
 
238
 
  /* Bitmaps of key parts that =const for the entire join. */
239
 
  key_part_map  const_key_parts[MAX_KEY];
240
 
 
241
 
  uint32_t quick_key_parts[MAX_KEY];
242
 
  uint32_t quick_n_ranges[MAX_KEY];
243
 
 
244
 
  memory::Root mem_root;
 
545
  bool insert_or_update;             /* Can be used by the handler */
 
546
  bool alias_name_used;         /* true if table_name is alias */
 
547
  bool get_fields_in_item_tree;      /* Signal to fix_field */
 
548
 
 
549
  REGINFO reginfo;                      /* field connections */
 
550
  MEM_ROOT mem_root;
245
551
  filesort_info_st sort;
246
552
 
247
 
  Table();
248
 
 
249
 
  int report_error(int error);
250
 
  /**
251
 
   * Free information allocated by openfrm
252
 
   *
253
 
   * @param If true if we also want to free table_share
254
 
   */
255
 
  int closefrm(bool free_share);
256
 
 
257
 
  void resetTable(Session *session, TableShare *share, uint32_t db_stat_arg);
258
 
 
259
 
  /* 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 */
275
 
 
276
 
  uint32_t index_flags(uint32_t idx) const
277
 
  {
278
 
    return s->storage_engine->index_flags(s->key_info[idx].algorithm);
279
 
  }
280
 
 
281
 
  inline plugin::StorageEngine *getEngine() const       /* table_type for handler */
282
 
  {
283
 
    return s->storage_engine;
284
 
  }
285
 
 
286
 
  Cursor &getCursor() const     /* table_type for handler */
287
 
  {
288
 
    assert(cursor);
289
 
    return *cursor;
290
 
  }
291
 
 
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
 
  size_t max_row_length(const unsigned char *data);
302
 
  uint32_t find_shortest_key(const key_map *usable_keys);
303
 
  bool compare_record(Field **ptr);
304
 
  bool compare_record();
305
 
  /* TODO: the (re)storeRecord's may be able to be further condensed */
306
 
  void storeRecord();
307
 
  void storeRecordAsInsert();
308
 
  void storeRecordAsDefault();
309
 
  void restoreRecord();
310
 
  void restoreRecordAsDefault();
311
 
  void emptyRecord();
312
 
 
313
 
  /* See if this can be blown away */
314
 
  inline uint32_t getDBStat () { return db_stat; }
315
 
  inline uint32_t setDBStat () { return db_stat; }
316
 
  /**
317
 
   * Create Item_field for each column in the table.
318
 
   *
319
 
   * @param[out] a pointer to an empty list used to store items
320
 
   *
321
 
   * @details
322
 
   *
323
 
   * Create Item_field object for each column in the table and
324
 
   * initialize it with the corresponding Field. New items are
325
 
   * created in the current Session memory root.
326
 
   *
327
 
   * @retval
328
 
   *  false on success
329
 
   * @retval
330
 
   *  true when out of memory
331
 
   */
332
553
  bool fill_item_list(List<Item> *item_list) const;
 
554
  void reset_item_list(List<Item> *item_list) const;
333
555
  void clear_column_bitmaps(void);
334
556
  void prepare_for_position(void);
335
 
  void mark_columns_used_by_index_no_reset(uint32_t index, MyBitmap *map);
336
 
  void mark_columns_used_by_index_no_reset(uint32_t index);
 
557
  void mark_columns_used_by_index_no_reset(uint32_t index, MY_BITMAP *map);
337
558
  void mark_columns_used_by_index(uint32_t index);
338
559
  void restore_column_maps_after_mark_index();
339
560
  void mark_auto_increment_column(void);
340
561
  void mark_columns_needed_for_update(void);
341
562
  void mark_columns_needed_for_delete(void);
342
563
  void mark_columns_needed_for_insert(void);
343
 
  inline void column_bitmaps_set(MyBitmap *read_set_arg,
344
 
                                 MyBitmap *write_set_arg)
 
564
  inline void column_bitmaps_set(MY_BITMAP *read_set_arg,
 
565
                                 MY_BITMAP *write_set_arg)
 
566
  {
 
567
    read_set= read_set_arg;
 
568
    write_set= write_set_arg;
 
569
    if (file)
 
570
      file->column_bitmaps_signal();
 
571
  }
 
572
  inline void column_bitmaps_set_no_signal(MY_BITMAP *read_set_arg,
 
573
                                           MY_BITMAP *write_set_arg)
345
574
  {
346
575
    read_set= read_set_arg;
347
576
    write_set= write_set_arg;
349
578
 
350
579
  void restore_column_map(my_bitmap_map *old);
351
580
 
352
 
  my_bitmap_map *use_all_columns(MyBitmap *bitmap);
 
581
  my_bitmap_map *use_all_columns(MY_BITMAP *bitmap);
353
582
  inline void use_all_columns()
354
583
  {
355
584
    column_bitmaps_set(&s->all_set, &s->all_set);
361
590
    write_set= &def_write_set;
362
591
  }
363
592
 
364
 
  /* Both of the below should go away once we can move this bit to the field objects */
365
 
  inline bool isReadSet(uint32_t index)
366
 
  {
367
 
    return read_set->isBitSet(index);
368
 
  }
369
 
 
370
 
  inline void setReadSet(uint32_t index)
371
 
  {
372
 
    read_set->setBit(index);
373
 
  }
374
 
 
375
 
  inline void setReadSet()
376
 
  {
377
 
    read_set->setAll();
378
 
  }
379
 
 
380
 
  inline void clearReadSet(uint32_t index)
381
 
  {
382
 
    read_set->clearBit(index);
383
 
  }
384
 
 
385
 
  inline void clearReadSet()
386
 
  {
387
 
    read_set->clearAll();
388
 
  }
389
 
 
390
 
  inline bool isWriteSet(uint32_t index)
391
 
  {
392
 
    return write_set->isBitSet(index);
393
 
  }
394
 
 
395
 
  inline void setWriteSet(uint32_t index)
396
 
  {
397
 
    write_set->setBit(index);
398
 
  }
399
 
 
400
 
  inline void setWriteSet()
401
 
  {
402
 
    write_set->setAll();
403
 
  }
404
 
 
405
 
  inline void clearWriteSet(uint32_t index)
406
 
  {
407
 
    write_set->clearBit(index);
408
 
  }
409
 
 
410
 
  inline void clearWriteSet()
411
 
  {
412
 
    write_set->clearAll();
413
 
  }
414
 
 
415
593
  /* Is table open or should be treated as such by name-locking? */
416
 
  inline bool is_name_opened()
417
 
  {
418
 
    return db_stat || open_placeholder;
419
 
  }
 
594
  inline bool is_name_opened() { return db_stat || open_placeholder; }
420
595
  /*
421
596
    Is this instance of the table should be reopen or represents a name-lock?
422
597
  */
423
598
  inline bool needs_reopen_or_name_lock()
424
 
  { 
425
 
    return s->version != refresh_version;
426
 
  }
427
 
 
428
 
  /**
429
 
    clean/setup table fields and map.
430
 
 
431
 
    @param table        Table structure pointer (which should be setup)
432
 
    @param table_list   TableList structure pointer (owner of Table)
433
 
    @param tablenr     table number
434
 
  */
435
 
  void setup_table_map(TableList *table_list, uint32_t tablenr);
436
 
  inline void mark_as_null_row()
437
 
  {
438
 
    null_row= 1;
439
 
    status|= STATUS_NULL_ROW;
440
 
    memset(null_flags, 255, s->null_bytes);
441
 
  }
442
 
 
443
 
  bool renameAlterTemporaryTable(TableIdentifier &identifier);
444
 
  void free_io_cache();
445
 
  void filesort_free_buffers(bool full= false);
446
 
  void intern_close_table();
447
 
 
448
 
  void print_error(int error, myf errflag)
449
 
  {
450
 
    s->storage_engine->print_error(error, errflag, *this);
451
 
  }
452
 
 
453
 
  /**
454
 
    @return
455
 
    key if error because of duplicated keys
456
 
  */
457
 
  uint32_t get_dup_key(int error)
458
 
  {
459
 
    cursor->errkey  = (uint32_t) -1;
460
 
    if (error == HA_ERR_FOUND_DUPP_KEY || error == HA_ERR_FOREIGN_DUPLICATE_KEY ||
461
 
        error == HA_ERR_FOUND_DUPP_UNIQUE ||
462
 
        error == HA_ERR_DROP_INDEX_FK)
463
 
      cursor->info(HA_STATUS_ERRKEY | HA_STATUS_NO_LOCK);
464
 
 
465
 
    return(cursor->errkey);
466
 
  }
467
 
 
468
 
  /*
469
 
    This is a short term fix. Long term we will used the TableIdentifier to do the actual comparison.
470
 
  */
471
 
  bool operator<(const Table &right) const
472
 
  {
473
 
    int result= strcasecmp(this->getShare()->getSchemaName(), right.getShare()->getSchemaName());
474
 
 
475
 
    if (result <  0)
476
 
      return true;
477
 
 
478
 
    if (result >  0)
479
 
      return false;
480
 
 
481
 
    result= strcasecmp(this->getShare()->getTableName(), right.getShare()->getTableName());
482
 
 
483
 
    if (result <  0)
484
 
      return true;
485
 
 
486
 
    if (result >  0)
487
 
      return false;
488
 
 
489
 
    if (this->getShare()->getTableProto()->type()  < right.getShare()->getTableProto()->type())
490
 
      return true;
491
 
 
492
 
    return false;
493
 
  }
494
 
 
495
 
  static bool compare(const Table *a, const Table *b)
496
 
  {
497
 
    return *a < *b;
498
 
  }
499
 
 
500
 
  friend std::ostream& operator<<(std::ostream& output, const Table &table)
501
 
  {
502
 
    output << "Table:(";
503
 
    output << table.getShare()->getSchemaName();
504
 
    output << ", ";
505
 
    output <<  table.getShare()->getTableName();
506
 
    output << ", ";
507
 
    output <<  table.getShare()->getTableTypeAsString();
508
 
    output << ")";
509
 
 
510
 
    return output;  // for multiple << operators.
511
 
  }
512
 
 
 
599
  { return s->version != refresh_version; }
 
600
 
 
601
  int report_error(int error);
513
602
};
514
603
 
515
 
Table *create_virtual_tmp_table(Session *session, List<CreateField> &field_list);
516
 
 
517
604
typedef struct st_foreign_key_info
518
605
{
519
606
  LEX_STRING *forein_id;
526
613
  List<LEX_STRING> referenced_fields;
527
614
} FOREIGN_KEY_INFO;
528
615
 
 
616
/*
 
617
  Make sure that the order of schema_tables and enum_schema_tables are the same.
 
618
*/
 
619
 
 
620
enum enum_schema_tables
 
621
{
 
622
  SCH_CHARSETS= 0,
 
623
  SCH_COLLATIONS,
 
624
  SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
 
625
  SCH_COLUMNS,
 
626
  SCH_GLOBAL_STATUS,
 
627
  SCH_GLOBAL_VARIABLES,
 
628
  SCH_KEY_COLUMN_USAGE,
 
629
  SCH_OPEN_TABLES,
 
630
  SCH_PLUGINS,
 
631
  SCH_PROCESSLIST,
 
632
  SCH_REFERENTIAL_CONSTRAINTS,
 
633
  SCH_SCHEMATA,
 
634
  SCH_SESSION_STATUS,
 
635
  SCH_SESSION_VARIABLES,
 
636
  SCH_STATISTICS,
 
637
  SCH_STATUS,
 
638
  SCH_TABLES,
 
639
  SCH_TABLE_CONSTRAINTS,
 
640
  SCH_TABLE_NAMES,
 
641
  SCH_VARIABLES
 
642
};
 
643
 
 
644
 
 
645
#define MY_I_S_MAYBE_NULL 1
 
646
#define MY_I_S_UNSIGNED   2
 
647
 
 
648
 
 
649
#define SKIP_OPEN_TABLE 0                // do not open table
 
650
#define OPEN_FRM_ONLY   1                // open FRM file only
 
651
#define OPEN_FULL_TABLE 2                // open FRM,MYD, MYI files
 
652
 
 
653
typedef struct st_field_info
 
654
{
 
655
  /** 
 
656
      This is used as column name. 
 
657
  */
 
658
  const char* field_name;
 
659
  /**
 
660
     For string-type columns, this is the maximum number of
 
661
     characters. Otherwise, it is the 'display-length' for the column.
 
662
  */
 
663
  uint32_t field_length;
 
664
  /**
 
665
     This denotes data type for the column. For the most part, there seems to
 
666
     be one entry in the enum for each SQL data type, although there seem to
 
667
     be a number of additional entries in the enum.
 
668
  */
 
669
  enum enum_field_types field_type;
 
670
  int value;
 
671
  /**
 
672
     This is used to set column attributes. By default, columns are @c NOT
 
673
     @c NULL and @c SIGNED, and you can deviate from the default
 
674
     by setting the appopriate flags. You can use either one of the flags
 
675
     @c MY_I_S_MAYBE_NULL and @cMY_I_S_UNSIGNED or
 
676
     combine them using the bitwise or operator @c |. Both flags are
 
677
     defined in table.h.
 
678
   */
 
679
  uint32_t field_flags;        // Field atributes(maybe_null, signed, unsigned etc.)
 
680
  const char* old_name;
 
681
  /**
 
682
     This should be one of @c SKIP_OPEN_TABLE,
 
683
     @c OPEN_FRM_ONLY or @c OPEN_FULL_TABLE.
 
684
  */
 
685
  uint32_t open_method;
 
686
} ST_FIELD_INFO;
529
687
 
530
688
 
531
689
class TableList;
 
690
typedef class Item COND;
 
691
 
 
692
struct ST_SCHEMA_TABLE
 
693
{
 
694
  const char* table_name;
 
695
  ST_FIELD_INFO *fields_info;
 
696
  /* Create information_schema table */
 
697
  Table *(*create_table)  (THD *thd, TableList *table_list);
 
698
  /* Fill table with data */
 
699
  int (*fill_table) (THD *thd, TableList *tables, COND *cond);
 
700
  /* Handle fileds for old SHOW */
 
701
  int (*old_format) (THD *thd, struct ST_SCHEMA_TABLE *schema_table);
 
702
  int (*process_table) (THD *thd, TableList *tables, Table *table,
 
703
                        bool res, LEX_STRING *db_name, LEX_STRING *table_name);
 
704
  int idx_field1, idx_field2; 
 
705
  bool hidden;
 
706
  uint32_t i_s_requested_object;  /* the object we need to open(Table | VIEW) */
 
707
};
 
708
 
532
709
 
533
710
#define JOIN_TYPE_LEFT  1
534
711
#define JOIN_TYPE_RIGHT 2
535
712
 
536
713
struct st_lex;
537
714
class select_union;
538
 
class Tmp_Table_Param;
 
715
class TMP_TABLE_PARAM;
539
716
 
540
 
struct open_table_list_st
 
717
struct Field_translator
541
718
{
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
 
 
 
719
  Item *item;
 
720
  const char *name;
552
721
};
553
722
 
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
 
void free_blobs(Table *table);
562
 
int set_zone(int nr,int min_zone,int max_zone);
563
 
uint32_t convert_period_to_month(uint32_t period);
564
 
uint32_t convert_month_to_period(uint32_t month);
565
 
 
566
 
int test_if_number(char *str,int *res,bool allow_wildcards);
567
 
void change_byte(unsigned char *,uint,char,char);
568
 
 
569
 
namespace optimizer { class SqlSelect; }
570
 
 
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
 
void change_double_for_sort(double nr,unsigned char *to);
582
 
double my_double_round(double value, int64_t dec, bool dec_unsigned,
583
 
                       bool truncate);
584
 
int get_quick_record(optimizer::SqlSelect *select);
585
 
 
586
 
void find_date(char *pos,uint32_t *vek,uint32_t flag);
587
 
TYPELIB *convert_strings_to_array_type(char * *typelibs, char * *end);
588
 
TYPELIB *typelib(memory::Root *mem_root, List<String> &strings);
589
 
ulong get_form_pos(int file, unsigned char *head, TYPELIB *save_names);
590
 
ulong next_io_size(ulong pos);
591
 
void append_unescaped(String *res, const char *pos, uint32_t length);
592
 
 
593
 
int rename_file_ext(const char * from,const char * to,const char * ext);
594
 
bool check_column_name(const char *name);
595
 
bool check_db_name(SchemaIdentifier &schema);
596
 
bool check_table_name(const char *name, uint32_t length);
597
 
 
598
 
} /* namespace drizzled */
 
723
 
 
724
typedef struct st_changed_table_list
 
725
{
 
726
  struct        st_changed_table_list *next;
 
727
  char          *key;
 
728
  uint32_t        key_length;
 
729
} CHANGED_TableList;
 
730
 
 
731
 
 
732
typedef struct st_open_table_list
 
733
{
 
734
  struct st_open_table_list *next;
 
735
  char  *db,*table;
 
736
  uint32_t in_use,locked;
 
737
} OPEN_TableList;
 
738
 
599
739
 
600
740
#endif /* DRIZZLED_TABLE_H */