Permalink
Browse files

Revert "Unicode support"

This reverts commit a02fb79.

It requires encoding, which isn't in Debian.  Trying to get this
version out.  Will re-apply later.
  • Loading branch information...
jgoerzen committed Dec 30, 2008
1 parent 04ef27e commit 8a0ee39042db1ed1a5db1ff771db9b977a63b2db
Showing with 16 additions and 22 deletions.
  1. +1 −3 Database/HDBC/PostgreSQL/Connection.hsc
  2. +14 −18 Database/HDBC/PostgreSQL/Statement.hsc
  3. +1 −1 HDBC-postgresql.cabal
@@ -69,7 +69,7 @@ mkConn args conn = withConn conn $
protover <- pqprotocolVersion cconn
serverver <- pqserverVersion cconn
let clientver = #{const_str PG_VERSION}
- let rconn = Impl.Connection {
+ return $ Impl.Connection {
Impl.disconnect = fdisconnect conn children,
Impl.commit = fcommit conn children,
Impl.rollback = frollback conn children,
@@ -84,8 +84,6 @@ mkConn args conn = withConn conn $
Impl.dbTransactionSupport = True,
Impl.getTables = fgetTables conn children,
Impl.describeTable = fdescribeTable conn children}
- quickQuery rconn "SET client_encoding TO utf8;" []
- return rconn
--------------------------------------------------
-- Guts here
@@ -35,10 +35,6 @@ import Data.List
import Data.Word
import Data.Maybe
import Data.Ratio
-import Data.ByteString(packCString, ByteString)
-import Data.Encoding
-import Data.Encoding.UTF8
-import Data.Encoding.ASCII
import Control.Exception
import System.IO
import System.Time
@@ -174,7 +170,7 @@ ffetchrow sstate = modifyMVar (nextrowmv sstate) dofetchrow
then return SqlNull
else do text <- pqgetvalue p row icol
coltype <- liftM oidToColType $ pqftype p icol
- s <- packCString text
+ s <- peekCString text
makeSqlValue coltype s
fgetcoldef cstmt =
@@ -259,7 +255,7 @@ foreign import ccall unsafe "libpq-fe.h PQftype"
-- Make a SqlValue for the passed column type and string value, where it is assumed that the value represented is not the Sql null value.
-- The IO Monad is required only to obtain the local timezone for interpreting date/time values without an explicit timezone.
-makeSqlValue :: SqlTypeId -> ByteString -> IO SqlValue
+makeSqlValue :: SqlTypeId -> String -> IO SqlValue
makeSqlValue sqltypeid strval =
case sqltypeid of
@@ -269,22 +265,22 @@ makeSqlValue sqltypeid strval =
tid == SqlLongVarCharT ||
tid == SqlWCharT ||
tid == SqlWVarCharT ||
- tid == SqlWLongVarCharT -> return $ SqlString $ decode UTF8 strval
+ tid == SqlWLongVarCharT -> return $ SqlString strval
tid | tid == SqlDecimalT ||
- tid == SqlNumericT -> return $ SqlRational (makeRationalFromDecimal $ decode ASCII strval)
+ tid == SqlNumericT -> return $ SqlRational (makeRationalFromDecimal strval)
tid | tid == SqlSmallIntT ||
tid == SqlTinyIntT ||
- tid == SqlIntegerT -> return $ SqlInt32 (read $ decode ASCII strval)
+ tid == SqlIntegerT -> return $ SqlInt32 (read strval)
- SqlBigIntT -> return $ SqlInteger (read $ decode ASCII strval)
+ SqlBigIntT -> return $ SqlInteger (read strval)
tid | tid == SqlRealT ||
tid == SqlFloatT ||
- tid == SqlDoubleT -> return $ SqlDouble (read $ decode ASCII strval)
+ tid == SqlDoubleT -> return $ SqlDouble (read strval)
- SqlBitT -> return $ case (decode ASCII strval) of
+ SqlBitT -> return $ case strval of
't':_ -> SqlBool True
'f':_ -> SqlBool False
'T':_ -> SqlBool True -- the rest of these are here "just in case", since they are legal as input
@@ -298,28 +294,28 @@ makeSqlValue sqltypeid strval =
tid == SqlTimestampT ||
tid == SqlUTCDateTimeT ->
do
- clockTime <- clockTimeFromISODateAndMaybeTime $ decode ASCII strval
+ clockTime <- clockTimeFromISODateAndMaybeTime strval
case clockTime of TOD epochSecs picos -> return $ SqlEpochTime epochSecs
-- Times without dates
tid | tid == SqlTimeT ||
- tid == SqlUTCTimeT -> return $ SqlTimeDiff $ secsTimeDiffFromISOTime $ decode ASCII strval
+ tid == SqlUTCTimeT -> return $ SqlTimeDiff $ secsTimeDiffFromISOTime strval
-- TODO: There's no proper way to map intervals as understood by postgres currently so we resort to SqlString.
-- E.g. a "1 month" interval is not a specific span of time that could be converted to a SqlTimeDiff.
-- A new SqlValue constructor would be needed (wrapping System.Time.TimeDiff) to really handle intervals properly.
- SqlIntervalT si -> return $ SqlString $ decode ASCII strval
+ SqlIntervalT si -> return $ SqlString strval
-- TODO: For now we just map the binary types to SqlStrings. New SqlValue constructors are needed to handle these.
tid | tid == SqlBinaryT ||
tid == SqlVarBinaryT ||
- tid == SqlLongVarBinaryT -> return $ SqlByteString strval
+ tid == SqlLongVarBinaryT -> return $ SqlString strval
- SqlGUIDT -> return $ SqlString $ decode ASCII strval
+ SqlGUIDT -> return $ SqlString strval
- SqlUnknownT s -> return $ SqlByteString strval
+ SqlUnknownT s -> return $ SqlString strval
-- Make a rational number from a decimal string representation of the number.
View
@@ -31,7 +31,7 @@ Library
--Extensions: ExistentialQuantification, AllowOverlappingInstances,
-- AllowUndecidableInstances, CPP
Extensions: ExistentialQuantification, ForeignFunctionInterface
- Build-Depends: base, mtl, HDBC>=1.1.0, parsec, encoding, bytestring
+ Build-Depends: base, mtl, HDBC>=1.1.0, parsec
if flag(splitBase)
Build-Depends: base >= 3 && < 4, old-time
else

0 comments on commit 8a0ee39

Please sign in to comment.