Skip to content

Commit

Permalink
Merge 10.6 into 10.7
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Jun 23, 2022
2 parents 8ebff3b + f2f18e2 commit 5d0496c
Show file tree
Hide file tree
Showing 17 changed files with 143 additions and 160 deletions.
19 changes: 19 additions & 0 deletions mysql-test/main/range.result
Original file line number Diff line number Diff line change
Expand Up @@ -3635,6 +3635,25 @@ SELECT * FROM t1 LEFT JOIN t2 ON a = pk WHERE b >= 0 AND pk IS NULL;
a pk b
DROP TABLE t1, t2;
SET @@optimizer_switch= @save_optimizer_switch;

# MDEV-28858 Wrong result with table elimination combined with
# not_null_range_scan
#
CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (10,1),(null,2);
CREATE TABLE t2 (pk INT PRIMARY KEY) ENGINE=MyISAM;
INSERT INTO t2 VALUES (1),(2);
SET @save_optimizer_switch= @@optimizer_switch;
SET optimizer_switch= 'not_null_range_scan=on';
SELECT t1.b FROM t1 LEFT JOIN t2 ON t1.a = t2.pk WHERE t1.a IS NULL ORDER BY t1.b;
b
2
SET optimizer_switch= 'not_null_range_scan=off';
SELECT t1.b FROM t1 LEFT JOIN t2 ON t1.a = t2.pk WHERE t1.a IS NULL ORDER BY t1.b;
b
2
SET @@optimizer_switch=@save_optimizer_switch;
drop table t1,t2;
#
# End of 10.5 tests
#
Expand Down
18 changes: 18 additions & 0 deletions mysql-test/main/range.test
Original file line number Diff line number Diff line change
Expand Up @@ -2492,6 +2492,24 @@ DROP TABLE t1, t2;

SET @@optimizer_switch= @save_optimizer_switch;

--echo
--echo # MDEV-28858 Wrong result with table elimination combined with
--echo # not_null_range_scan
--echo #

CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (10,1),(null,2);
CREATE TABLE t2 (pk INT PRIMARY KEY) ENGINE=MyISAM;
INSERT INTO t2 VALUES (1),(2);

SET @save_optimizer_switch= @@optimizer_switch;
SET optimizer_switch= 'not_null_range_scan=on';
SELECT t1.b FROM t1 LEFT JOIN t2 ON t1.a = t2.pk WHERE t1.a IS NULL ORDER BY t1.b;
SET optimizer_switch= 'not_null_range_scan=off';
SELECT t1.b FROM t1 LEFT JOIN t2 ON t1.a = t2.pk WHERE t1.a IS NULL ORDER BY t1.b;
SET @@optimizer_switch=@save_optimizer_switch;
drop table t1,t2;

--echo #
--echo # End of 10.5 tests
--echo #
Expand Down
19 changes: 19 additions & 0 deletions mysql-test/main/range_mrr_icp.result
Original file line number Diff line number Diff line change
Expand Up @@ -3624,6 +3624,25 @@ SELECT * FROM t1 LEFT JOIN t2 ON a = pk WHERE b >= 0 AND pk IS NULL;
a pk b
DROP TABLE t1, t2;
SET @@optimizer_switch= @save_optimizer_switch;

