Details
-
Task
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
None
-
None
Description
Whilst the limitation described below is in libfmt, i.e. see (w/ thanks serg):
#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
- is caused by
-
MDEV-25015 Custom formatting of strings in MariaDB queries
- Closed
- relates to
-
MDEV-26649 SFORMAT: Temporal type support (DATE) missing
- Open