You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MDEV-24387: Wrong number of decimal digits in certain UNION/Subqery
constellation
Analysis: The decimals is set to NOT_FIXED_DEC for Field_str even if it is
NULL. Unsigned has decimals=0. So Type_std_attributes::decimals is set to 39
(maximum between 0 and 39). This results in incorrect number of decimals
when we have union of unsigned and NULL type.
Fix: Check if the field is created from NULL value. If yes, set decimals to 0
otherwise set it to NOT_FIXED_DEC.
Copy file name to clipboardExpand all lines: mysql-test/main/union.result
+34Lines changed: 34 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -2601,5 +2601,39 @@ Warnings:
2601
2601
Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where `test`.`t2`.`a` < 5 except /* select#2 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` where `test`.`t3`.`a` < 5 union all /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` > 4
2602
2602
drop table t1,t2,t3;
2603
2603
#
2604
+
# MDEV-24387: Wrong number of decimal digits in certain UNION/Subqery
2605
+
# constellation
2606
+
#
2607
+
SELECT CAST(1 AS UNSIGNED) UNION ALL SELECT * from (SELECT NULL) t;
2608
+
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
2609
+
def CAST(1 AS UNSIGNED) 246 2 1 Y 32896 0 63
2610
+
CAST(1 AS UNSIGNED)
2611
+
1
2612
+
NULL
2613
+
SELECT CAST(1 AS SIGNED) UNION ALL SELECT * from (SELECT NULL) t;
2614
+
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
2615
+
def CAST(1 AS SIGNED) 3 2 1 Y 32896 0 63
2616
+
CAST(1 AS SIGNED)
2617
+
1
2618
+
NULL
2619
+
SELECT CAST(1 AS SIGNED) UNION ALL SELECT * from (SELECT CAST(1 AS UNSIGNED)) t;
2620
+
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
2621
+
def CAST(1 AS SIGNED) 246 11 1 N 32897 0 63
2622
+
CAST(1 AS SIGNED)
2623
+
1
2624
+
1
2625
+
SELECT CAST(1 AS UNSIGNED) UNION ALL SELECT NULL;
2626
+
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
2627
+
def CAST(1 AS UNSIGNED) 246 2 1 Y 32896 0 63
2628
+
CAST(1 AS UNSIGNED)
2629
+
1
2630
+
NULL
2631
+
SELECT CAST(1 AS UNSIGNED) UNION ALL SELECT CAST(1 AS SIGNED);
2632
+
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
0 commit comments