MDEV-40486 Length check for vector fields in CREATE TABLE ... SELECT - #5443
MDEV-40486 Length check for vector fields in CREATE TABLE ... SELECT#5443mariadb-YuchenPei wants to merge 1 commit into
Conversation
|
|
|
claude: Code Review: MDEV-40486 — Length check for vector fields in
|
The changes of MDEV-39558 2b65294 added length check assertion in Field_varstring constructors, and length check in type inference for SELECT set operations, to emit errors before reaching the assertions. That change caused an error to turn into an assertion failure in a separate path, when the length limit violation is not detected before tripping the assertion. So in this patch we fix it by adding an earlier length check in that path. Also use max_char_length() instead of max_length. This is a more accurate length of characters. And add handling of empty string edge case. Added testcases accordingly.
3b1915b to
4e97c43
Compare
|
claude: Code Review: MDEV-40486 (revised) — Length check for vector fields in
|
|
re claude comment
This is actually covered, for example, in this testcase: Before the change from max_length to max_char_length() this would fail with ER_TOO_BIG_FIELDLENGTH, because the max_length of VARCHAR(16383) is 65532 which results in 131064 max length for the vector, exceeding its limit. After the change it uses max_char_length() which is, well, 16383 and is correct.
I am not sure how this is possible, so I asked claude to come up with a testcase and it came up with a wrong one. After more back and forth it conceded this point is invalid. The second round review is done after that, but somehow clauded decided to make the same comment again |
sanja-byelkin
left a comment
There was a problem hiding this comment.
Main problem is spoiled SHOW CREATE VIEW (or I just do not understand how it should be shown)
CREATE TABLE t1 (a CHAR(1));
CREATE TABLE t2 AS SELECT VEC_FROMTEXT(a) AS f FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`f` vector(0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
INSERT INTO t2 VALUES (VEC_FROMTEXT('[1]'));
ERROR 22007: Incorrect vector value: '\x00\x00\x80?' for column `test`.`t2`.`f` at row 1
CREATE TABLE t3 (f VECTOR(0));
ERROR 42000: Incorrect column specifier for column 'f'
DROP TABLE t1, t2;
i.e. it shows impossible CREATE TABLE
here is a test case (of course it is incorrect just changed to pass):
CREATE TABLE t1 (a CHAR(1));
CREATE TABLE t2 AS SELECT VEC_FROMTEXT(a) AS f FROM t1;
SHOW CREATE TABLE t2; # `f` vector(0)
--error ER_TRUNCATED_WRONG_VALUE
INSERT INTO t2 VALUES (VEC_FROMTEXT('[1]')); # rejected, count(*) = 0
--error ER_WRONG_FIELD_SPEC
CREATE TABLE t3 (f VECTOR(0));
DROP TABLE t1, t2;
Add SHOW CREATE TABLE to the test and fix it please. Also there are some quietsions
The changes of MDEV-39558 2b65294 added length check assertion in Field_varstring constructors, and length check in type inference for SELECT set operations, to emit errors before reaching the assertions.
That change caused an error to turn into an assertion failure in a separate path, when the length limit violation is not detected before tripping the assertion. So in this patch we fix it by adding an earlier length check in that path.