Transactions: Difference between revisions
(Created page with " ← Back to Full SCM API documentation == tx_commit == Commits the current transaction. '''Allowed number of parameters:''' 1–1 <span id="parameters-2"></span> === Parameters === * '''session''' (<code>func(key:string?, value:any?) -> any</code>): the session function that holds tx state <span id="returns-2"></span> === Returns === <code>bool</code> == tx_rollback == Rolls back the current transaction. '''Allowed number of parameters:''' 1–1 <span...") |
Wikiservice (talk | contribs) (Refresh MemCP documentation: accuracy, operational guidance, performance profile and maintained API reference) |
||
| Line 1: | Line 1: | ||
<!-- Copyright (C) 2026 Carl-Philip Haensch --> | |||
<!-- SPDX-License-Identifier: GPL-3.0-or-later --> | |||
<span id="transactions"></span> | |||
= Transactions = | |||
<!-- Generated from MemCP c42e19eba on 2026-08-27; do not edit manually. --> | |||
<div class="mw-message-box mw-message-box-notice">Generated from MemCP commit <code>c42e19eba</code> on 27 August 2026. See [[Full SCM API documentation]].</div> | |||
The '''Transactions''' module manages transaction contexts stored in a session. It provides cursor-stability transactions, ACID snapshot/OCC transactions, commit, rollback, and implicit autocommit wrapping. | |||
These functions are runtime primitives used by the SQL frontend. Applications normally use <code>BEGIN</code>, <code>COMMIT</code>, and <code>ROLLBACK</code>; see [[Transactions and Isolation]] for visibility, conflict, and durability semantics. | |||
== tx_begin == | |||
Begins a new cursor-stability transaction. Takes the session function as argument. Stores the transaction context in the session. | |||
'''Allowed number of parameters:''' 1–1 | |||
<span id="parameters"></span> | |||
=== Parameters === | |||
* '''session''' (<code>func</code>): the session function to store tx state in | |||
** '''Parameters''' | |||
*** '''key''' (<code>string</code>) ''(optional)'' | |||
*** '''value''' (<code>any</code>) ''(optional)'' | |||
** '''Returns''' | |||
*** '''value''' (<code>any</code>) | |||
<span id="returns"></span> | |||
=== Returns === | |||
* '''value''' (<code>bool</code>) | |||
== tx_begin_acid == | |||
Begins a new ACID transaction with snapshot isolation and OCC commit. Takes the session function as argument. | |||
'''Allowed number of parameters:''' 1–1 | |||
<span id="parameters-1"></span> | |||
=== Parameters === | |||
* '''session''' (<code>func</code>): the session function to store tx state in | |||
** '''Parameters''' | |||
*** '''key''' (<code>string</code>) ''(optional)'' | |||
*** '''value''' (<code>any</code>) ''(optional)'' | |||
** '''Returns''' | |||
*** '''value''' (<code>any</code>) | |||
<span id="returns-1"></span> | |||
=== Returns === | |||
* '''value''' (<code>bool</code>) | |||
== tx_commit == | == tx_commit == | ||
| Line 12: | Line 63: | ||
=== Parameters === | === Parameters === | ||
* '''session''' (<code>func | * '''session''' (<code>func</code>): the session function that holds tx state | ||
** '''Parameters''' | |||
*** '''key''' (<code>string</code>) ''(optional)'' | |||
*** '''value''' (<code>any</code>) ''(optional)'' | |||
** '''Returns''' | |||
*** '''value''' (<code>any</code>) | |||
<span id="returns-2"></span> | <span id="returns-2"></span> | ||
=== Returns === | === Returns === | ||
<code>bool</code> | * '''value''' (<code>bool</code>) | ||
== tx_rollback == | == tx_rollback == | ||
| Line 28: | Line 84: | ||
=== Parameters === | === Parameters === | ||
* '''session''' (<code>func | * '''session''' (<code>func</code>): the session function that holds tx state | ||
** '''Parameters''' | |||
*** '''key''' (<code>string</code>) ''(optional)'' | |||
*** '''value''' (<code>any</code>) ''(optional)'' | |||
** '''Returns''' | |||
*** '''value''' (<code>any</code>) | |||
<span id="returns-3"></span> | <span id="returns-3"></span> | ||
=== Returns === | === Returns === | ||
<code>bool</code> | * '''value''' (<code>bool</code>) | ||
== with_autocommit == | == with_autocommit == | ||
| Line 44: | Line 105: | ||
=== Parameters === | === Parameters === | ||
* '''session''' (<code>func | * '''session''' (<code>func</code>): the session function holding tx state | ||
** '''Parameters''' | |||
*** '''key''' (<code>string</code>) ''(optional)'' | |||
*** '''value''' (<code>any</code>) ''(optional)'' | |||
** '''Returns''' | |||
*** '''value''' (<code>any</code>) | |||
* '''fn''' (<code>func</code>): zero-argument function to execute | * '''fn''' (<code>func</code>): zero-argument function to execute | ||
** '''Returns''' | |||
*** '''value''' (<code>any</code>) | |||
<span id="returns-4"></span> | <span id="returns-4"></span> | ||
=== Returns === | === Returns === | ||
<code>any</code> | * '''value''' (<code>any</code>) | ||
Latest revision as of 11:59, 28 August 2026
Transactions
The Transactions module manages transaction contexts stored in a session. It provides cursor-stability transactions, ACID snapshot/OCC transactions, commit, rollback, and implicit autocommit wrapping.
These functions are runtime primitives used by the SQL frontend. Applications normally use BEGIN, COMMIT, and ROLLBACK; see Transactions and Isolation for visibility, conflict, and durability semantics.
tx_begin
Begins a new cursor-stability transaction. Takes the session function as argument. Stores the transaction context in the session.
Allowed number of parameters: 1–1
Parameters
- session (
func): the session function to store tx state in- Parameters
- key (
string) (optional) - value (
any) (optional)
- key (
- Returns
- value (
any)
- value (
- Parameters
Returns
- value (
bool)
tx_begin_acid
Begins a new ACID transaction with snapshot isolation and OCC commit. Takes the session function as argument.
Allowed number of parameters: 1–1
Parameters
- session (
func): the session function to store tx state in- Parameters
- key (
string) (optional) - value (
any) (optional)
- key (
- Returns
- value (
any)
- value (
- Parameters
Returns
- value (
bool)
tx_commit
Commits the current transaction.
Allowed number of parameters: 1–1
Parameters
- session (
func): the session function that holds tx state- Parameters
- key (
string) (optional) - value (
any) (optional)
- key (
- Returns
- value (
any)
- value (
- Parameters
Returns
- value (
bool)
tx_rollback
Rolls back the current transaction.
Allowed number of parameters: 1–1
Parameters
- session (
func): the session function that holds tx state- Parameters
- key (
string) (optional) - value (
any) (optional)
- key (
- Returns
- value (
any)
- value (
- Parameters
Returns
- value (
bool)
with_autocommit
Executes fn inside an implicit TxCursorStability transaction if no explicit transaction is active in session. Commits on success, rolls back on error, and re-raises any panic so the caller's error handler still fires. If an explicit transaction is active (session["transaction"] != nil), fn is executed without any wrapping.
Allowed number of parameters: 2–2
Parameters
- session (
func): the session function holding tx state- Parameters
- key (
string) (optional) - value (
any) (optional)
- key (
- Returns
- value (
any)
- value (
- Parameters
- fn (
func): zero-argument function to execute- Returns
- value (
any)
- value (
- Returns
Returns
- value (
any)