As a side effect tc_remove_all_unused_tables() has to call
tc_wait_for_mdl_deadlock_detector() once per TABLE object now, while it called
it only once before. This should be acceptable since actual wait will still be
performed only once. It only adds redundant checks for all_tables_refs.
This is mostly needed to hide all references to free_tables, so that further
implementation of multi-instance list can be done completely inside
table_cache.cc
Allowing GROUP_CONCAT(... ORDER BY ..) in queries with ROLLUP.
The story of the related code:
1. The original patch from Wax
commit: 0b505fb437
date: Tue Mar 18 03:07:40 2003
opt_gorder_clause reused the regular order_clause,
which already had some protection against ROLLUP queries:
order_clause:
ORDER_SYM BY
{
LEX *lex=Lex;
if (lex->current_select->linkage != GLOBAL_OPTIONS_TYPE &&
lex->current_select->select_lex()->olap !=
UNSPECIFIED_OLAP_TYPE)
{
net_printf(lex->thd, ER_WRONG_USAGE,
"CUBE/ROLLUP",
"ORDER BY");
YYABORT;
}
} order_list;
The assumption that ORDER BY in group_concat() had to have
the same ROLLUP restriction (with order_clause) was wrong.
Moreover, GROUP_CONCAT() in select_item_list was not affected
by this restriction, because WITH ROLLUP goes after
select_item_list and therefore sel->olap is always equal
to UNSPECIFIED_OLAP_TYPE during select_item_list.
GROUP BY was not affected for two reasons:
- it goes before WITH ROLLUP and sel->olap is still
UNSPECIFIED_OLAP_TYPE
- Aggregate functions like AVG(), GROUP_CONCAT() in GROUP BY
are not allowed
So only GROUP_CONCAT() in HAVING and ORDER BY clauses
were erroneously affected by this restriction.
2. Bug#27848 rollup in union part causes error with order of union
commit: 3f6073ae63
Author: unknown <igor@olga.mysql.com> 2007-12-15 01:42:46
The condition in the ROLLUP protection code became more complex.
Note, opt_gconcat_order still reused the regular order_clause.
3. Bug#16347426 ASSERTION FAILED: (SELECT_INSERT &&
!TABLES->NEXT_NAME_RESOLUTION_TABLE) || !TAB
commit: 2d83663380
author: Chaithra Gopalareddy <chaithra.gopalareddy@oracle.com>
date: 2013-04-14 06:00:49
opt_gorder_clause was refactored not to use order_clause and
to collect information directly to select->gorder_list.
The ROLLUP protection code was duplicated from order_clause
to the new version of opt_gorder_clause.
- Validate the specified wsrep_start_position value by also
checking the return status of wsrep->sst_received. This also
ensures that changes in wsrep_start_position is not allowed
when the node is not in JOINING state.
- Do not allow decrease in seqno within same UUID.
- The initial checkpoint in SEs should be [0...:-1].
Using /*empty*/, union_list, union_order_or_limit instead.
This is to get rid of lex->current_select->braces easier
(separately in union_list and in union_order_or_limit)
- Moving opt_union_order_or_limit inside union_opt,
as it's not used in other places any more.
- Changing union_opt to have no type.
Earlier (before all MDEV-8909 dependency tasks) it had the <num> type,
and it's return value was used to generate errors.
Now union_opt does not need a return value because the grammar
disallows ORDER and LIMIT clauses in wrong context.
(to simplify further MDEV-8909 changes)
1. Better semantic readability:
- Moving get_select_lex_derived inside select_derived_init
and decomposing it into get_select_lex and
$1->init_nested_join(lex->thd)
- Moving DBUG_ASSERT($1 == Lex->current_select) inside
select_derived_init
Now init_nested_join() and end_nested_join() reside inside
the same rule select_derived_init.
(It's very likely that they can be further removed,
as there are no any joins in this rule).
3. Better grammar readability:
Moving SELECT_SYM from select_derived_init to derived_query_specification.
It's easier to read a rule when it starts from a terminal symbol.
1. Moving the "| get_select_lex_derived select_derived_init" part of
select_derived into a separate new rule derived_query_specification.
2. Using derived_query_specification directly in select_derived_union
rather than in select_derived.
3. Moving the sequence "opt_order_clause opt_limit_clause opt_select_lock_type"
from select_derived2 to select_derived_union,
after derived_query_specification.
Effectively, the parser now does not go through the sequence
"opt_order_clause opt_limit_clause ... opt_union_order_or_limit" any more.
This fixes the problem with double LIMIT clause and removes 2 shift/reduce
conflicts.
"MDEV-8909 union parser cleanup" changes.
When the server parses a query like
SELECT * FROM (SELECT 1);
a sequence of calls
st_select_lex::init_nested_join() ..
st_select_lex::end_nested_join()
was performed two times (tested in gdb).
Both pairs of calls seem to be redundant for a query
like this, because there are actually no any joins here.
This patch moved "table_ref_select" inside "select_derived",
which revealed that one the pairs was definitely redundant:
After this transformation we got an init_nested_join()
immediately followed by end_nested_join() for the same st_select_lex,
which has no any sense. So this pair of calls was removed.
- Moving "SELECT_SYM select_init2_derived opt_table_expression"
from query_term into a new separate rule query_specification,
and using query_specification in the beginning of query_term.
- query_term now does not have a %type, query_specification has a %type
instead. This removes duplicate code that returns
Lex->current_select->master_unit()->first_select();
- Moving select_options_and_item_list from select_init2
to select_init and view_select_aux
- Renaming select_init2 to select_init3
This will simplify upcoming sql_yacc.yy fixes (e.g. MDEV-10035, MDEV-8909).
An addition to original patch:
- use FN_REFLEN instead of HOST_NAME_MAX (the latter can be undefined)
- avoid calling gethostname() on every prompt construction by caching it
Introduce `\H` option which behaves mostly like `\h`. The only exception is
when the client connects to the server hosted on localhost. In this case, the
hostname will be used instead.
closer the grammar in the SQL Standard:
- <query specification> is only a SELECT followed by
<set quantifier>, <select list> and <table expression>.
- While <query term> includes SELECT queries and derived tables.
This change refactors the "table_expression" rule in sql_yacc.yy.
Queries with subselects and derived tables, as well as "CREATE TABLE ... SELECT"
now return syntax error instead of "Incorrect usage of PROCEDURE and ...".
* simplify the code at default: label
* bugfix: flush the checksum for NULL fields
(perfschema.checksum was failing)
* cleanup: put repeated code into a function
Checksum implementations contain optimizations for calculating
checksums of larger blocks of memory.
This optimization calls my_checksum on a larger block of memory
rather than calling on multiple adjacent memory as its going though
the table columns for each table row.