Below is the list of changes that have just been committed into a local
4.1 repository of bell. When bell does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2481 05/10/14 14:37:28 bell@stripped +8 -0
Make clone of field list before setup procedure call to protect it from changing in SELECT_LEX::item_list (BUG#13673)
sql/sql_union.cc
1.145 05/10/14 14:37:25 bell@stripped +1 -1
JOIN::fields_list type changed to pointer from reference
sql/sql_select.h
1.77 05/10/14 14:37:25 bell@stripped +3 -4
JOIN::fields_list type changed to pointer from reference
sql/sql_select.cc
1.441 05/10/14 14:37:25 bell@stripped +37 -26
JOIN::fields_list type changed to pointer from reference
Make clone of field list before setup procedure call to protect it from changing in SELECT_LEX::item_list
sql/sql_list.h
1.32 05/10/14 14:37:25 bell@stripped +4 -0
list cloning method
sql/sql_list.cc
1.11 05/10/14 14:37:25 bell@stripped +31 -0
list cloning method
sql/item_subselect.cc
1.140 05/10/14 14:37:25 bell@stripped +1 -1
JOIN::fields_list type changed to pointer from reference
mysql-test/t/analyze.test
1.6 05/10/14 14:37:25 bell@stripped +10 -0
procedure in PS
mysql-test/r/analyze.result
1.3 05/10/14 14:37:25 bell@stripped +8 -0
procedure in PS
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: bell
# Host: sanja.is.com.ua
# Root: /home/bell/mysql/bk/work-qc-4.1
--- 1.10/sql/sql_list.cc 2005-06-05 20:38:41 +03:00
+++ 1.11/sql/sql_list.cc 2005-10-14 14:37:25 +03:00
@@ -37,3 +37,34 @@
while ((tmp= list->get()))
delete tmp;
}
+
+
+/*
+ Make given list clone, support self-cloning
+
+ SYNOPSIS
+ base_list::make_clone()
+ list list for cloning
+
+ RETIRN
+ FALSE OK
+ TRUE Error
+*/
+
+bool base_list::make_clone(base_list *list)
+{
+ list_node *el= list->first;
+ empty();
+ while(el->info)
+ {
+ if (!((*last)= new list_node(el->info, &end_of_list)))
+ {
+ return (TRUE);
+ }
+ last= &(*last)->next;
+ elements++;
+ el= el->next;
+ }
+ return FALSE;
+}
+
--- 1.31/sql/sql_list.h 2005-05-18 23:13:57 +03:00
+++ 1.32/sql/sql_list.h 2005-10-14 14:37:25 +03:00
@@ -180,6 +180,7 @@
inline void **head_ref() { return first != &end_of_list ? &first->info : 0; }
inline bool is_empty() { return first == &end_of_list ; }
inline list_node *last_ref() { return &end_of_list; }
+ bool make_clone(base_list *list);
friend class base_list_iterator;
friend class error_list;
friend class error_list_iterator;
@@ -332,6 +333,9 @@
inline T* head() {return (T*) base_list::head(); }
inline T** head_ref() {return (T**) base_list::head_ref(); }
inline T* pop() {return (T*) base_list::pop(); }
+ inline bool make_clone(List<T> *list)
+ { return base_list::make_clone(list); }
+
void delete_elements(void)
{
list_node *element,*next;
--- 1.440/sql/sql_select.cc 2005-10-13 17:25:25 +03:00
+++ 1.441/sql/sql_select.cc 2005-10-14 14:37:25 +03:00
@@ -266,11 +266,11 @@
/* Check that all tables, fields, conds and order are ok */
if (setup_tables(tables_list) ||
- setup_wild(thd, tables_list, fields_list, &all_fields, wild_num) ||
+ setup_wild(thd, tables_list, *fields_list, &all_fields, wild_num) ||
select_lex->setup_ref_array(thd, og_num) ||
- setup_fields(thd, (*rref_pointer_array), tables_list, fields_list, 1,
+ setup_fields(thd, (*rref_pointer_array), tables_list, *fields_list, 1,
&all_fields, 1) ||
- setup_without_group(thd, (*rref_pointer_array), tables_list, fields_list,
+ setup_without_group(thd, (*rref_pointer_array), tables_list, *fields_list,
all_fields, &conds, order, group_list,
&hidden_group_fields))
DBUG_RETURN(-1); /* purecov: inspected */
@@ -318,7 +318,7 @@
if (!group_list)
{
uint flag=0;
- List_iterator_fast<Item> it(fields_list);
+ List_iterator_fast<Item> it(*fields_list);
Item *item;
while ((item= it++))
{
@@ -343,13 +343,24 @@
for (ORDER *group_tmp= group_list ; group_tmp ; group_tmp= group_tmp->next)
send_group_parts++;
}
-
- procedure= setup_procedure(thd, proc_param, result, fields_list, &error);
+ /*
+ Make clone of field list, to protect list refered from SELECT_LEX from
+ changing by procedure, because we will need it again if it is SP or PS
+ */
+ if (!thd->current_arena->is_conventional_execution())
+ {
+ List<Item> *list= new(thd->mem_root) List<Item>;
+ if (!list || list->make_clone(fields_list))
+ DBUG_RETURN(-1); // End Of Memory
+ fields_list= list;
+ }
+
+ procedure= setup_procedure(thd, proc_param, result, *fields_list, &error);
if (error)
goto err; /* purecov: inspected */
if (procedure)
{
- if (setup_new_fields(thd, tables_list, fields_list, all_fields,
+ if (setup_new_fields(thd, tables_list, *fields_list, all_fields,
procedure->param_fields))
goto err; /* purecov: inspected */
if (procedure->group)
@@ -404,7 +415,7 @@
is the same table (Bug #6034). Do the preparation after the select phase.
*/
if (! procedure && ! test(select_options & OPTION_BUFFER_RESULT) &&
- result && result->prepare(fields_list, unit_arg))
+ result && result->prepare(*fields_list, unit_arg))
goto err; /* purecov: inspected */
if (select_lex->olap == ROLLUP_TYPE && rollup_init())
@@ -643,7 +654,7 @@
if (order)
skip_sort_order= test_if_skip_sort_order(tab, order, select_limit, 1);
if ((group_list=create_distinct_group(thd, select_lex->ref_pointer_array,
- order, fields_list,
+ order, *fields_list,
&all_order_fields_used)))
{
bool skip_group= (skip_sort_order &&
@@ -868,7 +879,7 @@
init_items_ref_array();
tmp_table_param.hidden_field_count= (all_fields.elements -
- fields_list.elements);
+ fields_list->elements);
if (!(exec_tmp_table1 =
create_tmp_table(thd, &tmp_table_param, all_fields,
((!simple_group && !procedure &&
@@ -904,13 +915,13 @@
if (create_sort_index(thd, this, group_list,
HA_POS_ERROR, HA_POS_ERROR) ||
alloc_group_fields(this, group_list) ||
- make_sum_func_list(all_fields, fields_list, 1))
+ make_sum_func_list(all_fields, *fields_list, 1))
DBUG_RETURN(1);
group_list=0;
}
else
{
- if (make_sum_func_list(all_fields, fields_list, 0))
+ if (make_sum_func_list(all_fields, *fields_list, 0))
DBUG_RETURN(1);
if (!group_list && ! exec_tmp_table1->distinct && order && simple_order)
{
@@ -1049,15 +1060,15 @@
error= 0;
if (procedure)
{
- if (procedure->change_columns(fields_list) ||
- result->prepare(fields_list, unit))
+ if (procedure->change_columns(*fields_list) ||
+ result->prepare(*fields_list, unit))
{
thd->limit_found_rows= thd->examined_row_count= 0;
DBUG_VOID_RETURN;
}
}
else if (test(select_options & OPTION_BUFFER_RESULT) &&
- result && result->prepare(fields_list, unit))
+ result && result->prepare(*fields_list, unit))
{
error= 1;
thd->limit_found_rows= thd->examined_row_count= 0;
@@ -1071,7 +1082,7 @@
(zero_result_cause?zero_result_cause:"No tables used"));
else
{
- result->send_fields(fields_list,1);
+ result->send_fields(*fields_list, 1);
/*
We have to test for 'conds' here as the WHERE may not be constant
even if we don't have any tables for prepared statements or if
@@ -1081,9 +1092,9 @@
(!conds || conds->val_int()) &&
(!having || having->val_int()))
{
- if (do_send_rows && (procedure ? (procedure->send_row(fields_list) ||
+ if (do_send_rows && (procedure ? (procedure->send_row(*fields_list) ||
procedure->end_of_records())
- : result->send_data(fields_list)))
+ : result->send_data(*fields_list)))
error= 1;
else
{
@@ -1107,7 +1118,7 @@
if (zero_result_cause)
{
- (void) return_zero_rows(this, result, tables_list, fields_list,
+ (void) return_zero_rows(this, result, tables_list, *fields_list,
send_row_on_empty_set(),
select_options,
zero_result_cause,
@@ -1148,7 +1159,7 @@
JOIN *curr_join= this;
List<Item> *curr_all_fields= &all_fields;
- List<Item> *curr_fields_list= &fields_list;
+ List<Item> *curr_fields_list= fields_list;
TABLE *curr_tmp_table= 0;
/* Create a tmp table if distinct or if the sort is too complicated */
@@ -1180,14 +1191,14 @@
{
if (change_to_use_tmp_fields(thd, items1,
tmp_fields_list1, tmp_all_fields1,
- fields_list.elements, all_fields))
+ fields_list->elements, all_fields))
DBUG_VOID_RETURN;
}
else
{
if (change_refs_to_tmp_fields(thd, items1,
tmp_fields_list1, tmp_all_fields1,
- fields_list.elements, all_fields))
+ fields_list->elements, all_fields))
DBUG_VOID_RETURN;
}
curr_join->tmp_all_fields1= tmp_all_fields1;
@@ -1322,7 +1333,7 @@
items2= items1 + all_fields.elements;
if (change_to_use_tmp_fields(thd, items2,
tmp_fields_list2, tmp_all_fields2,
- fields_list.elements, tmp_all_fields1))
+ fields_list->elements, tmp_all_fields1))
DBUG_VOID_RETURN;
curr_join->tmp_fields_list2= tmp_fields_list2;
curr_join->tmp_all_fields2= tmp_all_fields2;
@@ -8945,7 +8956,7 @@
disctinct->group_by optimization
*/
if (select_distinct)
- group_parts+= fields_list.elements;
+ group_parts+= fields_list->elements;
/* This must use calloc() as rollup_make_fields depends on this */
sum_funcs= (Item_sum**) thd->calloc(sizeof(Item_sum**) * (func_count+1) +
@@ -9390,7 +9401,7 @@
}
for (i= 0 ; i < send_group_parts; i++)
{
- for (j=0 ; j < fields_list.elements ; j++)
+ for (j=0 ; j < fields_list->elements ; j++)
rollup.fields[i].push_back(rollup.null_items[i]);
}
List_iterator_fast<Item> it(all_fields);
@@ -10162,7 +10173,7 @@
{
DBUG_ENTER("JOIN::change_result");
result= res;
- if (!procedure && result->prepare(fields_list, select_lex->master_unit()))
+ if (!procedure && result->prepare(*fields_list, select_lex->master_unit()))
{
DBUG_RETURN(-1);
}
--- 1.76/sql/sql_select.h 2005-06-23 16:13:38 +03:00
+++ 1.77/sql/sql_select.h 2005-10-14 14:37:25 +03:00
@@ -203,7 +203,7 @@
List<Item> tmp_all_fields1, tmp_all_fields2, tmp_all_fields3;
//Part, shared with list above, emulate following list
List<Item> tmp_fields_list1, tmp_fields_list2, tmp_fields_list3;
- List<Item> &fields_list; // hold field list passed to mysql_select
+ List<Item> *fields_list; // hold field list passed to mysql_select
int error;
ORDER *order, *group_list, *proc_param; //hold parameters of mysql_select
@@ -222,7 +222,7 @@
JOIN(THD *thd_arg, List<Item> &fields_arg, ulong select_options_arg,
select_result *result_arg)
- :fields_list(fields_arg)
+ :fields_list(&fields_arg)
{
init(thd_arg, fields_arg, select_options_arg, result_arg);
}
@@ -261,7 +261,7 @@
buffer_result= test(select_options & OPTION_BUFFER_RESULT) &&
!test(select_options & OPTION_FOUND_ROWS);
all_fields= fields_arg;
- fields_list= fields_arg;
+ fields_list= &fields_arg;
error= 0;
select= 0;
ref_pointer_array= items0= items1= items2= items3= 0;
@@ -269,7 +269,6 @@
zero_result_cause= 0;
optimized= 0;
- fields_list= fields_arg;
bzero((char*) &keyuse,sizeof(keyuse));
tmp_table_param.copy_field=0;
tmp_table_param.end_write_records= HA_POS_ERROR;
--- 1.144/sql/sql_union.cc 2005-08-09 00:13:46 +03:00
+++ 1.145/sql/sql_union.cc 2005-10-14 14:37:25 +03:00
@@ -169,7 +169,7 @@
select_limit_cnt= HA_POS_ERROR;
offset_limit_cnt= 0;
if (!sl->join->procedure &&
- result->prepare(sl->join->fields_list, this))
+ result->prepare(*sl->join->fields_list, this))
{
DBUG_RETURN(1);
}
--- 1.139/sql/item_subselect.cc 2005-08-13 07:45:07 +03:00
+++ 1.140/sql/item_subselect.cc 2005-10-14 14:37:25 +03:00
@@ -1577,7 +1577,7 @@
uint subselect_single_select_engine::cols()
{
DBUG_ASSERT(select_lex->join); // should be called after fix_fields()
- return select_lex->join->fields_list.elements;
+ return select_lex->join->fields_list->elements;
}
--- 1.2/mysql-test/r/analyze.result 2005-09-15 17:18:52 +03:00
+++ 1.3/mysql-test/r/analyze.result 2005-10-14 14:37:25 +03:00
@@ -30,3 +30,11 @@
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
+CREATE TABLE t1 (a int);
+prepare stmt1 from "SELECT * FROM t1 PROCEDURE ANALYSE()";
+execute stmt1;
+Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
+execute stmt1;
+Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
+deallocate prepare stmt1;
+drop table t1;
--- 1.5/mysql-test/t/analyze.test 2005-09-15 17:17:08 +03:00
+++ 1.6/mysql-test/t/analyze.test 2005-10-14 14:37:25 +03:00
@@ -39,4 +39,14 @@
drop table t1;
+#
+# procedure in PS BUG#13673
+#
+CREATE TABLE t1 (a int);
+prepare stmt1 from "SELECT * FROM t1 PROCEDURE ANALYSE()";
+execute stmt1;
+execute stmt1;
+deallocate prepare stmt1;
+drop table t1;
+
# End of 4.1 tests
| Thread |
|---|
| • bk commit into 4.1 tree (bell:1.2481) BUG#13673 | sanja | 14 Oct |