Commit graph

177401 commits

Author SHA1 Message Date
Marko Mäkelä
206ecb79a5 Follow-up to MDEV-12289: Support innodb_undo_tablespaces=127
MySQL 5.7 reduced the maximum number of innodb_undo_tablespaces
from 126 to 95 when it reserved 32 persistent rollback segments
for the temporary undo logs. Since MDEV-12289 restored all 128
persistent rollback segments for persistent undo logs, the
reasonable maximum value of innodb_undo_tablespaces is 127
(not 126 or 95). This is because out of the 128 rollback segments,
the first one will always be created in the system tablespace
and the remaining ones can be created in dedicated undo tablespaces.
2017-04-26 23:03:28 +03:00
Marko Mäkelä
23ea4360fd Remove TRX_SYS_OLD_N_RSEGS 2017-04-26 23:03:27 +03:00
Marko Mäkelä
472b5f0d1f Follow-up to Bug#24346574 PAGE CLEANER THREAD, ASSERT BLOCK->N_POINTERS == 0
Silence the Valgrind warnings on instrumented builds (-DWITH_VALGRIND).

assert_block_ahi_empty_on_init(): A variant of
assert_block_ahi_empty() that declares n_pointers initialized and then
asserts that n_pointers==0.

In Valgrind-instrumented builds, InnoDB declares allocated memory
uninitialized.
2017-04-26 23:03:27 +03:00
Marko Mäkelä
e63ead68bf Bug#24346574 PAGE CLEANER THREAD, ASSERT BLOCK->N_POINTERS == 0
btr_search_drop_page_hash_index(): Do not return before ensuring
that block->index=NULL, even if !btr_search_enabled. We would
typically still skip acquiring the AHI latch when the AHI is
disabled, because block->index would already be NULL. Only if the AHI
is in the process of being disabled, we would wait for the AHI latch
and then notice that block->index=NULL and return.

The above bug was a regression caused in MySQL 5.7.9 by the fix of
Bug#21407023: DISABLING AHI SHOULD AVOID TAKING AHI LATCH

The rest of this patch improves diagnostics by adding assertions.

assert_block_ahi_valid(): A debug predicate for checking that
block->n_pointers!=0 implies block->index!=NULL.

assert_block_ahi_empty(): A debug predicate for checking that
block->n_pointers==0.

buf_block_init(): Instead of assigning block->n_pointers=0,
assert_block_ahi_empty(block).

buf_pool_clear_hash_index(): Clarify comments, and assign
block->n_pointers=0 before assigning block->index=NULL.
The wrong ordering could make block->n_pointers appear incorrect in
debug assertions. This bug was introduced in MySQL 5.1.52 by
Bug#13006367 62487: INNODB TAKES 3 MINUTES TO CLEAN UP THE
ADAPTIVE HASH INDEX AT SHUTDOWN

i_s_innodb_buffer_page_get_info(): Add a comment that
the IS_HASHED column in the INFORMATION_SCHEMA views
INNODB_BUFFER_POOL_PAGE and INNODB_BUFFER_PAGE_LRU may
show false positives (there may be no pointers after all.)

ha_insert_for_fold_func(), ha_delete_hash_node(),
ha_search_and_update_if_found_func(): Use atomics for
updating buf_block_t::n_pointers. While buf_block_t::index is
always protected by btr_search_x_lock(index), in
ha_insert_for_fold_func() the n_pointers-- may belong to
another dict_index_t whose btr_search_latches[] we are not holding.

RB: 13879
Reviewed-by: Jimmy Yang <jimmy.yang@oracle.com>
2017-04-26 23:03:27 +03:00
Thirunarayanan Balathandayuthapani
a6adf567fd Bug #23533396 ASSERTION !M_PREBUILT->TRX->CHECK_FOREIGNS
Analysis:
========
A foreign key constraint cannot reference a secondary index defined
on a generated virtual column. While adding new index/drop existing
column, server internally drops the internal foreign key index and
it leads to choose the virtual secondary index as foreign key index.
But innodb doesn't allow foreign key constraint reference to
secondary virtual index.

