* 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: implement serialze no copy on lockedsqlitehandle
* feat: implement serialize on sqliteconnection
* feat: implement deserialize on sqliteconnection and add sqlitebuf wrapper type
* refactor: misc sqlite type and deserialize refactoring
* chore: misc clippy refactoring
* fix: misc refactoring and fixes
- pass non-owned byte slice to deserialize
- `SqliteBufError` and better error handling
- more impl for `SqliteOnwedBuf` so it can be used as a slice
- default serialize for `SqliteConnection`
* refactor: move serialize and deserialize on worker thread
This implements `Command::Serialize` and `Command::Deserialize` and moves the
serialize and deserialize logic to the worker thread.
`Serialize` will need some more iterations as it's not clear whether it would
need to wait for other write transactions before running.
* refactor: misc refactoring and changes
- Merged deserialize module with serialize module
- Moved `SqliteOwnedBuf` into serialize module
- Fixed rustdocs
* chore: API tweaks, better docs, tests
* fix: unused import
* fix: export `SqliteOwnedBuf`, docs and safety tweaks
---------
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
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.
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.
The `try_from` and `json` sections are "Field attributes" so they should probably be part of the corresponding section instead of subsections of "Manual implementation". `flatten` should be H4 instead of H3, since "Field attributes" is H3 and all other field attribute sections are H4 too.
query_as.rs: 230 mismatched bracket.
query_as.rs: 230 move TIMESTAMP to TIMESTAMPTZ to match type time::OffsetDateTime.
query_as.rs: 241, 251, 260 move i64 to i32 to match postgres type `INT4`.
* Add a "sqlite-unbundled" feature that dynamically links to system libsqlite3.so library
* update README abouot the newly-added `sqlite-unbundled` feature
* Update README.md to make it clear with bulleted list
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
* more cfg feature updates
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
* update documentation in sqlx-sqlx/src/lib.rs too
and also mention possible build time increasement.
* cargo fmt
* Add "sqlite-unbundled" feature to sqlx-cli
* Add sqlite-unbundled to gituhb actions tests
* cfg(feature = "sqlite") => cfg(any(feature = "sqlite", feature = "sqlite-unbundled"))
* fix
* CI: make sqlite-unbundled tests workaround required-features
by duplicating the relevant test section
* use an internal "_sqlite" feature to do the conditional compilation
---------
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
* fix(postgres): make `PgStream::recv_unchecked()` cancel-safe
* fix(postgres): make `PgListener` close the connection on-error
* fix: incorrect math in `BufferedSocket::read_buffered()`
* add information and example on using json in query macros
* run cargo format
* add missing bracket to docs of json
* wrap docs in hidden async function
* change no_run to ignore
* fix(ci): update workflows/examples.yml
* Removed archived `actions-rs` actions
* Upgraded `Swatinem/rust-cache`, `actions/checkout`, `actions/download-artifact`, `actions/upload-artifact`
* chore: deprecate `AnyKind`
* fix: remove dead references to DB features in `sqlx-core`
This reactivates a couple of tests that had stopped working.
* chore(ci): move sqlx-cli checks to their own workflow
* fix(ci): remove remaining `uses: actions-rs/cargo`
* fix warnings
* chore: add titles to sqlx-cli jobs
* fix warnings (2)
* fix error in pool example
* fix warnings (3)
* fix query_builder test
* fix: don't run CLI tests on Windows
* chore: upgrade `rust-toolchain` to 1.80
* fix(postgres): fix missing Tokio specialization in `PgCopyIn`
Caught by the new `unexpected_cfgs` lint.
* fix new warnings
* Fixed some rust docs intra-doc non functioning links
* Minor tweaks
* Added warning for MSSQL not being functional yet
* Fixed requested changes
* Readded missing time
* Aligned table
* feat: support `NonZero*` scalar types
This commits adds `Type`, `Encode`, and `Decode` impls for all the
`NonZero*` types from the standard library. They are implemented as
direct proxies to their primitive counterparts, except that when
decoding, the values are checked to not be zero.
* fixup!: remove `non-zero` cargo feature
* fixup!: make `non-zero` module private
* fixup!: rebase and fix trait impls
* Make encode and encode_by_ref fallible
This only changes the trait for now and makes it compile, calling .expect() on all users. Those will be removed in a later commit.
* PgNumeric: Turn TryFrom Decimal to an infallible From
* Turn panics in Encode implementations into errors
* Add Encode error analogous to the Decode error
* Propagate decode errors through Arguments::add
This pushes the panics one level further to mostly bind calls. Those will also be removed later.
* Only check argument encoding at the end
* Use Result in Query internally
* Implement query_with functions in terms of _with_result
* Surface encode errors when executing a query.
* Remove remaining panics in AnyConnectionBackend implementations
* PostgreSQL BigDecimal: Return encode error immediately
* Arguments: Add len method to report how many arguments were added
* Query::bind: Report which argument failed to encode
* IsNull: Add is_null method
* MySqlArguments: Replace manual bitmap code with NullBitMap helper type
* Roll back buffer in MySqlArguments if encoding fails
* Roll back buffer in SqliteArguments if encoding fails
* Roll back PgArgumentBuffer if encoding fails
* fix: make resolve_blocking not take ownership of path
When using sqlx_macros_unstable the codepath taken further uses the path
variable and it is more convenient to not take ownership but instead
pass references to needed functions.
* fix: change &PathBuf to &Path in resolve_blocking
* test: add a failing test
* feat: add no_tx to migration struct
* feat: execute migration with no tx block
* fix: expected string literal compilation error
* test: update no tx to content comment
* refactor: use the sql comment instead of file name semantics
* docs: remove no_tx from file format comment
* fix: remove filename matches
* fix: messed up merge
* refactor: dedupe migration
* fix: move comment to where it makes sense
* fix: linter error