| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Hmssql.Tds.TypeInfo
Description
Column/parameter type descriptors and the length-prefixed value encodings that go with them.
Synopsis
- data TypeInfo
- = TINull
- | TIBit
- | TIInt1
- | TIInt2
- | TIInt4
- | TIInt8
- | TIMoney4
- | TIMoney8
- | TIDateTime4
- | TIDateTime8
- | TIFlt4
- | TIFlt8
- | TIBitN
- | TIIntN !Word8
- | TIMoneyN !Word8
- | TIDateTimeN !Word8
- | TIFltN !Word8
- | TIGuid
- | TIDecimalN !Precision !Scale
- | TINumericN !Precision !Scale
- | TIDateN
- | TITimeN !Scale
- | TIDateTime2N !Scale
- | TIDateTimeOffsetN !Scale
- | TIBigChar !Word16 !Collation
- | TIBigVarChar !Word16 !Collation
- | TIText !Word32 !Collation
- | TINChar !Word16 !Collation
- | TINVarChar !Word16 !Collation
- | TINText !Word32 !Collation
- | TIBigBinary !Word16
- | TIBigVarBinary !Word16
- | TIImage !Word32
- | TIXml !(Maybe XmlSchema)
- | TISqlVariant !Word32
- | TIUdt !UdtInfo
- data XmlSchema = XmlSchema {
- xmlDbName :: !Text
- xmlOwningSchema :: !Text
- xmlSchemaCollection :: !Text
- data UdtInfo = UdtInfo {
- udtMaxLength :: !Word16
- udtDbName :: !Text
- udtSchemaName :: !Text
- udtTypeName :: !Text
- udtAssemblyQualifiedName :: !Text
- maxLength :: Word16
- type RawBytes = Maybe ByteString
- readDecimalInfo :: (Precision -> Scale -> a) -> Parser a
- readTypeInfo :: Parser TypeInfo
- putTypeInfo :: TdsContext -> TypeInfo -> Put
- putValue :: TdsContext -> TypeInfo -> RawBytes -> Put
- putValueUnchecked :: TypeInfo -> RawBytes -> Put
- data LengthKind
- = Fixed !Int
- | ByteLen
- | UShortCharBin
- | LongLen
- | VariantLen
- | Plp
- | NoValue
- lengthKind :: TypeInfo -> LengthKind
- valueProblem :: TypeInfo -> RawBytes -> Maybe String
- typeInfoProblem :: TypeInfo -> Maybe String
- typeInfoSqlName :: TypeInfo -> Text
- isNullableType :: TypeInfo -> Bool
- writeTypeInfo :: TypeInfo -> Builder
- writeValue :: TypeInfo -> RawBytes -> Builder
Documentation
A type as the wire describes it (MS-TDS 2.2.5.4 TYPE_INFO): the
token's type byte with its length, precision and scale, or collation,
as the server sends it in COLMETADATA and a client sends it for a
parameter. The wire has fewer types than T-SQL (int arrives as
TIIntN 4 or TIInt4; json and vector as character types):
Hmssql.SqlType names the declared type. RawParam takes one to send
a value with a wire type of your choosing.
Constructors
Instances
The schema collection of a typed xml column or parameter.
Constructors
| XmlSchema | |
Fields
| |
MS-TDS 2.2.5.5.2 UDT_INFO, as the server sends it in COLMETADATA and RETURNVALUE.
Constructors
| UdtInfo | |
Fields
| |
type RawBytes = Maybe ByteString Source #
An undecoded column or parameter value; Nothing is SQL NULL.
readDecimalInfo :: (Precision -> Scale -> a) -> Parser a Source #
Precision and scale of decimal / numeric, which must satisfy
1 <= precision <= 38 and scale <= precision (MS-TDS 2.2.5.5.1.3).
readTypeInfo :: Parser TypeInfo Source #
A column's or parameter's TYPE_INFO, as COLMETADATA and RETURNVALUE carry it.
putTypeInfo :: TdsContext -> TypeInfo -> Put Source #
TYPE_INFO as a Put: writeTypeInfo.
putValue :: TdsContext -> TypeInfo -> RawBytes -> Put Source #
Write a value as it appears in RPC parameters. Fails (with error)
if valueProblem finds invalid framing, including a non-NULL empty
payload whose length would encode NULL. This does not validate the
type declaration or the payload's semantic value.
putValueUnchecked :: TypeInfo -> RawBytes -> Put Source #
putValue without the check, for a value checked with
valueProblem. Invalid lengths can wrap or encode NULL (writeValue).
data LengthKind Source #
How a type's values are delimited on the wire (lengthKind).
Constructors
| Fixed !Int | |
| ByteLen | 1-byte length, 0 = NULL |
| UShortCharBin | 2-byte length, 0xFFFF = NULL |
| LongLen | 4-byte length, 0xFFFFFFFF = NULL |
| VariantLen | 4-byte length, 0 = NULL ( |
| Plp | partially length-prefixed |
| NoValue |
lengthKind :: TypeInfo -> LengthKind Source #
How values of the type are delimited.
valueProblem :: TypeInfo -> RawBytes -> Maybe String Source #
Why a value can't be sent as a parameter of this type, if it can't:
a lengthProblem, or an empty value of a type whose length prefix uses 0
for NULL (every BYTE-length type, and sql_variant), which the server
would read as NULL.
typeInfoProblem :: TypeInfo -> Maybe String Source #
Why a parameter can't have this type, if it can't: a precision or
scale SQL Server doesn't have (a decimal or numeric precision outside
1 through 38 or a scale above the precision, MS-TDS 2.2.5.5.1.3; a
time, datetime2 or datetimeoffset scale above 7, 2.2.5.4.2), XML
schema names too long for their length prefixes, or a CLR user-defined
type, which hmssql doesn't send.
typeInfoSqlName :: TypeInfo -> Text Source #
The T-SQL type declaration for a parameter of this type, as used in the
@params argument of sp_executesql.
isNullableType :: TypeInfo -> Bool Source #
Whether the wire encoding of this type can carry NULL.
The wire layouts, written to any sink
writeTypeInfo :: TypeInfo -> Builder Source #
TYPE_INFO (MS-TDS 2.2.5.6): the type byte, then what the type carries (a length, a precision and scale, a collation, names).
writeValue :: TypeInfo -> RawBytes -> Builder Source #
A value as RPC parameters carry it, after its TYPE_INFO: nothing for
a type with no value, the bytes of a fixed-length type, else a length
prefix (whose NULL spelling depends on the kind, LengthKind) and the
bytes, or PLP chunks. Nothing is checked here: a value too long for its
length prefix wraps, and an empty BYTE-length or sql_variant payload is
written as NULL. putValue checks with valueProblem first; this is for
values checked already.