~drizzle-trunk/drizzle/development

390.1.2 by Monty Taylor
Fixed copyright headers in drizzled/
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
 */
1 by brian
clean slate
20
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
21
/* Structs that defines the Table */
1 by brian
clean slate
22
327.1.2 by Brian Aker
Commiting next pass of Table class cleanup.
23
#ifndef DRIZZLED_TABLE_H
24
#define DRIZZLED_TABLE_H
25
992.1.25 by Monty Taylor
Moved myisam to new plugin system.
26
#include <plugin/myisam/myisam.h>
520.8.6 by Monty Taylor
Removed handler from common_includes.
27
#include <mysys/hash.h>
1055.2.2 by Jay Pipes
Cleanup of style, indentation, and documentation of Table class members. Removed 5 or 6 dead Table member variables.
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/handler.h"
33
#include "drizzled/lex_string.h"
34
#include "drizzled/table_list.h"
35
#include "drizzled/table_share.h"
327.1.2 by Brian Aker
Commiting next pass of Table class cleanup.
36
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
37
class Item;
1 by brian
clean slate
38
class Item_subselect;
848 by Brian Aker
typdef class removal (just... use the name of the class).
39
class Select_Lex_Unit;
846 by Brian Aker
Removing on typedeffed class.
40
class Select_Lex;
1 by brian
clean slate
41
class COND_EQUAL;
42
class Security_context;
327.2.4 by Brian Aker
Refactoring table.h
43
class TableList;
1 by brian
clean slate
44
class Field_timestamp;
45
class Field_blob;
46
47
typedef enum enum_table_category TABLE_CATEGORY;
48
49
TABLE_CATEGORY get_table_category(const LEX_STRING *db,
50
                                  const LEX_STRING *name);
51
520.1.22 by Brian Aker
Second pass of thd cleanup
52
bool create_myisam_from_heap(Session *session, Table *table,
327.1.2 by Brian Aker
Commiting next pass of Table class cleanup.
53
                             MI_COLUMNDEF *start_recinfo,
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
54
                             MI_COLUMNDEF **recinfo,
327.1.2 by Brian Aker
Commiting next pass of Table class cleanup.
55
                             int error, bool ignore_last_dupp_key_error);
56
1055.2.2 by Jay Pipes
Cleanup of style, indentation, and documentation of Table class members. Removed 5 or 6 dead Table member variables.
57
/**
58
 * Class representing a set of records, either in a temporary, 
59
 * normal, or derived table.
60
 */
