hmssql
Safe HaskellNone
LanguageHaskell2010

Hmssql.Tds.Parameter

Description

A parameter's value, which is in memory, lazy, or read from a source as it is sent, and how a value is written.

Synopsis

Documentation

data ParamValue Source #

An in-memory value (Nothing is NULL), lazy bytes read as they are sent, or a source run as it is sent. A request holding either of the last two can be sent only once; a query builds a new request each time it is sent.

The constructors are public so that libraries can inspect and build values.

Instances

Instances details
Show ParamValue Source # 
Instance details

Defined in Hmssql.Tds.Parameter

newtype Source a Source #

Where a streamed parameter's bytes come from. It is a function of what consumes the stream, so a resource can be scoped to exactly the send, for example with withBinaryFile. A bare stream couldn't scope one, and a second send would run it from wherever it had got to.

Constructors

Source (forall r. (Stream (Of a) IO () -> IO r) -> IO r) 

sourceOf :: Stream (Of a) IO () -> Source a Source #

Use an existing stream. Holding on to the stream yourself keeps whatever it has produced alive, and a stream can be sent only once.

sourceIO :: IO (Stream (Of a) IO ()) -> Source a Source #

A stream made by this action when sending starts. For a resource to release after the send, use the Source constructor.

paramValueProblem :: TypeInfo -> ParamValue -> Maybe String Source #

Why a value can't be sent in this type, if it can't. A value sent as it is read has no length ahead of time, so only a PLP type can carry it.

streamed :: ParamValue -> Bool Source #

Whether the value is sent as it is read, so it isn't in memory to check.

writeParamValue :: PacketWriter -> TypeInfo -> ParamValue -> IO () Source #

Write a parameter's value, which has been checked already (paramValueProblem). A lazy or streamed value is written as a PLP value of unknown total length, in chunks of at most 8000 bytes, with the source's empty chunks left out; a UTF-16 source must end on a code unit boundary.

writeParamValueWith :: PacketWriter -> Builder -> TypeInfo -> ParamValue -> IO () Source #

writeParamValue, with what comes before the value, such as the parameter's header, in the same Builder. A BYTE-length scalar is poked straight after the header rather than composed with it; every other value runs the writer once for both.