339
339
lex->nest_level=0 ;
340
340
lex->allow_sum_func= 0;
341
341
lex->in_sum_func= NULL;
343
ok, there must be a better solution for this, long-term
344
I tried "memset" in the sql_yacc.yy code, but that for
345
some reason made the values zero, even if they were set
347
lex->server_options.server_name= 0;
348
lex->server_options.server_name_length= 0;
349
lex->server_options.host= 0;
350
lex->server_options.db= 0;
351
lex->server_options.username= 0;
352
lex->server_options.password= 0;
353
lex->server_options.scheme= 0;
354
lex->server_options.owner= 0;
355
lex->server_options.port= -1;
343
357
lex->is_lex_started= true;
2132
2146
reset_query_tables_list(true);
2151
Check whether the merging algorithm can be used on this VIEW
2154
LEX::can_be_merged()
2157
We can apply merge algorithm if it is single SELECT view with
2158
subqueries only in WHERE clause (we do not count SELECTs of underlying
2159
views, and second level subqueries) and we have not grpouping, ordering,
2160
HAVING clause, aggregate functions, DISTINCT clause, LIMIT clause and
2161
several underlying tables.
2164
false - only temporary table algorithm can be used
2165
true - merge algorithm can be used
2168
bool LEX::can_be_merged()
2170
// TODO: do not forget implement case when select_lex.table_list.elements==0
2172
/* find non VIEW subqueries/unions */
2173
bool selects_allow_merge= select_lex.next_select() == 0;
2174
if (selects_allow_merge)
2176
for (SELECT_LEX_UNIT *tmp_unit= select_lex.first_inner_unit();
2178
tmp_unit= tmp_unit->next_unit())
2180
if (tmp_unit->first_select()->parent_lex == this &&
2181
(tmp_unit->item == 0 ||
2182
(tmp_unit->item->place() != IN_WHERE &&
2183
tmp_unit->item->place() != IN_ON)))
2185
selects_allow_merge= 0;
2191
return (selects_allow_merge &&
2192
select_lex.group_list.elements == 0 &&
2193
select_lex.having == 0 &&
2194
select_lex.with_sum_func == 0 &&
2195
select_lex.table_list.elements >= 1 &&
2196
!(select_lex.options & SELECT_DISTINCT) &&
2197
select_lex.select_limit == 0);
2202
check if command can use VIEW with MERGE algorithm (for top VIEWs)
2205
LEX::can_use_merged()
2208
Only listed here commands can use merge algorithm in top level
2209
SELECT_LEX (for subqueries will be used merge algorithm if
2210
LEX::can_not_use_merged() is not true).
2213
false - command can't use merged VIEWs
2214
true - VIEWs with MERGE algorithms can be used
2217
bool LEX::can_use_merged()
2219
switch (sql_command)
2222
case SQLCOM_CREATE_TABLE:
2224
case SQLCOM_UPDATE_MULTI:
2226
case SQLCOM_DELETE_MULTI:
2228
case SQLCOM_INSERT_SELECT:
2229
case SQLCOM_REPLACE:
2230
case SQLCOM_REPLACE_SELECT:
2239
Check if command can't use merged views in any part of command
2242
LEX::can_not_use_merged()
2245
Temporary table algorithm will be used on all SELECT levels for queries
2246
listed here (see also LEX::can_use_merged()).
2249
false - command can't use merged VIEWs
2250
true - VIEWs with MERGE algorithms can be used
2253
bool LEX::can_not_use_merged()
2255
switch (sql_command)
2258
SQLCOM_SHOW_FIELDS is necessary to make
2259
information schema tables working correctly with views.
2260
see get_schema_tables_result function
2262
case SQLCOM_SHOW_FIELDS:
2136
2270
Detect that we need only table structure of derived table/view