~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.h

  • Committer: Brian Aker
  • Date: 2008-08-12 03:12:57 UTC
  • Revision ID: brian@tangent.org-20080812031257-ln3uk87y1r22byeg
First pass of new sql_db.cc work

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; either version 2 of the License, or
9
 
 *  (at your option) any later version.
10
 
 *
11
 
 *  This program is distributed in the hope that it will be useful,
12
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 *  GNU General Public License for more details.
15
 
 *
16
 
 *  You should have received a copy of the GNU General Public License
17
 
 *  along with this program; if not, write to the Free Software
18
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
 
 */
20
 
 
21
 
/* Structs that defines the Table */
22
 
 
23
 
#ifndef DRIZZLED_TABLE_H
24
 
#define DRIZZLED_TABLE_H
25
 
 
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 */
 
1
/* Copyright (C) 2000-2006 MySQL AB
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
 
 
17
/* Structs that defines the TABLE */
 
18
 
 
19
class Item;                             /* Needed by ORDER */
34
20
class Item_subselect;
35
21
class st_select_lex_unit;
36
22
class st_select_lex;
37
23
class COND_EQUAL;
38
24
class Security_context;
39
 
class TableList;
40
25
 
41
26
/*************************************************************************/
42
27
 
 
28
/* Order clause list element */
 
29
 
 
30
typedef struct st_order {
 
31
  struct st_order *next;
 
32
  Item   **item;                        /* Point at item in select fields */
 
33
  Item   *item_ptr;                     /* Storage for initial item */
 
34
  Item   **item_copy;                   /* For SPs; the original item ptr */
 
35
  int    counter;                       /* position in SELECT list, correct
 
36
                                           only if counter_used is true*/
 
37
  bool   asc;                           /* true if ascending */
 
38
  bool   free_me;                       /* true if item isn't shared  */
 
39
  bool   in_field_list;                 /* true if in select field list */
 
40
  bool   counter_used;                  /* parameter was counter of columns */
 
41
  Field  *field;                        /* If tmp-table group */
 
42
  char   *buff;                         /* If tmp-table group */
 
43
  table_map used, depend_map;
 
44
} ORDER;
 
45
 
43
46
enum tmp_table_type
44
47
{
45
48
  NO_TMP_TABLE, NON_TRANSACTIONAL_TMP_TABLE, TRANSACTIONAL_TMP_TABLE,
46
49
  INTERNAL_TMP_TABLE, SYSTEM_TMP_TABLE, TMP_TABLE_FRM_FILE_ONLY
47
50
};
48
51
 
49
 
bool mysql_frm_type(THD *thd, char *path, enum legacy_db_type *dbt);
 
52
enum frm_type_enum
 
53
{
 
54
  FRMTYPE_ERROR= 0,
 
55
  FRMTYPE_TABLE
 
56
};
 
57
 
 
58
frm_type_enum mysql_frm_type(THD *thd, char *path, enum legacy_db_type *dbt);
50
59
 
51
60
 
52
61
enum release_type { RELEASE_NORMAL, RELEASE_WAIT_FOR_DROP };
53
62
 
 
63
typedef struct st_filesort_info
 
64
{
 
65
  IO_CACHE *io_cache;           /* If sorted through filesort */
 
66
  uchar     **sort_keys;        /* Buffer for sorting keys */
 
67
  uchar     *buffpek;           /* Buffer for buffpek structures */
 
68
  uint      buffpek_len;        /* Max number of buffpeks in the buffer */
 
69
  uchar     *addon_buf;         /* Pointer to a buffer if sorted with fields */
 
70
  size_t    addon_length;       /* Length of the buffer */
 
71
  struct st_sort_addon_field *addon_field;     /* Pointer to the fields info */
 
72
  void    (*unpack)(struct st_sort_addon_field *, uchar *); /* To unpack back */
 
73
  uchar     *record_pointers;    /* If sorted in memory */
 
74
  ha_rows   found_records;      /* How many records in sort */
 
75
} FILESORT_INFO;
 
76
 
 
77
 
54
78
/*
55
79
  Values in this enum are used to indicate how a tables TIMESTAMP field
56
80
  should be treated. It can be set to the current timestamp on insert or
89
113
    - FLUSH TABLES WITH READ LOCK
90
114
    - SET GLOBAL READ_ONLY = ON
91
115
    do not apply to this table.
92
 
    Note that LOCK Table t FOR READ/WRITE
 
116
    Note that LOCK TABLE t FOR READ/WRITE
93
117
    can be used on temporary tables.
94
118
    Temporary tables are not part of the table cache.
95
119
  */
98
122
  /**
99
123
    User table.
100
124
    These tables do honor:
101
 
    - LOCK Table t FOR READ/WRITE
 
125
    - LOCK TABLE t FOR READ/WRITE
102
126
    - FLUSH TABLES WITH READ LOCK
103
127
    - SET GLOBAL READ_ONLY = ON
104
128
    User tables are cached in the table cache.
106
130
  TABLE_CATEGORY_USER=2,
107
131
 
108
132
  /**
 
133
    System table, maintained by the server.
 
134
    These tables do honor:
 
135
    - LOCK TABLE t FOR READ/WRITE
 
136
    - FLUSH TABLES WITH READ LOCK
 
137
    - SET GLOBAL READ_ONLY = ON
 
138
    Typically, writes to system tables are performed by
 
139
    the server implementation, not explicitly be a user.
 
140
    System tables are cached in the table cache.
 
141
  */
 
142
  TABLE_CATEGORY_SYSTEM=3,
 
