Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
merging from SqlClient
  • Loading branch information
Carl Meyertons committed Jun 9, 2020
commit 581d43b1d28502b61e88eaf46fe360fade96393c
Original file line number Diff line number Diff line change
Expand Up @@ -1646,8 +1646,7 @@ private Task ConvertWriteValueAsync<T>(T value, int col, _SqlMetaData metadata,
}
catch (SqlTruncateException)
{
mt = MetaType.GetMetaTypeFromSqlDbType(type.SqlDbType, false);
throw SQL.BulkLoadCannotConvertValue(value.GetType(), mt, ADP.ParameterValueOutOfRange(decValue.Value));
throw SQL.BulkLoadCannotConvertValue(value.GetType(), mt, metadata.ordinal, RowNumber, metadata.isEncrypted, metadata.column, value.ToString(), ADP.ParameterValueOutOfRange(sqlValue));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1272,73 +1272,8 @@ internal SqlError ProcessSNIError(TdsParserStateObject stateObj)

if (details.sniErrorNumber != 0)
{
case (int)SNINativeMethodWrapper.SniSpecialErrors.MultiSubnetFailoverWithMoreThan64IPs:
// Connecting with the MultiSubnetFailover connection option to a SQL Server instance configured with more than 64 IP addresses is not supported.
throw SQL.MultiSubnetFailoverWithMoreThan64IPs();

case (int)SNINativeMethodWrapper.SniSpecialErrors.MultiSubnetFailoverWithInstanceSpecified:
// Connecting to a named SQL Server instance using the MultiSubnetFailover connection option is not supported.
throw SQL.MultiSubnetFailoverWithInstanceSpecified();

case (int)SNINativeMethodWrapper.SniSpecialErrors.MultiSubnetFailoverWithNonTcpProtocol:
// Connecting to a SQL Server instance using the MultiSubnetFailover connection option is only supported when using the TCP protocol.
throw SQL.MultiSubnetFailoverWithNonTcpProtocol();
// continue building SqlError instance
}
}
// PInvoke code automatically sets the length of the string for us
// So no need to look for \0
string errorMessage = details.errorMessage;

// Format SNI errors and add Context Information
//
// General syntax is:
// <sqlclient message>
// (provider:<SNIx provider>, error: <SNIx error code> - <SNIx error message>)
//
// errorMessage | sniError |
// -------------------------------------------
// ==null | x | must never happen
// !=null | != 0 | retrieve corresponding errorMessage from resources
// !=null | == 0 | replace text left of errorMessage
//

if (TdsParserStateObjectFactory.UseManagedSNI)
Debug.Assert(!string.IsNullOrEmpty(details.errorMessage) || details.sniErrorNumber != 0, "Empty error message received from SNI");
else
Debug.Assert(!string.IsNullOrEmpty(details.errorMessage), "Empty error message received from SNI");

string sniContextEnumName = TdsEnums.GetSniContextEnumName(stateObj.SniContext);

string sqlContextInfo = SRHelper.GetResourceString(sniContextEnumName);
string providerRid = string.Format("SNI_PN{0}", details.provider);
string providerName = SRHelper.GetResourceString(providerRid);
Debug.Assert(!string.IsNullOrEmpty(providerName), $"invalid providerResourceId '{providerRid}'");
uint win32ErrorCode = details.nativeError;

if (details.sniErrorNumber == 0)
{
// Provider error. The message from provider is preceded with non-localizable info from SNI
// strip provider info from SNI
//
int iColon = errorMessage.IndexOf(':');
Debug.Assert(0 <= iColon, "':' character missing in sni errorMessage");
Debug.Assert(errorMessage.Length > iColon + 1 && errorMessage[iColon + 1] == ' ', "Expecting a space after the ':' character");

// extract the message excluding the colon and trailing cr/lf chars
if (0 <= iColon)
{
int len = errorMessage.Length;
len -= Environment.NewLine.Length; // exclude newline sequence
iColon += 2; // skip over ": " sequence
len -= iColon;
/*
The error message should come back in the following format: "TCP Provider: MESSAGE TEXT"
If the message is received on a Win9x OS, the error message will not contain MESSAGE TEXT
If we get an error message with no message text, just return the entire message otherwise
return just the message text.
*/
if (len > 0)
// handle special SNI error codes that are converted into exception which is not a SqlException.
switch (details.sniErrorNumber)
{
case (int)SNINativeMethodWrapper.SniSpecialErrors.MultiSubnetFailoverWithMoreThan64IPs:
// Connecting with the MultiSubnetFailover connection option to a SQL Server instance configured with more than 64 IP addresses is not supported.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<IntermediateOutputPath>$(ObjFolder)$(Configuration).$(Platform).$(AssemblyName)</IntermediateOutputPath>
<OutputPath>$(BinFolder)$(Configuration).$(Platform).$(AssemblyName)</OutputPath>
</PropertyGroup>
<ItemGroup>
<ItemGroup Condition="!$(ReferenceType.Contains('NetStandard'))">
<Compile Include="..\..\netfx\src\Microsoft\Data\SqlClient\GenericConverter.cs" Link="GenericConverter.cs" />
<Compile Include="AlwaysEncryptedTests\ConnectionStringBuilderShould.cs" />
<Compile Include="AlwaysEncryptedTests\DummyKeyStoreProvider.cs" />
Expand Down Expand Up @@ -51,7 +51,7 @@
<Compile Include="SqlConnectionStringBuilderTest.cs" />
<Compile Include="SerializeSqlTypesTest.cs" />
<Compile Include="GenericConverterTests.cs" />
<!-- <Compile Include="DiagnosticTest.cs" /> -->
<Compile Include="TestTdsServer.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkVersion)" />
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.