Commit graph

23738 commits

Author SHA1 Message Date
unknown
39afdcddd1 MDEV-5401: Wrong result (missing row) on a 2nd execution of PS with exists_to_in=on, MERGE view or a SELECT SQ
The problem was that the view substitute its fields (on prepare) with reverting the change after execution. After prepare on optimization exists2in convertion substituted arguments of '=' with constsnt '1', but then one of the arguments of '=' was reverted to the view field reference.This lead to incorrect WHERE condition on the second execution.

To fix the problem we replace whole '=' with '1' permannently.
2014-04-10 12:14:18 +03:00
Sergey Petrunya
26a3d567c9 MDEV-5992: EITS: Selectivity of non-indexed condition is counted twice in table's fanout
MDEV-5984: EITS: Incorrect filtered% value for single-table select with range access
- Fix calculate_cond_selectivity_for_table() to work correctly with range accesses 
  over multi-component keys:
  = First, take selectivity of all possible range scans into account. Remember which 
    fields were used bt the range scans.
  = Then, calculate selectivity produced by sargable predicates on fields. If a 
    field was used in a possible range access, assume its selectivity is already
    taken into account.
- Fix table_cond_selectivity(): when quick select is used, selectivity of
  COND(table) is taken into account in matching_candidates_in_table(). In
  table_cond_selectivity() we should not apply it for the second time.
2014-04-01 09:59:51 -07:00
Sergei Golubchik
73f4861575 MDEV-5969 Crash in prepared statement with NO_ZERO_IN_DATE and ROLLUP
MDEV-5971 Asymmetry between CAST(DATE'2001-00-00') to INT and TO CHAR in prepared statements

Consistently set maybe_null flag, even not-NULL temporal literal may become NULL
in the restrictive sql_mode.
2014-03-29 11:33:20 +01:00
Sergei Golubchik
b37157e49e update the result file 2014-03-29 11:32:49 +01:00
Michael Widenius
d5a185a552 automatic merge 2014-03-28 21:42:57 +02:00
Michael Widenius
3f7ee1f12e Updated sponsors and authors 2014-03-28 09:31:43 +02:00
Michael Widenius
10ae6e35d0 Fixed that the we don't change CREATE to CREATE OR REPLACE, except if the slave removed an existing table as part of CREATE.
This will help the following replicaition scenario:
MariaDB 10.0 master (statement replication) -> MariaDB 10.0 slave (row based replication) -> MySQL or MariaDB 5.x slave


mysql-test/r/mysqld--help.result:
  Updated help text
mysql-test/suite/rpl/r/create_or_replace_mix.result:
  Added more tests
mysql-test/suite/rpl/r/create_or_replace_row.result:
  Added more tests
mysql-test/suite/rpl/r/create_or_replace_statement.result:
  Added more tests
mysql-test/suite/rpl/t/create_or_replace.inc:
  Added more tests
sql/handler.h:
  Added org_options so that we can detect what come from the query and what was possible added later.
sql/sql_insert.cc:
  Only write CREATE OR REPLACE if was originally specified or if we delete a conflicting table as part of create
sql/sql_parse.cc:
  Remember orginal create options
sql/sql_table.cc:
  Only write CREATE OR REPLACE if was originally specified or if we delete a conflicting table as part of create
sql/sys_vars.cc:
  Updated help text
2014-03-28 09:31:24 +02:00
Sergey Petrunya
68015a99cd Change the order of parameters in DECODE_HISTOGRAM to match the order of fields in
mysql.column_stats.
2014-03-28 23:18:33 +04:00
Sergey Petrunya
92e49bb066 MDEV-4360: ANALYZE shows "Table is already up to date" while updating stats
- Show a line with "Engine-independent statistics collected" when ANALYZE command
  caused EITS statistics to be recollected.
2014-03-28 00:32:53 +04:00
Michael Widenius
4cc3fd48f6 MDEV-5876: MySQL bug #11766767 - "59957: VIEW USING MERGE PERMISSIONS IN MULTI-TABLE UPDATE"
Backported multi_update_check_table_access() from 5.6

The code is slightly different in MariaDB, becasue we instansiate fields in merged tables earlier.

mysql-test/mysql-test-run.pl:
  Fixed comment
mysql-test/r/view_grant.result:
  Merged test case from 5.6
mysql-test/t/view_grant.test:
  Merged test case from 5.6
sql/sql_parse.cc:
  Reset orig_want_privilege as this will be rechecked later.
  If not, we will have a problem in mysql_multi_update_prepare() for the call to mysql_handle_derived()
sql/sql_update.cc:
  Backport multi_update_check_table_access() from 5.6
2014-03-24 08:18:01 +02:00
Michael Widenius
9aac546872 MDEV-5930 Server crashes in thd_get_ha_data on CREATE OR REPLACE TABLE
mysql-test/r/create_or_replace.result:
  More tests for create or replace
mysql-test/t/create_or_replace.test:
  More tests for create or replace
sql/log.cc:
  Don't use binlog_hton if binlog is not enabmed
sql/sql_base.cc:
  We have to call restart_trans_for_tables also if tables where not locked with LOCK TABLES.
  If not, we will get a crash in TokuDB
sql/sql_insert.cc:
  Don't call binlog_reset_cache() if we don't have binary log open
sql/sql_table.cc:
  Don't log to binary log if not open
  Better test if we where using create or replace ... select
storage/tokudb/mysql-test/tokudb_mariadb/r/create_or_replace.result:
  More tests for create or replace
storage/tokudb/mysql-test/tokudb_mariadb/t/create_or_replace.test:
  More tests for create or replace
2014-03-23 18:39:10 +02:00
Michael Widenius
39e6083e35 MDEV-5818: MySQL WL#6145: Separate the dependence of DATA DIRECTORY from symbolic links
Copied relevant test cases and code from the MySQL 5.6 tree
Testing of my_use_symdir moved to engines.


mysql-test/r/partition_windows.result:
  Updated result file
mysql-test/suite/archive/archive_no_symlink-master.opt:
  Testing of symlinks with archive
mysql-test/suite/archive/archive_no_symlink.result:
  Testing of symlinks with archive
mysql-test/suite/archive/archive_no_symlink.test:
  Testing of symlinks with archive
mysql-test/suite/archive/archive_symlink.result:
  Testing of symlinks with archive