Fix:
===
Allow foreign key constraint refer to secondary index defined on
a generated virutal column.

Reviewed-by: Jimmy Yang<jimmy.yang@oracle.com>
RB: 13586
2017-04-26 23:03:27 +03:00
Marko Mäkelä
93078c9cb1 Bug#24444831 MY_ERROR(ER_INNODB_ONLINE_LOG_TOO_BIG) CALLED WITH INVALID INDEX NAME
This bug was introduced in MySQL 5.6.8 with WL#6255.
When an error occurs while rebuilding a table that only has a
hidden GEN_CLUST_INDEX inside InnoDB, ha_alter_info->key_info_buffer
would be invalid and should not be dereferenced.

get_error_key_name(): Get the name of an erroneous key.
Avoid dereferencing ha_alter_info->key_info_buffer when no keys
exist in the SQL layer.

ha_innobase::inplace_alter_table(),
ha_innobase::commit_try_rebuild(): Invoke get_error_key_name()
for reporting ER_INNODB_ONLINE_LOG_TOO_BIG or ER_INDEX_CORRUPT.

RB: 13834
Reviewed-by: Jimmy Yang <jimmy.yang@oracle.com>
2017-04-26 23:03:27 +03:00
Marko Mäkelä
9a848ee182 Fix the -DWITH_INNODB_AHI=OFF build 2017-04-26 23:02:53 +03:00
Marko Mäkelä
8080d79f7e Adjust a test for WL9513 Bug#23333990 2017-04-26 23:00:57 +03:00
Igor Babaev
c7a153453e Fixed the bug mdev-12556.
When the rows produced on the current iteration are sent to the
temporary table T of the UNION type created for CTE the rows
that were not there simultaneously are sent to the temporary
table D that contains rows for the next iteration. The test
whether a row was in T checks the return code of writing into T.
If just a HEAP table is used for T then the return code is
HA_ERR_FOUND_DUPP_KEY, but if an ARIA table is used for T then
the return code is HA_ERR_FOUND_DUPP_UNIQUE.
The implementation of select_union_recursive::send_data()
erroneously checked only for the first return code. So if an Aria
table was used for T then all rows produced by the current iteration
went to D and and in most cases D grew with each iteration.
Whether T has reached stabilization is detected by
checking whether D is empty. So as a result, the iterations were
never stopped unless a limit for them was set.

Fixed by checking for both HA_ERR_FOUND_DUPP_KEY and
HA_ERR_FOUND_DUPP_UNIQUE as return codes returned by
the function writing a row into the temporary table T.
2017-04-26 10:16:03 -07:00
Jan Lindström
765a43605a MDEV-12253: Buffer pool blocks are accessed after they have been freed
Problem was that bpage was referenced after it was already freed
from LRU. Fixed by adding a new variable encrypted that is
passed down to buf_page_check_corrupt() and used in
buf_page_get_gen() to stop processing page read.

This patch should also address following test failures and
bugs:

MDEV-12419: IMPORT should not look up tablespace in
PageConverter::validate(). This is now removed.

MDEV-10099: encryption.innodb_onlinealter_encryption fails
sporadically in buildbot

MDEV-11420: encryption.innodb_encryption-page-compression
failed in buildbot

MDEV-11222: encryption.encrypt_and_grep failed in buildbot on P8

Removed dict_table_t::is_encrypted and dict_table_t::ibd_file_missing
and replaced these with dict_table_t::file_unreadable. Table
ibd file is missing if fil_get_space(space_id) returns NULL
and encrypted if not. Removed dict_table_t::is_corrupted field.

Ported FilSpace class from 10.2 and using that on buf_page_check_corrupt(),
buf_page_decrypt_after_read(), buf_page_encrypt_before_write(),
buf_dblwr_process(), buf_read_page(), dict_stats_save_defrag_stats().

