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

Wrong result set metadata for DIV

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.1, 10.2, 10.3
    • Fix Version/s: 10.3.1
    • Component/s: OTHER
    • Labels:

      Description

      SELECT 2 DIV 1;
      

      Field   1:  `2 DIV 1`
      Type:       LONGLONG
      Collation:  binary (63)
      Length:     1
      Max_length: 1
      Decimals:   0
      Flags:      BINARY NUM
      

      CREATE OR REPLACE TABLE t1 AS SELECT 2 DIV 1 AS c;
      DESCRIBE t1;
      

      +-------+--------+------+-----+---------+-------+
      | Field | Type   | Null | Key | Default | Extra |
      +-------+--------+------+-----+---------+-------+
      | c     | int(1) | YES  |     | NULL    |       |
      +-------+--------+------+-----+---------+-------+
      

      Notice, result set metadata for SELECT 2 DIV 1 reports the data type as LONGLONG. This looks wrong.
      A CREATE..SELECT query for the same expression correctly makes an INT column.
      Result set metadata should be fixed to report LONG for all DIV expressions creating an INT column. LONGLONG should be reported only for DIV making a BIGINT column in CREATE..SELECT.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bar Alexander Barkov
              Reporter:
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: