nsertThread :: DBInfo -> MachineId -> ProcessId -> ThreadId -> IO DBInfo
insertThread dbi mid pid tid = do
    let conn       = db_connection dbi
        processKey = (db_processes dbi) M.! (mid,pid)
    threadKey <- head <$> query conn insertThreadQuery (tid, processKey)
    case threadKey of
        Only key -> do
            return $ dbi {
                db_threads   = M.insert (mid,tid) key (db_threads dbi)
                }
        _       -> error "machine insertion failed"

insertThread :: DBInfo -> MachineId -> ProcessId -> ThreadId -> IO DBInfo
insertThread dbi mid pid tid = do
    let conn       = db_connection dbi
        processKey = (db_processes dbi) M.! (mid,pid)
    threadKey <- head <$> query conn insertThreadQuery (tid, processKey)
    case threadKey of
        Only key -> do
            return $ dbi {
                db_threads   = M.insert (mid,tid) key (db_threads dbi)
                }
        _       -> error "machine insertion failed"
insertThread dbi mid pid tid = do
    let conn       = db_connection dbi
        processKey = (db_processes dbi) M.! (mid,pid)
    threadKey <- head <$> query conn insertThreadQuery (tid, processKey)
    case threadKey of
        Only key -> do
            return $ dbi {
                db_threads   = M.insert (mid,tid) key (db_threads dbi)
                }
        _       -> error "machine insertion failed"