hmssql
Safe HaskellNone
LanguageHaskell2010

Hmssql.Tds.Client

Description

Messages sent from the client to the server.

MS-TDS 2.2.6 Client Messages

Synopsis

PRELOGIN

newtype Prelogin Source #

A PRELOGIN message: its options, in order.

Constructors

Prelogin [PreloginOption] 

Instances

Instances details
Show Prelogin Source # 
Instance details

Defined in Hmssql.Tds.Client

Eq Prelogin Source # 
Instance details

Defined in Hmssql.Tds.Client

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 EncryptOn does. (0x03)

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

Instances details
Show Encryption Source # 
Instance details

Defined in Hmssql.Tds.Client

Eq Encryption Source # 
Instance details

Defined in Hmssql.Tds.Client

LOGIN7

data Login7 Source #

A LOGIN7 message, which putLogin7 writes; start from defaultLogin7.

Instances

Instances details
Show Login7 Source #

As derived, except that a non-empty password is shown as redacted.

Instance details

Defined in Hmssql.Tds.Client

Eq Login7 Source # 
Instance details

Defined in Hmssql.Tds.Client

Methods

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

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

data Feature Source #

A LOGIN7 feature extension. MS-TDS 2.2.6.4 FeatureExt

Constructors

Feature 

Instances

Instances details
Show Feature Source #

As derived, except that the data of a FEDAUTH feature (an access token) is shown as redacted.

Instance details

Defined in Hmssql.Tds.Client

Eq Feature Source # 
Instance details

Defined in Hmssql.Tds.Client

Methods

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

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

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.

putLogin7 :: Login7 -> Put Source #

Fails (with error) if there is a login7Problem.

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

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.

data RpcRequest Source #

One RPC: the procedure, the option flags and the parameters.

Constructors

RpcRequest 

Instances

Instances details
Show RpcRequest Source # 
Instance details

Defined in Hmssql.Tds.Client

data RpcProc Source #

The procedure an RPC calls: by its identifier (procSpExecuteSql is sp_executesql) or by name.

Constructors

RpcProcId !Word16 
RpcProcName !Text 

Instances

Instances details
Show RpcProc Source # 
Instance details

Defined in Hmssql.Tds.Client

Eq RpcProc Source # 
Instance details

Defined in Hmssql.Tds.Client

Methods

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

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

data RpcParam Source #

A parameter of an RPC.

Constructors

RpcParam 

Fields

Instances

Instances details
Show RpcParam Source # 
Instance details

Defined in Hmssql.Tds.Client

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.