143
 
 
144
  /**
109
145
    Information schema tables.
110
146
    These tables are an interface provided by the system
111
147
    to inspect the system metadata.
112
148
    These tables do *not* honor:
113
 
    - LOCK Table t FOR READ/WRITE
 
149
    - LOCK TABLE t FOR READ/WRITE
114
150
    - FLUSH TABLES WITH READ LOCK
115
151
    - SET GLOBAL READ_ONLY = ON
116
152
    as there is no point in locking explicitely
125
161
    to I_S tables in the table cache, which should use
126
162
    this table type.
127
163
  */
128
 
  TABLE_CATEGORY_INFORMATION
 
164
  TABLE_CATEGORY_INFORMATION=4
129
165
};
130
166
typedef enum enum_table_category TABLE_CATEGORY;
131
167
 
155
191
  struct st_table_share *next,          /* Link to unused shares */
156
192
    **prev;
157
193
 
158
 
  /* The following is copied to each Table on OPEN */
 
194
  /* The following is copied to each TABLE on OPEN */
159
195
  Field **field;
160
196
  Field **found_next_number_field;
161
197
  Field *timestamp_field;               /* Used only during open */
162
198
  KEY  *key_info;                       /* data of keys in database */
163
199
  uint  *blob_field;                    /* Index to blobs in Field arrray*/
164
200
 
165
 
  unsigned char *default_values;                /* row with default values */
 
201
  uchar *default_values;                /* row with default values */
166
202
  LEX_STRING comment;                   /* Comment about table */
167
203
  const CHARSET_INFO *table_charset; /* Default charset of string fields */
168
204
 
180
216
  LEX_STRING table_cache_key;
181
217
  LEX_STRING db;                        /* Pointer to db */
182
218
  LEX_STRING table_name;                /* Table name (for open) */
183
 
  LEX_STRING path;      /* Path to .frm file (from datadir) */
 
219
  LEX_STRING path;                      /* Path to .frm file (from datadir) */
184
220
  LEX_STRING normalized_path;           /* unpack_filename(path) */
185
221
  LEX_STRING connect_string;
186
222
 
187
 
  /*
 
223
  /* 
188
224
     Set of keys in use, implemented as a Bitmap.
189
 
     Excludes keys disabled by ALTER Table ... DISABLE KEYS.
 
225
     Excludes keys disabled by ALTER TABLE ... DISABLE KEYS.
190
226
  */
191
227
  key_map keys_in_use;
192
228
  key_map keys_for_keyread;
193
229
  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 */
 
230
  ulong   avg_row_length;               /* create information */
 
231
  ulong   block_size;                   /* create information */
 
232
  ulong   version, mysql_version;
 
233
  ulong   timestamp_offset;             /* Set to offset+1 of record */
 
234
  ulong   reclength;                    /* Recordlength */
199
235
 
200
236
  plugin_ref db_plugin;                 /* storage engine plugin */
201
237
  inline handlerton *db_type() const    /* table_type for handler */
202
 
  {
 
238
  { 
203
239
    // assert(db_plugin);
204
240
    return db_plugin ? plugin_data(db_plugin, handlerton*) : NULL;
205
241
  }
208
244
  enum ha_choice transactional;
209
245
  enum ha_choice page_checksum;
210
246
 
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 */
 
247
  uint ref_count;                       /* How many TABLE objects uses this */
 
248
  uint open_count;                      /* Number of tables in open list */
 
249
  uint blob_ptr_size;                   /* 4 or 8 */
 
250
  uint key_block_size;                  /* create key_block_size, if used */
 
251
  uint null_bytes, last_null_bit_pos;
 
252
  uint fields;                          /* Number of fields */
 
253
  uint rec_buff_length;                 /* Size of table->record[] buffer */
 
254
  uint keys, key_parts;
 
255
  uint max_key_length, max_unique_length, total_key_length;
 
256
  uint uniques;                         /* Number of UNIQUE index */
 
257
  uint null_fields;                     /* number of null fields */
 
258
  uint blob_fields;                     /* number of blob fields */
 
259
  uint timestamp_field_offset;          /* Field number for timestamp field */
 
260
  uint varchar_fields;                  /* number of varchar fields */
 
261
  uint db_create_options;               /* Create options from database */
 
262
  uint db_options_in_use;               /* Options in use */
 
263
  uint db_record_offset;                /* if HA_REC_IN_SEQ */
 
264
  uint rowid_field_offset;              /* Field_nr +1 to rowid field */
229
265
  /* 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;
 
266
  uint primary_key;
 
267
  uint next_number_index;               /* autoincrement key number */
 
268
  uint next_number_key_offset;          /* autoinc keypart offset in a key */
 
269
  uint next_number_keypart;             /* autoinc keypart number in a key */
 
270
  uint error, open_errno, errarg;       /* error from open_table_def() */
 
271
  uint column_bitmap_size;
 
272
  uchar frm_version;
237
273
  bool null_field_first;
 
274
  bool system;                          /* Set if system table (one record) */
238
275
  bool db_low_byte_first;               /* Portable row format */
239
276
  bool crashed;
240
277
  bool name_lock, replace_with_name_lock;
241
278
  bool waiting_on_cond;                 /* Protection against free */
242
 
  uint32_t table_map_id;                   /* for row-based replication */
 
279
  ulong table_map_id;                   /* for row-based replication */
243
280
  uint64_t table_map_version;
244
281
 
245
282
  /*
266
303
      appropriate values by using table cache key as their source.
267
304
  */
268
305
 
269
 
  void set_table_cache_key(char *key_buff, uint32_t key_length)
 
306
  void set_table_cache_key(char *key_buff, uint key_length)
270
307
  {
271
308
    table_cache_key.str= key_buff;
272
309
    table_cache_key.length= key_length;
296
333
      it should has same life-time as share itself.
297
334
  */
298
335
 
299
 
  void set_table_cache_key(char *key_buff, const char *key, uint32_t key_length)
 
336
  void set_table_cache_key(char *key_buff, const char *key, uint key_length)
300
337
  {
301
338
    memcpy(key_buff, key, key_length);
302
339
    set_table_cache_key(key_buff, key_length);
304
341
 
305
342
  inline bool honor_global_locks()
306
343
  {
307
 
    return (table_category == TABLE_CATEGORY_USER);
 
344
    return ((table_category == TABLE_CATEGORY_USER)
 
345
            || (table_category == TABLE_CATEGORY_SYSTEM));
308
346
  }
309
347
 
310
 
  inline uint32_t get_table_def_version()
 
348
  inline ulong get_table_def_version()
311
349
  {
312
350
    return table_map_id;
313
351
  }
315
353
} TABLE_SHARE;
316
354
 
317
355
 
318
 
extern uint32_t refresh_version;
 
356
extern ulong refresh_version;
319
357
 
320
358
/* Information for one open table */
321
359
enum index_hint_type
325
363
  INDEX_HINT_FORCE
326
364
};
327
365
 
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,
336
 
                             MI_COLUMNDEF *start_recinfo,
337
 
                             MI_COLUMNDEF **recinfo, 
338
 
                             int error, bool ignore_last_dupp_key_error);
339
 
 
340
 
class Table {
341
 
 
342
 
public:
 
366
struct st_table {
 
367
  st_table() {}                               /* Remove gcc warning */
 
368
 
343
369
  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
370
  handler       *file;
387
 
  Table *next, *prev;
 
371
  struct st_table *next, *prev;
388
372
 
389
373
  THD   *in_use;                        /* Which thread uses this */
390
374
  Field **field;                        /* Pointer to fields */
391
375
 
392
 
  unsigned char *record[2];                     /* Pointer to records */
393
 
  unsigned char *write_row_record;              /* Used as optimisation in
 
376
  uchar *record[2];                     /* Pointer to records */
 
377
  uchar *write_row_record;              /* Used as optimisation in
394
378
                                           THD::write_row */
395
 
  unsigned char *insert_values;                  /* used by INSERT ... UPDATE */
 
379
  uchar *insert_values;                  /* used by INSERT ... UPDATE */
396
380
  /* 
397
381
    Map of keys that can be used to retrieve all data from this table 
398
382
    needed by the query without reading the row.
403
387
    A set of keys that can be used in the query that references this
404
388
    table.
405
389
 
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
 
390
    All indexes disabled on the table's TABLE_SHARE (see TABLE::s) will be 
 
391
    subtracted from this set upon instantiation. Thus for any TABLE t it holds
408
392
    that t.keys_in_use_for_query is a subset of t.s.keys_in_use. Generally we 
409
393
    must not introduce any new keys here (see setup_tables).
410
394
 
421
405
  Field *found_next_number_field;       /* Set on open */
422
406
  Field_timestamp *timestamp_field;
423
407
 
424
 
  TableList *pos_in_table_list;/* Element referring to this table */
425
 
  order_st *group;
 
408
  TABLE_LIST *pos_in_table_list;/* Element referring to this table */
 
409
  ORDER         *group;
426
410
  const char    *alias;                   /* alias or table name */
427
 
  unsigned char         *null_flags;
 
411
  uchar         *null_flags;
428
412
  my_bitmap_map *bitmap_init_value;
429
413
  MY_BITMAP     def_read_set, def_write_set, tmp_set; /* containers */
430
414
  MY_BITMAP     *read_set, *write_set;          /* Active column sets */
485
469
  timestamp_auto_set_type timestamp_field_type;
486
470
  table_map     map;                    /* ID bit of table (1,2,4,8,16...) */
487
471
 
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 */
 
472
  uint          lock_position;          /* Position in MYSQL_LOCK.table */
 
473
  uint          lock_data_start;        /* Start pos. in MYSQL_LOCK.locks */
 
474
  uint          lock_count;             /* Number of locks */
491
475
  uint          tablenr,used_fields;
492
 
  uint32_t          temp_pool_slot;             /* Used by intern temp tables */
 
476
  uint          temp_pool_slot;         /* Used by intern temp tables */
493
477
  uint          status;                 /* What's in record[0] */
 
478
  uint          db_stat;                /* mode of file as in handler.h */
494
479
  /* number of select if it is derived table */
495
 
  uint32_t          derived_select_number;
 
480
  uint          derived_select_number;
496
481
  int           current_lock;           /* Type of lock on table */
497
482
  bool copy_blobs;                      /* copy_blobs when storing */
498
483
 
501
486
    If maybe_null !=0, this table is inner w.r.t. some outer join operation,
502
487
    and null_row may be true.
503
488
  */
504
 
  bool maybe_null;
505
 
 
 
489
  uint maybe_null;
506
490
  /*
507
491
    If true, the current table row is considered to have all columns set to 
508
492
    NULL, including columns declared as "not null" (see maybe_null).
509
493
  */
510
494
  bool null_row;
511
495
 
 
496
  /*
 
497
    TODO: Each of the following flags take up 8 bits. They can just as easily
 
498
    be put into one single unsigned long and instead of taking up 18
 
499
    bytes, it would take up 4.
 
500
  */
512
501
  bool force_index;
513
502
  bool distinct,const_table,no_rows;
514
503
  bool key_read, no_keyread;
548
537
 
549
538
  REGINFO reginfo;                      /* field connections */
550
539
  MEM_ROOT mem_root;
551
 
