summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/derived.result11
-rw-r--r--mysql-test/r/multi_update.result11
-rw-r--r--mysql-test/r/view.result13
-rw-r--r--mysql-test/suite/innodb/r/innodb_multi_update.result8
-rw-r--r--mysql-test/suite/innodb/t/innodb_multi_update.test9
-rw-r--r--mysql-test/t/derived.test11
-rw-r--r--mysql-test/t/multi_update.test11
-rw-r--r--mysql-test/t/view.test16
-rw-r--r--sql/item.cc11
-rw-r--r--sql/item_cmpfunc.cc10
-rw-r--r--sql/item_func.cc2
-rw-r--r--sql/item_row.cc8
-rw-r--r--sql/item_subselect.cc20
-rw-r--r--sql/item_subselect.h1
-rw-r--r--sql/sql_class.h2
-rw-r--r--sql/sql_derived.cc3
-rw-r--r--sql/sql_lex.cc2
-rw-r--r--sql/sql_lex.h16
-rw-r--r--sql/sql_parse.cc7
-rw-r--r--sql/sql_prepare.cc18
-rw-r--r--sql/sql_priv.h33
-rw-r--r--sql/sql_select.cc3
-rw-r--r--sql/sql_show.cc8
-rw-r--r--sql/sql_view.cc2
24 files changed, 153 insertions, 83 deletions
diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result
index 53cd89c13c1..d5a0c320d60 100644
--- a/mysql-test/r/derived.result
+++ b/mysql-test/r/derived.result
@@ -400,4 +400,15 @@ SELECT 0 FROM
(SELECT 0) t61;
0
0
+#
+# A nested materialized derived table is used before being populated.
+# (addon for bug#19077)
+#
+CREATE TABLE t1 (i INT, j BIGINT);
+INSERT INTO t1 VALUES (1, 2), (2, 2), (3, 2);
+SELECT * FROM (SELECT MIN(i) FROM t1
+WHERE j = SUBSTRING('12', (SELECT * FROM (SELECT MIN(j) FROM t1) t2))) t3;
+MIN(i)
+1
+DROP TABLE t1;
# End of 5.0 tests
diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result
index 07a92e2abf0..e36bef1f338 100644
--- a/mysql-test/r/multi_update.result
+++ b/mysql-test/r/multi_update.result
@@ -669,4 +669,15 @@ Error 1242 Subquery returns more than 1 row
Error 1242 Subquery returns more than 1 row
DROP TABLE t1, t2, t3;
SET SESSION sql_safe_updates = DEFAULT;
+#
+# Bug#52157 various crashes and assertions with multi-table update, stored function
+#
+CREATE FUNCTION f1 () RETURNS BLOB RETURN 1;
+CREATE TABLE t1 (f1 DATE);
+INSERT INTO t1 VALUES('2001-01-01');
+UPDATE (SELECT 1 FROM t1 WHERE f1 = (SELECT f1() FROM t1)) x, t1 SET f1 = 1;
+Warnings:
+Warning 1292 Truncated incorrect datetime value: '1'
+DROP FUNCTION f1;
+DROP TABLE t1;
end of tests
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 8d39b4e596b..fdeed10701d 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -3999,6 +3999,19 @@ CREATE VIEW v1 AS SELECT 1 from t1
WHERE t1.b <=> (SELECT a FROM t1 WHERE a < SOME(SELECT '1'));
DROP VIEW v1;
DROP TABLE t1;
+#
+# Bug#57703 create view cause Assertion failed: 0, file .\item_subselect.cc, line 846
+#
+CREATE TABLE t1(a int);
+CREATE VIEW v1 AS SELECT 1 FROM t1 GROUP BY
+SUBSTRING(1 FROM (SELECT 3 FROM t1 WHERE a >= ANY(SELECT 1)));
+DROP VIEW v1;
+DROP TABLE t1;
+#
+# Bug#57352 valgrind warnings when creating view
+#
+CREATE VIEW v1 AS SELECT 1 IN (1 LIKE 2,0) AS f;
+DROP VIEW v1;
# -----------------------------------------------------------------
# -- End of 5.1 tests.
# -----------------------------------------------------------------
diff --git a/mysql-test/suite/innodb/r/innodb_multi_update.result b/mysql-test/suite/innodb/r/innodb_multi_update.result
index 7af9b030d1f..558fc3938a8 100644
--- a/mysql-test/suite/innodb/r/innodb_multi_update.result
+++ b/mysql-test/suite/innodb/r/innodb_multi_update.result
@@ -74,3 +74,11 @@ a b
4 14
5 15
drop table bug38999_1,bug38999_2;
+#
+# Bug#54475 improper error handling causes cascading crashing failures in innodb/ndb
+#
+CREATE TABLE t1(f1 INT) ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+UPDATE (SELECT ((SELECT 1 FROM t1), 1) FROM t1 WHERE (SELECT 1 FROM t1)) x, (SELECT 1) AS d SET d.f1 = 1;
+ERROR 21000: Operand should contain 1 column(s)
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/t/innodb_multi_update.test b/mysql-test/suite/innodb/t/innodb_multi_update.test
index 7ab17ccf70a..778f4e980ca 100644
--- a/mysql-test/suite/innodb/t/innodb_multi_update.test
+++ b/mysql-test/suite/innodb/t/innodb_multi_update.test
@@ -27,3 +27,12 @@ select * from bug38999_1;
select * from bug38999_2;
drop table bug38999_1,bug38999_2;
+
+--echo #
+--echo # Bug#54475 improper error handling causes cascading crashing failures in innodb/ndb
+--echo #
+CREATE TABLE t1(f1 INT) ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+--error ER_OPERAND_COLUMNS
+UPDATE (SELECT ((SELECT 1 FROM t1), 1) FROM t1 WHERE (SELECT 1 FROM t1)) x, (SELECT 1) AS d SET d.f1 = 1;
+DROP TABLE t1;
diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test
index 27e85ee237b..939d370cc78 100644
--- a/mysql-test/t/derived.test
+++ b/mysql-test/t/derived.test
@@ -301,4 +301,15 @@ SELECT 0 FROM
(SELECT 0) t56, (SELECT 0) t57, (SELECT 0) t58, (SELECT 0) t59, (SELECT 0) t60,
(SELECT 0) t61; # 61 == MAX_TABLES
+--echo #
+--echo # A nested materialized derived table is used before being populated.
+--echo # (addon for bug#19077)
+--echo #
+
+CREATE TABLE t1 (i INT, j BIGINT);
+INSERT INTO t1 VALUES (1, 2), (2, 2), (3, 2);
+SELECT * FROM (SELECT MIN(i) FROM t1
+WHERE j = SUBSTRING('12', (SELECT * FROM (SELECT MIN(j) FROM t1) t2))) t3;
+DROP TABLE t1;
+
--echo # End of 5.0 tests
diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test
index 8ed0ed45b82..0e2abe578ce 100644
--- a/mysql-test/t/multi_update.test
+++ b/mysql-test/t/multi_update.test
@@ -672,4 +672,15 @@ SET t3.a = 0;
DROP TABLE t1, t2, t3;
SET SESSION sql_safe_updates = DEFAULT;
+--echo #
+--echo # Bug#52157 various crashes and assertions with multi-table update, stored function
+--echo #
+
+CREATE FUNCTION f1 () RETURNS BLOB RETURN 1;
+CREATE TABLE t1 (f1 DATE);
+INSERT INTO t1 VALUES('2001-01-01');
+UPDATE (SELECT 1 FROM t1 WHERE f1 = (SELECT f1() FROM t1)) x, t1 SET f1 = 1;
+DROP FUNCTION f1;
+DROP TABLE t1;
+
--echo end of tests
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 236f2e84770..c82443e792f 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -3963,6 +3963,22 @@ WHERE t1.b <=> (SELECT a FROM t1 WHERE a < SOME(SELECT '1'));
DROP VIEW v1;
DROP TABLE t1;
+--echo #
+--echo # Bug#57703 create view cause Assertion failed: 0, file .\item_subselect.cc, line 846
+--echo #
+
+CREATE TABLE t1(a int);
+CREATE VIEW v1 AS SELECT 1 FROM t1 GROUP BY
+SUBSTRING(1 FROM (SELECT 3 FROM t1 WHERE a >= ANY(SELECT 1)));
+DROP VIEW v1;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#57352 valgrind warnings when creating view
+--echo #
+CREATE VIEW v1 AS SELECT 1 IN (1 LIKE 2,0) AS f;
+DROP VIEW v1;
+
--echo # -----------------------------------------------------------------
--echo # -- End of 5.1 tests.
--echo # -----------------------------------------------------------------
diff --git a/sql/item.cc b/sql/item.cc
index e14c3c95934..5645a1bee1c 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1812,16 +1812,7 @@ bool agg_item_set_converter(DTCollation &coll, const char *fname,
if (!(conv= (*arg)->safe_charset_converter(coll.collation)) &&
((*arg)->collation.repertoire == MY_REPERTOIRE_ASCII))
- {
- /*
- We should disable const subselect item evaluation because
- subselect transformation does not happen in view_prepare_mode
- and thus val_...() methods can not be called for const items.
- */
- bool resolve_const= ((*arg)->type() == Item::SUBSELECT_ITEM &&
- thd->lex->view_prepare_mode) ? FALSE : TRUE;
- conv= new Item_func_conv_charset(*arg, coll.collation, resolve_const);
- }
+ conv= new Item_func_conv_charset(*arg, coll.collation, 1);
if (!conv)
{
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index b04ec105468..18a92c6b8c2 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -403,7 +403,7 @@ static bool convert_constant_item(THD *thd, Item_field *field_item,
Field *field= field_item->field;
int result= 0;
- if (!(*item)->with_subselect && (*item)->const_item())
+ if ((*item)->const_item())
{
TABLE *table= field->table;
ulonglong orig_sql_mode= thd->variables.sql_mode;
@@ -499,7 +499,7 @@ void Item_bool_func2::fix_length_and_dec()
}
thd= current_thd;
- if (!thd->is_context_analysis_only())
+ if (!thd->lex->is_ps_or_view_context_analysis())
{
if (args[0]->real_item()->type() == FIELD_ITEM)
{
@@ -803,7 +803,7 @@ Arg_comparator::can_compare_as_dates(Item *a, Item *b, ulonglong *const_value)
confuse storage engines since in context analysis mode tables
aren't locked.
*/
- if (!thd->is_context_analysis_only() &&
+ if (!thd->lex->is_ps_or_view_context_analysis() &&
cmp_type != CMP_DATE_WITH_DATE && str_arg->const_item() &&
(str_arg->type() != Item::FUNC_ITEM ||
((Item_func*)str_arg)->functype() != Item_func::GUSERVAR_FUNC))
@@ -1036,7 +1036,7 @@ Item** Arg_comparator::cache_converted_constant(THD *thd_arg, Item **value,
Item_result type)
{
/* Don't need cache if doing context analysis only. */
- if (!thd_arg->is_context_analysis_only() &&
+ if (!thd->lex->is_ps_or_view_context_analysis() &&
(*value)->const_item() && type != (*value)->result_type())
{
Item_cache *cache= Item_cache::get_cache(*value, type);
@@ -4714,7 +4714,7 @@ bool Item_func_like::fix_fields(THD *thd, Item **ref)
return TRUE;
}
- if (escape_item->const_item() && !thd->lex->view_prepare_mode)
+ if (escape_item->const_item())
{
/* If we are on execution stage */
String *escape_str= escape_item->val_str(&cmp.value1);
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 92b80e274f4..ecc4f30e25d 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -6492,7 +6492,7 @@ Item_func_sp::fix_fields(THD *thd, Item **ref)
if (res)
DBUG_RETURN(res);
- if (thd->lex->view_prepare_mode)
+ if (thd->lex->context_analysis_only & CONTEXT_ANALYSIS_ONLY_VIEW)
{
/*
Here we check privileges of the stored routine only during view
diff --git a/sql/item_row.cc b/sql/item_row.cc
index 2fbf0c12499..94515640625 100644
--- a/sql/item_row.cc
+++ b/sql/item_row.cc
@@ -80,12 +80,8 @@ bool Item_row::fix_fields(THD *thd, Item **ref)
used_tables_cache |= item->used_tables();
const_item_cache&= item->const_item() && !with_null;
not_null_tables_cache|= item->not_null_tables();
- /*
- Some subqueries transformations aren't done in the view_prepare_mode thus
- is_null() will fail. So we skip is_null() calculation for CREATE VIEW as
- not necessary.
- */
- if (const_item_cache && !thd->lex->view_prepare_mode)
+
+ if (const_item_cache)
{
if (item->cols() > 1)
with_null|= item->null_inside();
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index c1b1f47e5e9..7ed24a03025 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -131,20 +131,6 @@ void Item_subselect::cleanup()
}
-/*
- We cannot use generic Item::safe_charset_converter() because
- Subselect transformation does not happen in view_prepare_mode
- and thus we can not evaluate val_...() for const items.
-*/
-
-Item *Item_subselect::safe_charset_converter(CHARSET_INFO *tocs)
-{
- Item_func_conv_charset *conv=
- new Item_func_conv_charset(this, tocs, thd->lex->view_prepare_mode ? 0 : 1);
- return conv->safe ? conv : NULL;
-}
-
-
void Item_singlerow_subselect::cleanup()
{
DBUG_ENTER("Item_singlerow_subselect::cleanup");
@@ -279,6 +265,7 @@ bool Item_subselect::exec()
if (thd->is_error() || thd->killed)
return 1;
+ DBUG_ASSERT(!thd->lex->context_analysis_only);
/*
Simulate a failure in sub-query execution. Used to test e.g.
out of memory or query being killed conditions.
@@ -315,7 +302,7 @@ table_map Item_subselect::used_tables() const
bool Item_subselect::const_item() const
{
- return const_item_cache;
+ return thd->lex->context_analysis_only ? FALSE : const_item_cache;
}
Item *Item_subselect::get_tmp_table_item(THD *thd_arg)
@@ -1646,7 +1633,8 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
{
bool result = 0;
- if (thd_arg->lex->view_prepare_mode && left_expr && !left_expr->fixed)
+ if ((thd_arg->lex->context_analysis_only & CONTEXT_ANALYSIS_ONLY_VIEW) &&
+ left_expr && !left_expr->fixed)
result = left_expr->fix_fields(thd_arg, &left_expr);
return result || Item_subselect::fix_fields(thd_arg, ref);
diff --git a/sql/item_subselect.h b/sql/item_subselect.h
index d8d18fd8ef6..3f8726eddc7 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -138,7 +138,6 @@ public:
virtual void reset_value_registration() {}
enum_parsing_place place() { return parsing_place; }
bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
- Item *safe_charset_converter(CHARSET_INFO *tocs);
/**
Get the SELECT_LEX structure associated with this Item.
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 02f28b54e10..db20fd73b42 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -2503,8 +2503,6 @@ public:
(variables.sql_mode & MODE_STRICT_ALL_TABLES)));
}
void set_status_var_init();
- bool is_context_analysis_only()
- { return stmt_arena->is_stmt_prepare() || lex->view_prepare_mode; }
void reset_n_backup_open_tables_state(Open_tables_backup *backup);
void restore_backup_open_tables_state(Open_tables_backup *backup);
void reset_sub_statement_state(Sub_statement_state *backup, uint new_state);
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index 47bc13beb53..4a7b3e98935 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -151,10 +151,11 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *orig_table_list)
if (!(derived_result= new select_union))
DBUG_RETURN(TRUE); // out of memory
+ lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_DERIVED;
// st_select_lex_unit::prepare correctly work for single select
if ((res= unit->prepare(thd, derived_result, 0)))
goto exit;
-
+ lex->context_analysis_only&= ~CONTEXT_ANALYSIS_ONLY_DERIVED;
if ((res= check_duplicate_names(unit->types, 0)))
goto exit;
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 7a8a86d3ca4..5e8ecc6b815 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -383,7 +383,7 @@ void lex_start(THD *thd)
lex->select_lex.group_list.empty();
lex->describe= 0;
lex->subqueries= FALSE;
- lex->view_prepare_mode= FALSE;
+ lex->context_analysis_only= 0;
lex->derived_tables= 0;
lex->safe_to_cache_query= 1;
lex->leaf_tables_insert= 0;
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 191562bd3e8..2d11bc7aad7 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -2286,19 +2286,12 @@ struct LEX: public Query_tables_list
uint8 derived_tables;
uint8 create_view_algorithm;
uint8 create_view_check;
+ uint8 context_analysis_only;
bool drop_if_exists, drop_temporary, local_file, one_shot_set;
bool autocommit;
bool verbose, no_write_to_binlog;
enum enum_yes_no_unknown tx_chain, tx_release;
- /*
- Special JOIN::prepare mode: changing of query is prohibited.
- When creating a view, we need to just check its syntax omitting
- any optimizations: afterwards definition of the view will be
- reconstructed by means of ::print() methods and written to
- to an .frm file. We need this definition to stay untouched.
- */
- bool view_prepare_mode;
bool safe_to_cache_query;
bool subqueries, ignore;
st_parsing_options parsing_options;
@@ -2403,6 +2396,13 @@ struct LEX: public Query_tables_list
delete_dynamic(&plugins);
}
+ inline bool is_ps_or_view_context_analysis()
+ {
+ return (context_analysis_only &
+ (CONTEXT_ANALYSIS_ONLY_PREPARE |
+ CONTEXT_ANALYSIS_ONLY_VIEW));
+ }
+
inline void uncacheable(uint8 cause)
{
safe_to_cache_query= 0;
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 40cecb75b69..3d5f99c8953 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -5295,13 +5295,6 @@ mysql_new_select(LEX *lex, bool move_down)
DBUG_RETURN(1);
}
select_lex->nest_level= lex->nest_level;
- /*
- Don't evaluate this subquery during statement prepare even if
- it's a constant one. The flag is switched off in the end of
- mysqld_stmt_prepare.
- */
- if (thd->stmt_arena->is_stmt_prepare())
- select_lex->uncacheable|= UNCACHEABLE_PREPARE;
if (move_down)
{
SELECT_LEX_UNIT *unit;
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 4a1d1ae7fe3..345f7158dbf 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1780,7 +1780,7 @@ static bool mysql_test_create_view(Prepared_statement *stmt)
if (open_normal_and_derived_tables(thd, tables, MYSQL_OPEN_FORCE_SHARED_MDL))
goto err;
- lex->view_prepare_mode= 1;
+ lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW;
res= select_like_stmt_test(stmt, 0, 0);
err:
@@ -2292,19 +2292,6 @@ end:
}
-/** Init PS/SP specific parse tree members. */
-
-static void init_stmt_after_parse(LEX *lex)
-{
- SELECT_LEX *sl= lex->all_selects_list;
- /*
- Switch off a temporary flag that prevents evaluation of
- subqueries in statement prepare.
- */
- for (; sl; sl= sl->next_select_in_list())
- sl->uncacheable&= ~UNCACHEABLE_PREPARE;
-}
-
/**
SQLCOM_PREPARE implementation.
@@ -3223,6 +3210,7 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
parser_state.m_lip.multi_statements= FALSE;
lex_start(thd);
+ lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_PREPARE;
error= parse_sql(thd, & parser_state, NULL) ||
thd->is_error() ||
@@ -3283,7 +3271,7 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
if (error == 0)
{
setup_set_params();
- init_stmt_after_parse(lex);
+ lex->context_analysis_only&= ~CONTEXT_ANALYSIS_ONLY_PREPARE;
state= Query_arena::PREPARED;
flags&= ~ (uint) IS_IN_USE;
diff --git a/sql/sql_priv.h b/sql/sql_priv.h
index 4e1dac269b7..434dfb1e306 100644
--- a/sql/sql_priv.h
+++ b/sql/sql_priv.h
@@ -182,17 +182,42 @@
*/
+/*
+ Flags below are set when we perform
+ context analysis of the statement and make
+ subqueries non-const. It prevents subquery
+ evaluation at context analysis stage.
+*/
+
+/*
+ Don't evaluate this subquery during statement prepare even if
+ it's a constant one. The flag is switched off in the end of
+ mysqld_stmt_prepare.
+*/
+#define CONTEXT_ANALYSIS_ONLY_PREPARE 1
+/*
+ Special JOIN::prepare mode: changing of query is prohibited.
+ When creating a view, we need to just check its syntax omitting
+ any optimizations: afterwards definition of the view will be
+ reconstructed by means of ::print() methods and written to
+ to an .frm file. We need this definition to stay untouched.
+*/
+#define CONTEXT_ANALYSIS_ONLY_VIEW 2
+/*
+ Don't evaluate this subquery during derived table prepare even if
+ it's a constant one.
+*/
+#define CONTEXT_ANALYSIS_ONLY_DERIVED 4
+
// uncachable cause
#define UNCACHEABLE_DEPENDENT 1
#define UNCACHEABLE_RAND 2
#define UNCACHEABLE_SIDEEFFECT 4
/// forcing to save JOIN for explain
#define UNCACHEABLE_EXPLAIN 8
-/** Don't evaluate subqueries in prepare even if they're not correlated */
-#define UNCACHEABLE_PREPARE 16
/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
-#define UNCACHEABLE_UNITED 32
-#define UNCACHEABLE_CHECKOPTION 64
+#define UNCACHEABLE_UNITED 16
+#define UNCACHEABLE_CHECKOPTION 32
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
#define UNDEF_POS (-1)
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index e4772bf3fb2..e5d574192b1 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -567,7 +567,8 @@ JOIN::prepare(Item ***rref_pointer_array,
thd->lex->allow_sum_func= save_allow_sum_func;
}
- if (!thd->lex->view_prepare_mode && !(select_options & SELECT_DESCRIBE))
+ if (!(thd->lex->context_analysis_only & CONTEXT_ANALYSIS_ONLY_VIEW) &&
+ !(select_options & SELECT_DESCRIBE))
{
Item_subselect *subselect;
/* Is it subselect? */
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 2c71fe5dd48..58b15ed1ec7 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -674,7 +674,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
MDL_savepoint mdl_savepoint= thd->mdl_context.mdl_savepoint();
/* We want to preserve the tree for views. */
- thd->lex->view_prepare_mode= TRUE;
+ thd->lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW;
{
Show_create_error_handler view_error_suppressor(thd, table_list);
@@ -3435,7 +3435,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
uint derived_tables= lex->derived_tables;
int error= 1;
Open_tables_backup open_tables_state_backup;
- bool save_view_prepare_mode= lex->view_prepare_mode;
+ uint8 save_context_analysis_only= lex->context_analysis_only;
Query_tables_list query_tables_list_backup;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
Security_context *sctx= thd->security_ctx;
@@ -3455,7 +3455,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
*/
can_deadlock= thd->mdl_context.has_locks();
- lex->view_prepare_mode= TRUE;
+ lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW;
lex->reset_n_backup_query_tables_list(&query_tables_list_backup);
/*
Restore Query_tables_list::sql_command value, which was reset
@@ -3685,7 +3685,7 @@ err:
lex->restore_backup_query_tables_list(&query_tables_list_backup);
lex->derived_tables= derived_tables;
lex->all_selects_list= old_all_select_lex;
- lex->view_prepare_mode= save_view_prepare_mode;
+ lex->context_analysis_only= save_context_analysis_only;
DBUG_RETURN(error);
}
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 54b5eb43ab1..f569c679776 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -550,7 +550,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
}
/* prepare select to resolve all fields */
- lex->view_prepare_mode= 1;
+ lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW;
if (unit->prepare(thd, 0, 0))
{
/*