Commit graph

171883 commits

Author SHA1 Message Date
Monty
8d4d185a08 Simple optimization and removal of compiler warnings 2015-07-05 12:40:16 +03:00
Monty
86377d078e Fixes done while working on MDEV-4119:
Fixed several optimizer issues relatied to GROUP BY:

a) Refering to a SELECT column in HAVING sometimes calculated it twice, which caused problems with non determinstic functions

b) Removing duplicate fields and constants from GROUP BY was done too late for "using index for group by" optimization to work

c) EXPLAIN SELECT ... GROUP BY did wrongly show 'Using filesort' in some cases involving "Using index for group-by"


a) was fixed by:
- Changed last argument to Item::split_sum_func2() from bool to int to allow more flags
- Added flag argument to Item::split_sum_func() to allow on to specify if the item was in the SELECT part
- Mark all split_sum_func() calls from SELECT with SPLIT_SUM_SELECT
- Changed split_sum_func2() to do nothing if called with an argument that is not a sum function and doesn't include sum functions, if we are not an argument to SELECT.

This ensures that in a case like
select a*sum(b) as f1 from t1 where a=1 group by c having f1 <= 10;

That 'a' in the SELECT part is stored as a reference in the temporary table togeher with sum(b) while the 'a' in having isn't (not needed as 'a' is already a reference to a column in the result)

b) was fixed by:
- Added an extra remove_const() pass for GROUP BY arguments before make_join_statistics() in case of one table SELECT.

This allowes get_best_group_min_max() to optimize things better.

c) was fixed by:
- Added test for group by optimization in JOIN::exec_inner for
  select->quick->get_type() == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX

item.cc:
- Simplifed Item::split_sum_func2()
  - Split test to make them faster and easier to read
  - Changed last argument to Item::split_sum_func2() from bool to int to allow more flags
  - Added flag argument to Item::split_sum_func() to allow on to specify if the item was in the SELECT part
  - Changed split_sum_func2() to do nothing if called with an argument that is not a sum function and doesn't include sum functions, if we are not an argument to SELECT.

opt_range.cc:
- Simplified get_best_group_min_max() by calcuating first how many group_by elements.
- Use join->group instead of join->group_list to test if group by, as join->group_list may be NULL if everything was optimized away.

sql_select.cc:
- Added an extra remove_const() pass for GROUP BY arguments before make_join_statistics() in case of one table SELECT.
- Use group instead of group_list to test if group by, as group_list may be NULL if everything was optimized away.
- Moved printing of "Error in remove_const" to remove_const() instead of having it in caller.
- Simplified some if tests by re-ordering code.
- update_depend_map_for_order() and remove_const() fixed to handle the case where make_join_statistics() has not yet been called (join->join_tab is 0 in this case)
2015-07-05 12:39:46 +03:00
Jan Lindström
79af0b3823 MDEV-8393: InnoDB: Assertion failure in file fil0crypt.cc line 2109
Crypt data was used when it was already freed. Delete crypt data
more thorougly when freed.
2015-06-29 14:10:37 +03:00
Jan Lindström
4fac626917 MDEV-8390: innodb.innodb-flush-changed-page-bitmaps crashes
Analysis: Flush changed page bitmaps calls log_online_follow_redo_log
that later calls log_group_read_log_seg with release_mutex = true
and that causes the log_sys mutex being released before
log_decrypt_after_read function that later required log_sys mutex.

Fix: Enter log_sys mutex before log_decrypt_after_read if mutex
is released and release the mutex after the function if we
acquired it before function call.
2015-06-29 12:48:42 +03:00
Sergey Vojtovich
08fa60e5f3 MDEV-8382 - Processlist returns random numbers in Time column
Time column of SHOW PROCESSLIST was returned in microseconds after rev. 8f603bc.
Revert original timescale (seconds).
2015-06-29 12:06:00 +04:00
Sergey Vojtovich
a0f5f407eb MDEV-8339 - Server crash during table cache eviction
TDC_element::free_tables_back() had pre-lfhash leftover code, which referenced
TDC_element::free_tables via TDC_element::share. This is not correct as share
may be NULL (newly inserted or to be removed), instead access free_tables
directly.
2015-06-29 11:07:23 +04:00
Sergey Vojtovich
0865e3deab MDEV-7792 - SQL Parsing Error - UNION AND ORDER BY WITH JOIN
ORDER BY against union may confuse name resolution context, causing valid
SQL statements to fail.

The purpose of context change was presumably intended for the duration of
gathering field list for ORDER BY. However it isn't actually required (name
resolution context is never accessed by the latter).