  filesort_info_st sort;
 
540
  FILESORT_INFO sort;
552
541
 
553
542
  bool fill_item_list(List<Item> *item_list) const;
554
543
  void reset_item_list(List<Item> *item_list) const;
555
544
  void clear_column_bitmaps(void);
556
545
  void prepare_for_position(void);
557
 
  void mark_columns_used_by_index_no_reset(uint32_t index, MY_BITMAP *map);
558
 
  void mark_columns_used_by_index(uint32_t index);
 
546
  void mark_columns_used_by_index_no_reset(uint index, MY_BITMAP *map);
 
547
  void mark_columns_used_by_index(uint index);
559
548
  void restore_column_maps_after_mark_index();
560
549
  void mark_auto_increment_column(void);
561
550
  void mark_columns_needed_for_update(void);
575
564
    read_set= read_set_arg;
576
565
    write_set= write_set_arg;
577
566
  }
578
 
 
579
 
  void restore_column_map(my_bitmap_map *old);
580
 
 
581
 
  my_bitmap_map *use_all_columns(MY_BITMAP *bitmap);
582
567
  inline void use_all_columns()
583
568
  {
584
569
    column_bitmaps_set(&s->all_set, &s->all_set);
585
570
  }
586
 
 
587
571
  inline void default_column_bitmaps()
588
572
  {
589
573
    read_set= &def_read_set;
590
574
    write_set= &def_write_set;
591
575
  }
592
 
 
593
576
  /* Is table open or should be treated as such by name-locking? */
594
577
  inline bool is_name_opened() { return db_stat || open_placeholder; }
595
578
  /*
597
580
  */
598
581
  inline bool needs_reopen_or_name_lock()
599
582
  { return s->version != refresh_version; }
 
583
};
600
584
 
601
 
  int report_error(int error);
 
585
enum enum_schema_table_state
 
586
 
587
  NOT_PROCESSED= 0,
 
588
  PROCESSED_BY_CREATE_SORT_INDEX,
 
589
  PROCESSED_BY_JOIN_EXEC
602
590
};
603
591
 
604
592
typedef struct st_foreign_key_info
660
648
     For string-type columns, this is the maximum number of
661
649
     characters. Otherwise, it is the 'display-length' for the column.
662
650
  */
663
 
  uint32_t field_length;
 
651
  uint field_length;
664
652
  /**
665
653
     This denotes data type for the column. For the most part, there seems to
666
654
     be one entry in the enum for each SQL data type, although there seem to
676
664
     combine them using the bitwise or operator @c |. Both flags are
677
665
     defined in table.h.
678
666
   */
679
 
  uint32_t field_flags;        // Field atributes(maybe_null, signed, unsigned etc.)
 
667
  uint field_flags;        // Field atributes(maybe_null, signed, unsigned etc.)
680
668
  const char* old_name;
681
669
  /**
682
670
     This should be one of @c SKIP_OPEN_TABLE,
683
671
     @c OPEN_FRM_ONLY or @c OPEN_FULL_TABLE.
684
672
  */
685
 
  uint32_t open_method;
 
673
  uint open_method;
686
674
} ST_FIELD_INFO;
687
675
 
688
676
 
689
 
class TableList;
 
677
struct TABLE_LIST;
690
678
typedef class Item COND;
691
679
 
692
 
struct ST_SCHEMA_TABLE
 
680
typedef struct st_schema_table
693
681
{
694
682
  const char* table_name;
695
683
  ST_FIELD_INFO *fields_info;
696
684
  /* Create information_schema table */
697
 
  Table *(*create_table)  (THD *thd, TableList *table_list);
 
685
  TABLE *(*create_table)  (THD *thd, TABLE_LIST *table_list);
698
686
  /* Fill table with data */
699
 
  int (*fill_table) (THD *thd, TableList *tables, COND *cond);
 
687
  int (*fill_table) (THD *thd, TABLE_LIST *tables, COND *cond);
700
688
  /* 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,
 
689
  int (*old_format) (THD *thd, struct st_schema_table *schema_table);
 
690
  int (*process_table) (THD *thd, TABLE_LIST *tables, TABLE *table,
703
691
                        bool res, LEX_STRING *db_name, LEX_STRING *table_name);
704
692
  int idx_field1, idx_field2; 
705
693
  bool hidden;
706
 
  uint32_t i_s_requested_object;  /* the object we need to open(Table | VIEW) */
707
 
};
 
694
  uint i_s_requested_object;  /* the object we need to open(TABLE | VIEW) */
 
695
} ST_SCHEMA_TABLE;
708
696
 
709
697
 
710
698
#define JOIN_TYPE_LEFT  1
714
702
class select_union;
715
703
class TMP_TABLE_PARAM;
716
704
 
 
705
Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref,
 
706
                        const char *name);
 
707
 
717
708
struct Field_translator
718
709
{
719
710
  Item *item;
721
712
};
722
713
 
723
714
 
 
715
/*
 
716
  Column reference of a NATURAL/USING join. Since column references in
 
717
  joins can be both from views and stored tables, may point to either a
 
718
  Field (for tables), or a Field_translator (for views).
 
719
*/
 
720
 
 
721
class Natural_join_column: public Sql_alloc
 
