Commit graph

1118 commits

Author SHA1 Message Date
Arne Beer
21590d51f5
Expose connect_options for initialized pools and database on the PgConnectOptions (#1897)
* Expose ConnectOptions

* Expose PoolOptions
2022-06-16 12:25:13 -07:00
Chengxing Yuan
edaf7d0673
Add i16 support for Any Type. (#1895)
* Add i16 support for Any Type.

* fix test.
2022-06-08 16:01:55 -07:00
Keiji, Yoshimi
185c57d936
added test for LoginAck (#1890) 2022-06-08 15:49:34 -07:00
Keiji, Yoshimi
4e9bfb0b2d
added test for mssql protocol Info (#1891) 2022-06-08 15:49:25 -07:00
Keiji, Yoshimi
3cfa734b50
added test for mssql ReturnValue (#1892)
* added test for mssql ReturnValue

* fixed warnings: unused import: `DataType`
2022-06-08 15:49:12 -07:00
Kian-Meng Ang
d52f301a94
Fix typos (#1894)
* Fix typos

* Update CHANGELOG.md

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2022-06-08 14:56:56 -07:00
tyrelr
ed56622526
Improve Sqlite support for sub-queries and CTE's (#1816)
* 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
2022-06-07 14:24:08 -07:00
Ophir LOJKINE
20d61f4271
query_as: don't stop stream after decoding error (#1887)
* 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
2022-06-01 19:18:18 -07:00
smonv
4e3ff3644f
trim [ and ] from host string before used to connect by TcpStream (#1818) 2022-05-31 18:03:26 -07:00
Erik Rhodes
c744cb7f60
Avoid panic when streaming packets are empty (#1861)
* 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>
2022-05-31 17:58:49 -07:00
Oskar Persson
63291d677f
Fix nullability check for inner joins in postgres (#1863) 2022-05-31 17:58:38 -07:00
Scott Wey
5d91ffc81c
add COLLATE_UTF8MB4_0900_AI_CI (#1856) 2022-05-31 17:58:16 -07:00
Michael Freeborn
1b9c40b3c8
fix serde_json usage in macros (#1842) 2022-05-31 16:58:11 -07:00
Michael Freeborn
a110e75b95
make methods pub (#1843) 2022-05-31 16:57:46 -07:00
Charles Samborski
d5f7e4288d
Fix panics on unknown Postgres type oid when decoding (#1855)
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
2022-05-31 16:57:16 -07:00
LovecraftianHorror
a2691b9635
Reuse a cached DB connection instead of always recreating for sqlx-macros (#1782)
* 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`
2022-05-25 18:22:09 -07:00
Dirkjan Ochtman
fa5c436918
Update crc to 3 (#1831) 2022-05-02 12:44:16 -07:00
Paolo Barbolini
ec15f6b30c
Update uuid crate to v1 (#1821) 2022-04-20 12:48:29 -07:00
Paolo Barbolini
b934f82440
Bump remanining dependencies (#1807)
Co-authored-by: Austin Bonander <austin@launchbadge.com>
2022-04-15 14:34:48 -07:00
Paolo Barbolini
fc9c9be5e8
Update to edition 2021 (#1808)
* Update to edition 2021

* Fix running tests
2022-04-15 12:52:00 -07:00
Sebastian Pütz
babd353c2c
Make PgLTree::push infallible and take PgLTreeLabel directly. (#1734)
* 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>
2022-04-14 16:16:00 -07:00
Valentin
c7478dcc66
Update BigDecimal dependency (#1529)
* Update BigDecimal dependency

* rebase onto master

Co-authored-by: Austin Bonander <austin@launchbadge.com>
2022-04-14 16:12:15 -07:00
Atkins
17760d0f83
Move server_version_num from trait to impl (#1384)
* refactor(core): move `fn server_version_num` from `trait PgConnectionInfo` to impl

Signed-off-by: Atkins Chang <atkinschang@gmail.com>

* fix rebase issues

Co-authored-by: Austin Bonander <austin@launchbadge.com>
2022-04-14 16:02:08 -07:00
Paolo Barbolini
17fde443be
Bump ipnetwork to 0.19 (#1426)
* Bump ipnetwork to 0.18

* Bump ipnetwork to 0.19
2022-04-14 15:11:58 -07:00
Paolo Barbolini
ba123e62fa
Update time to 0.3.2 (#1455)
Co-authored-by: Tyler Hill <tyhi@tyhi.rs>
2022-04-14 15:11:46 -07:00
Paolo Barbolini
08296a28a0
Upgrade rustls to 0.20 (#1505)
* Upgrade rustls to 0.20

* Rustls 0.20.1 is out

* Fix merge conflict mistake

* Bump rustls-pemfile to 0.3

* Resync Cargo.lock

* Bump rustls-pemfile to v1

Co-authored-by: Austin Bonander <austin@launchbadge.com>
2022-04-14 15:11:17 -07:00
Paolo Barbolini
a97208c016
postgres: use Oid type everywhere instead of u32 (#1602)
* 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
2022-04-14 15:07:45 -07:00
05storm26
a68957b21f
Make all ConnectOptions clonable (#1612) 2022-04-14 15:07:29 -07:00
05storm26
f328cc15d8
Sqlite chrono::DateTime<FixedOffset> timezone fix (#1618) 2022-04-14 15:06:55 -07:00
Josh Triplett
342d157a50
Update git2 to 0.14 (#1733)
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.
2022-04-14 15:06:37 -07:00
Austin Bonander
2e026cae67
prepare 0.5.12 release (#1800)
* prepare release 0.5.12

* chore: remove mentions of things happening in 0.6

except one mention that should still be happening in 0.6
2022-04-14 14:21:15 -07:00
Austin Bonander
6c7006c4cc
fix(pool): don't leak connections if drop task doesn't run (#1799)
fixes #1396
2022-04-13 16:39:07 -07:00
Sebastien Guillemot
973f3d154d
Fix newline parsing in pgpass (#1791)
* Fix newline parsing in pgpass

* test loading pgpass from a file

Co-authored-by: Austin Bonander <austin@launchbadge.com>
2022-04-13 14:58:34 -07:00
Austin Bonander
a46e370c94
feat: document and expand query builder (#1790)
elaborates on the API introduced in #1780
2022-04-12 13:22:47 -07:00
Paolo Barbolini
ccbbe102b2
Update RustCrypto crates (#1625)
* Update RustCrypto crates

* rsa bump

* rsa dump

* rsa bump

* Bump rsa to 0.6.0-pre crates.io release

* Bump hkdf

* Resync Cargo.lock

* Bump rsa to 0.6.0
2022-04-11 11:24:09 -07:00
crajcan
a470682572
Add Query builder (#1780)
* 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
2022-04-08 13:36:42 -07:00
david-mcgillicuddy-moixa
6efc39f213
Include affected rows in logging even when query is done (#1754)
* fix logging bug

* slight code cleanup

* change to split rows affected and rows returned

* review comments, and small unreachable bug
2022-04-08 12:40:11 -07:00
Jérémie Drouet
0c95fdd19a
feat(migration): add function to undo migrations (#1675)
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>
2022-04-07 16:03:00 -07:00
tyrelr
217dc55062
Fix #1249 Left joins in SQLite can break the query macros (#1789)
* 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
2022-04-07 13:18:37 -07:00
Austin Bonander
f1c635d739
feat(pool): implement close-event notification (#1776)
fix(postgres): integrate pool close-event into `PgListener`

closes #1764
2022-04-05 16:17:35 -07:00
Andrew Whitehead
acb3da8a34
(mysql) silence warnings for unused fields (#1786)
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
2022-04-05 15:00:32 -07:00
Andrew Whitehead
040eb77d95
add FromStr, Copy, PartialEq, Eq impls for sqlite options (#1784)
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
2022-04-05 12:37:53 -07:00
Austin Bonander
f8581386d2
feat(postgres): make extra_float_digits settable (#1774) 2022-04-01 14:51:29 -07:00
Rafael Ávila de Espíndola
d3093d0b70
Update libsqlite3-sys (#1763) 2022-03-28 15:04:49 -07:00
Austin Bonander
e1817f0a9d
feat: convenient wrapper for Postgres advisory locks (#1641) 2022-03-24 17:38:24 -07:00
Vladimir
9d76f7cd9e
Derive clone for mysql and mssql arguments (#1736) 2022-03-24 11:34:07 -07:00
Ivan Petkov
1af26d8350
sqlx-core: impl Type for Cow<str> on Mssql, MySql, and Sqlite (#1757) 2022-03-23 12:31:43 -07:00
Grachev Mikhail
78dc0ad811
docs(query_as): fix link (#1761) 2022-03-23 12:16:44 -07:00
Grachev Mikhail
3b1801b585
Fix typo in TSTZRANGE (#1741) 2022-03-09 17:54:44 -06:00
Dylan DPC
b40a86ceb7
Update Cargo.toml (#1738) 2022-03-09 11:57:37 -06:00
liushuyu
dfd9cf59f1
fix(postgres): fix option passing logic (#1731)
Co-authored-by: Austin Bonander <austin@launchbadge.com>

Co-authored-by: Austin Bonander <austin@launchbadge.com>
2022-03-01 21:29:38 -08:00
Andre B. Reis
99d3220d88
Impl PgHasArrayType for serde_json::{Value,RawValue} (#1722)
* 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
2022-02-23 12:57:48 -08:00
Austin Bonander
eaf41fd092
prepare 0.5.11 release (#1715) 2022-02-18 13:49:06 -08:00
Bastian
dd39e79f8a
Support for lquery (#1710)
* initial lquery version

* share code between ltree/lquery

* more lquery functions

* fix rebase issues

* add version comment

* Update sqlx-core/src/postgres/types/lquery.rs

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>

Co-authored-by: Bastian Schubert <bastian.schubert@crosscard.com>
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2022-02-17 15:06:35 -08:00
05storm26
8bccd53346
Allow converting AnyConnectOptions to a specific ConnectOptions (#1610) 2022-02-17 14:57:48 -08:00
stoically
45854a4246
docs: Acquire examples and alternative (#1687) 2022-02-17 14:55:38 -08:00
Andrew Wheeler(Genusis)
183e620381
Implement From for AnyConnection (#1652)
* Implemented From for AnyConnection to cover the 4 Database type connections to AnyConnection

* formatting
2022-02-16 18:59:32 -08:00
Arttu Liimola
160f345f4f
Fix Option for Any driver. (#1661)
With macro impl_encode_for_option Null values are not added, when creating arguments for the actual driver selected at runtime.
2022-02-15 21:12:02 -08:00
Bastian
6674e8ba96
Basic support for ltree (#1696)
* support ltree

* add default and push to PgLTree

* add more derived for ltree

* fix copy/paste

* Update sqlx-core/src/error.rs

Co-authored-by: Paolo Barbolini <paolo@paolo565.org>

* PR fixes

* ltree with name instead of OID

* custom ltree errors

* add pop ot PgLTree

* do not hide ltree behind feature flag

* bytes() instead of chars()

* apply extend_display suggestion

* add more functions to PgLTree

* fix IntoIter

* resolve PR annotation

* add tests

* remove code from arguments

* fix array

* fix setup isse

* fix(postgres): disable `ltree` tests on Postgres 9.6

Co-authored-by: Bastian Schubert <bastian.schubert@crosscard.com>
Co-authored-by: Paolo Barbolini <paolo@paolo565.org>
Co-authored-by: Austin Bonander <austin@launchbadge.com>
2022-02-15 20:40:03 -08:00
Marco Napetti
2849468e57
Avoid panicking if packet empty (#1667)
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.
2022-02-15 20:11:38 -08:00
Adam Cigánek
347374b94b
SQLite unlock notification (#1658)
* sqlite: add test for concurrent table access (failing)

* sqlite: implement unlock notification
2022-02-15 20:10:36 -08:00
VersBinarii
fd2d26e12d
Fix power calculation when encoding the BigDecimal into NUMERIC (#1692)
* Show failing test

0.002 will be encoded as 0.02

* The power calculation should depend on the offset

of the digits
2022-02-11 12:28:07 -08:00
Daniel Beckwith
d901694ec6
Add target context to Postgres notice logs (#1606)
Adds a `target` field to the Postgres notice logs and filters based on that target, just like how the query logs do it.
2022-01-04 15:37:37 -08:00
Andrew Whitehead
dec0ed1a4d
drop worker shared state in shutdown (#1608)
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
2022-01-04 15:37:16 -08:00
Paolo Barbolini
bcb2d8e604
Remove unused dependencies (#1605) 2022-01-03 16:56:01 -08:00
Austin Bonander
fdbfc5dfc3
Prepare 0.5.10 release (#1603)
* 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
2021-12-29 17:25:49 -08:00
Austin Bonander
63ca2ccc6c
refactor(sqlite): make background thread responsible for all FFI calls (#1551) 2021-12-29 15:23:02 -08:00
liushuyu
b3091b0322
feat(postgres): add an option to specify extra options (#1539)
* 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
2021-12-29 13:10:18 -08:00
Charles Samborski
32f1273565
Fix support for Postgres array of custom types (#1483)
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
2021-12-29 13:05:15 -08:00
Pieter
dee514704f
Postgres: Array enum encoding (#1511)
* Postgres: Add test for array enum

* Allow produces() to override type_info() as per doc

* run cargo fmt
2021-12-29 13:04:42 -08:00
Douman
04109d9323
Reimport Either used in Executor (#1562)
* Reimport Either used in Executor

* Re-import sqlx-core

* Update src/lib.rs

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>

* Apply fmt

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2021-12-29 13:01:16 -08:00
Rob Gilson
f79d321b78
fix(postgres): Match ~/.pgpass password after URL parsing and fix user and database ordering (#1566)
* 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
2021-12-29 13:00:49 -08:00
Paolo Barbolini
fca866d0bc
Update itoa and dirs (#1601) 2021-12-29 11:56:58 -08:00
05storm26
beb2100f29
Make the database kind queryable from AnyConnectionKind and AnyConnection (#1592) 2021-12-28 17:19:26 -08:00
parazyd
d258e8c681
core/sqlite: Add special case for sqlcipher key pragma when connecting. (#1587)
* core/sqlite: Add special case for sqlcipher key pragma when connecting.

* core/sqlite: Move std::fmt::Write import to module level.
2021-12-27 15:33:06 -08:00
Paolo Barbolini
ce572bcee4
Update rsa crate to 0.5 (#1572)
* Update rsa crate to 0.5

* Don't do pem decoding ourselves
2021-12-20 17:58:37 -08:00
Josh Triplett
2e6ab7c3de
Make whoami optional, and only pull it in for postgres (#1571)
sqlx-core uses whoami to provide the fallback for postgres username. If
not building postgres support, omit the dependency on whoami.
2021-12-20 17:54:58 -08:00
Jonas Platte
12d9f54c7d
Rewrite Postgres array type handling (#1385)
… to reduce boilerplate and allow custom types.
2021-11-22 17:17:00 -08:00
nitnelave
5aef7d7801
Add a get_kind method to Pool (#1228) 2021-11-22 17:00:00 -08:00
David Yamnitsky
8299687878
bump libsqlite3-sys to 0.23.1 (#1535) 2021-11-12 14:37:19 -08:00
Akira Hayakawa
a304161b28
Copy API improvement (#1536) (#1537)
* expose PgCopyIn

* downgrade Pool<Posgres> copy_in_raw/out_row to take &self
2021-11-12 14:15:15 -08:00
Kirill Mironov
df2d5c7a1b
Encode/Decode impl for Cow<'_, str> (#1343)
* Encode/Decode impl for Cow<'_, str>

resolves #1214

* --wip-- [skip ci]

* Add Cow decode/encode to other databases and fix build
2021-11-08 18:58:24 -08:00
yuyawk
626dd0db38
fix panic when converting negative chrono::Duration into PgInterval (#1475)
* fix PgInterval convert failure for negative chrono::Duration

* add unit tests for PgInterval

* Fix: remove redundancy because nanosecond overflow implies microsecond overflow
2021-11-08 18:47:57 -08:00
yuyawk
cdb40b1f8e
derive Clone, Copy for AnyKind (#1474) 2021-11-08 18:45:19 -08:00
Austin Bonander
b419bf5298
docs: revise Pool docs in a couple places (#1526) 2021-11-04 18:52:55 -07:00
meh
62b57f021f
fix(postgres): allow rust_decimal::Decimal in PgRange (#1523)
* fix(postgres): allow rust_decimal::Decimal in PgRange

* test(postgres): add tests for BigDecimal and Decimal in ranges
2021-11-03 12:28:39 -07:00
Daniel Imfeld
1efbbcaffa
Reduce indexmap version to 1.6.2 (#1501)
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)
2021-11-02 18:22:49 -07:00
Akira Hayakawa
f1851e7832
Add persistent setter (#1503) (#1508) 2021-11-02 18:08:15 -07:00
Lucille Blumire
4ada6ac7e1
Add support for serialized threading mode to sqlite (#1514)
* Add support for serialized threading mode

* Typos

* Fix build
2021-11-02 18:07:56 -07:00
Austin Bonander
9abe9b3ac5
prepare 0.5.9 hotfix release (#1469) 2021-10-01 15:52:52 -07:00
Austin Bonander
1b5dd6514b
preparing 0.5.8 release (#1466)
* preparing 0.5.8 release

* fix warnings before release
2021-10-01 14:45:25 -07:00
Billy Chan
8561891474
[SQLite] encoding & decoding NaiveTime with correct format (#1459)
* Fix SQLite encoding format

* Update SQLite decoding format

* Update sqlx-core/src/sqlite/types/chrono.rs

* fixup: add `#[rustfmt::skip]`

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
Co-authored-by: Austin Bonander <austin@launchbadge.com>
2021-09-30 19:45:48 -07:00
Austin Bonander
51e45ce3ab
Revert "feat: allow log level customization (#1371)" (#1465)
This reverts commit 719d80038b.
2021-09-30 18:58:42 -07:00
Andrew Whitehead
ba3e373b7e
Shut down statement worker in Sqlite Connection::close (#1453)
* 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>
2021-09-30 18:14:30 -07:00
Paolo Barbolini
c2e04a1f3c
Upgrade hmac to 0.11 (#1443) 2021-09-23 12:05:31 -07:00
Austin Bonander
8b30f3059b
Fix a panic in the worker thread when dropping the connection while SqliteRows still exist (#1450)
* chore(sqlite): add repro for #1419

* fix(sqlite): hold a reference to the connection in `SqliteRow`

fixes #1419
2021-09-22 16:55:22 -07:00
Kohei Suzuki
593364f801
fix(mysql): handle multiple waiting results correctly (#1439)
* test(mysql): add test case for pending rows and dropped transaction

* fix(mysql): handle multiple waiting results correctly
2021-09-22 13:39:56 -07:00
Ghass Mo
a5997a2813
Support custom initial options for sqlite (#1295)
* 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>
2021-09-13 13:48:24 -07:00
Austin Bonander
2307f432eb
fix: run cargo fmt 2021-09-13 13:14:24 -07:00
Montana Low
ec510b37e7
Finish support for Postgres COPY (#1345)
* feat(postgres): WIP implement `COPY FROM/TO STDIN`

Signed-off-by: Austin Bonander <austin@launchbadge.com>

* feat(postgres): WIP implement `COPY FROM/TO STDIN`

Signed-off-by: Austin Bonander <austin@launchbadge.com>

* test and complete support for postgres copy

Co-authored-by: Austin Bonander <austin@launchbadge.com>
2021-09-13 13:03:38 -07:00
David Marcin
687fbf9909
Support the immutable option on SQLite connections (#1289)
Co-authored-by: Austin Bonander <austin@launchbadge.com>
2021-09-10 15:47:30 -07:00
Paolo Barbolini
092f811f62
Fix CIDR[] not being compatible with Vec<IpNetwork> (#1433) 2021-09-10 15:43:04 -07:00
Paolo Barbolini
efd08cc4b3
Reduce futures-util features (#1427)
* Reduce futures-util features

* Remove unused futures crate from sqlx-macros
2021-09-08 12:36:05 -07:00
Elise
719d80038b
feat: allow log level customization (#1371) 2021-08-31 17:51:48 -07:00
Jonas Platte
335eed4545
Add executor trait "aliases" (#1412) 2021-08-31 17:36:27 -07:00
Jonas Platte
d94c081468
Add more debugging info to unresolved type declaration panic (#1416) 2021-08-31 17:35:10 -07:00
Simon Paitrault
135d16a34f
Getting current Handle in Drop (#1395)
Signed-off-by: Freyskeyd <simon.paitrault@gmail.com>
2021-08-30 14:11:49 -07:00
Austin Bonander
3749e0ea37
chore: prepare 0.5.7 (hotfix) release (#1394) 2021-08-20 17:14:42 -07:00
Austin Bonander
0e8ffb564b
fix(postgres): avoid recursively spawning tasks in PgListener::drop() (#1393)
refactor(pool): deprecate `PoolConnection::release()`, provide renamed alts
2021-08-20 16:44:46 -07:00
Austin Bonander
207e6db2ce
chore: bump versions of sqlx-* in dependencies 2021-08-17 12:49:02 -07:00
Austin Bonander
6bb1c716bd
preparing 0.5.6 release (#1382)
* fix(pool): reenable connection reaper

* fix warnings

* chore: bump published crates to 0.5.6

* chore: update CHANGELOG.md for 0.5.6
2021-08-17 12:44:24 -07:00
Altan Özlü
774880d17c
cockroachdb fix for macro (#1386) 2021-08-17 12:20:08 -07:00
Atkins
dd27aa0587
Fix bug for PostgreSQL if the statement has type holes (#1363)
* 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>
2021-08-16 16:50:11 -07:00
Austin Bonander
71388a7ef2
sqlite: fix a couple segfaults (#1351)
* 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>
2021-08-16 14:39:45 -07:00
Atkins
55c603e9e7
build(deps): bump git2 from 0.13.19 to 0.13.20 (#1362)
Signed-off-by: Atkins Chang <atkinschang@gmail.com>
2021-08-07 01:48:10 -07:00
Atkins
9f7205e80f
Fix GitHub Actions and integration test (#1346)
* fix test suite

* rustfmt

* need Row

* test: fix integration test scripts and update the upstream supported databases

Signed-off-by: Atkins Chang <atkinschang@gmail.com>

* ci(actions): update supported databases

Signed-off-by: Atkins Chang <atkinschang@gmail.com>

* ci(actions): use `pg_isready` instead of `sleep` to avoid error cause by database not ready

Signed-off-by: Atkins Chang <atkinschang@gmail.com>

* feat(core): add `trait PgConnectionInfo` for connection parameter status from server

Signed-off-by: Atkins Chang <atkinschang@gmail.com>

* test(postgres): fix integration test for postgres

Signed-off-by: Atkins Chang <atkinschang@gmail.com>

* test(mysql): fix integration tests

Signed-off-by: Atkins Chang <atkinschang@gmail.com>

* ci(actions): test database against the oldest and newest supported versions

Signed-off-by: Atkins Chang <atkinschang@gmail.com>

* docs(core): document `trait PgConnectionInfo`

Signed-off-by: Atkins Chang <atkinschang@gmail.com>

Co-authored-by: Montana Low <montanalow@gmail.com>
2021-07-28 14:00:34 -07:00
Daniel Faust
f0d0dce8e2
Use postgres as maintenance db unless maintaining postgres itself (#1339)
Fixes #1283.
2021-07-23 16:39:25 -07:00
Luca Palmieri
34db44bffd
Mark the original DatabaseError as source. (#1197) 2021-07-23 16:31:49 -07:00
Austin Bonander
a8544fd503
fix(pg_money): handle negative values correctly in PgMoney::from_decimal() (#1334)
closes #1321
2021-07-21 16:29:20 -07:00
Austin Bonander
531740550f
fix(pool): reimplement pool internals with futures-intrusive (#1320) 2021-07-21 16:28:44 -07:00
marshoepial
cb3ff28721
Keep track of column typing in SQLite EXPLAIN parsing (#1323)
* NewRowid, Column opcodes, better pointer handling

* Implement tracking of column typing on sqlite explain parser

* fmt for sqlite column typing for explain parsing

Co-authored-by: marshoepial <marshoepial@gmail.com>
2021-07-21 16:27:47 -07:00
Austin Bonander
8bcac0394f
fix(mysql): implement type traits for chrono::DateTime<Local> (#1335)
closes #1222
2021-07-21 16:27:00 -07:00
nomick
be189bd11e
Support MACADDR in Postgres (#1329) 2021-07-19 16:55:53 -07:00
Akhil Velagapudi
0abbcc510f
Update crc 1.8.1 -> 2.0.0 (#1256) 2021-07-16 15:25:32 -07:00
Ryan Leckey
694a2ac478 release: v0.5.5 2021-05-24 09:34:34 -07:00
Ryan Leckey
5d9c292132 release: v0.5.4 2021-05-22 16:38:54 -07:00
Eamon Caton
b391d4878e Revert webpki version bump to keep compatability with tokio-rustls feature 2021-05-22 11:03:01 -07:00
Ryan Leckey
13f7c7124a release: v0.5.3 2021-05-21 17:27:15 -07:00
Ryan Leckey
2d38332137 fix: bring back accidentally removed methods on the Migrate trait as deprecated 2021-05-21 17:16:22 -07:00
Nathan Roach
db09cb61e5 Adding Any support for Local chrono datetime for MySQL 2021-05-21 16:46:41 -07:00
Guy Lapid
18acba2358 Added any types for binary blobs and chrono NaiveDateTime 2021-05-21 16:46:26 -07:00
Rafael Epplée
0acb0e5eff
Add docs for rename_all attribute for Type derive macro (#1212)
* add missing closing bracket in doctest

* document rename_all attribute for Type derive
2021-05-21 16:12:16 -07:00
Austin Bonander
8f1d8c7e2f
more pool fixes (#1211)
* 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>
2021-05-17 19:24:40 -07:00
Feike Steenbergen
78a94240e6
Skip empty and commented pgpass entries (#1216)
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
2021-05-10 16:18:13 -07:00
link2xt
405474b575
sqlite: add SqliteConnectOptions::shared_cache() (#1177)
This makes it possible to open database in shared cache mode without
having to construct `sqlite://` URL with `?cache=shared` flag.
2021-04-27 18:35:45 -07:00
Josh Triplett
b5928f6e7f Export SqliteAutoVacuum so it can be used 2021-04-27 12:35:58 -07:00
Josh Triplett
d4a7217a56 Support setting sqlite page_size
The page size setting only takes effect if set before doing anything
else to the database.
2021-04-27 12:35:23 -07:00
link2xt
fda55fe3b3 sqlite: export SqliteLockingMode
This makes it possible to `use sqlx::sqlite::SqliteLockingMode`.
2021-04-16 18:25:07 -07:00
Ryan Leckey
f7775f7fde release: 0.5.2 2021-04-15 18:40:46 -07:00
Jonas Platte
73d35e73a6 Remove Self: Type bounds in Encode / Decode implementations 2021-04-15 18:27:13 -07:00
Jonas Platte
81ae756e86 Fix warnings 2021-04-15 18:27:13 -07:00
Ryan Leckey
9e8e334697
chore: add std_rng to rand 2021-04-09 15:48:19 -07:00
Ryan Leckey
633a662752 chore: update dependencies 2021-04-09 00:31:07 -07:00
Alexander Krotov
78656eb469 fix(sqlite): reset the statement when fetch_many() stream is dropped
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()`.
2021-04-09 00:23:17 -07:00
link2xt
5cf1af2d19 fix(sqlite): do not ignore API misuse errors from sqlite3_finalize 2021-04-09 00:21:52 -07:00
link2xt
f488f53916 fix(sqlite): do not cast pointers to i32
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.
2021-04-09 00:21:12 -07:00
argv-minus-one
2123d9de2e Make the bounds on Connection::transaction less strict.
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.
2021-04-09 00:13:51 -07:00
Ryan Leckey
fd828fed14 Merge remote-tracking branch 'demurgos/domain-type-description' 2021-04-08 23:59:25 -07:00
Diggory Blake
a3b73f8e08 Remove all listeners before returning a connection to the pool 2021-04-08 23:54:10 -07:00
Diggory Blake
01bef75cb9 Fix bug when a read on a BufStream is cancelled. 2021-04-08 23:53:45 -07:00
Josh Triplett
c96bcd9f6b Support the sqlite auto_vacuum pragma 2021-04-08 23:52:34 -07:00
Josh Triplett
62e58f5b1c Support the sqlite locking_mode pragma
This allows applications that never use a sqlite database concurrently
to avoid using shared memory for the write-ahead log.
2021-04-08 23:52:34 -07:00
Evgeny Nosov
e4dd1c3a1d Ignore reversing migrations in migrate! macro 2021-04-08 23:50:39 -07:00
Evgeny Nosov
8b866bb23d Fix migrate! macro 2021-04-08 23:50:39 -07:00
Evgeny Nosov
85ff651ba1 Add ignore_missing parameter 2021-04-08 23:50:39 -07:00
Evgeny Nosov
8950332ca3 Rewrite migration algorithm in order to apply also unapplied migrations 2021-04-08 23:50:39 -07:00
Tom Dohrmann
7463cdaf45 rename test to tests
Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>
2021-04-08 23:47:35 -07:00
Tom Dohrmann
47253d5d20 move pgpass functions into seperate submodule 2021-04-08 23:47:35 -07:00
Tom Dohrmann
88ee528f24 prefer PGPASSFILE over default paths 2021-04-08 23:47:35 -07:00
Tom Dohrmann
ea7cc78445 move tests into submodule 2021-04-08 23:47:35 -07:00
Tom Dohrmann
4c28cd5c50 fix test 2021-04-08 23:47:35 -07:00
Tom Dohrmann
ac4a9c3c1d run cargo fmt 2021-04-08 23:47:35 -07:00
Tom Dohrmann
9ccf030248 add support for pgpass files 2021-04-08 23:47:35 -07:00
Austin Bonander
5295ff10a5 fix: pool internals improvements
* 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>
2021-04-06 09:04:20 -07:00
crajcan
469c4ac130
Correct Postgres' Length Limit for Bind Parameters (#1141)
* Bump limit for postgres' bind parameters

* Fix lingering fmt error
2021-03-29 19:39:27 -07:00
Charles Samborski
93b90be9f7 fix(postgres): Add support for domain types description
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.

Fixes launchbadge/sqlx#110
2021-03-16 20:23:03 +01:00
Rich Murphey
edcc91c9f2
replace deprecated compare_and_swap() with compare_exchange() (#1080) 2021-03-03 08:50:12 -08:00
Nathan Roach
d5f9f08c62 Fixing NaiveTime not including SQLite 2021-02-27 01:24:25 -08:00
Nathan Roach
4b5f41eebe Fixing format, removing duplicate NaiveDate 2021-02-27 01:24:25 -08:00
Nathan Roach
9d6c5defd4 Adding derivation of any types for chrono types present in all of the featured sql types at compile time 2021-02-27 01:24:25 -08:00
Jonas Platte
e8f4eebdbe Make re-exports from other crates show up as such
… in `types` and sub-modules.
2021-02-27 01:22:22 -08:00
mareq
111265b5ab doc: Add information on the required structure of the migration scripts 2021-02-27 01:06:17 -08:00
Austin Bonander
0ed524d65c fix(pool): always ping connection on release to see if it's still viable
Signed-off-by: Austin Bonander <austin@launchbadge.com>
2021-02-27 00:56:08 -08:00
Austin Bonander
1a9e0d9a52 ban Ord::{min, max} with Clippy as it's too easy to misread
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>
2021-02-05 13:30:35 -08:00
Ryan Leckey
cbe820760f
release: 0.5.1 2021-02-04 09:16:11 -08:00
Ryan Leckey
efccd6c9b8
chore: update sqlx-rt to 0.3 2021-02-04 09:15:00 -08:00
Ryan Leckey
94d0baeb52
release: 0.5 2021-02-04 06:32:50 -08:00
Ryan Leckey
2fd26b5504
sqlite: remove support for u64
see https://github.com/launchbadge/sqlx/pull/919#discussion_r557106441
2021-02-04 06:17:17 -08:00
wuaoxiang
31abe22e34 fix(sqlite): GROUP BY in query! cause infinite loop at compile time 2021-01-31 16:58:48 -08:00
Jonas Platte
6fea00304e Remove any::AnyType
It was not actually used in a meaningful way.
2021-01-31 16:56:37 -08:00
Jonas Platte
1b217cfac4 Make impl Acquire for &'_ Pool<DB> more general 2021-01-31 16:54:22 -08:00
Jonas Platte
77238108cf Require Acquire::Connection to be Send 2021-01-31 16:54:22 -08:00
Ryan Leckey
df393128f8
style: rustfmt 2021-01-20 22:29:05 -08:00
Austin Bonander
89305873b0
fix(postgres): patch nullable inference in Postgres using EXPLAIN
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>
2021-01-20 22:27:44 -08:00
Austin Bonander
5e452d9e86
fix(sqlite): remove errant println!() in sqlite/explain.rs 2021-01-20 22:26:43 -08:00
Austin Bonander
7c32928ebc
feat(macros): implement query_scalar!() and variants
Signed-off-by: Austin Bonander <austin@launchbadge.com>
2021-01-20 22:23:04 -08:00
Ryan Leckey
b0c430ed18
feat(sqlite): track nullable through left joins 2021-01-20 22:22:26 -08:00
Sho Nakatani
0c0dd6936a feat: Adds Debug, Clone auto-derive to SqliteArguments 2021-01-20 22:15:48 -08:00
William Hammond
25858fc42a Improves error handling in the case of missing type 2021-01-20 22:10:03 -08:00
Ryan Leckey
e03c31adcd
Merge branch 'feature/inline-certificates' of https://github.com/alex-berger/sqlx into alex-berger-feature/inline-certificates 2021-01-20 22:08:26 -08:00
Florian Hübsch
68cf2f9cdb Add constraint method to DatabaseError trait
Override `constraint` method for `PgDatabaseError`.
2021-01-20 22:00:44 -08:00
Ryan Leckey
d5e0f1b92b
refactor: rename DbOutcome to DbQueryResult 2021-01-20 21:57:26 -08:00
Jonas Platte
c5d43db312
Upgrade async runtime dependencies
Co-authored-by: Josh Toft <joshtoft@gmail.com>
Co-authored-by: Philip A Reimer <antreimer@gmail.com>
2021-01-20 21:50:45 -08:00
Ryan Leckey
de4a7decfb
fix(sqlite): i64 -> u64 in type docs 2021-01-20 21:50:45 -08:00
dignifiedquire
1d87b6cc8d
feat: implement unsigned int support for sqlite 2021-01-20 21:50:45 -08:00
Takeru Ohta
a6aef7817b
fix to read just 20 bytes for AuthSwitchRequest data 2021-01-20 21:50:44 -08:00
Jonas Platte
08a76f45ae
Rename DbDone to DbOutcome 2021-01-12 14:45:01 +01:00
Jonas Platte
a1d562f04b
Remove the Done trait 2021-01-12 14:37:44 +01:00
Jonas Platte
e2f7aa2eca Restore support for sqlx(rename) on types, with a deprecation warning 2021-01-12 03:39:10 -08:00
Jonas Platte
fd8b2b7f8a Rename sqlx(rename) attribute to sqlx(type_name) 2021-01-12 03:39:10 -08:00