mysql-test/suite/archive/archive_symlink.test:
  Testing of symlinks with archive
sql/log_event.cc:
  Updated comment
sql/partition_info.cc:
  Don't test my_use_symdir here
sql/sql_parse.cc:
  Updated comment
sql/sql_table.cc:
  Don't test my_use_symdir here
sql/table.cc:
  Added more DBUG_PRINT
storage/archive/ha_archive.cc:
  Give warnings for index_file_name and if we can't use data directory
storage/myisam/ha_myisam.cc:
  Give warnings if we can't use data directory or index directory
2014-03-23 17:00:29 +02:00
Michael Widenius
b18a1b0e6c MDEV-5850: MySQL Bug#21317: SHOW CREATE DATABASE does not obey to lower_case_table_names
Bug #3329 Incomplete lower_case_table_names=2 implementation

The problem was that check_db_name() converted database names to lower case also in case of lower_case_table_names=2.

Fixed by removing the conversion in check_db_name for lower_case_table_names = 2 and instead converting db name to
lower case at same places as table names are converted.

Fixed bug that SHOW CREATE DATABASE FOO showed information for database 'foo'.

I also removed some checks of lower_case_table_names when it was enough to use table_alias_charset.


mysql-test/mysql-test-run.pl:
  Added --use-copy argument to force mysql-test-run to copy files instead of doing symlinks. This is needed when you run
  with test directory on another file system
mysql-test/r/lowercase_table.result:
  Updated results
mysql-test/r/lowercase_table2.result:
  Updated results
mysql-test/suite/parts/r/partition_mgm_lc2_innodb.result:
  Updated results
mysql-test/suite/parts/r/partition_mgm_lc2_memory.result:
  Updated results
mysql-test/suite/parts/r/partition_mgm_lc2_myisam.result:
  Updated results
mysql-test/t/lowercase_table.test:
  Added tests with mixed case databases
mysql-test/t/lowercase_table2.test:
  Added tests with mixed case databases
sql/log.cc:
  Don't check lower_case_table_names when we can use table_alias_charset
sql/sql_base.cc:
  Don't check lower_case_table_names when we can use table_alias_charset
sql/sql_db.cc:
  Use cmp_db_names() for checking if current database changed.
  mysql_rm_db() now converts db to lower case if lower_case_table_names was used.
  Changed database options cache to use table_alias_charset. This fixed a bug where SHOW CREATE DATABASE showed wrong information.
sql/sql_parse.cc:
  Change also db name to lower case when file names are changed.
  Don't need to story copy of database name anymore when lower_case_table_names == 2 as check_db_name() don't convert in this case.
  Updated arguments to mysqld_show_create_db().
  When adding table to TABLE_LIST also convert db name to lower case if needed (same way as we do with table names).
sql/sql_show.cc:
  mysqld_show_create_db() now also takes original name as argument for output to user.
sql/sql_show.h:
  Updated prototype for mysqld_show_create_db()
sql/sql_table.cc:
  In mysql_rename_table(), do same conversions to database name as we do for the file name
2014-03-23 15:43:57 +02:00
Alexander Barkov
63d0918807 MDEV-5783 Assertion `0' failed in make_sortkey(SORTPARAM*, uchar*, uchar*) on ORDER BY HEX( UNCOMPRESSED_LENGTH( pk ) ) 2014-03-23 16:02:56 +04:00
Sergey Petrunya
79a8a6130b Code cleanup:
- Move [some] engine-agnostic tests from t/selectivity.test to t/selectivity_no_engine.test
- Move Histogram::point_selectivity to sql_statistics.cc
2014-03-27 13:08:00 +04:00
Sergey Petrunya
0d67aafaa2 Merge 2014-03-27 12:37:05 +04:00
Sergey Petrunya
ab061a2bb3 MDEV-5926, MDEV-4362 post-fixes:
- Histogram::find_bucket() should not walk off the end of the value range.
- Address review feedback in Histogram::point_selectivity(): different handling
  for zero-width buckets, and explanations.
2014-03-27 12:30:49 +04:00
Sergei Golubchik
97687f2888 Fix hostcache_ipv4_blocked and hostcache_ipv6_blocked to pass.
Don't abort plugin reads whem mpvio->make_it_fail is set - this can leak information.
2014-03-26 22:32:10 +01:00
Sergei Golubchik
10740939eb 5.5 merge 2014-03-26 22:25:38 +01:00
Sergei Golubchik
44002a34e6 MDEV-5955 Server crashes in handler::ha_external_lock or assertion `m_lock_type == 2' fails in handler::ha_close on disconnect with a locked temporary table
first unlock locked tables, then close and remove temporary
2014-03-26 19:56:23 +01:00
Sergey Petrunya
dee11f9633 MDEV-4362: {division by zero when lookup constant is outside the value table}
- Fix Histogram::point_selectivity() to work in the case where the 
  passed value_pos=0 (or 1) and the first (or the last) bucket in the 
  histogram has zero value-range (i.e one value).
