[MDEV-6945] SET STATEMENT autocommit=... has no effect and causes warnings in the error log Created: 2014-10-25  Updated: 2015-02-02  Resolved: 2014-10-29

Status: Closed
Project: MariaDB Server
Component/s: Admin statements
Affects Version/s: N/A
Fix Version/s: 10.1.2

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Oleksandr Byelkin
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-5231 Per query variables from Percona Serv... Closed
relates to MDEV-6923 Testing for SET STATEMENT .. FOR (MDE... Closed

 Description   

Note: I couldn't find a test so I don't know whether it should work. If not, probably the attempt should cause a warning (not the one described below, but a normal one, "not supported" or something).

Results of the test case below

create table t1 (i int) engine=InnoDB;
set autocommit = 1;
# Insert '1' with autocommit enabled
insert into t1 values (1);
connect  con1,localhost,root,,;
set session transaction isolation level read committed;
# Make sure the value '1' is visible right away
select * from t1;
i
1
connection default;
# Disable autocommit for inserting the value '2'
set statement autocommit=0 for insert into t1 values (2);
connection con1;
# The value '2' should not be visible
select * from t1;
i
1
2
# ... but it is
connection default;
# Disable autocommit in general
set autocommit = 0;
# Insert '3' with autocommit disabled
insert into t1 values (3);
connection con1;
# Make sure the value '3' is not visible 
select * from t1;
i
1
2
connection default;
rollback;
# Enable autocommit for inserting the value '4'
set statement autocommit=1 for insert into t1 values (4);
connection con1;
# The value '4' should be visible
select * from t1;
i
1
2
# ... but it is not.
disconnect con1;

The part SET STATEMENT autocommit=1 FOR .. also causes warnings in the error log:

[Warning] MySQL is closing a connection that has an active InnoDB transaction.  1 row modifications will roll back.

Test case

--enable_connect_log
 
--source include/have_innodb.inc
 
create table t1 (i int) engine=InnoDB;
set autocommit = 1;
 
--echo # Insert '1' with autocommit enabled
insert into t1 values (1);
 
--connect (con1,localhost,root,,)
set session transaction isolation level read committed;
 
--echo # Make sure the value '1' is visible right away
select * from t1;
 
--connection default
 
--echo # Disable autocommit for inserting the value '2'
set statement autocommit=0 for insert into t1 values (2);
 
--connection con1
 
--echo # The value '2' should not be visible
select * from t1;
 
--echo # ... but it is
 
--connection default
 
--echo # Disable autocommit in general
set autocommit = 0;
 
--echo # Insert '3' with autocommit disabled
insert into t1 values (3);
 
--connection con1
 
--echo # Make sure the value '3' is not visible 
select * from t1;
 
--connection default
rollback;
 
--echo # Enable autocommit for inserting the value '4'
set statement autocommit=1 for insert into t1 values (4);
 
--connection con1
 
--echo # The value '4' should be visible
select * from t1;
 
--echo # ... but it is not.
 
# Cleanup
--disconnect con1

It's all the same in Percona server.



 Comments   
Comment by Oleksandr Byelkin [ 2014-10-26 ]

adding COMMIT after SET STATEMENT does not fix situation... it is strange.

Comment by Oleksandr Byelkin [ 2014-10-27 ]

The problem is that we return old value of autocommit before code in mysql_execute_commend() which decides if we should close transaction...

Comment by Oleksandr Byelkin [ 2014-10-27 ]

Moving returning to old variables 'down' is problematic due to freeing resources...

Comment by Oleksandr Byelkin [ 2014-10-29 ]

The variable is prohibited in SET STATEMENT for now.

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