summaryrefslogtreecommitdiff
path: root/sql/sql_update.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2020-12-14 18:25:08 +0100
committerSergei Golubchik <serg@mariadb.org>2020-12-19 11:44:42 +0100
commita587ded283d8abd1f20258b283911abe759f5f64 (patch)
treed9c40466c58df8661bd11de698b4eee101cfac30 /sql/sql_update.cc
parent5785de72ac85ba37eda837c691aaf9a9195ba45d (diff)
downloadmariadb-git-a587ded283d8abd1f20258b283911abe759f5f64.tar.gz
MDEV-24346 valgrind error in main.precedence
in queries like create view v1 as select 2 like 1 escape (3 in (select 0 union select 1)); select 2 union select * from v1; Item_func_like::escape was left uninitialized, because Item_in_optimizer is const_during_execution() but not actually const_item() during execution. It's not, because const subquery evaluation was disabled for derived. Practically it only needs to be disabled for multi-update that runs fix_fields() before all tables are locked.
Diffstat (limited to 'sql/sql_update.cc')
-rw-r--r--sql/sql_update.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 5e40cd242a4..7454d16d55d 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -1534,7 +1534,11 @@ int mysql_multi_update_prepare(THD *thd)
During prepare phase acquire only S metadata locks instead of SW locks to
keep prepare of multi-UPDATE compatible with concurrent LOCK TABLES WRITE
and global read lock.
+
+ Don't evaluate any subqueries even if constant, because
+ tables aren't locked yet.
*/
+ lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_DERIVED;
if (thd->lex->sql_command == SQLCOM_UPDATE_MULTI)
{
if (open_tables(thd, &table_list, &table_count,
@@ -1557,6 +1561,9 @@ int mysql_multi_update_prepare(THD *thd)
{
DBUG_RETURN(TRUE);
}
+
+ lex->context_analysis_only&= ~CONTEXT_ANALYSIS_ONLY_DERIVED;
+
(void) read_statistics_for_tables_if_needed(thd, table_list);
/* @todo: downgrade the metadata locks here. */