* 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
When using the 'Any' driver with MySQL backend, fetch_optional
does not return the connection to the pool if no results
are returned from the query. This is due to not all of the packets
being read from the underlying stream.
This fix continues to read result packets from the stream until they
have all been exhausted (just like the normal MySql drivers
implementation of fetch_optional). In general, a better refactoring would
be to call the MySQL fetch_optional code in the Any driver, rather than
re-implementing and duplicating code.
Also clarifies the handling of `TIME` (we never realized it's used for both time-of-day and signed intervals) and adds appropriate impls for `std::time::Duration`, `time::Duration`, `chrono::TimeDelta`
* HasValueRef, HasArguments, HasStatement -> Database GATs
replace the associated types from the generic traits
`HasValueRef<'r>`, `HasArguments<'q>` and `HasStatement<'q>`
with generic associated types in `Database`
* fixup after rebase
---------
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
* feat: add get_url to connect options
Add a get_url to connect options and implement it for all needed types;
include get_filename for sqlite. These changes make it easier to test
sqlx.
* refactor: use expect with message
* refactor: change method name to `to_url_lossy`
* fix: remove unused imports
* feat(mysql): provide options to disable default connection settings after connecting
* style(mysql): remove unecessary newlines and run rustfmt
* feat(mysql): allow to pass a custom timezone to the database after connecting
docs(mysql): improve docs for options set_names and no_engine_substitution
Exposes some of the main fields for PgConnectOptions
and MySqlConnectOptions. Exposed fields include: host,
port, socket, ssl mode, application name, and charset.
The Postgres implementation has this method. It is also
helpful for queries that require the current datbase name.
example:
```sql
SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_name = ? &&
table_schema = ?;
```
fixes https://github.com/readysettech/readyset/issues/143
When using readyset as a caching proxy - readyset returns a decimal with the following type info `MySqlTypeInfo { type: Decimal, flags: ColumnFlags(0x0), char_set: 33, max_size: Some(1024) }`
Currently rust_decimal and bigdecimal expect an exact match for the type info `MySqlTypeInfo { type: NewDecimal, flags: ColumnFlags(BINARY), char_set: 63, max_size: None }`
Therefore the following error occurs when readyset sends a valid decimal type
```
error occurred while decoding column "price": mismatched types; Rust type `core::option::Option<rust_decimal::decimal::Decimal>` (as SQL type `DECIMAL`) is not compatible with SQL type `DECIMAL`
```
This patch makes the `Type<MySql> for Decimal` more lenient by matching `MySqlTypeInfo` that has ColumType::Decimal | ColumnType::NewDecimal to be parsed by both rust_decimal and bigdecimal types
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
```
If the first test thread is a bit slow after it acquires the
`DO_CLEANUP` permit, it can accidentally delete a fresh test db created
by another thread right before that other thread has a chance to open
its connection.
This fix simply records the current timestamp _before_ we acquire the
`DO_CLEANUP` permit and only cleans up test db's created before then.
* 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>
* Fixed typo. (#2156)
* Set whoami default-features to false
Otherwise, whoami pulls in web-sys, wasm-bindgen and a BUNCH of
additional dependencies. This is really unnecessary, and if
someone has an actual use case where they are attempting to connect
to postgres from a browser, well ... they've probably already been
pwned by now. If it is deemed necessary, then add an additional
activation feature for that specific slew of deps.
---------
Co-authored-by: Chris Foster <cdbfoster@gmail.com>
* Add tracing dep
* Switch over basic events
* Switch over dynamically enabled events
* Fix missing SocketAddr formatting
* More format fixing
* refactor: Apply tracing changes to new crate structure