Skip to content

Commit 6891c48

Browse files
committed
MDEV-28269 Assertion `save_errno' in maria_write or ER_GET_ERRNO
The issue was that the value of MARIA_FOUND_WRONG_KEY was a value that could be returned by ha_key_cmp. This was already fixed in MyISAM, now using the same fix in Aria: Setting the value to INT_MAX32, which should be impossible in any normal cases. I also fixed so that if there is a wrong key, we now get a proper error message and not an assert.
1 parent 2ae92e8 commit 6891c48

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

mysql-test/suite/maria/maria.result

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2882,3 +2882,15 @@ key(c, a), unique(b)
28822882
partition by hash (b);
28832883
replace into t1 values (1, 0, 0), (2, 0, 0), (0, 0, 0);
28842884
drop table t1;
2885+
#
2886+
# MDEV-28269 Assertion `save_errno' in maria_write or ER_GET_ERRNO
2887+
#
2888+
connect session1,localhost,root,,;
2889+
SET big_tables= on;
2890+
SET NAMES 'sjis';
2891+
SELECT 'למטה' AS a UNION SELECT 'Wetter' AS a;
2892+
a
2893+
למט�?
2894+
Wetter
2895+
connection default;
2896+
disconnect session1;

mysql-test/suite/maria/maria.test

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,7 @@ CREATE TABLE t1 (
14301430
) ENGINE=aria DEFAULT CHARSET=utf8 PACK_KEYS=0;
14311431
let $MYSQLD_DATADIR= `select @@datadir`;
14321432
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
1433-
--exec $MARIA_CHK -d $MYSQLD_DATADIR/test/t1
1433+
--exec $MARIA_CHK -d --ignore-control-file $MYSQLD_DATADIR/test/t1
14341434
DROP TABLE t1;
14351435

14361436
# Test warnings with transactional=1 with MyISAM
@@ -2105,3 +2105,14 @@ partition by hash (b);
21052105
replace into t1 values (1, 0, 0), (2, 0, 0), (0, 0, 0);
21062106
# cleanup
21072107
drop table t1;
2108+
2109+
--echo #
2110+
--echo # MDEV-28269 Assertion `save_errno' in maria_write or ER_GET_ERRNO
2111+
--echo #
2112+
2113+
connect (session1,localhost,root,,);
2114+
SET big_tables= on;
2115+
SET NAMES 'sjis';
2116+
SELECT 'למטה' AS a UNION SELECT 'Wetter' AS a;
2117+
connection default;
2118+
disconnect session1;

storage/maria/ma_write.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,10 @@ static int w_search(register MARIA_HA *info, uint32 comp_flag, MARIA_KEY *key,
728728
}
729729
}
730730
if (flag == MARIA_FOUND_WRONG_KEY)
731+
{
732+
my_errno= HA_ERR_CRASHED;
731733
goto err;
734+
}
732735
if (!was_last_key)
733736
insert_last=0;
734737
next_page= _ma_kpos(page.node, keypos);

storage/maria/maria_def.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,8 @@ struct st_maria_handler
887887
#define PACK_TYPE_SELECTED 1U /* Bits in field->pack_type */
888888
#define PACK_TYPE_SPACE_FIELDS 2U
889889
#define PACK_TYPE_ZERO_FILL 4U
890-
#define MARIA_FOUND_WRONG_KEY 32768U /* Impossible value from ha_key_cmp */
890+
891+
#define MARIA_FOUND_WRONG_KEY INT_MAX32 /* Impossible value from ha_key_cmp */
891892

892893
#define MARIA_BLOCK_SIZE(key_length,data_pointer,key_pointer,block_size) (((((key_length)+(data_pointer)+(key_pointer))*4+(key_pointer)+2)/(block_size)+1)*(block_size))
893894
#define MARIA_MAX_KEYPTR_SIZE 5 /* For calculating block lengths */

0 commit comments

Comments
 (0)