moondb

waxing gibbous · a statute of moondb

moonsqls

The SQL Server implementation of the AsyncDriver contract — TDS spoken directly, statements the server compiles once, rows that travel in the protocol's own load format.

Enactment

What it is

moonsqls connects to a SQL Server instance and implements AsyncDriver over TDS: prelogin, login7, the token stream. The password never crosses the wire in the clear — encryption is negotiated before the login, and the handshake runs inside prelogin packets, after which whole TDS packets are the plaintext inside TLS.

i

Install

moon add moonbitstack/moonsqls

ii

Binding

A statement is written with ?. The driver rewrites each one into @p1, @p2 and sends the values as named RPC parameters to sp_executesql — beside the statement, never inside it.

iii

Prepared statements

prepare compiles the text with sp_prepare, whose handle comes back in an OUTPUT parameter; every run after that is an sp_execute carrying the handle and the values, so the statement text does not travel again. close releases the plan with sp_unprepare.

iv

Bulk copy

bulk_copy arms the table with INSERT BULK and then sends one message of column metadata and row tokens, so a thousand rows cost one round trip. Column types are inferred from the values and declared wider than the destination, so the server converts and no row overflows a width an earlier row chose.

v

TDS 8.0

connect(strict=true) starts TLS before the first TDS byte and announces version 8.0 over the ALPN protocol tds/8.0: there is no clear-text prelogin to downgrade, and a server that cannot do it fails the handshake rather than falling back.

vi

Coverage

execute query cursor transactions savepoints prepared handles bulk copy TLS and TDS 8.0 error classification MARS (declined).

moonsqls implements AsyncDriver placeholder ? → @p1 interface TDS 7.4 / 8.0
See the family The contract it obeys