Skip to content
/ server Public

MDEV-39002: Diagnostics area assertion failure upon CREATE TABLE (ER_CANT_AGGREGATE_2COLLATIONS)#4789

Open
kjarir wants to merge 1 commit intoMariaDB:10.11from
kjarir:mdev-39002
Open

MDEV-39002: Diagnostics area assertion failure upon CREATE TABLE (ER_CANT_AGGREGATE_2COLLATIONS)#4789
kjarir wants to merge 1 commit intoMariaDB:10.11from
kjarir:mdev-39002

Conversation

@kjarir
Copy link

@kjarir kjarir commented Mar 12, 2026

Description

Resolves an assertion failure in Diagnostics_area::set_ok_status that correctly triggered when CREATE TABLE operations involving mismatched collations incorrectly signaled success.

Root Cause:
Methods like Item_func_ifnull::fix_length_and_dec and Item_func_if::fix_length_and_dec were previously ignoring the boolean return value from internal fix_attributes() calls. During functions such as IFNULL encountering collation aggregation failures (e.g., INT paired with a default fallback like swe7_swedish_ci), fix_attributes() properly stored an ER_CANT_AGGREGATE_2COLLATIONS error in the Diagnostics Area. By ignoring fix_attributes()'s failure flag, the parser assumed the step prevailed and eventually hit the assertion while assigning an OK diagnostics status over the stored error.

Solution:
Propagated the boolean return values natively from fix_attributes() calls upwards to parser handlers in sql/item_cmpfunc.h:

  • Propagated boolean correctly inside Item_func_coalesce::fix_length_and_dec.
  • Handled boolean evaluations faithfully within Item_func_case_abbreviation2::fix_length_and_dec2.
  • Ensured boolean transmission through Item_func_if::fix_length_and_dec and Item_func_nvl2::fix_length_and_dec.

@CLAassistant
Copy link

CLAassistant commented Mar 12, 2026

CLA assistant check
All committers have signed the CLA.

@kjarir kjarir changed the base branch from main to 10.4 March 12, 2026 00:25
@kjarir kjarir changed the base branch from 10.4 to 12.3 March 12, 2026 00:25
@kjarir kjarir changed the base branch from 12.3 to 10.11 March 12, 2026 00:27
Copy link
Member

@grooverdan grooverdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On commit message, its more than just preventing an assertion, its about giving a error message to the user. While the bug report shows a certian behaviour, as you resolve and understand the problem the description of the problem can evolve to something easier to consume, especially for the end user.

I'm slightly surprised this hasn't generated any other test failures (yet?) - https://buildbot.mariadb.org/#/grid?branch=refs%2Fpull%2F4789%2Fhead

@@ -0,0 +1,2 @@
--error ER_CANT_AGGREGATE_2COLLATIONS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move this test to part of mysql-test/main/create.test at end, with a :

--echo #
--echo # MDEV-x....
--echo 

(the test)

--echo End of 10.11 tests

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

bool fix_length_and_dec(THD *thd) override
{
return fix_length_and_dec2_eliminate_null(args + 1);
if (fix_length_and_dec2_eliminate_null(args + 1))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be simpler as return fix_length..... but I've no great preference. For multiple expression values like in fix_length_and_dec2 above the verbose forms is needed to be clearer.

@kjarir kjarir requested a review from grooverdan March 12, 2026 08:00
@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Mar 12, 2026
@gkodinov gkodinov changed the title MDEV - 39002 Diagnostics area assertion failure upon CREATE TABLE (ER_CANT_AGGREGATE_2COLLATIONS) MDEV-39002: Diagnostics area assertion failure upon CREATE TABLE (ER_CANT_AGGREGATE_2COLLATIONS) Mar 12, 2026
Copy link
Member

@gkodinov gkodinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution. This is a preliminary review.

If this fails in 10.6 I'd suggest using 10.6 as a base: it is severe enough I believe.

`STAGE` tinyint(2) NOT NULL,
`MAX_STAGE` tinyint(2) NOT NULL,
`PROGRESS` decimal(7,3) NOT NULL,
`MEMORY_USED` bigint(7) NOT NULL,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you have that change? it's causing the buildbot tests to fail.

…REATE TABLE

Handle collation mismatch errors during CREATE TABLE by correctly propagating
the error status from DEFAULT expression evaluation. When a DEFAULT expression
involves a collation mismatch (e.g., IFNULL(a, '') with conflicting charsets),
the error is now properly reported to the user instead of triggering a
diagnostics area assertion.

This fix also addresses test regressions in create.result and follows the
mentor's requested test formatting.
@kjarir
Copy link
Author

kjarir commented Mar 12, 2026

@grooverdan @gkodinov I've updated the PR by reverting the accidental changes to MEMORY_USED in create.result
and relocation the test case to the end of create.test with the requested formatting. I squashed these into a single clean commit and force-pushed them to your branch. Almost all Buildbots are now passing, with only one outlier remaining that appears unrelated to your changes.

@kjarir kjarir requested a review from gkodinov March 12, 2026 23:42
@grooverdan grooverdan requested a review from abarkov March 13, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

5 participants