Skip to content

Commit

Permalink
Remove old SQL 2005 code
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Engel committed May 27, 2022
1 parent 6f2acf3 commit 88e8b92
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6527,7 +6527,6 @@ private void SetUpRPCParameters(_SqlRPC rpc, int startCount, bool inSchema, SqlP
int paramCount = GetParameterCount(parameters);
int j = startCount;
TdsParser parser = _activeConnection.Parser;
bool is2005OrNewer = parser.Is2005OrNewer;

for (ii = 0; ii < paramCount; ii++)
{
Expand All @@ -6536,7 +6535,7 @@ private void SetUpRPCParameters(_SqlRPC rpc, int startCount, bool inSchema, SqlP

// func will change type to that with a 4 byte length if the type has a two
// byte length and a parameter length > than that expressable in 2 bytes
if ((!parameter.ValidateTypeLengths(is2005OrNewer).IsPlp) && (parameter.Direction != ParameterDirection.Output))
if ((!parameter.ValidateTypeLengths().IsPlp) && (parameter.Direction != ParameterDirection.Output))
{
parameter.FixStreamDataForNonPLP();
}
Expand Down Expand Up @@ -6912,8 +6911,6 @@ internal string BuildParamList(TdsParser parser, SqlParameterCollection paramete
StringBuilder paramList = new StringBuilder();
bool fAddSeparator = false;

bool is2005OrNewer = parser.Is2005OrNewer;

int count = 0;

count = parameters.Count;
Expand Down Expand Up @@ -6963,7 +6960,7 @@ internal string BuildParamList(TdsParser parser, SqlParameterCollection paramete
{
// func will change type to that with a 4 byte length if the type has a two
// byte length and a parameter length > than that expressable in 2 bytes
mt = sqlParam.ValidateTypeLengths(is2005OrNewer);
mt = sqlParam.ValidateTypeLengths();
if ((!mt.IsPlp) && (sqlParam.Direction != ParameterDirection.Output))
{
sqlParam.FixStreamDataForNonPLP();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1648,11 +1648,7 @@ internal SmiParameterMetaData GetMetadataForTypeInfo()
internal SmiParameterMetaData MetaDataForSmi(out ParameterPeekAheadValue peekAhead)
{
peekAhead = null;
MetaType mt = ValidateTypeLengths(
#if NETFRAMEWORK
true /* 2005 or newer */
#endif
);
MetaType mt = ValidateTypeLengths();
long actualLen = GetActualSize();
long maxLen = Size;

Expand Down Expand Up @@ -1989,11 +1985,7 @@ internal void Validate(int index, bool isCommandProc)

// func will change type to that with a 4 byte length if the type has a two
// byte length and a parameter length > than that expressible in 2 bytes
internal MetaType ValidateTypeLengths(
#if NETFRAMEWORK
bool is2005OrNewer
#endif
)
internal MetaType ValidateTypeLengths()
{
MetaType mt = InternalMetaType;
// Since the server will automatically reject any
Expand Down Expand Up @@ -2025,11 +2017,7 @@ bool is2005OrNewer
// Keeping these goals in mind - the following are the changes we are making

long maxSizeInBytes;
if (mt.IsNCharType
#if NETFRAMEWORK
&& is2005OrNewer
#endif
)
if (mt.IsNCharType)
{
maxSizeInBytes = ((sizeInCharacters * sizeof(char)) > actualSizeInBytes) ? sizeInCharacters * sizeof(char) : actualSizeInBytes;
}
Expand All @@ -2046,60 +2034,8 @@ bool is2005OrNewer
HasFlag(SqlParameterFlags.CoercedValueIsDataFeed) ||
(sizeInCharacters == -1) ||
(actualSizeInBytes == -1)
)
)
{
#if NETFRAMEWORK
// is size > size able to be described by 2 bytes
if (is2005OrNewer)
{
// Convert the parameter to its max type
mt = MetaType.GetMaxMetaTypeFromMetaType(mt);
_metaType = mt;
InternalMetaType = mt;
if (!mt.IsPlp)
{
if (mt.SqlDbType == SqlDbType.Xml)
{
throw ADP.InvalidMetaDataValue(); //Xml should always have IsPartialLength = true
}
if (
mt.SqlDbType == SqlDbType.NVarChar ||
mt.SqlDbType == SqlDbType.VarChar ||
mt.SqlDbType == SqlDbType.VarBinary
)
{
Size = (int)SmiMetaData.UnlimitedMaxLengthIndicator;
}
}
}
else
{
switch (mt.SqlDbType)
{ // widening the SqlDbType is automatic
case SqlDbType.Binary:
case SqlDbType.VarBinary:
mt = MetaType.GetMetaTypeFromSqlDbType(SqlDbType.Image, false);
_metaType = mt; // do not use SqlDbType property which calls PropertyTypeChanging resetting coerced value
InternalMetaType = mt;
break;
case SqlDbType.Char:
case SqlDbType.VarChar:
mt = MetaType.GetMetaTypeFromSqlDbType(SqlDbType.Text, false);
_metaType = mt;
InternalMetaType = mt;
break;
case SqlDbType.NChar:
case SqlDbType.NVarChar:
mt = MetaType.GetMetaTypeFromSqlDbType(SqlDbType.NText, false);
_metaType = mt;
InternalMetaType = mt;
break;
default:
Debug.Assert(false, "Missed metatype in SqlCommand.BuildParamList()");
break;
}
}
#else
mt = MetaType.GetMaxMetaTypeFromMetaType(mt);
_metaType = mt;
InternalMetaType = mt;
Expand All @@ -2118,8 +2054,6 @@ bool is2005OrNewer
Size = (int)SmiMetaData.UnlimitedMaxLengthIndicator;
}
}

#endif
}
}
return mt;
Expand Down

0 comments on commit 88e8b92

Please sign in to comment.