With MariaDB 10.3 EOL it seems prudent to include
the latest 10.11 LTS release in the CI tests.
To catch #1664 sort of issues prior to release, add
a container image test for mariadb that contains the
finished pre-release code changes (and container changes)
to ensure that compatibilty is maintianed. When
server code hits the branch associated with this tag
it is considered finished by its server developers and
has passes CI so no regressions are expected, but
it wouldn't hurt to have CI in other systems testing
it too.
Since MySQL has fixed the regression that caused #1664
this puts it back to their 8.0 release tag.
Append the :z tag to the docker compose volume mounts
so on selinux systems enough permissions occur for the
volume to be able to read the volume contents.
* fix(postgres): sqlx prepare fails if shared_preload_libraries=pg_stat_statements
closes#2622
refs:
* https://serde.rs/enum-representations.html#untagged
* https://serde.rs/field-attrs.html#skip
* https://www.postgresql.org/docs/current/pgstatstatements.html
* https://www.postgresql.org/docs/current/runtime-config-statistics.html#GUC-COMPUTE-QUERY-ID
* fix(postgres): regression of #1449
```
error: error occurred while decoding column 0: data did not match any variant of untagged enum Explain at line 3 column 1
Error: --> tests/postgres/macros.rs:103:15
|
103 | let row = sqlx::query!(r#"CALL forty_two(null)"#)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `$crate::sqlx_macros::expand_query` which comes from the expansion of the macro `sqlx::query` (in Nightly builds, run with -Z macro-backtrace for more info)
error: could not compile `sqlx` (test "postgres-macros") due to previous error
```
* refactor(postgres): don't define unused fields in QueryPlan
* refactor(postgres): simplify query plan handling, add unit test
* chore: document why we load `pg_stat_statements` in tests
---------
Co-authored-by: mrl5 <31549762+mrl5@users.noreply.github.com>
Inlined format args make code more readable, and code more compact.
I ran this clippy command to fix most cases, and then cleaned up a few trailing commas and uncaught edge cases.
```
cargo clippy --bins --examples --benches --tests --lib --workspace --fix -- -A clippy::all -W clippy::uninlined_format_args
```
* Traverse symlinks when resolving migrations
When enumerating the source directory seeking migration files, `sqlx`
ignores entries that aren't files. This was previously reported as #614
and fixed in #985 but apparently regressed somewhere along the way. This
commit reintroduces the fix from #985 to the current implementation: use
`std::fs::metadata` instead of `std::fs::DirEntry::metadata`. The former
is documented to traverse symlinks; the latter does not.
* add migrations_symlink test
* Add failing tests
* remove unnecessary functions, clarify function names
* simplify access to cursor columns with helper methods
* split table info from cursor info so that cursors can share table info
* fix test expectations
Fixes#1449 (I think). I verified that the code fixes the new test.
I used INOUT in setup.sql because older versions of Postgres don't
support OUT parameters.
* use native-tls API
* Add client cert and key to MySQL connector
* Add client ssl tests for PostgreSQL
* Add client ssl tests for MariaDB and MySQL
* Adapt GA tests
* Fix RUSTFLAGS to run all tests
* Remove containers to free the DB port before running SSL auth tests
* Fix CI bad naming
* Use docker-compose down to remove also the network
* Fix main rebase
* Stop trying to stop service using docker-compose, simply use docker cmd
* Fix RUSTFLAGS for Postgres
* Name the Docker images for MariaDB and MySQL so we can stop them using their name
* Add the exception for mysql 5.7 not supporting compatible TLS version with RusTLS
* Rebase fixes
* Set correctly tls struct (fix merge)
* Handle Elliptic Curve variant for private key
* Fix tests suite
* Fix features in CI
* Add tests for Postgres 15 + rebase
* Python tests: fix exception for MySQL 5.7 + remove unneeded for loops
* CI: run SSL tests only when building with TLS support
---------
Co-authored-by: Barry Simons <linuxuser586@gmail.com>
* add failing test for nested orderby
* log query paths which were abandoned due to invalid state or looping. Allow instructions to be executed a small number of times to fix nested order by query
* add failing testcase using nested orderby
* fix handling of sequence/offset and rewind
* fix handling when sqlite nests records inside of records
* add test of temporary table handling
* WIP add test failure for temp table access
* fix support for temp tables
* add tests for sqlite datetime functions
* add basic date and time function support
* handle gosub opcode correctly
* add group by test
* fix group by handling
* add additional passing group by test
* add test case for simple limit query
* fix IfPos & If touching wrong branches state, fix IfPos using wrong branch criteria
* add test for large offsets
* add short-circuit for possible query offset loops
* add groupby query that is predicted incorrectly
* fix handling of integer cast failures
* add tests for single-row aggregate results
* fix handling of null-based branching
* add test for coercion of text by sum
* fix calculation of sum value coercion
* add failing test for recursive with query
* add logic for delete operation to fix queries grouping by columns from a recursive query
* add failing test cases for update/delete return into
* fix regression in null tracking by improving tracking of cursor empty/full state
* add failing test case for order by column types
* Add support for SorterOpen,SorterInsert,SorterData
* add failing test case for unions
* fix range copy/move implementation
* fix wrong copy/move range
* remove calls to dbg!
* fix: ensure migration progress is not lost for PG
Fixes#1966.
* fix: ensure migration progress is not lost for sqlite
This is similar to #1966.
* fix: ensure reverse migration progress is not lost for PG
See #1966.
* fix: ensure reverse migration progress is not lost for sqlite
See #1966.
* fix: ensure migration progress is not lost for mysql
This is similar to #1966.
* fix: ensure reverse migration progress is not lost for mysql
See #1966.
* test: check migration type as well
* test: extend migrations testing
* fix: work around MySQL implicit commits
* refactor: simplify migration testing
* Add extension support for SQLite
While SQLite supports loading extensions at run-time via either the C
API or the SQL interface, they strongly recommend [1] only enabling the C
API so that SQL injections don't allow attackers to run arbitrary
extension code.
Here we take the most conservative approach, we enable only the C
function, and then only when the user requests extensions be loaded in
their `SqliteConnectOptions`, and disable it again once we're done
loading those requested modules. We don't add any support for loading
extensions via environment variables or connection strings.
Extensions in the options are stored as an IndexMap as the load order
can have side effects, they will be loaded in the order they are
supplied by the caller.
Extensions with custom entry points are supported, but a default API
is exposed as most users will interact with extensions using the
defaults.
[1]: https://sqlite.org/c3ref/enable_load_extension.html
* Add extension testing for SQlite
Extends x.py to download an appropriate shared object file for supported
operating systems, and uses wget to fetch one into the GitHub Actions
context for use by CI.
Overriding LD_LIBRARY_PATH for only this specific DB minimises the
impact on the rest of the suite.
* SQLite: Execute SQLCipher pragmas as very first operations on the database
SQLCipher requires, apart from 'key' pragma also other cipher-related
to be executed before read/write to the database.
* Added tests for SQLCipher functionality
* remove default-features from libsqlite3-sys when building from dev-dependencies
Co-authored-by: Szymon Zimnowoda <szimnowoda.memri@gmail.com>
* use direct blocking calls for SQLite in `sqlx_macros`
* this also ensures the database is closed properly, cleaning up tempfiles
* don't send `PRAGMA journal_mode` unless set
* this previously defaulted to WAL mode which is a permanent setting
on databases which doesn't necessarily apply to all use-cases
* changing into or out of WAL mode acquires an exclusive lock on the database
that can't be waited on by `sqlite3_busy_timeout()`
* for consistency, `sqlx-cli` commands that create databases will still
create SQLite databases in WAL mode; added a flag to disable this.
* in general, don't send `PRAGMA`s unless different than default
* we were sending a bunch of `PRAGMA`s with their default values just to enforce
an execution order on them, but we can also do this by inserting empty slots
for their keys into the `IndexMap`
* add error code to `SqliteError` printout
* document why `u64` is not supported
* feat(sqlite): Add 'time' crate support for date/time types
docs(sqlite): Update types module docs for JSON and Chrono
docs(mysql): Update types module docs for JSON
* More efficient time crate decoding with FormatItem::First and hand-crafting of format descriptions
* Replace temporary testing code with original intention
* Replace duplicated formatting test with intended test
* Performance improvements to decoding OffsetDateTime, PrimitiveDateTime, and Time
* Use correct iteration for OffsetDateTime
* Reduce visibility of format constants
Co-authored-by: John B Codes <johnbcodes@users.noreply.github.com>
This function can panic due to slicing out of bounds when the server
responds without the `\x` prefix. With this commit we instead error and
also ensure that the prefix is what we expect instead of blindly
removing it.
Not directly related to the panic, we replace as_str() with as_bytes()
because there is no reason to perform a utf8 validity check when
hex::decode already checks that the content is valid.
* pool: fix panic when using callbacks
add regression test
* pool: fix panic when using callbacks
add regression test
added missing typedef `MssqlPoolOptions`
* Fixed leak of `Arc<SharedPool>` in `DecrementSizeGuard::cancel()`
* Renamed `PoolOptions::connect_timeout` to `acquire_timeout` for clarity.
* Fixed `/* SQLx ping */` showing up in Postgres query logs
* Made `.close()` a regular function that returns a `Future`
* Deleted deprecated method `PoolConnection::release()`
* Document why connection might be dropped if `Pool::acquire()` is cancelled
* Added connection metadata to pool lifecycle callbacks
* Improved guarantees for `min_connections`
* Fixed `num_idle()` to not spin forever at high load
* Improved documentation across the `pool` module
* reproduce incorrect nullability for materialized views
* split ephemeral/index-only table handling from real table handling
* add test for literal null, expect nullability to be identified from table information
* gather interpreter state into a struct, no change in behaviour
* prevent infinite loops that could arise once branching is supported
* track nullability alongside the datatype instead of in a separate lookup
* implement basic comprehension of branching opcodes
* fix datatype calculation of aggregates which are never 'stepped' through
* implement coroutine and return operations, including tracking of 'actual' integer value stored in the register by Integer/InitCoroutine/Yield operations.
* strip unnecessary history field out
* Modify variable test to expect bind-variable outputs to be nullable, rather than unknown
* add partially commented-out union tests, simplify code to satisfy simplest union case
* fix unit test incorrectly expecting primary keys to be implicitly not-null
* add failing test for recursive tables
* add logging of query explain plan
* track explain plan execution history
* broken RowData implementation (doesn't alias)
* Implement OpenPseudo tables as an alias of a register value
* fix comment
* clean up logging code warnings
* use cfg to omit QueryPlanLogger unless sqlite feature is used
* query_as: don't stop stream after decoding error
Fixes https://github.com/launchbadge/sqlx/issues/1884
When a single row cannot be converted to the target type of query_as,
it should not prevent the library user from accessing the other rows
Otherwise, the user cannot access all query results in query_as.
* use union in tests to maximize db compatibility
Postgres arrays and records do not fully support custom types. When encountering an unknown OID, they currently default to using `PgTypeInfo::with_oid`. This is invalid as it breaks the invariant that decoding only uses resolved types, leading to panics.
This commit returns an error instead of panicking. This is merely a mitigation: a proper fix would actually add full support for custom Postgres types. Full support involves more work, so it may still be useful to fix this immediate issue.
Related issues:
- https://github.com/launchbadge/sqlx/issues/1672
- https://github.com/launchbadge/sqlx/issues/1797