# MDEV-28858 Wrong result with table elimination combined with
# not_null_range_scan
#
CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (10,1),(null,2);
CREATE TABLE t2 (pk INT PRIMARY KEY) ENGINE=MyISAM;
INSERT INTO t2 VALUES (1),(2);
SET @save_optimizer_switch= @@optimizer_switch;
SET optimizer_switch= 'not_null_range_scan=on';
SELECT t1.b FROM t1 LEFT JOIN t2 ON t1.a = t2.pk WHERE t1.a IS NULL ORDER BY t1.b;
b
2
SET optimizer_switch= 'not_null_range_scan=off';
SELECT t1.b FROM t1 LEFT JOIN t2 ON t1.a = t2.pk WHERE t1.a IS NULL ORDER BY t1.b;
b
2
SET @@optimizer_switch=@save_optimizer_switch;
drop table t1,t2;
#
# End of 10.5 tests
#
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/suite/encryption/r/innodb-redo-badkey.result
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]
call mtr.add_suppression("InnoDB: Unable to decompress .*.test.t[12]\\.ibd\\[page id: space=[1-9][0-9]*, page number=[0-9]+\\]");
call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed read of file '.*test.t[12]\\.ibd'");
call mtr.add_suppression("InnoDB: Failed to read page .* from file '.*'");
call mtr.add_suppression("InnoDB: OPT_PAGE_CHECKSUM mismatch");
call mtr.add_suppression("InnoDB: Set innodb_force_recovery=1 to ignore corruption");
call mtr.add_suppression("InnoDB: Plugin initialization aborted");
call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed");
call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot decrypt \\[page id: space=");
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/suite/encryption/t/innodb-redo-badkey.test
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]
call mtr.add_suppression("InnoDB: Unable to decompress .*.test.t[12]\\.ibd\\[page id: space=[1-9][0-9]*, page number=[0-9]+\\]");
call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed read of file '.*test.t[12]\\.ibd'");
call mtr.add_suppression("InnoDB: Failed to read page .* from file '.*'");
call mtr.add_suppression("InnoDB: OPT_PAGE_CHECKSUM mismatch");
call mtr.add_suppression("InnoDB: Set innodb_force_recovery=1 to ignore corruption");
call mtr.add_suppression("InnoDB: Plugin initialization aborted");
call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed");
# for innodb_checksum_algorithm=full_crc32 only
Expand Down
14 changes: 8 additions & 6 deletions sql/sql_select.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29974,11 +29974,12 @@ bool build_notnull_conds_for_range_scans(JOIN *join, Item *cond,

DBUG_ENTER("build_notnull_conds_for_range_scans");

for (JOIN_TAB *s= join->join_tab + join->const_tables ;
for (JOIN_TAB *s= join->join_tab;
s < join->join_tab + join->table_count ; s++)
{
/* Clear all needed bitmaps to mark found fields */
if (allowed & s->table->map)
if ((allowed & s->table->map) &&
!(s->table->map && join->const_table_map))
bitmap_clear_all(&s->table->tmp_set);
}

Expand All @@ -29993,17 +29994,18 @@ bool build_notnull_conds_for_range_scans(JOIN *join, Item *cond,
For each table t from 'allowed' build a conjunction of NOT NULL predicates
constructed for all found fields if they are included in some indexes.
If the construction of the conjunction succeeds attach the formula to
t->table->notnull_cond. The condition will be used to look for complementary
range scans.
t->table->notnull_cond. The condition will be used to look for
complementary range scans.
*/
for (JOIN_TAB *s= join->join_tab + join->const_tables ;
for (JOIN_TAB *s= join->join_tab ;
s < join->join_tab + join->table_count ; s++)
{
TABLE *tab= s->table;
List<Item> notnull_list;
Item *notnull_cond= 0;

if (!(allowed & tab->map))
if (!(allowed & tab->map) ||
(s->table->map && join->const_table_map))
continue;

for (Field** field_ptr= tab->field; *field_ptr; field_ptr++)
Expand Down
1 change: 0 additions & 1 deletion storage/innobase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ SET(INNOBASE_SOURCES
include/trx0i_s.h
include/trx0purge.h
include/trx0rec.h
include/trx0rec.inl
include/trx0roll.h
include/trx0rseg.h
include/trx0sys.h
Expand Down
4 changes: 0 additions & 4 deletions storage/innobase/include/trx0purge.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ Created 3/26/1996 Heikki Tuuri

#include <queue>

/** A dummy undo record used as a return value when we have a whole undo log
which needs no purge */
extern trx_undo_rec_t trx_purge_dummy_rec;

/** Prepend the history list with an undo log.
Remove the undo log segment from the rseg slot if it is too big for reuse.
@param[in] trx transaction
Expand Down
49 changes: 23 additions & 26 deletions storage/innobase/include/trx0rec.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ Transaction undo log record
Created 3/26/1996 Heikki Tuuri
*******************************************************/

#ifndef trx0rec_h
#define trx0rec_h
#pragma once

#include "trx0types.h"
#include "row0types.h"
Expand All @@ -37,29 +36,31 @@ Created 3/26/1996 Heikki Tuuri

/***********************************************************************//**
Copies the undo record to the heap.
@return own: copy of undo log record */
UNIV_INLINE
trx_undo_rec_t*
trx_undo_rec_copy(
/*==============*/
const trx_undo_rec_t* undo_rec, /*!< in: undo log record */
mem_heap_t* heap); /*!< in: heap where copied */
/**********************************************************************//**
Reads the undo log record type.
@return record type */
UNIV_INLINE
ulint
trx_undo_rec_get_type(
/*==================*/
const trx_undo_rec_t* undo_rec); /*!< in: undo log record */
@param undo_rec record in an undo log page
@param heap memory heap
@return copy of undo_rec
@retval nullptr if the undo log record is corrupted */
inline trx_undo_rec_t* trx_undo_rec_copy(const trx_undo_rec_t *undo_rec,
mem_heap_t *heap)
{
const size_t offset= ut_align_offset(undo_rec, srv_page_size);
const size_t end= mach_read_from_2(undo_rec);
if (end <= offset || end >= srv_page_size - FIL_PAGE_DATA_END)
return nullptr;
const size_t len= end - offset;
trx_undo_rec_t *rec= static_cast<trx_undo_rec_t*>
(mem_heap_dup(heap, undo_rec, len));
mach_write_to_2(rec, len);
return rec;
}

/**********************************************************************//**
Reads the undo log record number.
@return undo no */
UNIV_INLINE
undo_no_t
trx_undo_rec_get_undo_no(
/*=====================*/
const trx_undo_rec_t* undo_rec); /*!< in: undo log record */
inline undo_no_t trx_undo_rec_get_undo_no(const trx_undo_rec_t *undo_rec)
{
return mach_u64_read_much_compressed(undo_rec + 3);
}

/**********************************************************************//**
Returns the start of the undo record data area. */
Expand Down Expand Up @@ -345,7 +346,3 @@ inline table_id_t trx_undo_rec_get_table_id(const trx_undo_rec_t *rec)
mach_read_next_much_compressed(&rec);
return mach_read_next_much_compressed(&rec);
}

#include "trx0rec.inl"

#endif /* trx0rec_h */
73 changes: 0 additions & 73 deletions storage/innobase/include/trx0rec.inl

This file was deleted.

2 changes: 1 addition & 1 deletion storage/innobase/include/trx0undo.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ class UndorecApplier
page_id_t get_page_id() const { return page_id; }

/** Handle the DML undo log and apply it on online indexes */
void apply_undo_rec();
inline void apply_undo_rec();

~UndorecApplier()
{
Expand Down
31 changes: 15 additions & 16 deletions storage/innobase/log/log0recv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1194,17 +1194,14 @@ inline size_t recv_sys_t::files_size()
}

/** Process a file name from a FILE_* record.
@param[in,out] name file name
@param[in] name file name
@param[in] len length of the file name
@param[in] space_id the tablespace ID
@param[in] deleted whether this is a FILE_DELETE record
@param[in] lsn lsn of the redo log
@param[in] store whether the redo log has to
stored */
static
void
fil_name_process(char* name, ulint len, uint32_t space_id,
bool deleted, lsn_t lsn, store_t *store)
@param[in] store whether the redo log has to be stored */
static void fil_name_process(const char *name, ulint len, uint32_t space_id,
bool deleted, lsn_t lsn, const store_t *store)
{
if (srv_operation == SRV_OPERATION_BACKUP
|| srv_operation == SRV_OPERATION_BACKUP_NO_DEFER) {
Expand All @@ -1226,13 +1223,17 @@ fil_name_process(char* name, ulint len, uint32_t space_id,

file_name_t& f = p.first->second;

if (deleted) {
/* Got FILE_DELETE */
if (auto d = deferred_spaces.find(static_cast<uint32_t>(
space_id))) {
if (auto d = deferred_spaces.find(space_id)) {
if (deleted) {
d->deleted = true;
goto got_deleted;
}
goto reload;
}

if (deleted) {
got_deleted:
/* Got FILE_DELETE */
if (!p.second && f.status != file_name_t::DELETED) {
f.status = file_name_t::DELETED;
if (f.space != NULL) {
Expand All @@ -1244,6 +1245,7 @@ fil_name_process(char* name, ulint len, uint32_t space_id,
ut_ad(f.space == NULL);
} else if (p.second // the first FILE_MODIFY or FILE_RENAME
|| f.name != fname.name) {
reload:
fil_space_t* space;

/* Check if the tablespace file exists and contains
Expand All @@ -1254,8 +1256,7 @@ fil_name_process(char* name, ulint len, uint32_t space_id,
case FIL_LOAD_OK:
ut_ad(space != NULL);

deferred_spaces.remove(
static_cast<uint32_t>(space_id));
deferred_spaces.remove(space_id);
if (!f.space) {
if (f.size
|| f.flags != f.initial_flags) {
Expand Down Expand Up @@ -1314,9 +1315,7 @@ fil_name_process(char* name, ulint len, uint32_t space_id,
/** Skip the deferred spaces
when lsn is already processed */
if (*store != store_t::STORE_IF_EXISTS) {
deferred_spaces.add(
static_cast<uint32_t>(space_id),
name, lsn);
deferred_spaces.add(space_id, name, lsn);
}
break;
case FIL_LOAD_INVALID:
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/row/row0purge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@ row_purge(
trx_undo_rec_t* undo_rec, /*!< in: record to purge */
que_thr_t* thr) /*!< in: query thread */
{
if (undo_rec != &trx_purge_dummy_rec) {
if (undo_rec != reinterpret_cast<trx_undo_rec_t*>(-1)) {
bool updated_extern;

while (row_purge_parse_undo_rec(
Expand Down

0 comments on commit 5d0496c

Please sign in to comment.