Closed robx closed 2 years ago
I've split out the first commit in #23, will file follow-up PRs if/as that one gets merged.
Apologies for the re-review request, meant to request review for #23.
This PR does multiple things at once. Please split.
Did you see #23? Is that what you had in mind?
Sorry, that's because I was repurposing the branch to file a PR against a fork of this repo. Closing.
fork? interesting...
There's no desire to fork, I just want to move forward with this in PostgREST in some way, and the best choice seems to be to build against a (hopefully temporary) fork. Some discussion over here if you're interested: https://github.com/PostgREST/postgrest/issues/2422
Currently, the library copies every input parameter when passing it to libpq via
Data.ByteString.useAsCString
. This PR avoids those copies for the case of binary parameters, by usingData.ByteString.Unsafe.unsafeUseAsCString
.I claim that this is safe because:
ByteString
uses pinned memoryThere are a few preparatory commits to factor out duplicate code to
withParams
, and to avoid a bit of unnecessary work there.Context is https://github.com/PostgREST/postgrest/issues/2261. We see significant decrease of memory use with this change: https://github.com/PostgREST/postgrest/pull/2349