| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Hmssql.Tds.Client
Description
Messages sent from the client to the server.
Synopsis
- newtype Prelogin = Prelogin [PreloginOption]
- data PreloginOption
- = PLVersion !Word8 !Word8 !Word16 !Word16
- | PLEncryption !Word8
- | PLInstance !ByteString
- | PLThreadId !(Maybe Word32)
- | PLMars !Word8
- | PLTraceId !ByteString !ByteString !Word32
- | PLFedAuthRequired !Word8
- | PLNonce !ByteString
- | PLUnknown !Word8 !ByteString
- data Encryption
- encryptionWord :: Encryption -> Word8
- encryptionFromWord :: Word8 -> Maybe Encryption
- putPrelogin :: Prelogin -> Put
- getPrelogin :: Get Prelogin
- data Login7 = Login7 {
- l7Version :: !TdsVersion
- l7PacketSize :: !Word32
- l7ClientProgVer :: !Word32
- l7ClientPid :: !Word32
- l7ConnectionId :: !Word32
- l7OptionFlags1 :: !Word8
- l7OptionFlags2 :: !Word8
- l7TypeFlags :: !Word8
- l7OptionFlags3 :: !Word8
- l7TimeZone :: !Int32
- l7Collation :: !Word32
- l7HostName :: !Text
- l7UserName :: !Text
- l7Password :: !Text
- l7AppName :: !Text
- l7ServerName :: !Text
- l7LibraryName :: !Text
- l7Language :: !Text
- l7Database :: !Text
- l7ClientId :: !ByteString
- l7Features :: ![Feature]
- data Feature = Feature {
- featureId :: !Word8
- featureData :: !ByteString
- featureUtf8Support :: Feature
- featureFedAuthToken :: Bool -> Text -> Maybe ByteString -> Feature
- defaultLogin7 :: Login7
- putLogin7 :: Login7 -> Put
- login7Problem :: Login7 -> Maybe String
- obfuscatePassword :: ByteString -> ByteString
- putAllHeaders :: TdsContext -> Put
- putSqlBatch :: TdsContext -> Text -> Put
- sqlBatchProblem :: TdsContext -> Text -> Maybe String
- sqlBatchBuilder :: TdsContext -> Text -> Builder
- rpcRequestBuilder :: TdsContext -> [RpcRequest] -> Builder
- rpcParamBuilder :: RpcParam -> Builder
- allHeadersBuilder :: TdsContext -> Builder
- sqlBatchBody :: TdsContext -> Text -> ByteString
- data RpcRequest = RpcRequest {}
- data RpcProc
- = RpcProcId !Word16
- | RpcProcName !Text
- data RpcParam = RpcParam {
- rpcParamName :: !Text
- rpcParamStatus :: !Word8
- rpcParamType :: !TypeInfo
- rpcParamValue :: !ParamValue
- paramByRef :: Word8
- paramDefault :: Word8
- procSpExecuteSql :: RpcProc
- putRpcRequest :: TdsContext -> [RpcRequest] -> Put
- rpcRequestBody :: TdsContext -> [RpcRequest] -> ByteString
- rpcRequestBodyUnchecked :: TdsContext -> [RpcRequest] -> ByteString
- newRpcWriter :: [RpcRequest] -> IO (TdsContext -> PacketWriter -> IO ())
- writeRpcRequests :: TdsContext -> PacketWriter -> [RpcRequest] -> IO ()
- rpcRequestProblem :: RpcRequest -> Maybe String
- rpcParamProblem :: RpcParam -> Maybe String
- tmBeginTransactionBuilder :: TdsContext -> Word8 -> Builder
- tmBeginTransactionBody :: TdsContext -> Word8 -> ByteString
PRELOGIN
data PreloginOption Source #
One option of a PRELOGIN message.
Constructors
| PLVersion !Word8 !Word8 !Word16 !Word16 | major, minor, build, sub-build |
| PLEncryption !Word8 | |
| PLInstance !ByteString | |
| PLThreadId !(Maybe Word32) | |
| PLMars !Word8 | |
| PLTraceId !ByteString !ByteString !Word32 | |
| PLFedAuthRequired !Word8 | |
| PLNonce !ByteString | |
| PLUnknown !Word8 !ByteString |
Instances
| Show PreloginOption Source # | |
Defined in Hmssql.Tds.Client Methods showsPrec :: Int -> PreloginOption -> ShowS # show :: PreloginOption -> String # showList :: [PreloginOption] -> ShowS # | |
| Eq PreloginOption Source # | |
Defined in Hmssql.Tds.Client Methods (==) :: PreloginOption -> PreloginOption -> Bool # (/=) :: PreloginOption -> PreloginOption -> Bool # | |
data Encryption Source #
How much of the connection is encrypted (connectEncryption).
The first four are the values of the ENCRYPTION option of PRELOGIN, where
the client and the server negotiate. EncryptStrict is TDS 8.0, which
never negotiates.
Constructors
| EncryptOff | Encrypt the login packet only, or the whole session if the server requires it. If the server doesn't support encryption at all, nothing is encrypted, not even the password. (0x00) |
| EncryptOn | Encrypt the whole session, and fail if the server doesn't support encryption. The default. (0x01) |
| EncryptNotSup | Encrypt nothing, and fail if the server requires encryption. (0x02) |
| EncryptReq | Encryption required. It behaves as |
| EncryptStrict | TDS 8.0: TLS from the first byte, before any PRELOGIN, and a failure against a server that doesn't support TDS 8.0. (0x04, which is never sent, since there is no PRELOGIN to send it in) |
Instances
| Show Encryption Source # | |
Defined in Hmssql.Tds.Client Methods showsPrec :: Int -> Encryption -> ShowS # show :: Encryption -> String # showList :: [Encryption] -> ShowS # | |
| Eq Encryption Source # | |
Defined in Hmssql.Tds.Client | |
encryptionWord :: Encryption -> Word8 Source #
putPrelogin :: Prelogin -> Put Source #
LOGIN7
A LOGIN7 message, which putLogin7 writes; start from defaultLogin7.
Constructors
| Login7 | |
Fields
| |
A LOGIN7 feature extension. MS-TDS 2.2.6.4 FeatureExt
Constructors
| Feature | |
Fields
| |
featureUtf8Support :: Feature Source #
Tell the server we can handle UTF-8 collations.
featureFedAuthToken :: Bool -> Text -> Maybe ByteString -> Feature Source #
Federated authentication with an access token the caller obtained (MS-TDS calls the library "Security Token", 0x01): the token, UTF-16 encoded, goes in LOGIN7 and the server validates it; there is no further exchange, unlike the MSAL library's, where the server first names the token issuer (FEDAUTHINFO).
The first argument echoes the server's PRELOGIN answer to the FEDAUTHREQUIRED option (the client must send that option to use this feature), and the last is the nonce from that answer, if the server sent one, which it only does when the client sent one.
defaultLogin7 :: Login7 Source #
TDS 7.4, 4096-byte packets, empty names, and the UTF-8 feature.
login7Problem :: Login7 -> Maybe String Source #
Why putLogin7 can't encode this login, if it can't: its strings
(host, user, password, application, server, library, language and
database names) are located by 16-bit offsets from the start of the
message, so together they must end by byte 65535. (Written modulo 65536
instead, a long application name would shift where the server reads the
following fields from.) The server's own limit of 128 characters per
field is left to the server. The message gives the length of each field
but the password's.
obfuscatePassword :: ByteString -> ByteString Source #
Swap the nibbles of each byte, then XOR with 0xA5.
SQLBatch and RPC
putAllHeaders :: TdsContext -> Put Source #
ALL_HEADERS with a single Transaction Descriptor header. MS-TDS 2.2.5.3 Packet Data Stream Headers
putSqlBatch :: TdsContext -> Text -> Put Source #
sqlBatchProblem :: TdsContext -> Text -> Maybe String Source #
The server's packet-count limit for a SQL batch. Most text fits using its UTF-8 byte count as a bound, avoiding a separate whole-text scan.
sqlBatchBuilder :: TdsContext -> Text -> Builder Source #
rpcRequestBuilder :: TdsContext -> [RpcRequest] -> Builder Source #
rpcParamBuilder :: RpcParam -> Builder Source #
sqlBatchBody :: TdsContext -> Text -> ByteString Source #
data RpcRequest Source #
One RPC: the procedure, the option flags and the parameters.
Constructors
| RpcRequest | |
Instances
| Show RpcRequest Source # | |
Defined in Hmssql.Tds.Client Methods showsPrec :: Int -> RpcRequest -> ShowS # show :: RpcRequest -> String # showList :: [RpcRequest] -> ShowS # | |
The procedure an RPC calls: by its identifier (procSpExecuteSql is
sp_executesql) or by name.
Constructors
| RpcProcId !Word16 | |
| RpcProcName !Text |
A parameter of an RPC.
Constructors
| RpcParam | |
Fields
| |
paramByRef :: Word8 Source #
Status flag: the parameter is an output parameter.
paramDefault :: Word8 Source #
Status flag: use the procedure's default value.
putRpcRequest :: TdsContext -> [RpcRequest] -> Put Source #
One or more RPCs in a single request, separated by the 0xFF batch flag.
Fails (with error) if rpcRequestProblem finds a problem; callers
check first. (Writing a name or value length modulo the size of its
length prefix would make the server read the rest as further fields: a
300-character parameter name would go out as a 44-character name followed
by what the server takes for the parameter's type and value.)
rpcRequestBody :: TdsContext -> [RpcRequest] -> ByteString Source #
The bytes of putRpcRequest: fails (with error, when forced) if
rpcRequestProblem finds a problem.
rpcRequestBodyUnchecked :: TdsContext -> [RpcRequest] -> ByteString Source #
Build a checked request's bytes with the same Builder used for sending.
newRpcWriter :: [RpcRequest] -> IO (TdsContext -> PacketWriter -> IO ()) Source #
The writer of these requests. In-memory requests can be sent any number of times. Requests with lazy or effectful values can be sent once: the writer takes them out of a reference as it starts, so the request no longer keeps a lazy value's head alive while it is sent, and a value is read once no matter how many threads try. A query builds a new writer per send.
writeRpcRequests :: TdsContext -> PacketWriter -> [RpcRequest] -> IO () Source #
Write requests whose types, names and values have been validated at construction, in order, with one separator between requests.
rpcRequestProblem :: RpcRequest -> Maybe String Source #
Why putRpcRequest can't encode this RPC, if it can't: a procedure name
of 65535 or more UTF-16 code units (NameLenProcID is a USHORT, and 0xFFFF
announces a procedure ID instead), or an rpcParamProblem.
rpcParamProblem :: RpcParam -> Maybe String Source #
Why a parameter can't be sent, if it can't: a name of more than 255
UTF-16 code units (a B_VARCHAR; SQL Server's own limit is 128 characters,
which it reports itself), a typeInfoProblem, or a valueProblem.
Transaction Manager requests
tmBeginTransactionBuilder :: TdsContext -> Word8 -> Builder Source #
The body of a Transaction Manager request that begins a transaction (MS-TDS 2.2.6.9, TM_BEGIN_XACT): ALL_HEADERS, the request type (5), the isolation level (0 keeps the session's; 1 READ UNCOMMITTED, 2 READ COMMITTED, 3 REPEATABLE READ, 4 SERIALIZABLE, 5 SNAPSHOT, which the session then keeps after the transaction), and an empty transaction name.
tmBeginTransactionBody :: TdsContext -> Word8 -> ByteString Source #