TdsLib icon indicating copy to clipboard operation
TdsLib copied to clipboard

Column type 0x20 and 0x21 unspecified, but returned by AWS-based SQL Server instances

Open monty241 opened this issue 11 months ago • 2 comments

Specifically on SQL Server running on AWS as service, there is a column type 0x20 and 0x21 being returned. On other SQL Server editions (on-premises, Azure) this has not yet been found in identical scenarios.

Wireshark TDS seems also unable to handle it, leading to nonsense column metadata being reported.

The documented types are listed in 2.2.5 Data Type Definitions.

Is it possible to add documentation and logic in C# how to interprete these column types 0x20 and 0x21 as part of the TDS specification to allow building a custom SQL Server client?

TDS column type 0x20

Reproduction: start SQL Server Management Studio and connect to SQL Server on AWS. First statement is:

Image

With result for the first column (a non-casted 1 as value) a column data type 0x20:

Image

TDS column type 0x21

Reproduction: run a query returning 1 cased as tinyint/shortint/int (always 0x21):

Image

Resulting data type for column according to SQL Server instance is column data type 0x21:

Image

monty241 avatar Jan 10 '25 12:01 monty241

Like you say, those data types don't seem to be described in the MS-TDS protocol. Perhaps they are from a different TDS spec or could also be Wireshark that is not parsing the tokens correctly and shows wrong values?

This is likely not the ideal location to diagnose that further. You should try to reach out to AWS support or community forums.

valterc avatar Jan 10 '25 15:01 valterc

Thanks for feedback!

0x20 and 0x21 were not to be found in any reference documentation version.

We built our own parser starting from TdsLib and ran into the same issue as Wireshark, so it seems to be generic issue when the spec is followed.

To be sure: this statement is the Microsoft Corp. official point of view that the current TDS documentation is correct?

Reaching out to AWS what type of SQL Server they have acquired and whether they made any specific deviations from the TDS-standard in source code or configuration is going to be a major pain, especially with the current deviations in policy between the EU and US.

When this is formal point of view, we can just map occurrence 0x20 and 0x21 to justify an error like "This is a SQL Server implementation deviant from the formal TDS specification." with hint "Please reach out to your supplier to acquire a TDS-standard compliant SQL Server instance."

monty241 avatar Jan 10 '25 16:01 monty241