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

Concatenation operator || returns wrong results in sql_mode=ORACLE

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 5.5(EOL), 10.0(EOL), 10.1(EOL), 10.2(EOL), 10.3(EOL), 10.4(EOL)
    • 10.3.7
    • OTHER
    • None

    Description

      In Oracle, concatenation has the same priority with + (and lower than *).

      SELECT -1+1||1 FROM DUAL /* (-1+1)||'1' */;
      

      01
      

      SELECT -1||0+1 FROM DUAL /* (-1||0)+1 */;
      

      -9
      

      SELECT 1*1||-1 FROM DUAL /* (1*1)||-1 */;
      

      1-1
      

      SELECT 1||1*-1 FROM DUAL /* 1||(1*-1) */;
      

      1-1
      

      In MariaDB, the concatenation operator || (with PIPES_AS_CONCAT enables) has higher priority over + and * and bit shift. This gives difference results in Oracle compatibility mode:

      SET sql_mode=ORACLE;
      SELECT -1+1||1 FROM DUAL /* (-1+1)||'1' */;
      

      10
      

      SET sql_mode=ORACLE;
      SELECT -1||0+1 FROM DUAL /* (-1||0)+1 */;
      

      -9
      

      SET sql_mode=ORACLE;
      SELECT 1*1||-1 FROM DUAL /* (1*1)||-1 */;
      

      1
      

      SET sql_mode=ORACLE;
      SELECT 1||1*-1 FROM DUAL /* 1||(1*-1) */;
      

      -11
      

      It should be fixed to produce Oracle compatible results when sql_mode=ORACLE is set.

      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.