Skip to content

Commit

Permalink
MDEV-13555 Assertion `!item->null_value' failed in Type_handler::Item…
Browse files Browse the repository at this point in the history
…_send_str
  • Loading branch information
Alexander Barkov committed Aug 17, 2017
1 parent ff3cf74 commit a70809c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
14 changes: 14 additions & 0 deletions mysql-test/r/func_str.result
Expand Up @@ -4887,5 +4887,19 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
Warnings:
Note 1003 select octet_length('a') AS `LENGTH('a')`,octet_length('a') AS `LENGTHB('a')`
#
# MDEV-13555 Assertion `!item->null_value' failed in Type_handler::Item_send_str
#
CREATE TABLE t1 (c VARCHAR(8));
INSERT INTO t1 VALUES (NULL),('bar');
SELECT LPAD( c, 0, '?' ) FROM t1;
LPAD( c, 0, '?' )
NULL

SELECT RPAD( c, 0, '?' ) FROM t1;
RPAD( c, 0, '?' )
NULL

DROP TABLE t1;
#
# End of 10.3 tests
#
12 changes: 12 additions & 0 deletions mysql-test/t/func_str.test
Expand Up @@ -1889,6 +1889,18 @@ DROP TABLE t1;
SELECT LENGTHB('a'), LENGTHB(_utf8 0xC39F), LENGTHB(123), LENGTH(null);
EXPLAIN EXTENDED SELECT LENGTH('a'), LENGTHB('a');


--echo #
--echo # MDEV-13555 Assertion `!item->null_value' failed in Type_handler::Item_send_str
--echo #

CREATE TABLE t1 (c VARCHAR(8));
INSERT INTO t1 VALUES (NULL),('bar');
SELECT LPAD( c, 0, '?' ) FROM t1;
SELECT RPAD( c, 0, '?' ) FROM t1;
DROP TABLE t1;


--echo #
--echo # End of 10.3 tests
--echo #
6 changes: 4 additions & 2 deletions sql/item_strfunc.cc
Expand Up @@ -3267,10 +3267,11 @@ String *Item_func_rpad::val_str(String *str)
((count < 0) && !args[1]->unsigned_flag))
goto err;

null_value=0;

if (count == 0)
return make_empty_result();

null_value=0;
/* Assumes that the maximum length of a String is < INT_MAX32. */
/* Set here so that rest of code sees out-of-bound value as such. */
if ((ulonglong) count > INT_MAX32)
Expand Down Expand Up @@ -3358,10 +3359,11 @@ String *Item_func_lpad::val_str(String *str)
((count < 0) && !args[1]->unsigned_flag))
goto err;

null_value=0;

if (count == 0)
return make_empty_result();

null_value=0;
/* Assumes that the maximum length of a String is < INT_MAX32. */
/* Set here so that rest of code sees out-of-bound value as such. */
if ((ulonglong) count > INT_MAX32)
Expand Down

0 comments on commit a70809c

Please sign in to comment.