2014-03-26 21:05:31 +04:00
Sergey Petrunya
ad842b5f05 MDEV-5926: EITS: Histogram estimates for column=least_possible_value are wrong
[Attempt #2]
- Use a new selectivity calculation formula in Histogram::point_selectivity. 
  The formula is different from the old one because it was developed from scratch.
  it doesn't have any possible division-by-zero problems.
2014-03-26 17:55:00 +04:00
Sergei Golubchik
a91c59c2af MDEV-5920 MySQL Bug#16765410 FTS: STACK AROUND THE VARIABLE 'MYSTR' WAS CORRUPTED IN INNOBASE_STRNXFRM 2014-03-26 09:43:02 +01:00
Sergei Golubchik
319bcde937 MDEV-5861 MySQL Bug#12601974 - STORED PROCEDURE SQL_MODE=NO_BACKSLASH_ESCAPES IGNORED AND BREAKS REPLICATION
escape usernames in CREATE/DROP USER error messages according to NO_BACKSLASH_ESCAPES
2014-03-26 09:42:52 +01:00
Sergei Golubchik
88ec8a08f3 MDEV-5909 MySQL BUG#11748924 PARTITIONS: TOO-LONG COMMENT CAUSES NO WARNING 2014-03-26 09:41:28 +01:00
Sergei Golubchik
11b498d6e0 build_frm_image(): don't try to guess the "real table name" from the
field list, it doesn't work if ALTER TABLE has replaced all fields.
Instead, pass the correct original table name down from the caller.
2014-03-26 09:41:16 +01:00
Sergei Golubchik
1b468ca675 MDEV-5815 MySQL BUG#11751736: DROP DATABASE STATEMENT SHOULD REMOVE .OLD SUFFIX FROM DATABASE DIRECTORY
Delete .OLD and .TMD files when a MyISAM table is dropped.
Same for Aria.

sql/sql_db.cc:
  dead code - *.TMD cannot be deleted from here.
2014-03-26 09:32:54 +01:00
Sergei Golubchik
21a17536c6 5.3 merge 2014-03-25 11:09:12 +01:00
Sergei Golubchik
a52e2c787d MDEV-5823 MySQL bug#11760213-52599: ALTER TABLE REMOVE PARTITIONING ON NON-PARTITIONED TABLE CORRUPTS MYISAM
add the test case only
2014-03-21 14:05:44 +01:00
Sergey Petrunya
e59dec0345 MDEV-5917: EITS: different order of predicates in IN (...) causes different estimates
- Forgot to update one .result file.
2014-03-21 15:42:37 +04:00
Sergei Golubchik
3bb249612f MDEV-5846 MySQL Bug #18144 - Cost with FORCE/USE index seems incorrect in some cases. 2014-03-20 23:27:08 +01:00
Sergei Golubchik
dee0fd4233 MDEV-5820 MySQL Bug #54805 definitions in regex/my_regex.h conflict with /usr/include/regex.h 2014-03-20 23:26:50 +01:00
Sergei Golubchik
7b1b744f53 MDEV-5849 MySQL bug#12602983 - User without privilege on routine can discover its existence by executing "select non_existing_func();" or by "call non_existing_proc()"
add or move privilege checks before existence checks
2014-03-20 23:26:41 +01:00
Sergey Petrunya
0e211841f2 MDEV-5917: EITS: different order of predicates in IN (...) causes different estimates
- Save range key before making field->pos_in_interval() call (like we do for non-equality ranges)
2014-03-21 00:53:41 +04:00
Sergei Golubchik
9ff0c9f730 MDEV-5858 MySQL Bug#12744991 - DECIMAL_ROUND(X,D) GIVES WRONG RESULTS WHEN D == N*(-9)
don't use mysql-5.6 change.
correct fix: zero-out rounded tail after the number was shifted because
of the carry digit (otherwise the carry digit will be zeroed out too).
2014-03-20 09:50:45 +01:00
Sergei Golubchik
47f438675b MDEV-5894 MySQL BUG#34750: Print database name in Unknown Table error message 2014-03-20 00:44:35 +01:00
Michael Widenius
f71dc02e67 Automatic merge 2014-03-20 01:07:01 +02:00
Igor Babaev
d51ee6d412 Merge. 2014-03-19 14:58:29 -07:00
Sergei Golubchik
9418bd9c21 MDEV-5898 FOUND_ROWS() return incorrect value when using DISTINCT
revert the fix for MDEV-5549, use a different approach.
2014-03-19 20:33:12 +01:00
Michael Widenius
913d1f199c MDEV-5854 Interrupted CREATE OR REPLACE is written into binlog, and in a wrong format
mysql-test/r/create_or_replace2.result:
  Added test case
mysql-test/t/create_or_replace.test:
  Fixed comment
mysql-test/t/create_or_replace2.test:
  Added test case
sql/sql_base.cc:
  Safety fix:
  Don't let threads with query_id=0 free temporary tables as this may free temporary tables not in use.
  This is mostly the case for the slave io threads, as most other threads has thd->query_id != 0.
sql/sql_table.cc:
  Added comment.
  Ignore kill when opening temporary table for CREATE ... LIKE.
  This fixed the original isue
2014-03-19 15:15:57 +02:00
unknown
e7704bfdd6 RBR triggers compiled-out with ifdefs in 10.0 2014-03-19 11:35:32 +02:00
unknown
af3180ab6f MDEV-9095: Executing triggers on slave in row-based replication 2014-03-19 11:00:56 +02:00
Alexander Barkov
ce3c457e6d MDEV-5781 Item_sum_std::val_real(): Assertion `nr >= 0.0' fails on query with STDDEV_POP, ROUND and variable 2014-03-23 19:43:01 +04:00
Alexander Barkov
92bd6801b9 A joint patch for:
- MDEV-5689 ExtractValue(xml, 'substring(/x,/y)') crashes
- MDEV-5709 ExtractValue() with XPath variable references returns wrong result.

Description:

1. The main problem was that that nodeset_func->fix_fields() was
called in Item_func_xml_extractvalue::val_str() and
Item_func_xml_update::val_str(), which led in some cases to
execution of the XPath engine *before* having a parsed XML value.
Moved to Item_xml_str_func::fix_fields().

2. Cleanup: added a new method Item_xml_str_func::fix_fields() and moved
most of the code from Item_xml_str_func::fix_length_and_dec()
to Item_xml_str_func::fix_fields(), to follow the usual Item layout.

3. Cleanup: a parsed XML value is useless without the raw XML value
it was built from.

Previously the parsed and the raw values where stored in separate String
instances. It was hard to follow how they are synchronized.
Added a helper class XML which contains both parsed and raw values.
Makes things easier to read and modify.

4. MDEV-5709: const_item() could incorrectly return a "true"
result when XPath expression contains users/SP variable references.
Now nodeset_func->const_item() is also taken into account to
catch such cases.

5. Minor code enhancements.
2014-03-23 15:15:07 +04:00
Alexander Barkov
e0f75b1bff MDEV-5870 Assertion `ltime->neg == 0' fails with COALESCE, ADDDATE, MAKEDATE
A huge number in the "day" part of an interval made the code to return
a negative date erroneously. Adding a test to return an error on a too
large "day" value.
2014-03-23 14:22:44 +04:00
Igor Babaev
887a210ffc Fixed bug mdev-5931.
After constant table row substitution the where condition may be converted
to always true. The function calculate_cond_selectivity_for_table() should
take into account this possibility.
2014-03-22 12:44:39 -07:00
Praveenkumar Hulakund
95e99e1263 Bug#11759519 - INFINITE HANG WITH 100% CPU USAGE WITH LOAD DATA
LOCAL AND IMPORT ERRORS

Description:
-----------
This bug happens due to the fact that current algorithm is designed
that in the case of LOCAL load of data, in case of the error, the
remaining part of the file is read in order to return the proper
error message to the client side.

But, the problem with current implementation is that data stream
for the client side is cleared only in the case where line delimiters
exist, which is not a case with, for example fixed width
fields.

Fix:
----
Ported patch provided by Sinisa Milivojevic n bug report for this
issue to 5.5+ versions.

As part of this patch code is changed to clear the data stream
by calling new member function "READ_INFO::skip_data_till_eof".
2014-03-19 12:30:30 +05:30
Igor Babaev
06ef0bdad2 Fixed bug mdev-5191.
Corrected cost estimates when a join buffer is used and the optimizer is requested
to use condition selectivities.
2014-03-18 11:30:50 -07:00
Sergey Petrunya
8dae5a8a89 Merge 2014-03-18 12:06:32 +04:00
Sergey Petrunya
727896df27 Merge 2014-03-17 13:45:56 +04:00
unknown
4e1a928d18 Fix missing .result file update before push. 2014-03-17 09:44:17 +01:00
Sergei Golubchik
5d0c01608c 5.2 merge 2014-03-16 21:03:01 +01:00
Sergei Golubchik
5d8c15228e 5.3-merge 2014-03-16 19:21:37 +01:00
Sergey Petrunya
07a52afd00 MDEV-4410: update does not want to use a covering index, but select uses it
- If an UPDATE 1) modifies the key it is using, and 2) has ORDER BY ... LIMIT
  which matches the key it is using,  Then we should use "Using buffer", not
  "Using filesort".
2014-03-16 14:33:37 +01:00
Sergei Golubchik
e772cbd7b7 5.1 merge 2014-03-16 13:59:44 +01:00
Sergei Golubchik
d7304375e5 mysql-5.1.73 merge 2014-03-15 18:24:15 +01:00
Sergey Petrunya
365ba070fe MDEV-5814: MySQL Bug#13948247 DIVISION BY 0 IN GET_BEST_DISJUNCT_QUICK WITH FORCE INDEX GROUP BY
- Adopt MySQL's fix: don't run index_merge optimizer if the table statistics 
  reports that the table has 0 rows.
2014-03-14 18:52:16 +01:00
Sergey Petrunya
43a43b8289 Merge 2014-03-14 17:23:13 +01:00
unknown
5c8ed7dd54 MDEV-5446: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' fails on EXPLAIN EXTENDED with VALUES function
field_index should be set correctly for null field created by Item_insert_value::fix_fields().
2014-03-14 11:38:17 +02:00
unknown
f9b3cc11bc MDEV-5819: MySQL Bug #13500371 63704: CONVERSION OF '1.' TO A NUMBER GIVES ERROR 1265 (WARN_DATA_TRUNCATED)
Fix by MySQL ported
2014-03-14 09:31:16 +02:00
Sergei Golubchik
a0ea960c3e 5.2 merge 2014-03-13 18:36:52 +01:00
Sergei Golubchik
5616bd5597 unix_socket bypasses make_if_fail by not doing any network reads 2014-03-13 16:35:14 +01:00
Sergey Petrunya
8c04dd33dd MDEV-5811: Server crashes in best_access_path with materialization+semijoin and big_tables=ON
- With big_tables=ON, materialized table will use Aria (or MyISAM) SE, which
  allows prefix key reads. However, the temp.table has rec_per_key=NULL which
  causes the optimizer to crash when attempting to read index statistics for a 
  prefix index read.
- Fixed by providing a rec_per_key array with zeros (i.e. "no statistics data")
2014-03-13 12:20:57 +01:00
unknown
70c08df4dc MDEV-5840: group_concat( column_json(dynamic_column )) return empty result
Fixed max_length of dynamic columns json/create/add functions.
2014-03-13 10:38:41 +02:00
Sergei Golubchik
8940611079 update test results 2014-03-12 12:34:47 +01:00
Sergei Golubchik
4e29d31c58 typo fixed 2014-03-12 12:34:36 +01:00
unknown
d8ea8a3d13 MDEV-5717: Server crash with insert statement containing DEFAULT into view
Item_default_value::arg can be NULL so walk() should take it into consideration.
2014-03-12 12:34:16 +02:00
Michael Widenius
f320b12ca5 MDEV-5619: CREATE OR REPLACE does not release MDL_EXCLUSIVE upon failure
mysql-test/r/create_or_replace.result:
  Added test of releasing of metadata locks
mysql-test/t/create_or_replace.test:
  Added test of releasing of metadata locks
sql/handler.h:
  Added marker if table was deleted as part of CREATE OR REPLACE
sql/sql_base.cc:
  Added Locked_tables_list::unlock_locked_table()
sql/sql_class.h:
  New prototypes
sql/sql_insert.cc:
  Unlock metadata locks for deleted table in case of error. Also do unlock tables if this was the only locked table.
sql/sql_table.cc:
  Unlock metadata locks for deleted table in case of error. Also do unlock tables if this was the only locked table.
2014-03-12 11:26:40 +02:00
unknown
8b9b7ec395 MDEV-5804: If same GTID is received on multiple master connections in multi-source replication, the event is double-executed causing corruption or replication failure
Some fixes, mainly to make it work in non-parallel replication mode also
(--slave-parallel-threads=0).

