[MDEV-31108] autocommit in stored functions Created: 2023-04-21  Updated: 2023-04-21

Status: Open
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Andrii Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None

Attachments: File test.sh    

 Description   

Documentation says about autocommit:
"as soon as you execute a statement that updates (modifies) a table, MariaDB stores the update on disk to make it permanent".
Also
"Transactions cannot be used in Stored Functions".

But it is not obvious that autocommit is effectively disabled inside stored functions.
Please confirm it and reflect in documentation.

---TRANSACTION 24, ACTIVE 0 sec inserting
mysql tables in use 1, locked 1
LOCK WAIT 2 lock struct(s), heap size 1128, 1 row lock(s)
MariaDB thread id 7, OS thread handle 140301147223808, query id 11 localhost root Executing
insert into t.t select 1
------- TRX HAS BEEN WAITING 201824 ns FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 8 page no 3 n bits 8 index PRIMARY of table `t`.`t` trx id 24 lock mode S locks rec but not gap waiting
Record lock, heap no 2 PHYSICAL RECORD: n_fields 3; compact format; info bits 32
 0: len 4; hex 80000001; asc     ;;
 1: len 6; hex 000000000017; asc       ;;
 2: len 7; hex 060000002e0110; asc     .  ;;
 
------------------
---TRANSACTION 23, ACTIVE 1 sec
mysql tables in use 1, locked 1
2 lock struct(s), heap size 1128, 6 row lock(s), undo log entries 5
MariaDB thread id 6, OS thread handle 140301147531008, query id 10 localhost root User sleep
insert into t select case when sleep(5) < 1 then 1 else 2 end



 Comments   
Comment by Andrii [ 2023-04-21 ]

for reference - original problem in application: https://github.com/preaction/Minion-Backend-mysql/issues/38

Generated at Thu Feb 08 10:21:20 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.