13
13
along with this program; if not, write to the Free Software
14
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#include <drizzled/error.h>
17
#include <drizzled/table_list.h>
18
#include <drizzled/item.h>
19
#include <drizzled/item/field.h>
20
#include <drizzled/nested_join.h>
21
#include <drizzled/sql_lex.h>
22
#include <drizzled/server_includes.h>
23
#include <drizzled/sql_select.h>
16
#include "drizzled/server_includes.h"
20
#include "drizzled/error.h"
21
#include "drizzled/table_list.h"
22
#include "drizzled/item.h"
23
#include "drizzled/item/field.h"
24
#include "drizzled/nested_join.h"
25
#include "drizzled/sql_lex.h"
26
#include "drizzled/sql_select.h"
27
28
using namespace std;
33
Create a table cache key
36
create_table_def_key()
37
key Create key here (must be of size MAX_DBKEY_LENGTH)
38
table_list Table definition
41
The table cache_key is created from:
45
if the table is a tmp table, we add the following to make each tmp table
48
4 bytes for master thread id
49
4 bytes pseudo thread id
55
33
uint32_t TableList::create_table_def_key(char *key)
57
35
return TableShare::createKey(key, db, table_name);
62
Set insert_values buffer
66
mem_root memory pool for allocating
73
38
bool TableList::set_insert_values(MEM_ROOT *mem_root)
88
Test if this is a leaf with respect to name resolution.
91
TableList::is_leaf_for_name_resolution()
94
A table reference is a leaf with respect to name resolution if
95
it is either a leaf node in a nested join tree (table, view,
96
schema table, subquery), or an inner node that represents a
97
NATURAL/USING join, or a nested join with materialized join
101
TRUE if a leaf, false otherwise.
103
51
bool TableList::is_leaf_for_name_resolution()
105
53
return (is_natural_join || is_join_columns_complete || !nested_join);
111
Create Item_field for each column in the table.
114
Table::fill_item_list()
115
item_list a pointer to an empty list used to store items
118
Create Item_field object for each column in the table and
119
initialize it with the corresponding Field. New items are
120
created in the current Session memory root.
127
bool Table::fill_item_list(List<Item> *item_list) const
130
All Item_field's created using a direct pointer to a field
131
are fixed in Item_field constructor.
133
for (Field **ptr= field; *ptr; ptr++)
135
Item_field *item= new Item_field(*ptr);
136
if (!item || item_list->push_back(item))
144
Find underlying base tables (TableList) which represent given
145
table_to_find (Table)
148
TableList::find_underlying_table()
149
table_to_find table to find
153
found table reference
156
56
TableList *TableList::find_underlying_table(Table *table_to_find)
158
58
/* is this real table and table which we are looking for? */
166
65
bool TableList::placeholder()
168
67
return derived || schema_table || (create && !table->getDBStat()) || !table;
173
Retrieve the last (right-most) leaf in a nested join tree with
174
respect to name resolution.
177
TableList::last_leaf_for_name_resolution()
180
Given that 'this' is a nested table reference, recursively walk
181
down the right-most children of 'this' until we reach a leaf
182
table reference with respect to name resolution.
185
The right-most child of a nested table reference is the first
186
element in the list of children because the children are inserted
190
- If 'this' is a nested table reference - the right-most child of
191
the tree rooted in 'this',
71
* The right-most child of a nested table reference is the first
72
* element in the list of children because the children are inserted
195
75
TableList *TableList::last_leaf_for_name_resolution()
197
77
TableList *cur_table_ref= this;
225
105
return cur_table_ref;
230
Retrieve the first (left-most) leaf in a nested join tree with
231
respect to name resolution.
234
TableList::first_leaf_for_name_resolution()
237
Given that 'this' is a nested table reference, recursively walk
238
down the left-most children of 'this' until we reach a leaf
239
table reference with respect to name resolution.
242
The left-most child of a nested table reference is the last element
243
in the list of children because the children are inserted in
247
If 'this' is a nested table reference - the left-most child of
248
the tree rooted in 'this',
109
* The left-most child of a nested table reference is the last element
110
* in the list of children because the children are inserted in
252
113
TableList *TableList::first_leaf_for_name_resolution()
254
115
TableList *cur_table_ref= NULL;
282
143
return cur_table_ref;
287
Return subselect that contains the FROM list this table is taken from
290
TableList::containing_subselect()
293
Subselect item for the subquery that contains the FROM list
294
this table is taken from if there is any
299
146
Item_subselect *TableList::containing_subselect()
301
148
return (select_lex ? select_lex->master_unit()->item : 0);
306
Compiles the tagged hints list and fills up the bitmasks.
309
process_index_hints()
310
table the Table to operate on.
313
The parser collects the index hints for each table in a "tagged list"
314
(TableList::index_hints). Using the information in this tagged list
315
this function sets the members Table::keys_in_use_for_query,
316
Table::keys_in_use_for_group_by, Table::keys_in_use_for_order_by,
317
Table::force_index and Table::covering_keys.
319
Current implementation of the runtime does not allow mixing FORCE INDEX
320
and USE INDEX, so this is checked here. Then the FORCE INDEX list
321
(if non-empty) is appended to the USE INDEX list and a flag is set.
323
Multiple hints of the same kind are processed so that each clause
324
is applied to what is computed in the previous clause.
326
USE INDEX (i1) USE INDEX (i2)
329
and means "consider only i1 and i2".
332
USE INDEX () USE INDEX (i1)
335
and means "consider only the index i1"
337
It is OK to have the same index several times, e.g. "USE INDEX (i1,i1)" is
340
Different kind of hints (USE/FORCE/IGNORE) are processed in the following
342
1. All indexes in USE (or FORCE) INDEX are added to the mask.
345
e.g. "USE INDEX i1, IGNORE INDEX i1, USE INDEX i1" will not use i1 at all
346
as if we had "USE INDEX i1, USE INDEX i1, IGNORE INDEX i1".
348
As an optimization if there is a covering index, and we have
349
IGNORE INDEX FOR GROUP/order_st, and this index is used for the JOIN part,
350
then we have to ignore the IGNORE INDEX FROM GROUP/order_st.
353
false no errors found
354
TRUE found and reported an error.
356
151
bool TableList::process_index_hints(Table *tbl)
358
153
/* initialize the result variables */