From 11a9a764005d31c806322e8bdb22fa0c1612de6b Mon Sep 17 00:00:00 2001 From: Chris Done Date: Tue, 26 Oct 2021 11:29:25 +0100 Subject: [PATCH 1/2] Switch from Int16/Word16 to CShort/CUShort --- src/Database/ODBC/Internal.hs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Database/ODBC/Internal.hs b/src/Database/ODBC/Internal.hs index 23fd968..c0a2e80 100644 --- a/src/Database/ODBC/Internal.hs +++ b/src/Database/ODBC/Internal.hs @@ -58,7 +58,6 @@ import qualified Data.ByteString.Unsafe as S import Data.Coerce import Data.Data import Data.Hashable -import Data.Int import Data.String import Data.Text (Text) import qualified Data.Text as T @@ -81,13 +80,13 @@ newtype Connection = Connection -- throw this exception type. data ODBCException = UnsuccessfulReturnCode !String - !Int16 + !CShort !String -- ^ An ODBC operation failed with the given return code. | AllocationReturnedNull !String -- ^ Allocating an ODBC resource failed. | UnknownDataType !String - !Int16 + !CShort -- ^ An unsupported/unknown data type was returned from the ODBC -- driver. | DatabaseIsClosed !String @@ -577,7 +576,7 @@ fetchStatementRows dbc stmt = do else pure [] -- | Describe the given column by its integer index. -describeColumn :: Ptr EnvAndDbc -> SQLHSTMT s -> Int16 -> IO Column +describeColumn :: Ptr EnvAndDbc -> SQLHSTMT s -> CShort -> IO Column describeColumn dbPtr stmt i = T.useAsPtr (T.replicate 1000 (fromString "0")) @@ -1013,7 +1012,7 @@ newtype SQLPOINTER = SQLPOINTER (Ptr SQLPOINTER) -- | A type that maps to https://docs.microsoft.com/en-us/sql/odbc/reference/appendixes/c-data-types newtype SQLCTYPE = - SQLCTYPE Int16 + SQLCTYPE SQLSMALLINT deriving (Show, Eq, Storable, Integral, Enum, Real, Num, Ord) -- https://github.com/Microsoft/ODBC-Specification/blob/753d7e714b7eab9eaab4ad6105fdf4267d6ad6f6/Windows/inc/sqltypes.h#L152 @@ -1021,16 +1020,16 @@ newtype RETCODE = RETCODE Int16 deriving (Show, Eq) -- https://github.com/Microsoft/ODBC-Specification/blob/753d7e714b7eab9eaab4ad6105fdf4267d6ad6f6/Windows/inc/sqltypes.h#L89 -newtype SQLUSMALLINT = SQLUSMALLINT Word16 deriving (Show, Eq, Storable, Integral, Enum, Real, Num, Ord) +newtype SQLUSMALLINT = SQLUSMALLINT CUShort deriving (Show, Eq, Storable, Integral, Enum, Real, Num, Ord) -- https://github.com/Microsoft/ODBC-Specification/blob/753d7e714b7eab9eaab4ad6105fdf4267d6ad6f6/Windows/inc/sqltypes.h#L52..L52 -newtype SQLUCHAR = SQLUCHAR Word8 deriving (Show, Eq, Storable) +newtype SQLUCHAR = SQLUCHAR CUChar deriving (Show, Eq, Storable) -- https://github.com/Microsoft/ODBC-Specification/blob/753d7e714b7eab9eaab4ad6105fdf4267d6ad6f6/Windows/inc/sqltypes.h#L52..L52 newtype SQLCHAR = SQLCHAR CChar deriving (Show, Eq, Storable) -- https://github.com/Microsoft/ODBC-Specification/blob/753d7e714b7eab9eaab4ad6105fdf4267d6ad6f6/Windows/inc/sqltypes.h#L88 -newtype SQLSMALLINT = SQLSMALLINT Int16 deriving (Show, Eq, Storable, Num, Integral, Enum, Ord, Real) +newtype SQLSMALLINT = SQLSMALLINT CShort deriving (Show, Eq, Storable, Num, Integral, Enum, Ord, Real) -- https://github.com/Microsoft/ODBC-Specification/blob/753d7e714b7eab9eaab4ad6105fdf4267d6ad6f6/Windows/inc/sqltypes.h#L64 newtype SQLLEN = SQLLEN Int64 deriving (Show, Eq, Storable, Num) From 27b3c97ff52d5b473324b5bfe2f99b71714d2359 Mon Sep 17 00:00:00 2001 From: Chris Done Date: Tue, 26 Oct 2021 11:32:02 +0100 Subject: [PATCH 2/2] Switch to CShort for RETCODE --- src/Database/ODBC/Internal.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Database/ODBC/Internal.hs b/src/Database/ODBC/Internal.hs index c0a2e80..6c783c2 100644 --- a/src/Database/ODBC/Internal.hs +++ b/src/Database/ODBC/Internal.hs @@ -1016,7 +1016,7 @@ newtype SQLCTYPE = deriving (Show, Eq, Storable, Integral, Enum, Real, Num, Ord) -- https://github.com/Microsoft/ODBC-Specification/blob/753d7e714b7eab9eaab4ad6105fdf4267d6ad6f6/Windows/inc/sqltypes.h#L152 -newtype RETCODE = RETCODE Int16 +newtype RETCODE = RETCODE CShort deriving (Show, Eq) -- https://github.com/Microsoft/ODBC-Specification/blob/753d7e714b7eab9eaab4ad6105fdf4267d6ad6f6/Windows/inc/sqltypes.h#L89