Added test cases when enrypted page could be read while doing
redo log crash recovery. Also added test case for row compressed
blobs.

btr_cur_open_at_index_side_func(),
btr_cur_open_at_rnd_pos_func(): Avoid referencing block that is
NULL.

buf_page_get_zip(): Issue error if page read fails.

buf_page_get_gen(): Use dberr_t for error detection and
do not reference bpage after we hare freed it.

buf_mark_space_corrupt(): remove bpage from LRU also when
it is encrypted.

buf_page_check_corrupt(): @return DB_SUCCESS if page has
been read and is not corrupted,
DB_PAGE_CORRUPTED if page based on checksum check is corrupted,
DB_DECRYPTION_FAILED if page post encryption checksum matches but
after decryption normal page checksum does not match. In read
case only DB_SUCCESS is possible.

buf_page_io_complete(): use dberr_t for error handling.

buf_flush_write_block_low(),
buf_read_ahead_random(),
buf_read_page_async(),
buf_read_ahead_linear(),
buf_read_ibuf_merge_pages(),
buf_read_recv_pages(),
fil_aio_wait():
        Issue error if page read fails.

btr_pcur_move_to_next_page(): Do not reference page if it is
NULL.

Introduced dict_table_t::is_readable() and dict_index_t::is_readable()
that will return true if tablespace exists and pages read from
tablespace are not corrupted or page decryption failed.
Removed buf_page_t::key_version. After page decryption the
key version is not removed from page frame. For unencrypted
pages, old key_version is removed at buf_page_encrypt_before_write()

dict_stats_update_transient_for_index(),
dict_stats_update_transient()
        Do not continue if table decryption failed or table
        is corrupted.

dict0stats.cc: Introduced a dict_stats_report_error function
to avoid code duplication.

fil_parse_write_crypt_data():
        Check that key read from redo log entry is found from
        encryption plugin and if it is not, refuse to start.

PageConverter::validate(): Removed access to fil_space_t as
tablespace is not available during import.

Fixed error code on innodb.innodb test.

Merged test cased innodb-bad-key-change5 and innodb-bad-key-shutdown
to innodb-bad-key-change2.  Removed innodb-bad-key-change5 test.
Decreased unnecessary complexity on some long lasting tests.

Removed fil_inc_pending_ops(), fil_decr_pending_ops(),
fil_get_first_space(), fil_get_next_space(),
fil_get_first_space_safe(), fil_get_next_space_safe()
functions.

fil_space_verify_crypt_checksum(): Fixed bug found using ASAN
where FIL_PAGE_END_LSN_OLD_CHECKSUM field was incorrectly
accessed from row compressed tables. Fixed out of page frame
bug for row compressed tables in
fil_space_verify_crypt_checksum() found using ASAN. Incorrect
function was called for compressed table.

Added new tests for discard, rename table and drop (we should allow them
even when page decryption fails). Alter table rename is not allowed.
Added test for restart with innodb-force-recovery=1 when page read on
redo-recovery cant be decrypted. Added test for corrupted table where
both page data and FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION is corrupted.

Adjusted the test case innodb_bug14147491 so that it does not anymore
expect crash. Instead table is just mostly not usable.

fil0fil.h: fil_space_acquire_low is not visible function
and fil_space_acquire and fil_space_acquire_silent are
inline functions. FilSpace class uses fil_space_acquire_low
directly.

recv_apply_hashed_log_recs() does not return anything.
2017-04-26 15:19:16 +03:00
Sachin Setiya
e180c35619 MDEV-12017 Unclear error with flashback: Variable 'binlog_format' can't ...
When WSREP(thd) is not true we will use my_error(...) to print error. This
will set thd->is_error() to true and we wont be getting generic error.

