[MCOL-4700] Wrong result of a UNION for INT and INT UNSIGNED Created: 2021-04-30 Updated: 2021-06-14 Resolved: 2021-06-14 |
|
| Status: | Closed |
| Project: | MariaDB ColumnStore |
| Component/s: | PrimProc |
| Affects Version/s: | None |
| Fix Version/s: | 6.1.1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Alexander Barkov | Assignee: | Daniel Lee (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||
| Description |
|
This problem was found by tntnatbry while working on
Looks wrong. The expected result would be:
|
| Comments |
| Comment by David Hall (Inactive) [ 2021-04-30 ] | |||
|
The UNION code attempts to figure a common data type and translate the data to that for comparison. In this case, the common data type is UNSIGNED, so the result is unsigned. Any result column can only have one data type. Our code will not support a different type for different rows. If we choose INT as the common type, the result would be incorrect for a different data set. A potential fix is to choose a larger data type like BIGINT to hold the result. This would be large enough to handle the largest UNSIGNED and still handle negative numbers. It becomes a little more problematic if one of the types is UNSIGNED BIGINT. Perhaps we could do something with int128_t. | |||
| Comment by Alexander Barkov [ 2021-05-02 ] | |||
|
MariaDB chooses:
I think CS should choose the same data types. | |||
| Comment by Daniel Lee (Inactive) [ 2021-06-14 ] | |||
|
Build verified: 6.1.1 ( Drone #2585) Reproduced the issue in build 2584 and verified the fix in build 2585. MariaDB [mytest]> DROP TABLE IF EXISTS t1; MariaDB [mytest]> CREATE TABLE t1 (a INT, b INT UNSIGNED) ENGINE=ColumnStore; MariaDB [mytest]> INSERT INTO t1 VALUES (-1,1); MariaDB [mytest]> SELECT * FROM (SELECT a FROM t1 UNION SELECT b FROM t1) tu;
------
------ |