Commit a454c695 authored by unknown's avatar unknown

Merge kboortz@bk-internal.mysql.com:/home/bk/mysql-5.0

into mysql.com:/Users/kent/mysql/bk/mysql-5.0


sql/sql_base.cc:
  Auto merged
parents f2b9c3e0 443b1686
...@@ -3062,12 +3062,6 @@ static int run_query_normal(MYSQL* mysql, struct st_query* q, int flags) ...@@ -3062,12 +3062,6 @@ static int run_query_normal(MYSQL* mysql, struct st_query* q, int flags)
goto end; goto end;
} }
if (handle_no_error(q))
{
error= 1;
goto end;
}
if (!disable_result_log) if (!disable_result_log)
{ {
ulong affected_rows; /* Ok to be undef if 'disable_info' is set */ ulong affected_rows; /* Ok to be undef if 'disable_info' is set */
...@@ -3112,12 +3106,9 @@ static int run_query_normal(MYSQL* mysql, struct st_query* q, int flags) ...@@ -3112,12 +3106,9 @@ static int run_query_normal(MYSQL* mysql, struct st_query* q, int flags)
MYSQL_RES *warn_res=0; MYSQL_RES *warn_res=0;
uint count= mysql_warning_count(mysql); uint count= mysql_warning_count(mysql);
if (!mysql_real_query(mysql, "SHOW WARNINGS", 13)) if (!mysql_real_query(mysql, "SHOW WARNINGS", 13))
{
warn_res= mysql_store_result(mysql); warn_res= mysql_store_result(mysql);
}
if (!warn_res) if (!warn_res)
verbose_msg("Warning count is %u but didn't get any warnings", die("Warning count is %u but didn't get any warnings", count);
count);
else else
{ {
dynstr_append_mem(ds, "Warnings:\n", 10); dynstr_append_mem(ds, "Warnings:\n", 10);
...@@ -3148,15 +3139,28 @@ static int run_query_normal(MYSQL* mysql, struct st_query* q, int flags) ...@@ -3148,15 +3139,28 @@ static int run_query_normal(MYSQL* mysql, struct st_query* q, int flags)
} }
else if (q->record_file[0]) else if (q->record_file[0])
{ {
error = check_result(ds, q->record_file, q->require_file); error= check_result(ds, q->record_file, q->require_file);
} }
if (res) if (res)
mysql_free_result(res); mysql_free_result(res);
last_result= 0; last_result= 0;
counter++; counter++;
} while (!(err= mysql_next_result(mysql))); } while (!(err= mysql_next_result(mysql)));
if (err >= 1) if (err > 0)
mysql_error(mysql); {
/* We got an error from mysql_next_result, maybe expected */
if (handle_error(query, q, mysql_errno(mysql), mysql_error(mysql),
mysql_sqlstate(mysql), ds))
error= 1;
goto end;
}
/* If we come here the query is both executed and read successfully */
if (handle_no_error(q))
{
error= 1;
goto end;
}
end: end:
free_replace(); free_replace();
...@@ -3209,8 +3213,7 @@ static int handle_error(const char *query, struct st_query *q, ...@@ -3209,8 +3213,7 @@ static int handle_error(const char *query, struct st_query *q,
abort_not_supported_test(); abort_not_supported_test();
if (q->abort_on_error) if (q->abort_on_error)
die("query '%s' failed: %d: %s", query, die("query '%s' failed: %d: %s", query, err_errno, err_error);
err_errno, err_error);
for (i= 0 ; (uint) i < q->expected_errors ; i++) for (i= 0 ; (uint) i < q->expected_errors ; i++)
{ {
...@@ -3249,13 +3252,11 @@ static int handle_error(const char *query, struct st_query *q, ...@@ -3249,13 +3252,11 @@ static int handle_error(const char *query, struct st_query *q,
if (i) if (i)
{ {
if (q->expected_errno[0].type == ERR_ERRNO) if (q->expected_errno[0].type == ERR_ERRNO)
verbose_msg("query '%s' failed with wrong errno %d instead of %d...", die("query '%s' failed with wrong errno %d instead of %d...",
q->query, err_errno, q->query, err_errno, q->expected_errno[0].code.errnum);
q->expected_errno[0].code.errnum);
else else
verbose_msg("query '%s' failed with wrong sqlstate %s instead of %s...", die("query '%s' failed with wrong sqlstate %s instead of %s...",
q->query, err_sqlstate, q->query, err_sqlstate, q->expected_errno[0].code.sqlstate);
q->expected_errno[0].code.sqlstate);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
...@@ -3289,16 +3290,16 @@ static int handle_no_error(struct st_query *q) ...@@ -3289,16 +3290,16 @@ static int handle_no_error(struct st_query *q)
q->expected_errno[0].code.errnum != 0) q->expected_errno[0].code.errnum != 0)
{ {
/* Error code we wanted was != 0, i.e. not an expected success */ /* Error code we wanted was != 0, i.e. not an expected success */
verbose_msg("query '%s' succeeded - should have failed with errno %d...", die("query '%s' succeeded - should have failed with errno %d...",
q->query, q->expected_errno[0].code.errnum); q->query, q->expected_errno[0].code.errnum);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
else if (q->expected_errno[0].type == ERR_SQLSTATE && else if (q->expected_errno[0].type == ERR_SQLSTATE &&
strcmp(q->expected_errno[0].code.sqlstate,"00000") != 0) strcmp(q->expected_errno[0].code.sqlstate,"00000") != 0)
{ {
/* SQLSTATE we wanted was != "00000", i.e. not an expected success */ /* SQLSTATE we wanted was != "00000", i.e. not an expected success */
verbose_msg("query '%s' succeeded - should have failed with sqlstate %s...", die("query '%s' succeeded - should have failed with sqlstate %s...",
q->query, q->expected_errno[0].code.sqlstate); q->query, q->expected_errno[0].code.sqlstate);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
...@@ -3318,7 +3319,7 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags) ...@@ -3318,7 +3319,7 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags)
{ {
int error= 0; /* Function return code if "goto end;" */ int error= 0; /* Function return code if "goto end;" */
int err; /* Temporary storage of return code from calls */ int err; /* Temporary storage of return code from calls */
int query_len, got_error_on_execute; int query_len;
ulonglong num_rows; ulonglong num_rows;
char *query; char *query;
MYSQL_RES *res= NULL; /* Note that here 'res' is meta data result set */ MYSQL_RES *res= NULL; /* Note that here 'res' is meta data result set */
...@@ -3334,7 +3335,7 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags) ...@@ -3334,7 +3335,7 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags)
*/ */
if (!(stmt= mysql_stmt_init(mysql))) if (!(stmt= mysql_stmt_init(mysql)))
die("unable init stmt structure"); die("unable init stmt structure");
if (q->type != Q_EVAL) if (q->type != Q_EVAL)
{ {
query= q->query; query= q->query;
...@@ -3375,30 +3376,21 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags) ...@@ -3375,30 +3376,21 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags)
if (err != 0) if (err != 0)
{ {
if (q->abort_on_error) /*
{ Preparing is part of normal execution and some errors may be expected
die("query '%s' failed: %d: %s", query, */
mysql_stmt_errno(stmt), mysql_stmt_error(stmt)); if (handle_error(query, q, mysql_stmt_errno(stmt),
} mysql_stmt_error(stmt), mysql_stmt_sqlstate(stmt), ds))
else error= 1;
{ goto end;
/*
Preparing is part of normal execution and some errors may be expected
*/
error= handle_error(query, q, mysql_stmt_errno(stmt),
mysql_stmt_error(stmt), mysql_stmt_sqlstate(stmt),
ds);
goto end;
}
} }
/* We may have got warnings already, collect them if any */ /* We may have got warnings already, collect them if any */
/* FIXME we only want this if the statement succeeds I think */
if (!disable_ps_warnings) if (!disable_ps_warnings)
run_query_stmt_handle_warnings(mysql, ds); run_query_stmt_handle_warnings(mysql, ds);
/* /*
No need to call mysql_stmt_bind_param() because we have no No need to call mysql_stmt_bind_param() because we have no
parameter markers. parameter markers.
To optimize performance we use a global 'stmt' that is initiated To optimize performance we use a global 'stmt' that is initiated
...@@ -3407,24 +3399,13 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags) ...@@ -3407,24 +3399,13 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags)
prepared statement. prepared statement.
*/ */
if ((got_error_on_execute= mysql_stmt_execute(stmt)) != 0) /* 0 == Success */ if (mysql_stmt_execute(stmt) != 0) /* 0 == Success */
{ {
if (q->abort_on_error) /* We got an error, maybe expected */
{ if (handle_error(query, q, mysql_stmt_errno(stmt),
/* We got an error, unexpected */ mysql_stmt_error(stmt), mysql_stmt_sqlstate(stmt), ds))
die("unable to execute statement '%s': " error= 1;
"%s (mysql_stmt_errno=%d returned=%d)", goto end;
query, mysql_stmt_error(stmt),
mysql_stmt_errno(stmt), got_error_on_execute);
}
else
{
/* We got an error, maybe expected */
error= handle_error(query, q, mysql_stmt_errno(stmt),
mysql_stmt_error(stmt), mysql_stmt_sqlstate(stmt),
ds);
goto end;
}
} }
/* /*
...@@ -3434,11 +3415,10 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags) ...@@ -3434,11 +3415,10 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags)
*/ */
{ {
my_bool one= 1; my_bool one= 1;
if (mysql_stmt_attr_set(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, if ((err= mysql_stmt_attr_set(stmt, STMT_ATTR_UPDATE_MAX_LENGTH,
(void*) &one) != 0) (void*) &one)) != 0)
die("unable to set stmt attribute " die("unable to set stmt attribute "
"'STMT_ATTR_UPDATE_MAX_LENGTH': %s (returned=%d)", "'STMT_ATTR_UPDATE_MAX_LENGTH' err: %d", err);
query, err);
} }
/* /*
...@@ -3447,22 +3427,11 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags) ...@@ -3447,22 +3427,11 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags)
*/ */
if ((err= mysql_stmt_store_result(stmt)) != 0) if ((err= mysql_stmt_store_result(stmt)) != 0)
{ {
if (q->abort_on_error) /* We got an error, maybe expected */
{ if(handle_error(query, q, mysql_stmt_errno(stmt),
/* We got an error, unexpected */ mysql_stmt_error(stmt), mysql_stmt_sqlstate(stmt), ds))
die("unable to execute statement '%s': " error = 1;
"%s (mysql_stmt_errno=%d returned=%d)", goto end;
query, mysql_stmt_error(stmt),
mysql_stmt_errno(stmt), got_error_on_execute);
}
else
{
/* We got an error, maybe expected */
error= handle_error(query, q, mysql_stmt_errno(stmt),
mysql_stmt_error(stmt), mysql_stmt_sqlstate(stmt),
ds);
goto end;
}
} }
/* If we got here the statement was both executed and read succeesfully */ /* If we got here the statement was both executed and read succeesfully */
...@@ -3486,8 +3455,6 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags) ...@@ -3486,8 +3455,6 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags)
MYSQL_FIELD *field= mysql_fetch_fields(res); MYSQL_FIELD *field= mysql_fetch_fields(res);
uint num_fields= mysql_num_fields(res); uint num_fields= mysql_num_fields(res);
/* FIXME check error from the above? */
if (display_metadata) if (display_metadata)
run_query_display_metadata(field, num_fields, ds); run_query_display_metadata(field, num_fields, ds);
...@@ -3640,9 +3607,6 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags) ...@@ -3640,9 +3607,6 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags)
mysql_free_result(res); /* Free normal result set with meta data */ mysql_free_result(res); /* Free normal result set with meta data */
last_result= 0; /* FIXME have no idea what this is about... */ last_result= 0; /* FIXME have no idea what this is about... */
if (err >= 1)
mysql_error(mysql); /* FIXME strange, has no effect... */
end: end:
free_replace(); free_replace();
last_result=0; last_result=0;
...@@ -3733,8 +3697,8 @@ static void run_query_stmt_handle_warnings(MYSQL *mysql, DYNAMIC_STRING *ds) ...@@ -3733,8 +3697,8 @@ static void run_query_stmt_handle_warnings(MYSQL *mysql, DYNAMIC_STRING *ds)
{ {
MYSQL_RES *warn_res= mysql_store_result(mysql); MYSQL_RES *warn_res= mysql_store_result(mysql);
if (!warn_res) if (!warn_res)
verbose_msg("Warning count is %u but didn't get any warnings", die("Warning count is %u but didn't get any warnings",
count); count);
else else
{ {
dynstr_append_mem(ds, "Warnings:\n", 10); dynstr_append_mem(ds, "Warnings:\n", 10);
......
...@@ -134,7 +134,6 @@ select 1146 as "after_!errno_masked_error" ; ...@@ -134,7 +134,6 @@ select 1146 as "after_!errno_masked_error" ;
after_!errno_masked_error after_!errno_masked_error
1146 1146
mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno 1146 instead of 1000... mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno 1146 instead of 1000...
mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno 1146 instead of 1000...
garbage ; garbage ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1
select 1064 as "after_--enable_abort_on_error" ; select 1064 as "after_--enable_abort_on_error" ;
...@@ -143,7 +142,6 @@ after_--enable_abort_on_error ...@@ -143,7 +142,6 @@ after_--enable_abort_on_error
select 3 from t1 ; select 3 from t1 ;
ERROR 42S02: Table 'test.t1' doesn't exist ERROR 42S02: Table 'test.t1' doesn't exist
mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno 1146 instead of 1064... mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno 1146 instead of 1064...
mysqltest: At line 1: query 'select 3 from t1' failed: 1146: Table 'test.t1' doesn't exist
hello hello
hello hello
;;;;;;;; ;;;;;;;;
......
...@@ -1057,42 +1057,64 @@ create table t1 (s1 int)// ...@@ -1057,42 +1057,64 @@ create table t1 (s1 int)//
create procedure f1 () begin create procedure f1 () begin
select sql_cache * from t1; select sql_cache * from t1;
select sql_cache * from t1; select sql_cache * from t1;
select sql_cache * from t1;
end;//
create procedure f2 () begin
select sql_cache * from t1 where s1=1;
select sql_cache * from t1;
end;//
create procedure f3 () begin
select sql_cache * from t1;
select sql_cache * from t1 where s1=1;
end;//
create procedure f4 () begin
select sql_cache * from t1;
select sql_cache * from t1 where s1=1;
select sql_cache * from t1;
select sql_cache * from t1 where s1=1;
select sql_cache * from t1 where s1=1;
end;// end;//
call f1(); call f1();
s1 s1
s1
s1
show status like "Qcache_queries_in_cache"; show status like "Qcache_queries_in_cache";
Variable_name Value Variable_name Value
Qcache_queries_in_cache 1 Qcache_queries_in_cache 3
show status like "Qcache_inserts"; show status like "Qcache_inserts";
Variable_name Value Variable_name Value
Qcache_inserts 1 Qcache_inserts 3
show status like "Qcache_hits"; show status like "Qcache_hits";
Variable_name Value Variable_name Value
Qcache_hits 1 Qcache_hits 0
call f1(); call f1();
s1 s1
s1
s1
show status like "Qcache_queries_in_cache"; show status like "Qcache_queries_in_cache";
Variable_name Value Variable_name Value
Qcache_queries_in_cache 1 Qcache_queries_in_cache 3
show status like "Qcache_inserts"; show status like "Qcache_inserts";
Variable_name Value Variable_name Value
Qcache_inserts 1 Qcache_inserts 3
show status like "Qcache_hits"; show status like "Qcache_hits";
Variable_name Value Variable_name Value
Qcache_hits 3 Qcache_hits 3
call f1(); call f1();
s1 s1
s1
s1
select sql_cache * from t1; select sql_cache * from t1;
s1 s1
show status like "Qcache_queries_in_cache"; show status like "Qcache_queries_in_cache";
Variable_name Value Variable_name Value
Qcache_queries_in_cache 2 Qcache_queries_in_cache 4
show status like "Qcache_inserts"; show status like "Qcache_inserts";
Variable_name Value Variable_name Value
Qcache_inserts 2 Qcache_inserts 4
show status like "Qcache_hits"; show status like "Qcache_hits";
Variable_name Value Variable_name Value
Qcache_hits 5 Qcache_hits 6
insert into t1 values (1); insert into t1 values (1);
select sql_cache * from t1; select sql_cache * from t1;
s1 s1
...@@ -1102,28 +1124,150 @@ Variable_name Value ...@@ -1102,28 +1124,150 @@ Variable_name Value
Qcache_queries_in_cache 1 Qcache_queries_in_cache 1
show status like "Qcache_inserts"; show status like "Qcache_inserts";
Variable_name Value Variable_name Value
Qcache_inserts 3 Qcache_inserts 5
show status like "Qcache_hits"; show status like "Qcache_hits";
Variable_name Value Variable_name Value
Qcache_hits 5 Qcache_hits 6
call f1(); call f1();
s1 s1
1 1
s1
1
s1
1
call f1(); call f1();
s1 s1
1 1
s1
1
s1
1
select sql_cache * from t1; select sql_cache * from t1;
s1 s1
1 1
show status like "Qcache_queries_in_cache"; show status like "Qcache_queries_in_cache";
Variable_name Value Variable_name Value
Qcache_queries_in_cache 2 Qcache_queries_in_cache 4
show status like "Qcache_inserts"; show status like "Qcache_inserts";
Variable_name Value Variable_name Value
Qcache_inserts 4 Qcache_inserts 8
show status like "Qcache_hits"; show status like "Qcache_hits";
Variable_name Value Variable_name Value
Qcache_hits 9 Qcache_hits 10
flush query cache;
reset query cache;
flush status;
select sql_cache * from t1;
s1
1
select sql_cache * from t1 where s1=1;
s1
1
call f1();
s1
1
s1
1
s1
1
call f2();
s1
1
s1
1
call f3();
s1
1
s1
1
call f4();
s1
1
s1
1
s1
1
s1
1
s1
1
call f4();
s1
1
s1
1
s1
1
s1
1
s1
1
call f3();
s1
1
s1
1
call f2();
s1
1
s1
1
select sql_cache * from t1 where s1=1;
s1
1
insert into t1 values (2);
call f1();
s1
1
2
s1
1
2
s1
1
2
select sql_cache * from t1 where s1=1;
s1
1
select sql_cache * from t1;
s1
1
2
call f1();
s1
1
2
s1
1
2
s1
1
2
call f3();
s1
1
2
s1
1
call f3();
s1
1
2
s1
1
call f1();
s1
1
2
s1
1
2
s1
1
2
drop procedure f1; drop procedure f1;
drop procedure f2;
drop procedure f3;
drop procedure f4;
drop table t1; drop table t1;
set GLOBAL query_cache_size=0; set GLOBAL query_cache_size=0;
...@@ -692,6 +692,7 @@ END P1| ...@@ -692,6 +692,7 @@ END P1|
call SP001(); call SP001();
TEMP_SUM TEMP_SUM
0 0
ERROR 24000: Cursor is not open
drop procedure SP001; drop procedure SP001;
drop table t1, t2; drop table t1, t2;
drop function if exists bug11394| drop function if exists bug11394|
......
...@@ -2286,5 +2286,15 @@ SELECT v1.a FROM v1 GROUP BY v1.a HAVING v1.a > 1; ...@@ -2286,5 +2286,15 @@ SELECT v1.a FROM v1 GROUP BY v1.a HAVING v1.a > 1;
a a
2 2
3 3
SELECT t_1.a FROM t1 AS t_1 GROUP BY t_1.a HAVING t_1.a IN (1,2,3);
a
1
2
3
SELECT v_1.a FROM v1 AS v_1 GROUP BY v_1.a HAVING v_1.a IN (1,2,3);
a
1
2
3
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; DROP TABLE t1;
...@@ -776,6 +776,7 @@ delimiter ;// ...@@ -776,6 +776,7 @@ delimiter ;//
# #
# query in QC from normal execution and SP (BUG#6897) # query in QC from normal execution and SP (BUG#6897)
# improved to also test BUG#3583 and BUG#12990
# #
flush query cache; flush query cache;
reset query cache; reset query cache;
...@@ -785,6 +786,22 @@ create table t1 (s1 int)// ...@@ -785,6 +786,22 @@ create table t1 (s1 int)//
create procedure f1 () begin create procedure f1 () begin
select sql_cache * from t1; select sql_cache * from t1;
select sql_cache * from t1; select sql_cache * from t1;
select sql_cache * from t1;
end;//
create procedure f2 () begin
select sql_cache * from t1 where s1=1;
select sql_cache * from t1;
end;//
create procedure f3 () begin
select sql_cache * from t1;
select sql_cache * from t1 where s1=1;
end;//
create procedure f4 () begin
select sql_cache * from t1;
select sql_cache * from t1 where s1=1;
select sql_cache * from t1;
select sql_cache * from t1 where s1=1;
select sql_cache * from t1 where s1=1;
end;// end;//
delimiter ;// delimiter ;//
call f1(); call f1();
...@@ -811,7 +828,32 @@ select sql_cache * from t1; ...@@ -811,7 +828,32 @@ select sql_cache * from t1;
show status like "Qcache_queries_in_cache"; show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts"; show status like "Qcache_inserts";
show status like "Qcache_hits"; show status like "Qcache_hits";
flush query cache;
reset query cache;
flush status;
select sql_cache * from t1;
select sql_cache * from t1 where s1=1;
call f1();
call f2();
call f3();
call f4();
call f4();
call f3();
call f2();
select sql_cache * from t1 where s1=1;
insert into t1 values (2);
call f1();
select sql_cache * from t1 where s1=1;
select sql_cache * from t1;
call f1();
call f3();
call f3();
call f1();
drop procedure f1; drop procedure f1;
drop procedure f2;
drop procedure f3;
drop procedure f4;
drop table t1; drop table t1;
set GLOBAL query_cache_size=0; set GLOBAL query_cache_size=0;
......
...@@ -991,6 +991,7 @@ P1: BEGIN ...@@ -991,6 +991,7 @@ P1: BEGIN
SELECT 'end of proc'; SELECT 'end of proc';
END P1| END P1|
delimiter ;| delimiter ;|
--error 1326
call SP001(); call SP001();
drop procedure SP001; drop procedure SP001;
drop table t1, t2; drop table t1, t2;
...@@ -1187,7 +1188,30 @@ delimiter ;| ...@@ -1187,7 +1188,30 @@ delimiter ;|
create trigger bug12712 create trigger bug12712
before insert on t1 for each row set session autocommit = 0; before insert on t1 for each row set session autocommit = 0;
#
# BUG#9367: Stored procedures: client hang after "show warnings"
#
--disable_parsing
--disable_warnings
drop procedure if exists bug9367;
--enable_warnings
create table t1 (s1 int);
select s1 from t1;
delimiter |;
create procedure bug9367()
begin
declare v int;
declare c cursor for select s1 from t1;
open c;
show warnings;
fetch c into v;
select v;
end|
delimiter ;|
call bug9367();
drop procedure bug9367;
drop table t1;
--enable_parsing
# #
# BUG#NNNN: New bug synopsis # BUG#NNNN: New bug synopsis
# #
......
...@@ -2162,6 +2162,8 @@ INSERT INTO t1 VALUES (1,1),(2,2),(3,3); ...@@ -2162,6 +2162,8 @@ INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
CREATE VIEW v1 AS SELECT a,b FROM t1; CREATE VIEW v1 AS SELECT a,b FROM t1;
SELECT t1.a FROM t1 GROUP BY t1.a HAVING t1.a > 1; SELECT t1.a FROM t1 GROUP BY t1.a HAVING t1.a > 1;
SELECT v1.a FROM v1 GROUP BY v1.a HAVING v1.a > 1; SELECT v1.a FROM v1 GROUP BY v1.a HAVING v1.a > 1;
SELECT t_1.a FROM t1 AS t_1 GROUP BY t_1.a HAVING t_1.a IN (1,2,3);
SELECT v_1.a FROM v1 AS v_1 GROUP BY v_1.a HAVING v_1.a IN (1,2,3);
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; DROP TABLE t1;
...@@ -2973,7 +2973,7 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list) ...@@ -2973,7 +2973,7 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
const char *field_name; const char *field_name;
ORDER *found_group= NULL; ORDER *found_group= NULL;
int found_match_degree= 0; int found_match_degree= 0;
Item_field *cur_field; Item_ident *cur_field;
int cur_match_degree= 0; int cur_match_degree= 0;
if (find_item->type() == Item::FIELD_ITEM || if (find_item->type() == Item::FIELD_ITEM ||
...@@ -2992,7 +2992,7 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list) ...@@ -2992,7 +2992,7 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
{ {
if ((*(cur_group->item))->real_item()->type() == Item::FIELD_ITEM) if ((*(cur_group->item))->real_item()->type() == Item::FIELD_ITEM)
{ {
cur_field= (Item_field*) *cur_group->item; cur_field= (Item_ident*) *cur_group->item;
cur_match_degree= 0; cur_match_degree= 0;
DBUG_ASSERT(cur_field->field_name != 0); DBUG_ASSERT(cur_field->field_name != 0);
......
...@@ -1622,7 +1622,7 @@ class Item_ref :public Item_ident ...@@ -1622,7 +1622,7 @@ class Item_ref :public Item_ident
} }
Item *real_item() Item *real_item()
{ {
return (*ref)->real_item(); return (ref && *ref) ? (*ref)->real_item() : this;
} }
bool walk(Item_processor processor, byte *arg) bool walk(Item_processor processor, byte *arg)
{ return (*ref)->walk(processor, arg); } { return (*ref)->walk(processor, arg); }
......
...@@ -538,6 +538,7 @@ struct Query_cache_query_flags ...@@ -538,6 +538,7 @@ struct Query_cache_query_flags
unsigned int client_long_flag:1; unsigned int client_long_flag:1;
unsigned int client_protocol_41:1; unsigned int client_protocol_41:1;
unsigned int more_results_exists:1; unsigned int more_results_exists:1;
unsigned int pkt_nr;
uint character_set_client_num; uint character_set_client_num;
uint character_set_results_num; uint character_set_results_num;
uint collation_connection_num; uint collation_connection_num;
......
...@@ -3353,9 +3353,9 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter, ...@@ -3353,9 +3353,9 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
for (uint i= 0; (item=li++); i++) for (uint i= 0; (item=li++); i++)
{ {
if (field_name && item->type() == Item::FIELD_ITEM) if (field_name && item->real_item()->type() == Item::FIELD_ITEM)
{ {
Item_field *item_field= (Item_field*) item; Item_ident *item_field= (Item_ident*) item;
/* /*
In case of group_concat() with ORDER BY condition in the QUERY In case of group_concat() with ORDER BY condition in the QUERY
......
...@@ -801,6 +801,7 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used) ...@@ -801,6 +801,7 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
CLIENT_PROTOCOL_41); CLIENT_PROTOCOL_41);
flags.more_results_exists= test(thd->server_status & flags.more_results_exists= test(thd->server_status &
SERVER_MORE_RESULTS_EXISTS); SERVER_MORE_RESULTS_EXISTS);
flags.pkt_nr= net->pkt_nr;
flags.character_set_client_num= flags.character_set_client_num=
thd->variables.character_set_client->number; thd->variables.character_set_client->number;
flags.character_set_results_num= flags.character_set_results_num=
...@@ -814,12 +815,13 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used) ...@@ -814,12 +815,13 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
flags.sql_mode= thd->variables.sql_mode; flags.sql_mode= thd->variables.sql_mode;
flags.max_sort_length= thd->variables.max_sort_length; flags.max_sort_length= thd->variables.max_sort_length;
flags.group_concat_max_len= thd->variables.group_concat_max_len; flags.group_concat_max_len= thd->variables.group_concat_max_len;
DBUG_PRINT("qcache", ("long %d, 4.1: %d, more results %d, \ DBUG_PRINT("qcache", ("long %d, 4.1: %d, more results %d, pkt_nr: %d, \
CS client: %u, CS result: %u, CS conn: %u, limit: %lu, TZ: 0x%lx, \ CS client: %u, CS result: %u, CS conn: %u, limit: %lu, TZ: 0x%lx, \
sql mode: 0x%lx, sort len: %lu, conncat len: %lu", sql mode: 0x%lx, sort len: %lu, conncat len: %lu",
(int)flags.client_long_flag, (int)flags.client_long_flag,
(int)flags.client_protocol_41, (int)flags.client_protocol_41,
(int)flags.more_results_exists, (int)flags.more_results_exists,
flags.pkt_nr,
flags.character_set_client_num, flags.character_set_client_num,
flags.character_set_results_num, flags.character_set_results_num,
flags.collation_connection_num, flags.collation_connection_num,
...@@ -1019,6 +1021,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length) ...@@ -1019,6 +1021,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
CLIENT_PROTOCOL_41); CLIENT_PROTOCOL_41);
flags.more_results_exists= test(thd->server_status & flags.more_results_exists= test(thd->server_status &
SERVER_MORE_RESULTS_EXISTS); SERVER_MORE_RESULTS_EXISTS);
flags.pkt_nr= thd->net.pkt_nr;
flags.character_set_client_num= thd->variables.character_set_client->number; flags.character_set_client_num= thd->variables.character_set_client->number;
flags.character_set_results_num= flags.character_set_results_num=
(thd->variables.character_set_results ? (thd->variables.character_set_results ?
...@@ -1030,12 +1033,13 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length) ...@@ -1030,12 +1033,13 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
flags.sql_mode= thd->variables.sql_mode; flags.sql_mode= thd->variables.sql_mode;
flags.max_sort_length= thd->variables.max_sort_length; flags.max_sort_length= thd->variables.max_sort_length;
flags.group_concat_max_len= thd->variables.group_concat_max_len; flags.group_concat_max_len= thd->variables.group_concat_max_len;
DBUG_PRINT("qcache", ("long %d, 4.1: %d, more results %d, \ DBUG_PRINT("qcache", ("long %d, 4.1: %d, more results %d, pkt_nr: %d, \
CS client: %u, CS result: %u, CS conn: %u, limit: %lu, TZ: 0x%lx, \ CS client: %u, CS result: %u, CS conn: %u, limit: %lu, TZ: 0x%lx, \
sql mode: 0x%lx, sort len: %lu, conncat len: %lu", sql mode: 0x%lx, sort len: %lu, conncat len: %lu",
(int)flags.client_long_flag, (int)flags.client_long_flag,
(int)flags.client_protocol_41, (int)flags.client_protocol_41,
(int)flags.more_results_exists, (int)flags.more_results_exists,
flags.pkt_nr,
flags.character_set_client_num, flags.character_set_client_num,
flags.character_set_results_num, flags.character_set_results_num,
flags.collation_connection_num, flags.collation_connection_num,
......
...@@ -440,7 +440,8 @@ bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, ...@@ -440,7 +440,8 @@ bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_DB_CREATE_EXISTS, ER(ER_DB_CREATE_EXISTS), db); ER_DB_CREATE_EXISTS, ER(ER_DB_CREATE_EXISTS), db);
error= 0; error= 0;
send_ok(thd); if (!silent)
send_ok(thd);
goto exit; goto exit;
} }
else else
......
...@@ -2426,22 +2426,6 @@ Field *Natural_join_column::field() ...@@ -2426,22 +2426,6 @@ Field *Natural_join_column::field()
const char *Natural_join_column::table_name() const char *Natural_join_column::table_name()
{ {
return table_ref->alias; return table_ref->alias;
/*
TODO:
I think that it is sufficient to return just
table->alias, which is correctly set to either
the view name, the table name, or the alias to
the table reference (view or stored table).
*/
#ifdef NOT_YET
if (view_field)
return table_ref->view_name.str;
DBUG_ASSERT(!strcmp(table_ref->table_name,
table_ref->table->s->table_name));
return table_ref->table_name;
}
#endif
} }
...@@ -2577,7 +2561,7 @@ Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref, ...@@ -2577,7 +2561,7 @@ Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref,
DBUG_RETURN(field); DBUG_RETURN(field);
} }
Item *item= new Item_direct_view_ref(&view->view->select_lex.context, Item *item= new Item_direct_view_ref(&view->view->select_lex.context,
field_ref, view->view_name.str, field_ref, view->alias,
name); name);
DBUG_RETURN(item); DBUG_RETURN(item);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment