1
0
mirror of https://github.com/MariaDB/server.git synced 2026-10-23 18:49:29 +03:00

MDEV-40486 [to-squash] Move the new lneght check in Item_func_vec_fromtext::val_str to later

This fixes the crashes mentioned in the parent commit
This commit is contained in:
Yuchen Pei
2026-08-17 17:24:31 +10:00
committed by Oleksandr Byelkin
parent 9d916c463c
commit 3436bd69ec
4 changed files with 17 additions and 5 deletions

View File

@@ -592,7 +592,15 @@ SELECT VEC_FROMTEXT(concat('[1', repeat(',1', 16382), ']')) AS f;
DROP TABLE tt;
CREATE TABLE tt AS
SELECT VEC_FROMTEXT(concat('[1', repeat(',1', 16383), ']')) AS f;
ERROR 22007: Incorrect vector value: '\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00...' for column `test`.`tt`.`f` at row 1
ERROR 22007: Truncated incorrect vector value: '[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,...'
CREATE TABLE t1 (v VECTOR(2));
INSERT INTO t1 VALUES (VEC_FROMTEXT(CONCAT('[1.', REPEAT('0',70000), ',2]')));
DROP TABLE t1;
SELECT VEC_FROMTEXT('😀😀😀');
VEC_FROMTEXT('😀😀😀')
NULL
Warnings:
Warning 4038 Syntax error in JSON text in argument 1 to function 'VEC_FromText' at position 1
## "Zero-dimensional" argument, no change in behaviour after fix
SELECT VEC_FROMTEXT('[]') as f;
f

View File

@@ -482,6 +482,12 @@ DROP TABLE tt;
CREATE TABLE tt AS
SELECT VEC_FROMTEXT(concat('[1', repeat(',1', 16383), ']')) AS f;
CREATE TABLE t1 (v VECTOR(2));
INSERT INTO t1 VALUES (VEC_FROMTEXT(CONCAT('[1.', REPEAT('0',70000), ',2]')));
DROP TABLE t1;
SELECT VEC_FROMTEXT('😀😀😀');
--echo ## "Zero-dimensional" argument, no change in behaviour after fix
SELECT VEC_FROMTEXT('[]') as f;
--error ER_TRUNCATED_WRONG_VALUE

Binary file not shown.

View File

@@ -210,9 +210,6 @@ String *Item_func_vec_fromtext::val_str(String *buf)
if ((null_value= !value))
return nullptr;
if (value->length() > max_length)
return nullptr;
buf->length(0);
buf->set_charset(&my_charset_bin);
CHARSET_INFO *cs= value->charset();
@@ -262,7 +259,8 @@ String *Item_func_vec_fromtext::val_str(String *buf)
if (!end_ok)
goto error_format;
if (Type_handler_vector::is_valid(buf->ptr(), buf->length()))
if (buf->length() <= MAX_FIELD_VARCHARLENGTH &&
Type_handler_vector::is_valid(buf->ptr(), buf->length()))
return buf;
null_value= true;