mysql-0.1.0.0: A low-level MySQL client library.

Portabilityportable
Stabilityexperimental
MaintainerBryan O'Sullivan <bos@mailrank.com>

Database.MySQL.Base.C

Contents

Description

Direct bindings to the C mysqlclient API.

Synopsis

Connection management

mysql_initSource

Arguments

:: Ptr MYSQL

should usually be nullPtr

-> IO (Ptr MYSQL) 

mysql_ssl_setSource

Arguments

:: Ptr MYSQL 
-> CString

Key.

-> CString

Cert.

-> CString

CA.

-> CString

CA path.

-> CString

Ciphers.

-> IO MyBool 

mysql_real_connectSource

Arguments

:: Ptr MYSQL

Context (from mysql_init).

-> CString

Host name.

-> CString

User name.

-> CString

Password.

-> CString

Database.

-> CInt

Port.

-> CString

Unix socket.

-> CULong

Flags.

-> IO (Ptr MYSQL) 

mysql_change_userSource

Arguments

:: Ptr MYSQL 
-> CString

user

-> CString

password

-> CString

database

-> IO MyBool 

Connection information

Querying

Escaping

Results

Working with results

Multiple results

Transactions

General information

Error handling

Support functions

withRTSSignalsBlocked :: IO a -> IO aSource

Execute an IO action with signals used by GHC's runtime signals blocked. The mysqlclient C library does not correctly restart system calls if they are interrupted by signals, so many MySQL API calls can unexpectedly fail when called from a Haskell application. This is most likely to occur if you are linking against GHC's threaded runtime (using the -threaded option).

This function blocks SIGALRM and SIGVTALRM, runs your action, then unblocks those signals. If you have a series of HDBC calls that may block for a period of time, it may be wise to wrap them in this action. Blocking and unblocking signals is cheap, but not free.

Here is an example of an exception that could be avoided by temporarily blocking GHC's runtime signals:

  SqlError {
    seState = "", 
    seNativeError = 2003, 
    seErrorMsg = "Can't connect to MySQL server on 'localhost' (4)"
  }