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

NO_UNSIGNED_SUBTRACTION does not work for multiple unsigned integers

    XMLWordPrintable

Details

    • Bug
    • Status: In Testing (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.5.27, 10.6.20, 10.11.10, 11.4.4
    • 10.5
    • None
    • None

    Description

      sql_mode='NO_UNSIGNED_SUBTRACTION' is supposed to allow the subtraction of two unsigned integers. However, in MariaDB it seems to allow only subtractions involving only ONE unsigned integer (if the result is negative).

      SET SQL_MODE='NO_UNSIGNED_SUBTRACTION';
       
      SELECT CAST(0 AS UNSIGNED) - 1;        
      +-------------------------+
      | CAST(0 AS UNSIGNED) - 1 |
      +-------------------------+
      |                      -1 |
      +-------------------------+
       
      SELECT 2-CAST(3 AS UNSIGNED);    
      +-----------------------+
      | 2-CAST(3 AS UNSIGNED) |
      +-----------------------+
      |                    -1 |
      +-----------------------+
       
      SELECT CAST(1 AS UNSIGNED) - CAST(2 AS UNSIGNED);
      ERROR 1690 (22003): BIGINT value is out of range in 'cast(1 as unsigned) - cast(2 as unsigned)'
      

      This works in MySQL (tested version 5.6.40 and 8.0.39)

      Error originally reported on https://mariadb.com/kb/en/scope-of-no_unsigned_subtraction/

      Attachments

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              greenman Ian Gilfillan
              Votes:
              1 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.