[Haskell-cafe] Odd HDBC connection bug

William Shackleton w.shackleton at gmail.com
Sat Jun 16 01:32:06 CEST 2012


I'm having issues with HDBC when connecting to a remote MySQL server -
certain queries cause the DB connection to be lost. The following program
demonstrates this:

import Database.HDBC
import Database.HDBC.ODBC
main = do
        conn <- connectODBC "DSN=owlro"
        putStrLn "Connected"
        quickQuery' conn "SELECT time, power FROM Power LIMIT 100;" []
        putStrLn "Finished query 1"
        quickQuery' conn "SELECT time, power FROM Power ORDER BY time;" []
        putStrLn "Finished query 2"
        disconnect conn

The DSN points to a remote 32-bit Ubuntu 12.04 Server. The connection and
queries work using mysql and isql on the command line, and the table in
question contains about 1.3 million rows and only the columns id, time,

When I compile and run this on a 64-bit Ubuntu 12.04 PC using HDBC-
and HDBC-odbc- using GHC, I get the following (unwanted) output:
$ ghc Test.hs
$ ./Test
Finished query 1
Test: SqlError {seState = "[\"08S01\"]", seNativeError = -1, seErrorMsg =
"execute execute: [\"2013: [MySQL][ODBC 5.1
Driver][mysqld-5.5.24-0ubuntu0.12.04.1]Lost connection to MySQL server
during query\"]"}

This program finishes (and fails) in less than half a second.

When I run it using runhaskell however, the slow second query completes:
$ runhaskell Test.hs
Finished query 1
Finished query 2

I get the same result from ghci; this method takes about 10 seconds as

Basically, simple (short) queries complete, yet long ones crash the
connection. I also noticed similar results with HDBC-mysql.
Any ideas on what is causing this?
Will Shackleton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120616/f621f46c/attachment-0001.htm>

More information about the Haskell-Cafe mailing list