hocilib 0.1.0 → 0.2.0
raw patch · 15 files changed
+145/−143 lines, 15 filesdep ~bytestring
Dependency ranges changed: bytestring
Files
- README.md +2/−0
- hocilib.cabal +5/−4
- src/Database/Ocilib/Bindings.hs +59/−58
- src/Database/Ocilib/BitMask.hs +1/−0
- src/Database/Ocilib/Collections.hs +5/−4
- src/Database/Ocilib/Connection.hs +5/−6
- src/Database/Ocilib/Errors.hs +3/−3
- src/Database/Ocilib/Fetch.hs +38/−38
- src/Database/Ocilib/Internal.hs +1/−0
- src/Database/Ocilib/Pool.hs +7/−7
- src/Database/Ocilib/Schemas.hs +5/−5
- src/Database/Ocilib/Statement.hs +13/−13
- src/Database/Ocilib/Timestamp.hs +0/−1
- src/Database/Ocilib/Transaction.hs +0/−3
- stack.yaml +1/−1
README.md view
@@ -3,6 +3,8 @@ hocilib is a FFI binding of [ocilib](http://www.ocilib.net) for haskell. [](https://travis-ci.org/fpinsight/hocilib)+[](http://stackage.org/lts/package/hocilib)+[](http://stackage.org/nightly/package/hocilib) # Join in!
hocilib.cabal view
@@ -1,5 +1,5 @@ name: hocilib-version: 0.1.0+version: 0.2.0 license: BSD3 license-file: LICENSE category: Database, Oracle, Ocilib, FFI@@ -64,9 +64,10 @@ extra-libraries: ocilib extra-lib-dirs: /usr/local/lib - build-depends: base >= 4.8 && < 5- , containers >= 0.5 && < 1- , inline-c >= 0.5 && < 1+ build-depends: base >= 4.8 && < 5+ , bytestring >= 0.10 && < 0.11+ , containers >= 0.5 && < 1+ , inline-c >= 0.5 && < 1 , template-haskell
src/Database/Ocilib/Bindings.hs view
@@ -84,6 +84,7 @@ , ociBindSetCharsetForm ) where +import Data.ByteString import Data.Monoid ((<>)) import Foreign.C.Types import Foreign.C.String@@ -121,20 +122,20 @@ fmap toBool [C.exp| int { OCI_IsRebindingAllowed($(OCI_Statement *st)) } |] -- | Bind a boolean variable (PL/SQL ONLY)-ociBindBoolean :: Ptr OCI_Statement -> String -> Ptr CInt -> IO Bool-ociBindBoolean st n d = withCString n (\n' ->+ociBindBoolean :: Ptr OCI_Statement -> ByteString -> Ptr CInt -> IO Bool+ociBindBoolean st n d = useAsCString n (\n' -> fmap toBool [C.exp| int { OCI_BindBoolean($(OCI_Statement *st), $(const char *n'), $(int *d)) } |] ) -- | Bind an short variable.-ociBindShort :: Ptr OCI_Statement -> String -> Ptr CShort -> IO Bool-ociBindShort st n d = withCString n (\n' ->+ociBindShort :: Ptr OCI_Statement -> ByteString -> Ptr CShort -> IO Bool+ociBindShort st n d = useAsCString n (\n' -> fmap toBool [C.exp| int { OCI_BindShort($(OCI_Statement *st), $(const char *n'), $(short *d)) } |] ) -- | Bind an array of shorts.-ociBindArrayOfShorts :: Ptr OCI_Statement -> String -> Ptr CShort -> CUInt -> IO Bool-ociBindArrayOfShorts st n d nb = withCString n (\n' ->+ociBindArrayOfShorts :: Ptr OCI_Statement -> ByteString -> Ptr CShort -> CUInt -> IO Bool+ociBindArrayOfShorts st n d nb = useAsCString n (\n' -> fmap toBool [C.exp| int { OCI_BindArrayOfShorts($(OCI_Statement *st) , $(const char *n') , $(short *d)@@ -142,16 +143,16 @@ ) -- | Bind an unsigned short variable.-ociBindUnsignedShort :: Ptr OCI_Statement -> String -> Ptr CUShort -> IO Bool-ociBindUnsignedShort st n d = withCString n (\n' ->+ociBindUnsignedShort :: Ptr OCI_Statement -> ByteString -> Ptr CUShort -> IO Bool+ociBindUnsignedShort st n d = useAsCString n (\n' -> fmap toBool [C.exp| int { OCI_BindUnsignedShort($(OCI_Statement *st) , $(const char *n') , $(unsigned short *d)) } |] ) -- | Bind an array of unsigned shorts.-ociBindArrayOfUnsignedShorts :: Ptr OCI_Statement -> String -> Ptr CUShort -> CUInt -> IO Bool-ociBindArrayOfUnsignedShorts st n d nb = withCString n (\n' ->+ociBindArrayOfUnsignedShorts :: Ptr OCI_Statement -> ByteString -> Ptr CUShort -> CUInt -> IO Bool+ociBindArrayOfUnsignedShorts st n d nb = useAsCString n (\n' -> fmap toBool [C.exp| int { OCI_BindArrayOfUnsignedShorts($(OCI_Statement * st) , $(const char *n') , $(unsigned short *d)@@ -159,16 +160,16 @@ ) -- | Bind an integer variable.-ociBindInt :: Ptr OCI_Statement -> String -> Ptr CInt -> IO Bool-ociBindInt st n d = withCString n (\n' ->+ociBindInt :: Ptr OCI_Statement -> ByteString -> Ptr CInt -> IO Bool+ociBindInt st n d = useAsCString n (\n' -> fmap toBool [C.exp| int { OCI_BindInt($(OCI_Statement *st) , $(const char *n') , $(int *d)) } |] ) -- | Bind an array of integers.-ociBindArrayOfInts :: Ptr OCI_Statement -> String -> Ptr CInt -> CUInt -> IO Bool-ociBindArrayOfInts st n d nb = withCString n (\n' ->+ociBindArrayOfInts :: Ptr OCI_Statement -> ByteString -> Ptr CInt -> CUInt -> IO Bool+ociBindArrayOfInts st n d nb = useAsCString n (\n' -> fmap toBool [C.exp| int { OCI_BindArrayOfInts($(OCI_Statement *st) , $(const char *n') , $(int *d)@@ -176,16 +177,16 @@ ) -- | Bind an unsigned integer variable.-ociBindUnsignedInt :: Ptr OCI_Statement -> String -> Ptr CUInt -> IO Bool-ociBindUnsignedInt st n d = withCString n (\n' ->+ociBindUnsignedInt :: Ptr OCI_Statement -> ByteString -> Ptr CUInt -> IO Bool+ociBindUnsignedInt st n d = useAsCString n (\n' -> fmap toBool [C.exp| int { OCI_BindUnsignedInt($(OCI_Statement *st) , $(const char* n') , $(unsigned int *d)) } |] ) -- | Bind an array of unsigned integers.-ociBindArrayOfUnsignedInts :: Ptr OCI_Statement -> String -> Ptr CUInt -> CUInt -> IO Bool-ociBindArrayOfUnsignedInts st n d nb = withCString n (\n' ->+ociBindArrayOfUnsignedInts :: Ptr OCI_Statement -> ByteString -> Ptr CUInt -> CUInt -> IO Bool+ociBindArrayOfUnsignedInts st n d nb = useAsCString n (\n' -> fmap toBool [C.exp| int { OCI_BindArrayOfUnsignedInts($(OCI_Statement *st) , $(const char *n') , $(unsigned int *d)@@ -194,8 +195,8 @@ {- -- | Bind a big integer variable. -- boolean OCI_BindBigInt (OCI_Statement *stmt, const otext *name, big_int *data)-ociBindBigInt :: Ptr OCI_Statement -> String -> Ptr Big_Int -> IO Bool-ociBindBigInt st n d = withCString n (\n' ->+ociBindBigInt :: Ptr OCI_Statement -> ByteString -> Ptr Big_Int -> IO Bool+ociBindBigInt st n d = useAsCString n (\n' -> fmap toBool [C.exp| int { OCI_BindBigInt($(OCI_Statement *st) , $(const char *n') , $(Big_Int *d)) } |]@@ -212,9 +213,9 @@ -} -- | Bind a string variable.-ociBindString :: Ptr OCI_Statement -> String -> CString -> CUInt -> IO Bool+ociBindString :: Ptr OCI_Statement -> ByteString -> CString -> CUInt -> IO Bool ociBindString st name d l =- withCString name (\n ->+ useAsCString name (\n -> fmap toBool [C.exp| int { OCI_BindString($(OCI_Statement *st) , $(char *n) , $(char *d)@@ -222,9 +223,9 @@ ) -- | Bind an array of strings.-ociBindArrayOfStrings :: Ptr OCI_Statement -> String -> CString -> CUInt -> CUInt -> IO Bool+ociBindArrayOfStrings :: Ptr OCI_Statement -> ByteString -> CString -> CUInt -> CUInt -> IO Bool ociBindArrayOfStrings st name d len nbElem =- withCString name (\n ->+ useAsCString name (\n -> fmap toBool [C.exp| int { OCI_BindArrayOfStrings($(OCI_Statement *st) , $(char *n) , $(char *d)@@ -240,16 +241,16 @@ -- boolean OCI_BindArrayOfRaws (OCI_Statement *stmt, const otext *name, void *data, unsigned int len, unsigned int nbelem) -- | Bind a double variable.-ociBindDouble :: Ptr OCI_Statement -> String -> Ptr CDouble -> IO Bool-ociBindDouble st n d = withCString n (\n' ->+ociBindDouble :: Ptr OCI_Statement -> ByteString -> Ptr CDouble -> IO Bool+ociBindDouble st n d = useAsCString n (\n' -> fmap toBool [C.exp| int { OCI_BindDouble($(OCI_Statement *st) , $(const char *n') , $(double *d)) } |] ) -- | Bind an array of doubles.-ociBindArrayOfDoubles :: Ptr OCI_Statement -> String -> Ptr CDouble -> CUInt -> IO Bool-ociBindArrayOfDoubles st n d nb = withCString n (\n' ->+ociBindArrayOfDoubles :: Ptr OCI_Statement -> ByteString -> Ptr CDouble -> CUInt -> IO Bool+ociBindArrayOfDoubles st n d nb = useAsCString n (\n' -> fmap toBool [C.exp| int { OCI_BindArrayOfDoubles($(OCI_Statement *st) , $(const char *n') , $(double *d)@@ -257,23 +258,23 @@ ) -- | Bind a float variable.-ociBindFloat :: Ptr OCI_Statement -> String -> Ptr CFloat -> IO Bool-ociBindFloat st n d = withCString n (\n' ->+ociBindFloat :: Ptr OCI_Statement -> ByteString -> Ptr CFloat -> IO Bool+ociBindFloat st n d = useAsCString n (\n' -> fmap toBool [C.exp| int { OCI_BindFloat($(OCI_Statement *st) , $(const char *n') , $(float *d)) } |] ) -- | Bind an array of floats.-ociBindArrayOfFloats :: Ptr OCI_Statement -> String -> Ptr CFloat -> CUInt -> IO Bool-ociBindArrayOfFloats st n d nb = withCString n (\n' ->+ociBindArrayOfFloats :: Ptr OCI_Statement -> ByteString -> Ptr CFloat -> CUInt -> IO Bool+ociBindArrayOfFloats st n d nb = useAsCString n (\n' -> fmap toBool [C.exp| int { OCI_BindArrayOfFloats($(OCI_Statement *st) , $(const char *n') , $(float *d) , $(unsigned int nb)) } |] ) -- | Bind a date variable.-ociBindDate :: Ptr OCI_Statement -> String -> Ptr OCI_Date -> IO Bool-ociBindDate st n d = withCString n (\n' ->+ociBindDate :: Ptr OCI_Statement -> ByteString -> Ptr OCI_Date -> IO Bool+ociBindDate st n d = useAsCString n (\n' -> fmap toBool [C.exp| int { OCI_BindDate($(OCI_Statement *st) , $(const char* n') , $(OCI_Date *d)) } |]@@ -282,8 +283,8 @@ -- | Bind an array of dates. -- boolean OCI_BindArrayOfDates (OCI_Statement *stmt, const otext *name, OCI_Date **data, unsigned int nbelem) {--ociBindArrayOfDates :: Ptr OCI_Statement -> String -> Ptr OCI_Date -> CUInt -> IO Bool-ociBindArrayOfDates st n d nb = withCString n (\n' ->+ociBindArrayOfDates :: Ptr OCI_Statement -> ByteString -> Ptr OCI_Date -> CUInt -> IO Bool+ociBindArrayOfDates st n d nb = useAsCString n (\n' -> fmap toBool [C.exp| int { OCI_BindArrayOfDates($(OCI_Statement *st) , $(const char *n') , $(OCI_Date *d)@@ -292,8 +293,8 @@ -} -- | Bind a timestamp variable.-ociBindTimestamp :: Ptr OCI_Statement -> String -> Ptr OCI_Timestamp -> IO Bool-ociBindTimestamp st n d = withCString n (\n' ->+ociBindTimestamp :: Ptr OCI_Statement -> ByteString -> Ptr OCI_Timestamp -> IO Bool+ociBindTimestamp st n d = useAsCString n (\n' -> fmap toBool [C.exp| int { OCI_BindTimestamp($(OCI_Statement *st) , $(const char *n') , $(OCI_Timestamp *d)) } |]@@ -303,8 +304,8 @@ -- boolean OCI_BindArrayOfTimestamps (OCI_Statement *stmt, const otext *name, OCI_Timestamp **data, unsigned int type, unsigned int nbelem) -- | Bind an interval variable.-ociBindInterval :: Ptr OCI_Statement -> String -> Ptr OCI_Interval -> IO Bool-ociBindInterval st n d = withCString n (\n' ->+ociBindInterval :: Ptr OCI_Statement -> ByteString -> Ptr OCI_Interval -> IO Bool+ociBindInterval st n d = useAsCString n (\n' -> fmap toBool [C.exp| int { OCI_BindInterval($(OCI_Statement *st) , $(const char *n') , $(OCI_Interval *d)) } |]@@ -313,8 +314,8 @@ -- boolean OCI_BindArrayOfIntervals (OCI_Statement *stmt, const otext *name, OCI_Interval **data, unsigned int type, unsigned int nbelem) -- | Bind a Lob variable.-ociBindLob :: Ptr OCI_Statement -> String -> Ptr OCI_Lob -> IO Bool-ociBindLob st n d = withCString n (\n' ->+ociBindLob :: Ptr OCI_Statement -> ByteString -> Ptr OCI_Lob -> IO Bool+ociBindLob st n d = useAsCString n (\n' -> fmap toBool [C.exp| int { OCI_BindLob($(OCI_Statement *st) , $(const char *n') , $(OCI_Lob *d)) } |]@@ -324,8 +325,8 @@ -- boolean OCI_BindArrayOfLobs (OCI_Statement *stmt, const otext *name, OCI_Lob **data, unsigned int type, unsigned int nbelem) -- | Bind a File variable.-ociBindFile :: Ptr OCI_Statement -> String -> Ptr OCI_File -> IO Bool-ociBindFile st n d = withCString n (\n' ->+ociBindFile :: Ptr OCI_Statement -> ByteString -> Ptr OCI_File -> IO Bool+ociBindFile st n d = useAsCString n (\n' -> fmap toBool [C.exp| int { OCI_BindFile($(OCI_Statement *st) , $(const char *n') , $(OCI_File *d)) } |]@@ -344,8 +345,8 @@ -- boolean OCI_BindArrayOfObjects (OCI_Statement *stmt, const otext *name, OCI_Object **data, OCI_TypeInfo *typinf, unsigned int nbelem) -- | Bind a Collection variable.-ociBindColl :: Ptr OCI_Statement -> String -> Ptr OCI_Coll -> IO Bool-ociBindColl st n d = withCString n (\n' ->+ociBindColl :: Ptr OCI_Statement -> ByteString -> Ptr OCI_Coll -> IO Bool+ociBindColl st n d = useAsCString n (\n' -> fmap toBool [C.exp| int { OCI_BindColl($(OCI_Statement *st) , $(const char *n') , $(OCI_Coll *d)) } |]@@ -355,8 +356,8 @@ -- boolean OCI_BindArrayOfColls (OCI_Statement *stmt, const otext *name, OCI_Coll **data, OCI_TypeInfo *typinf, unsigned int nbelem) -- | Bind a Ref variable.-ociBindRef :: Ptr OCI_Statement -> String -> Ptr OCI_Ref -> IO Bool-ociBindRef st n d = withCString n (\n' ->+ociBindRef :: Ptr OCI_Statement -> ByteString -> Ptr OCI_Ref -> IO Bool+ociBindRef st n d = useAsCString n (\n' -> fmap toBool [C.exp| int { OCI_BindRef($(OCI_Statement *st) , $(const char *n') , $(OCI_Ref *d)) } |]@@ -366,14 +367,14 @@ -- boolean OCI_BindArrayOfRefs (OCI_Statement *stmt, const otext *name, OCI_Ref **data, OCI_TypeInfo *typinf, unsigned int nbelem) -- | Bind a Statement variable (PL/SQL Ref Cursor)-ociBindStatement :: Ptr OCI_Statement -> String -> Ptr OCI_Statement -> IO Bool-ociBindStatement st name d = withCString name (\name' ->+ociBindStatement :: Ptr OCI_Statement -> ByteString -> Ptr OCI_Statement -> IO Bool+ociBindStatement st name d = useAsCString name (\name' -> fmap toBool [C.exp| int { OCI_BindStatement($(OCI_Statement *st), $(const char *name'), $(OCI_Statement *d)) } |] ) -- | Bind a Long variable.-ociBindLong :: Ptr OCI_Statement -> String -> Ptr OCI_Long -> CUInt -> IO Bool-ociBindLong st name d s = withCString name (\name' ->+ociBindLong :: Ptr OCI_Statement -> ByteString -> Ptr OCI_Long -> CUInt -> IO Bool+ociBindLong st name d s = useAsCString name (\name' -> fmap toBool [C.exp| int { OCI_BindLong($(OCI_Statement *st), $(const char *name'), $(OCI_Long *d), $(unsigned int s)) } |] ) @@ -394,22 +395,22 @@ ociGetBind st i = fmap toMaybePtr [C.exp| OCI_Bind* { OCI_GetBind($(OCI_Statement *st), $(unsigned int i)) } |] -- | Return a bind handle from its name.-ociGetBind2 :: Ptr OCI_Statement -> String -> IO (Maybe (Ptr OCI_Bind))-ociGetBind2 st name = withCString name (\name' ->+ociGetBind2 :: Ptr OCI_Statement -> ByteString -> IO (Maybe (Ptr OCI_Bind))+ociGetBind2 st name = useAsCString name (\name' -> fmap toMaybePtr [C.exp| OCI_Bind* { OCI_GetBind2($(OCI_Statement *st), $(char *name')) } |] ) -- | Return the index of the bind from its name belonging to the given statement.-ociGetBindIndex :: Ptr OCI_Statement -> String -> IO CUInt-ociGetBindIndex st name = withCString name (\name' ->+ociGetBindIndex :: Ptr OCI_Statement -> ByteString -> IO CUInt+ociGetBindIndex st name = useAsCString name (\name' -> [C.exp| unsigned int { OCI_GetBindIndex($(OCI_Statement *st), $(char* name')) } |] ) -- | Return the name of the given bind.-ociBindGetName :: Ptr OCI_Bind -> IO String+ociBindGetName :: Ptr OCI_Bind -> IO ByteString ociBindGetName b = do name <- [C.exp| const char* { OCI_BindGetName($(OCI_Bind *b)) } |]- peekCString name+ packCString name -- | Set the direction mode of a bind handle. ociBindSetDirection :: Ptr OCI_Bind -> BindDirectionMode -> IO Bool
src/Database/Ocilib/BitMask.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE DefaultSignatures #-}+{-# OPTIONS_HADDOCK hide, prune, ignore-exports #-} -- | -- Module: Database.Ocilib.BitMask
src/Database/Ocilib/Collections.hs view
@@ -79,6 +79,7 @@ , ociElemSetNull ) where +import Data.ByteString import Data.Monoid ((<>)) import Foreign.C.Types import Foreign.C.String@@ -230,10 +231,10 @@ -} -- | Return the String value of the given collection element.-ociElemGetString :: Ptr OCI_Elem -> IO String+ociElemGetString :: Ptr OCI_Elem -> IO ByteString ociElemGetString elem = do s <- [C.exp| const char* { OCI_ElemGetString($(OCI_Elem *elem)) } |]- peekCString s+ packCString s {- -- | Read the RAW value of the collection element into the given buffer.@@ -295,9 +296,9 @@ -} -- | Set a string value to a collection element.-ociElemSetString :: Ptr OCI_Elem -> String -> IO Bool+ociElemSetString :: Ptr OCI_Elem -> ByteString -> IO Bool ociElemSetString elem value =- withCString value (\value' ->+ useAsCString value (\value' -> fmap toBool [C.exp| int { OCI_ElemSetString($(OCI_Elem *elem), $(char *value')) } |] ) {-
src/Database/Ocilib/Connection.hs view
@@ -23,9 +23,8 @@ , ociBreak ) where +import Data.ByteString import Data.Monoid ((<>))--- import Foreign.C.Types-import Foreign.C.String import Foreign.Marshal.Utils import Foreign.Ptr import qualified Language.C.Inline as C@@ -42,12 +41,12 @@ type Connection = Ptr OCI_Connection -- | Create a physical connection to an Oracle database server.-ociConnectionCreate :: String -> String -> String -> SessionMode -> IO (Maybe Connection)+ociConnectionCreate :: ByteString -> ByteString -> ByteString -> SessionMode -> IO (Maybe Connection) ociConnectionCreate db user pass mode = do let m = fromIntegral $ fromEnum mode- withCString db ( \d ->- withCString user ( \u ->- withCString pass ( \p ->+ useAsCString db ( \d ->+ useAsCString user ( \u ->+ useAsCString pass ( \p -> fmap toMaybePtr [C.exp| OCI_Connection* { OCI_ConnectionCreate($(char* d), $(char* u), $(char* p), $(unsigned int m)) } |] ) )
src/Database/Ocilib/Errors.hs view
@@ -24,9 +24,9 @@ , ociErrorGetRow ) where +import Data.ByteString import Data.Monoid ((<>)) import Foreign.C.Types-import Foreign.C.String import Foreign.Ptr import qualified Language.C.Inline as C import Database.Ocilib.Oci@@ -44,10 +44,10 @@ ociGetLastError = fmap toMaybePtr [C.exp| OCI_Error* { OCI_GetLastError() } |] -- | Retrieve error message from error handle.-ociErrorGetString :: Ptr OCI_Error -> IO String+ociErrorGetString :: Ptr OCI_Error -> IO ByteString ociErrorGetString err = do s <- [C.exp| const char* { OCI_ErrorGetString($(OCI_Error *err)) } |]- peekCString s+ packCString s -- | Retrieve the type of error from error handle. ociErrorGetType :: Ptr OCI_Error -> IO ErrorType
src/Database/Ocilib/Fetch.hs view
@@ -89,9 +89,9 @@ , ociGetDataLength ) where +import Data.ByteString import Data.Monoid ((<>)) import Foreign.C.Types-import Foreign.C.String import Foreign.Marshal.Utils import Foreign.Ptr import qualified Language.C.Inline as C@@ -152,24 +152,24 @@ ociGetColumn rs i = [C.exp| OCI_Column* { OCI_GetColumn($(OCI_Resultset *rs), $(unsigned int i)) } |] -- | Return the column object handle from its name in the resultset.-ociGetColumn2 :: Ptr OCI_Resultset -> String -> IO (Ptr OCI_Column)+ociGetColumn2 :: Ptr OCI_Resultset -> ByteString -> IO (Ptr OCI_Column) ociGetColumn2 rs name =- withCString name (\n ->+ useAsCString name (\n -> [C.exp| OCI_Column* { OCI_GetColumn2($(OCI_Resultset *rs), $(char *n)) } |] ) -- | Return the index of the column in the result from its name.-ociGetColumnIndex :: Ptr OCI_Resultset -> String -> IO CUInt+ociGetColumnIndex :: Ptr OCI_Resultset -> ByteString -> IO CUInt ociGetColumnIndex rs name =- withCString name (\n ->+ useAsCString name (\n -> [C.exp| unsigned int { OCI_GetColumnIndex($(OCI_Resultset *rs), $(char *n)) } |] ) -- | Return the name of the given column.-ociColumnGetName :: Ptr OCI_Column -> IO String+ociColumnGetName :: Ptr OCI_Column -> IO ByteString ociColumnGetName c = do s <- [C.exp| const char* { OCI_ColumnGetName($(OCI_Column *c)) } |]- peekCString s+ packCString s -- | Return the type of the given column. ociColumnGetType :: Ptr OCI_Column -> IO ColumnType@@ -183,10 +183,10 @@ -} -- | Return the Oracle SQL type name of the column data type.-ociColumnGetSQLType :: Ptr OCI_Column -> IO String+ociColumnGetSQLType :: Ptr OCI_Column -> IO ByteString ociColumnGetSQLType c = do s <- [C.exp| const char* { OCI_ColumnGetSQLType($(OCI_Column *c)) } |]- peekCString s+ packCString s {- -- | Return the Oracle SQL Full name including precision and size of the column data type.@@ -238,9 +238,9 @@ ociSetStructNumericType rs i t = fmap toBool [C.exp| int { OCI_SetStructNumericType($(OCI_Resultset *rs), $(unsigned int i), $(unsigned int t)) } |] -- | set the numeric data type of the given structure member (identified from column name in the resultset) to retrieve when calling OCI_GetStruct()-ociSetStructNumericType2 :: Ptr OCI_Resultset -> String -> CUInt -> IO Bool -- FIXME use enum for the type+ociSetStructNumericType2 :: Ptr OCI_Resultset -> ByteString -> CUInt -> IO Bool -- FIXME use enum for the type ociSetStructNumericType2 rs name t =- withCString name (\n ->+ useAsCString name (\n -> fmap toBool [C.exp| int { OCI_SetStructNumericType2($(OCI_Resultset *rs), $(char *n), $(unsigned int t))} |] ) @@ -254,9 +254,9 @@ ociGetShort rs i = [C.exp| short { OCI_GetShort($(OCI_Resultset *rs), $(unsigned int i)) } |] -- | Return the current short value of the column from its name in the resultset.-ociGetShort2 :: Ptr OCI_Resultset -> String -> IO CShort+ociGetShort2 :: Ptr OCI_Resultset -> ByteString -> IO CShort ociGetShort2 rs name =- withCString name (\n ->+ useAsCString name (\n -> [C.exp| short { OCI_GetShort2($(OCI_Resultset *rs), $(char *n)) } |] ) @@ -265,9 +265,9 @@ ociGetUnsignedShort rs i = [C.exp| unsigned short { OCI_GetUnsignedShort($(OCI_Resultset *rs), $(unsigned int i)) } |] -- | Return the current unsigned short value of the column from its name in the resultset.-ociGetUnsignedShort2 :: Ptr OCI_Resultset -> String -> IO CUShort+ociGetUnsignedShort2 :: Ptr OCI_Resultset -> ByteString -> IO CUShort ociGetUnsignedShort2 rs name =- withCString name (\n ->+ useAsCString name (\n -> [C.exp| unsigned short { OCI_GetUnsignedShort2($(OCI_Resultset *rs), $(char *n)) } |] ) @@ -276,9 +276,9 @@ ociGetInt rs i = [C.exp| int { OCI_GetInt($(OCI_Resultset *rs), $(unsigned int i)) } |] -- | Return the current integer value of the column from its name in the resultset.-ociGetInt2 :: Ptr OCI_Resultset -> String -> IO CInt+ociGetInt2 :: Ptr OCI_Resultset -> ByteString -> IO CInt ociGetInt2 rs name =- withCString name (\n ->+ useAsCString name (\n -> [C.exp| int { OCI_GetInt2($(OCI_Resultset *rs), $(char *n)) } |] ) @@ -287,9 +287,9 @@ ociGetUnsignedInt rs i = [C.exp| unsigned int { OCI_GetUnsignedInt($(OCI_Resultset *rs), $(unsigned int i)) } |] -- | Return the current unsigned integer value of the column from its name in the resultset.-ociGetUnsignedInt2 :: Ptr OCI_Resultset -> String -> IO CUInt+ociGetUnsignedInt2 :: Ptr OCI_Resultset -> ByteString -> IO CUInt ociGetUnsignedInt2 rs name =- withCString name (\n ->+ useAsCString name (\n -> [C.exp| unsigned int { OCI_GetUnsignedInt2($(OCI_Resultset *rs), $(char *n))} |] ) @@ -309,17 +309,17 @@ -} -- | Return the current string value of the column at the given index in the resultset.-ociGetString :: Ptr OCI_Resultset -> CUInt -> IO String+ociGetString :: Ptr OCI_Resultset -> CUInt -> IO ByteString ociGetString rs i = do s <- [C.exp| const char* { OCI_GetString($(OCI_Resultset *rs), $(unsigned int i)) }|]- peekCString s -- FIXME release CString ?+ packCString s -- FIXME release CString ? -- | Return the current string value of the column from its name in the resultset.-ociGetString2 :: Ptr OCI_Resultset -> String -> IO String+ociGetString2 :: Ptr OCI_Resultset -> ByteString -> IO ByteString ociGetString2 rs name =- withCString name (\n -> do+ useAsCString name (\n -> do s <- [C.exp| const char* { OCI_GetString2($(OCI_Resultset *rs), $(char *n)) } |]- peekCString s+ packCString s ) {-@@ -335,9 +335,9 @@ ociGetDouble rs i = [C.exp| double { OCI_GetDouble($(OCI_Resultset *rs), $(unsigned int i))} |] -- | Return the current double value of the column from its name in the resultset.-ociGetDouble2 :: Ptr OCI_Resultset -> String -> IO CDouble+ociGetDouble2 :: Ptr OCI_Resultset -> ByteString -> IO CDouble ociGetDouble2 rs name =- withCString name (\n ->+ useAsCString name (\n -> [C.exp| double { OCI_GetDouble2($(OCI_Resultset *rs), $(char *n))} |] ) @@ -346,9 +346,9 @@ ociGetFloat rs i = [C.exp| float { OCI_GetFloat($(OCI_Resultset *rs), $(unsigned int i)) } |] -- | Return the current float value of the column from its name in the resultset.-ociGetFloat2 :: Ptr OCI_Resultset -> String -> IO CFloat+ociGetFloat2 :: Ptr OCI_Resultset -> ByteString -> IO CFloat ociGetFloat2 rs name =- withCString name (\n ->+ useAsCString name (\n -> [C.exp| float { OCI_GetFloat2($(OCI_Resultset *rs), $(char *n))} |] ) @@ -357,9 +357,9 @@ ociGetDate rs i = [C.exp| OCI_Date* { OCI_GetDate($(OCI_Resultset *rs), $(unsigned int i))} |] -- | Return the current date value of the column from its name in the resultset.-ociGetDate2 :: Ptr OCI_Resultset -> String -> IO (Ptr OCI_Date)+ociGetDate2 :: Ptr OCI_Resultset -> ByteString -> IO (Ptr OCI_Date) ociGetDate2 rs name =- withCString name (\n ->+ useAsCString name (\n -> [C.exp| OCI_Date* { OCI_GetDate2($(OCI_Resultset *rs), $(char *n))} |] ) @@ -368,9 +368,9 @@ ociGetTimestamp rs i = [C.exp| OCI_Timestamp* { OCI_GetTimestamp($(OCI_Resultset *rs), $(unsigned int i)) } |] -- | Return the current timestamp value of the column from its name in the resultset.-ociGetTimestamp2 :: Ptr OCI_Resultset -> String -> IO (Ptr OCI_Timestamp)+ociGetTimestamp2 :: Ptr OCI_Resultset -> ByteString -> IO (Ptr OCI_Timestamp) ociGetTimestamp2 rs name =- withCString name (\n ->+ useAsCString name (\n -> [C.exp| OCI_Timestamp* { OCI_GetTimestamp2($(OCI_Resultset *rs), $(char *n)) } |] ) @@ -379,9 +379,9 @@ ociGetInterval rs i = [C.exp| OCI_Interval* { OCI_GetInterval($(OCI_Resultset *rs), $(unsigned int i)) } |] -- | Return the current interval value of the column from its name in the resultset.-ociGetInterval2 :: Ptr OCI_Resultset -> String -> IO (Ptr OCI_Interval)+ociGetInterval2 :: Ptr OCI_Resultset -> ByteString -> IO (Ptr OCI_Interval) ociGetInterval2 rs name =- withCString name (\n ->+ useAsCString name (\n -> [C.exp| OCI_Interval* { OCI_GetInterval2($(OCI_Resultset *rs), $(char *n)) } |] ) @@ -390,9 +390,9 @@ ociGetStatement rs i = [C.exp| OCI_Statement* { OCI_GetStatement($(OCI_Resultset *rs), $(unsigned int i)) }|] -- | Return the current cursor value of the column from its name in the resultset.-ociGetStatement2 :: Ptr OCI_Resultset -> String -> IO (Ptr OCI_Statement)+ociGetStatement2 :: Ptr OCI_Resultset -> ByteString -> IO (Ptr OCI_Statement) ociGetStatement2 rs name =- withCString name (\n ->+ useAsCString name (\n -> [C.exp| OCI_Statement* { OCI_GetStatement2($(OCI_Resultset *rs), $(char *n)) } |] ) @@ -441,9 +441,9 @@ -- | Check if the current row value is null for the column of the given name in the resultset. -- boolean OCI_IsNull2 (OCI_Resultset *rs, const otext *name)-ociIsNull2 :: Ptr OCI_Resultset -> String -> IO Bool+ociIsNull2 :: Ptr OCI_Resultset -> ByteString -> IO Bool ociIsNull2 rs name =- withCString name (\n ->+ useAsCString name (\n -> fmap toBool [C.exp| int { OCI_IsNull2($(OCI_Resultset *rs), $(char *n)) } |] )
src/Database/Ocilib/Internal.hs view
@@ -13,6 +13,7 @@ import Foreign.Ptr +-- | return Nothing if nullPtr Ptr otherwise toMaybePtr :: Ptr a -> Maybe (Ptr a) toMaybePtr a | a == nullPtr = Nothing
src/Database/Ocilib/Pool.hs view
@@ -33,9 +33,9 @@ , ociPoolSetStatementCacheSize ) where +import Data.ByteString import Data.Monoid ((<>)) import Foreign.C.Types-import Foreign.C.String import Foreign.Marshal.Utils import Foreign.Ptr import qualified Language.C.Inline as C@@ -52,13 +52,13 @@ type Pool = Ptr OCI_Pool -- | Create an Oracle pool of connections or sessions.-ociPoolCreate :: String -> String -> String -> PoolType -> SessionMode -> CUInt -> CUInt -> CUInt -> IO (Maybe Pool)+ociPoolCreate :: ByteString -> ByteString -> ByteString -> PoolType -> SessionMode -> CUInt -> CUInt -> CUInt -> IO (Maybe Pool) ociPoolCreate db user pwd pType mode minCon maxCon incrCon = do let pt = fromIntegral $ fromEnum pType m = fromIntegral $ fromEnum mode- withCString db (\d ->- withCString user (\u ->- withCString pwd (\p ->+ useAsCString db (\d ->+ useAsCString user (\u ->+ useAsCString pwd (\p -> fmap toMaybePtr [C.exp| OCI_Pool* { OCI_PoolCreate( $(char *d) , $(char *u) , $(char *p)@@ -76,9 +76,9 @@ ociPoolFree p = fmap toBool [C.exp| int { OCI_PoolFree($(OCI_Pool *p))} |] -- | Get a connection from the pool.-ociPoolGetConnection :: Ptr OCI_Pool -> String -> IO (Maybe (Ptr OCI_Connection))+ociPoolGetConnection :: Ptr OCI_Pool -> ByteString -> IO (Maybe (Ptr OCI_Connection)) ociPoolGetConnection p tag =- withCString tag (\t ->+ useAsCString tag (\t -> fmap toMaybePtr [C.exp| OCI_Connection* { OCI_PoolGetConnection($(OCI_Pool *p), $(char *t)) } |] )
src/Database/Ocilib/Schemas.hs view
@@ -15,9 +15,9 @@ module Database.Ocilib.Schemas where +import Data.ByteString import Data.Monoid ((<>)) import Foreign.C.Types-import Foreign.C.String import Foreign.Marshal.Utils import Foreign.Ptr import qualified Language.C.Inline as C@@ -32,10 +32,10 @@ -- Describing Schema Meta data and Objects -- | Retrieve the available type info information.-ociTypeInfoGet :: Ptr OCI_Connection -> String -> TypeInfoType -> IO (Maybe (Ptr OCI_TypeInfo))+ociTypeInfoGet :: Ptr OCI_Connection -> ByteString -> TypeInfoType -> IO (Maybe (Ptr OCI_TypeInfo)) ociTypeInfoGet c name typ = do let typ' = fromIntegral $ fromEnum typ- withCString name (\name' ->+ useAsCString name (\name' -> fmap toMaybePtr [C.exp| OCI_TypeInfo* { OCI_TypeInfoGet($(OCI_Connection *c), $(char *name'), $(unsigned int typ')) } |] ) @@ -60,7 +60,7 @@ ociTypeInfoGetColumn t i = [C.exp| OCI_Column* { OCI_TypeInfoGetColumn($(OCI_TypeInfo *t), $(unsigned int i))} |] -- | Return the name described by the type info object.-ociTypeInfoGetName :: Ptr OCI_TypeInfo -> IO String+ociTypeInfoGetName :: Ptr OCI_TypeInfo -> IO ByteString ociTypeInfoGetName t = do s <- [C.exp| const char* { OCI_TypeInfoGetName($(OCI_TypeInfo *t)) } |]- peekCString s+ packCString s
src/Database/Ocilib/Statement.hs view
@@ -46,9 +46,9 @@ , ociStatementGetConnection ) where +import Data.ByteString import Data.Monoid ((<>)) import Foreign.C.Types-import Foreign.C.String import Foreign.Marshal.Utils import Foreign.Ptr import qualified Language.C.Inline as C@@ -71,9 +71,9 @@ ociStatementFree s = fmap toBool [C.exp| int { OCI_StatementFree($(OCI_Statement *s)) } |] -- | Prepare a SQL statement or PL/SQL block.-ociPrepare :: Ptr OCI_Statement -> String -> IO Bool+ociPrepare :: Ptr OCI_Statement -> ByteString -> IO Bool ociPrepare s sql =- withCString sql (\q ->+ useAsCString sql (\q -> fmap toBool [C.exp| int { OCI_Prepare($(OCI_Statement *s), $(char *q)) } |] ) @@ -82,31 +82,31 @@ ociExecute s = fmap toBool [C.exp| int { OCI_Execute($(OCI_Statement *s)) } |] -- | Prepare and Execute a SQL statement or PL/SQL block.-ociExecuteStmt :: Ptr OCI_Statement -> String -> IO Bool+ociExecuteStmt :: Ptr OCI_Statement -> ByteString -> IO Bool ociExecuteStmt s sql =- withCString sql (\q ->+ useAsCString sql (\q -> fmap toBool [C.exp| int { OCI_ExecuteStmt($(OCI_Statement *s), $(char *q)) } |] ) -- | Parse a SQL statement or PL/SQL block.-ociParse :: Ptr OCI_Statement -> String -> IO Bool+ociParse :: Ptr OCI_Statement -> ByteString -> IO Bool ociParse st sql =- withCString sql (\s ->+ useAsCString sql (\s -> fmap toBool [C.exp| int { OCI_Parse($(OCI_Statement *st), $(char *s)) } |] ) -- | Describe the select list of a SQL select statement.-ociDescribe :: Ptr OCI_Statement -> String -> IO Bool+ociDescribe :: Ptr OCI_Statement -> ByteString -> IO Bool ociDescribe st sql =- withCString sql (\s ->+ useAsCString sql (\s -> fmap toBool [C.exp| int {OCI_Describe($(OCI_Statement *st), $(char *s)) } |] ) -- | Return the last SQL or PL/SQL statement prepared or executed by the statement.-ociGetSql :: Ptr OCI_Statement -> IO String+ociGetSql :: Ptr OCI_Statement -> IO ByteString ociGetSql st = do r <- [C.exp| const char* { OCI_GetSql($(OCI_Statement *st)) } |] -- FIXME should release the CString- peekCString r+ packCString r -- | Return the error position (in terms of characters) in the SQL statement where the error occurred in case of SQL parsing error. ociGetSqlErrorPos :: Ptr OCI_Statement -> IO CUInt@@ -121,10 +121,10 @@ ociGetSQLCommand st = [C.exp| unsigned int { OCI_GetSQLCommand($(OCI_Statement *st)) } |] -- | Return the verb of the SQL command held by the statement handle.-ociGetSQLVerb :: Ptr OCI_Statement -> IO String+ociGetSQLVerb :: Ptr OCI_Statement -> IO ByteString ociGetSQLVerb st = do v <- [C.exp| const char* { OCI_GetSQLVerb($(OCI_Statement *st)) } |]- peekCString v+ packCString v -- Statement Control
src/Database/Ocilib/Timestamp.hs view
@@ -17,7 +17,6 @@ import Data.Monoid ((<>)) import Foreign.C.Types--- import Foreign.C.String import Foreign.Marshal.Utils import Foreign.Ptr import qualified Language.C.Inline as C
src/Database/Ocilib/Transaction.hs view
@@ -16,13 +16,10 @@ module Database.Ocilib.Transaction where import Data.Monoid ((<>))--- import Foreign.C.Types--- import Foreign.C.String import Foreign.Marshal.Utils import Foreign.Ptr import qualified Language.C.Inline as C import Database.Ocilib.Oci--- import Database.Ocilib.Enums C.context (C.baseCtx <> C.funCtx <> ociCtx)
stack.yaml view
@@ -1,4 +1,4 @@-resolver: lts-6.13+resolver: lts-7.2 packages: - '.' extra-deps: []