Commits

Bryan O'Sullivan  committed b6d490d

selectDB

  • Participants
  • Parent commits a23a646

Comments (0)

Files changed (2)

File Database/MySQL.hs

     , autocommit
     , ping
     , changeUser
+    , selectDB
     -- ** Connection information
     , threadId
     , serverInfo
       withRTSSignalsBlocked (mysql_change_user ptr cuser cpass cdb) >>=
       check "changeUser" ptr
 
+selectDB :: Connection -> String -> IO ()
+selectDB conn db = 
+  withCString db $ \cdb ->
+    withConn conn $ \ptr ->
+      withRTSSignalsBlocked (mysql_select_db ptr cdb) >>= check "selectDB" ptr
+
 query :: Connection -> ByteString -> IO ()
 query conn q = withConn conn $ \ptr ->
   unsafeUseAsCStringLen q $ \(p,l) ->

File Database/MySQL/C.hsc

     , mysql_ping
     , mysql_autocommit
     , mysql_change_user
+    , mysql_select_db
     -- ** Connection information
     , mysql_thread_id
     , mysql_get_server_info
     -> CString                  -- ^ database
     -> IO MyBool
 
+foreign import ccall unsafe mysql_select_db
+    :: Ptr MYSQL
+    -> CString
+    -> IO CInt
+
 foreign import ccall safe mysql_get_server_info
     :: Ptr MYSQL -> IO CString