73
Table() {} /* Remove gcc warning */
76
Field **field; /* Pointer to fields */
82
MY_BITMAP *read_set; /* Active column sets */
83
MY_BITMAP *write_set; /* Active column sets */
86
uint32_t db_stat; /* mode of file as in handler.h */
73
88
my_bitmap_map *bitmap_init_value;
74
89
MY_BITMAP def_read_set, def_write_set, tmp_set; /* containers */
75
MY_BITMAP *read_set, *write_set; /* Active column sets */
78
Table() {} /* Remove gcc warning */
81
inline TableShare *getShare() { return s; } /* Get rid of this long term */
82
inline void setShare(TableShare *new_share) { s= new_share; } /* Get rid of this long term */
83
inline uint32_t sizeKeys() { return s->keys; }
84
inline uint32_t sizeFields() { return s->fields; }
85
inline uint32_t getRecordLength() { return s->reclength; }
86
inline uint32_t sizeBlobFields() { return s->blob_fields; }
87
inline uint32_t *getBlobField() { return s->blob_field; }
88
inline uint32_t getNullBytes() { return s->null_bytes; }
89
inline uint32_t getNullFields() { return s->null_fields; }
90
inline unsigned char *getDefaultValues() { return s->default_values; }
92
inline bool isDatabaseLowByteFirst() { return s->db_low_byte_first; } /* Portable row format */
93
inline bool isCrashed() { return s->crashed; }
94
inline bool isNameLock() { return s->name_lock; }
95
inline bool isReplaceWithNameLock() { return s->replace_with_name_lock; }
96
inline bool isWaitingOnCondition() { return s->waiting_on_cond; } /* Protection against free */
98
/* For TMP tables, should be pulled out as a class */
99
void updateCreateInfo(HA_CREATE_INFO *create_info);
100
void setup_tmp_table_column_bitmaps(unsigned char *bitmaps);
101
bool create_myisam_tmp_table(KEY *keyinfo,
102
MI_COLUMNDEF *start_recinfo,
103
MI_COLUMNDEF **recinfo,
105
void free_tmp_table(Session *session);
106
bool open_tmp_table();
107
size_t max_row_length(const unsigned char *data);
108
uint32_t find_shortest_key(const key_map *usable_keys);
109
bool compare_record(Field **ptr);
110
bool compare_record();
111
/* TODO: the (re)storeRecord's may be able to be further condensed */
113
void storeRecordAsInsert();
114
void storeRecordAsDefault();
115
void restoreRecord();
116
void restoreRecordAsDefault();
118
bool table_check_intact(const uint32_t table_f_count, const TABLE_FIELD_W_TYPE *table_def);
120
/* See if this can be blown away */
121
inline uint32_t getDBStat () { return db_stat; }
122
inline uint32_t setDBStat () { return db_stat; }
123
uint32_t db_stat; /* mode of file as in handler.h */
128
91
Session *in_use; /* Which thread uses this */
129
Field **field; /* Pointer to fields */
131
93
unsigned char *record[2]; /* Pointer to records */
132
94
unsigned char *write_row_record; /* Used as optimisation in
133
95
Session::write_row */
134
96
unsigned char *insert_values; /* used by INSERT ... UPDATE */
136
Map of keys that can be used to retrieve all data from this table
137
needed by the query without reading the row.
139
key_map covering_keys;
140
key_map quick_keys, merge_keys;
142
A set of keys that can be used in the query that references this
145
All indexes disabled on the table's TableShare (see Table::s) will be
146
subtracted from this set upon instantiation. Thus for any Table t it holds
147
that t.keys_in_use_for_query is a subset of t.s.keys_in_use. Generally we
148
must not introduce any new keys here (see setup_tables).
150
The set is implemented as a bitmap.
152
key_map keys_in_use_for_query;
153
/* Map of keys that can be used to calculate GROUP BY without sorting */
154
key_map keys_in_use_for_group_by;
155
/* Map of keys that can be used to calculate ORDER BY without sorting */
156
key_map keys_in_use_for_order_by;
157
97
KEY *key_info; /* data of keys in database */
159
98
Field *next_number_field; /* Set if next_number is activated */
160
99
Field *found_next_number_field; /* Set on open */
161
100
Field_timestamp *timestamp_field;
165
104
const char *alias; /* alias or table name */
166
105
unsigned char *null_flags;
168
The ID of the query that opened and is using this table. Has different
169
meanings depending on the table type.
173
table->query_id is set to session->query_id for the duration of a statement
174
and is reset to 0 once it is closed by the same statement. A non-zero
175
table->query_id means that a statement is using the table even if it's
176
not the current statement (table is in use by some outer statement).
178
Non-temporary tables:
180
Under pre-locked or LOCK TABLES mode: query_id is set to session->query_id
181
for the duration of a statement and is reset to 0 once it is closed by
182
the same statement. A non-zero query_id is used to control which tables
183
in the list of pre-opened and locked tables are actually being used.
188
For each key that has quick_keys.test(key) == true: estimate of #records
189
and max #key parts that range access would use.
191
ha_rows quick_rows[MAX_KEY];
193
/* Bitmaps of key parts that =const for the entire join. */
194
key_part_map const_key_parts[MAX_KEY];
196
uint quick_key_parts[MAX_KEY];
197
uint quick_n_ranges[MAX_KEY];
200
Estimate of number of records that satisfy SARGable part of the table
201
condition, or table->file->records if no SARGable condition could be
203
This value is used by join optimizer as an estimate of number of records
204
that will pass the table condition (condition that depends on fields of
205
this table and constants)
207
ha_rows quick_condition_rows;
210
If this table has TIMESTAMP field with auto-set property (pointed by
211
timestamp_field member) then this variable indicates during which
212
operations (insert only/on update/in both cases) we should set this
213
field to current timestamp. If there are no such field in this table
214
or we should not automatically set its value during execution of current
215
statement then the variable contains TIMESTAMP_NO_AUTO_SET (i.e. 0).
217
Value of this variable is set for each statement in open_table() and
218
if needed cleared later in statement processing code (see mysql_update()
221
timestamp_auto_set_type timestamp_field_type;
222
table_map map; /* ID bit of table (1,2,4,8,16...) */
224
107
uint32_t lock_position; /* Position in DRIZZLE_LOCK.table */
225
108
uint32_t lock_data_start; /* Start pos. in DRIZZLE_LOCK.locks */
226
109
uint32_t lock_count; /* Number of locks */
227
uint tablenr,used_fields;
110
uint32_t used_fields;
228
111
uint32_t temp_pool_slot; /* Used by intern temp tables */
229
uint status; /* What's in record[0] */
112
uint32_t status; /* What's in record[0] */
230
113
/* number of select if it is derived table */
231
114
uint32_t derived_select_number;
232
115
int current_lock; /* Type of lock on table */
279
161
bool insert_or_update; /* Can be used by the handler */
280
162
bool alias_name_used; /* true if table_name is alias */
281
163
bool get_fields_in_item_tree; /* Signal to fix_field */
164
int report_error(int error);
165
int closefrm(bool free_share);
166
uint32_t tmpkeyval();
169
The ID of the query that opened and is using this table. Has different
170
meanings depending on the table type.
174
table->query_id is set to session->query_id for the duration of a statement
175
and is reset to 0 once it is closed by the same statement. A non-zero
176
table->query_id means that a statement is using the table even if it's
177
not the current statement (table is in use by some outer statement).
179
Non-temporary tables:
181
Under pre-locked or LOCK TABLES mode: query_id is set to session->query_id
182
for the duration of a statement and is reset to 0 once it is closed by
183
the same statement. A non-zero query_id is used to control which tables
184
in the list of pre-opened and locked tables are actually being used.
189
Estimate of number of records that satisfy SARGable part of the table
190
condition, or table->file->records if no SARGable condition could be
192
This value is used by join optimizer as an estimate of number of records
193
that will pass the table condition (condition that depends on fields of
194
this table and constants)
196
ha_rows quick_condition_rows;
199
If this table has TIMESTAMP field with auto-set property (pointed by
200
timestamp_field member) then this variable indicates during which
201
operations (insert only/on update/in both cases) we should set this
202
field to current timestamp. If there are no such field in this table
203
or we should not automatically set its value during execution of current
204
statement then the variable contains TIMESTAMP_NO_AUTO_SET (i.e. 0).
206
Value of this variable is set for each statement in open_table() and
207
if needed cleared later in statement processing code (see mysql_update()
210
timestamp_auto_set_type timestamp_field_type;
211
table_map map; /* ID bit of table (1,2,4,8,16...) */
283
213
REGINFO reginfo; /* field connections */
216
Map of keys that can be used to retrieve all data from this table
217
needed by the query without reading the row.
219
key_map covering_keys;
226
A set of keys that can be used in the query that references this
229
All indexes disabled on the table's TableShare (see Table::s) will be
230
subtracted from this set upon instantiation. Thus for any Table t it holds
231
that t.keys_in_use_for_query is a subset of t.s.keys_in_use. Generally we
232
must not introduce any new keys here (see setup_tables).
234
The set is implemented as a bitmap.
236
key_map keys_in_use_for_query;
237
/* Map of keys that can be used to calculate GROUP BY without sorting */
238
key_map keys_in_use_for_group_by;
239
/* Map of keys that can be used to calculate ORDER BY without sorting */
240
key_map keys_in_use_for_order_by;
243
For each key that has quick_keys.test(key) == true: estimate of #records
244
and max #key parts that range access would use.
246
ha_rows quick_rows[MAX_KEY];
248
/* Bitmaps of key parts that =const for the entire join. */
249
key_part_map const_key_parts[MAX_KEY];
251
uint32_t quick_key_parts[MAX_KEY];
252
uint32_t quick_n_ranges[MAX_KEY];
284
254
MEM_ROOT mem_root;
285
255
filesort_info_st sort;
260
inline TableShare *getShare() { 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; }
271
inline bool isDatabaseLowByteFirst() { return s->db_low_byte_first; } /* Portable row format */
272
inline bool isCrashed() { return s->crashed; }
273
inline bool isNameLock() { return s->name_lock; }
274
inline bool isReplaceWithNameLock() { return s->replace_with_name_lock; }
275
inline bool isWaitingOnCondition() { return s->waiting_on_cond; } /* Protection against free */
277
/* For TMP tables, should be pulled out as a class */
278
void updateCreateInfo(HA_CREATE_INFO *create_info);
279
void setup_tmp_table_column_bitmaps(unsigned char *bitmaps);
280
bool create_myisam_tmp_table(KEY *keyinfo,
281
MI_COLUMNDEF *start_recinfo,
282
MI_COLUMNDEF **recinfo,
284
void free_tmp_table(Session *session);
285
bool open_tmp_table();
286
size_t max_row_length(const unsigned char *data);
287
uint32_t find_shortest_key(const key_map *usable_keys);
288
bool compare_record(Field **ptr);
289
bool compare_record();
290
/* TODO: the (re)storeRecord's may be able to be further condensed */
292
void storeRecordAsInsert();
293
void storeRecordAsDefault();
294
void restoreRecord();
295
void restoreRecordAsDefault();
297
bool table_check_intact(const uint32_t table_f_count, const TABLE_FIELD_W_TYPE *table_def);
299
/* See if this can be blown away */
300
inline uint32_t getDBStat () { return db_stat; }
301
inline uint32_t setDBStat () { return db_stat; }
287
302
bool fill_item_list(List<Item> *item_list) const;
288
303
void reset_item_list(List<Item> *item_list) const;
289
304
void clear_column_bitmaps(void);