Skip to content

Conversation

@DaveGosselin-MariaDB
Copy link
Member

@DaveGosselin-MariaDB DaveGosselin-MariaDB commented Oct 20, 2025

We need to ensure that all the unions are marked as UNCACHEABLE_RAND in cases like:

  select * from t1 where 1 in (select 1 union select 2 union select RAND());

@DaveGosselin-MariaDB
Copy link
Member Author

Updated to include a new test case that would crash without this fix in place. Adds a loop and assertion to check that if any SELECT is marked as UNCACHEABLE_RAND, then the corresponding union should be likewise marked. This loop and assertion only execute in builds where DBUG_ASSERT is available.

sql/sql_lex.cc Outdated
bool has_rand= false;
for (SELECT_LEX *sl= un->first_select(); sl && !has_rand;
sl= sl->next_select())
has_rand= sl->uncacheable & UNCACHEABLE_RAND;
Copy link
Member

Choose a reason for hiding this comment

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

IIRC some compilers will give a warning for this, need to have

        has_rand= (sl->uncacheable & UNCACHEABLE_RAND);

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you, will update this before pushing.

Copy link
Member

@spetrunia spetrunia left a comment

Choose a reason for hiding this comment

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

Otherwise, ok to push.

We need to ensure that all the unions are marked as UNCACHEABLE_RAND in
cases like:
  select * from t1 where 1 in (select 1 union select 2 union select RAND());
@DaveGosselin-MariaDB DaveGosselin-MariaDB force-pushed the 12.2-MDEV-37905-unit-uncacheable-rand branch from 459b147 to 2ea313e Compare November 4, 2025 12:14
@DaveGosselin-MariaDB DaveGosselin-MariaDB merged commit 101346c into main Nov 4, 2025
18 checks passed
@DaveGosselin-MariaDB DaveGosselin-MariaDB deleted the 12.2-MDEV-37905-unit-uncacheable-rand branch November 4, 2025 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants