File tree Expand file tree Collapse file tree 5 files changed +43
-3
lines changed Expand file tree Collapse file tree 5 files changed +43
-3
lines changed Original file line number Diff line number Diff line change @@ -1732,3 +1732,16 @@ RELEASE_ALL_LOCKS()
1732
1732
SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA
1733
1733
FROM information_schema.metadata_lock_info WHERE thread_id>0 ORDER BY TABLE_SCHEMA;
1734
1734
LOCK_MODE LOCK_TYPE TABLE_SCHEMA
1735
+ #
1736
+ # MDEV-32583 UUID() should be treated as stochastic for the purposes of
1737
+ # forcing query materialization
1738
+ #
1739
+ create table t1 as WITH cte AS (SELECT UUID() as r FROM seq_1_to_10)
1740
+ SELECT r as r1, r FROM cte;
1741
+ select count(*) from t1 where r1!=r;
1742
+ count(*)
1743
+ 0
1744
+ drop table t1;
1745
+ #
1746
+ # End of 10.5 tests
1747
+ #
Original file line number Diff line number Diff line change @@ -1361,3 +1361,18 @@ FROM information_schema.metadata_lock_info WHERE thread_id>0 ORDER BY TABLE_SCHE
1361
1361
1362
1362
--enable_ps2_protocol
1363
1363
--enable_view_protocol
1364
+
1365
+ --echo #
1366
+ --echo # MDEV-32583 UUID() should be treated as stochastic for the purposes of
1367
+ --echo # forcing query materialization
1368
+ --echo #
1369
+
1370
+ --source include/have_sequence.inc
1371
+ create table t1 as WITH cte AS (SELECT UUID() as r FROM seq_1_to_10)
1372
+ SELECT r as r1, r FROM cte;
1373
+ select count(*) from t1 where r1!=r;
1374
+ drop table t1;
1375
+
1376
+ --echo #
1377
+ --echo # End of 10.5 tests
1378
+ --echo #
Original file line number Diff line number Diff line change @@ -5301,7 +5301,7 @@ Create_func_uuid::create_builder(THD *thd)
5301
5301
{
5302
5302
DBUG_ENTER (" Create_func_uuid::create" );
5303
5303
thd->lex ->set_stmt_unsafe (LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
5304
- thd->lex ->safe_to_cache_query = 0 ;
5304
+ thd->lex ->uncacheable (UNCACHEABLE_RAND); // disallow cache and query merges
5305
5305
DBUG_RETURN (new (thd->mem_root ) Item_func_uuid (thd));
5306
5306
}
5307
5307
@@ -5313,7 +5313,7 @@ Create_func_uuid_short::create_builder(THD *thd)
5313
5313
{
5314
5314
DBUG_ENTER (" Create_func_uuid_short::create" );
5315
5315
thd->lex ->set_stmt_unsafe (LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
5316
- thd->lex ->safe_to_cache_query = 0 ;
5316
+ thd->lex ->uncacheable (UNCACHEABLE_RAND); // disallow cache and query merges
5317
5317
DBUG_RETURN (new (thd->mem_root ) Item_func_uuid_short (thd));
5318
5318
}
5319
5319
Original file line number Diff line number Diff line change @@ -3621,6 +3621,15 @@ struct LEX: public Query_tables_list
3621
3621
return (context_analysis_only & CONTEXT_ANALYSIS_ONLY_VIEW);
3622
3622
}
3623
3623
3624
+ /* *
3625
+ Mark all queries in this lex structure as uncacheable for the cause given
3626
+
3627
+ @param cause the reason queries are to be marked as uncacheable
3628
+
3629
+ Note, any cause is sufficient for st_select_lex_unit::can_be_merged() to
3630
+ disallow query merges.
3631
+ */
3632
+
3624
3633
inline void uncacheable (uint8 cause)
3625
3634
{
3626
3635
safe_to_cache_query= 0 ;
Original file line number Diff line number Diff line change 316
316
*/
317
317
/* This subquery has fields from outer query (put by user) */
318
318
#define UNCACHEABLE_DEPENDENT_GENERATED 1
319
- /* This subquery contains functions with random result */
319
+ /*
320
+ This subquery contains functions with random result.
321
+ Something that is uncacheable is by default unmergeable.
322
+ */
320
323
#define UNCACHEABLE_RAND 2
321
324
/* This subquery contains functions with side effect */
322
325
#define UNCACHEABLE_SIDEEFFECT 4
You can’t perform that action at this time.
0 commit comments