Commits

Bryan O'Sullivan committed d55e392

setCharacterSet

Comments (0)

Files changed (2)

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)

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
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.