Skip to content
/ server Public

MDEV-38757 Fix EXCHANGE PARTITION with generated columns containing and/or#4623

Draft
singlow wants to merge 1 commit intoMariaDB:10.11from
singlow:medev-38757-exchange-partition-with-boolean-operators
Draft

MDEV-38757 Fix EXCHANGE PARTITION with generated columns containing and/or#4623
singlow wants to merge 1 commit intoMariaDB:10.11from
singlow:medev-38757-exchange-partition-with-boolean-operators

Conversation

@singlow
Copy link

@singlow singlow commented Feb 5, 2026

EXCHANGE PARTITION fails with ERROR 1736 (Tables have different definitions) when tables contain generated columns with AND/OR conditions, even when the expressions are logically equivalent. This occurs because when expressions are re-parsed (e.g., via CREATE TABLE ... LIKE), the order of arguments in AND/OR conditions may change, but the comparison was order-sensitive.

The Item_cond::eq() method was implemented to perform set-based comparison for commutative AND/OR operations. The set-based comparison algorithm ensures that two Item_cond expressions are considered equal if they contain the same set of equivalent arguments, regardless of order.

Added comprehensive test case covering:

  • Generated columns with OR conditions
  • Generated columns with AND conditions
  • Multiple generated columns with different AND/OR combinations
  • Nested AND/OR conditions

The fix allows EXCHANGE PARTITION to succeed when expressions are logically equivalent but have different argument ordering, which is correct behavior since AND/OR operations are commutative.

@CLAassistant
Copy link

CLAassistant commented Feb 5, 2026

CLA assistant check
All committers have signed the CLA.

@singlow singlow force-pushed the medev-38757-exchange-partition-with-boolean-operators branch from 45b4251 to 743dc52 Compare February 5, 2026 15:52
…ND/OR conditions

EXCHANGE PARTITION fails with ERROR 1736 (Tables have different definitions)
when tables contain generated columns with AND/OR conditions, even when the
expressions are logically equivalent. This occurs because when expressions are
re-parsed (e.g., via CREATE TABLE ... LIKE), the order of arguments in AND/OR
conditions may change, but the comparison was order-sensitive.

The Item_cond::eq() method was implemented to perform set-based comparison
for commutative AND/OR operations. The set-based comparison algorithm ensures
that two Item_cond expressions are considered equal if they contain the same set
of equivalent arguments, regardless of order.

Added comprehensive test case covering:
- Generated columns with OR conditions
- Generated columns with AND conditions
- Multiple generated columns with different AND/OR combinations
- Nested AND/OR conditions

The fix allows EXCHANGE PARTITION to succeed when expressions are logically
equivalent but have different argument ordering, which is correct behavior
since AND/OR operations are commutative.
@singlow singlow force-pushed the medev-38757-exchange-partition-with-boolean-operators branch from 743dc52 to 6aba215 Compare February 5, 2026 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants