-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | A low-level MySQL client library.
--   
--   A low-level client library for the MySQL database, implemented as
--   bindings to the C <tt>mysqlclient</tt> API.
--   
--   <i>Important licensing note</i>: This library is BSD-licensed under
--   the terms of the MySQL FOSS License Exception
--   <a>http://www.mysql.com/about/legal/licensing/foss-exception/</a>.
--   
--   Since this library links against the GPL-licensed <tt>mysqlclient</tt>
--   library, a non-open-source application that uses it <i>may</i> be
--   subject to the terms of the GPL.
@package mysql
@version 0.1.7


-- | Types for working with the direct bindings to the C
--   <tt>mysqlclient</tt> API.
module Database.MySQL.Base.Types

-- | Column types supported by MySQL.
data Type
Decimal :: Type
Tiny :: Type
Short :: Type
Long :: Type
Float :: Type
Double :: Type
Null :: Type
Timestamp :: Type
LongLong :: Type
Int24 :: Type
Date :: Type
Time :: Type
DateTime :: Type
Year :: Type
NewDate :: Type
VarChar :: Type
Bit :: Type
NewDecimal :: Type
Enum :: Type
Set :: Type
TinyBlob :: Type
MediumBlob :: Type
LongBlob :: Type
Blob :: Type
VarString :: Type
String :: Type
Geometry :: Type
Json :: Type
type Seconds = Word
data Protocol
TCP :: Protocol
Socket :: Protocol
Pipe :: Protocol
Memory :: Protocol
data Option
ConnectTimeout :: Seconds -> Option
Compress :: Option
NamedPipe :: Option
InitCommand :: ByteString -> Option
ReadDefaultFile :: FilePath -> Option
ReadDefaultGroup :: ByteString -> Option
CharsetDir :: FilePath -> Option
CharsetName :: String -> Option
LocalInFile :: Bool -> Option
Protocol :: Protocol -> Option
SharedMemoryBaseName :: ByteString -> Option
ReadTimeout :: Seconds -> Option
WriteTimeout :: Seconds -> Option
UseRemoteConnection :: Option
UseEmbeddedConnection :: Option
GuessConnection :: Option
ClientIP :: ByteString -> Option
SecureAuth :: Bool -> Option
ReportDataTruncation :: Bool -> Option
Reconnect :: Bool -> Option
SSLVerifyServerCert :: Bool -> Option
FoundRows :: Option
IgnoreSIGPIPE :: Option
IgnoreSpace :: Option
Interactive :: Option
LocalFiles :: Option
MultiResults :: Option
MultiStatements :: Option
NoSchema :: Option

-- | A description of a field (column) of a table.
data Field
Field :: ByteString -> ByteString -> ByteString -> ByteString -> ByteString -> ByteString -> Maybe ByteString -> Word -> Word -> FieldFlags -> Word -> Word -> Type -> Field

-- | Name of column.
[fieldName] :: Field -> ByteString

-- | Original column name, if an alias.
[fieldOrigName] :: Field -> ByteString

-- | Table of column, if column was a field.
[fieldTable] :: Field -> ByteString

-- | Original table name, if table was an alias.
[fieldOrigTable] :: Field -> ByteString

-- | Database for table.
[fieldDB] :: Field -> ByteString

-- | Catalog for table.
[fieldCatalog] :: Field -> ByteString

-- | Default value.
[fieldDefault] :: Field -> Maybe ByteString

-- | Width of column (create length).
[fieldLength] :: Field -> Word

-- | Maximum width for selected set.
[fieldMaxLength] :: Field -> Word

-- | Div flags.
[fieldFlags] :: Field -> FieldFlags

-- | Number of decimals in field.
[fieldDecimals] :: Field -> Word

