Skip to content
Permalink
Browse files
MDEV-21127 Assertion in key_text::key_text()
Unsigned type while RHS expression could be less than 0.
  • Loading branch information
midenok committed Nov 26, 2019
1 parent 25e2a55 commit a35427f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
@@ -190,3 +190,12 @@ bor#oda CREATE TABLE `bor#oda` (
CONSTRAINT `bor#oda_ibfk_2` FOREIGN KEY (`b`) REFERENCES `bor#oda` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
DROP TABLE `bor#oda`;
#
# MDEV-21127 Assertion `(size_t)(ptr - buf) < MAX_TEXT - 4' failed in key_text::key_text
#
CREATE TABLE t1 (
a012345678901234567890123456789012345678901 char(255),
b char(255),
FOREIGN KEY ( a012345678901234567890123456789012345678901, b ) REFERENCES tx (ax, bx)
) ENGINE=InnoDB;
ERROR HY000: Can't create table `test`.`t1` (errno: 150 "Foreign key constraint is incorrectly formed")
@@ -226,3 +226,13 @@ ADD FOREIGN KEY (`b`) REFERENCES `bor#oda`(`id`);

SHOW CREATE TABLE `bor#oda`;
DROP TABLE `bor#oda`;

--echo #
--echo # MDEV-21127 Assertion `(size_t)(ptr - buf) < MAX_TEXT - 4' failed in key_text::key_text
--echo #
--error ER_CANT_CREATE_TABLE
CREATE TABLE t1 (
a012345678901234567890123456789012345678901 char(255),
b char(255),
FOREIGN KEY ( a012345678901234567890123456789012345678901, b ) REFERENCES tx (ax, bx)
) ENGINE=InnoDB;
@@ -12208,9 +12208,9 @@ class key_text
/* 3 is etc continuation ("...");
2 is comma separator (", ") in case of next exists;
1 is terminating ')' */
if ((size_t)(ptr - buf) < MAX_TEXT
- (it.peek() ? 3 + 2 + 1 : 3 + 1)
- k->field_name.length) {
if (MAX_TEXT - (size_t)(ptr - buf)
>= (it.peek() ? 3 + 2 + 1 : 3 + 1)
+ k->field_name.length) {
memcpy(ptr, k->field_name.str,
k->field_name.length);
ptr += k->field_name.length;

0 comments on commit a35427f

Please sign in to comment.