Patch should be fairly complete now.
2014-03-12 00:14:49 +01:00
Elena Stepanova
5c31e79f8b create_or_replace test failed with embedded-server due to different
thread IDs
2014-03-15 16:56:35 +04:00
Sergey Petrunya
908fa69da9 Bug #13571700 TINYBLOB NOT NULL, CRASH IN PROTOCOL::NET_STORE_DATA
- Backport testcase from mysql-5.6
2014-03-07 13:21:16 +01:00
Sergey Petrunya
5ba109c4f6 Bug#45227: Lost HAVING clause led to a wrong result.
- Backport testcase from mysql-5.6
2014-03-07 13:14:58 +01:00
Sergey Petrunya
f20cab1a83 BUG#13803810: TOO FEW ROWS RETURNED FOR RANGE ACCESS IN VARCHAR INDEX USING DATETIME VALUE
- Backport the testcase from mysql-5.6
2014-03-07 13:00:20 +01:00
unknown
321ff25f3d MDEV-5740: Assertion `!derived->first_select()->exclude_from_table_unique_test || derived->outer_select()-> exclude_from_table_unique_test' failed on 2nd execution of PS with derived_merge
Do not check tables of executed units.
Debug info about stages of derived tables execution added.
2014-03-07 13:57:07 +02:00
Sergey Petrunya
7af71b74a9 BUG#13731380: RANGE OPTIMIZER CALLS RECORDS_IN_RANGE() FOR OPEN RANGE
- Backport testcase from mysql-5.6
2014-03-07 12:49:40 +01:00
Michael Widenius
3b55c2fe21 Fixed MDEV-5724 "Server crashes on SQL select containing more group by and left join statements using innodb tables"
The problem was that a big record was allocated on the stack, which casued stack to run out.

Fixed by using my_safe_alloca() instead of my_alloca() when allocating records.
Now only records <= 16384 are allocated on the stack.

mysql-test/r/stack-crash.result:
  Added test case
mysql-test/t/stack-crash.test:
  Added test case
storage/maria/ma_blockrec.c:
  Use my_safe_alloca() instead of my_alloca()
storage/maria/ma_dynrec.c:
  Use my_safe_alloca() instead of my_alloca()
storage/maria/maria_def.h:
  Added MARIA_MAX_RECORD_ON_STACK
storage/maria/maria_pack.c:
  Use my_safe_alloca() instead of my_alloca()
2014-03-10 21:14:38 +02:00
Michael Widenius
b07f9f72dc Fixed MDEV-5780 "create-big fails in 10.0"
The issue was that create...trigger part of the test suite used a debug_sync point that before was never triggered (in other words, wrong meaningless test).
With the new create ... replace code the debug sync point is triggered and the test case could not handled that.

I fixed this by adding a wait and go for the debug syncpoint in the test.

Removed some compiler warnings from mysql_cond_timedwait


include/mysql/psi/mysql_thread.h:
  Removed compiler warnings
mysql-test/r/create-big.result:
  New test result
mysql-test/t/create-big.test:
  Fixed test case as create_table_select_before_check_if_exists was not before triggered by the code.
2014-03-10 14:08:12 +02:00
Sergei Golubchik
12f54d7de0 @@old_mode=zero_date_time_cast 2014-03-07 21:05:28 +01:00
Sergei Golubchik
a5fdd75980 XtraDB made the default 2014-03-07 15:21:07 +01:00
Igor Babaev
1f2ef57403 Fixed bug mdev-5686.
The calls of the function remove_eq_conds() may change the and/or structure
of the where conditions. So JOIN::equal_cond should be updated for non-recursive
calls of remove_eq_conds().
2014-03-06 13:56:34 -08:00
Alexander Barkov
89e1715355 MDEV-5372 Make "CAST(time_expr AS DATETIME)" compatible with MySQL-5.6 (and the SQL Standard) 2014-03-07 00:21:25 +04:00
Sergey Vojtovich
b95c8ce530 MDEV-5675 - Performance: my_hash_sort_bin is called too often
Reduced number of my_hash_sort_bin() calls from 4 to 1 per query.
Reduced number of memory accesses done by my_hash_sort_bin().

Details:
- let MDL subsystem use pre-calculated hash value for hash
  inserts and deletes
- let table cache use pre-calculated MDL hash value
- MDL namespace is excluded from hash value calculation, so that
  hash value can be used by table cache as is
- hash value for MDL is calculated as resulting hash value + MDL
  namespace
- extended hash implementation to accept user defined hash function
2014-03-06 16:19:12 +04:00
Sergei Golubchik
4c788b06d4 10.0-base merge 2014-03-05 23:20:10 +01:00
Sergey Petrunya
64649e3393 MDEV-5723: mysqldump -uroot unusable for multi-database operations, checks all databases
- Make do_fill_table() use join_tab->cache_select->cond if it is present.  When 
  join_tab->cache_select->cond is present, join_tab->select_cond doesn't have any 
  conditions that are usable for I_S optimizations.
2014-03-04 15:14:40 +04:00
Sergei Golubchik
eb9f422c43 MDEV-5667 online alter and changed field/index options
use the Alter_inplace_info::ALTER_COLUMN_OPTION flag if
field/column flags were altered.

change ha_example to use check_if_supported_inplace_alter() instead
of obsolete check_if_incompatible_data()
2014-03-02 15:02:13 +01:00
Alexander Barkov
f467f4bb93 MDEV-5459 Illegal mix of collations for datetime 2014-04-28 17:01:58 +04:00
Alexander Barkov
1081e403c6 MDEV-5702 Incorrect results are returned with NULLIF() 2014-04-28 15:56:31 +04:00
unknown
968f4d4e25 MDEV-6139: UPDATE w/ join against MRG_MyISAM table with read-only sub-table failsUPDATE w/ join against MRG_MyISAM table with read-only sub-table fails
The problem was that on opening all tables TL_WRITE, than local tables which is not updated set to TL_READ, but underlying tables of MyISAMmrg left untouched.

Prartition engine has not this problem.

All cases where lock_type assigned is not changed because call of virtual function is not cheap.
2014-04-28 09:13:53 +03:00
Elena Stepanova
64d7c97db9 MDEV-6178 mysql_upgrade breaks databases with long user names
Added a 5.5-specific test which involves manual modification of system
tables. The problem itself was fixed in MDEV-6068
2014-04-28 02:56:53 +04:00
Elena Stepanova
4ccea172ff MDEV-6169 main.myisam-metadata fails mtr internal check
The test didn't clean debug_sync
2014-04-26 23:16:51 +04:00
Michael Widenius
b17a053cc9 MDEV-6129: Server crashes during UNION with ORDER BY field IS NULL
Fixed crashing bug for union queries where there was no real tables.


mysql-test/r/group_by.result:
  Added test case
mysql-test/t/group_by.test:
  Added test case
sql/db.opt:
  Removed genrated file
sql/item.cc:
  Handled case when table_list->pos_in_tables is not set. Can only happens when there is no real tables in query
2014-04-24 18:20:57 +03:00
Alexander Barkov
64d33032a6 Merge 5.3->5.5 2014-04-23 17:43:20 +04:00
Alexander Barkov
2f93e7cf47 MDEV-6146 Can't mix (latin1_swedish_ci,NUMERIC) and (utf8_unicode_ci,IMPLICIT) for MATCH 2014-04-23 10:28:06 +04:00
Alexander Barkov
31c82360e4 Merge from 5.3 2014-04-21 14:22:18 +04:00
Alexander Barkov
f5b73fe3f1 Merge from 5.3. 2014-04-21 12:19:47 +04:00
Alexander Barkov
1c6d508a2b Merge from 5.3 2014-04-18 13:41:15 +04:00
Alexander Barkov
f7a47e137b Merge from 5.3 2014-04-18 12:16:56 +04:00
Alexey Botchkov
365960a068 MDEV-5138 Numerous test failures in "mtr --ps --embedded".
As Davi added code like
          sav_protocol= thd->protocol
          thd->protocol= &thd->protocol_binary
          ...
          thd->protocol= sav_protocol
  the fucntions like emb_store_querycache_result() cannot determine
  the used protocol testing thd->protocol == &thd->protocol_binary.
  Fixed by additional check thd->command == COM_STMT_EXECUTE.
2014-04-15 18:09:58 +05:00
unknown
05722f06b2 MDEV-5991: crash in Item_field::used_tables
Units of subqueroes from excluded expressions should be excluded from select_lex/select_unit tree.
2014-04-15 13:20:26 +03:00
Sergei Golubchik
27a26acb1c MDEV-5700 Cannot SHOW CREATE VIEW if underlying tabels are ALTERed 2014-04-10 15:07:34 +02:00
Sergei Golubchik
32b3c9f35d Make THDVAR_INT variables to be signed in SELECT in SHOW 2014-04-09 14:28:07 +02:00
Sergei Golubchik
5f0c98c17b MDEV-5743 Server crashes in mysql_alter_table on an attempt to add a primary key to InnoDB table 2014-04-07 21:53:19 +02:00
Sergei Golubchik
cb67dcb618 mysql-5.5.37 selective merge 2014-03-27 22:26:58 +01:00
Sergei Golubchik
41c760b121 merge 2014-02-28 10:00:31 +01:00
Igor Babaev
1a536c8daf Fixed bug mdev-5635.
After constant row substitution some field items become constant items.
The range analyzer should take into account this fact when looking for
ranges.
2014-02-27 13:54:05 -08:00
Sergey Petrunya
472bc477f6 Merge 2014-02-27 13:43:06 +04:00
Sergey Petrunya
d7081b2524 Update test results after fix for MDEV-5732 2014-02-27 13:40:40 +04:00
unknown
6d3150c48d Merge MDEV-5657 (parallel replication) to 10.0-base 2014-02-26 17:03:32 +01:00
unknown
20959fa09c Merge MDEV-5657 (parallel replication) to 10.0 2014-02-26 16:38:42 +01:00
Sergei Golubchik
0dc23679c8 10.0-base merge 2014-02-26 15:28:07 +01:00
unknown
e90f68c0ba MDEV-5657: Parallel replication.
Clean up and improve the parallel implementation code, mainly related to
scheduling of work to threads and handling of stop and errors.

Fix a lot of bugs in various corner cases that could lead to crashes or
corruption.

Fix that a single replication domain could easily grab all worker threads and
stall all other domains; now a configuration variable
--slave-domain-parallel-threads allows to limit the number of
workers.

Allow next event group to start as soon as previous group begins the commit
phase (as opposed to when it ends it); this allows multiple event groups on
the slave to participate in group commit, even when no other opportunities for
parallelism are available.

Various fixes:

 - Fix some races in the rpl.rpl_parallel test case.

 - Fix an old incorrect assertion in Log_event iocache read.

 - Fix repeated malloc/free of wait_for_commit and rpl_group_info objects.

 - Simplify wait_for_commit wakeup logic.

 - Fix one case in queue_for_group_commit() where killing one thread would
   fail to correctly signal the error to the next, causing loss of the
   transaction after slave restart.

 - Fix leaking of pthreads (and their allocated stack) due to missing
   PTHREAD_CREATE_DETACHED attribute.

 - Fix how one batch of group-committed transactions wait for the previous
   batch before starting to execute themselves. The old code had a very
   complex scheduling where the first transaction was handled differently,
   with subtle bugs in corner cases. Now each event group is always scheduled
   for a new worker (in a round-robin fashion amongst available workers).
   Keep a count of how many transactions have started to commit, and wait for
   that counter to reach the appropriate value.

 - Fix slave stop to wait for all workers to actually complete processing;
   before, the wait was for update of last_committed_sub_id, which happens a
   bit earlier, and could leave worker threads potentially accessing bits of
   the replication state that is no longer valid after slave stop.

 - Fix a couple of places where the test suite would kill a thread waiting
   inside enter_cond() in connection with debug_sync; debug_sync + kill can
   crash in rare cases due to a race with mysys_var_current_mutex in this
   case.

 - Fix some corner cases where we had enter_cond() but no exit_cond().

 - Fix that we could get failure in wait_for_prior_commit() but forget to flag
   the error with my_error().

 - Fix slave stop (both for normal stop and stop due to error). Now, at stop
   we pick a specific safe point (in terms of event groups executed) and make
   sure that all event groups before that point are executed to completion,
   and that no event group after start executing; this ensures a safe place to
   restart replication, even for non-transactional stuff/DDL. In error stop,
   make sure that all prior event groups are allowed to execute to completion,
   and that any later event groups that have started are rolled back, if
   possible. The old code could leave eg. T1 and T3 committed but T2 not, or
   it could even leave half a transaction not rolled back in some random
   worker, which would cause big problems when that worker was later reused
   after slave restart.

 - Fix the accounting of amount of events queued for one worker. Before, the
   amount was reduced immediately as soon as the events were dequeued (which
   happens all at once); this allowed twice the amount of events to be queued
   in memory for each single worker, which is not what users would expect.

 - Fix that an error set during execution of one event was sometimes not
   cleared before executing the next, causing problems with the error
   reporting.

 - Fix incorrect handling of thd->killed in worker threads.
2014-02-26 15:02:09 +01:00
Sergei Golubchik
0b9a0a3517 5.5 merge 2014-02-25 16:04:35 +01:00
Sergey Petrunya
6324c36bd7 Update test results after the previous push 2014-02-25 13:01:57 +04:00
Sergey Petrunya
fb6183a80b MDEV-5244: Make extended_keys=ON by default in 10.0
- Change the default flag value to ON.
- Update the testcases to be run extended_keys=ON:
  = trivial test result updates
  = If extended_keys setting makes a difference for a testcase, run the testcase 
    with extended_keys=off. There were only a few such cases
- Update to vcol_select_innodb looks like a worse plan but it will be gone in 10.0.
2014-02-25 01:18:13 +04:00
Sergei Golubchik
ff2e82f4a1 5.3 merge 2014-02-22 22:51:20 +01:00
Igor Babaev
3e03c9eae9 After constant row substitution the optimizer should call the method
update_used_tables for the the where condition to update cached
indicators of constant subexpressions. It should be done before further
possible simplification of the where condition.

This change caused simplification of the executed where conditions 
in many test cases.
2014-02-20 21:27:33 -08:00
Sergei Golubchik
74feebcd43 MDEV-5624 mysqldump --dump-slave option does not restart the replication if the dump has failed 2014-02-21 00:53:02 +01:00
Sergey Petrunya
6ebaa4939e Backport the following from 5.5 to 5.3:
MDEV-4556 Server crashes in SEL_ARG::rb_insert with index_merge+index_merge_sort_union, FORCE INDEX
- merge_same_index_scans() may put the same SEL_ARG tree in multiple result plans.
  make it call incr_refs() on the SEL_ARG trees that it does key_or() on, because 
  key_or(sel_arg_tree_1, sel_arg_tree_2) call may invalidate SEL_ARG trees pointed 
  by sel_arg_tree_1 and sel_arg_tree_2.
2014-02-19 18:34:12 +04:00
Alexey Botchkov
84580f950c MDEV-5481 mysqldump fails to dump geometry types properly.
Fixed so the MYSQL_TYPE_GEOMETRY is treated as BLOB.
2014-02-18 17:45:08 +04:00
Alexey Botchkov
820b1a6687 MDEV-5615 crash in Gcalc_function::add_operation.
The result is EMPTY for a buffer(line, -1), but we still
need one FALSE operation to be stored in the condition.
And we actually add it but forgot to alloc memory to store it.
2014-02-18 17:15:25 +04:00
Sergey Petrunya
b594e31b6b Merge 2014-02-17 18:53:54 +04:00
Sergey Petrunya
df963fd3c7 MDEV-5177: ha_partition and innodb index intersection produce fewer rows (MySQL Bug#70703)
MDEV-5555: Incorrect index_merge on BTREE indices
- In ha_partition, make ordered index reads return rows in rowid order
  when index columns are the same.
2014-02-17 18:50:54 +04:00
Sergei Golubchik
4881c65007 test case for
MDEV-5689 ExtractValue(xml, 'substring(/x,/y)') crashes
MySQL bug#12428404 MYSQLD.EXE CRASHES WHEN EXTRACTVALUE() IS CALLED WITH MALFORMED XPATH EXP
2014-02-17 11:09:24 +01:00
Sergei Golubchik
84651126c0 MySQL-5.5.36 merge
(without few incorrect bugfixes and with 1250 files where only a copyright year was changed)
2014-02-17 11:00:51 +01:00
Sergey Petrunya
8c9b2f3429 MDEV-5581: Server crashes in in JOIN::prepare on 2nd execution of PS with materialization+semijoin
- The problem was that JOIN::prepare() tried to set TABLE::maybe_null
  for a table in join. Non-merged semi-join tables 1) are present as 
  join's base tables on second EXECUTE, but 2) do not yet have a TABLE 
  object.
  Worked around the problem by putting mixed_implicit_grouping into JOIN
  object, and then passing it to JTBM tables in setup_jtbm_semi_joins().
2014-02-15 01:21:46 +04:00
Sergei Golubchik
fb27ce22f7 5.3 merge 2014-02-14 14:09:29 +01:00
Sergei Golubchik
12253abadb MDEV-714 LP:1020645 - crash (sig 11) with union query
Don't ignore the error from st_select_lex_unit::optimize()
2014-02-13 20:21:57 +01:00
Sergei Golubchik
4b57720caa use a different error for MySQL bug#11747970 - kill the query,
as it was supposed to be in bug#11747970, don't fake an error.
(this kill can be useful for other bugs too)
2014-02-13 20:20:17 +01:00
Sergey Vojtovich
e2a99f1863 MDEV-5616 - Deadlock between CREATE/DROP FUNCTION and SELECT from view
Deadlock happened due to mixed lock order.
CREATE/DROP function: wrlock(THR_LOCK_udf) -> lock(LOCK_open)
SELECT from view: lock(LOCK_open) -> rdlock(THR_LOCK_udf)

Fixed CREATE/DROP function so that LOCK_open does not intersect with
wrlock(THR_LOCK_udf).

10.0 is not affected: it doesn't hold LOCK_open while opening view.
2014-02-13 16:41:08 +04:00
Sergei Golubchik
913beda8c8 5.2 merge 2014-02-13 10:15:03 +01:00
Sergey Petrunya
5611c0e29d Merge 2014-03-11 17:14:48 +01:00
Sergey Petrunya
cb5b6c7e39 MDEV-5177: ha_partition and innodb index intersection produce fewer rows (MySQL Bug#70703)
(This is attempt at fix #2) (re-commit with fixed typo)
- Moved the testcase from partition_test to partition_innodb.test where it can really work.
- Made ordered index scans over ha_partition tables to satisfy ROR property for 
  the case where underlying table uses extended keys.
2014-03-11 16:45:08 +01:00
Michael Widenius
f031f0ae67 Fixed test failure (5.5 had different test result than 10.0) 2014-03-11 17:37:46 +02:00
Michael Widenius
599eb0dc86 Fixed MDEV-5724 "Server crashes on SQL select containing more group by and left join statements using innodb tables"
The problem was that a big record was allocated on the stack, which casued stack to run out.
  
Fixed by using my_safe_alloca() instead of my_alloca() when allocating records.
Now only records <= 16384 are allocated on the stack.

mysql-test/r/stack-crash.result:
  Added test case
mysql-test/t/stack-crash.test:
  Added test case
storage/maria/ma_blockrec.c:
  Use my_safe_alloca() instead of my_alloca()
storage/maria/ma_dynrec.c:
  Use my_safe_alloca() instead of my_alloca()
storage/maria/maria_def.h:
  Added MARIA_MAX_RECORD_ON_STACK
storage/maria/maria_pack.c:
  Use my_safe_alloca() instead of my_alloca()
2014-03-10 21:40:27 +02:00
Sergei Golubchik
48445f3556 5.1 merge 2014-02-13 08:25:33 +01:00
Sergei Golubchik
52f038c5c3 MDEV-5655 Server crashes on NAME_CONST containing AND/OR expressions
fix the NAME_CONST check to only allow literals, negated literals, and literals with
the explicit collation.
2014-02-12 21:17:28 +01:00
Sergey Petrunya
2f22e85d05 Backport from 10.0 to 10.0-base the following:
revision-id: psergey@askmonty.org-20140204092710-2yt5ysa5ej3l2c03
MDEV-5606: range optimizer: "x < y" is sargable, while "y > x" is not
Port to mariadb-1.0 the following fix from mysql-5.6:
      
Revision ID: jorgen.loland@oracle.com-20120314131055-ml54x9deueqfsff4
BUG#13701206: WHERE A>=B DOES NOT GIVE SAME EXECUTION PLAN
              AS WHERE B<=A (RANGE OPTIMIZER)
       
that fix didn't have a public testcase, so I created one.
2014-02-12 21:37:58 +04:00
unknown
528df1df45 MDEV-5505: Assertion `! is_set()' fails on PREPARE SELECT with out of range in GROUP BY
Fixed error processing in find_order_in_list(): if an error reported to user there is no sens to continue.
2014-02-12 17:07:05 +02:00
Neeraj Bisht
e13b28afdf Bug#17075846 - UNQUOTED FILE NAMES FOR VARIABLE VALUES ARE
ACCEPTED BUT PARSED INCORRECTLY

