Skip to content

Commit 3a566de

Browse files
committed
Merge 10.5 into 10.6
2 parents 9fc67c6 + 344e599 commit 3a566de

File tree

5 files changed

+77
-14
lines changed

5 files changed

+77
-14
lines changed

mysql-test/main/derived_view.result

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3480,3 +3480,24 @@ Warnings:
34803480
Note 1003 select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`a` AS `a`,3 AS `d`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t1`.`a` = 3 and `test`.`t1`.`pk` <= 2
34813481
drop view v1;
34823482
drop table t1,t2,t3;
3483+
#
3484+
# MDEV-25679: view / derived table defined as ordered select with LIMIT
3485+
#
3486+
create table t1 (a int);
3487+
insert into t1 values (3), (7), (1);
3488+
create view v1 as (select a from t1 limit 2) order by a desc;
3489+
(select a from t1 limit 2) order by a desc;
3490+
a
3491+
7
3492+
3
3493+
select * from v1;
3494+
a
3495+
7
3496+
3
3497+
select * from ((select a from t1 limit 2) order by a desc) dt;
3498+
a
3499+
3
3500+
7
3501+
drop view v1;
3502+
drop table t1;
3503+
# End of 10.2 tests

mysql-test/main/derived_view.test

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,3 +2273,20 @@ eval explain extended $q;
22732273

22742274
drop view v1;
22752275
drop table t1,t2,t3;
2276+
2277+
--echo #
2278+
--echo # MDEV-25679: view / derived table defined as ordered select with LIMIT
2279+
--echo #
2280+
2281+
create table t1 (a int);
2282+
insert into t1 values (3), (7), (1);
2283+
2284+
create view v1 as (select a from t1 limit 2) order by a desc;
2285+
(select a from t1 limit 2) order by a desc;
2286+
select * from v1;
2287+
select * from ((select a from t1 limit 2) order by a desc) dt;
2288+
2289+
drop view v1;
2290+
drop table t1;
2291+
2292+
--echo # End of 10.2 tests

storage/innobase/log/log0crypt.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ static bool init_crypt_key(crypt_info_t* info, bool upgrade = false)
9696
<< info->key_version << " failed (" << rc
9797
<< "). Maybe the key or the required encryption "
9898
"key management plugin was not found.";
99+
info->key_version = ENCRYPTION_KEY_VERSION_INVALID;
99100
return false;
100101
}
101102

@@ -115,6 +116,7 @@ static bool init_crypt_key(crypt_info_t* info, bool upgrade = false)
115116
if (err != MY_AES_OK || dst_len != MY_AES_BLOCK_SIZE) {
116117
ib::error() << "Getting redo log crypto key failed: err = "
117118
<< err << ", len = " << dst_len;
119+
info->key_version = ENCRYPTION_KEY_VERSION_INVALID;
118120
return false;
119121
}
120122

@@ -291,6 +293,7 @@ ATTRIBUTE_COLD bool log_crypt_101_read_block(byte* buf, lsn_t start_lsn)
291293
for (const crypt_info_t* const end = info + infos_used; info < end;
292294
info++) {
293295
if (info->key_version
296+
&& info->key_version != ENCRYPTION_KEY_VERSION_INVALID
294297
&& info->checkpoint_no == checkpoint_no) {
295298
goto found;
296299
}
@@ -302,6 +305,9 @@ ATTRIBUTE_COLD bool log_crypt_101_read_block(byte* buf, lsn_t start_lsn)
302305
/* MariaDB Server 10.1 would use the first key if it fails to
303306
find a key for the current checkpoint. */
304307
info = infos;
308+
if (info->key_version == ENCRYPTION_KEY_VERSION_INVALID) {
309+
return false;
310+
}
305311
found:
306312
byte dst[OS_FILE_LOG_BLOCK_SIZE];
307313
uint dst_len;

storage/innobase/trx/trx0rseg.cc

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ dberr_t trx_rseg_array_init()
578578
bool wsrep_xid_in_rseg_found = false;
579579
#endif
580580
mtr_t mtr;
581+
dberr_t err = DB_SUCCESS;
581582

582583
for (ulint rseg_id = 0; rseg_id < TRX_SYS_N_RSEGS; rseg_id++) {
583584
mtr.start();
@@ -607,10 +608,11 @@ dberr_t trx_rseg_array_init()
607608
ut_ad(rseg->id == rseg_id);
608609
ut_ad(!trx_sys.rseg_array[rseg_id]);
609610
trx_sys.rseg_array[rseg_id] = rseg;
610-
if (dberr_t err = trx_rseg_mem_restore(
611-
rseg, max_trx_id, &mtr)) {
611+
if ((err = trx_rseg_mem_restore(
612+
rseg, max_trx_id, &mtr))
613+
!= DB_SUCCESS) {
612614
mtr.commit();
613-
return err;
615+
break;
614616
}
615617
#ifdef WITH_WSREP
616618
if (!wsrep_sys_xid.is_null() &&
@@ -631,6 +633,21 @@ dberr_t trx_rseg_array_init()
631633
mtr.commit();
632634
}
633635

636+
if (err != DB_SUCCESS) {
637+
for (ulint rseg_id = 0; rseg_id < TRX_SYS_N_RSEGS; rseg_id++) {
638+
if (trx_rseg_t*& rseg = trx_sys.rseg_array[rseg_id]) {
639+
while (trx_undo_t* u= UT_LIST_GET_FIRST(
640+
rseg->undo_list)) {
641+
UT_LIST_REMOVE(rseg->undo_list, u);
642+
ut_free(u);
643+
}
644+
trx_rseg_mem_free(rseg);
645+
rseg = NULL;
646+
}
647+
}
648+
return err;
649+
}
650+
634651
#ifdef WITH_WSREP
635652
if (!wsrep_sys_xid.is_null()) {
636653
/* Upgrade from a version prior to 10.3.5,

storage/innobase/trx/trx0undo.cc

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -845,18 +845,11 @@ trx_undo_mem_create_at_db_start(trx_rseg_t *rseg, ulint id, uint32_t page_no,
845845
const uint16_t type = mach_read_from_2(TRX_UNDO_PAGE_HDR
846846
+ TRX_UNDO_PAGE_TYPE
847847
+ block->frame);
848-
switch (type) {
849-
case 0:
850-
case 2: /* TRX_UNDO_UPDATE */
851-
break;
852-
case 1: /* TRX_UNDO_INSERT */
853-
sql_print_error("InnoDB: upgrade from older version than"
854-
" MariaDB 10.3 requires clean shutdown");
855-
goto corrupted;
856-
default:
848+
if (UNIV_UNLIKELY(type > 2)) {
849+
corrupted_type:
857850
sql_print_error("InnoDB: unsupported undo header type %u",
858851
type);
859-
corrupted:
852+
corrupted:
860853
mtr.commit();
861854
return nullptr;
862855
}
@@ -876,12 +869,21 @@ trx_undo_mem_create_at_db_start(trx_rseg_t *rseg, ulint id, uint32_t page_no,
876869
switch (state) {
877870
case TRX_UNDO_ACTIVE:
878871
case TRX_UNDO_PREPARED:
879-
break;
872+
if (UNIV_LIKELY(type != 1)) {
873+
break;
874+
}
875+
sql_print_error("InnoDB: upgrade from older version than"
876+
" MariaDB 10.3 requires clean shutdown");
877+
goto corrupted;
880878
default:
881879
sql_print_error("InnoDB: unsupported undo header state %u",
882880
state);
883881
goto corrupted;
884882
case TRX_UNDO_TO_PURGE:
883+
if (UNIV_UNLIKELY(type == 1)) {
884+
goto corrupted_type;
885+
}
886+
/* fall through */
885887
case TRX_UNDO_CACHED:
886888
trx_id_t id = mach_read_from_8(TRX_UNDO_TRX_NO + undo_header);
887889
if (id >> 48) {

0 commit comments

Comments
 (0)