summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <sergefp@mysql.com>2005-10-29 02:19:38 +0400
committerunknown <sergefp@mysql.com>2005-10-29 02:19:38 +0400
commited9a29f1573a6ad9c0b8a934b957cf43ea7d5ffd (patch)
tree8d5a7123eb4ba9a89dc091331e247b81d1034f94
parent342c54884fcc2752473db6092481c9bcc4622cc6 (diff)
parentd942044cf1429c204fa509c2f0b690cbdc267c4a (diff)
downloadmariadb-git-ed9a29f1573a6ad9c0b8a934b957cf43ea7d5ffd.tar.gz
Merge spetrunia@bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/psergey/mysql-5.0-oct25-test
-rw-r--r--client/mysqldump.c2
-rw-r--r--mysql-test/r/analyse.result26
-rw-r--r--mysql-test/t/analyse.test25
-rw-r--r--sql/sql_select.cc24
-rw-r--r--sql/sql_select.h1
5 files changed, 67 insertions, 11 deletions
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 2ec1dd28f73..b92b971ea4f 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -342,7 +342,7 @@ static struct my_option my_long_options[] =
{"result-file", 'r',
"Direct output to a given file. This option should be used in MSDOS, because it prevents new line '\\n' from being converted to '\\r\\n' (carriage return + line feed).",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- {"routines", 'R', "Dump routines FUNCTIONS and PROCEDURES.",
+ {"routines", 'R', "Dump stored routines (functions and procedures).",
(gptr*) &opt_routines, (gptr*) &opt_routines, 0, GET_BOOL,
NO_ARG, 0, 0, 0, 0, 0, 0},
{"set-charset", OPT_SET_CHARSET,
diff --git a/mysql-test/r/analyse.result b/mysql-test/r/analyse.result
index df524b491f1..59c75c0f313 100644
--- a/mysql-test/r/analyse.result
+++ b/mysql-test/r/analyse.result
@@ -115,3 +115,29 @@ select * from t1 procedure analyse (1,1);
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
test.t1.d 100000 100000 6 6 0 0 100000 0 MEDIUMINT(6) UNSIGNED NOT NULL
drop table t1;
+create table t1 (product varchar(32), country_id int not null, year int,
+profit int);
+insert into t1 values ( 'Computer', 2,2000, 1200),
+( 'TV', 1, 1999, 150),
+( 'Calculator', 1, 1999,50),
+( 'Computer', 1, 1999,1500),
+( 'Computer', 1, 2000,1500),
+( 'TV', 1, 2000, 150),
+( 'TV', 2, 2000, 100),
+( 'TV', 2, 2000, 100),
+( 'Calculator', 1, 2000,75),
+( 'Calculator', 2, 2000,75),
+( 'TV', 1, 1999, 100),
+( 'Computer', 1, 1999,1200),
+( 'Computer', 2, 2000,1500),
+( 'Calculator', 2, 2000,75),
+( 'Phone', 3, 2003,10)
+;
+create table t2 (country_id int primary key, country char(20) not null);
+insert into t2 values (1, 'USA'),(2,'India'), (3,'Finland');
+select product, sum(profit),avg(profit) from t1 group by product with rollup procedure analyse();
+Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
+test.t1.product Computer TV 2 8 0 0 4.2500 NULL ENUM('Computer','Phone','TV') NOT NULL
+sum(profit) 10 6900 2 4 0 0 1946 2868 ENUM('10','275','600','6900') NOT NULL
+avg(profit) 10.0000 1380.0000 7 9 0 0 394.6875 570.2003 ENUM('10.0000','68.7500','120.0000','1380.0000') NOT NULL
+drop table t1,t2;
diff --git a/mysql-test/t/analyse.test b/mysql-test/t/analyse.test
index 4060892c389..a248c671c18 100644
--- a/mysql-test/t/analyse.test
+++ b/mysql-test/t/analyse.test
@@ -65,5 +65,30 @@ insert into t1 values (100000);
select * from t1 procedure analyse (1,1);
drop table t1;
+#
+# Bug #14138 ROLLUP and PROCEDURE ANALYSE() hang server
+#
+create table t1 (product varchar(32), country_id int not null, year int,
+ profit int);
+insert into t1 values ( 'Computer', 2,2000, 1200),
+ ( 'TV', 1, 1999, 150),
+ ( 'Calculator', 1, 1999,50),
+ ( 'Computer', 1, 1999,1500),
+ ( 'Computer', 1, 2000,1500),
+ ( 'TV', 1, 2000, 150),
+ ( 'TV', 2, 2000, 100),
+ ( 'TV', 2, 2000, 100),
+ ( 'Calculator', 1, 2000,75),
+ ( 'Calculator', 2, 2000,75),
+ ( 'TV', 1, 1999, 100),
+ ( 'Computer', 1, 1999,1200),
+ ( 'Computer', 2, 2000,1500),
+ ( 'Calculator', 2, 2000,75),
+ ( 'Phone', 3, 2003,10)
+ ;
+create table t2 (country_id int primary key, country char(20) not null);
+insert into t2 values (1, 'USA'),(2,'India'), (3,'Finland');
+select product, sum(profit),avg(profit) from t1 group by product with rollup procedure analyse();
+drop table t1,t2;
# End of 4.1 tests
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 44a600be725..af2e5879b95 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1175,18 +1175,21 @@ JOIN::save_join_tab()
void
JOIN::exec()
{
+ List<Item> *columns_list= &fields_list;
int tmp_error;
DBUG_ENTER("JOIN::exec");
error= 0;
if (procedure)
{
- if (procedure->change_columns(fields_list) ||
- result->prepare(fields_list, unit))
+ procedure_fields_list= fields_list;
+ if (procedure->change_columns(procedure_fields_list) ||
+ result->prepare(procedure_fields_list, unit))
{
thd->limit_found_rows= thd->examined_row_count= 0;
DBUG_VOID_RETURN;
}
+ columns_list= &procedure_fields_list;
}
(void) result->prepare2(); // Currently, this cannot fail.
@@ -1197,7 +1200,7 @@ JOIN::exec()
(zero_result_cause?zero_result_cause:"No tables used"));
else
{
- result->send_fields(fields_list,
+ result->send_fields(*columns_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF);
/*
We have to test for 'conds' here as the WHERE may not be constant
@@ -1208,9 +1211,9 @@ JOIN::exec()
(!conds || conds->val_int()) &&
(!having || having->val_int()))
{
- if (do_send_rows && (procedure ? (procedure->send_row(fields_list) ||
- procedure->end_of_records())
- : result->send_data(fields_list)))
+ if (do_send_rows &&
+ (procedure ? (procedure->send_row(procedure_fields_list) ||
+ procedure->end_of_records()) : result->send_data(fields_list)))
error= 1;
else
{
@@ -1234,7 +1237,7 @@ JOIN::exec()
if (zero_result_cause)
{
- (void) return_zero_rows(this, result, select_lex->leaf_tables, fields_list,
+ (void) return_zero_rows(this, result, select_lex->leaf_tables, *columns_list,
send_row_on_empty_set(),
select_options,
zero_result_cause,
@@ -1668,7 +1671,7 @@ JOIN::exec()
{
thd->proc_info="Sending data";
DBUG_PRINT("info", ("%s", thd->proc_info));
- result->send_fields(*curr_fields_list,
+ result->send_fields(*columns_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF);
error= do_select(curr_join, curr_fields_list, NULL, procedure);
thd->limit_found_rows= curr_join->send_records;
@@ -9020,6 +9023,7 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure)
int rc= 0;
enum_nested_loop_state error= NESTED_LOOP_OK;
JOIN_TAB *join_tab;
+ List<Item> *columns_list= procedure? &join->procedure_fields_list : fields;
DBUG_ENTER("do_select");
join->procedure=procedure;
@@ -9053,7 +9057,7 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure)
error= (*end_select)(join,join_tab,1);
}
else if (join->send_row_on_empty_set())
- rc= join->result->send_data(*join->fields);
+ rc= join->result->send_data(*columns_list);
}
else
{
@@ -10082,7 +10086,7 @@ end_send(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
DBUG_RETURN(NESTED_LOOP_OK); // Didn't match having
error=0;
if (join->procedure)
- error=join->procedure->send_row(*join->fields);
+ error=join->procedure->send_row(join->procedure_fields_list);
else if (join->do_send_rows)
error=join->result->send_data(*join->fields);
if (error)
diff --git a/sql/sql_select.h b/sql/sql_select.h
index d6161eb6372..e0f4056e5da 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -244,6 +244,7 @@ class JOIN :public Sql_alloc
//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> procedure_fields_list;
int error;
ORDER *order, *group_list, *proc_param; //hold parameters of mysql_select