61
class Table 
62
{
327.1.1 by Brian Aker
First pass in encapsulating table (it is now an object, no longer a structure).
63
public:
1030.1.1 by Brian Aker
Straighten out structures (remove some some dead bits).
64
1055.2.2 by Jay Pipes
Cleanup of style, indentation, and documentation of Table class members. Removed 5 or 6 dead Table member variables.
65
  TableShare *s; /**< Pointer to the shared metadata about the table */
66
  Field **field; /**< Pointer to fields collection */
1030.1.1 by Brian Aker
Straighten out structures (remove some some dead bits).
67
1055.2.2 by Jay Pipes
Cleanup of style, indentation, and documentation of Table class members. Removed 5 or 6 dead Table member variables.
68
  handler *file; /**< Pointer to the storage engine's handler managing this table */
1030.1.1 by Brian Aker
Straighten out structures (remove some some dead bits).
69
  Table *next;
70
  Table *prev;
71
1055.2.2 by Jay Pipes
Cleanup of style, indentation, and documentation of Table class members. Removed 5 or 6 dead Table member variables.
72
  MY_BITMAP *read_set; /* Active column sets */
73
  MY_BITMAP *write_set; /* Active column sets */
74
75
  uint32_t tablenr;
76
  uint32_t db_stat; /**< information about the file as in handler.h */
77
78
  MY_BITMAP def_read_set; /**< Default read set of columns */
79
  MY_BITMAP def_write_set; /**< Default write set of columns */
80
  MY_BITMAP tmp_set; /* Not sure about this... */
81
82
  Session	*in_use; /**< Pointer to the current session using this object */
83
84
  unsigned char *record[2]; /**< Pointer to "records" */
85
  unsigned char *insert_values; /* used by INSERT ... UPDATE */
86
  KEY  *key_info; /**< data of keys in database */
87
  Field *next_number_field; /**< Set if next_number is activated. @TODO What the heck is the difference between this and the next member? */
88
  Field *found_next_number_field; /**< Points to the "next-number" field (autoincrement field) */
89
  Field_timestamp *timestamp_field; /**< Points to the auto-setting timestamp field, if any */
90
91
  TableList *pos_in_table_list; /* Element referring to this table */
327.2.3 by Brian Aker
Refactoring of class Table
92
  order_st *group;
1055.2.2 by Jay Pipes
Cleanup of style, indentation, and documentation of Table class members. Removed 5 or 6 dead Table member variables.
93
  const char *alias; /**< alias or table name if no alias */
94
  unsigned char *null_flags;
1 by brian
clean slate
95
1055.2.2 by Jay Pipes
Cleanup of style, indentation, and documentation of Table class members. Removed 5 or 6 dead Table member variables.
96
  uint32_t lock_position; /**< Position in DRIZZLE_LOCK.table */
97
  uint32_t lock_data_start; /**< Start pos. in DRIZZLE_LOCK.locks */
98
  uint32_t lock_count; /**< Number of locks */
1030.1.2 by Brian Aker
More alignment for structures
99
  uint32_t used_fields;
1055.2.2 by Jay Pipes
Cleanup of style, indentation, and documentation of Table class members. Removed 5 or 6 dead Table member variables.
100
  uint32_t status; /* What's in record[0] */
1 by brian
clean slate
101
  /* number of select if it is derived table */
1055.2.2 by Jay Pipes
Cleanup of style, indentation, and documentation of Table class members. Removed 5 or 6 dead Table member variables.
102
  uint32_t derived_select_number;
103
  int	current_lock; /**< Type of lock on table */
104
  bool copy_blobs; /**< Should blobs by copied when storing? */
1 by brian
clean slate
105
106
  /*
107
    0 or JOIN_TYPE_{LEFT|RIGHT}. Currently this is only compared to 0.
108
    If maybe_null !=0, this table is inner w.r.t. some outer join operation,
109
    and null_row may be true.
110
  */
327.1.3 by Brian Aker
Cleaned up depend in Proto utils. Modified int to bool. Put TmpTable class
111
  bool maybe_null;
112
1 by brian
clean slate
113
  /*
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
114
    If true, the current table row is considered to have all columns set to
1 by brian
clean slate
115
    NULL, including columns declared as "not null" (see maybe_null).
116
  */
274 by Brian Aker
my_bool conversion in Table
117
  bool null_row;
1 by brian
clean slate
118
274 by Brian Aker
my_bool conversion in Table
119
  bool force_index;
120
  bool distinct,const_table,no_rows;
1030.1.2 by Brian Aker
More alignment for structures
121
  bool key_read;
122
  bool no_keyread;
1 by brian
clean slate
123
  /*
124
    Placeholder for an open table which prevents other connections
125
    from taking name-locks on this table. Typically used with
1000.1.3 by Brian Aker
Renamed TABLE_SHARE to TableShare
126
    TableShare::version member to take an exclusive name-lock on
1 by brian
clean slate
127
    this table name -- a name lock that not only prevents other
128
    threads from opening the table, but also blocks other name
129
    locks. This is achieved by:
130
    - setting open_placeholder to 1 - this will block other name
131
      locks, as wait_for_locked_table_name will be forced to wait,
132
      see table_is_used for details.
133
    - setting version to 0 - this will force other threads to close
134
      the instance of this table and wait (this is the same approach
135
      as used for usual name locks).
136
    An exclusively name-locked table currently can have no handler
137
    object associated with it (db_stat is always 0), but please do
138
    not rely on that.
139
  */
274 by Brian Aker
my_bool conversion in Table
140
  bool open_placeholder;
141
  bool locked_by_name;
142
  bool no_cache;
1 by brian
clean slate
143
  /*
144
    To indicate that a non-null value of the auto_increment field
145
    was provided by the user or retrieved from the current record.
146
    Used only in the MODE_NO_AUTO_VALUE_ON_ZERO mode.
147
  */
274 by Brian Aker
my_bool conversion in Table
148
  bool auto_increment_field_not_null;
1055.2.2 by Jay Pipes
Cleanup of style, indentation, and documentation of Table class members. Removed 5 or 6 dead Table member variables.
149
  bool alias_name_used; /* true if table_name is alias */
1030.1.2 by Brian Aker
More alignment for structures
150
151
  /*
152
   The ID of the query that opened and is using this table. Has different
153
   meanings depending on the table type.
154
155
   Temporary tables:
156
157
   table->query_id is set to session->query_id for the duration of a statement
158
   and is reset to 0 once it is closed by the same statement. A non-zero
159
   table->query_id means that a statement is using the table even if it's
160
   not the current statement (table is in use by some outer statement).
161
162
   Non-temporary tables:
163
164
   Under pre-locked or LOCK TABLES mode: query_id is set to session->query_id
165
   for the duration of a statement and is reset to 0 once it is closed by
166
   the same statement. A non-zero query_id is used to control which tables
167
   in the list of pre-opened and locked tables are actually being used.
168
  */
169
  query_id_t	query_id;
170
171
  /*
172
    Estimate of number of records that satisfy SARGable part of the table
173
    condition, or table->file->records if no SARGable condition could be
174
    constructed.
175
    This value is used by join optimizer as an estimate of number of records
176
    that will pass the table condition (condition that depends on fields of
177
    this table and constants)
178
  */
1055.2.2 by Jay Pipes
Cleanup of style, indentation, and documentation of Table class members. Removed 5 or 6 dead Table member variables.
179
  ha_rows quick_condition_rows;
1030.1.2 by Brian Aker
More alignment for structures
180
181
  /*
182
    If this table has TIMESTAMP field with auto-set property (pointed by
183
    timestamp_field member) then this variable indicates during which
184
    operations (insert only/on update/in both cases) we should set this
185
    field to current timestamp. If there are no such field in this table
186
    or we should not automatically set its value during execution of current
187
    statement then the variable contains TIMESTAMP_NO_AUTO_SET (i.e. 0).
188
189
    Value of this variable is set for each statement in open_table() and
190
    if needed cleared later in statement processing code (see mysql_update()
191
    as example).
192
  */
193
  timestamp_auto_set_type timestamp_field_type;
1055.2.2 by Jay Pipes
Cleanup of style, indentation, and documentation of Table class members. Removed 5 or 6 dead Table member variables.
194
  table_map	map; /* ID bit of table (1,2,4,8,16...) */
1 by brian
clean slate
195
1055.2.2 by Jay Pipes
Cleanup of style, indentation, and documentation of Table class members. Removed 5 or 6 dead Table member variables.
196
  RegInfo reginfo; /* field connections */
1030.1.2 by Brian Aker
More alignment for structures
197
198
  /*
199
    Map of keys that can be used to retrieve all data from this table
200
    needed by the query without reading the row.
201
  */
202
  key_map covering_keys;
203
  key_map quick_keys;
204
  key_map merge_keys;
205
206
  /*
207
    A set of keys that can be used in the query that references this
208
    table.
209
210
    All indexes disabled on the table's TableShare (see Table::s) will be
211
    subtracted from this set upon instantiation. Thus for any Table t it holds
212
    that t.keys_in_use_for_query is a subset of t.s.keys_in_use. Generally we
213
    must not introduce any new keys here (see setup_tables).
214
215
    The set is implemented as a bitmap.
216
  */
217
  key_map keys_in_use_for_query;
218
  /* Map of keys that can be used to calculate GROUP BY without sorting */
219
  key_map keys_in_use_for_group_by;
220
  /* Map of keys that can be used to calculate ORDER BY without sorting */
221
  key_map keys_in_use_for_order_by;
222
223
  /*
224
    For each key that has quick_keys.test(key) == true: estimate of #records
225
    and max #key parts that range access would use.
226
  */
227
  ha_rows	quick_rows[MAX_KEY];
228
229
  /* Bitmaps of key parts that =const for the entire join. */
230
  key_part_map  const_key_parts[MAX_KEY];
231
1055.2.2 by Jay Pipes
Cleanup of style, indentation, and documentation of Table class members. Removed 5 or 6 dead Table member variables.
232
  uint32_t quick_key_parts[MAX_KEY];
233
  uint32_t quick_n_ranges[MAX_KEY];
1030.1.2 by Brian Aker
More alignment for structures
234
1 by brian
clean slate
235
  MEM_ROOT mem_root;
327.2.3 by Brian Aker
Refactoring of class Table
236
  filesort_info_st sort;
1 by brian
clean slate
237
1055.2.2 by Jay Pipes
Cleanup of style, indentation, and documentation of Table class members. Removed 5 or 6 dead Table member variables.
238
  Table() : 
239
    s(NULL), 
240
    field(NULL),
241
    file(NULL),
242
    next(NULL),
243
    prev(NULL),
244
    read_set(NULL),
245
    write_set(NULL),
246
    tablenr(0),
247
    db_stat(0),
248
    in_use(NULL),
249
    insert_values(NULL),
250
    key_info(NULL),
251
    next_number_field(NULL),
252
    found_next_number_field(NULL),
253
    timestamp_field(NULL),
254
    pos_in_table_list(NULL),
255
    group(NULL),
256
    alias(NULL),
257
    null_flags(NULL),
258
    lock_position(0),
259
    lock_data_start(0),
260
    lock_count(0),
261
    used_fields(0),
262
    status(0),
263
    derived_select_number(0),
264
    current_lock(F_UNLCK),
265
    copy_blobs(false),
266
    maybe_null(false),
267
    null_row(false),
268
    force_index(false),
269
    distinct(false),
270
    const_table(false),
271
    no_rows(false),
272
    key_read(false),
273
    no_keyread(false),
274
    open_placeholder(false),
275
    locked_by_name(false),
276
    no_cache(false),
277
    auto_increment_field_not_null(false),
278
    alias_name_used(false),
279
    query_id(0), 
280
    quick_condition_rows(0),
281
    timestamp_field_type(TIMESTAMP_NO_AUTO_SET),
282
    map(0)
1039.1.10 by Brian Aker
Minor formating, change of one name to make grep easier :)
283
  {
1055.2.2 by Jay Pipes
Cleanup of style, indentation, and documentation of Table class members. Removed 5 or 6 dead Table member variables.
284
    record[0]= (unsigned char *) 0;
285
    record[1]= (unsigned char *) 0;
1014.2.9 by Monty Taylor
Merged trunk.
286
287
    covering_keys.reset();
288
289
    quick_keys.reset();
290
    merge_keys.reset();
291
292
    keys_in_use_for_query.reset();
293
    keys_in_use_for_group_by.reset();
294
    keys_in_use_for_order_by.reset();
295
1014.2.8 by Monty Taylor
Less fail.
296
    memset(quick_rows, 0, sizeof(query_id_t) * MAX_KEY);
297
    memset(const_key_parts, 0, sizeof(ha_rows) * MAX_KEY);
1014.2.9 by Monty Taylor
Merged trunk.
298
1014.2.8 by Monty Taylor
Less fail.
299
    memset(quick_key_parts, 0, sizeof(unsigned int) * MAX_KEY);
300
    memset(quick_n_ranges, 0, sizeof(unsigned int) * MAX_KEY);
1014.2.9 by Monty Taylor
Merged trunk.
301
302
    init_sql_alloc(&mem_root, TABLE_ALLOC_BLOCK_SIZE, 0);
1014.2.8 by Monty Taylor
Less fail.
303
    memset(&sort, 0, sizeof(filesort_info_st));
304
  }
