Add Eq, Show instances, use safe foreign imports, and add utility module #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note: This is my first time doing a pull request.
These commits do essentially three things:
Add
Eq
,Show
instances for enumeration typesUse safe for all foreign imports. Safe calls are more expensive, but not terribly so. With
-threaded
, the foreign call overhead is increased by a factor of almost two. If I'm not mistaken, a safe foreign call does not require spawning a new thread; it just needs to hold the current OS thread hostage until the foreign call is complete.Some foreign imports definitely need to be marked safe. For example, if the connection to the server hangs, calls such as PQexec and PQcancel can cause the entire RTS to hang if they are marked unsafe. Other foreign imports appear trivial, but do sneaky stuff. PQgetvalue should be a simple array access, but if the row and column are out of bounds, it will invoke error handling code.
It's better to use safe by default, and only use unsafe when there is clear evidence of a performance bottleneck.
Added
Database.PQ.Utils
, a utility module that provides exception-based error handling and convenient conversion to/from SQL values. I suppose this functionality could be provided in a separate package (e.g.libpq-extra
), but I don't think it adds too much in the way of dependencies.The first three commits are tweaks that I would really like to be applied. The last three commits introduce a utility module that could just as well be a package of its own.
I did not change the version number. However, per the Hackage version number policy, I think A.B needs to be incremented because of the new instances. I suppose the new version would be 0.5.0 .