-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Implement a diesel connection based on the pure rust postgres crate #2257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit adds a second connection implementation for postgresql, based on the pure rust postgres crate. This allows us to remove the dependency on libpq in certain cases, by providing a separate feature for using a the pure rust implementation for example. Maybe this also simplifies cross platform support for a async postgres connection?
|
Another benefit: Using a pure rust postgres implementation greatly decreases the complexity in building a statically linked binary that uses diesel as a dependency. Currently you have to recompile openssl, libz, and libpq using musl and configured for static linking, which is quite the journey. With a pure rust postgres impl it becomes just running |
(The derive places a bound on the new type parameter, that is not needed)
…ture/pure_postgres
0483629 to
98e4572
Compare
98e4572 to
9a5a6ec
Compare
|
I haven't had a chance to review this in depth yet, but rather than shipping both the libpq backend and the postgres backend, which requires both impls to co-exist (which in turn requires breaking changes to things like |
|
@sgrif Yeah, a feature gate is also a must if my previously described benefits with regards to static builds are to be realized. |
|
Sure, it shouldn't be to hard to put that behind a feature flag. The harder part is to discuss how we would like to have those features be organized? To minimize breaking stuff probably something like:
That should be the only breaking change with the current implementation, all other changes ( Another thing that could be useful: We could change the implementation of |
|
If we ship it I would definitely want |
This is supposedly marked as unstable, as we want to experiment a bit with this before actually committing into supporting this.
* Allow to construct a connection directly from a existing `postgres::Client` (Probably usefull if someone want's to have special configurations for example ssl) * Allow to access the inner client * Add some documentation
|
Wanting to provide some real world feedback, I've been trying to get this running against our code base by Is the code knowingly in a state where it doesn't really work, or am I probably doing something wrong? |
|
The code is at least in a state where it compiles and passes the test-suite. Without knowing the exact error messages it's a bit hard to tell what's exactly wrong. I would guess that you need to also |
|
|
|
Okay, that took a bit due to a vacation, but I've got our code base up and running with the Rust based PostgreSQL connection, and it's looking good so far. No discernible difference in performance, but a nice cleanup of our release build flow. |
| quickcheck = "0.4" | ||
|
|
||
| [features] | ||
| default = ["with-deprecated", "32-column-tables"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to remove 32-column-tables from default? It bit me in the behind while porting to the new system as the error message when lacking it isn't really that great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's only a left over artefact from local development. I tend to disable the 32-column-tables feature, because this reduces the time needed to compile of diesel quite significantly.
(But yes, this should be fixed before merging)
|
Is there any progress here? This is a killer feature imo |
|
@jamessewell Asking for updates on a stalled pull request won't magically make this feature appear, so please don't do this.
|
|
Closed as this is currently not planed as part of diesel. I encourage interested users to publish such a connection implementation as third party crate for now. After such a crate reaches a stable state we can talk about upstreaming parts of that work into diesel. |
This commit adds a second connection implementation for postgresql,
based on the pure rust postgres crate. This allows us to remove the
dependency on libpq in certain cases, by providing a separate feature
for using a the pure rust implementation for example. Maybe this also
simplifies cross platform support for a async postgres connection?
Test suite is passing for the new connection implementation if I change diesel-tests to use this one instead of the old
PgConnectionimplementation.I've done a small unscientific benchmark with those two implementations. The code is here. Results are here. (Take them with a grain of salt, just run them once without actual complicated benchmark setup). From a coarse look it seems like the pure rust implementation is minimally slower the the native libpq version, for the given benchmarks. (Or it's just noise?)
Open questions: