sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

Questions about MS SQL connector

Open milgner opened this issue 3 years ago • 0 comments

After adding support for DateTime2 types, I thought I'd give implementing packet chunking for the MS SQL connector a go. I'm a total noob when it comes to the TDS protocol, so there's two things that caught my attention:

  1. When I ran a query through IntelliJ's DB console and captured it in Wireshark, I saw that it sends chunked SQLBatch packets. But when running a query through sqlx, it generates "Remote Procedure Call" packets. At first I thought that this is only because I was using a named parameter in my query - but when I got rid of that, it was still returning Some(arguments) from that query, wherein there was only a single, 0-length argument? The issue is that I unfortunately (:see_no_evil:) have to run a very long query and when using RPC instead of SQLBatch, I run into a fixed 8000-character limit for NVarChar arguments so RPC seems to be out of the question.

  2. I noticed that every call to MssqlStream#write_packet was always accompanied by a follow-up call to MssqlStream#flush - except in TransactionManager#start_rollback which only writes to the buffer but doesn't seem to have any corresponding flush() call. This is understandable in that it's referred to from the Drop implementation of Transaction, which is (infamously) unable to run async code. But it's not clear to me where this buffer would be flushed as the Drop trait for either the connection, stream or BufWriter seem to have any corresponding functionality at first glance.

Any explanation and additional pointers on the subject or on what would need to be done to support very long queries in addition to packet chunking would be appreciated.

milgner avatar Apr 11 '22 09:04 milgner