mysql
mysql copied to clipboard
Add Support for prepared statements
This is definitely a first pass. I am not sure if this is the correct module structure or if the Value
type is too "high level"
Some of the mysql_stmt_* functions don't have wrappers implemented yet but figured it was better to get something out there rather than just leaving it hiding on my computer.
One thing which makes me nervous about this package is the lack of detailed tests. This hasn't been too serious up to now, since when I took over as maintainer, I reckoned that the only changes would be minor bug fixes and updated dependencies. However, if we're going to make changes involving several hundred lines of code, I think we would need to add full tests, both for the existing functionality (to make sure it isn't disturbed by the change) and for the new.
Can I ask whether you have looked at mysql-haskell? It supports prepared statements, and doesn't have the thread-safety problems of the C library. It's probably a better way to go in the long run, though I haven't yet had an opportunity to check out persistent-mysql-haskell
. I'd be interested in any comments you have.
I Am definitely on board with the needing more tests. I was a bad and didn't save all the different things I tested as I was writing the code.
I have not had a look at mysql-haskell
but I am wary about re implementing the wire format separate from the rest of the world. What thread-safety issues does the C library have and how are we sure that the haskell reimplementation doesn't have them?
On the threading issues, these articles are both a little old, and I haven't checked whether more recent versions of the standard C client library change anything: https://ro-che.info/articles/2015-04-17-safe-concurrent-mysql-haskell and https://www.yesodweb.com/blog/2016/11/use-mysql-safely-in-yesod
I get the point about re-implementations vs. the "standard" library. There do seem to be a number of re-implementations, though (eg the node mysql module just to choose one at random).