Skip to content

Commit b6840ad

Browse files
committed
MDEV-39002 Fix CREATE TABLE Assertion
Propagate fix_attributes boolean return value to prevent Diagnostics_area assertion failures during error conditions.
1 parent bf363a5 commit b6840ad

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

mysql-test/main/mdev_39002.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CREATE TABLE t (a INT, b VARCHAR(8) DEFAULT (IFNULL(a,''))) CHARSET swe7;
2+
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,NUMERIC) and (swe7_swedish_ci,COERCIBLE) for operation 'ifnull'

mysql-test/main/mdev_39002.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--error ER_CANT_AGGREGATE_2COLLATIONS
2+
CREATE TABLE t (a INT, b VARCHAR(8) DEFAULT (IFNULL(a,''))) CHARSET swe7;

sql/item_cmpfunc.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,9 +1207,9 @@ class Item_func_coalesce :public Item_func_case_expression
12071207
bool fix_length_and_dec(THD *thd) override
12081208
{
12091209
update_nullability_post_fix_fields();
1210-
if (aggregate_for_result(func_name_cstring(), args, arg_count, true))
1210+
if (aggregate_for_result(func_name_cstring(), args, arg_count, true) ||
1211+
fix_attributes(args, arg_count))
12111212
return TRUE;
1212-
fix_attributes(args, arg_count);
12131213
return FALSE;
12141214
}
12151215
LEX_CSTRING func_name_cstring() const override
@@ -1236,9 +1236,9 @@ class Item_func_case_abbreviation2 :public Item_func_case_expression
12361236
protected:
12371237
bool fix_length_and_dec2(Item **items)
12381238
{
1239-
if (aggregate_for_result(func_name_cstring(), items, 2, true))
1239+
if (aggregate_for_result(func_name_cstring(), items, 2, true) ||
1240+
fix_attributes(items, 2))
12401241
return TRUE;
1241-
fix_attributes(items, 2);
12421242
return FALSE;
12431243
}
12441244

@@ -1376,7 +1376,9 @@ class Item_func_if :public Item_func_case_abbreviation2_switch
13761376
bool fix_fields(THD *, Item **) override;
13771377
bool fix_length_and_dec(THD *thd) override
13781378
{
1379-
return fix_length_and_dec2_eliminate_null(args + 1);
1379+
if (fix_length_and_dec2_eliminate_null(args + 1))
1380+
return TRUE;
1381+
return FALSE;
13801382
}
13811383
LEX_CSTRING func_name_cstring() const override
13821384
{
@@ -1413,7 +1415,9 @@ class Item_func_nvl2 :public Item_func_case_abbreviation2_switch
14131415
}
14141416
bool fix_length_and_dec(THD *thd) override
14151417
{
1416-
return fix_length_and_dec2_eliminate_null(args + 1);
1418+
if (fix_length_and_dec2_eliminate_null(args + 1))
1419+
return TRUE;
1420+
return FALSE;
14171421
}
14181422

14191423
protected:

0 commit comments

Comments
 (0)