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

Virtual columns do not check assignment cast validity

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11, 11.0, 11.1, 11.2, 11.3, 11.4, 11.5
    • 11.5.1
    • Data types, Virtual Columns
    • None

    Description

      Direct assignment between some data types is now allowed. For example, it's not possible to store an INT into a POINT:

      CREATE OR REPLACE TABLE t1 (b POINT);
      INSERT INTO t1 VALUES (1);
      ERROR 4078 (HY000): Cannot cast 'int' as 'point' in assignment of `test`.`t1`.`b`
      

      CREATE OR REPLACE TABLE t1 (a INT, b POINT);
      UPDATE t1 SET b=a;
      ERROR 4078 (HY000): Cannot cast 'int' as 'point' in assignment of `test`.`t1`.`b`
      

      However, virtual columns do not check if the assignment is OK:

      CREATE OR REPLACE TABLE t1 (a INT, b POINT GENERATED ALWAYS AS (a));
      INSERT INTO t1 (a) VALUES (1);
      SELECT a, AsText(b) FROM t1;
      SHOW WARNINGS;
      +---------+------+---------------------------------------------------------------------+
      | Level   | Code | Message                                                             |
      +---------+------+---------------------------------------------------------------------+
      | Warning | 1416 | Cannot get geometry object from data you send to the GEOMETRY field |
      +---------+------+---------------------------------------------------------------------+
      

      This looks incorrect. The 'Cannot cast' error should be displayed at CREATE TABLE time.

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.