dbBegin-TrinoConnection-method: Start, commit and roll back a transaction

dbBegin,TrinoConnection-methodR Documentation

Start, commit and roll back a transaction

Description

Every statement runs inside Trino's engine-level transaction mechanism: dbBegin() sends ⁠START TRANSACTION⁠ and keeps the transaction id Trino answers with, which is then carried on every later request until dbCommit() or dbRollback() sends COMMIT or ROLLBACK and clears it.

Usage

## S4 method for signature 'TrinoConnection'
dbBegin(conn, ...)

## S4 method for signature 'TrinoConnection'
dbCommit(conn, ...)

## S4 method for signature 'TrinoConnection'
dbRollback(conn, ...)

Arguments

conn

A TrinoConnection object.

...

Unused, for compatibility with the generic.

Details

Whether a ROLLBACK actually undoes a write depends on the connector behind the active catalog, not on RTrino: Iceberg and Delta Lake tables support it, most others (including Hive, strictly) only partially, and Trino's own synthetic catalogs (memory, tpch, ...) not at all. dbBegin() warns when the active catalog is one of the latter.

Value

TRUE, invisibly.

Examples


con <- DBI::dbConnect(RTrino::Trino(), host = Sys.getenv("RTRINO_TEST_URL"),
                      catalog = "tpch", schema = "tiny")

# tpch holds no real storage, so dbBegin() warns that a ROLLBACK would
# undo nothing. On an Iceberg or Delta Lake catalog it would not.
DBI::dbBegin(con)
DBI::dbGetQuery(con, "SELECT count(*) AS n FROM nation")
DBI::dbCommit(con)

DBI::dbDisconnect(con)


RTrino documentation built on Oct. 15, 2026, 5:08 p.m.