327.1.1 by Brian Aker
First pass in encapsulating table (it is now an object, no longer a structure).
305
1055.2.2 by Jay Pipes
Cleanup of style, indentation, and documentation of Table class members. Removed 5 or 6 dead Table member variables.
306
  int report_error(int error);
307
  int closefrm(bool free_share);
308
1039.1.10 by Brian Aker
Minor formating, change of one name to make grep easier :)
309
  void resetTable(Session *session, TableShare *share, uint32_t db_stat_arg)
1014.2.7 by Monty Taylor
First malloc(Table) stab (doesn't work)
310
  {
1014.2.9 by Monty Taylor
Merged trunk.
311
    s= share;
312
    field= NULL;
313
1014.2.8 by Monty Taylor
Less fail.
314
    file= NULL;
315
    next= NULL;
316
    prev= NULL;
1014.2.9 by Monty Taylor
Merged trunk.
317
318
    read_set= NULL;
319
    write_set= NULL;
320
321
    tablenr= 0;
322
    db_stat= db_stat_arg;
323
324
    in_use= session;
1055.2.3 by Jay Pipes
Removed dead Table::table_check_intact() method.
325
    record[0]= (unsigned char *) 0;
326
    record[1]= (unsigned char *) 0;
1014.2.9 by Monty Taylor
Merged trunk.
327
1014.2.8 by Monty Taylor
Less fail.
328
    insert_values= NULL;
329
    key_info= NULL;
330
    next_number_field= NULL;
331
    found_next_number_field= NULL;
332
    timestamp_field= NULL;
1014.2.9 by Monty Taylor
Merged trunk.
333
1014.2.8 by Monty Taylor
Less fail.
334
    pos_in_table_list= NULL;
335
    group= NULL;
336
    alias= NULL;
337
    null_flags= NULL;
338
     
339
    lock_position= 0;
340
    lock_data_start= 0;
341
    lock_count= 0;
342
    used_fields= 0;
343
    status= 0;
344
    derived_select_number= 0;
345
    current_lock= F_UNLCK;
346
    copy_blobs= false;
1014.2.9 by Monty Taylor
Merged trunk.
347
1014.2.8 by Monty Taylor
Less fail.
348
    maybe_null= false;
1014.2.9 by Monty Taylor
Merged trunk.
349
1014.2.8 by Monty Taylor
Less fail.
350
    null_row= false;
1014.2.9 by Monty Taylor
Merged trunk.
351
1014.2.8 by Monty Taylor
Less fail.
352
    force_index= false;
353
    distinct= false;
354
    const_table= false;
355
    no_rows= false;
356
    key_read= false;
357
    no_keyread= false;
1014.2.9 by Monty Taylor
Merged trunk.
358
1014.2.8 by Monty Taylor
Less fail.
359
    open_placeholder= false;
360
    locked_by_name= false;
361
    no_cache= false;
1014.2.9 by Monty Taylor
Merged trunk.
362
1014.2.8 by Monty Taylor
Less fail.
363
    auto_increment_field_not_null= false;
364
    alias_name_used= false;
365
    
1014.2.9 by Monty Taylor
Merged trunk.
366
    query_id= 0;
367
    quick_condition_rows= 0;
368
     
369
    timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
370
    map= 0;
371
1014.2.10 by Monty Taylor
Made REGINFO into RegInfo and responsible for initializing itself.
372
    reginfo.reset();
1014.2.8 by Monty Taylor
Less fail.
373
1014.2.9 by Monty Taylor
Merged trunk.
374
    covering_keys.reset();
1014.2.8 by Monty Taylor
Less fail.
375
1014.2.7 by Monty Taylor
First malloc(Table) stab (doesn't work)
376
    quick_keys.reset();
1014.2.9 by Monty Taylor
Merged trunk.
377
    merge_keys.reset();
378
1014.2.7 by Monty Taylor
First malloc(Table) stab (doesn't work)
379
    keys_in_use_for_query.reset();
1014.2.9 by Monty Taylor
Merged trunk.
380
    keys_in_use_for_group_by.reset();
381
    keys_in_use_for_order_by.reset();
1014.2.7 by Monty Taylor
First malloc(Table) stab (doesn't work)
382
1014.2.8 by Monty Taylor
Less fail.
383
    memset(quick_rows, 0, sizeof(query_id_t) * MAX_KEY);
384
    memset(const_key_parts, 0, sizeof(ha_rows) * MAX_KEY);
1014.2.9 by Monty Taylor
Merged trunk.
385
1014.2.8 by Monty Taylor
Less fail.
386
    memset(quick_key_parts, 0, sizeof(unsigned int) * MAX_KEY);
387
    memset(quick_n_ranges, 0, sizeof(unsigned int) * MAX_KEY);
1014.2.9 by Monty Taylor
Merged trunk.
388
389
    init_sql_alloc(&mem_root, TABLE_ALLOC_BLOCK_SIZE, 0);
1014.2.8 by Monty Taylor
Less fail.
390
    memset(&sort, 0, sizeof(filesort_info_st));
1014.2.7 by Monty Taylor
First malloc(Table) stab (doesn't work)
391
  }
1030.1.2 by Brian Aker
More alignment for structures
392
1030.1.1 by Brian Aker
Straighten out structures (remove some some dead bits).
393
  /* SHARE methods */
394
  inline TableShare *getShare() { return s; } /* Get rid of this long term */
395
  inline void setShare(TableShare *new_share) { s= new_share; } /* Get rid of this long term */
396
  inline uint32_t sizeKeys() { return s->keys; }
397
  inline uint32_t sizeFields() { return s->fields; }
398
  inline uint32_t getRecordLength() { return s->reclength; }
399
  inline uint32_t sizeBlobFields() { return s->blob_fields; }
400
  inline uint32_t *getBlobField() { return s->blob_field; }
401
  inline uint32_t getNullBytes() { return s->null_bytes; }
402
  inline uint32_t getNullFields() { return s->null_fields; }
403
  inline unsigned char *getDefaultValues() { return s->default_values; }
404
1055.2.2 by Jay Pipes
Cleanup of style, indentation, and documentation of Table class members. Removed 5 or 6 dead Table member variables.
405
  inline bool isDatabaseLowByteFirst() { return s->db_low_byte_first; } /* Portable row format */
1030.1.1 by Brian Aker
Straighten out structures (remove some some dead bits).
406
  inline bool isCrashed() { return s->crashed; }
407
  inline bool isNameLock() { return s->name_lock; }
408
  inline bool isReplaceWithNameLock() { return s->replace_with_name_lock; }
1055.2.2 by Jay Pipes
Cleanup of style, indentation, and documentation of Table class members. Removed 5 or 6 dead Table member variables.
409
  inline bool isWaitingOnCondition() { return s->waiting_on_cond; } /* Protection against free */
1030.1.1 by Brian Aker
Straighten out structures (remove some some dead bits).
410
411
  /* For TMP tables, should be pulled out as a class */
412
  void updateCreateInfo(HA_CREATE_INFO *create_info);
413
  void setup_tmp_table_column_bitmaps(unsigned char *bitmaps);
414
  bool create_myisam_tmp_table(KEY *keyinfo,
415
                               MI_COLUMNDEF *start_recinfo,
416
                               MI_COLUMNDEF **recinfo,
417
                               uint64_t options);
418
  void free_tmp_table(Session *session);
419
  bool open_tmp_table();
420
  size_t max_row_length(const unsigned char *data);
421
  uint32_t find_shortest_key(const key_map *usable_keys);
422
  bool compare_record(Field **ptr);
423
  bool compare_record();
424
  /* TODO: the (re)storeRecord's may be able to be further condensed */
425
  void storeRecord();
426
  void storeRecordAsInsert();
427
  void storeRecordAsDefault();
428
  void restoreRecord();
429
  void restoreRecordAsDefault();
430
  void emptyRecord();
431
432
  /* See if this can be blown away */
433
  inline uint32_t getDBStat () { return db_stat; }
434
  inline uint32_t setDBStat () { return db_stat; }
1 by brian
clean slate
435
  bool fill_item_list(List<Item> *item_list) const;
436
  void clear_column_bitmaps(void);
437
  void prepare_for_position(void);
1005.2.3 by Monty Taylor
Further reversion of P.
438
  void mark_columns_used_by_index_no_reset(uint32_t index, MY_BITMAP *map);
1003.1.7 by Brian Aker
Add mark_columns_used_by_index_no_reset() with just index (assumes read_set
439
  void mark_columns_used_by_index_no_reset(uint32_t index);
482 by Brian Aker
Remove uint.
440
  void mark_columns_used_by_index(uint32_t index);
1 by brian
clean slate
441
  void restore_column_maps_after_mark_index();
442
  void mark_auto_increment_column(void);
443
  void mark_columns_needed_for_update(void);
444
  void mark_columns_needed_for_delete(void);
445
  void mark_columns_needed_for_insert(void);
1005.2.3 by Monty Taylor
Further reversion of P.
446
  inline void column_bitmaps_set(MY_BITMAP *read_set_arg,
447
                                 MY_BITMAP *write_set_arg)
1 by brian
clean slate
448
  {
449
    read_set= read_set_arg;
450
    write_set= write_set_arg;
451
  }
1055.2.24 by Jay Pipes
Merge with trunk and resolve conflicts.
452
  /**
453
   * Find field in table, no side effects, only purpose is to check for field
454
   * in table object and get reference to the field if found.
455
   *
456
   * @param Name of field searched for
457
   *
458
   * @retval
459
   *  0 field is not found
460
   * @retval
461
   *  non-0 pointer to field
462
   */
463
  Field *find_field_in_table_sef(const char *name);
354 by Brian Aker
Refactor of Table methods.
464
1005.2.3 by Monty Taylor
Further reversion of P.
465
  void restore_column_map(my_bitmap_map *old);
354 by Brian Aker
Refactor of Table methods.
466
1005.2.3 by Monty Taylor
Further reversion of P.
467
  my_bitmap_map *use_all_columns(MY_BITMAP *bitmap);
1 by brian
clean slate
468
  inline void use_all_columns()
469
  {
470
    column_bitmaps_set(&s->all_set, &s->all_set);
471
  }
354 by Brian Aker
Refactor of Table methods.
472
1 by brian
clean slate
473
  inline void default_column_bitmaps()
474
  {
475
    read_set= &def_read_set;
476
    write_set= &def_write_set;
477
  }
354 by Brian Aker
Refactor of Table methods.
478
1003.1.12 by Brian Aker
Begin of abstract out the bitmap from direct reference.
479
  /* Both of the below should go away once we can move this bit to the field objects */
480
  inline bool isReadSet(uint32_t index)
481
  {
1005.2.5 by Monty Taylor
Merged with trunk.
482
    return bitmap_is_set(read_set, index);
1003.1.12 by Brian Aker
Begin of abstract out the bitmap from direct reference.
483
  }
484
485
  inline void setReadSet(uint32_t index)
486
  {
1005.2.5 by Monty Taylor
Merged with trunk.
487
    bitmap_set_bit(read_set, index);
1003.1.12 by Brian Aker
Begin of abstract out the bitmap from direct reference.
488
  }
489
1005.2.12 by Monty Taylor
Moved some things to the API.
490
  inline void setReadSet()
491
  {
492
    bitmap_set_all(read_set);
493
  }
494
1003.1.12 by Brian Aker
Begin of abstract out the bitmap from direct reference.
495
  inline bool isWriteSet(uint32_t index)
496
  {
1005.2.5 by Monty Taylor
Merged with trunk.
497
    return bitmap_is_set(write_set, index);
1003.1.12 by Brian Aker
Begin of abstract out the bitmap from direct reference.
498
  }
499
500
  inline void setWriteSet(uint32_t index)
501
  {
1005.2.5 by Monty Taylor
Merged with trunk.
502
    bitmap_set_bit(write_set, index);
1003.1.12 by Brian Aker
Begin of abstract out the bitmap from direct reference.
503
  }
504
1005.2.12 by Monty Taylor
Moved some things to the API.
505
  inline void setWriteSet()
506
  {
507
    bitmap_set_all(write_set);
508
  }
509
1 by brian
clean slate
510
  /* Is table open or should be treated as such by name-locking? */
1055.2.2 by Jay Pipes
Cleanup of style, indentation, and documentation of Table class members. Removed 5 or 6 dead Table member variables.
511
  inline bool is_name_opened()
512
  {
513
    return db_stat || open_placeholder;
514
  }
1 by brian
clean slate
515
  /*
516
    Is this instance of the table should be reopen or represents a name-lock?
517
  */
518
  inline bool needs_reopen_or_name_lock()
1055.2.2 by Jay Pipes
Cleanup of style, indentation, and documentation of Table class members. Removed 5 or 6 dead Table member variables.
519
  { 
520
    return s->version != refresh_version;
521
  }
354 by Brian Aker
Refactor of Table methods.
522
934.1.1 by Brian Aker
Moved two functions in classes.
523
  /**
524
    clean/setup table fields and map.
525
526
    @param table        Table structure pointer (which should be setup)
527
    @param table_list   TableList structure pointer (owner of Table)
528
    @param tablenr     table number
529
  */
530
  void setup_table_map(TableList *table_list, uint32_t tablenr);
531
  inline void mark_as_null_row()
532
  {
1055.2.3 by Jay Pipes
Removed dead Table::table_check_intact() method.
533
    null_row= 1;
534
    status|= STATUS_NULL_ROW;
934.1.1 by Brian Aker
Moved two functions in classes.
535
    memset(null_flags, 255, s->null_bytes);
536
  }
1 by brian
clean slate
537
};
538
1052.2.7 by Nathan Williams
Merged trunk and resolved conflicts.
539
Table *create_virtual_tmp_table(Session *session, List<CreateField> &field_list);
575.4.7 by Monty Taylor
More header cleanup.
540
1 by brian
clean slate
541
typedef struct st_foreign_key_info
542
{
543
  LEX_STRING *forein_id;
544
  LEX_STRING *referenced_db;
545
  LEX_STRING *referenced_table;
546
  LEX_STRING *update_method;
547
  LEX_STRING *delete_method;
548
  LEX_STRING *referenced_key_name;
549
  List<LEX_STRING> foreign_fields;
550
  List<LEX_STRING> referenced_fields;
551
} FOREIGN_KEY_INFO;
552
553
typedef struct st_field_info
554
{
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
555
  /**
556
      This is used as column name.
1 by brian
clean slate
557
  */
558
  const char* field_name;
559
  /**
560
     For string-type columns, this is the maximum number of
561
     characters. Otherwise, it is the 'display-length' for the column.
562
  */
482 by Brian Aker
Remove uint.
563
  uint32_t field_length;
1 by brian
clean slate
564
  /**
565
     This denotes data type for the column. For the most part, there seems to
566
     be one entry in the enum for each SQL data type, although there seem to
567
     be a number of additional entries in the enum.
568
  */
569
  enum enum_field_types field_type;
570
  int value;
571
  /**
572
     This is used to set column attributes. By default, columns are @c NOT
573
     @c NULL and @c SIGNED, and you can deviate from the default
574
     by setting the appopriate flags. You can use either one of the flags
575
     @c MY_I_S_MAYBE_NULL and @cMY_I_S_UNSIGNED or
576
     combine them using the bitwise or operator @c |. Both flags are
577
     defined in table.h.
578
   */
482 by Brian Aker
Remove uint.
579
  uint32_t field_flags;        // Field atributes(maybe_null, signed, unsigned etc.)
1 by brian
clean slate
580
  const char* old_name;
581
  /**
582
     This should be one of @c SKIP_OPEN_TABLE,
583
     @c OPEN_FRM_ONLY or @c OPEN_FULL_TABLE.
584
  */
482 by Brian Aker
Remove uint.
585
  uint32_t open_method;
1 by brian
clean slate
586
} ST_FIELD_INFO;
587
588
327.2.4 by Brian Aker
Refactoring table.h
589
class TableList;
1 by brian
clean slate
590
typedef class Item COND;
591
971.1.68 by Monty Taylor
Renamed ST_SCHEMA_TABLE to InfoSchemaTable. One step down towards making the darned thing a class. (/me shudders)
592
struct InfoSchemaTable
1 by brian
clean slate
593
{
594
  const char* table_name;
595
  ST_FIELD_INFO *fields_info;
596
  /* Create information_schema table */
520.1.22 by Brian Aker
Second pass of thd cleanup
597
  Table *(*create_table)  (Session *session, TableList *table_list);
1 by brian
clean slate
598
  /* Fill table with data */
520.1.22 by Brian Aker
Second pass of thd cleanup
599
  int (*fill_table) (Session *session, TableList *tables, COND *cond);
1 by brian
clean slate
600
  /* Handle fileds for old SHOW */
971.1.68 by Monty Taylor
Renamed ST_SCHEMA_TABLE to InfoSchemaTable. One step down towards making the darned thing a class. (/me shudders)
601
  int (*old_format) (Session *session, struct InfoSchemaTable *schema_table);
520.1.22 by Brian Aker
Second pass of thd cleanup
602
  int (*process_table) (Session *session, TableList *tables, Table *table,
1 by brian
clean slate
603
                        bool res, LEX_STRING *db_name, LEX_STRING *table_name);
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
604
  int idx_field1, idx_field2;
1 by brian
clean slate
605
  bool hidden;
482 by Brian Aker
Remove uint.
606
  uint32_t i_s_requested_object;  /* the object we need to open(Table | VIEW) */
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
607
};
1 by brian
clean slate
608
609
#define JOIN_TYPE_LEFT	1
610
#define JOIN_TYPE_RIGHT	2
611
612
struct st_lex;
613
class select_union;
851 by Brian Aker
Class rewrite of Session (aka get all of the junk out)
614
class Tmp_Table_Param;
1 by brian
clean slate
615
616
typedef struct st_changed_table_list
617
{
618
  struct	st_changed_table_list *next;
619
  char		*key;
1046.1.6 by Brian Aker
Formatting/style cleanup.
620
  uint32_t key_length;
327.2.4 by Brian Aker
Refactoring table.h
621
} CHANGED_TableList;
1 by brian
clean slate
622
352 by Brian Aker
Merge of Brian's tree to main tree.
623
typedef struct st_open_table_list
624
{
1 by brian
clean slate
625
  struct st_open_table_list *next;
1046.1.6 by Brian Aker
Formatting/style cleanup.
626
  char	*db;
627
  char	*table;
205 by Brian Aker
uint32 -> uin32_t
628
  uint32_t in_use,locked;
327.2.4 by Brian Aker
Refactoring table.h
629
} OPEN_TableList;
1 by brian
clean slate
630
327.1.2 by Brian Aker
Commiting next pass of Table class cleanup.
631
#endif /* DRIZZLED_TABLE_H */