hmssql
Safe HaskellNone
LanguageHaskell2010

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

Documentation

data CompiledRow a Source #

A row decoder compiled against a result set's columns.

Constructors

CompiledRow 

Fields

  • rowPrepare :: Int -> Prepared (Parser a)

    The row's recipe, given the bound on allocating ahead of a value's bytes. A row that doesn't decode fails the recipe (failValue) once the row has been read, and the driver takes the failure (runParserAt); rowRecipe takes it out with the failure caught.

data Prepared a Source #

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

Instances details
Show ReadFailure Source # 
Instance details

Defined in Hmssql.Tds.Parser

data RowRead a Source #

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 (rowReader), which serves the whole result set, and the slot through which a row suspended across packets delivers its result.

WholeRows (Row -> a)

Keep each row as a Row of raw cells, for the token-level interface.

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.

wholeRows :: RowRead Row Source #

Every row as a Row.

discardRows :: RowRead () Source #

Skip the rows, keeping the other tokens.

drainingRows :: RowRead () Source #

Discard token payloads too, including large RETURNVALUE values.

skippedAs :: RowRead a -> Maybe a Source #

The value associated with a row that is deliberately skipped.