Commit 78e8833f authored by unknown's avatar unknown

Fix bug#13535 Incorrect result from SELECT statement after SHOW TABLE STATUS

After SHOW TABLE STATUS last_insert_id wasn't cleaned, and next select
erroneously rewrites WHERE condition and returs a row;
5.0 isn't affected because of different SHOW TABLE STATUS handling.

last_insert_id cleanup added to mysqld_extend_show_tables().


sql/sql_show.cc:
  Fix bug #13535 Incorrect result from SELECT statement after SHOW TABLE STATUS
  Added last_insert_id cleanup after SHOW TABLE STATUS command.
mysql-test/t/select.test:
  Test case for bug #13535 Incorrect result from SELECT statement after SHOW TABLE STATUS
mysql-test/r/select.result:
  Test case for bug #13535 Incorrect result from SELECT statement after SHOW TABLE STATUS
parent 7b8a6e45
...@@ -2626,3 +2626,13 @@ f1 ...@@ -2626,3 +2626,13 @@ f1
select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,NULL)); select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,NULL));
f1 f1
drop table t1,t2; drop table t1,t2;
create table t1 (f1 int not null auto_increment primary key, f2 varchar(10));
create table t11 like t1;
insert into t1 values(1,""),(2,"");
show table status like 't1%';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MyISAM 9 Dynamic 2 20 X X X X X X X X latin1_swedish_ci NULL
t11 MyISAM 9 Dynamic 0 0 X X X X X X X X latin1_swedish_ci NULL
select 123 as a from t1 where f1 is null;
a
drop table t1,t11;
...@@ -2174,4 +2174,14 @@ select f1 from t1,t2 where f1=f2 and (f1,NULL) = ((1,1)); ...@@ -2174,4 +2174,14 @@ select f1 from t1,t2 where f1=f2 and (f1,NULL) = ((1,1));
select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,NULL)); select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,NULL));
drop table t1,t2; drop table t1,t2;
#
# Bug #13535
#
create table t1 (f1 int not null auto_increment primary key, f2 varchar(10));
create table t11 like t1;
insert into t1 values(1,""),(2,"");
--replace_column 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
show table status like 't1%';
select 123 as a from t1 where f1 is null;
drop table t1,t11;
# End of 4.1 tests # End of 4.1 tests
...@@ -462,6 +462,7 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild) ...@@ -462,6 +462,7 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
TABLE *table; TABLE *table;
Protocol *protocol= thd->protocol; Protocol *protocol= thd->protocol;
TIME time; TIME time;
int res= 0;
DBUG_ENTER("mysqld_extend_show_tables"); DBUG_ENTER("mysqld_extend_show_tables");
(void) sprintf(path,"%s/%s",mysql_data_home,db); (void) sprintf(path,"%s/%s",mysql_data_home,db);
...@@ -632,10 +633,15 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild) ...@@ -632,10 +633,15 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
close_thread_tables(thd,0); close_thread_tables(thd,0);
} }
if (protocol->write()) if (protocol->write())
DBUG_RETURN(-1); {
res= -1;
break;
}
} }
send_eof(thd); thd->insert_id(0);
DBUG_RETURN(0); if (!res)
send_eof(thd);
DBUG_RETURN(res);
} }
......
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