[MCOL-3762] HEX(<decimal>) gets truncated Created: 2020-02-04  Updated: 2023-11-02

Status: Stalled
Project: MariaDB ColumnStore
Component/s: ExeMgr
Affects Version/s: 1.4.2
Fix Version/s: 23.10

Type: Bug Priority: Minor
Reporter: David Hall (Inactive) Assignee: Leonid Fedorov
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Blocks
is blocked by MDEV-20548 Unexpected error on CREATE..SELECT HE... Open
PartOf
is part of MCOL-3747 Regression in 1.4 working_ssb_compare... Closed
Sprint: 2020-2
Assigned for Testing: Daniel Lee Daniel Lee (Inactive)

 Description   

see mysql/queries/working_tpch1/qa_fe_cnxFunctions/hex.sql

The query:

select cidx, CDECIMAL1, HEX(CDECIMAL1) from DataTypeTestm order by cidx;

should return

1         -9   FFFFFFFFFFFFFFF7
2         -8   FFFFFFFFFFFFFFF8
3         -7   FFFFFFFFFFFFFFF9
4         -6   FFFFFFFFFFFFFFFA
5         -5   FFFFFFFFFFFFFFFB
6          5   5
7          6   6
8          7   7
9          8   8
10        9   9
11        0   0

But instead returns

1	-9	FFFF
2	-8	FFFF
3	-7	FFFF
4	-6	FFFF
5	-5	FFFF
6	5	5
7	6	6
8	7	7
9	8	8
10	9	9
11	0	0

This appears to only affect decimal types. I looked in the utils/funcexp/hex.cpp code and no changes there should have caused this.



 Comments   
Comment by Gagan Goel (Inactive) [ 2020-02-06 ]

Investigated this issue. ColumnStore creates the correct string with length 16, however the server truncates the field length when the string is sent to it via store() call in fetchNextRow().

There is an open server issue for this: https://jira.mariadb.org/browse/MDEV-20548

Closing this issue.

Comment by Roman [ 2020-03-06 ]

Opened as a notification.

Comment by Patrick LeBlanc (Inactive) [ 2020-03-10 ]

changed the fix version to n/a because it was messing up daniel's accounting. Change it to whatever is appropriate once it's fixed.

Comment by Gagan Goel (Inactive) [ 2020-04-03 ]

The ref file (mysql/queries/working_tpch1/qa_fe_cnxFunctions/hex.sql.ref.log) is temporarily changed to match (incorrect) output from ColumnStore. We need to revert it back when MDEV-20548 is fixed.

Comment by Gregory Dorman (Inactive) [ 2020-07-01 ]

MDEV-20548 is not done, so we cannot do this for 1..5.3.

Comment by Alexander Barkov [ 2020-11-10 ]

How to repeat the problem:

First, I create the table:

cd mariadb-columnstore-regression-test
mysql test < mysql/scripts/create_datatypetestm.sql 

Now run this query:

select cidx, CDECIMAL1, HEX(CDECIMAL1) from datatypetestm order by cidx;

+------+-----------+----------------+
| cidx | CDECIMAL1 | HEX(CDECIMAL1) |
+------+-----------+----------------+
|    1 |        -9 | FFFF           |
|    2 |        -8 | FFFF           |
|    3 |        -7 | FFFF           |
|    4 |        -6 | FFFF           |
|    5 |        -5 | FFFF           |
|    6 |         5 | 5              |
|    7 |         6 | 6              |
|    8 |         7 | 7              |
|    9 |         8 | 8              |
|   10 |         9 | 9              |
|   11 |         0 | 0              |
+------+-----------+----------------+

Notice, the FFFF in the last column is wrong.

Now if I change the engine from ColumnStore to InnoDB, the results become correct:

alter table datatypetestm engine=innodb;
select cidx, CDECIMAL1, HEX(CDECIMAL1) from datatypetestm order by cidx;

+------+-----------+------------------+
| cidx | CDECIMAL1 | HEX(CDECIMAL1)   |
+------+-----------+------------------+
|    1 |        -9 | FFFFFFFFFFFFFFF7 |
|    2 |        -8 | FFFFFFFFFFFFFFF8 |
|    3 |        -7 | FFFFFFFFFFFFFFF9 |
|    4 |        -6 | FFFFFFFFFFFFFFFA |
|    5 |        -5 | FFFFFFFFFFFFFFFB |
|    6 |         5 | 5                |
|    7 |         6 | 6                |
|    8 |         7 | 7                |
|    9 |         8 | 8                |
|   10 |         9 | 9                |
|   11 |         0 | 0                |
+------+-----------+------------------+

Generated at Thu Feb 08 02:45:14 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.