[MDEV-29193] CONCAT of DOUBLE with a string cuts off last character sometimes Created: 2022-07-28  Updated: 2022-08-04  Resolved: 2022-08-04

Status: Closed
Project: MariaDB Server
Component/s: Data types
Affects Version/s: 10.8.3
Fix Version/s: N/A

Type: Bug Priority: Minor
Reporter: Simon Assignee: Unassigned
Resolution: Not a Bug Votes: 0
Labels: None


 Description   

I found a strange behaviour of DOUBLE-fields.

I have a table with a field duration which is defined as double(4,2)

Then there are the following entries:

8.45
13.55

When I do the following select:

SELECT CONCAT(duration,' hours') FROM table;

I get the following result:

8.45 hours
13.55 hour

as soon as the value exceeds 10, the "s" of hours gets cut off.

changing the field to decimal(4,2) solved the problem for me.



 Comments   
Comment by Alice Sherepa [ 2022-08-02 ]

Could you please describe more how exactly you were getting that behavior, I can't repeat it:

MariaDB [test]> create table t (duration double(4,2));
Query OK, 0 rows affected (0.037 sec)
 
MariaDB [test]> insert into t values (8.45),(13.55);
Query OK, 2 rows affected (0.016 sec)
Records: 2  Duplicates: 0  Warnings: 0
 
MariaDB [test]> SELECT CONCAT(duration,' hours') FROM t;
+---------------------------+
| CONCAT(duration,' hours') |
+---------------------------+
| 8.45 hours                |
| 13.55 hours               |
+---------------------------+
2 rows in set (0.000 sec)
 
MariaDB [test]> select version();
+----------------+
| version()      |
+----------------+
| 10.8.3-MariaDB |
+----------------+
1 row in set (0.000 sec)

Comment by Simon [ 2022-08-04 ]

Well, this is very strange.

I tested the behaviour on my local server, on our company server and another person tested it as well.
A day later (after commented) it worked as expected on the same systems - I'm confused...

So I think, this isn't a bug in MariaDB.

Generated at Thu Feb 08 10:06:37 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.