mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-32583 UUID() should be treated as stochastic for the purposes of forcing query materialization
RAND() and UUID() are treated differently with respect to subquery materialization both should be marked as uncacheable, forcing materialization. Altered Create_func_uuid(_short)::create_builder(). Added comment in header about UNCACHEABLE_RAND meaning also unmergeable.
This commit is contained in:
@ -1732,3 +1732,16 @@ RELEASE_ALL_LOCKS()
|
||||
SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA
|
||||
FROM information_schema.metadata_lock_info WHERE thread_id>0 ORDER BY TABLE_SCHEMA;
|
||||
LOCK_MODE LOCK_TYPE TABLE_SCHEMA
|
||||
#
|
||||
# MDEV-32583 UUID() should be treated as stochastic for the purposes of
|
||||
# forcing query materialization
|
||||
#
|
||||
create table t1 as WITH cte AS (SELECT UUID() as r FROM seq_1_to_10)
|
||||
SELECT r as r1, r FROM cte;
|
||||
select count(*) from t1 where r1!=r;
|
||||
count(*)
|
||||
0
|
||||
drop table t1;
|
||||
#
|
||||
# End of 10.5 tests
|
||||
#
|
||||
|
@ -1361,3 +1361,18 @@ FROM information_schema.metadata_lock_info WHERE thread_id>0 ORDER BY TABLE_SCHE
|
||||
|
||||
--enable_ps2_protocol
|
||||
--enable_view_protocol
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-32583 UUID() should be treated as stochastic for the purposes of
|
||||
--echo # forcing query materialization
|
||||
--echo #
|
||||
|
||||
--source include/have_sequence.inc
|
||||
create table t1 as WITH cte AS (SELECT UUID() as r FROM seq_1_to_10)
|
||||
SELECT r as r1, r FROM cte;
|
||||
select count(*) from t1 where r1!=r;
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.5 tests
|
||||
--echo #
|
||||
|
@ -5301,7 +5301,7 @@ Create_func_uuid::create_builder(THD *thd)
|
||||
{
|
||||
DBUG_ENTER("Create_func_uuid::create");
|
||||
thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
|
||||
thd->lex->safe_to_cache_query= 0;
|
||||
thd->lex->uncacheable(UNCACHEABLE_RAND); // disallow cache and query merges
|
||||
DBUG_RETURN(new (thd->mem_root) Item_func_uuid(thd));
|
||||
}
|
||||
|
||||
@ -5313,7 +5313,7 @@ Create_func_uuid_short::create_builder(THD *thd)
|
||||
{
|
||||
DBUG_ENTER("Create_func_uuid_short::create");
|
||||
thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
|
||||
thd->lex->safe_to_cache_query= 0;
|
||||
thd->lex->uncacheable(UNCACHEABLE_RAND); // disallow cache and query merges
|
||||
DBUG_RETURN(new (thd->mem_root) Item_func_uuid_short(thd));
|
||||
}
|
||||
|
||||
|
@ -3621,6 +3621,15 @@ public:
|
||||
return (context_analysis_only & CONTEXT_ANALYSIS_ONLY_VIEW);
|
||||
}
|
||||
|
||||
/**
|
||||
Mark all queries in this lex structure as uncacheable for the cause given
|
||||
|
||||
@param cause the reason queries are to be marked as uncacheable
|
||||
|
||||
Note, any cause is sufficient for st_select_lex_unit::can_be_merged() to
|
||||
disallow query merges.
|
||||
*/
|
||||
|
||||
inline void uncacheable(uint8 cause)
|
||||
{
|
||||
safe_to_cache_query= 0;
|
||||
|
@ -316,7 +316,10 @@
|
||||
*/
|
||||
/* This subquery has fields from outer query (put by user) */
|
||||
#define UNCACHEABLE_DEPENDENT_GENERATED 1
|
||||
/* This subquery contains functions with random result */
|
||||
/*
|
||||
This subquery contains functions with random result.
|
||||
Something that is uncacheable is by default unmergeable.
|
||||
*/
|
||||
#define UNCACHEABLE_RAND 2
|
||||
/* This subquery contains functions with side effect */
|
||||
#define UNCACHEABLE_SIDEEFFECT 4
|
||||
|
Reference in New Issue
Block a user