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

trigger sql_mode set to 'NO_UNSIGNED_SUBTRACTION' has no effect after upgrade from 10.3.37 to 10.4.27

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.4.27
    • None
    • None
    • Linux 4.19.0-22-amd64 #1 SMP Debian 4.19.260-1 (2022-09-29) x86_64 GNU/Linux

    Description

      After upgrading from 10.3.37 to 10.4.27 a trigger stopped working.

      The trigger relied on sql_mode: NO_UNSIGNED_SUBTRACTION to set a temporary negative value out of subtraction from two BIGINT UNSIGNED values.

      Code that is working on 10.3 and stopped working on 10.4.27

      create database test;
      use test;
       
      MariaDB [test]> select @@sql_mode;
      +------------+
      | @@sql_mode |
      +------------+
      |            |
      +------------+
      1 row in set (0.000 sec)
       
      MariaDB [test]> select @@global.sql_mode;
      +-------------------+
      | @@global.sql_mode |
      +-------------------+
      |                   |
      +-------------------+
      1 row in set (0.000 sec)
       
       
      /**/
      create table article (id int unsigned not null auto_increment primary key, size bigint unsigned default 0);
      insert into article values(NULL, 10);
       
      DELIMITER $$
      SET sql_mode = 'NO_UNSIGNED_SUBTRACTION';
      CREATE TRIGGER article_update_quota BEFORE UPDATE ON `article`
      FOR EACH ROW
      BEGIN
        DECLARE _size_diff BIGINT DEFAULT 0;
        IF OLD.size != NEW.size THEN
          *SET _size_diff = NEW.size - OLD.size;*
        END IF;
      END;
      SET sql_mode = @@global.sql_mode;
      $$
       
      DELIMITER ;
      update article set size=9; // FAILS with "BIGINT value is out of range in 'NEW.size - OLD.size'" altough trigger sql_mode: NO_UNSIGNED_SUBTRACTION
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            danielgavrila Daniel Gavrila
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.