-- | Character set number.
[fieldCharSet] :: Field -> Word
[fieldType] :: Field -> Type
type FieldFlag = FieldFlags
data FieldFlags
data MYSQL
data MYSQL_RES
type MYSQL_ROW = Ptr (Ptr CChar)
data MYSQL_ROWS
type MYSQL_ROW_OFFSET = Ptr MYSQL_ROWS
type MyBool = CChar
hasAllFlags :: FieldFlags -> FieldFlags -> Bool
flagNotNull :: FieldFlag
flagPrimaryKey :: FieldFlag
flagUniqueKey :: FieldFlag
flagMultipleKey :: FieldFlag
flagUnsigned :: FieldFlag
flagZeroFill :: FieldFlag
flagBinary :: FieldFlag
flagAutoIncrement :: FieldFlag
flagNumeric :: FieldFlag
flagNoDefaultValue :: FieldFlag
toConnectFlag :: Option -> CULong
instance GHC.Show.Show Database.MySQL.Base.Types.Option
instance GHC.Read.Read Database.MySQL.Base.Types.Option
instance GHC.Classes.Eq Database.MySQL.Base.Types.Option
instance GHC.Enum.Enum Database.MySQL.Base.Types.Protocol
instance GHC.Show.Show Database.MySQL.Base.Types.Protocol
instance GHC.Read.Read Database.MySQL.Base.Types.Protocol
instance GHC.Classes.Eq Database.MySQL.Base.Types.Protocol
instance GHC.Show.Show Database.MySQL.Base.Types.Field
instance GHC.Classes.Eq Database.MySQL.Base.Types.Field
instance GHC.Classes.Eq Database.MySQL.Base.Types.FieldFlags
instance GHC.Show.Show Database.MySQL.Base.Types.Type
instance GHC.Classes.Eq Database.MySQL.Base.Types.Type
instance GHC.Enum.Enum Database.MySQL.Base.Types.Type
instance Foreign.Storable.Storable Database.MySQL.Base.Types.Field
instance GHC.Show.Show Database.MySQL.Base.Types.FieldFlags
instance GHC.Base.Semigroup Database.MySQL.Base.Types.FieldFlags
instance GHC.Base.Monoid Database.MySQL.Base.Types.FieldFlags


-- | Direct bindings to the C <tt>mysqlclient</tt> API.
module Database.MySQL.Base.C
mysql_init :: Ptr MYSQL -> IO (Ptr MYSQL)
mysql_options :: Ptr MYSQL -> Option -> IO CInt
mysql_ssl_set :: Ptr MYSQL -> CString -> CString -> CString -> CString -> CString -> IO MyBool
mysql_real_connect :: Ptr MYSQL -> CString -> CString -> CString -> CString -> CInt -> CString -> CULong -> IO (Ptr MYSQL)
mysql_close :: Ptr MYSQL -> IO ()
mysql_ping :: Ptr MYSQL -> IO CInt
mysql_autocommit :: Ptr MYSQL -> MyBool -> IO MyBool
mysql_change_user :: Ptr MYSQL -> CString -> CString -> CString -> IO MyBool
mysql_select_db :: Ptr MYSQL -> CString -> IO CInt
mysql_set_character_set :: Ptr MYSQL -> CString -> IO CInt
mysql_thread_id :: Ptr MYSQL -> IO CULong
mysql_get_server_info :: Ptr MYSQL -> IO CString
mysql_get_server_version :: Ptr MYSQL -> IO CULong
mysql_get_host_info :: Ptr MYSQL -> IO CString
mysql_get_proto_info :: Ptr MYSQL -> IO CUInt
mysql_character_set_name :: Ptr MYSQL -> IO CString
mysql_get_ssl_cipher :: Ptr MYSQL -> IO CString
mysql_stat :: Ptr MYSQL -> IO CString
mysql_real_query :: Ptr MYSQL -> CString -> CULong -> IO CInt
mysql_insert_id :: Ptr MYSQL -> IO CULLong
mysql_real_escape_string :: Ptr MYSQL -> CString -> CString -> CULong -> IO CULong
mysql_field_count :: Ptr MYSQL -> IO CUInt
mysql_affected_rows :: Ptr MYSQL -> IO CULLong
mysql_store_result :: Ptr MYSQL -> IO (Ptr MYSQL_RES)
mysql_use_result :: Ptr MYSQL -> IO (Ptr MYSQL_RES)
mysql_fetch_lengths :: Ptr MYSQL_RES -> IO (Ptr CULong)
mysql_fetch_lengths_nonblock :: Ptr MYSQL_RES -> IO (Ptr CULong)
mysql_fetch_row :: Ptr MYSQL_RES -> IO MYSQL_ROW
mysql_fetch_row_nonblock :: Ptr MYSQL_RES -> IO MYSQL_ROW
mysql_free_result :: Ptr MYSQL_RES -> IO ()
mysql_free_result_nonblock :: Ptr MYSQL_RES -> IO ()
mysql_fetch_fields :: Ptr MYSQL_RES -> IO (Ptr Field)
mysql_fetch_fields_nonblock :: Ptr MYSQL_RES -> IO (Ptr Field)
mysql_data_seek :: Ptr MYSQL_RES -> CULLong -> IO ()
mysql_row_seek :: Ptr MYSQL_RES -> MYSQL_ROW_OFFSET -> IO MYSQL_ROW_OFFSET
mysql_row_tell :: Ptr MYSQL_RES -> IO MYSQL_ROW_OFFSET
mysql_next_result :: Ptr MYSQL -> IO CInt
mysql_commit :: Ptr MYSQL -> IO MyBool
mysql_rollback :: Ptr MYSQL -> IO MyBool
mysql_get_client_info :: CString
mysql_get_client_version :: CULong
mysql_errno :: Ptr MYSQL -> IO CInt
mysql_error :: Ptr MYSQL -> IO CString
mysql_library_init :: CInt -> Ptr (Ptr Char) -> Ptr (Ptr Char) -> IO CInt
mysql_thread_init :: IO MyBool
mysql_thread_end :: IO ()


-- | A low-level client library for the MySQL database, implemented as
--   bindings to the C <tt>mysqlclient</tt> API.
--   
--   The C library is thread-safe, but uses thread-local state. Therefore,
--   if these bindings are used in a multi-threaded program, "bound"
--   threads should be used (see <a>Control.Concurrent</a>). In addition,
--   explicit calls to <a>initLibrary</a>, and possibly <a>initThread</a>
--   and <a>endThread</a> may be needed in a multi-threaded program.
module Database.MySQL.Base
data ConnectInfo
ConnectInfo :: String -> Word16 -> String -> String -> String -> [Option] -> FilePath -> Maybe SSLInfo -> ConnectInfo
[connectHost] :: ConnectInfo -> String
[connectPort] :: ConnectInfo -> Word16
[connectUser] :: ConnectInfo -> String
[connectPassword] :: ConnectInfo -> String
[connectDatabase] :: ConnectInfo -> String
[connectOptions] :: ConnectInfo -> [Option]
[connectPath] :: ConnectInfo -> FilePath
[connectSSL] :: ConnectInfo -> Maybe SSLInfo
data SSLInfo
SSLInfo :: FilePath -> FilePath -> FilePath -> FilePath -> String -> SSLInfo
[sslKey] :: SSLInfo -> FilePath
[sslCert] :: SSLInfo -> FilePath
[sslCA] :: SSLInfo -> FilePath
[sslCAPath] :: SSLInfo -> FilePath

-- | Comma-separated list of cipher names.
[sslCiphers] :: SSLInfo -> String
type Seconds = Word
data Protocol
TCP :: Protocol
Socket :: Protocol
Pipe :: Protocol
Memory :: Protocol
data Option
ConnectTimeout :: Seconds -> Option
Compress :: Option
NamedPipe :: Option
InitCommand :: ByteString -> Option
ReadDefaultFile :: FilePath -> Option
ReadDefaultGroup :: ByteString -> Option
CharsetDir :: FilePath -> Option
CharsetName :: String -> Option
LocalInFile :: Bool -> Option
Protocol :: Protocol -> Option
SharedMemoryBaseName :: ByteString -> Option
ReadTimeout :: Seconds -> Option
WriteTimeout :: Seconds -> Option
UseRemoteConnection :: Option
UseEmbeddedConnection :: Option
GuessConnection :: Option
ClientIP :: ByteString -> Option
SecureAuth :: Bool -> Option
ReportDataTruncation :: Bool -> Option
Reconnect :: Bool -> Option
SSLVerifyServerCert :: Bool -> Option
FoundRows :: Option
IgnoreSIGPIPE :: Option
IgnoreSpace :: Option
Interactive :: Option
LocalFiles :: Option
MultiResults :: Option
MultiStatements :: Option
NoSchema :: Option

-- | Default information for setting up a connection.
--   
--   Defaults are as follows:
--   
--   <ul>
--   <li>Server on <tt>localhost</tt></li>
--   <li>User <tt>root</tt></li>
--   <li>No password</li>
--   <li>Database <tt>test</tt></li>
--   <li>Character set <tt>utf8</tt></li>
--   </ul>
--   
--   Use as in the following example:
--   
--   <pre>
--   connect defaultConnectInfo { connectHost = "db.example.com" }
--   </pre>
defaultConnectInfo :: ConnectInfo

-- | Default (empty) information for setting up an SSL connection.
defaultSSLInfo :: SSLInfo

-- | Connection to a MySQL database.
data Connection

-- | Result of a database query.
data Result

-- | Column types supported by MySQL.
data Type
Decimal :: Type
Tiny :: Type
Short :: Type
Long :: Type
Float :: Type
Double :: Type
Null :: Type
Timestamp :: Type
LongLong :: Type
Int24 :: Type
Date :: Type
Time :: Type
DateTime :: Type
Year :: Type
NewDate :: Type
VarChar :: Type
Bit :: Type
NewDecimal :: Type
Enum :: Type
Set :: Type
TinyBlob :: Type
MediumBlob :: Type
LongBlob :: Type
Blob :: Type
VarString :: Type
String :: Type
Geometry :: Type
Json :: Type

-- | A row cursor, used by <a>rowSeek</a> and <a>rowTell</a>.
data Row

-- | The constructors of <tt>MySQLError</tt> are not currently exported,
--   but they have a consistent set of field names which are exported.
--   These fields are:
--   
--   <pre>
--   errFunction :: String
--   errNumber   :: Int
--   errMessage  :: String
--   </pre>
data MySQLError

-- | Connect to a database.
connect :: ConnectInfo -> IO Connection

-- | Close a connection, and mark any outstanding <a>Result</a> as invalid.
close :: Connection -> IO ()

-- | Turn autocommit on or off.
--   
--   By default, MySQL runs with autocommit mode enabled. In this mode, as
--   soon as you modify a table, MySQL stores your modification
--   permanently.
autocommit :: Connection -> Bool -> IO ()
ping :: Connection -> IO ()
changeUser :: Connection -> String -> String -> Maybe String -> IO ()
selectDB :: Connection -> String -> IO ()
setCharacterSet :: Connection -> String -> IO ()
threadId :: Connection -> IO Word
serverInfo :: Connection -> IO String
hostInfo :: Connection -> IO String
protocolInfo :: Connection -> IO Word
characterSet :: Connection -> IO String
sslCipher :: Connection -> IO (Maybe String)
serverStatus :: Connection -> IO String
query :: Connection -> ByteString -> IO ()

-- | Return the value generated for an <tt>AUTO_INCREMENT</tt> column by
--   the previous <tt>INSERT</tt> or <tt>UPDATE</tt> statement.
--   
--   See <a>http://dev.mysql.com/doc/refman/5.5/en/mysql-insert-id.html</a>
insertID :: Connection -> IO Word64
escape :: Connection -> ByteString -> IO ByteString

-- | Return the number of fields (columns) in a result.
--   
--   <ul>
--   <li>If <a>Left</a> <a>Connection</a>, returns the number of columns
--   for the most recent query on the connection.</li>
--   <li>For <a>Right</a> <a>Result</a>, returns the number of columns in
--   each row of this result.</li>
--   </ul>
--   
--   The number of columns may legitimately be zero.
fieldCount :: Either Connection Result -> IO Int
affectedRows :: Connection -> IO Int64

