R/dbRollback_PqConnection.R

Defines functions dbRollback_PqConnection

Documented in dbRollback_PqConnection

#' @rdname postgres-transactions
#' @usage NULL
dbRollback_PqConnection <- function(conn, ..., name = NULL) {
  if (is.null(name)) {
    if (!connection_is_transacting(conn@ptr)) {
      stop("Call dbBegin() to start a transaction.", call. = FALSE)
    }
    dbExecute(conn, "ROLLBACK")
    connection_set_transacting(conn@ptr, FALSE)
  } else {
    name_quoted <- dbQuoteIdentifier(conn, name)
    dbExecute(conn, paste0("ROLLBACK TO ", name_quoted))
    dbExecute(conn, paste0("RELEASE SAVEPOINT ", name_quoted))
  }
  invisible(TRUE)
}

#' @rdname postgres-transactions
#' @export
setMethod("dbRollback", "PqConnection", dbRollback_PqConnection)

Try the RPostgres package in your browser

Any scripts or data that you put into this service are public.

RPostgres documentation built on Oct. 23, 2023, 1:06 a.m.