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

Uuid. "UPDATE/DELETE" not working "WHERE id IN (SELECT id FROM ..)"

Details

    Description

      Prepare:

      CREATE TABLE companies (id uuid, name varchar(10));
      INSERT INTO companies (id) values ('7bc95b06-cc6c-11ec-96c5-0242ac130002');
       
      CREATE TABLE divisions (company_id uuid);
      INSERT INTO divisions (company_id) values ('7bc95b06-cc6c-11ec-96c5-0242ac130002');
      

      Strange results:

      // 1 row retrieved

      SELECT *
      FROM companies
      WHERE id IN (
          SELECT company_id FROM divisions
      );
      

      // not row affected

      UPDATE companies
      SET name = 'value'
      WHERE id IN (
          SELECT company_id FROM divisions
      );
      

      // not row affected

      DELETE FROM companies
      WHERE id IN (
          SELECT company_id FROM divisions
      );
      

      // 1 row affected

      UPDATE companies
      SET name = 'value'
      WHERE CAST(id as varchar(100)) IN (
          SELECT company_id FROM divisions
      );
      

      // 1 row affected

      DELETE FROM companies
      WHERE CAST(id as varchar(100)) IN (
          SELECT company_id FROM divisions
      );
      

      // 1 row affected

      UPDATE companies
      SET column_a = 'value'
      WHERE id IN (
          SELECT '7bc95b06-cc6c-11ec-96c5-0242ac130002'
      );
      

      // 1 row affected

      DELETE FROM companies
      WHERE id IN (
          SELECT '7bc95b06-cc6c-11ec-96c5-0242ac130002'
      );
      

      // not row affected

      UPDATE companies
      SET column_a = 'value'
      WHERE id IN (
          SELECT '7bc95b06-cc6c-11ec-96c5-0242ac130002'
          UNION
          SELECT '7bc95b06-cc6c-11ec-96c5-0242ac130002'
      );
      

      // not row affected

      DELETE FROM companies
      WHERE id IN (
          SELECT '7bc95b06-cc6c-11ec-96c5-0242ac130002'
          UNION
          SELECT '7bc95b06-cc6c-11ec-96c5-0242ac130002'
      );
      

      Attachments

        Issue Links

          Activity

            The same problem is repeatable with INET6:

            CREATE OR REPLACE TABLE t1 (id INET6, name varchar(10));
            INSERT INTO t1 (id) values ('00::01');
             
            CREATE OR REPLACE TABLE t2 (company_id INET6);
            INSERT INTO t2 (company_id) values ('00::01');
             
            SELECT * FROM t1 WHERE id IN (SELECT company_id FROM t2);
            

            +------+------+
            | id   | name |
            +------+------+
            | ::1  | NULL |
            +------+------+
            

            UPDATE t1 SET name = 'value' WHERE id IN (SELECT company_id FROM t2);
            

            Query OK, 0 rows affected (0.001 sec)
            Rows matched: 0  Changed: 0  Warnings: 0
            

            bar Alexander Barkov added a comment - The same problem is repeatable with INET6: CREATE OR REPLACE TABLE t1 (id INET6, name varchar (10)); INSERT INTO t1 (id) values ( '00::01' );   CREATE OR REPLACE TABLE t2 (company_id INET6); INSERT INTO t2 (company_id) values ( '00::01' );   SELECT * FROM t1 WHERE id IN ( SELECT company_id FROM t2); +------+------+ | id | name | +------+------+ | ::1 | NULL | +------+------+ UPDATE t1 SET name = 'value' WHERE id IN ( SELECT company_id FROM t2); Query OK, 0 rows affected (0.001 sec) Rows matched: 0 Changed: 0 Warnings: 0

            Pushed a fix into 10.7.5. Now need to backport to 10.5.

            bar Alexander Barkov added a comment - Pushed a fix into 10.7.5. Now need to backport to 10.5.
            bar Alexander Barkov added a comment - - edited

            Pushed a 10.5 specific patch.

            This code has diverged between 10.5 and 10.7, therefore two separate patches were needed.

            bar Alexander Barkov added a comment - - edited Pushed a 10.5 specific patch. This code has diverged between 10.5 and 10.7, therefore two separate patches were needed.
            Dantist Gri added a comment -

            When will it be released?

            10.7 branch considered to be a production-ready and one can rely on UUID field type as production-ready feature, but this bug is not just a Critical-level bug, it is a Blocker that generally eliminates possibility of using a UUID at all and ruins end-user's applications that rely on this feature.
            Subqueries are extensively used by any ORM and it is currently unusable at all.

            This bugfix deserves a special release of the 10.7 branch.

            Dantist Gri added a comment - When will it be released? 10.7 branch considered to be a production-ready and one can rely on UUID field type as production-ready feature, but this bug is not just a Critical-level bug, it is a Blocker that generally eliminates possibility of using a UUID at all and ruins end-user's applications that rely on this feature. Subqueries are extensively used by any ORM and it is currently unusable at all. This bugfix deserves a special release of the 10.7 branch.

            The release schedule is directly on https://jira.mariadb.org/ — new release is planned for the end of July

            serg Sergei Golubchik added a comment - The release schedule is directly on https://jira.mariadb.org/ — new release is planned for the end of July

            People

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