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

Allow large UDT buffers for netfx #456

Merged
merged 2 commits into from
Apr 8, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,12 @@ static internal Exception UDTInvalidSqlType(string typeName)
{
return ADP.Argument(StringsHelper.GetString(Strings.SQLUDT_InvalidSqlType, typeName));
}

static internal Exception UDTInvalidSize(int maxSize, int maxSupportedSize)
{
throw ADP.ArgumentOutOfRange(StringsHelper.GetString(Strings.SQLUDT_InvalidSize, maxSize, maxSupportedSize));
}


static internal Exception InvalidSqlDbTypeForConstructor(SqlDbType type)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9965,10 +9965,12 @@ internal Task TdsExecuteRPC(SqlCommand cmd, _SqlRPC[] rpcArray, int timeout, boo

Debug.Assert(_isYukon, "Invalid DataType UDT for non-Yukon or later server!");

int maxSupportedSize = IsKatmaiOrNewer ? int.MaxValue : short.MaxValue;

if (!isNull)
{
// When writing UDT parameter values to the TDS stream, allow sending byte[] or SqlBytes
// directly to the server and not rejected as invalid. This allows users to handle
// directly to the server and not reject them as invalid. This allows users to handle
// serialization and deserialization logic without having to have SqlClient be aware of
// the types and without using inefficient text representations.
if (value is byte[] rawBytes)
Expand Down Expand Up @@ -9999,19 +10001,15 @@ internal Task TdsExecuteRPC(SqlCommand cmd, _SqlRPC[] rpcArray, int timeout, boo
size = udtVal.Length;

//it may be legitimate, but we dont support it yet
if (size < 0 || (size >= UInt16.MaxValue && maxsize != -1))
throw new IndexOutOfRangeException();
if (size < 0 || (size >= maxSupportedSize && maxsize != -1))
{
throw SQL.UDTInvalidSize(maxsize, maxSupportedSize);
}
}

//if this is NULL value, write special null value
byte[] lenBytes = BitConverter.GetBytes((Int64)size);

if (ADP.IsEmpty(param.UdtTypeName))
throw SQL.MustSetUdtTypeNameForUdtParams();

// Split the input name. TypeName is returned as single 3 part name during DeriveParameters.
// NOTE: ParseUdtTypeName throws if format is incorrect
String[] names = SqlParameter.ParseTypeName(param.UdtTypeName, true /* is UdtTypeName */);
String[] names = SqlParameter.ParseTypeName(param.UdtTypeName, isUdtTypeName: true);
if (!ADP.IsEmpty(names[0]) && TdsEnums.MAX_SERVERNAME < names[0].Length)
{
throw ADP.ArgumentOutOfRange("names");
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4527,4 +4527,7 @@
<data name="TCE_AttestationProtocolNotSpecifiedForGeneratingEnclavePackage" xml:space="preserve">
<value>Error occurred when generating enclave package. Attestation Protocol has not been specified in the connection string, but the query requires enclave computations.</value>
</data>
</root>
<data name="SQLUDT_InvalidSize" xml:space="preserve">
<value>UDT size must be less than {1}, size: {0}</value>
</data>
</root>
cheenamalhotra marked this conversation as resolved.
Show resolved Hide resolved