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

Feature: SFORMAT auto-typing

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Fix Version/s: None
    • Component/s: Server
    • Labels:
      None

      Description

      Whilst the limitation described below is in libfmt, i.e. see (w/ thanks Sergei Golubchik):

      #include <fmt/format-inl.h>
      #include <iostream>
      int main() {
        std::cout << fmt::format("The answer is {:.5f}.\n", 42);
      }
      

      The resulting outcome in SFORMAT (for an INT passed as input with a FLOAT or DECIMAL requested formatting) is not formatted,unless the input is made into a float already):

      10.7.0 53b2c1f4664a3cb90f583979d9aa2771b7e1c98d (Debug) preview-10.7-MDEV-25015-sformat

      10.7.0-dbg>select SFORMAT ('FLOAT {:.5f}',3);
      +-----------------------------+
      | SFORMAT ('FLOAT {:.5f}',3) |
      +-----------------------------+
      | NULL                        |
      +-----------------------------+
      1 row in set, 1 warning (0.000 sec)
       
      10.7.0-dbg>show warnings;
      +---------+------+-------------------------------------------------------------+
      | Level   | Code | Message                                                     |
      +---------+------+-------------------------------------------------------------+
      | Warning | 4183 | SFORMAT error: precision not allowed for this argument type |
      +---------+------+-------------------------------------------------------------+
      1 row in set (0.000 sec)
       
      10.7.0-dbg>select SFORMAT ('FLOAT {:.5f}',3.1);
      +-------------------------------+
      | SFORMAT ( 'FLOAT {:.5f}',3.1) |
      +-------------------------------+
      | FLOAT 3.10000                 |
      +-------------------------------+
      1 row in set (0.000 sec)
       
      10.7.0-dbg>select SFORMAT ('FLOAT {:.5f}',3.);
      +------------------------------+
      | SFORMAT ('FLOAT {:.5f}',3.) |
      +------------------------------+
      | FLOAT 3.00000                |
      +------------------------------+
      1 row in set (0.000 sec)
      

      One would expect that an INT would readily be converted to FLOAT/DECIMAL.

      This libfmt limitation can likely be easily accounted for in the code.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              serg Sergei Golubchik
              Reporter:
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:

                  Git Integration