* 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
* changed [] access to .get() to return result instead of panic
* changed error type to protocol err
* fixed issue with comparing ref
* cargo fmt
Co-authored-by: Erik Rhodes <erik@space-nav.com>
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
* refactor: Reuse a cached connection instead of always recreating for `sqlx-macros`
* fix: Fix type inference issue when no database features used
* refactor: Switch cached db conn to an `AnyConnection`
* fix: Fix invalid variant name only exposed with features
* fix: Tweak connection options for SQLite with `sqlx-macros`
* fix: Remove read only option for SQLite connection
* fix: Fix feature flags regarding usage of `sqlx_core::any`
* Make PgLTree::push infallible and take PgLTreeLabel directly.
Previously the function took strings and parsed them into
PgLTreeLabel internally, now it's possible to directlry push
PgLTreeLabels onto a PgLTree.
* Push PgLTree String conversion to label.
* rebase and fix compile error
Co-authored-by: Austin Bonander <austin@launchbadge.com>
* postgres: use Oid type instead of u32
* Make serde happy
* Expose the inner u32
* docs
* Try to fix tests
* Fix unit tests
* Fix order
* Not sure what happened here
git2-rs recently updated major versions due to libgit2 doing the same.
Bump the version used in sqlx accordingly, to allow users of the new
git2 to use git2::Oid with sqlx.
* Add Query builder
* Make query_builder.rs in sqlx-core
* Add QueryBuilder::new()
* Add QueryBuilder::push()
* Define questions for documentation
* Get new, push, push_bind working with types
* Handle postgres' numbered bind varaibles
* Add a test for QueryBuilder#build
* Move arguments into Option
* Refactor query builder
* Finish testing QueryBuilder#build
* Remove design doc
* Add a test for pushing strings with push_bind
* Integration test green
* Adjust some tests
* Make query builder generic about placeholder segmenent ('$N' or '?')
* Run fmt
* Redesign Arguments#format_placeholder in line with code review
* Use write! to push sql to QueryBuilder
* Add QueryBuilder::reset to allow for QueryBuilder reuse
* Run cargo fmt
Right now, there is only a `run` function to programatically run the
migrations, which is great, but nothing to run the migrations down.
This function adds the possibility to undo the migrations until a
specific version (could say -1 or 0 to remove them all).
With this feature, it's now possible, in the end to end or integration
tests to run the migrations and undo them between each test set and
therefore test the migrations themselves.
This is the kind of feature that some ORM have like sequelize in nodejs
that allow you to undo migrations programatically.
Reference to the doc:
https://sequelize.org/v7/manual/migrations.html#undoing-migrations
Signed-off-by: Jérémie Drouet <jeremie.drouet@gmail.com>
* Reproduce github issue#1249: Left joins in sqlite can break the query macros
* Fix panic caused by unknown cursor columns when executing NullRow command. Fixes#1249
* Implement PgHasArrayType for JSON types in the serde_json crate
* Remove redundant Type impls for arrays and Vecs of JsonValue
* Relax an implicit Sized bound to support JsonRawValue
I'm having panics on those index accesses, an empty packet is probably a symptom of other problems, but it would be cool if the application doesn't panics like it does.
* fix(cli): change new `rustls` and `native-tls` features to use correct runtime feature
* chore: upgrade SQLx crates to 0.5.10, upgrade all dependencies to latest versions
chore(cli): upgraded `clap` to `3.0.0-rc.9`
* fix(tests/sqlite): ignore `issue_1467()` as spuriously failing
I'm well aware of the principle that a spuriously failing test is a failing test, but even though I have it outputting the seed used with a reproducible PRNG, I can't reproduce the failures locally, so 🤷.
* chore: add CHANGELOG entry for 0.5.10
* feat(postgres): add an option to specify extra options ...
... this allow you to specify stuff like search path and statement
timeouts etc.
* feat(postgres): set options through setting run-time parameters
* feat(postgres): use flat command-list instead of hashmap
* feat(postgres): make the options taking parameters with `Display` trait
This commit fixes the array decoder to support custom types. The core of the issue was that the array decoder did not use the type info retrieved from the database. It means that it only supported native types.
This commit fixes the issue by using the element type info fetched from the database. A new internal helper method is added to the `PgType` struct: it returns the type info for the inner array element, if available.
Closes#1477
* fix(postgres): Fixes pgpass so it applies after parsing and matches usernames & databases correctly
* chore: Updated unit test
* refactor: Previous semantics of PgConnectOptions::default()
* refactor: formatting
deno_core currently uses `=1.6.2` for indexmap, and Cargo refuses to resolve a version with sqlx's requirement of 1.7.0.
004d07dccd/core/Cargo.toml (L18)
* add explicit shutdown of sqlite statement worker in Connection::close()
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
* test sqlite database close method
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
* await worker shutdown after dropping SqliteConnection
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
* restore explicit drop
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
* Support custom initial options for sqlite
Apply suggestions from code review
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
Apply suggestions from code review
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
Use order-preserving map to set pragmas for an initial sqlite statement
Use Cow<'static, str> instead of String
Co-authored-by: Austin Bonander <austin@launchbadge.com>
* fix: wait until ready after executing other helper queries while pg quering is executing
Signed-off-by: Atkins Chang <atkinschang@gmail.com>
* fix: use tls parameter for testing target
Signed-off-by: Atkins Chang <atkinschang@gmail.com>
* sqlite: use Arc instead of Copy-able StatementHandle
This guarantees that StatementHandle is never used after calling
`sqlite3_finalize`. Now `sqlite3_finalize` is only called when
StatementHandle is dropped.
(cherry picked from commit 5eebc05dc3)
* sqlite: use Weak poiter to StatementHandle in the worker
Otherwise some tests fail to close connection.
(cherry picked from commit 5461eeeee3)
* Fix segfault due to race condition in sqlite (#1300)
(cherry picked from commit bb62cf767e)
* fix(sqlite): run `sqlite3_reset()` in `StatementWorker`
this avoids possible race conditions without using a mutex
* fix(sqlite): have `StatementWorker` keep a strong ref to `ConnectionHandle`
this should prevent the database handle from being finalized before all statement handles
have been finalized
* fix(sqlite/test): make `concurrent_resets_dont_segfault` runtime-agnostic
Co-authored-by: link2xt <link2xt@testrun.org>
Co-authored-by: Adam Cigánek <adam.ciganek@gmail.com>
* a task that is marked woken but didn't actually wake before being cancelled will instead wake the next task in the queue
* a task that wakes but doesn't get a connection will put itself back in the queue instead of waiting until it times out with no way to be woken
* the idle reaper now won't run if there are tasks waiting for a connection, and also uses
the proper `SharedPool::release()` to return validated connections to the pool so waiting tasks get woken
closes#622, #1210
(hopefully for good this time)
Signed-off-by: Austin Bonander <austin@launchbadge.com>
While running an application a lot of warnings were printed about my
pgpass file, like:
Malformed line in pgpass file
This was due to the fact that my pgpass file contains whitespace and
comments to organize it in a better way.
This commit ensures we will ignore empty lines and lines that (barring
whitespace) start with a comment. This is in line with how PostgreSQL
treats these entries in the pgpass file:
- https://www.postgresql.org/docs/current/libpq-pgpass.html
- function passwordFromFile in src/interfaces/libpq/fe-connect.c
Unlike `Executor.fetch_optional()`, `Executor.fetch_many()` does not
have a single exit. The stream can be dropped at any time. To catch
this event, we create a `StatementResetter` structure inside the stream
loop and reset the statement when it is dropped.
A test case `it_resets_prepared_statement_after_fetch_many` is
similar to `it_resets_prepared_statement_after_fetch_one` which tests
`Executor.fetch_optional()`.
64-bit pointers can't be casted to i32 correctly.
It does not seem to cause problems on amd64 as long as both pointers
reside in the same page, but it's not correct generally.
The provided callback doesn't need to be `'static`. It should be enough that it doesn't borrow anything from the `Connection` itself, even if it does borrow data from elsewhere.
* fix `DecrementSizeGuard::drop()` only waking one `Waiter` regardless of whether that waiter was already woken
* fix connect-backoff loop giving up the size guard
* don't cut in line to open a new connection
* have tasks waiting on `acquire()` wake periodically to check if there's a connection in the queue
Signed-off-by: Austin Bonander <austin@launchbadge.com>
Fix commit updates the `postgres::connection::describe` module to add full support for domain types. Domain types were previously confused with their category which caused invalid oid resolution.
Fixeslaunchbadge/sqlx#110
It is *much* too easy to misread `x.min(y)` as "`x` should be *at least* `y`" when in fact it means the *exact* opposite, and same with `x.max(y)`. This has bitten us in the gluteus maximus a number of times both in SQLx and in private projects.
Signed-off-by: Austin Bonander <austin@launchbadge.com>
BREAKING CHANGE: some columns in `query!()` et. al. output will change from `T` to `Option<T>`
breakage should be minimal in practice as
these columns will need to have been manually
overridden anyway to avoid runtime errors
Signed-off-by: Austin Bonander <austin@launchbadge.com>