From: <kr_...@us...> - 2004-11-06 08:28:31
|
Update of /cvsroot/htoolkit/HSQL/src/HSQL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30320/src/HSQL Modified Files: MySQL.hsc Log Message: Partial support for multiple results Index: MySQL.hsc =================================================================== RCS file: /cvsroot/htoolkit/HSQL/src/HSQL/MySQL.hsc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** MySQL.hsc 11 Apr 2004 10:06:43 -0000 1.6 --- MySQL.hsc 6 Nov 2004 08:26:15 -0000 1.7 *************** *** 46,54 **** foreign import #{CALLCONV} "HsMySQL.h mysql_init" mysql_init :: MYSQL -> IO MYSQL ! foreign import #{CALLCONV} "HsMySQL.h mysql_real_connect" mysql_real_connect :: MYSQL -> CString -> CString -> CString -> CString -> Int -> CString -> Int -> IO MYSQL foreign import #{CALLCONV} "HsMySQL.h mysql_close" mysql_close :: MYSQL -> IO () ! foreign import #{CALLCONV} "HsMySQL.h mysql_errno" mysql_errno :: MYSQL -> IO Int foreign import #{CALLCONV} "HsMySQL.h mysql_error" mysql_error :: MYSQL -> IO CString ! foreign import #{CALLCONV} "HsMySQL.h mysql_query" mysql_query :: MYSQL -> CString -> IO Int foreign import #{CALLCONV} "HsMySQL.h mysql_use_result" mysql_use_result :: MYSQL -> IO MYSQL_RES foreign import #{CALLCONV} "HsMySQL.h mysql_fetch_field" mysql_fetch_field :: MYSQL_RES -> IO MYSQL_FIELD --- 46,54 ---- foreign import #{CALLCONV} "HsMySQL.h mysql_init" mysql_init :: MYSQL -> IO MYSQL ! foreign import #{CALLCONV} "HsMySQL.h mysql_real_connect" mysql_real_connect :: MYSQL -> CString -> CString -> CString -> CString -> CInt -> CString -> CInt -> IO MYSQL foreign import #{CALLCONV} "HsMySQL.h mysql_close" mysql_close :: MYSQL -> IO () ! foreign import #{CALLCONV} "HsMySQL.h mysql_errno" mysql_errno :: MYSQL -> IO CInt foreign import #{CALLCONV} "HsMySQL.h mysql_error" mysql_error :: MYSQL -> IO CString ! foreign import #{CALLCONV} "HsMySQL.h mysql_query" mysql_query :: MYSQL -> CString -> IO CInt foreign import #{CALLCONV} "HsMySQL.h mysql_use_result" mysql_use_result :: MYSQL -> IO MYSQL_RES foreign import #{CALLCONV} "HsMySQL.h mysql_fetch_field" mysql_fetch_field :: MYSQL_RES -> IO MYSQL_FIELD *************** *** 58,61 **** --- 58,64 ---- foreign import #{CALLCONV} "HsMySQL.h mysql_list_tables" mysql_list_tables :: MYSQL -> CString -> IO MYSQL_RES foreign import #{CALLCONV} "HsMySQL.h mysql_list_fields" mysql_list_fields :: MYSQL -> CString -> CString -> IO MYSQL_RES + foreign import #{CALLCONV} "HsMySQL.h mysql_next_result" mysql_next_result :: MYSQL -> IO CInt + + ----------------------------------------------------------------------------------------- *************** *** 67,71 **** errno <- mysql_errno pMYSQL errMsg <- mysql_error pMYSQL >>= peekCString ! throwDyn (SqlError "" errno errMsg) ----------------------------------------------------------------------------------------- --- 70,74 ---- errno <- mysql_errno pMYSQL errMsg <- mysql_error pMYSQL >>= peekCString ! throwDyn (SqlError "" (fromIntegral errno) errMsg) ----------------------------------------------------------------------------------------- *************** *** 85,89 **** pUser <- newCString user pAuthentication <- newCString authentication ! res <- mysql_real_connect pMYSQL pServer pUser pAuthentication pDatabase 0 nullPtr 0 free pServer free pDatabase --- 88,92 ---- pUser <- newCString user pAuthentication <- newCString authentication ! res <- mysql_real_connect pMYSQL pServer pUser pAuthentication pDatabase 0 nullPtr (#const CLIENT_MULTI_STATEMENTS) free pServer free pDatabase *************** *** 176,181 **** res <- withCString query (mysql_query pMYSQL) when (res /= 0) (handleSqlError pMYSQL) ! pRes <- mysql_use_result pMYSQL withStatement conn pMYSQL pRes fetch :: MYSQL_RES -> MVar (MYSQL_ROW, MYSQL_LENGTHS) -> IO Bool --- 179,195 ---- res <- withCString query (mysql_query pMYSQL) when (res /= 0) (handleSqlError pMYSQL) ! pRes <- getFirstResult pMYSQL withStatement conn pMYSQL pRes + where + getFirstResult :: MYSQL -> IO MYSQL_RES + getFirstResult pMYSQL = do + pRes <- mysql_use_result pMYSQL + if pRes == nullPtr + then do + res <- mysql_next_result pMYSQL + if res == 0 + then getFirstResult pMYSQL + else return nullPtr + else return pRes fetch :: MYSQL_RES -> MVar (MYSQL_ROW, MYSQL_LENGTHS) -> IO Bool |