summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/sql_cte.cc14
-rw-r--r--sql/sql_cte.h2
-rw-r--r--sql/sql_derived.cc2
-rw-r--r--sql/sql_view.h2
-rw-r--r--sql/sql_yacc.yy2
5 files changed, 13 insertions, 9 deletions
diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc
index 031208dafdb..ef2a0714d41 100644
--- a/sql/sql_cte.cc
+++ b/sql/sql_cte.cc
@@ -270,7 +270,7 @@ bool With_clause::prepare_unreferenced_elements(THD *thd)
bool With_element::set_unparsed_spec(THD *thd, char *spec_start, char *spec_end)
{
unparsed_spec.length= spec_end - spec_start;
- unparsed_spec.str= (char*) sql_memdup(spec_start, unparsed_spec.length+1);
+ unparsed_spec.str= (char*) thd->memdup(spec_start, unparsed_spec.length+1);
unparsed_spec.str[unparsed_spec.length]= '\0';
if (!unparsed_spec.str)
@@ -394,6 +394,8 @@ err:
@brief
Process optional column list of this with element
+ @param thd The context of the statement containing this with element
+
@details
The method processes the column list in this with element.
It reports an error if the cardinality of this list differs from
@@ -407,7 +409,7 @@ err:
false otherwise
*/
-bool With_element::process_column_list()
+bool With_element::process_column_list(THD *thd)
{
if (column_list_is_processed)
return false;
@@ -429,12 +431,12 @@ bool With_element::process_column_list()
/* Rename the columns of the first select in the specification query */
while ((item= it++, name= nm++))
{
- item->set_name(name->str, (uint) name->length, system_charset_info);
+ item->set_name(thd, name->str, (uint) name->length, system_charset_info);
item->is_autogenerated_name= false;
}
}
- make_valid_column_names(select->item_list);
+ make_valid_column_names(thd, select->item_list);
column_list_is_processed= true;
return false;
@@ -471,8 +473,8 @@ bool With_element::prepare_unreferenced(THD *thd)
thd->lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_DERIVED;
if (!spec->prepared &&
(spec->prepare(thd, 0, 0) ||
- process_column_list() ||
- check_duplicate_names(first_sl->item_list, 1)))
+ process_column_list(thd) ||
+ check_duplicate_names(thd, first_sl->item_list, 1)))
rc= true;
thd->lex->context_analysis_only&= ~CONTEXT_ANALYSIS_ONLY_DERIVED;
diff --git a/sql/sql_cte.h b/sql/sql_cte.h
index 5d3c0000581..1d572376f46 100644
--- a/sql/sql_cte.h
+++ b/sql/sql_cte.h
@@ -85,7 +85,7 @@ public:
st_select_lex_unit *clone_parsed_spec(THD *thd, TABLE_LIST *with_table);
- bool process_column_list();
+ bool process_column_list(THD *thd);
bool is_referenced() { return references != 0; }
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index e932480393e..978c6a1fdf6 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -672,7 +672,7 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived)
if ((res= unit->prepare(thd, derived->derived_result, 0)))
goto exit;
if (derived->with &&
- (res= derived->with->process_column_list()))
+ (res= derived->with->process_column_list(thd)))
goto exit;
lex->context_analysis_only&= ~CONTEXT_ANALYSIS_ONLY_DERIVED;
if ((res= check_duplicate_names(thd, unit->types, 0)))
diff --git a/sql/sql_view.h b/sql/sql_view.h
index 9f3881661b5..b9eb92198f8 100644
--- a/sql/sql_view.h
+++ b/sql/sql_view.h
@@ -56,6 +56,8 @@ bool check_duplicate_names(THD *thd, List<Item>& item_list,
bool mysql_rename_view(THD *thd, const char *new_db, const char *new_name,
TABLE_LIST *view);
+void make_valid_column_names(THD *thd, List<Item> &item_list);
+
#define VIEW_ANY_ACL (SELECT_ACL | UPDATE_ACL | INSERT_ACL | DELETE_ACL)
extern const LEX_STRING view_type;
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 0baf8d7e878..ce098084128 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -10868,7 +10868,7 @@ table_factor:
also do not merge them
*/
if (!sel->next_select())
- $2->select_n_where_fields+=
+ $3->select_n_where_fields+=
sel->select_n_where_fields;
}
/*else if (($4->select_lex &&