722
{
 
723
public:
 
724
  Field_translator *view_field;  /* Column reference of merge view. */
 
725
  Field            *table_field; /* Column reference of table or temp view. */
 
726
  TABLE_LIST *table_ref; /* Original base table/view reference. */
 
727
  /*
 
728
    True if a common join column of two NATURAL/USING join operands. Notice
 
729
    that when we have a hierarchy of nested NATURAL/USING joins, a column can
 
730
    be common at some level of nesting but it may not be common at higher
 
731
    levels of nesting. Thus this flag may change depending on at which level
 
732
    we are looking at some column.
 
733
  */
 
734
  bool is_common;
 
735
public:
 
736
  Natural_join_column(Field_translator *field_param, TABLE_LIST *tab);
 
737
  Natural_join_column(Field *field_param, TABLE_LIST *tab);
 
738
  const char *name();
 
739
  Item *create_item(THD *thd);
 
740
  Field *field();
 
741
  const char *table_name();
 
742
  const char *db_name();
 
743
};
 
744
 
 
745
 
 
746
/*
 
747
  Table reference in the FROM clause.
 
748
 
 
749
  These table references can be of several types that correspond to
 
750
  different SQL elements. Below we list all types of TABLE_LISTs with
 
751
  the necessary conditions to determine when a TABLE_LIST instance
 
752
  belongs to a certain type.
 
753
 
 
754
  1) table (TABLE_LIST::view == NULL)
 
755
     - base table
 
756
       (TABLE_LIST::derived == NULL)
 
757
     - subquery - TABLE_LIST::table is a temp table
 
758
       (TABLE_LIST::derived != NULL)
 
759
     - information schema table
 
760
       (TABLE_LIST::schema_table != NULL)
 
761
       NOTICE: for schema tables TABLE_LIST::field_translation may be != NULL
 
762
  2) view (TABLE_LIST::view != NULL)
 
763
     - merge    (TABLE_LIST::effective_algorithm == VIEW_ALGORITHM_MERGE)
 
764
           also (TABLE_LIST::field_translation != NULL)
 
765
     - tmptable (TABLE_LIST::effective_algorithm == VIEW_ALGORITHM_TMPTABLE)
 
766
           also (TABLE_LIST::field_translation == NULL)
 
767
  3) nested table reference (TABLE_LIST::nested_join != NULL)
 
768
     - table sequence - e.g. (t1, t2, t3)
 
769
       TODO: how to distinguish from a JOIN?
 
770
     - general JOIN
 
771
       TODO: how to distinguish from a table sequence?
 
772
     - NATURAL JOIN
 
773
       (TABLE_LIST::natural_join != NULL)
 
774
       - JOIN ... USING
 
775
         (TABLE_LIST::join_using_fields != NULL)
 
776
     - semi-join
 
777
       ;
 
778
*/
 
779
 
 
780
class Index_hint;
 
781
struct TABLE_LIST
 
782
{
 
783
  TABLE_LIST() {}                          /* Remove gcc warning */
 
784
 
 
785
  /**
 
786
    Prepare TABLE_LIST that consists of one table instance to use in
 
787
    simple_open_and_lock_tables
 
788
  */
 
789
  inline void init_one_table(const char *db_name_arg,
 
790
                             const char *table_name_arg,
 
791
                             enum thr_lock_type lock_type_arg)
 
792
  {
 
793
    memset(this, 0, sizeof(*this));
 
794
    db= (char*) db_name_arg;
 
795
    table_name= alias= (char*) table_name_arg;
 
796
    lock_type= lock_type_arg;
 
797
  }
 
798
 
 
799
  /*
 
800
    List of tables local to a subquery (used by SQL_LIST). Considers
 
801
    views as leaves (unlike 'next_leaf' below). Created at parse time
 
802
    in st_select_lex::add_table_to_list() -> table_list.link_in_list().
 
803
  */
 
804
  TABLE_LIST *next_local;
 
805
  /* link in a global list of all queries tables */
 
806
  TABLE_LIST *next_global, **prev_global;
 
807
  char          *db, *alias, *table_name, *schema_table_name;
 
808
  char          *option;                /* Used by cache index  */
 
809
  Item          *on_expr;               /* Used with outer join */
 
810
  Item          *sj_on_expr;
 
811
  /*
 
812
    (Valid only for semi-join nests) Bitmap of tables that are within the
 
813
    semi-join (this is different from bitmap of all nest's children because
 
814
    tables that were pulled out of the semi-join nest remain listed as
 
815
    nest's children).
 
816
  */
 
817
  table_map     sj_inner_tables;
 
818
  /* Number of IN-compared expressions */
 
819
  uint          sj_in_exprs; 
 
820
  /*
 
821
    The structure of ON expression presented in the member above
 
822
    can be changed during certain optimizations. This member
 
823
    contains a snapshot of AND-OR structure of the ON expression
 
824
    made after permanent transformations of the parse tree, and is
 
825
    used to restore ON clause before every reexecution of a prepared
 
826
    statement or stored procedure.
 
827
  */
 
828
  Item          *prep_on_expr;
 
829
  COND_EQUAL    *cond_equal;            /* Used with outer join */
 
830
  /*
 
831
    During parsing - left operand of NATURAL/USING join where 'this' is
 
832
    the right operand. After parsing (this->natural_join == this) iff
 
833
    'this' represents a NATURAL or USING join operation. Thus after
 
834
    parsing 'this' is a NATURAL/USING join iff (natural_join != NULL).
 
835
  */
 
836
  TABLE_LIST *natural_join;
 
837
  /*
 
838
    True if 'this' represents a nested join that is a NATURAL JOIN.
 
839
    For one of the operands of 'this', the member 'natural_join' points
 
840
    to the other operand of 'this'.
 
841
  */
 
842
  bool is_natural_join;
 
843
  /* Field names in a USING clause for JOIN ... USING. */
 
844
  List<String> *join_using_fields;
 
845
  /*
 
846
    Explicitly store the result columns of either a NATURAL/USING join or
 
847
    an operand of such a join.
 
848
  */
 
849
  List<Natural_join_column> *join_columns;
 
850
  /* true if join_columns contains all columns of this table reference. */
 
851
  bool is_join_columns_complete;
 
852
 
 
853
  /*
 
854
    List of nodes in a nested join tree, that should be considered as
 
855
    leaves with respect to name resolution. The leaves are: views,
 
856
    top-most nodes representing NATURAL/USING joins, subqueries, and
 
857
    base tables. All of these TABLE_LIST instances contain a
 
858
    materialized list of columns. The list is local to a subquery.
 
859
  */
 
860
  TABLE_LIST *next_name_resolution_table;
 
861
  /* Index names in a "... JOIN ... USE/IGNORE INDEX ..." clause. */
 
862
  List<Index_hint> *index_hints;
 
863
  TABLE        *table;                          /* opened table */
 
864
  uint          table_id; /* table id (from binlog) for opened table */
 
865
  /*
 
866
    select_result for derived table to pass it from table creation to table
 
867
    filling procedure
 
868
  */
 
869
  select_union  *derived_result;
 
870
  /*
 
871
    Reference from aux_tables to local list entry of main select of
 
872
    multi-delete statement:
 
873
    delete t1 from t2,t1 where t1.a<'B' and t2.b=t1.b;
 
874
    here it will be reference of first occurrence of t1 to second (as you
 
875
    can see this lists can't be merged)
 
876
  */
 
877
  TABLE_LIST    *correspondent_table;
 
878
  st_select_lex_unit *derived;          /* SELECT_LEX_UNIT of derived table */
 
879
  ST_SCHEMA_TABLE *schema_table;        /* Information_schema table */
 
880
  st_select_lex *schema_select_lex;
 
881
  /*
 
882
    True when the view field translation table is used to convert
 
883
    schema table fields for backwards compatibility with SHOW command.
 
884
  */
 
885
  bool schema_table_reformed;
 
886
  TMP_TABLE_PARAM *schema_table_param;
 
887
  /* link to select_lex where this table was used */
 
888
  st_select_lex *select_lex;
 
889
  Field_translator *field_translation;  /* array of VIEW fields */
 
890
  /* pointer to element after last one in translation table above */
 
891
  Field_translator *field_translation_end;
 
892
  /*
 
893
    List (based on next_local) of underlying tables of this view. I.e. it
 
894
    does not include the tables of subqueries used in the view. Is set only
 
895
    for merged views.
 
896
  */
 
897
  TABLE_LIST    *merge_underlying_list;
 
898
  /*
 
899
    - 0 for base tables
 
900
    - in case of the view it is the list of all (not only underlying
 
901
    tables but also used in subquery ones) tables of the view.
 
902
  */
 
903
  List<TABLE_LIST> *view_tables;
 
904
  /* most upper view this table belongs to */
 
905
  TABLE_LIST    *belong_to_view;
 
906
  /* Ptr to parent MERGE table list item. See top comment in ha_myisammrg.cc */
 
907
  TABLE_LIST    *parent_l;
 
908
  /*
 
909
    List of all base tables local to a subquery including all view
 
910
    tables. Unlike 'next_local', this in this list views are *not*
 
911
    leaves. Created in setup_tables() -> make_leaves_list().
 
912
  */
 
913
  TABLE_LIST    *next_leaf;
 
914
  /* data need by some engines in query cache*/
 
915
  uint64_t     engine_data;
 
916
  /* call back function for asking handler about caching in query cache */
 
917
  qc_engine_callback callback_func;
 
918
  thr_lock_type lock_type;
 
919
  uint          outer_join;             /* Which join type */
 
920
  uint          shared;                 /* Used in multi-upd */
 
921
  size_t        db_length;
 
922
  size_t        table_name_length;
 
923
  bool          straight;               /* optimize with prev table */
 
924
  bool          updating;               /* for replicate-do/ignore table */
 
925
  bool          force_index;            /* prefer index over table scan */
 
926
  bool          ignore_leaves;          /* preload only non-leaf nodes */
 
927
  table_map     dep_tables;             /* tables the table depends on      */
 
928
  table_map     on_expr_dep_tables;     /* tables on expression depends on  */
 
929
  struct st_nested_join *nested_join;   /* if the element is a nested join  */
 
930
  TABLE_LIST *embedding;             /* nested join containing the table */
 
931
  List<TABLE_LIST> *join_list;/* join list the table belongs to   */
 
932
  bool          cacheable_table;        /* stop PS caching */
 
933
  /* FRMTYPE_ERROR if any type is acceptable */
 
934
  enum frm_type_enum required_type;
 
935
  handlerton    *db_type;               /* table_type for handler */
 
936
  char          timestamp_buffer[20];   /* buffer for timestamp (19+1) */
 
937
  /*
 
938
    This TABLE_LIST object corresponds to the table to be created
 
939
    so it is possible that it does not exist (used in CREATE TABLE
 
940
    ... SELECT implementation).
 
941
  */
 
942
  bool          create;
 
943
  /* For transactional locking. */
 
944
  int           lock_timeout;           /* NOWAIT or WAIT [X]               */
 
945
  bool          lock_transactional;     /* If transactional lock requested. */
 
946
  bool          internal_tmp_table;
 
947
  /** true if an alias for this table was specified in the SQL. */
 
948
  bool          is_alias;
 
949
  /** true if the table is referred to in the statement using a fully
 
950
      qualified name (<db_name>.<table_name>).
 
951
  */
 
952
  bool          is_fqtn;
 
953
 
 
954
  uint i_s_requested_object;
 
955
  bool has_db_lookup_value;
 
956
  bool has_table_lookup_value;
 
957
  uint table_open_method;
 
958
  enum enum_schema_table_state schema_table_state;
 
959
  void set_underlying_merge();
 
960
  bool setup_underlying(THD *thd);
 
961
  void cleanup_items();
 
962
  /*
 
963
    If you change placeholder(), please check the condition in
 
964
    check_transactional_lock() too.
 
965
  */
 
966
  bool placeholder()
 
967
  {
 
968
    return derived || schema_table || (create && !table->db_stat) || !table;
 
969
  }
 
970
  void print(THD *thd, String *str, enum_query_type query_type);
 
971
  bool set_insert_values(MEM_ROOT *mem_root);
 
972
  TABLE_LIST *find_underlying_table(TABLE *table);
 
973
  TABLE_LIST *first_leaf_for_name_resolution();
 
974
  TABLE_LIST *last_leaf_for_name_resolution();
 
975
  bool is_leaf_for_name_resolution();
 
976
  inline TABLE_LIST *top_table()
 
977
    { return belong_to_view ? belong_to_view : this; }
 
978
 
 
979
  /*
 
980
    Cleanup for re-execution in a prepared statement or a stored
 
981
    procedure.
 
982
  */
 
983
  void reinit_before_use(THD *thd);
 
984
  Item_subselect *containing_subselect();
 
985
 
 
986
  /* 
 
987
    Compiles the tagged hints list and fills up st_table::keys_in_use_for_query,
 
988
    st_table::keys_in_use_for_group_by, st_table::keys_in_use_for_order_by,
 
989
    st_table::force_index and st_table::covering_keys.
 
990
  */
 
991
  bool process_index_hints(TABLE *table);
 
992
 
 
993
private:
 
994
  bool prep_where(THD *thd, Item **conds, bool no_where_clause);
 
995
  /*
 
996
    Cleanup for re-execution in a prepared statement or a stored
 
997
    procedure.
 
998
  */
 
999
};
 
1000
 
 
1001
class Item;
 
1002
 
 
1003
/*
 
1004
  Iterator over the fields of a generic table reference.
 
1005
*/
 
1006
 
 
1007
class Field_iterator: public Sql_alloc
 
1008
{
 
1009
public:
 
1010
  Field_iterator() {}                         /* Remove gcc warning */
 
1011
  virtual ~Field_iterator() {}
 
1012
  virtual void set(TABLE_LIST *)= 0;
 
1013
  virtual void next()= 0;
 
1014
  virtual bool end_of_fields()= 0;              /* Return 1 at end of list */
 
1015
  virtual const char *name()= 0;
 
1016
  virtual Item *create_item(THD *)= 0;
 
1017
  virtual Field *field()= 0;
 
1018
};
 
1019
 
 
1020
 
 
1021
/* 
 
1022
  Iterator over the fields of a base table, view with temporary
 
1023
  table, or subquery.
 
1024
*/
 
1025
 
 
1026
class Field_iterator_table: public Field_iterator
 
1027
{
 
1028
  Field **ptr;
 
1029
public:
 
1030
  Field_iterator_table() :ptr(0) {}
 
1031
  void set(TABLE_LIST *table) { ptr= table->table->field; }
 
1032
  void set_table(TABLE *table) { ptr= table->field; }
 
1033
  void next() { ptr++; }
 
1034
  bool end_of_fields() { return *ptr == 0; }
 
1035
  const char *name();
 
1036
  Item *create_item(THD *thd);
 
1037
  Field *field() { return *ptr; }
 
1038
};
 
1039
 
 
1040
 
 
1041
/* Iterator over the fields of a merge view. */
 
1042
 
 
1043
class Field_iterator_view: public Field_iterator
 
1044
{
 
1045
  Field_translator *ptr, *array_end;
 
1046
  TABLE_LIST *view;
 
1047
public:
 
1048
  Field_iterator_view() :ptr(0), array_end(0) {}
 
1049
  void set(TABLE_LIST *table);
 
1050
  void next() { ptr++; }
 
1051
  bool end_of_fields() { return ptr == array_end; }
 
1052
  const char *name();
 
1053
  Item *create_item(THD *thd);
 
1054
  Item **item_ptr() {return &ptr->item; }
 
1055
  Field *field() { return 0; }
 
1056
  inline Item *item() { return ptr->item; }
 
1057
  Field_translator *field_translator() { return ptr; }
 
1058
};
 
1059
 
 
1060
 
 
1061
/*
 
1062
  Field_iterator interface to the list of materialized fields of a
 
1063
  NATURAL/USING join.
 
1064
*/
 
1065
 
 
1066
class Field_iterator_natural_join: public Field_iterator
 
1067
{
 
1068
  List_iterator_fast<Natural_join_column> column_ref_it;
 
1069
  Natural_join_column *cur_column_ref;
 
1070
public:
 
1071
  Field_iterator_natural_join() :cur_column_ref(NULL) {}
 
1072
  ~Field_iterator_natural_join() {}
 
1073
  void set(TABLE_LIST *table);
 
1074
  void next();
 
1075
  bool end_of_fields() { return !cur_column_ref; }
 
1076
  const char *name() { return cur_column_ref->name(); }
 
1077
  Item *create_item(THD *thd) { return cur_column_ref->create_item(thd); }
 
1078
  Field *field() { return cur_column_ref->field(); }
 
1079
  Natural_join_column *column_ref() { return cur_column_ref; }
 
1080
};
 
