| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Hmssql.Tds.Reader
Description
A row decoder compiled for a result set, and how a row that spans two
packets reaches its decoder. The response holds the suspended recipe, and
the decoder's RowRead holds only a slot for the row's result; a row that
completes within one packet never touches the slot.
Synopsis
- data CompiledRow a = CompiledRow {
- rowPrepare :: Int -> Prepared (Parser a)
- data Prepared a = Prepared a
- rowRecipe :: CompiledRow a -> Int -> Parser (Either ReadFailure a)
- rowReader :: CompiledRow a -> Int -> Parser a
- data ReadFailure
- data RowRead a
- newRowRead :: Int -> CompiledRow a -> IO (RowRead a)
- wholeRows :: RowRead Row
- discardRows :: RowRead ()
- drainingRows :: RowRead ()
- skippedAs :: RowRead a -> Maybe a
Documentation
data CompiledRow a Source #
A row decoder compiled against a result set's columns.
Constructors
| CompiledRow | |
Fields
| |
A value built once and then used many times, such as a row's recipe, which is prepared once for a result set and then read for each row.
Constructors
| Prepared a |
rowRecipe :: CompiledRow a -> Int -> Parser (Either ReadFailure a) Source #
The row's recipe, given the bound on allocating ahead of a value's bytes. A
Left is a failure of this row alone, with the row fully read: the driver stops the
batch there and a DecodeFailed is thrown once the response is drained. An
exception thrown by the recipe means the bytes can't be read, and it breaks the
connection. Prepare it once per result set and use it for each row.
rowReader :: CompiledRow a -> Int -> Parser a Source #
The row's recipe with its failure left in the recipe, for a driver that takes it
with runParserAt. The connection's driver reads rows this way, so that a row
costs no Right.
data ReadFailure Source #
Why a value or a row was read past without a result.
Constructors
| DecodeFailed !DecodeError | The value was read but can't be decoded, or the row doesn't have the columns its decoder expects. |
| ReadDiscarded | The response is being thrown away, so the value wasn't assembled and its consumer didn't run. Nothing reads this result. |
Instances
| Show ReadFailure Source # | |
Defined in Hmssql.Tds.Parser Methods showsPrec :: Int -> ReadFailure -> ShowS # show :: ReadFailure -> String # showList :: [ReadFailure] -> ShowS # | |
What to do with rows, as a response is read.
Constructors
| ReadRows !(Parser a) !(IORef (Maybe (Either ReadFailure a))) | Decode each row: the prepared recipe ( |
| WholeRows (Row -> a) | Keep each row as a |
| DiscardRows a | Skip the rows and keep the other tokens, output parameters included. |
| DrainRows a | Throw the whole response away, the values of output parameters included. |
| StopAtRow | Stop before a row, consuming nothing. A request waiting behind a reset reads only the reset's leading tokens, and reading a row there would mean keeping it for the consumer and parsing it a second time. |
newRowRead :: Int -> CompiledRow a -> IO (RowRead a) Source #
Read rows with this compiled row decoder, given the bound on allocating ahead
of a value's bytes. One RowRead serves a whole result set.
discardRows :: RowRead () Source #
Skip the rows, keeping the other tokens.
drainingRows :: RowRead () Source #
Discard token payloads too, including large RETURNVALUE values.