packages feed

DSH 0.6.1 → 0.6.2

raw patch · 4 files changed

+22/−41 lines, 4 files

Files

DSH.cabal view
@@ -1,5 +1,5 @@ Name:                DSH-Version:             0.6.1+Version:             0.6.2 Synopsis:            Database Supported Haskell Description:   This is a Haskell library for database-supported program execution. Using
examples/Example2.hs view
@@ -21,14 +21,14 @@   ]  query :: Q [(Text, Integer)]-query = [$qc| tuple (the dept, sum salary)-            | (name, dept, salary) <- employees-            , then group by dept-            , then sortWith by (sum salary)-            , then take 5 |]+query = [qc| tuple (the dept, sum salary)+           | (name, dept, salary) <- employees+          , then group by dept+          , then sortWith by (sum salary)+          , then take 5 |]  getConn :: IO Connection-getConn = connectPostgreSQL "user = 'postgres' password = 'haskell98' host = 'localhost' dbname = 'ferry'"+getConn = connectPostgreSQL "user = 'giorgidz' password = '' host = 'localhost' dbname = 'giorgidz'"  main :: IO () main = do
src/Database/DSH/Combinators.hs view
@@ -336,9 +336,9 @@  -- 'QA', 'TA' and 'View' instances for tuples up to the defined length. -$(generateDeriveTupleQARange   3 12)-$(generateDeriveTupleTARange   3 12)-$(generateDeriveTupleViewRange 3 12)+$(generateDeriveTupleQARange   3 16)+$(generateDeriveTupleTARange   3 16)+$(generateDeriveTupleViewRange 3 16)   -- * Missing Combinators
src/Database/DSH/Compile.hs view
@@ -13,25 +13,12 @@ import Control.Monad.Reader import Control.Exception (evaluate) -import Control.Concurrent.MVar-import System.IO.Unsafe (unsafePerformIO)- import qualified Text.XML.HaXml as X import Text.XML.HaXml (Content(..), AttValue(..), tag, deep, children, xmlParse, Document(..))  import Database.HDBC import Data.Convertible ---- | This is a global synchronisation variable used to gouard calls to the--- Pathfinder C library. The C library appears not to be thread safe and this--- variable is used to make sure that only one pathfinder call is made at time--- even when a number parallel calls are made to the DSH's fromQ query--- evaluator.-{-# NOINLINE globalMVar #-}-globalMVar :: MVar ()-globalMVar = unsafePerformIO (newEmptyMVar)- -- | Wrapper type with phantom type for algebraic plan -- The type variable represents the type of the result of the plan newtype AlgebraXML a = Algebra String@@ -67,27 +54,21 @@                         runSQL c $ extractSQL sql  algToAlg :: AlgebraXML a -> IO (AlgebraXML a)-algToAlg (Algebra s) = do-                        putMVar  globalMVar ()-                        r <- pathfinder s [] OutputXml-                        takeMVar globalMVar-                        case r of-                           (Right sql) -> return $ Algebra sql-                           (Left err) -> error $ "Pathfinder compilation for input: \n"-                                                   ++ s ++ "\n failed with error: \n"-                                                   ++ err+algToAlg (Algebra s) = do r <- pathfinder s [] OutputXml+                          case r of+                            (Right sql) -> return $ Algebra sql+                            (Left err)  -> error $ "Pathfinder compilation for input: \n"+                                                     ++ s ++ "\n failed with error: \n"+                                                     ++ err  -- | Translate an algebraic plan into SQL code using Pathfinder algToSQL :: AlgebraXML a -> IO (SQLXML a)-algToSQL (Algebra s) = do-                         putMVar  globalMVar ()-                         r <- pathfinder s [] OutputSql-                         takeMVar globalMVar-                         case r of-                            (Right sql) -> return $ SQL sql-                            (Left err) -> error $ "Pathfinder compilation for input: \n"-                                                    ++ s ++ "\n failed with error: \n"-                                                    ++ err+algToSQL (Algebra s) = do r <- pathfinder s [] OutputSql+                          case r of+                             (Right sql) -> return $ SQL sql+                             (Left err) -> error $ "Pathfinder compilation for input: \n"+                                                     ++ s ++ "\n failed with error: \n"+                                                     ++ err  -- | Extract the SQL queries from the XML structure generated by pathfinder extractSQL :: SQLXML a -> QueryBundle a