mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fixing bug #8850 in such a way that when TRUNCATE is called within
stored procedure, it is converted to DELETE.
This commit is contained in:
@ -1105,3 +1105,4 @@ vio/test-ssl
|
|||||||
vio/test-sslclient
|
vio/test-sslclient
|
||||||
vio/test-sslserver
|
vio/test-sslserver
|
||||||
vio/viotest-ssl
|
vio/viotest-ssl
|
||||||
|
acinclude.m4
|
||||||
|
@ -2538,3 +2538,24 @@ drop procedure bug7992|
|
|||||||
drop table t3|
|
drop table t3|
|
||||||
drop table t1;
|
drop table t1;
|
||||||
drop table t2;
|
drop table t2;
|
||||||
|
drop procedure if exists sp1;
|
||||||
|
create table t1 (a int) engine=innodb|
|
||||||
|
create procedure sp1 ()
|
||||||
|
begin
|
||||||
|
truncate table t1; insert t1 values (1); rollback;
|
||||||
|
end
|
||||||
|
|
|
||||||
|
begin;
|
||||||
|
insert t1 values (2);
|
||||||
|
call sp1();
|
||||||
|
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
||||||
|
commit;
|
||||||
|
select * from t1;
|
||||||
|
a
|
||||||
|
2
|
||||||
|
call sp1();
|
||||||
|
select * from t1;
|
||||||
|
a
|
||||||
|
1
|
||||||
|
drop table t1;
|
||||||
|
drop procedure sp1;
|
||||||
|
@ -3073,3 +3073,27 @@ delimiter ;|
|
|||||||
drop table t1;
|
drop table t1;
|
||||||
drop table t2;
|
drop table t2;
|
||||||
|
|
||||||
|
#
|
||||||
|
# BUG#8850
|
||||||
|
#
|
||||||
|
--disable_warnings
|
||||||
|
drop procedure if exists sp1;
|
||||||
|
--enable_warnings
|
||||||
|
delimiter |;
|
||||||
|
create table t1 (a int) engine=innodb|
|
||||||
|
create procedure sp1 ()
|
||||||
|
begin
|
||||||
|
truncate table t1; insert t1 values (1); rollback;
|
||||||
|
end
|
||||||
|
|
|
||||||
|
delimiter ;|
|
||||||
|
begin;
|
||||||
|
insert t1 values (2);
|
||||||
|
--error 1192
|
||||||
|
call sp1();
|
||||||
|
commit;
|
||||||
|
select * from t1;
|
||||||
|
call sp1();
|
||||||
|
select * from t1;
|
||||||
|
drop table t1;
|
||||||
|
drop procedure sp1;
|
||||||
|
@ -749,11 +749,12 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
|
|||||||
table_list->db, table_list->table_name);
|
table_list->db, table_list->table_name);
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
}
|
}
|
||||||
if (!ha_supports_generate(table_type))
|
if (!ha_supports_generate(table_type) || thd->lex->sphead)
|
||||||
{
|
{
|
||||||
/* Probably InnoDB table */
|
/* Probably InnoDB table */
|
||||||
table_list->lock_type= TL_WRITE;
|
table_list->lock_type= TL_WRITE;
|
||||||
ha_enable_transaction(thd, FALSE);
|
ha_enable_transaction(thd, FALSE);
|
||||||
|
mysql_init_select(thd->lex);
|
||||||
error= mysql_delete(thd, table_list, (COND*) 0, (SQL_LIST*) 0,
|
error= mysql_delete(thd, table_list, (COND*) 0, (SQL_LIST*) 0,
|
||||||
HA_POS_ERROR, 0);
|
HA_POS_ERROR, 0);
|
||||||
ha_enable_transaction(thd, TRUE);
|
ha_enable_transaction(thd, TRUE);
|
||||||
|
@ -3312,7 +3312,7 @@ unsent_create_error:
|
|||||||
Don't allow this within a transaction because we want to use
|
Don't allow this within a transaction because we want to use
|
||||||
re-generate table
|
re-generate table
|
||||||
*/
|
*/
|
||||||
if (thd->locked_tables || thd->active_transaction())
|
if ((thd->locked_tables && !lex->sphead) || thd->active_transaction())
|
||||||
{
|
{
|
||||||
my_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
|
my_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
|
||||||
ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
|
ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
|
||||||
|
Reference in New Issue
Block a user