[MDEV-26648] Feature: SFORMAT auto-typing Created: 2021-09-20  Updated: 2021-09-21

Status: Open
Project: MariaDB Server
Component/s: Server
Fix Version/s: None

Type: Task Priority: Major
Reporter: Roel Van de Paar Assignee: Sergei Golubchik
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-25015 Custom formatting of strings in Maria... Closed
Relates
relates to MDEV-26649 SFORMAT: Temporal type support (DATE)... Open

 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.



 Comments   
Comment by Roel Van de Paar [ 2021-09-20 ]

The issue's title is generic, as there are likely other types this applies to. For example auto-date formatting once MDEV-26649 is implemented.

Generated at Thu Feb 08 09:46:53 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.