See also alternative solution (in MySQL 5.7): 92145b95.
2015-06-29 11:04:55 +04:00
Jan Lindström
ad9b3263d3 MDEV-8391: encryption.innodb-page_encryption_compression fails
Test create_or_replace should make sure that background decrypt
operation is finished and flush all dirty pages using restart
to clean up the database before ending.
2015-06-29 08:49:58 +03:00
Sergei Golubchik
7567b9fa10 update tests to pass 2015-06-28 18:51:40 +02:00
Alexander Barkov
4d4f2ed2e1 Moving Item_bool_func::add_key_fields_optimize_op() to Item_bool_func2.
It's now needed outside of Item_bool_func2 any more.
2015-06-28 18:23:15 +04:00
Sergei Golubchik
e04f6e7e3a Merge branch 'bb-10.1-serg' into 10.1 2015-06-28 15:23:33 +02:00
Alexander Barkov
ee0237fe89 MDEV-8330 Get rid of Item_func::select_optimize() and Item_func::optimize_type 2015-06-28 14:29:51 +04:00
Sergei Golubchik
26162c71c5 rename {sys_vars,sql_plugin_services}.h -> *.ic 2015-06-28 12:09:46 +02:00
Sergei Golubchik
55b96d2708 bump the VERSION to 10.1.6 and related changes
fix two #if MYSQL_VERSION_ID > 100105
2015-06-28 12:09:18 +02:00
Sergei Golubchik
d1a11568c7 cleanup: safer versions of PSI no-op macros 2015-06-27 20:38:05 +02:00
Sergei Golubchik
658992699b Merge tag 'mariadb-10.0.20' into 10.1 2015-06-27 20:35:26 +02:00
Sergei Golubchik
fe7e334f3e cleanup: remove unused function argument 2015-06-27 09:40:57 +02:00
Sergei Golubchik
c583360359 unittest: encrypted temporary IO_CACHE 2015-06-27 09:40:56 +02:00
Sergei Golubchik
31eed4759b cleanup: use WRITE_CACHE for view frm files
SEQ_READ_APPEND is for two threads (reader and writer)
simultaneously accessing the IO_CACHE
2015-06-27 09:40:56 +02:00
Sergei Golubchik
1ce71c8478 MDEV-7832 Add status variables to track CREATE TEMPORARY TABLE and DROP TEMPORARY TABLE
Pretend that CREATE TABLE and CREATE TEMPORARY TABLE are
two different commands internally. The user doesn't need
to know that they both are SQLCOM_CREATE_TABLE.

Same for DROP [TEMPORARY] TABLE
2015-06-27 09:40:56 +02:00
Sergei Golubchik
e24caa7588 small cleanup
* keep all com_xxx constants together in struct system_status_var
* fix an outdated comment in sql_cmd.h
* fix an off-by-one bug in mysqld.cc
2015-06-27 09:40:56 +02:00
Sergei Golubchik
c47acc21aa remove unused function and array 2015-06-27 09:40:55 +02:00
Sergei Golubchik
794a895c4c simplify CREATE TEMPORARY TABLE parser rule
as a bonus that makes CREATE TEMPORARY TEMPORARY TABLE illegal
2015-06-27 09:40:55 +02:00
Sergei Golubchik
bfabaf6486 Deinitialize plugins in the reverse plugin_type_initialization_order
Old code worked because plugin locking guaranteed that
encryption plugin is deinitialized last.
But compiled-in plugins are never locked.

This fixes encryption failures on fulltest builder
2015-06-27 09:40:55 +02:00
Sergei Golubchik
ff7a1ff6d7 fix printf format string 2015-06-27 09:40:54 +02:00
Sergei Golubchik
8036ad0a08 misc encryption tests fixes
* support statically compiled file_key_management when possible
* rename encryption.encryption_create_or_replace -> encryption.create_or_replace
* delete unnecessary *.opt file (including
  have_key_management_plugin.inc is enough)
* remove unnecessary LOWER() for strings that are compared
  case insensitively anyway
2015-06-27 09:40:54 +02:00
Sergei Golubchik
627c6e812b MDEV-8298 sys_vars.all_vars fails in -DWITH_WSREP=OFF build
Disable sys_vars.all_vars test. There's no need to write
boilerplate tests for every new system variable, our
INFORMATION_SCHEMA.SYSTEM_VARIABLES and sysvar_* tests
are now used to show all basic properties of all variables.
2015-06-27 09:40:54 +02:00
Sergei Golubchik
e7620ce4ce MDEV-8281 aes_decrypt crashes in block_crypt()
fix aes_decrypt of yassl to support zero-length input
2015-06-27 09:40:54 +02:00
Sergei Golubchik
e20be69ecc update test results and 32-bit rdiffs 2015-06-27 09:40:42 +02:00
Alexander Barkov
55d8ee5f70 MDEV-8239 Reverse spatial operations OP(const, field) do not get optimized
Moving Item_func_spatial_rel from Item_bool_func to Item_bool_func2.
to make OP(const,field) use indexes.
- MBR functions supported OP(const,field) optimization in 10.0,
but were inintentionally broken in an earlier 10.1 change that introduced
a common parent for Item_func_spatial_mbr_rel and Item_func_spatial_precise_rel.
- Precise functions never supported optimization for OP(const,field).
Now both MBR and precise functions support OP(const,field) optimization.
2015-06-26 22:49:49 +04:00
Alexander Barkov
cb5f32ebe3 Moving Item_func_xor out of Item_bool_func2, as it does not need
any of the optimizer related functionality.
2015-06-26 20:00:24 +04:00
Alexander Barkov
40e5aceaff Removing Item_int_func::sargable. Adding virtual implementations of
count_sargable_conds() instead for Item_func_in, Item_func_null_predicate,
Item_bool_func2. There other Item_int_func descendants that used to set
"sargable" to true (Item_func_between, Item_equal) already have their
own implementation of count_sargable_conds(). There is no sense to
have two parallel coding models for the same thing.
2015-06-26 17:46:34 +04:00
Alexander Barkov
436411860e Moving ST_RELATE() implementation out of Item_func_precise_spatial_rel,
adding a separte class Item_func_spatial_relate for ST_RELATE().
This is a preparatory patch for:
 MDEV-8239 Reverse spatial operations OP(const, field) do not get optimized
2015-06-26 15:42:49 +04:00
Alexander Barkov
4f828a1cac MDEV-8214 Asian MB2 charsets: compare broken bytes as "greater than any non-broken character" 2015-06-26 13:40:28 +04:00
Jan Lindström
d535728165 MDEV-8219: enforce_storage_engine cannot be set globally
Change session only variable enforce_storage_engine to be
session variable and make sure that also global value
is used if session variable is not set.
2015-06-26 11:43:16 +03:00
Alexander Barkov
a4b0063d7b MDEV-8256 A part of a ROW comparison is erroneously optimized away
Item_func_eq's created during conversion of a ROW equality to a conjunction
of scalar equalities did not set cmp_context for its arguments properly,
so some of these created Item_func_eq could be later erroneously eliminated.
2015-06-26 10:58:51 +04:00
Alexander Barkov
4a7afdde86 MDEV-8373 Zero date can be inserted in strict no-zero mode through CREATE TABLE AS SELECT timestamp_field 2015-06-26 10:18:34 +04:00
Alexander Barkov
115904c2c8 MDEV-7824 [Bug #68041] Zero date can be inserted in strict no-zero mode through a default value 2015-06-26 10:16:51 +04:00
Jan Lindström
874df5092b Fix failing test case. 2015-06-26 08:34:09 +03:00
Alexey Botchkov
9111ab7127 GIS-related tests started to fail as some related functions
don't return NULL-s anymore, and actually they're not BOOLEAN.
Fixed.
2015-06-25 13:16:27 +05:00
Alexander Barkov
42bc08b347 MDEV-8229 GROUP_MIN_MAX is erroneously applied for BETWEEN in some cases 2015-06-25 12:51:32 +04:00
Nirbhay Choubey
1f4a89b10c Do print SST log messages. 2015-06-24 23:38:04 -04:00
Kristian Nielsen
565960816e Merge MDEV-8354 into 10.1 2015-06-24 17:18:12 +02:00
Kristian Nielsen
b89de2b2ce MDEV-8354: out-of-order error with --gtid-ignore-duplicates and row-based replication
The --gtid-ignore-duplicates option was not working correctly with row-based
replication. When a row event was completed, but before committing, there
was a small window where another multi-source SQL thread could wrongly try
to re-execute the same transaction, without properly ignoring the duplicate
GTID. This would lead to duplicate key error or out-of-order GTID error or
similar.

Thanks to Matt Neth for reporting this and giving an easy way to reproduce
the issue.
2015-06-24 16:52:50 +02:00
Alexey Botchkov
d43df4a33a These functions can never return NULL. 2015-06-23 15:06:23 +05:00
Jan Lindström
b7ff2f1b59 MDEV-7472: Implementation of user statements for handling the xtradb changed page bitmaps
Introduce a new dummy INFORMATION_SCHEMA.CHANGED_PAGE_BITMAPS table to XtraDB
with reset_table callback to allow FLUSH NO_WRITE_TO_BINLOG CHANGED_PAGE_BITMAPS
to be called from innobackupex.
2015-06-23 14:46:06 +03:00
Alexey Botchkov
d3b7eb7b99 MDEV-7528 GIS: Functions return NULL instead of specified -1 for NULL arguments.
The behaviour required by the standard seems too weird to expect.
2015-06-23 11:57:05 +05:00
Alexey Botchkov
3e4126e9d6 Merge branch '10.1' of github.com:MariaDB/server into 10.1 2015-06-23 11:30:39 +05:00
Sergey Vojtovich
9b57b214c4 MDEV-8199 - first_breadth_first_tab() takes 0.07% in OLTP RO
This is an addition to original patch: cleanups for next_breadth_first_tab().

Overhead change:
next_breadth_first_tab()  0.04% -> out of radar
2015-06-23 09:54:36 +04:00
Sergey Vojtovich
45f41b52e8 MDEV-8199 - first_breadth_first_tab() takes 0.07% in OLTP RO
Split first_breadth_first_tab() into
JOIN::first_breadth_first_optimization_tab() and
JOIN::first_breadth_first_execution_tab().

This allows to eliminate function call and one condition. Adjusted callers
accordingly.

Overhead change:
first_breadth_first_tab()        0.07% -> out of radar
next_breadth_first_tab()         0.04% -> 0.04%
JOIN::cleanup()                  0.15% -> 0.11%
JOIN::save_explain_data_intern() 0.28% -> 0.24%
2015-06-23 09:54:36 +04:00