hmssql
Safe HaskellNone
LanguageHaskell2010

Hmssql.Tds.Value

Description

How a value is delimited on the wire, apart from packets and from what is done with the value. A value is read in two steps: cellHead reads its delimiter, and the caller then says what it wants of the payload, which is all of it (wholeValueBytes), its pieces as they arrive (valueStream) or nothing (skipValue).

Synopsis

Documentation

data Row Source #

A row's values, each read whole into bytes of its own, for the token-level interface (TRow). A typed row decoder never builds one.

Instances

Instances details
Show Row Source # 
Instance details

Defined in Hmssql.Tds.Value

Methods

showsPrec :: Int -> Row -> ShowS #

show :: Row -> String #

showList :: [Row] -> ShowS #

Eq Row Source # 
Instance details

Defined in Hmssql.Tds.Value

Methods

(==) :: Row -> Row -> Bool #

(/=) :: Row -> Row -> Bool #

rowColumnCount :: Row -> Int Source #

How many columns the row has.

rowCell :: Row -> Int -> RawBytes Source #

The value at a column, counted from 0; error past the last.

rowCellLength :: Row -> Int -> Int Source #

The length of the value at a column, or -1 for NULL.

rowValues :: Row -> [RawBytes] Source #

The row's values, in column order.

rowFromValues :: [RawBytes] -> Row Source #

A row from its values.

data ColumnShape Source #

How a column's values are delimited, chosen once from its metadata. A value with no delimiter of its own (a fixed width, or no value at all) keeps its Cell here, so that every row shares it.

Instances

Instances details
Show ColumnShape Source # 
Instance details

Defined in Hmssql.Tds.Value

Eq ColumnShape Source # 
Instance details

Defined in Hmssql.Tds.Value

data Cell Source #

What a value's delimiter said: NULL, a known length, or a PLP value whose total length may or may not be known. The payload still follows.

Constructors

NullCell 
Sized !Int 
Unsized !(Maybe Word64) 

Instances

Instances details
Show Cell Source # 
Instance details

Defined in Hmssql.Tds.Value

Methods

showsPrec :: Int -> Cell -> ShowS #

show :: Cell -> String #

showList :: [Cell] -> ShowS #

Eq Cell Source # 
Instance details

Defined in Hmssql.Tds.Value

Methods

(==) :: Cell -> Cell -> Bool #

(/=) :: Cell -> Cell -> Bool #

cellLength :: Cell -> Maybe Int64 Source #

The value's declared length, if it has one that fits an Int64.

rowShape :: TypeInfo -> ColumnShape Source #

How a column's value is delimited in a ROW: as valueShape says, with a text pointer and timestamp in front of a legacy text, ntext or image value.

valueShape :: TypeInfo -> ColumnShape Source #

How a RETURNVALUE's value is delimited: as a column's, except that a legacy text, ntext or image value has no text pointer in front of it.

cellHead :: ColumnShape -> Parser Cell Source #

Read a value's delimiter. Each form has its own way to say NULL.

valueStream :: Cell -> Stream (Of ByteString) Parser () Source #

The value's payload as it arrives, in pieces. A PLP value's chunk headers are read here and never appear in the stream.

boundedValue :: Int -> Int -> Cell -> Parser (Either (Stream (Of ByteString) Parser ()) WholeValue) Source #

A value for a consumer: read whole (Right) if it is at most this many bytes, given the allocation bound of wholeValueBytes and the limit, or else its payload as it arrives (Left, as valueStream). A PLP value whose total isn't known (xml, and json) is read a chunk at a time until it ends within the limit; once a chunk would take it past, the stream starts with the chunks already read, so at most the limit is ever held. A whole value is Owned unless it lay in one payload, and a drain that takes over while it is read gives DiscardedValue.

data WholeValue Source #

A value read whole: NULL, present, or discarded because a drain took over the response while the value was being assembled.

wholeValueBytes :: Int -> Cell -> Parser WholeValue Source #

Read all of a value: a slice if it lies in the buffer, otherwise one buffer of its own.

ownedValue :: Int -> Cell -> Parser RawBytes Source #

Read all of a value into bytes of its own, as an output parameter's value is kept. A value discarded by a drain comes back as empty bytes, which only the drain sees.

skipValue :: Cell -> Parser () Source #

Pass over a value's payload.

foldValue :: (a -> Int -> Parser a) -> a -> Cell -> Parser a Source #

Fold over the pieces of a value's payload: one piece for a sized value, or a PLP value's chunks, with the chunk headers read here. The step must consume exactly the length it is given, whether it reads, collects or skips.

rowBitmap :: Int -> Parser ByteString Source #

A row's token byte, and an NBCROW's null bitmap. Empty means a ROW, where each delimiter says for itself whether its value is NULL.

columnNull :: ByteString -> Int -> Bool Source #

Whether the bitmap marks this column NULL, in which case it has no bytes at all.

cellAt :: ByteString -> Int -> ColumnShape -> Parser Cell Source #

Read one column's delimiter, including its NBCROW null bit.

skipCells :: ByteString -> [(Int, ColumnShape)] -> Parser () Source #

Read past these columns of a row, given as their indexes and shapes.