Commit 6891c487 authored by Monty's avatar Monty

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.
parent 2ae92e89
...@@ -2882,3 +2882,15 @@ key(c, a), unique(b) ...@@ -2882,3 +2882,15 @@ key(c, a), unique(b)
partition by hash (b); partition by hash (b);
replace into t1 values (1, 0, 0), (2, 0, 0), (0, 0, 0); replace into t1 values (1, 0, 0), (2, 0, 0), (0, 0, 0);
drop table t1; drop table t1;
#
# MDEV-28269 Assertion `save_errno' in maria_write or ER_GET_ERRNO
#
connect session1,localhost,root,,;
SET big_tables= on;
SET NAMES 'sjis';
SELECT 'למטה' AS a UNION SELECT 'Wetter' AS a;
a
למט?
Wetter
connection default;
disconnect session1;
...@@ -1430,7 +1430,7 @@ CREATE TABLE t1 ( ...@@ -1430,7 +1430,7 @@ CREATE TABLE t1 (
) ENGINE=aria DEFAULT CHARSET=utf8 PACK_KEYS=0; ) ENGINE=aria DEFAULT CHARSET=utf8 PACK_KEYS=0;
let $MYSQLD_DATADIR= `select @@datadir`; let $MYSQLD_DATADIR= `select @@datadir`;
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
--exec $MARIA_CHK -d $MYSQLD_DATADIR/test/t1 --exec $MARIA_CHK -d --ignore-control-file $MYSQLD_DATADIR/test/t1
DROP TABLE t1; DROP TABLE t1;
# Test warnings with transactional=1 with MyISAM # Test warnings with transactional=1 with MyISAM
...@@ -2105,3 +2105,14 @@ partition by hash (b); ...@@ -2105,3 +2105,14 @@ partition by hash (b);
replace into t1 values (1, 0, 0), (2, 0, 0), (0, 0, 0); replace into t1 values (1, 0, 0), (2, 0, 0), (0, 0, 0);
# cleanup # cleanup
drop table t1; drop table t1;
--echo #
--echo # MDEV-28269 Assertion `save_errno' in maria_write or ER_GET_ERRNO
--echo #
connect (session1,localhost,root,,);
SET big_tables= on;
SET NAMES 'sjis';
SELECT 'למטה' AS a UNION SELECT 'Wetter' AS a;
connection default;
disconnect session1;
...@@ -728,7 +728,10 @@ static int w_search(register MARIA_HA *info, uint32 comp_flag, MARIA_KEY *key, ...@@ -728,7 +728,10 @@ static int w_search(register MARIA_HA *info, uint32 comp_flag, MARIA_KEY *key,
} }
} }
if (flag == MARIA_FOUND_WRONG_KEY) if (flag == MARIA_FOUND_WRONG_KEY)
{
my_errno= HA_ERR_CRASHED;
goto err; goto err;
}
if (!was_last_key) if (!was_last_key)
insert_last=0; insert_last=0;
next_page= _ma_kpos(page.node, keypos); next_page= _ma_kpos(page.node, keypos);
......
...@@ -887,7 +887,8 @@ struct st_maria_handler ...@@ -887,7 +887,8 @@ struct st_maria_handler
#define PACK_TYPE_SELECTED 1U /* Bits in field->pack_type */ #define PACK_TYPE_SELECTED 1U /* Bits in field->pack_type */
#define PACK_TYPE_SPACE_FIELDS 2U #define PACK_TYPE_SPACE_FIELDS 2U
#define PACK_TYPE_ZERO_FILL 4U #define PACK_TYPE_ZERO_FILL 4U
#define MARIA_FOUND_WRONG_KEY 32768U /* Impossible value from ha_key_cmp */
#define MARIA_FOUND_WRONG_KEY INT_MAX32 /* Impossible value from ha_key_cmp */
#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)) #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))
#define MARIA_MAX_KEYPTR_SIZE 5 /* For calculating block lengths */ #define MARIA_MAX_KEYPTR_SIZE 5 /* For calculating block lengths */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment