Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-40751

CREATE ... SELECT VEC_FROMTEXT(...) may create VECTOR columns that reject every value

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 11.8
    • 11.8
    • Vector search
    • None

    Description

      Not a regression, though it likely manifests with different vec_fromtext input before and after MDEV-40486. Below is an example that works for both, kind of

      Example before MDEV-40486:

      CREATE TABLE t1 (a CHAR(4));
      create table t2 select vec_fromtext(a) from t1;
      show create table t2;
      Table	Create Table
      t2	CREATE TABLE `t2` (
        `vec_fromtext(a)` vector(7) DEFAULT NULL
      ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
      insert into t2 values (vec_fromtext('[1,2,3,4,5,6,7]'));
      temp.mdev_40486                          [ fail ]
              Test ended at 2026-08-13 17:21:34
       
      CURRENT_TEST: temp.mdev_40486
      mysqltest: At line 4: query 'insert into t2 values (vec_fromtext('[1,2,3,4,5,6,7]'))' failed: ER_TRUNCATED_WRONG_VALUE (1292): Incorrect vector value: '\x00\x00\x80?\x00\x00\x00@\x00\x00@@\x00\x00\x80@\x00\x00\xA0@\x00\x00\xC0@\x00\x00\xE0@' for column `test`.`t2`.`vec_fromtext(a)` at row 1
      

      after MDEV-40486:

      CREATE TABLE t1 (a CHAR(4));
      create table t2 select vec_fromtext(a) from t1;
      show create table t2;
      Table	Create Table
      t2	CREATE TABLE `t2` (
        `vec_fromtext(a)` vector(1) DEFAULT NULL
      ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
      insert into t2 values (vec_fromtext('[1]'));
      temp.mdev_40486                          [ fail ]
              Test ended at 2026-08-13 17:44:25
       
      CURRENT_TEST: temp.mdev_40486
      mysqltest: At line 4: query 'insert into t2 values (vec_fromtext('[1]'))' failed: ER_TRUNCATED_WRONG_VALUE (1292): Incorrect vector value: '\x00\x00\x80?' for column `test`.`t2`.`vec_fromtext(a)` at row 1
      

      The cause is the same. Before MDEV-40486, the max_length of the VECTOR field is 30 (field_length below) and truncated to 28 (length), causing the failure

      // in Field_vector::store:
          if (length != field_length)
            return report_wrong_value(ErrConvString(from, length, cs));
      

      After the patch it is 8 vs 6. Both are caused by the max_length computed not to be a multiple of 4 in Item_func_vec_fromtext::fix_length_and_dec

      Attachments

        Issue Links

          Activity

            People

              ycp Yuchen Pei
              ycp Yuchen Pei
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.