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

expressions with side effects should not be considered const

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Won't Fix
    • 10.3.38
    • N/A
    • N/A

    Description

      Short circuit evaluation in IF() statements appear not to work as expected:
      https://mariadb.com/kb/en/operator-precedence/#short-circuit-evaluation

      Example queries:

      SET @imchanged=0;
      SELECT IF(FALSE AND (@imchanged:=1), 0, @imchanged) AS `im changed`; # output is '1', expect '0'
       
      SET @imchanged=0;
      SELECT IF(FALSE, IF((@imchanged:=1), 1, 1), @imchanged) AS `im changed`; # output is '0', expect '0'
      

      Running these in any MySql version outputs are as expected.

      Attachments

        Activity

          People

            Unassigned Unassigned
            lzandvliet Leo Zandvliet
            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.