Skip to content

Commit

Permalink
Combine: Move SqlEnvChange to shared and sync usage (#1525)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wraith2 committed May 31, 2022
1 parent a43348b commit 73aa0da
Show file tree
Hide file tree
Showing 10 changed files with 289 additions and 274 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlEnums.cs">
<Link>Microsoft\Data\SqlClient\SqlEnums.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlEnvChange.cs">
<Link>Microsoft\Data\SqlClient\SqlEnvChange.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlError.cs">
<Link>Microsoft\Data\SqlClient\SqlError.cs</Link>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1994,36 +1994,36 @@ internal bool IgnoreEnvChange
internal void OnEnvChange(SqlEnvChange rec)
{
Debug.Assert(!IgnoreEnvChange, "This function should not be called if IgnoreEnvChange is set!");
switch (rec.type)
switch (rec._type)
{
case TdsEnums.ENV_DATABASE:
// If connection is not open and recovery is not in progress, store the server value as the original.
if (!_fConnectionOpen && _recoverySessionData == null)
{
_originalDatabase = rec.newValue;
_originalDatabase = rec._newValue;
}

CurrentDatabase = rec.newValue;
CurrentDatabase = rec._newValue;
break;

case TdsEnums.ENV_LANG:
// If connection is not open and recovery is not in progress, store the server value as the original.
if (!_fConnectionOpen && _recoverySessionData == null)
{
_originalLanguage = rec.newValue;
_originalLanguage = rec._newValue;
}

_currentLanguage = rec.newValue;
_currentLanguage = rec._newValue;
break;

case TdsEnums.ENV_PACKETSIZE:
_currentPacketSize = int.Parse(rec.newValue, CultureInfo.InvariantCulture);
_currentPacketSize = int.Parse(rec._newValue, CultureInfo.InvariantCulture);
break;

case TdsEnums.ENV_COLLATION:
if (_currentSessionData != null)
{
_currentSessionData._collation = rec.newCollation;
_currentSessionData._collation = rec._newCollation;
}
break;

Expand All @@ -2043,20 +2043,20 @@ internal void OnEnvChange(SqlEnvChange rec)
{
throw SQL.ROR_FailoverNotSupportedServer(this);
}
_currentFailoverPartner = rec.newValue;
_currentFailoverPartner = rec._newValue;
break;

case TdsEnums.ENV_PROMOTETRANSACTION:
byte[] dtcToken = null;
if (rec.newBinRented)
byte[] dtcToken;
if (rec._newBinRented)
{
dtcToken = new byte[rec.newLength];
Buffer.BlockCopy(rec.newBinValue, 0, dtcToken, 0, dtcToken.Length);
dtcToken = new byte[rec._newLength];
Buffer.BlockCopy(rec._newBinValue, 0, dtcToken, 0, dtcToken.Length);
}
else
{
dtcToken = rec.newBinValue;
rec.newBinValue = null;
dtcToken = rec._newBinValue;
rec._newBinValue = null;
}
PromotedDTCToken = dtcToken;
break;
Expand All @@ -2077,16 +2077,16 @@ internal void OnEnvChange(SqlEnvChange rec)
break;

case TdsEnums.ENV_USERINSTANCE:
_instanceName = rec.newValue;
_instanceName = rec._newValue;
break;

case TdsEnums.ENV_ROUTING:
SqlClientEventSource.Log.TryAdvancedTraceEvent("<sc.SqlInternalConnectionTds.OnEnvChange|ADV> {0}, Received routing info", ObjectID);
if (string.IsNullOrEmpty(rec.newRoutingInfo.ServerName) || rec.newRoutingInfo.Protocol != 0 || rec.newRoutingInfo.Port == 0)
if (string.IsNullOrEmpty(rec._newRoutingInfo.ServerName) || rec._newRoutingInfo.Protocol != 0 || rec._newRoutingInfo.Port == 0)
{
throw SQL.ROR_InvalidRoutingInfo(this);
}
RoutingInfo = rec.newRoutingInfo;
RoutingInfo = rec._newRoutingInfo;
break;

default:
Expand Down
Loading

0 comments on commit 73aa0da

Please sign in to comment.