[MCOL-4634] CHAR(negativeWideDecimal) is not like InnoDB Created: 2021-03-23  Updated: 2021-03-25  Resolved: 2021-03-23

Status: Closed
Project: MariaDB ColumnStore
Component/s: PrimProc
Affects Version/s: 5.6.1, 6.1.1
Fix Version/s: 6.1.1

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Duplicate Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates MCOL-4604 CHAR(negativeWideDecimal) not behavin... Closed
Relates
relates to MCOL-4631 CAST(double AS SIGNED) returns 0 or NULL Closed

 Description   

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a DECIMAL(30,0)) ENGINE=ColumnStore;
INSERT INTO t1 VALUES (-1);
SELECT HEX(CHAR(a USING latin1)) FROM t1;

+---------------------------+
| HEX(CHAR(a USING latin1)) |
+---------------------------+
| NULL                      |
+---------------------------+

Looks wrong.

The correct result is:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a DECIMAL(30,0)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (-1);
SELECT HEX(CHAR(a USING latin1)) FROM t1;

+---------------------------+
| HEX(CHAR(a USING latin1)) |
+---------------------------+
| FFFFFFFF                  |
+---------------------------+

Note, negative narrow decimals do not have this problem and work as expected:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a DECIMAL(10,0)) ENGINE=ColumnStore;
INSERT INTO t1 VALUES (-1);
SELECT HEX(CHAR(a USING latin1)) FROM t1;

+---------------------------+
| HEX(CHAR(a USING latin1)) |
+---------------------------+
| FFFFFFFF                  |
+---------------------------+


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