Update of /cvsroot/htoolkit/HSQL/PostgreSQL/Database/HSQL
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7000/PostgreSQL/Database/HSQL
Modified Files:
PostgreSQL.hsc
Log Message:
Another way to handle null values in HSQL. Not tested yet.
Index: PostgreSQL.hsc
===================================================================
RCS file: /cvsroot/htoolkit/HSQL/PostgreSQL/Database/HSQL/PostgreSQL.hsc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** PostgreSQL.hsc 17 Jun 2005 06:47:08 -0000 1.1
--- PostgreSQL.hsc 12 Dec 2005 15:21:56 -0000 1.2
***************
*** 209,213 ****
modifyMVar tupleIndex (\index -> return (index+1,index < countTuples-1))
! getColValue :: PGresult -> MVar Int -> Int -> Int -> FieldDef -> (SqlType -> CString -> Int -> IO (Maybe a)) -> IO (Maybe a)
getColValue pRes tupleIndex countTuples colNumber (name,sqlType,nullable) f = do
index <- readMVar tupleIndex
--- 209,213 ----
modifyMVar tupleIndex (\index -> return (index+1,index < countTuples-1))
! getColValue :: PGresult -> MVar Int -> Int -> Int -> FieldDef -> (FieldDef -> CString -> Int -> IO a) -> IO a
getColValue pRes tupleIndex countTuples colNumber (name,sqlType,nullable) f = do
index <- readMVar tupleIndex
***************
*** 215,224 ****
isnull <- pqGetisnull pRes index colNumber
if isnull == 1
! then return Nothing
else do
pStr <- pqGetvalue pRes index colNumber
strLen <- strlen pStr
! mb_value <- f sqlType pStr strLen
! case mb_value of
! Just v -> return (Just v)
! Nothing -> throwDyn (SqlBadTypeCast name sqlType)
--- 215,221 ----
isnull <- pqGetisnull pRes index colNumber
if isnull == 1
! then f sqlType nullPtr 0
else do
pStr <- pqGetvalue pRes index colNumber
strLen <- strlen pStr
! f sqlType pStr strLen
|