Commits

Bryan O'Sullivan  committed d55e392

setCharacterSet

  • Participants
  • Parent commits b6d490d

Comments (0)

Files changed (2)

File Database/MySQL.hs

     , ping
     , changeUser
     , selectDB
+    , setCharacterSet
     -- ** Connection information
     , threadId
     , serverInfo
     , hostInfo
     , protocolInfo
-    , characterSetName
+    , characterSet
     , sslCipher
     , serverStatus
     -- * Querying
 protocolInfo conn = withConn conn $ \ptr ->
                     fromIntegral <$> mysql_get_proto_info ptr
 
-characterSetName :: Connection -> IO String
-characterSetName conn = withConn conn $ \ptr ->
+setCharacterSet :: Connection -> String -> IO ()
+setCharacterSet conn cs =
+  withCString cs $ \ccs ->
+    withConn conn $ \ptr ->
+        mysql_set_character_set ptr ccs >>= check "setCharacterSet" ptr
+
+characterSet :: Connection -> IO String
+characterSet conn = withConn conn $ \ptr ->
                         peekCString =<< mysql_character_set_name ptr
 
 sslCipher :: Connection -> IO (Maybe String)

File Database/MySQL/C.hsc

     , mysql_autocommit
     , mysql_change_user
     , mysql_select_db
+    , mysql_set_character_set
     -- ** Connection information
     , mysql_thread_id
     , mysql_get_server_info
 foreign import ccall safe mysql_character_set_name
     :: Ptr MYSQL -> IO CString
 
+foreign import ccall safe mysql_set_character_set
+    :: Ptr MYSQL -> CString -> IO CInt
+
 foreign import ccall safe mysql_get_ssl_cipher
     :: Ptr MYSQL -> IO CString