mariadb-set-transaction

Documents MariaDB-specific SET TRANSACTION scope rules, isolation levels, and snapshot-isolation conflict handling.

28|115|Updated Jan 28, 2025
One-click install
npx skills add https://github.com/mariadb-corporation/mariadb-docs --skill mariadb-set-transaction-mariadb-corporation
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: mariadb-set-transaction
Source: https://github.com/mariadb-corporation/mariadb-docs/tree/main/agent-skills/granular/statements/mariadb-set-transaction
Command: npx skills add https://github.com/mariadb-corporation/mariadb-docs --skill mariadb-set-transaction-mariadb-corporation

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Standard SQL knowledge of SET TRANSACTION leads to errors in MariaDB: agents assume READ COMMITTED is the default, issue SET TRANSACTION mid-transaction, treat bare statements as session-sticky, and miss the ER_CHECKREAD (1020) error raised by innodb_snapshot_isolation under REPEATABLE READ. ## Core Features & Use Cases - Scope Rule Reference: Explains the GLOBAL / SESSION / next-transaction-only behavior of SET TRANSACTION, including why a bare statement fails with ERROR 1568 once a transaction is active. - Isolation Level Guidance: Covers MariaDB's REPEATABLE READ default, the deprecated tx_isolation variable versus transaction_isolation, and per-level locking semantics. - Snapshot Isolation Handling: Documents innodb_snapshot_isolation (ON by default since 11.6.2), which raises ER_CHECKREAD/1020 and rolls back the whole transaction on write-write conflicts, requiring retry logic that catches 1020 alongside deadlock 1213. - Use Case: When generating application retry logic for MariaDB transactions, use this Skill to ensure the code catches both error 1213 and error 1020 and retries the entire transaction rather than a single statement. ## Quick Start Ask the AI to write or review a MariaDB SET TRANSACTION statement or transaction retry logic and have it apply the correct scope rules and snapshot-isolation error handling.

Frequently Asked Questions about mariadb-set-transaction

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set transaction isolation level in MariaDB?▼

Use SET [GLOBAL | SESSION] TRANSACTION ISOLATION LEVEL followed by REPEATABLE READ, READ COMMITTED, READ UNCOMMITTED, or SERIALIZABLE. A bare SET TRANSACTION without GLOBAL or SESSION applies only to the next transaction and must be issued before START TRANSACTION.

What is the default transaction isolation level in MariaDB?▼

MariaDB with InnoDB defaults to REPEATABLE READ, not READ COMMITTED as in some other databases. You can verify the current level with SELECT @@transaction_isolation or set it at startup with --transaction-isolation=REPEATABLE-READ.

Why does SET TRANSACTION fail with error 1568 in MariaDB?▼

Error 1568 occurs because a bare SET TRANSACTION cannot be issued while a transaction is in progress; it only configures the next transaction. Issue it before START TRANSACTION, or use SET SESSION TRANSACTION which can be changed mid-transaction.

What is error 1020 ER_CHECKREAD in MariaDB transactions?▼

ER_CHECKREAD (1020) is raised by innodb_snapshot_isolation when an UPDATE or DELETE under REPEATABLE READ targets a row changed by a concurrent transaction since your snapshot. The entire transaction rolls back, so retry logic should catch 1020 alongside deadlock error 1213.

Is tx_isolation deprecated in MariaDB?▼

Yes, tx_isolation is deprecated since MariaDB 11.1 in favor of transaction_isolation, and tx_read_only in favor of transaction_read_only. The old names still work but new code should use the transaction_isolation variable.

Does SET GLOBAL TRANSACTION affect existing sessions in MariaDB?▼

No, SET GLOBAL TRANSACTION only sets the default isolation level and access mode for subsequent new connections. Existing sessions keep their current session default or any mid-flight override already in effect.