module Database.PostgreSQL.Simple.Vector.Unboxed where
import Database.PostgreSQL.Simple (Connection, formatQuery, formatMany)
import Database.PostgreSQL.Simple.FromRow (FromRow(..))
import Database.PostgreSQL.Simple.ToRow (ToRow(..))
import Database.PostgreSQL.Simple.Internal (RowParser, exec)
import Database.PostgreSQL.Simple.Internal.PQResultUtils
import Database.PostgreSQL.Simple.Types ( Query (..) )
import qualified Data.Vector.Unboxed as VU
query :: (ToRow q, FromRow r, VU.Unbox r) => Connection -> Query -> q -> IO (VU.Vector r)
query :: Connection -> Query -> q -> IO (Vector r)
query = RowParser r -> Connection -> Query -> q -> IO (Vector r)
forall q r.
(ToRow q, Unbox r) =>
RowParser r -> Connection -> Query -> q -> IO (Vector r)
queryWith RowParser r
forall a. FromRow a => RowParser a
fromRow
query_ :: (FromRow r, VU.Unbox r) => Connection -> Query -> IO (VU.Vector r)
query_ :: Connection -> Query -> IO (Vector r)
query_ = RowParser r -> Connection -> Query -> IO (Vector r)
forall r.
Unbox r =>
RowParser r -> Connection -> Query -> IO (Vector r)
queryWith_ RowParser r
forall a. FromRow a => RowParser a
fromRow
queryWith :: (ToRow q, VU.Unbox r) => RowParser r -> Connection -> Query -> q -> IO (VU.Vector r)
queryWith :: RowParser r -> Connection -> Query -> q -> IO (Vector r)
queryWith RowParser r
parser Connection
conn Query
template q
qs = do
Result
result <- Connection -> ByteString -> IO Result
exec Connection
conn (ByteString -> IO Result) -> IO ByteString -> IO Result
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Connection -> Query -> q -> IO ByteString
forall q. ToRow q => Connection -> Query -> q -> IO ByteString
formatQuery Connection
conn Query
template q
qs
RowParser r -> Connection -> Query -> Result -> IO (Vector r)
forall r.
Unbox r =>
RowParser r -> Connection -> Query -> Result -> IO (Vector r)
finishQueryWithVU RowParser r
parser Connection
conn Query
template Result
result
queryWith_ :: VU.Unbox r => RowParser r -> Connection -> Query -> IO (VU.Vector r)
queryWith_ :: RowParser r -> Connection -> Query -> IO (Vector r)
queryWith_ RowParser r
parser Connection
conn q :: Query
q@(Query ByteString
que) = do
Result
result <- Connection -> ByteString -> IO Result
exec Connection
conn ByteString
que
RowParser r -> Connection -> Query -> Result -> IO (Vector r)
forall r.
Unbox r =>
RowParser r -> Connection -> Query -> Result -> IO (Vector r)
finishQueryWithVU RowParser r
parser Connection
conn Query
q Result
result
returning :: (ToRow q, FromRow r, VU.Unbox r) => Connection -> Query -> [q] -> IO (VU.Vector r)
returning :: Connection -> Query -> [q] -> IO (Vector r)
returning = RowParser r -> Connection -> Query -> [q] -> IO (Vector r)
forall q r.
(ToRow q, Unbox r) =>
RowParser r -> Connection -> Query -> [q] -> IO (Vector r)
returningWith RowParser r
forall a. FromRow a => RowParser a
fromRow
returningWith :: (ToRow q, VU.Unbox r) => RowParser r -> Connection -> Query -> [q] -> IO (VU.Vector r)
returningWith :: RowParser r -> Connection -> Query -> [q] -> IO (Vector r)
returningWith RowParser r
_ Connection
_ Query
_ [] = Vector r -> IO (Vector r)
forall (m :: * -> *) a. Monad m => a -> m a
return Vector r
forall a. Unbox a => Vector a
VU.empty
returningWith RowParser r
parser Connection
conn Query
q [q]
qs = do
Result
result <- Connection -> ByteString -> IO Result
exec Connection
conn (ByteString -> IO Result) -> IO ByteString -> IO Result
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Connection -> Query -> [q] -> IO ByteString
forall q. ToRow q => Connection -> Query -> [q] -> IO ByteString
formatMany Connection
conn Query
q [q]
qs
RowParser r -> Connection -> Query -> Result -> IO (Vector r)
forall r.
Unbox r =>
RowParser r -> Connection -> Query -> Result -> IO (Vector r)
finishQueryWithVU RowParser r
parser Connection
conn Query
q Result
result