-- | Check whether a <a>Result</a> is still valid, i.e. backed by a live
--   <tt>MYSQL_RES</tt> value.
isResultValid :: Result -> IO Bool

-- | Immediately free the <tt>MYSQL_RES</tt> value associated with this
--   <a>Result</a>, and mark the <tt>Result</tt> as invalid.
freeResult :: Result -> IO ()

-- | Retrieve a complete result.
--   
--   Any previous outstanding <a>Result</a> is first marked as invalid.
storeResult :: Connection -> IO Result

-- | Initiate a row-by-row retrieval of a result.
--   
--   Any previous outstanding <a>Result</a> is first marked as invalid.
useResult :: Connection -> IO Result
fetchRow :: Result -> IO [Maybe ByteString]
fetchFields :: Result -> IO [Field]
dataSeek :: Result -> Int64 -> IO ()
rowSeek :: Result -> Row -> IO Row
rowTell :: Result -> IO Row

-- | Read the next statement result. Returns <a>True</a> if another result
--   is available, <a>False</a> otherwise.
--   
--   This function marks the current <a>Result</a> as invalid, if one
--   exists.
nextResult :: Connection -> IO Bool

-- | Commit the current transaction.
commit :: Connection -> IO ()

-- | Roll back the current transaction.
rollback :: Connection -> IO ()
clientInfo :: String
clientVersion :: Word

-- | Call <tt>mysql_library_init</tt>
--   
--   A single-threaded program can rely on an implicit initialisation done
--   when making the first connection, but a multi-threaded one should call
--   <a>initLibrary</a> separately, and it should be done before other
--   threads might call into this library, since this function is not
--   thread-safe. See
--   <a>https://ro-che.info/articles/2015-04-17-safe-concurrent-mysql-haskell</a>
--   and
--   <a>https://dev.mysql.com/doc/refman/5.7/en/c-api-threaded-clients.html</a>
--   for details.
initLibrary :: IO ()

-- | Call <tt>mysql_thread_init</tt>
--   
--   Again a single-threaded program does not need to call this explicitly.
--   Even in a multi-threaded one, if each connection is made, used, and
--   destroyed in a single thread, it is sufficient to rely on the
--   <a>connect</a> call to do an implicit thread initialisation. But in
--   other cases, for example when using a connection pool, each thread
--   requires explicit initialisation. See
--   <a>https://ro-che.info/articles/2015-04-17-safe-concurrent-mysql-haskell</a>
--   and
--   <a>https://dev.mysql.com/doc/refman/5.7/en/c-api-threaded-clients.html</a>
--   for details.
initThread :: IO ()

-- | Call <tt>mysql_thread_end</tt>
--   
--   This is needed at thread exit to avoid a memory leak, except when
--   using a non-debug build of at least version 5.7.9 of the MySQL
--   library. See
--   <a>https://dev.mysql.com/doc/refman/5.7/en/mysql-thread-end.html</a>.
--   The threads in question are the <i>OS threads</i>, so calling this
--   function is likely to be important when using large numbers of bound
--   threads (see <a>Control.Concurrent</a>). Unbound threads - those
--   created with <tt>forkIO</tt> and friends - share a small number of OS
--   threads, so in those it is hard to call this function safely, and
--   there is little benefit in doing so, but in any case using this
--   library in unbound threads is not recommended (see
--   <a>https://ro-che.info/articles/2015-04-17-safe-concurrent-mysql-haskell</a>).
endThread :: IO ()
instance GHC.Show.Show Database.MySQL.Base.MySQLError
instance GHC.Classes.Eq Database.MySQL.Base.MySQLError
instance GHC.Show.Show Database.MySQL.Base.ConnectInfo
instance GHC.Read.Read Database.MySQL.Base.ConnectInfo
instance GHC.Classes.Eq Database.MySQL.Base.ConnectInfo
instance GHC.Show.Show Database.MySQL.Base.SSLInfo
instance GHC.Read.Read Database.MySQL.Base.SSLInfo
instance GHC.Classes.Eq Database.MySQL.Base.SSLInfo
instance GHC.Exception.Type.Exception Database.MySQL.Base.MySQLError
