1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-28686 Assertion `0' in Type_handler_string_result::make_sort_key or unexpected result

The code in the can_eval_in_optimize() branch in
Item_func_pad::fix_length_and_dec() did not take into account
that the constant can be negative. So the function will return NULL.

This later crashed on DBUG_ASSERT() because a NOT NULL function returned NULL.

Adding set_maybe_null() into this branch if the constant is negative.
This commit is contained in:
Alexander Barkov
2024-11-06 15:45:59 +04:00
parent 4ded2cbe13
commit b9f9d804f2
3 changed files with 55 additions and 5 deletions

View File

@@ -2402,6 +2402,24 @@ CREATE VIEW v1 AS SELECT HEX(INSERT(_utf8 0xD18FD18E, 2, 1, 0x20));
SELECT * FROM v1;
DROP VIEW v1;
--echo #
--echo # MDEV-28686 Assertion `0' in Type_handler_string_result::make_sort_key or unexpected result
--echo #
CREATE TABLE t (s DATE, e DATE, PERIOD FOR p(s,e));
INSERT INTO t (s,e) VALUES ('1970-01-01','1970-01-02'),('1980-01-01','1980-01-02');
SET sql_mode='';
SELECT e, GROUP_CONCAT(s) FROM t GROUP BY CONVERT((LPAD(e, -1) AND e) USING utf8);
DROP TABLE t;
CREATE TABLE t (s DATE, e DATE, PERIOD FOR p(s,e));
INSERT INTO t (s,e) VALUES ('1970-01-01','1970-01-02'),('1980-01-01','1980-01-02');
SET sql_mode='';
SELECT DISTINCT CONVERT((LPAD(e, -1) AND e) USING utf8) FROM t;
SET sql_mode=STRICT_TRANS_TABLES;
SELECT DISTINCT CONVERT((LPAD(e, -1) AND e) USING utf8) FROM t;
DROP TABLE t;
SET sql_mode=DEFAULT;
--echo #
--echo # End of 10.6 tests