package pgxpool

import (
	

	
	
)

// Tx represents a database transaction acquired from a Pool.
type Tx struct {
	t pgx.Tx
	c *Conn
}

// Begin starts a pseudo nested transaction implemented with a savepoint.
func ( *Tx) ( context.Context) (pgx.Tx, error) {
	return .t.Begin()
}

// Commit commits the transaction and returns the associated connection back to the Pool. Commit will return an error
// where errors.Is(ErrTxClosed) is true if the Tx is already closed, but is otherwise safe to call multiple times. If
// the commit fails with a rollback status (e.g. the transaction was already in a broken state) then ErrTxCommitRollback
// will be returned.
func ( *Tx) ( context.Context) error {
	 := .t.Commit()
	if .c != nil {
		.c.Release()
		.c = nil
	}
	return 
}

// Rollback rolls back the transaction and returns the associated connection back to the Pool. Rollback will return
// where an error where errors.Is(ErrTxClosed) is true if the Tx is already closed, but is otherwise safe to call
// multiple times. Hence, defer tx.Rollback() is safe even if tx.Commit() will be called first in a non-error condition.
func ( *Tx) ( context.Context) error {
	 := .t.Rollback()
	if .c != nil {
		.c.Release()
		.c = nil
	}
	return 
}

func ( *Tx) ( context.Context,  pgx.Identifier,  []string,  pgx.CopyFromSource) (int64, error) {
	return .t.CopyFrom(, , , )
}

func ( *Tx) ( context.Context,  *pgx.Batch) pgx.BatchResults {
	return .t.SendBatch(, )
}

func ( *Tx) () pgx.LargeObjects {
	return .t.LargeObjects()
}

// Prepare creates a prepared statement with name and sql. If the name is empty,
// an anonymous prepared statement will be used. sql can contain placeholders
// for bound parameters. These placeholders are referenced positionally as $1, $2, etc.
//
// Prepare is idempotent; i.e. it is safe to call Prepare multiple times with the same
// name and sql arguments. This allows a code path to Prepare and Query/Exec without
// needing to first check whether the statement has already been prepared.
func ( *Tx) ( context.Context, ,  string) (*pgconn.StatementDescription, error) {
	return .t.Prepare(, , )
}

func ( *Tx) ( context.Context,  string,  ...any) (pgconn.CommandTag, error) {
	return .t.Exec(, , ...)
}

func ( *Tx) ( context.Context,  string,  ...any) (pgx.Rows, error) {
	return .t.Query(, , ...)
}

func ( *Tx) ( context.Context,  string,  ...any) pgx.Row {
	return .t.QueryRow(, , ...)
}

func ( *Tx) () *pgx.Conn {
	return .t.Conn()
}