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

IF() function consults 3rd argument to determine result display

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Not a Bug
    • Affects Version/s: 5.5.33a, 5.3.13, 5.5, 10.0
    • Fix Version/s: 5.5.41
    • Component/s: OTHER
    • Labels:
      None

      Description

      In MariaDB, it seems that the 3rd argument of the IF() function is consulted to determine how a DECIMAL result is zero-padded when sent back to the client. The behavior is different in MySQL. For example:

      In MySQL:

      mysql 5.6.21-log (root) [test]> SELECT IF (1=1, ROUND(0.123451, 3), ROUND(0.123451, 5)) as result;
      --------------
      SELECT IF (1=1, ROUND(0.123451, 3), ROUND(0.123451, 5)) as result
      --------------
       
      Field   1:  `result`
      Catalog:    `def`
      Database:   ``
      Table:      ``
      Org_table:  ``
      Type:       NEWDECIMAL
      Collation:  binary (63)
      Length:     9
      Max_length: 5
      Decimals:   5
      Flags:      NOT_NULL BINARY NUM
       
      +--------+
      | result |
      +--------+
      |  0.123 |
      +--------+
      1 row in set (0.00 sec)

      And in MariaDB:

      mysql 10.0.13-MariaDB-log (root) [test]> SELECT IF (1=1, ROUND(0.123451, 3), ROUND(0.123451, 5)) as result;
      --------------
      SELECT IF (1=1, ROUND(0.123451, 3), ROUND(0.123451, 5)) as result
      --------------
       
      Field   1:  `result`
      Catalog:    `def`
      Database:   ``
      Table:      ``
      Org_table:  ``
      Type:       NEWDECIMAL
      Collation:  binary (63)
      Length:     9
      Max_length: 7
      Decimals:   5
      Flags:      NOT_NULL BINARY NUM
       
      +---------+
      | result  |
      +---------+
      | 0.12300 |
      +---------+
      1 row in set (0.00 sec)

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bar Alexander Barkov
              Reporter:
              kolbe Kolbe Kegel (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: