2

Issue is shown query below.

The table has a column value_mean which is a float.

The issue is the last GROUP_CONCAT, it cut off the last 2 characters. Why?

MariaDB [testdb]> SELECT
    a.value_mean,
    b.value_mean,
    HEX(a.value_mean),
    HEX(b.value_mean),
    a.value_mean / b.value_mean,
    a.value_mean / b.value_mean * 100 - 100,
    CONCAT(a.value_mean / b.value_mean, 'AFTER'),
    CONCAT(a.value_mean / b.value_mean * 100 - 100, 'AFTER'),
    GROUP_CONCAT( CONCAT(a.value_mean / b.value_mean, 'AFTER') ),
    GROUP_CONCAT( CONCAT(a.value_mean / b.value_mean * 100 - 100, 'AFTER') )
FROM
    baseline_result AS a
    JOIN baseline_result AS b
WHERE
    a.id = 125716755
    AND b.id=125717382
\G
*************************** 1. row ***************************
                                                            value_mean: 15141600000
                                                            value_mean: 15141600000
                                                     HEX(a.value_mean): 38681F000
                                                     HEX(b.value_mean): 38681F400
                                           a.value_mean / b.value_mean: 0.9999999323715897
                               a.value_mean / b.value_mean * 100 - 100: -0.0000067628410249653825
                          CONCAT(a.value_mean / b.value_mean, 'AFTER'): 0.9999999323715897AFTER
              CONCAT(a.value_mean / b.value_mean * 100 - 100, 'AFTER'): -0.0000067628410249653825AFTER
            GROUP_CONCAT(CONCAT(a.value_mean / b.value_mean, 'AFTER')): 0.9999999323715897AFTER
GROUP_CONCAT(CONCAT(a.value_mean / b.value_mean * 100 - 100, 'AFTER')): -0.0000067628410249653825AFT
1 row in set (0.001 sec)

This shows it even better but harder to follow.. the SELECT will now actually have two rows to GROUP_CONCAT and can see the cutoff characters are in the middle of the GROUP_CONCAT:

MariaDB [testdb]> SELECT
    a.value_mean,
    b.value_mean,
    HEX(a.value_mean),
    HEX(b.value_mean),
    a.value_mean / b.value_mean,
    a.value_mean / b.value_mean * 100 - 100,
    CONCAT(a.value_mean / b.value_mean, 'AFTER'),
    CONCAT(a.value_mean / b.value_mean * 100 - 100, 'AFTER'),
    GROUP_CONCAT(CONCAT(a.value_mean / b.value_mean, 'AFTER')),
    GROUP_CONCAT(CONCAT(a.value_mean / b.value_mean * 100 - 100, 'AFTER'))
FROM
    baseline_result AS a
    JOIN baseline_result AS b
WHERE
    a.id = 125716755
    AND b.id in (125717382, 125717383)
\G
*************************** 1. row ***************************
                                                            value_mean: 15141600000
                                                            value_mean: 15141600000
                                                     HEX(a.value_mean): 38681F000
                                                     HEX(b.value_mean): 38681F400
                                           a.value_mean / b.value_mean: 0.9999999323715897
                               a.value_mean / b.value_mean * 100 - 100: -0.0000067628410249653825
                          CONCAT(a.value_mean / b.value_mean, 'AFTER'): 0.9999999323715897AFTER
              CONCAT(a.value_mean / b.value_mean * 100 - 100, 'AFTER'): -0.0000067628410249653825AFTER
            GROUP_CONCAT(CONCAT(a.value_mean / b.value_mean, 'AFTER')): 0.9999999323715897AFTER,0.8918810968677036AFTER
GROUP_CONCAT(CONCAT(a.value_mean / b.value_mean * 100 - 100, 'AFTER')): -0.0000067628410249653825AFT,-10.81189031322964AFTER
1 row in set (0.001 sec)
[root@test ~]# mysql --version
mysql  Ver 15.1 Distrib 5.5.56-MariaDB, for Linux (x86_64) using readline 5.1

I'm a bit stumped by this. If the float value are slightly different and issue is avoided. Just been getting lucky, I guess. Larger query failed, narrowed issue down to these two floats.. but now bit stumped.

I can avoid issue by rounding the values that are GROUP_CONCAT-ed but that isn't ideal solution.

More info.. the column is float, but just selecting value_mean its close enough it prints the same. Printing HEX() you can see value better.

MariaDB [testdb]> SELECT
id,
value_mean,
HEX(value_mean)
FROM baseline_result
WHERE id in (125716755,125717382,125717383);
+-----------+-------------+-----------------+
| id        | value_mean  | HEX(value_mean) |
+-----------+-------------+-----------------+
| 125716755 | 15141600000 | 38681F000       |
| 125717382 | 15141600000 | 38681F400       |
| 125717383 | 16977100000 | 3F3EA2800       |
+-----------+-------------+-----------------+
3 rows in set (0.000 sec)

MariaDB [testdb]> SELECT VERSION();
+----------------+
| VERSION()      |
+----------------+
| 5.5.56-MariaDB |
+----------------+
1 row in set (0.000 sec)

Here is easier repro with more recent MariaDB:

MariaDB [(none)]> SELECT VERSION();
+---------------------------------------+
| VERSION()                             |
+---------------------------------------+
| 10.5.13-MariaDB-1:10.5.13+maria~focal |
+---------------------------------------+
1 row in set (0.000 sec)

MariaDB [(none)]> select GROUP_CONCAT(a) FROM ( SELECT CONCAT(conv('38681F000', 16, 10) / conv('38681F400', 16, 10) * 100 - 100, 'AFTER') as a) xxx;
+------------------------------+
| GROUP_CONCAT(a)              |
+------------------------------+
| -0.0000067628410249653825AFT |
+------------------------------+
1 row in set (0.000 sec)
bexamous
  • 21
  • 4
  • Looks like a bug to me. Just to check I can reproduce this, can you provide the output of `SELECT value_mean FROM baseline_result WHERE id = 125717383`? Also, is the type of `value_mean` `FLOAT` or `DOUBLE`? Also, please provide the output of `SELECT VERSION()` so that we can see what MariaDB server version you are using. – Jivan Pal Nov 02 '22 at 12:19
  • Updated OP with more info. The actual value 3rd value doesn't really matter, I just typed a random id. I had little issue reproducing because the values of two columns print the same, can see HEX() to better see them. But not sure how to do an INSERT with the HEX value to a float column. – bexamous Nov 02 '22 at 14:17
  • Issue is not reproducible on MariaDB 10.4.24. The version you are using (5.5.56) reached end of life in April 2020; upgrade your database. See: https://endoflife.date/mariadb – Jivan Pal Nov 02 '22 at 14:25
  • 1
    Updated OP, I can repro issue with MariaDB 10.5.13. Don't even need a table. – bexamous Nov 02 '22 at 18:21
  • 1
    Thanks for reporting it as bug report [MDEV-29937](https://jira.mariadb.org/browse/MDEV-29937) – danblack Nov 02 '22 at 21:45
  • `mysql --version` reports the version of the command line client, not the server version. – Georg Richter Nov 03 '22 at 06:16
  • Interesting, thanks for the MWE (which reproduces the bug for me on 10.4.24 too) and bug report. – Jivan Pal Nov 03 '22 at 16:52

0 Answers0