39
The following data is based on the latin1 character set, and is only
40
used when comparing keywords
43
static unsigned char to_upper_lex[]=
45
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
46
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
47
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
49
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
50
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
51
96, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
52
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,123,124,125,126,127,
53
128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
54
144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
55
160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
56
176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
57
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
58
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
59
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
60
208,209,210,211,212,213,214,247,216,217,218,219,220,221,222,255
64
Names of the index hints (for error messages). Keep in sync with
46
Names of the index hints (for error messages). Keep in sync with
68
50
const char * index_hint_type_name[] =
75
inline int lex_casecmp(const char *s, const char *t, uint32_t len)
78
to_upper_lex[(unsigned char) *s++] == to_upper_lex[(unsigned char) *t++]) ;
88
for (i=0 ; i < array_elements(symbols) ; i++)
89
symbols[i].length=(unsigned char) strlen(symbols[i].name);
90
for (i=0 ; i < array_elements(sql_functions) ; i++)
91
sql_functions[i].length=(unsigned char) strlen(sql_functions[i].name);
98
{ // Call this when daemon ends
104
60
st_parsing_options::reset()
106
allows_variable= true;
107
allows_select_into= true;
108
62
allows_select_procedure= true;
109
allows_derived= true;
112
65
Lex_input_stream::Lex_input_stream(Session *session,
1813
bool st_select_lex_node::set_braces(bool value __attribute__((unused)))
1708
bool Select_Lex_Node::set_braces(bool)
1815
bool st_select_lex_node::inc_in_sum_expr() { return 1; }
1816
uint32_t st_select_lex_node::get_in_sum_expr() { return 0; }
1817
TableList* st_select_lex_node::get_table_list() { return 0; }
1818
List<Item>* st_select_lex_node::get_item_list() { return 0; }
1819
TableList *st_select_lex_node::add_table_to_list (Session *session __attribute__((unused)),
1820
Table_ident *table __attribute__((unused)),
1821
LEX_STRING *alias __attribute__((unused)),
1822
uint32_t table_join_options __attribute__((unused)),
1823
thr_lock_type flags __attribute__((unused)),
1824
List<Index_hint> *hints __attribute__((unused)),
1825
LEX_STRING *option __attribute__((unused)))
1710
bool Select_Lex_Node::inc_in_sum_expr() { return 1; }
1711
uint32_t Select_Lex_Node::get_in_sum_expr() { return 0; }
1712
TableList* Select_Lex_Node::get_table_list() { return 0; }
1713
List<Item>* Select_Lex_Node::get_item_list() { return 0; }
1714
TableList *Select_Lex_Node::add_table_to_list (Session *, Table_ident *, LEX_STRING *, uint32_t,
1715
thr_lock_type, List<Index_hint> *, LEX_STRING *)
1829
uint32_t st_select_lex_node::get_table_join_options()
1719
uint32_t Select_Lex_Node::get_table_join_options()
1849
st_select_lex_unit* st_select_lex_unit::master_unit()
1739
Select_Lex_Unit* Select_Lex_Unit::master_unit()
1855
st_select_lex* st_select_lex_unit::outer_select()
1745
Select_Lex* Select_Lex_Unit::outer_select()
1857
return (st_select_lex*) master;
1747
return (Select_Lex*) master;
1861
bool st_select_lex::add_order_to_list(Session *session, Item *item, bool asc)
1751
bool Select_Lex::add_order_to_list(Session *session, Item *item, bool asc)
1863
1753
return add_to_list(session, order_list, item, asc);
1867
bool st_select_lex::add_item_to_list(Session *session __attribute__((unused)),
1757
bool Select_Lex::add_item_to_list(Session *, Item *item)
1870
1759
return(item_list.push_back(item));
1874
bool st_select_lex::add_group_to_list(Session *session, Item *item, bool asc)
1763
bool Select_Lex::add_group_to_list(Session *session, Item *item, bool asc)
1876
1765
return add_to_list(session, group_list, item, asc);
1880
st_select_lex_unit* st_select_lex::master_unit()
1882
return (st_select_lex_unit*) master;
1886
st_select_lex* st_select_lex::outer_select()
1888
return (st_select_lex*) master->get_master();
1892
bool st_select_lex::set_braces(bool value)
1769
Select_Lex_Unit* Select_Lex::master_unit()
1771
return (Select_Lex_Unit*) master;
1775
Select_Lex* Select_Lex::outer_select()
1777
return (Select_Lex*) master->get_master();
1781
bool Select_Lex::set_braces(bool value)
1899
bool st_select_lex::inc_in_sum_expr()
1788
bool Select_Lex::inc_in_sum_expr()
1906
uint32_t st_select_lex::get_in_sum_expr()
1795
uint32_t Select_Lex::get_in_sum_expr()
1908
1797
return in_sum_expr;
1912
TableList* st_select_lex::get_table_list()
1801
TableList* Select_Lex::get_table_list()
1914
1803
return (TableList*) table_list.first;
1917
List<Item>* st_select_lex::get_item_list()
1806
List<Item>* Select_Lex::get_item_list()
1919
1808
return &item_list;
1922
uint32_t st_select_lex::get_table_join_options()
1811
uint32_t Select_Lex::get_table_join_options()
1924
1813
return table_join_options;
1928
bool st_select_lex::setup_ref_array(Session *session, uint32_t order_group_num)
1817
bool Select_Lex::setup_ref_array(Session *session, uint32_t order_group_num)
1930
1819
if (ref_pointer_array)
2135
2005
:result(0), yacc_yyss(0), yacc_yyvs(0),
2136
2006
sql_command(SQLCOM_END), option_type(OPT_DEFAULT), is_lex_started(0)
2139
my_init_dynamic_array2(&plugins, sizeof(plugin_ref),
2140
plugins_static_buffer,
2141
INITIAL_LEX_PLUGIN_LIST_SIZE,
2142
INITIAL_LEX_PLUGIN_LIST_SIZE);
2143
2009
reset_query_tables_list(true);
2148
Check whether the merging algorithm can be used on this VIEW
2151
st_lex::can_be_merged()
2154
We can apply merge algorithm if it is single SELECT view with
2155
subqueries only in WHERE clause (we do not count SELECTs of underlying
2156
views, and second level subqueries) and we have not grpouping, ordering,
2157
HAVING clause, aggregate functions, DISTINCT clause, LIMIT clause and
2158
several underlying tables.
2161
false - only temporary table algorithm can be used
2162
true - merge algorithm can be used
2165
bool st_lex::can_be_merged()
2167
// TODO: do not forget implement case when select_lex.table_list.elements==0
2169
/* find non VIEW subqueries/unions */
2170
bool selects_allow_merge= select_lex.next_select() == 0;
2171
if (selects_allow_merge)
2173
for (SELECT_LEX_UNIT *tmp_unit= select_lex.first_inner_unit();
2175
tmp_unit= tmp_unit->next_unit())
2177
if (tmp_unit->first_select()->parent_lex == this &&
2178
(tmp_unit->item == 0 ||
2179
(tmp_unit->item->place() != IN_WHERE &&
2180
tmp_unit->item->place() != IN_ON)))
2182
selects_allow_merge= 0;
2188
return (selects_allow_merge &&
2189
select_lex.group_list.elements == 0 &&
2190
select_lex.having == 0 &&
2191
select_lex.with_sum_func == 0 &&
2192
select_lex.table_list.elements >= 1 &&
2193
!(select_lex.options & SELECT_DISTINCT) &&
2194
select_lex.select_limit == 0);
2199
check if command can use VIEW with MERGE algorithm (for top VIEWs)
2202
st_lex::can_use_merged()
2205
Only listed here commands can use merge algorithm in top level
2206
SELECT_LEX (for subqueries will be used merge algorithm if
2207
st_lex::can_not_use_merged() is not true).
2210
false - command can't use merged VIEWs
2211
true - VIEWs with MERGE algorithms can be used
2214
bool st_lex::can_use_merged()
2216
switch (sql_command)
2219
case SQLCOM_CREATE_TABLE:
2221
case SQLCOM_UPDATE_MULTI:
2223
case SQLCOM_DELETE_MULTI:
2225
case SQLCOM_INSERT_SELECT:
2226
case SQLCOM_REPLACE:
2227
case SQLCOM_REPLACE_SELECT:
2236
Check if command can't use merged views in any part of command
2239
st_lex::can_not_use_merged()
2242
Temporary table algorithm will be used on all SELECT levels for queries
2243
listed here (see also st_lex::can_use_merged()).
2246
false - command can't use merged VIEWs
2247
true - VIEWs with MERGE algorithms can be used
2250
bool st_lex::can_not_use_merged()
2252
switch (sql_command)
2255
SQLCOM_SHOW_FIELDS is necessary to make
2256
information schema tables working correctly with views.
2257
see get_schema_tables_result function
2259
case SQLCOM_SHOW_FIELDS:
2267
2013
Detect that we need only table structure of derived table/view