diff options
author | Monty <monty@mariadb.org> | 2022-04-11 17:30:28 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2022-04-11 17:30:28 +0300 |
commit | 6891c4874a70685e6f6661fad2369d26007003c7 (patch) | |
tree | fc67fa78c271359fc7edbc5621b8f0cf835cc4c0 | |
parent | 2ae92e89817b1eceed134fcf98e21f99ce26a22d (diff) | |
download | mariadb-git-6891c4874a70685e6f6661fad2369d26007003c7.tar.gz |
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.
-rw-r--r-- | mysql-test/suite/maria/maria.result | 12 | ||||
-rw-r--r-- | mysql-test/suite/maria/maria.test | 13 | ||||
-rw-r--r-- | storage/maria/ma_write.c | 3 | ||||
-rw-r--r-- | storage/maria/maria_def.h | 3 |
4 files changed, 29 insertions, 2 deletions
diff --git a/mysql-test/suite/maria/maria.result b/mysql-test/suite/maria/maria.result index 2a0317d504d..baf57a0fee5 100644 --- a/mysql-test/suite/maria/maria.result +++ b/mysql-test/suite/maria/maria.result @@ -2882,3 +2882,15 @@ key(c, a), unique(b) partition by hash (b); replace into t1 values (1, 0, 0), (2, 0, 0), (0, 0, 0); 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; diff --git a/mysql-test/suite/maria/maria.test b/mysql-test/suite/maria/maria.test index e0d9d2addc7..6ab95a565b8 100644 --- a/mysql-test/suite/maria/maria.test +++ b/mysql-test/suite/maria/maria.test @@ -1430,7 +1430,7 @@ CREATE TABLE t1 ( ) ENGINE=aria DEFAULT CHARSET=utf8 PACK_KEYS=0; let $MYSQLD_DATADIR= `select @@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; # Test warnings with transactional=1 with MyISAM @@ -2105,3 +2105,14 @@ partition by hash (b); replace into t1 values (1, 0, 0), (2, 0, 0), (0, 0, 0); # cleanup 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; diff --git a/storage/maria/ma_write.c b/storage/maria/ma_write.c index 57758e8adae..33097e9ee2f 100644 --- a/storage/maria/ma_write.c +++ b/storage/maria/ma_write.c @@ -728,7 +728,10 @@ static int w_search(register MARIA_HA *info, uint32 comp_flag, MARIA_KEY *key, } } if (flag == MARIA_FOUND_WRONG_KEY) + { + my_errno= HA_ERR_CRASHED; goto err; + } if (!was_last_key) insert_last=0; next_page= _ma_kpos(page.node, keypos); diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h index 919dc831c75..382e3cbe2ba 100644 --- a/storage/maria/maria_def.h +++ b/storage/maria/maria_def.h @@ -887,7 +887,8 @@ struct st_maria_handler #define PACK_TYPE_SELECTED 1U /* Bits in field->pack_type */ #define PACK_TYPE_SPACE_FIELDS 2U #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_MAX_KEYPTR_SIZE 5 /* For calculating block lengths */ |