Signed-off-by: Sachin Setiya <sachin.setiya@mariadb.com>
2017-04-26 11:08:23 +05:30
Igor Babaev
a287bfa09a Fixed the bug mdev-12558.
In the current code temporary tables we identified and opened before
other tables. CTE tables are identified in the same procedure as
regular tables. When a temporary table and a CTE table have the same
name T any reference to T that is in the scope of the CTE declaration
must be associated with this CTE. Yet it was not done properly.
When a reference to T was found in the scope of the declaration
of CTE T a pointer to this CTE was set in the reference. No check
that the reference had been already associated with a temporary table
was done. As a result, if the temporary table T  had been created then
the reference to T was considered simultaneously as reference to the CTE
named T and as a reference to the temporary table named T. This
confused the code that were executed later and caused a crash of
the server.
Now when a table reference is associated with a CTE any previous
association with a temporary table is dropped.

This problem could be easily avoided if the temporary tables were
not identified prematurely.
as reference to CTE named T and
2017-04-25 19:34:39 -07:00
Daniel Black
d7d8c23654 MDEV-12469: static_assert cannot be determined on bigendian
Signed-off-by: Daniel Black <daniel.black@au.ibm.com>
2017-04-25 18:46:13 +04:00
Oleksandr Byelkin
49552cf1f7 Merge branch '5.5' into bb-10.0-merge-5.5 2017-04-25 16:30:39 +02:00
Sachin Setiya
97e0c260dc Fix Galera tests failures on 10.1 and 10.2
When we build server out of git directory , we did not copy
wsrep_sst_common into build-dir. This causes galera/wsrep tests
to fail
2017-04-25 15:28:29 +05:30
Sachin Setiya
a9ad84e4d4 Fix Galera tests failures on 10.1 and 10.2
When we build server out of git directory , we did not copy
wsrep_sst_common into build-dir. This causes galera/wsrep tests
to fail
2017-04-25 15:25:10 +05:30
Igor Babaev
4beb7e5355 Fixed the bug mdev-12373.
Condition pushdown into derived tables / views with side effects
is not allowed.
2017-04-24 23:58:23 -07:00
Igor Babaev
0906dc49e8 Fixed the bug mdev-12564.
Here's  what started happening after the patch that fixed
the bug mdev-10454 with query reported for the bug
SELECT * FROM t t1 right JOIN t t2 ON (t2.pk = t1.pk)
  WHERE (t2.i, t2.pk) NOT IN ( SELECT t3.i, t3.i FROM t t3, t t4 )
        AND t1.c = 'foo';
The patch added an implementation of propagate_equal_fields() for
the class Item_row and thus opened the possibility of equal fields
substitutions.
At the prepare stage after setup_conds() called for WHERE condition
had completed the flag of maybe_null of the Item_row object created
for  (t2.i, t2.pk) was set to false, because the maybe_null flags of
both elements were set to false. However the flag of maybe_null for
t1.pk from the ON condition were set to true, because t1 was an inner
table of an outer join.
At the optimization stage the outer join was converted to inner join,
but the maybe_null flags were not corrected and remained the same.
So after the substitution t2.pk/t1.pk. the maybe_null flag for the
row remained false while the maybe_flag for the second element of
the row was true. As a result, when the in-to_exists transformation
was performed for the NOT IN predicate the guards variables were
not created for the elements of the row, but a guard object for
the second element was created. The object were not valid because
it referred to NULL as a guard variable. This ultimately caused
a crash when the expression with the guard was evaluated at the
execution stage.

The patch made sure that the guard objects are not created without
guard variables.

Yet it does not resolve the problem of inconsistent maybe_null flags.
and it might be that the problem will pop op in other pieces of code.
The resolution of this problem is not easy, but the problem should
be resolved in future versions.
2017-04-24 14:57:26 -07:00
Igor Babaev
2e7ba70a94 Fixed the bug mdev-10693.
The code that chooses between materialization of a non-correlated
IN subquery and its transformation into an EXISTS correlated
subquery assumes that the execution plan for the outer select
has been already built. However it was not always so if subqueries
occurred in the expressions used for ref access to tables of
the outer select. A call of the function create_ref_for_key() in
get_best_combination() could trigger a premature execution of
the above mentioned code when the execution plan structures for
the outer select were not fully built. This could cause a crash
of the server.

The fix postpones the calls of create_ref_for_key() until the
structures for the execution plan is fully built.
2017-04-24 11:46:01 -07:00
Aditya A
44b1fb3614 WL9513 Bug#23333990 PERSISTENT INDEX STATISTICS UPDATE BEFORE TRANSACTION IS COMMITTED
PROBLEM

By design stats estimation always reading uncommitted data. In this scenario
an uncommitted transaction has deleted all rows in the table. In Innodb
uncommitted delete records are marked as delete but not actually removed
from Btree until the transaction has committed or a read view for the rows
is present.While calculating persistent stats we were ignoring the delete
marked records,since all the records are delete marked we were estimating
the number of rows present in the table as zero which leads to bad plans
in other transaction operating on the table.

Fix

Introduced a system variable called innodb_stats_include_delete_marked
which when enabled includes delete marked records for stat
calculations .
2017-04-24 17:45:23 +03:00
Marko Mäkelä
6f5f720848 Bug#22018745 CORRUPTION IN ONLINE TABLE REBUILD (ROW_FORMAT=REDUNDANT, INDEXED VIRTUAL COLUMN)
Apparently, WL#8149 QA did not cover the code changes made to
online table rebuild (which was introduced in MySQL 5.6.8 by WL#6255)
for ROW_FORMAT=REDUNDANT tables.

row_log_table_low_redundant(): Log the new values of indexed virtual
columns (ventry) only once.

row_log_table_low(): Assert that if o_ventry is specified, the
logged operation must not be ROW_T_INSERT, and ventry must be specified
as well.

row_log_table_low(): When computing the size of old_pk, pass v_entry=NULL to
rec_get_converted_size_temp(), to be consistent with the subsequent call
to rec_convert_dtuple_to_temp() for logging old_pk. Assert that
old_pk never contains information on virtual columns, thus proving that this
change is a no-op.

RB: 13822
Reviewed-by: Jimmy Yang <jimmy.yang@oracle.com>
2017-04-24 17:45:23 +03:00
Thirunarayanan Balathandayuthapani
223eb5fb9a Bug #20989615 INNODB AUTO_INCREMENT PRODUCES SAME VALUE TWICE
Problem:
=======
Autoincrement value gives duplicate values because of the following reasons.

(1) In InnoDB handler function, current autoincrement value is not changed
based on newly set auto_increment_increment or auto_increment_offset variable.

(2) Handler function does the rounding logic and changes the current
autoincrement value and InnoDB doesn't aware of the change in current
autoincrement value.

Solution:
========
Fix the problem(1), InnoDB always respect the auto_increment_increment
and auto_increment_offset value in case of current autoincrement value.
By fixing the problem (2), handler layer won't change any current
autoincrement value.

Reviewed-by: Jimmy Yang <jimmy.yang@oracle.com>
RB: 13748
2017-04-24 17:45:09 +03:00
Marko Mäkelä
57fea99eeb Add and adjust a test from MySQL:
commit 1198267c331b045b9cad26be72b1a5b4f8930a79
Author: Thirunarayanan Balathandayuthapani <thirunarayanan.balathandayuth@oracle.com>
Date:   Fri Aug 26 11:00:44 2016 +0530

    Bug #20989615   INNODB AUTO_INCREMENT PRODUCES SAME VALUE TWICE

The code fix is already present.
2017-04-24 16:45:40 +03:00
Marko Mäkelä
01389ee8ac Bug#24397406 INNODB: ALGORITHM=INPLACE FAILS TO PROMOTE UNIQUE KEY TO CLUSTERED INDEX
When a table has no PRIMARY KEY, but there is a UNIQUE INDEX
defined on NOT NULL columns that are not column prefixes,
that unique index must be treated as the primary key.

This property was being violated by InnoDB when a column was changed
to NOT NULL, such that a UNIQUE INDEX on that column became eligible
to being treated as a primary key.

innobase_create_key_defs(): Instead of checking each ADD [UNIQUE] INDEX
request, check if a GEN_CLUST_INDEX can be replaced with any unique index
in the altered_table definition. So, we can have new_primary even
if n_add==0.

prepare_inplace_alter_table_dict(): When the table is not being rebuilt,
assert that TABLE_SHARE::primary_key is not changing.

RB: 13595
Reviewed-by: Kevin Lewis <kevin.lewis@oracle.com>
2017-04-24 15:44:27 +03:00
Shaohua Wang
92f7f81b6b BUG#24331265 MEMORY LEAK IN SOME INNODB FTS TESTS
We don't free some memory used by fts optimize thread in release build.

Patch approved by Allen.Lai over IM.
2017-04-24 15:33:51 +03:00
Thirunarayanan Balathandayuthapani
f5759bd8d8 Bug #24347476 HIGH PRIORITY TRX FAILED TO KILL LOW PRIORITY TRX WHEN FOREIGN KEYS ARE INVOLVED
Problem:
=======
High priority transaction can't able to kill the blocking transaction
when foreign keys are involved. trx_kill_blocking() missing while checking
the foreign key constraint.

Fix:
===
Add trx_kill_blocking() while checking for the foreign key constraint.

Reviewed-by: Debarun Banerjee <debarun.banerjee@oracle.com>
RB: 13579
2017-04-24 15:29:12 +03:00
Shaohua Wang
a930c0aa86 BUG#23760086 INNODB: ASSERTION FAILURE: MACH0DATA.IC:56:(N | 0XFFFFUL) <= 0XFFFFUL
Analysis: In row_log_table_delete(), extern size could be greater
than 2 bytes int if there are enough index on blob columns.

Solution: Use 4 bytes int other than 2 bytes for extern size.

Reviewed-by: Marko Mäkelä <marko.makela@oracle.com>
RB: 13573
2017-04-24 15:20:27 +03:00
Shaohua Wang
d3a2f60e1a BUG#23477773 OPTION TO TURN OFF/ON DEADLOCK CHECKER
Backport WL#9383 INNODB: ADD AN OPTION TO TURN OFF/ON DEADLOCK CHECKER
(rb#12873) to 5.7.
2017-04-24 15:09:18 +03:00
Shaohua Wang
1a5ca702b1 Followup: BUG#23479595 SEGMENTATION FAULT WHEN SELECT FTS INDEX TABLES IN INFORMATION SCHEMA
BUG#23742339 FAILING ASSERTION: SYM_NODE->TABLE != NULL

Analysis: When we access fts aux tables in information schema,the
fts aux tables are dropped by DROP DATABASE in another session.

Solution: Drop parent table if it's a fts aux table, and drop
table will drop fts aux tables together.

Reviewed-by: Jimmy Yang <jimmy.yang@oracle.com>
RB: 13264
2017-04-24 14:53:59 +03:00
Shaohua Wang
b862c7972b BUG#24315031 FAILING ASSERTION: !TABLE->CAN_BE_EVICTED
Analysis:
the old table is dropped, just after it's added into drop list,
and new table with the same name is created, then we try to drop
the new table in background.

Solution:
Don't drop a table in background if table->to_be_dropped is false.

Reviewed-by: Jimmy Yang <jimmy.yang@oracle.com>
RB: 13414
2017-04-24 14:53:59 +03:00
Shaohua Wang
9ce1ea6f51 BUG#24009272 SEGFAULT WITH CREATE+SELECT FROM IS+DROP FTS TABLE CONCURRENTLY
Analysis:
When we access fts_internal_tbl_name in i_s_fts_config_fill (),
it can be set to NULL by another session.

Solution:
Define fts_internal_tbl_name2 for global variable innodb_ft_aux_table,
if it's NULL, set fts_internal_tbl_name to "default".

Reviewed-by: Jimmy Yang <jimmy.yang@oracle.com>
RB: 13401
2017-04-24 14:53:22 +03:00
Thirunarayanan Balathandayuthapani
4b5a9d8e0f Bug #23475211 COMBINING ALTER OPERATIONS TRIGGERS TABLE REBUILD
Problem:
=======
Inplace alter algorithm determines the table to be rebuild if the table
undergoes row format change, key block size if handler flag contains only
change table create option. If alter with inplace ignore flag operations and change table create options then it leads to table rebuild operation.

Solution:
========
During the check for rebuild, ignore the inplace ignore flag and check for
table create options.

Reviewed-by: Jimmy Yang <jimmy.yang@oracle.com>
Reviewed-by: Marko Makela <marko.makela@oracle.com>
RB: 13172
2017-04-24 14:03:22 +03:00
Marko Mäkelä
864548c4ec Add and adjust a test from MySQL:
commit 12343617922cfd9c48ee84ad6ecf53068d822010
Author: Thirunarayanan Balathandayuthapani <thirunarayanan.balathandayuth@oracle.com>
Date:   Fri Jul 15 14:39:37 2016 +0530

    Bug #23475211   COMBINING ALTER OPERATIONS TRIGGERS TABLE REBUILD

The code fix is already present.
2017-04-24 13:40:36 +03:00
Marko Mäkelä
340af4ebc3 Merge pull request #363 from grooverdan/10.1-MDEV-12488-xtradb-os_thread_pf
MDEV-12488: Remove type mismatch in InnoDB printf-like calls
2017-04-24 08:31:59 +03:00
Daniel Black
7d0ac3ade7 MDEV-12488: Remove type mismatch in InnoDB printf-like calls
To fix OSX error:

/Users/travis/build/grooverdan/mariadb-server/storage/xtradb/sync/sync0arr.cc:530:5: warning: format specifies type 'unsigned long' but the argument has type 'os_thread_id_t' (aka '_opaque_pthread_t *') [-Wformat]
                                mutex->thread_id,

                                ^~~~~~~~~~~~~~~~

Signed-off-by: Daniel Black <daniel.black@au.ibm.com>
2017-04-24 13:02:08 +10:00
Igor Babaev
d66c171e0f Fixed the bug mdev-12554.
When the WHERE condition is always FALSE then JOIN::join_tab is NULL.
2017-04-22 23:45:38 -07:00
Alexander Barkov
fac2a7a85d MDEV-12495 Conditional jump depends on uninitialised value for: SELECT NULL UNION geom_expression 2017-04-22 22:51:43 +04:00
Igor Babaev
97fb1f2679 Fixed bug mdev-10053.
The implementation of the walk method for the class Item_in_subselect
was missing. As a result the method never traversed the left operand
of any IN subquery predicate.

Item_exists_subselect::exists2in_processor() that performs the
Exist-To-In transformation calls the walk method to collect info
on outer references. As the walk method did not traverse the
left operands of the IN subqueries the outer references there
were not taken into account and some subqueries that were actually
correlated were marked as uncorrelated. It could lead to an
attempt of the materialization of such a subquery.

Also added a cleanup for some test cases merged from 5.5.
2017-04-21 14:34:24 -07:00
Sergei Golubchik
26ed68dcae fix "cmake -DWITH_PCRE=bundled"
after building with system
2017-04-21 18:34:30 +02:00
Sergei Golubchik
8d75a7533e Merge branch '5.5' into 10.0 2017-04-21 18:34:06 +02:00
Igor Babaev
54a995cd22 Fixed the bug mdev-12519.
This patch fixed some problems that occurred with subqueries that
contained directly or indirectly recursive references to recursive CTEs.

1. A [NOT] IN predicate with a constant left operand and a non-correlated
subquery as the right operand used in the specification of a recursive CTE
was considered as a constant predicate and was evaluated only once.
Now such a predicate is re-evaluated after every iteration of the process
that produces the records of the recursive CTE.
2. The Exists-To-IN transformation could be applied to [NOT] IN predicates
with recursive references. This opened a possibility of materialization
for the subqueries used as right operands. Yet, materialization
is prohibited for the subqueries if they contain a recursive reference.
Now the Exists-To-IN transformation cannot be applied for subquery
predicates with recursive references.

The function st_select_lex::check_subqueries_with_recursive_references()
is called now only for the first execution of the SELECT.
2017-04-21 09:33:36 -07:00
Marko Mäkelä
14d124880f Fix a crash when page_compression fails during IMPORT TABLESPACE
fil_compress_page(): Check for space==NULL.
2017-04-21 18:44:37 +03:00
Marko Mäkelä
200ef51344 Fix a compilation error 2017-04-21 18:29:50 +03:00
Marko Mäkelä
11f772fad6 Remove an orphan declaration of os_get_os_version() 2017-04-21 18:12:20 +03:00
Marko Mäkelä
0871a00a62 MDEV-12545 Reduce the amount of fil_space_t lookups
buf_flush_write_block_low(): Acquire the tablespace reference once,
and pass it to lower-level functions. This is only a start; further
calls may be removed.

fil_decompress_page(): Remove unsafe use of fil_space_get_by_id().
2017-04-21 18:12:10 +03:00
Marko Mäkelä
b66e15ecbc MDEV-12467 encryption.create_or_replace hangs during DROP TABLE
fil_crypt_thread(): Do invoke fil_crypt_complete_rotate_space()
when the tablespace is about to be dropped. Also, remove a redundant
check whether rotate_thread_t::space is NULL. It can only become
NULL when fil_crypt_find_space_to_rotate() returns false, and in
that case we would already have terminated the loop.

fil_crypt_find_page_to_rotate(): Remove a redundant check for
space->crypt_data == NULL. Once encryption metadata has been
created for a tablespace, it cannot be removed without dropping
the entire tablespace.
2017-04-21 18:04:20 +03:00
Marko Mäkelä
47141c9d9b Fix some InnoDB type mismatch
On 64-bit Windows, sizeof(ulint)!=sizeof(ulong).
2017-04-21 18:04:02 +03:00
Marko Mäkelä
5684aa220c MDEV-12488 Remove type mismatch in InnoDB printf-like calls
Alias the InnoDB ulint and lint data types to size_t and ssize_t,
which are the standard names for the machine-word-width data types.

Correspondingly, define ULINTPF as "%zu" and introduce ULINTPFx as "%zx".
In this way, better compiler warnings for type mismatch are possible.

Furthermore, use PRIu64 for that 64-bit format, and define
the feature macro __STDC_FORMAT_MACROS to enable it on Red Hat systems.

Fix some errors in error messages, and replace some error messages
with assertions.
Most notably, an IMPORT TABLESPACE error message in InnoDB was
displaying the number of columns instead of the mismatching flags.
2017-04-21 18:03:15 +03:00
Marko Mäkelä
039a299b92 MDEV-12534 Use atomic operations whenever available
Define UNIV_WORD_SIZE as a simple alias to SIZEOF_SIZE_T.
In MariaDB 10.0 and 10.1, it was incorrectly defined as 4 on
64-bit Windows.

MONITOR_OS_PENDING_READS, MONITOR_OS_PENDING_WRITES: Enable by default.

os_n_pending_reads, os_n_pending_writes: Remove.
Use the monitor counters instead.
2017-04-21 17:55:22 +03:00
Marko Mäkelä
996c7d5cb5 MDEV-12545 Reduce the amount of fil_space_t lookups
buf_flush_write_block_low(): Acquire the tablespace reference once,
and pass it to lower-level functions. This is only a start; further
calls may be removed later.
2017-04-21 17:47:23 +03:00