-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Is your feature request related to a problem? Please describe.
transaction_depth is currently marked as pub(crate) in the connection struct, which makes it inaccessible from outside the crate. This limitation poses a challenge when working with advisory locks, as described in the following library's README:
mpyw/laravel-database-advisory-lock: Advisory Locking Features for Postgres/MySQL/MariaDB on Laravel
Session-level advisory locks must be acquired before entering a transaction and released only after the transaction has been committed. To ensure consistency, it's crucial to verify whether a transaction is already active before acquiring the lock.
Describe the solution you'd like
I would like to request a read-only Getter method for the transaction_depth field to be added, so that it can be accessed from outside the crate.
Describe alternatives you've considered
An alternative could be to use a custom wrapper around the connection, but this would add unnecessary complexity and overhead. Another option might be to manage transaction depth manually in user code, but this is error-prone and defeats the purpose of the existing transaction_depth field.
Additional context
Providing access to transaction_depth would allow for safer and more consistent handling of nested transactions, particularly in scenarios involving advisory locks.