* feat: Implement `get_transaction_depth` for drivers
* test: Verify `get_transaction_depth()` on postgres
* Refactor: `TransactionManager` delegation without BC
SQLite implementation is currently WIP
* Fix: Avoid breaking changes on `AnyConnectionBackend`
* Refactor: Remove verbose `SqliteConnection` typing
* Feat: Implementation for SQLite
I have included `AtomicUsize` in `WorkerSharedState`. Ideally, it is not desirable to execute `load` and `fetch_add` in two separate steps, but we decided to allow it here since there is only one thread writing. To prevent writing from other threads, the field itself was made private, and a getter method was provided with `pub(crate)`.
* Refactor: Same approach for `cached_statements_size`
ref: a66787d36d62876b55475ef2326d17bade817aed
* Fix: Add missing `is_in_transaction` for backend
* Doc: Remove verbose "synchronously" word
* Fix: Remove useless `mut` qualifier
* feat: add Connection::begin_with
This patch completes the plumbing of an optional statement from these methods to
`TransactionManager::begin` without any validation of the provided statement.
There is a new `Error::InvalidSavePoint` which is triggered by any attempt to
call `Connection::begin_with` when we are already inside of a transaction.
* feat: add Pool::begin_with and Pool::try_begin_with
* feat: add Error::BeginFailed and validate that custom "begin" statements are successful
* chore: add tests of Error::BeginFailed
* chore: add tests of Error::InvalidSavePointStatement
* chore: test begin_with works for all SQLite "BEGIN" statements
* chore: improve comment on Connection::begin_with
* feat: add default impl of `Connection::begin_with`
This makes the new method a non-breaking change.
* refactor: combine if statement + unwrap_or_else into one match
* feat: use in-memory SQLite DB to avoid conflicts across tests run in parallel
* feedback: remove public wrapper for sqlite3_txn_state
Move the wrapper directly into the test that uses it instead.
* fix: cache Status on MySqlConnection
* fix: compilation errors
* fix: format
* fix: postgres test
* refactor: delete `Connection::get_transaction_depth`
* fix: tests
---------
Co-authored-by: mpyw <ryosuke_i_628@yahoo.co.jp>
Co-authored-by: Duncan Fairbanks <duncanfairbanks6@gmail.com>
* feat: add polygon
* test: paths for pgpoints in polygon test
* fix: import typo
* chore(Sqlite): remove ci.db from repo (#3768)
* fix: CI
* Fix breakage from Rustup 1.28 <https://blog.rust-lang.org/2025/03/02/Rustup-1.28.0.html>
* Let `Swatinem/rust-cache` generate cache keys
* fix(ci): upgrade Ubuntu image to 24.04
For some reason the `cargo +beta clippy` step is failing because `libsqlite3-sys` starts requiring Glibc >= 2.39 but I don't have time to figure out why and I can't reproduce it in a clean environment.
---------
Co-authored-by: joeydewaal <99046430+joeydewaal@users.noreply.github.com>
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
* feat: add geometry path
* fix: paths to pg point
* test: remove array tests for path
* Fix readme: uuid feature is gating for all repos (#3720)
The readme previously stated that the uuid feature is only for postres but it actually also gates the functionality in mysql and sqlite.
* Replace some futures_util APIs with std variants (#3721)
* feat(sqlx-cli): Add flag to disable automatic loading of .env files (#3724)
* Add flag to disable automatic loading of .env files
* Update sqlx-cli/src/opt.rs
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
---------
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
* chore: expose bstr feature (#3714)
* chore: replace rustls-pemfile with rustls-pki-types (#3725)
* QueryBuilder: add `debug_assert` when `push_values` is passed an empty set of tuples (#3734)
* throw a warning in tracing so that the empty tuples would be noticed
* use debug assertion to throw a panic in debug mode
* fix: merge conflicts
* chore(cli): remove unused async-trait crate from dependencies (#3754)
* Update pull_request_template.md
* Fix example calculation (#3741)
* Avoid privilege requirements by using an advisory lock in test setup (postgres). (#3753)
* feat(sqlx-postgres): use advisory lock to avoid setup race condition
* fix(sqlx-postgres): numeric hex constants not supported before postgres 16
* Small doc correction. (#3755)
When sqlx-core/src/from_row.rs was updated to implement FromRow for tuples of up to 16 values, a comment was left stating that it was implemented up to tuples of 9 values.
* Update FAQ.md
* refactor(cli): replace promptly with dialoguer (#3669)
* docs(pool): recommend actix-web ThinData over Data to avoid two Arcs (#3762)
Both actix_web::web::Data and sqlx::PgPool internally wrap an Arc. Thus,
using Data<PgPool> as an extractor in an actix-web route handler results
in two Arcs wrapping the data of interest, which isn't ideal.
Actix-web 4.9.0 introduced a new web::ThinData extractor for cases like
this, where the data is already wrapped in an `Arc` (or is otherwise
similarly cheap and sensible to simply clone), which doesn't wrap the
inner value in a (second) Arc.
Since the new extractor is better suited to the task, suggest it in
place of web::Data when giving an example on how to share a pool.
* fix: merge conflicts
* fix: use types mod from main
* fix: merge conflicts
* fix: merge conflicts
* fix: merge conflicts
* fix: ordering of types mod
* fix: path import
* test: no array test for path
---------
Co-authored-by: Jon Thacker <thacker.jon@gmail.com>
Co-authored-by: Paolo Barbolini <paolo.barbolini@m4ss.net>
Co-authored-by: Ben Wilber <benwilber@users.noreply.github.com>
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
Co-authored-by: joeydewaal <99046430+joeydewaal@users.noreply.github.com>
Co-authored-by: tottoto <tottotodev@gmail.com>
Co-authored-by: Ethan Wang <mailme@ethanavania.org>
Co-authored-by: Stefan Schindler <dns2utf8@users.noreply.github.com>
Co-authored-by: kildrens <5198060+kildrens@users.noreply.github.com>
Co-authored-by: Marti Serra <marti.serra+github@protonmail.com>
Co-authored-by: Jonas Malaco <jonas@protocubo.io>
* feat: add geometry line
* fix: point vs line
* fix: try regular comparison for line
* fix: undo point comparison change
* fix: regular comparison for array lines
* fix: remove line array test
When PgListener's underlying connection is closed, try_recv() will
return Ok(None) and reconnect on the next call. In this case, user code
is supposed to reload its state from the database (or otherwise handle
potentially missing messages). However, if the user code uses another
database connection to do so then there is a period between when the
state is reloaded and PgListener's connection is re-established where
notifications are lost without any indication that this has happened.
This commit changes PgListener to eagerly reconnect by default. At the
suggestion of @abonander on discord, I have also included an option to
switch back to the old behaviour in the case where someone was depending
on it.
Now, if the connection is closed then, by default, user code can do
whatever it needs to do in order to recover and any notifications
emitted in the meantime will be waiting for it when it is done.
* feat: point
* test: try if eq operator works for arrays of geometries
* fix: re-introduce comparison
* fix: test other geometry comparison
* test: geometry array equality check
* test: array match for geo arrays geo match for geo only
* fix: prepare geometric array type
* fix: update array comparison
* fix: try another method of geometric array comparison
* fix: one more geometry match tests
* fix: correct query syntax
* test: geometry test further
* impl AnyQueryResult for Sqlite and MySQL
* fix MySQL AnyQueryResult
* fix MySQL AnyQueryResult
* fix manifest
* rewrite `use` and address implementation concerns
* Implement Acquire for PgListener
* Add a test which checks that PgListener implements Acquire
* Drop unnecessary call to `.acquire()`
* Rename test channel to avoid conflict with other tests
* fix(sqlx-postgres): macro could not understand pg interval array type
* refactor(sqlx-postgres): move pg interval array types closer to other array types
* fix(postgres): make `PgStream::recv_unchecked()` cancel-safe
* fix(postgres): make `PgListener` close the connection on-error
* fix: incorrect math in `BufferedSocket::read_buffered()`
* fails to compile as size_of is not found in scope
* keep scoping consistent with other type modules
* fmt fixes
---------
Co-authored-by: kdesjard <kristian.desjardins@nrcan-rncan.gc.ca>