When we are setting the value in a system variable, 
We can set it like 

set sys_var="Iden1.Iden2";		//1
set sys_var='Iden1.Iden2';		//2
set sys_var=Iden1.Iden2;		//3
set sys_var=.ident1.ident2; 		//4
set sys_var=`Iden1.Iden2`;		//5


While parsing, for case 1(when ANSI_QUOTES is enable) and 2,
we will take as string literal(we will make item of type Item_string).
for case 3 & 4, taken as Item_field, where Iden1 is a table name and
iden2 is a field name.
for case 5, again Item_field type, where iden1.iden2 is taken as
field name.


Now in case 1, when we are assigning some value to system variable
(which can take string or enumerate type data), we are setting only 
field part.
This means only iden2 value will be set for system variable. This 
result in wrong result.

Solution:

(for string type) We need to Document that we are not allowed to set 
system variable which takes string as identifier, otherwise result 
in unexpected behaviour.

(for enumerate type)
if we pass iden1.iden2, we will give an error ER_WRONG_TYPE_FOR_VAR
(Incorrect argument type to variable).

mysql-test/suite/sys_vars/t/general_log_file_basic.test:
  Earlier we used to give ER_WRONG_VALUE_FOR_VAR error, but in the patch of
  (Bug32748-Inconsistent handling of assignments to general_log_file/slow_query_log_file)
  they quoted this line.But i am not able to find any relation of this with the changes of
  patch. So i think We should give error in this case.
