[MDEV-10221] ROLLBACK doesn't work after truncate temporary table Created: 2016-06-13  Updated: 2016-06-14  Resolved: 2016-06-14

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Procedure, Data Definition - Temporary
Affects Version/s: 10.1.14
Fix Version/s: N/A

Type: Bug Priority: Critical
Reporter: Chris Jeong Assignee: Unassigned
Resolution: Not a Bug Votes: 0
Labels: None
Environment:

Ubuntu 14.04 LTS



 Description   

Hello,
ROLLBACK does not work properly after truncate.
Please consider follow codes.

CREATE TABLE IF NOT EXISTS innodb_table (
	id INT NOT NULL,
	name VARCHAR(50) NOT NULL,
	state SMALLINT NOT NULL,
	PRIMARY KEY(id)
) ENGINE=InnoDB;
 
TRUNCATE TABLE innodb_table;
 
INSERT INTO innodb_table
	(id, name, state)
VALUES
	(1, 'tegrak', 0);
 
DROP PROCEDURE IF EXISTS temporary_table_test;
DELIMITER $$
CREATE PROCEDURE temporary_table_test()
BEGIN
	CREATE TEMPORARY TABLE IF NOT EXISTS temporary_table (
		seq INT NOT NULL
	) ENGINE=MEMORY;
 
	#TRUNCATE makes ROLLBACK crazy.
	TRUNCATE TABLE temporary_table;
	#DELETE FROM temporary_table;
 
	INSERT INTO temporary_table
	SELECT seq
	FROM
		seq_1_to_10;
END
$$
 
START TRANSACTION;
CALL temporary_table_test();
UPDATE innodb_table
SET
	state = 1
WHERE
	id = 1;
ROLLBACK;
 
#state must be 0 because it has to ROLLBACKed. but IT'S NOT!
SELECT * FROM innodb_table;
 
DROP TABLE IF EXISTS innodb_table;
DROP PROCEDURE IF EXISTS temporary_table_test;

I expected that state is 0, but it's changed to 1.
ROLLBACK worked after I replace TRUNCATE to DELETE in proc temporary_table_test().

Can you fix this bug?
Thank you in advance.



 Comments   
Comment by Elena Stepanova [ 2016-06-13 ]

Please provide the complete definition of the procedure, from CREATE PROCEDURE and to END. If you want to obfuscate table names, columns and such, feel free to do so, but please leave handler declarations and such unabridged, as well as types of statements you use inside the transactions.

Comment by Chris Jeong [ 2016-06-14 ]

Dear Stepanova,
I added complete codes that you can test.

Comment by Chris Jeong [ 2016-06-14 ]

Sorry for bothering you, I just read about implicit commit.

https://mariadb.com/kb/en/mariadb/sql-statements-that-cause-an-implicit-commit/

Thank you for your comment.

Generated at Thu Feb 08 07:40:34 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.