Closed driseley closed 5 years ago
Debug from the driver when this occurs:
---------- Receive Tokens ----------
<- TDS_LOGINACK: TDS 5.0.0.0, ASE 16.0.3
<- TDS_DONE: TDS_DONE_FINAL (24)
TDS_ENVCHANGE: TDS_ENV_CHARSET - iso_1 ->
INFO [10] [L:0]: Changed client character set setting to '<NULL>'.
TDS_ENVCHANGE: TDS_ENV_DB - master -> master
INFO [10] [L:0]: Changed database context to 'master'.
TDS_ENVCHANGE: TDS_ENV_LANG - -> us_english
INFO [10] [L:0]: Changed language setting to 'us_english'.
TDS_ENVCHANGE: TDS_ENV_PACKSIZE - -> 2048
Partial hexdump:
00000000 E3 08 00 03 00 05 69 73 6F 5F 31 E5 51 00 48 16 ã.....iso_1åQ.H.
00000010 00 00 02 0A 05 5A 5A 5A 5A 5A 00 01 00 32 00 43 .....ZZZZZ...2.C
00000020 68 61 6E 67 65 64 20 63 6C 69 65 6E 74 20 63 68 hanged client ch
00000030 61 72 61 63 74 65 72 20 73 65 74 20 73 65 74 74 aracter set sett
00000040 69 6E 67 20 74 6F 20 27 3C 4E 55 4C 4C 3E 27 2E ing to '<NULL>'.
When trying to connect to a Sybase database that has had the following parameter enabled:
sp_configure 'disable character set conversions', 1
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc31654.1600/doc/html/san1360629067891.html
and a Charset is specified on the login string, the connection fails with the following error:
This can be reproduced by running the
AdoNetCore.AseClient.Tests.Integration.Connection.CharsetTests.OpenConnection_WithCharsetCp850_PlusEncodingProvider_Succeeds
test against a database with this parameter set.This fails with the following error:
From the TDS Specification:
It looks to me like https://github.com/DataAction/AdoNetCore.AseClient/blob/82a0df85793b76f3062a10f5c327e3a7e400b712/src/AdoNetCore.AseClient/Internal/Handler/EnvChangeTokenHandler.cs#L57-L76 does not correctly handle an empty NewValue.
In my opinion, when this occurs the requested client encoding should be set anyway (if the encoding is resolvable) otherwise it will incorrectly use the default
ASCII
encoding.This appears to be the behaviour of the Java jTDS and jConnect drivers if the CHARSET driver property is specified and the 'disable character set conversions' parameter is set