1081
 
 
1082
 
 
1083
/*
 
1084
  Generic iterator over the fields of an arbitrary table reference.
 
1085
 
 
1086
  DESCRIPTION
 
1087
    This class unifies the various ways of iterating over the columns
 
1088
    of a table reference depending on the type of SQL entity it
 
1089
    represents. If such an entity represents a nested table reference,
 
1090
    this iterator encapsulates the iteration over the columns of the
 
1091
    members of the table reference.
 
1092
 
 
1093
  IMPLEMENTATION
 
1094
    The implementation assumes that all underlying NATURAL/USING table
 
1095
    references already contain their result columns and are linked into
 
1096
    the list TABLE_LIST::next_name_resolution_table.
 
1097
*/
 
1098
 
 
1099
class Field_iterator_table_ref: public Field_iterator
 
1100
{
 
1101
  TABLE_LIST *table_ref, *first_leaf, *last_leaf;
 
1102
  Field_iterator_table        table_field_it;
 
1103
  Field_iterator_view         view_field_it;
 
1104
  Field_iterator_natural_join natural_join_it;
 
1105
  Field_iterator *field_it;
 
1106
  void set_field_iterator();
 
1107
public:
 
1108
  Field_iterator_table_ref() :field_it(NULL) {}
 
1109
  void set(TABLE_LIST *table);
 
1110
  void next();
 
1111
  bool end_of_fields()
 
1112
  { return (table_ref == last_leaf && field_it->end_of_fields()); }
 
1113
  const char *name() { return field_it->name(); }
 
1114
  const char *table_name();
 
1115
  const char *db_name();
 
1116
  Item *create_item(THD *thd) { return field_it->create_item(thd); }
 
1117
  Field *field() { return field_it->field(); }
 
1118
  Natural_join_column *get_or_create_column_ref(TABLE_LIST *parent_table_ref);
 
1119
  Natural_join_column *get_natural_column_ref();
 
1120
};
 
1121
 
 
1122
 
 
1123
typedef struct st_nested_join
 
1124
{
 
1125
  List<TABLE_LIST>  join_list;       /* list of elements in the nested join */
 
1126
  table_map         used_tables;     /* bitmap of tables in the nested join */
 
1127
  table_map         not_null_tables; /* tables that rejects nulls           */
 
1128
  struct st_join_table *first_nested;/* the first nested table in the plan  */
 
1129
  /* 
 
1130
    Used to count tables in the nested join in 2 isolated places:
 
1131
    1. In make_outerjoin_info(). 
 
1132
    2. check_interleaving_with_nj/restore_prev_nj_state (these are called
 
1133
       by the join optimizer. 
 
1134
    Before each use the counters are zeroed by reset_nj_counters.
 
1135
  */
 
1136
  uint              counter_;
 
1137
  nested_join_map   nj_map;          /* Bit used to identify this nested join*/
 
1138
  /*
 
1139
    (Valid only for semi-join nests) Bitmap of tables outside the semi-join
 
1140
    that are used within the semi-join's ON condition.
 
1141
  */
 
1142
  table_map         sj_depends_on;
 
1143
  /* Outer non-trivially correlated tables */
 
1144
  table_map         sj_corr_tables;
 
1145
  List<Item>        sj_outer_expr_list;
 
1146
} NESTED_JOIN;
 
1147
 
 
1148
 
724
1149
typedef struct st_changed_table_list
725
1150
{
726
1151
  struct        st_changed_table_list *next;
727
1152
  char          *key;
728
1153
  uint32_t        key_length;
729
 
} CHANGED_TableList;
730
 
 
731
 
 
732
 
typedef struct st_open_table_list
733
 
{
 
1154
} CHANGED_TABLE_LIST;
 
1155
 
 
1156
 
 
1157
typedef struct st_open_table_list{
734
1158
  struct st_open_table_list *next;
735
1159
  char  *db,*table;
736
1160
  uint32_t in_use,locked;
737
 
} OPEN_TableList;
738
 
 
739
 
 
740
 
#endif /* DRIZZLED_TABLE_H */
 
1161
} OPEN_TABLE_LIST;
 
1162
 
 
1163
typedef struct st_table_field_w_type
 
1164
{
 
1165
  LEX_STRING name;
 
1166
  LEX_STRING type;
 
1167
  LEX_STRING cset;
 
1168
} TABLE_FIELD_W_TYPE;
 
1169
 
 
1170
 
 
1171
bool
 
1172
table_check_intact(TABLE *table, const uint table_f_count,
 
1173
                   const TABLE_FIELD_W_TYPE *table_def);
 
1174
 
 
1175
static inline my_bitmap_map *tmp_use_all_columns(TABLE *table,
 
1176
                                                 MY_BITMAP *bitmap)
 
1177
{
 
1178
  my_bitmap_map *old= bitmap->bitmap;
 
1179
  bitmap->bitmap= table->s->all_set.bitmap;
 
1180
  return old;
 
1181
}
 
1182
 
 
1183
 
 
1184
static inline void tmp_restore_column_map(MY_BITMAP *bitmap,
 
1185
                                          my_bitmap_map *old)
 
1186
{
 
1187
  bitmap->bitmap= old;
 
1188
}
 
1189
 
 
1190
/* The following is only needed for debugging */
 
1191
 
 
1192
static inline my_bitmap_map *dbug_tmp_use_all_columns(TABLE *table __attribute__((unused)),
 
1193
                                                      MY_BITMAP *bitmap __attribute__((unused)))
 
1194
{
 
1195
  return 0;
 
1196
}
 
1197
 
 
1198
static inline void dbug_tmp_restore_column_map(MY_BITMAP *bitmap __attribute__((unused)),
 
1199
                                               my_bitmap_map *old __attribute__((unused)))
 
1200
{
 
1201
  return;
 
1202
}
 
1203
 
 
1204
size_t max_row_length(TABLE *table, const uchar *data);
 
1205