mirror of
https://github.com/MariaDB/server.git
synced 2025-11-30 05:23:50 +03:00
The 'special' cases where we disable, suppress or circumvent UBSAN are: - ref10 source (as here we intentionally do some shifts that UBSAN complains about. - x86 version of optimized int#korr() methods. UBSAN do not like unaligned memory access of integers. Fixed by using byte_order_generic.h when compiling with UBSAN - We use smaller thread stack with ASAN and UBSAN, which forced me to disable a few tests that prints the thread stack size. - Verifying class types does not work for shared libraries. I added suppression in mysql-test-run.pl for this case. - Added '#ifdef WITH_UBSAN' when using integer arithmetic where it is safe to have overflows (two cases, in item_func.cc). Things fixed: - Don't left shift signed values (byte_order_generic.h, mysqltest.c, item_sum.cc and many more) - Don't assign not non existing values to enum variables. - Ensure that bool and enum values are properly initialized in constructors. This was needed as UBSAN checks that these types has correct values when one copies an object. (gcalc_tools.h, ha_partition.cc, item_sum.cc, partition_element.h ...) - Ensure we do not called handler functions on unallocated objects or deleted objects. (events.cc, sql_acl.cc). - Fixed bugs in Item_sp::Item_sp() where we did not call constructor on Query_arena object. - Fixed several cast of objects to an incompatible class! (Item.cc, Item_buff.cc, item_timefunc.cc, opt_subselect.cc, sql_acl.cc, sql_select.cc ...) - Ensure we do not do integer arithmetic that causes over or underflows. This includes also ++ and -- of integers. (Item_func.cc, Item_strfunc.cc, item_timefunc.cc, sql_base.cc ...) - Added JSON_VALUE_UNITIALIZED to json_value_types and ensure that value_type is initialized to this instead of to -1, which is not a valid enum value for json_value_types. - Ensure we do not call memcpy() when second argument could be null. Other things: - Changed struct st_position to an OBJECT and added an initialization function to it to ensure that we do not copy or use uninitialized members. The change to a class was also motived that we used "struct st_position" and POSITION randomly trough the code which was confusing. - Notably big rewrite in sql_acl.cc to avoid using deleted objects. - Changed in sql_partition to use '^' instead of '-'. This is safe as the operator is either 0 or 0x8000000000000000ULL. - Added check for select_nr < INT_MAX in JOIN::build_explain() to avoid bug when get_select() could return NULL. - Reordered elements in POSITION for better alignment. - Changed sql_test.cc::print_plan() to use pointers instead of objects. - Fixed bug in find_set() where could could execute '1 << -1'. - Added variable have_sanitizer, used by mtr. (This variable was before only in 10.5 and up). It can now have one of two values: ASAN or UBSAN. - Moved ~Archive_share() from ha_archive.cc to ha_archive.h and marked it virtual. This was an effort to get UBSAN to work with loaded storage engines. I kept the change as the new place is better. - Added in CONNECT engine COLBLK::SetName(), to get around a wrong cast in tabutil.cpp. Changes that should not be needed but had to be done to suppress warnings from UBSAN: - Added static_cast<<uint16_t>> around shift to get rid of a LOT of compiler warnings when using UBSAN. - Had to change some '/' of 2 base integers to shift to get rid of some compile time warnings. Fixes: MDEV-25505 Assertion `old_flags == ((my_flags & 0x10000U) ? 1 : 0) fixed (was caused by an old version if this commit). Reviewed by: - Json changes: Alexey Botchkov - Charset changes in ctype-uca.c: Alexander Barkov - InnoDB changes: Marko Mäkelä - sql_acl.cc changes: Vicențiu Ciorbaru - build_explain() changes: Sergey Petrunia Temporary commit to log changes for UBSAN
196 lines
5.9 KiB
Plaintext
196 lines
5.9 KiB
Plaintext
drop table if exists t1;
|
|
Warnings:
|
|
Note 1051 Unknown table 'test.t1'
|
|
CREATE TABLE t1 (pk INT, d DATETIME, PRIMARY KEY(pk), KEY(d)) ENGINE=Aria;
|
|
ALTER TABLE t1 DISABLE KEYS;
|
|
INSERT INTO t1 VALUES (1,'2000-01-01 22:22:22'),(2,'2012-12-21 12:12:12');
|
|
INSERT INTO t1 VALUES (3, '2008-07-24');
|
|
ALTER TABLE t1 ENABLE KEYS;
|
|
SELECT t1a.pk FROM t1 AS t1a LEFT JOIN t1 AS t1b ON t1a.pk = t1b.pk;
|
|
pk
|
|
1
|
|
2
|
|
3
|
|
SELECT * FROM t1 AS t1a LEFT JOIN t1 AS t1b ON t1a.pk = t1b.pk;
|
|
pk d pk d
|
|
1 2000-01-01 22:22:22 1 2000-01-01 22:22:22
|
|
2 2012-12-21 12:12:12 2 2012-12-21 12:12:12
|
|
3 2008-07-24 00:00:00 3 2008-07-24 00:00:00
|
|
DROP TABLE t1;
|
|
CREATE TABLE t1 (pk INT PRIMARY KEY, i INT, KEY(i)) ENGINE=Aria;
|
|
ALTER TABLE t1 DISABLE KEYS;
|
|
INSERT INTO t1 VALUES (1,11);
|
|
INSERT INTO t1 VALUES (2,0),(3,33),(4,0),(5,55),(6,66),(7,0),(8,88),(9,99);
|
|
ALTER TABLE t1 ENABLE KEYS;
|
|
SELECT * FROM t1 WHERE i = 0 OR pk BETWEEN 6 AND 10;
|
|
pk i
|
|
2 0
|
|
4 0
|
|
6 66
|
|
7 0
|
|
8 88
|
|
9 99
|
|
DROP TABLE t1;
|
|
CREATE TABLE t1 (f INT) ENGINE=Aria transactional=1;
|
|
SHOW CREATE TABLE t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`f` int(11) DEFAULT NULL
|
|
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=1
|
|
INSERT INTO t1 VALUES (1),(2);
|
|
ALTER TABLE t1 ORDER BY unknown_column;
|
|
ERROR 42S22: Unknown column 'unknown_column' in 'order clause'
|
|
SHOW CREATE TABLE t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`f` int(11) DEFAULT NULL
|
|
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=1
|
|
CREATE TABLE t2 SELECT * FROM t1;
|
|
DROP TABLE t1, t2;
|
|
#
|
|
# MDEV-19055 Assertion `(_my_thread_var())->thr_errno != 0' failed in pagecache_read
|
|
#
|
|
CREATE OR REPLACE TABLE t1 (x INT) ENGINE=Aria;
|
|
CREATE TEMPORARY TABLE t2 (a TIME) ENGINE=Aria;
|
|
ALTER TABLE t2 ADD b DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP;
|
|
ALTER TABLE t2 ADD CHECK (b = 4);
|
|
INSERT IGNORE INTO t2 () VALUES (),(),(),();
|
|
ALTER IGNORE TABLE t2 ADD c INT;
|
|
SELECT count(a),sum(a) FROM t2;
|
|
count(a) sum(a)
|
|
0 NULL
|
|
DELETE FROM t2 ORDER BY c LIMIT 1;
|
|
INSERT IGNORE INTO t2 SELECT * FROM t2;
|
|
OPTIMIZE TABLE t2;
|
|
Table Op Msg_type Msg_text
|
|
test.t2 optimize status OK
|
|
SELECT count(a),sum(a) FROM t2;
|
|
count(a) sum(a)
|
|
0 NULL
|
|
INSERT IGNORE INTO t2 SELECT * FROM t2;
|
|
SET SQL_MODE= 'STRICT_ALL_TABLES';
|
|
SELECT count(a),sum(a) FROM t2;
|
|
count(a) sum(a)
|
|
0 NULL
|
|
ALTER TABLE t2 CHANGE IF EXISTS d c INT;
|
|
ERROR 22007: Truncated incorrect datetime value: '4'
|
|
SELECT count(a),sum(a) FROM t2;
|
|
count(a) sum(a)
|
|
0 NULL
|
|
ALTER IGNORE TABLE t2 ADD IF NOT EXISTS e BIT;
|
|
ALTER TABLE t1 MODIFY IF EXISTS xx INT;
|
|
INSERT IGNORE INTO t2 () VALUES (),(),(),();
|
|
SELECT count(a),sum(a) FROM t2;
|
|
count(a) sum(a)
|
|
0 NULL
|
|
check table t1;
|
|
Table Op Msg_type Msg_text
|
|
test.t1 check status OK
|
|
check table t2;
|
|
Table Op Msg_type Msg_text
|
|
test.t2 check status OK
|
|
DROP TABLE t1,t2;
|
|
#
|
|
# MDEV-17576
|
|
# Assertion `share->reopen == 1' failed in maria_extra upon ALTER on
|
|
# Aria table with triggers and locks
|
|
#
|
|
CREATE TABLE t1 (a INT) ENGINE=Aria;
|
|
CREATE TRIGGER tr BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO t1 SELECT * FROM t1;
|
|
LOCK TABLE t1 WRITE;
|
|
ALTER TABLE t1 FORCE, LOCK=EXCLUSIVE;
|
|
DROP TRIGGER tr;
|
|
DROP TABLE t1;
|
|
#
|
|
# End of 10.2 test
|
|
#
|
|
#
|
|
# MDEV-17665 Assertion `!share || share->page_type == PAGECACHE_LSN_PAGE',
|
|
# `type != PAGECACHE_READ_UNKNOWN_PAGE' and similar ones upon concurrent
|
|
# Aria operations
|
|
#
|
|
CREATE TABLE t1 (pk INT PRIMARY KEY, a INT, KEY(a)) ENGINE=Aria;
|
|
ALTER TABLE t1 DISABLE KEYS;
|
|
INSERT INTO t1 SELECT seq, seq FROM seq_1_to_100;
|
|
connect con1,localhost,root,,test;
|
|
connect con2,localhost,root,,test;
|
|
INSERT INTO t1 SELECT seq, seq FROM seq_1_to_100;
|
|
connection con1;
|
|
FLUSH TABLES;
|
|
connection default;
|
|
INSERT INTO t1 SELECT 1;
|
|
ERROR 21S01: Column count doesn't match value count at row 1
|
|
connection con2;
|
|
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
|
|
disconnect con2;
|
|
connection con1;
|
|
disconnect con1;
|
|
connection default;
|
|
DROP TABLE t1;
|
|
#
|
|
# MDEV-22674 Server crash in compare_bin, ASAN heap-buffer-overflow in
|
|
# _ma_dpointer, Assertion `!info->s->have_versioning ||
|
|
# info->s->lock_key_trees' failed in restore_table_state_after_repair
|
|
#
|
|
CREATE TABLE t1 (id INT, d DATETIME, PRIMARY KEY(d,id),INDEX(d)) ENGINE=Aria;
|
|
INSERT INTO t1 SELECT seq, NOW() FROM seq_1_to_500;
|
|
CREATE TABLE t2 (a INT) ENGINE=InnoDB;
|
|
INSERT INTO t2 VALUES (1);
|
|
connect con1,localhost,root,,test;
|
|
ALTER TABLE t1 DISABLE KEYS;
|
|
INSERT INTO t1 (id) SELECT b FROM t2;
|
|
connection default;
|
|
INSERT INTO t1 SELECT a FROM t2;
|
|
ERROR 21S01: Column count doesn't match value count at row 1
|
|
connection con1;
|
|
ERROR 42S22: Unknown column 'b' in 'field list'
|
|
disconnect con1;
|
|
connection default;
|
|
drop table t1, t2;
|
|
# This is also in MDEV-22674
|
|
CREATE TABLE t1 (id INT, d DATETIME, PRIMARY KEY(d,id),INDEX(d)) ENGINE=Aria;
|
|
INSERT INTO t1 SELECT seq, NOW() FROM seq_1_to_500;
|
|
CREATE TABLE t2 (a INT) ENGINE=InnoDB;
|
|
INSERT INTO t2 VALUES (1);
|
|
ALTER TABLE t1 DISABLE KEYS;
|
|
INSERT INTO t1 (id) SELECT b FROM t2;
|
|
ERROR 42S22: Unknown column 'b' in 'field list'
|
|
INSERT INTO t1 SELECT a FROM t2;
|
|
ERROR 21S01: Column count doesn't match value count at row 1
|
|
SELECT COUNT(*) FROM t1;
|
|
COUNT(*)
|
|
500
|
|
DROP TABLE t1,t2;
|
|
#
|
|
# MDEV-23296 Assertion `block->type == PAGECACHE_EMPTY_PAGE ||
|
|
# block->type == PAGECACHE_READ_UNKNOWN_PAGE || block->type == type ||
|
|
# (block->type == PAGECACHE_PLAIN_PAGE && type == PAGECACHE_LSN_PAGE)'
|
|
# with aria_max_sort_file_size
|
|
#
|
|
SET @max_size.save= @@aria_max_sort_file_size;
|
|
SET GLOBAL aria_max_sort_file_size= 0;
|
|
CREATE TABLE t1 (pk INT PRIMARY KEY, a CHAR(255), KEY(a)) ENGINE=Aria;
|
|
ALTER TABLE t1 DISABLE KEYS;
|
|
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
|
|
ALTER TABLE t1 ENABLE KEYS;
|
|
INSERT INTO t1 VALUES (3,'nice try');
|
|
SELECT * FROM t1;
|
|
pk a
|
|
1 foo
|
|
2 bar
|
|
3 nice try
|
|
DROP TABLE t1;
|
|
SET GLOBAL aria_max_sort_file_size= @max_size.save;
|
|
#
|
|
# End of 10.4 test
|
|
#
|
|
#
|
|
# MDEV-25505 Assertion `old_flags == ((my_flags & 0x10000U) ? 1 : 0)'
|
|
# failed in my_realloc
|
|
#
|
|
CREATE TABLE t1 (pk int, c text, primary key (pk), key(c(32))) ENGINE=Aria ROW_FORMAT=DYNAMIC;
|
|
ALTER TABLE t1 DISABLE KEYS;
|
|
INSERT INTO t1 VALUES (1, 'Nine chars or more');
|
|
ALTER TABLE t1 ENABLE KEYS;
|
|
DROP TABLE t1;
|