mysql-test/suite/sys_vars/t/slow_query_log_file_basic.test:
  Earlier we used to give ER_WRONG_VALUE_FOR_VAR error, but in the patch of
  (Bug32748-Inconsistent handling of assignments to general_log_file/slow_query_log_file)
  they quoted this line.But i am not able to find any relation of this with the changes of
  patch. So i think We should give error in this case.
2014-02-12 14:33:56 +05:30
Igor Babaev
80a38b92d4 Fixed bug mdev-5630.
The function calculate_cond_selectivity_for_table() must consider
the case when the key range tree returned by the call of get_mm_tree()
is of the type SEL_TREE::ALWAYS.
2014-02-11 19:22:17 -08:00
Michael Widenius
103643d87a Changed " to ' around connection name (safer) 2014-02-12 00:06:44 +02:00
Michael Widenius
3474bb04ec Fixed that --apply-slave-statements also uses multi-source
mysql-test/r/rpl_mysqldump_slave.result:
  Updated test result
2014-02-11 23:41:56 +02:00
Michael Widenius
55829ac13d Support 6 digit version numbers in executable comment syntax.
This is needed to be able to ignore executable comments from version 10.0.
2014-02-11 21:43:08 +02:00
Michael Widenius
add6eb69a8 Fixed MDEV-4551: mysqldump --dump-slave fails with multi-source replication
When running with multi-source enabled master (MariaDB 10.0) all master will be recorded

mysql-test/r/rpl_mysqldump_slave.result:
  Updated results to new syntax
2014-02-11 19:42:18 +02:00
Michael Widenius
1bdf2151da Fixed MDEV-5617: mysqld crashes when running a query with ONLY_FULL_GROUP_BY
Problem was that we used cache_table in some cases where it was not initialized

mysql-test/r/func_group.result:
  Added test case
mysql-test/t/func_group.test:
  Added test case
sql/item.cc:
  Don't use cached_table if not set
sql/item_sum.cc:
  Don't use cached_table
2014-02-11 16:58:49 +02:00
Michael Widenius
67e8e926e9 Set default progress report time to 5 seconds
(Had accidently been set to 56 seconds in some merge)


sql/sys_vars.cc:
  Set default progress report time to 5 seconds
2014-02-11 16:56:38 +02:00
Igor Babaev
f17079fa7e Merge 5.3->5.5 2014-02-10 17:00:51 -08:00
Sergey Petrunya
cfbc545d1a Merge 2014-02-07 23:57:55 +04:00
Sergey Petrunya
34b6f51dab MDEV-5582: Plugin 'MEMORY' has ref_count=1 after shutdown with materialization+semijoin
- Let cleanup_empty_jtbm_semi_joins() walk into semi-join nests.
2014-02-07 20:51:31 +04:00
Sergei Golubchik
1b3c15f199 merge with 10.0-monty 2014-02-06 16:38:40 +01:00