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

Inconsistent NULL handling in vector type

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • N/A
    • 11.7.1
    • Vector search
    • None

    Description

      VECTOR column can be created as null-able, with NULL for a default value:

      bb-11.6-MDEV-32887-vector 764592a4da2a1b490471732fbefe2ce745ce1f32

      MariaDB [test]> create or replace table t (a vector(1));
      Query OK, 0 rows affected (0.090 sec)
       
      MariaDB [test]> show create table t\G
      *************************** 1. row ***************************
             Table: t
      Create Table: CREATE TABLE `t` (
        `a` vector(1) DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
      1 row in set (0.001 sec)
      

      Further, the default NULL value can be insert either by omitting any value, or by using DEFAULT();

      MariaDB [test]> insert into t values ();
      Query OK, 1 row affected (0.014 sec)
       
      MariaDB [test]> insert into t values (default(a));
      Query OK, 1 row affected (0.013 sec)
       
      MariaDB [test]> select * from t;
      +------+
      | a    |
      +------+
      | NULL |
      | NULL |
      +------+
      2 rows in set (0.001 sec)
      

      However, it cannot be inserted explicitly:

      MariaDB [test]> insert into t values (null);
      ERROR 4078 (HY000): Cannot cast 'null' as 'vector' in assignment of `test`.`t`.`a`
      

      Using non-strict mode or IGNORE allows to do it though:

      MariaDB [test]> delete from t;
      Query OK, 3 rows affected (0.014 sec)
       
      MariaDB [test]> insert ignore into t values (null);
      Query OK, 1 row affected, 1 warning (0.012 sec)
       
      MariaDB [test]> show warnings;
      +---------+------+----------------------------------------------------------------+
      | Level   | Code | Message                                                        |
      +---------+------+----------------------------------------------------------------+
      | Warning | 4078 | Cannot cast 'null' as 'vector' in assignment of `test`.`t`.`a` |
      +---------+------+----------------------------------------------------------------+
      1 row in set (0.000 sec)
       
      MariaDB [test]> select * from t;
      +------+
      | a    |
      +------+
      | NULL |
      +------+
      1 row in set (0.001 sec)
      

      It is all currently in vain though, because the vector index does not allow NULL-able columns (if I understand correctly, the idea is to allow and ignore NULLs in the index, so I'm adding it here in case it is going to happen):

      MariaDB [test]> truncate table t;
      Query OK, 0 rows affected (0.028 sec)
       
      MariaDB [test]> alter table t add vector(a);
      ERROR 1252 (42000): All parts of a VECTOR index must be NOT NULL
      

      Attachments

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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