Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port PR 34711 changes from corefx #232

Merged
merged 1 commit into from
Sep 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -671,67 +671,71 @@ override public void Prepare()
// between entry into Execute* API and the thread obtaining the stateObject.
_pendingCancel = false;


SqlStatistics statistics = null;
statistics = SqlStatistics.StartTimer(Statistics);
try
{
statistics = SqlStatistics.StartTimer(Statistics);

// only prepare if batch with parameters
if (
this.IsPrepared && !this.IsDirty
|| (this.CommandType == CommandType.StoredProcedure)
|| (
(System.Data.CommandType.Text == this.CommandType)
&& (0 == GetParameterCount(_parameters))
)
// only prepare if batch with parameters
if (
this.IsPrepared && !this.IsDirty
|| (this.CommandType == CommandType.StoredProcedure)
|| (
(System.Data.CommandType.Text == this.CommandType)
&& (0 == GetParameterCount(_parameters))
)

)
{
if (null != Statistics)
)
{
Statistics.SafeIncrement(ref Statistics._prepares);
if (null != Statistics)
{
Statistics.SafeIncrement(ref Statistics._prepares);
}
_hiddenPrepare = false;
}
_hiddenPrepare = false;
}
else
{
// Validate the command outside of the try\catch to avoid putting the _stateObj on error
ValidateCommand(isAsync: false);

bool processFinallyBlock = true;
try
else
{
// NOTE: The state object isn't actually needed for this, but it is still here for back-compat (since it does a bunch of checks)
GetStateObject();
// Validate the command outside of the try\catch to avoid putting the _stateObj on error
ValidateCommand(isAsync: false);

// Loop through parameters ensuring that we do not have unspecified types, sizes, scales, or precisions
if (null != _parameters)
bool processFinallyBlock = true;
try
{
int count = _parameters.Count;
for (int i = 0; i < count; ++i)
// NOTE: The state object isn't actually needed for this, but it is still here for back-compat (since it does a bunch of checks)
GetStateObject();

// Loop through parameters ensuring that we do not have unspecified types, sizes, scales, or precisions
if (null != _parameters)
{
_parameters[i].Prepare(this);
int count = _parameters.Count;
for (int i = 0; i < count; ++i)
{
_parameters[i].Prepare(this);
}
}
}

InternalPrepare();
}
catch (Exception e)
{
processFinallyBlock = ADP.IsCatchableExceptionType(e);
throw;
}
finally
{
if (processFinallyBlock)
InternalPrepare();
}
catch (Exception e)
{
processFinallyBlock = ADP.IsCatchableExceptionType(e);
throw;
}
finally
{
_hiddenPrepare = false; // The command is now officially prepared
if (processFinallyBlock)
{
_hiddenPrepare = false; // The command is now officially prepared

ReliablePutStateObject();
ReliablePutStateObject();
}
}
}
}

SqlStatistics.StopTimer(statistics);
finally
{
SqlStatistics.StopTimer(statistics);
}
}

private void InternalPrepare()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,12 @@ internal void Disconnect()
_pMarsPhysicalConObj = null;
}
}

_resetConnectionEvent?.Dispose();
_resetConnectionEvent = null;

_defaultEncoding = null;
_defaultCollation = null;
}

// Fires a single InfoMessageEvent
Expand Down