2756 Commits

Author SHA1 Message Date
Austin Bonander
0dd92b4594 WIP refactor: replace sharding with single connection set 2025-12-24 23:07:53 -08:00
Austin Bonander
d905016923 fix: debug timeouts in benchmark 2025-12-24 23:07:53 -08:00
Austin Bonander
44e40b2816 fixup! benchmark 2025-12-24 23:07:53 -08:00
Austin Bonander
dd9cb718de fix: bugs in sharded pool 2025-12-24 23:07:53 -08:00
Austin Bonander
23643d7fe2 chore: Cargo.lock after rebase 2025-12-24 23:07:53 -08:00
Austin Bonander
7c5486270b WIP feat: integrate sharding into pool 2025-12-24 23:05:17 -08:00
Austin Bonander
7f6d040cdd feat: create sharding structure for pool 2025-12-24 23:05:17 -08:00
Austin Bonander
4edab50827 fix errors after rebase 2025-12-24 23:05:17 -08:00
Austin Bonander
29035dd13e fix: errors after rebasing 2025-12-24 23:05:17 -08:00
Austin Bonander
782011bec4 fix(pool): tweaks and fixes 2025-12-24 23:05:17 -08:00
Austin Bonander
4d73193c39 fix(pool): use .fuse() 2025-12-24 23:05:17 -08:00
Austin Bonander
18908e6206 fix(pool): use the correct method in try_min_connections 2025-12-24 23:05:17 -08:00
Austin Bonander
0d593a039e fix(pool): don't stop emptying idle queue in .close() 2025-12-24 23:05:17 -08:00
Austin Bonander
928b25691e fix: tests 2025-12-24 23:05:17 -08:00
Austin Bonander
eb478cec03 fix: upgrade ease-off 2025-12-24 23:05:17 -08:00
Austin Bonander
0fb9ab12bb chore: delete defunct use of futures-intrusive 2025-12-24 23:05:17 -08:00
Austin Bonander
e210a23b72 fix: compilation error, warnings 2025-12-24 23:05:17 -08:00
Austin Bonander
98235e646e feat(pool): add more info to impl Debug for PoolConnection 2025-12-24 23:05:17 -08:00
Austin Bonander
8a0f1ab230 fix(pool): add timeout to return_to_pool() 2025-12-24 23:05:17 -08:00
Austin Bonander
b9781c2f10 refactor(pool): use a unique ID per connection 2025-12-24 23:05:17 -08:00
Austin Bonander
dd17a3d98b fix(pool): spawn task for before_acquire 2025-12-24 23:05:17 -08:00
Austin Bonander
3ec35e06bd WIP pool changes 2025-12-24 23:05:17 -08:00
Austin Bonander
0601c3a75d breaking(pool): use usize for all connection counts 2025-12-24 23:05:17 -08:00
Austin Bonander
54564bead6 feat: create Pool::acquire() benchmark 2025-12-24 23:05:15 -08:00
Austin Bonander
a2a219f175
fix CI: replace removed macOS runner, deprecated use of Command::cargo_bin() (#4134)
* fix(ci): update macOS intel runner version

* fix(cli/tests): replace use of deprecated `Command::cargo_bin()`
2025-12-24 21:40:53 -08:00
Joey de Waal
e8384f2a00
fix spelling (#4069) 2025-10-28 05:18:47 -07:00
Andreas Molitor
e4afbd4ca1
chore: update hashlink to v0.11.0 (#4072)
Co-authored-by: amolitor <andreas.molitor@andrena.de>
2025-10-28 04:46:25 -07:00
Austin Bonander
2a1eedd299
fix(CHANGELOG): correct link to #4015 2025-10-28 04:44:02 -07:00
Kevin R
a802da0e67
Fix typo in migration example from 'uesrs' to 'users' (#4068) 2025-10-22 19:40:50 +02:00
Austin Bonander
946b6d4d16 fix: break dev-dependency cycle because of rust-lang/cargo#15622 2025-10-14 19:08:15 -07:00
Austin Bonander
1b2b19fe8e
chore: update CHANGELOG for 0.9.0-alpha-1 (#4057) 2025-10-14 18:47:11 -07:00
Austin Bonander
388c424f48
fix(macros): smarter .env loading, caching, and invalidation (#4053)
* fix(macros): smarter `.env` loading, caching, and invalidation

* feat(mysql): test `.env` loading in CI

* feat(postgres): test `.env` loading in CI

* feat(macros): allow `DATABASE_URL` to be empty

* fix(examples/postgres): make `cargo-sqlx` executable

* fix(examples/postgres): `cargo sqlx` invocation

* feat(examples/postgres): check offline prepare on more examples

* fix(examples/postgres): the name of this step

* fix(cli): don't suppress error from `dotenv()`

* fix(ci/examples/postgres): don't use heredoc in this step

* fix(ci/examples/postgres): multi-tenant

* fix(ci/examples/sqlite): test `.env` loading

* chore: add CHANGELOG entry
2025-10-14 17:31:12 -07:00
David Uebler
064d649abd
native tls handshake: build TlsConnector in blocking threadpool (#4027)
* build TlsConnector in blocking threadpool

The openssl TlsConnector synchronously loads certificates from files.
Loading these files can block for tens of milliseconds.

* Update sqlx-core/src/net/tls/tls_native_tls.rs

---------

Co-authored-by: David Übler <david.uebler@puzzleyou.de>
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2025-09-23 07:23:01 -07:00
Dosenpfand
c52e129e83
fix(sqlite) Migrate revert with no-transaction (#4024)
* Fix migration reverts for no-TX SQLite

* Add regression test

---------

Co-authored-by: Markus Gasser <markus.gasser@frauscher.com>
2025-09-14 17:43:39 -07:00
iamjpotts
81526898d4
refactor(core): Remove lifetime parameter from Arguments trait (#3960)
* refactor(core): Remove lifetime parameter from Arguments trait

Signed-off-by: Joshua Potts <8704475+iamjpotts@users.noreply.github.com>

* refactor(core): Also relax lifetime of argument passed to Query::bind and Query::try_bind

Signed-off-by: Joshua Potts <8704475+iamjpotts@users.noreply.github.com>

---------

Signed-off-by: Joshua Potts <8704475+iamjpotts@users.noreply.github.com>
2025-09-13 21:47:45 -07:00
iamjpotts
54a0492ee2
refactor(any): Remove lifetime parameter from AnyArguments (#3958)
Signed-off-by: Joshua Potts <8704475+iamjpotts@users.noreply.github.com>
2025-09-12 16:11:39 -07:00
Alejandro González
1f4b5f28f3
feat(sqlite): no_tx migration support (#4015)
* chore(sqlx-postgres): fix typo in `migrate.rs` comment

* feat(sqlite): support `no_tx` migrations

SQLite includes several SQL statements that are useful during migrations but
must be executed outside of a transaction to take effect, such as `PRAGMA
foreign_keys = ON|OFF` or `VACUUM`. Additionally, advanced migrations may want
more precise control over how statements are grouped into transactions or
savepoints to achieve the desired atomicity for different parts of the
migration.

While SQLx already supports marking migrations to run outside explicit
transactions through a `-- no-transaction` comment, this feature is currently
only available for `PgConnection`'s `Migrate` implementation, leaving SQLite and
MySQL without this capability. Although it's possible to work around this
limitation by implementing custom migration logic instead of executing
`Migrator#run`, this comes at a cost of significantly reduced developer
ergonomics: code that relies on the default migration logic, such as
`#[sqlx::test]` or `cargo sqlx database setup`, won't support these migrations.

These changes extend `SqliteConnection`'s `Migrate` implementation to support
`no_tx` migrations in the same way as PostgreSQL, addressing this feature gap. I
also considered implementing the same functionality for MySQL, but since I
haven't found a practical use case for it yet, and every
non-transaction-friendly statement I could think about in MySQL triggers
implicit commits anyway, I determined it wasn't necessary at this time and could
be considered an overreach.

* test(sqlite): add test for `no_tx` migrations

* chore(sqlx-sqlite): bring back useful comment

* chore(sqlx-sqlite): unify SQL dialect in annotation comments
2025-09-08 14:55:58 -07:00
Austin Bonander
66526d9c56
refactor: tweaks after #3791 (#4022)
* restore fallback to `async-io` for `connect_tcp()` when `runtime-tokio` feature is enabled
* `smol` and `async-global-executor` both use `async-task`, so `JoinHandle` impls can be consolidated
* no need for duplicate `yield_now()` impls
* delete `impl Socket for ()`
2025-09-08 14:28:58 -07:00
Paul Xu
500cd18f19
Add Migrator::with_migrations() constructor (#4020)
* Add the helper function with_migrations() to Migrator.

* cargo fmt

* cargo fmt

* cargo fmt

* Improve comments.
2025-09-08 14:01:23 -07:00
martin-kolarik
6b828e698f
Smol+async global executor 1.80 dev (#3791)
* Sqlx-core: rename async_io dependency for async-std

* Sqlx-core: simplify TimeoutError

* Sqlx-core: code for async-global-executor

* Sqlx: integrate async-global-executor feature

* Note to unsafe

* Step up MSRV as async-global-executor needs it

* Sqlx-core: fix of unix socket build

* Unsafe fixes, smol executor added

* Workflow fix

* Changes outside sqlx_rt

* Cleanup conditional rt compilation

* Warning

* Add executors to test matrix

* Fix of skipping code sqlite due to mismatch in cargo feature names

* Smol executor isolated

* Fix, reduce number of tests, remove async_std

* Fix of test_block_on, regression

* Format fixes

* async-global-executor added

* async-std changed to 1.13

* litemap, zerofrom requires rustc 1.81

* Fix of missing _sqlite in cargo.toml

* Clippy lints

* Clean up

* Remove features combinations

* Fixes after merge

* Fix of compiling connect_tcp_address with both tokio + other executor selected

* Try to fix CI -Z minimal-versions check

Try to fix CI -Z minimal-versions check
2025-09-08 11:17:55 -07:00
Thom Wright
482c9427a9
PostgreSQL SASL – run SHA256 in a blocking executor (#4006)
* Yield while salting password for PG SASL

To prevent spenting too much time doing synchronous work on the
event loop, we yield every few iterations of the hmac-sha256.

* Remove unused bench
2025-09-05 18:02:39 -07:00
Sean Lynch
69bb5952ab
Drop cached db connections in macros upon hitting an error (#4009)
Once a connection to the database is lost all future macro evaluations
will fail. This is fine for normal compilation since it tends to be
short but causes issues with rust-analyzer since it keeps the macro
binaries loaded for a long time.

This commit changes the macro implementation to drop the cached
connection when it encounters an IO or protocol error. In practice these
seem to be the errors that show up when the connection is lost and
dumping the connection on every error would have unnecessary overhead.
2025-08-28 20:37:49 -07:00
Jonatan Czarniecki
3abb186324
make #[derive(sqlx::Type)] automatically generate impl PgHasArrayType by default for newtype structs (#4008)
add regression tests
2025-08-27 18:12:20 -07:00
Jonatan Czarniecki
e6e8fc7219
use random ports for all conatiners (#4007)
I couldn't follow the steps in `tests/README.md` because two containers failed to bind to the same port, already used by a local running database.
2025-08-27 11:16:19 -07:00
iamjpotts
c5037f1fca
chore(deps): Resolve deprecation warning for chrono Date and ymd methods (#3987)
* chore(deps): Resolve deprecation warning for chrono Date and ymd methods

Signed-off-by: Joshua Potts <8704475+iamjpotts@users.noreply.github.com>

* chore(ci): Fail postgres tests if compiling them generates warnings

Signed-off-by: Joshua Potts <8704475+iamjpotts@users.noreply.github.com>

---------

Signed-off-by: Joshua Potts <8704475+iamjpotts@users.noreply.github.com>
2025-08-27 11:03:03 -07:00
iamjpotts
5d4e1a4d4d
chore(deps): Set default-features=false on sqlx in workspace.dependencies (#3989)
Signed-off-by: Joshua Potts <8704475+iamjpotts@users.noreply.github.com>
2025-08-27 11:02:27 -07:00
Joey de Waal
4566df70a0
sqlx-postgres(tests): cleanup 2 unit tests. (#4002)
* sqlx-postgres(tests): fix positive_int domain type

* sqlx-postgres(tests): Update no pg array test

* sqlx-core: Remove conflicting Type impl for Box<JsonRawValue>
2025-08-26 22:29:10 -07:00
Dario Nieuwenhuis
648250dc6d
Add more JsonRawValue encode/decode impls. (#3859)
* Add support for `Box<JsonRawValue>` types.

This allows keeping structs that implement FromRow lifetime-free,
previously you had to use `&'a JsonRawValue`.

```rust
struct Foo {
    bar: Box<JsonRawValue>,
}
```

* Add Encode impls for `JsonRawValue`.
2025-08-25 16:40:26 -07:00
iamjpotts
99ec41913c
refactor(sqlite): Resolve duplicate test target warning for macros.rs (#3988)
* refactor(sqlite): Resolve duplicate test target warning for macros.rs

Signed-off-by: Joshua Potts <8704475+iamjpotts@users.noreply.github.com>

* refactor(sqlite): For macros tests, use _sqlite pseudo feature instead of #![cfg(...)] in the module

Signed-off-by: Joshua Potts <8704475+iamjpotts@users.noreply.github.com>

---------

Signed-off-by: Joshua Potts <8704475+iamjpotts@users.noreply.github.com>
2025-08-25 15:28:11 -07:00
jerryq
c01f51330a
Rename PgLTree::from to from_labels and add From<Vec<PgLTreeLabel>> implementation (#3949) 2025-08-21 22:11:35 -07:00