Permalink
Browse files

Added long paths to flush write buffers

  • Loading branch information...
YohDeadfall committed Jan 8, 2019
1 parent 8bf4219 commit 4a0f7d6c6e314132caf8e879e036812584a1e273
Showing with 26 additions and 5 deletions.
  1. +15 −5 src/Npgsql/TypeHandlers/UnknownTypeHandler.cs
  2. +11 −0 src/Npgsql/TypeHandlers/UnmappedEnumHandler.cs
@@ -72,12 +72,22 @@ protected internal override Task WriteObjectWithLength(object value, NpgsqlWrite
if (value == null || value is DBNull)
return base.WriteObjectWithLength(value, buf, lengthCache, parameter, async);

var convertedValue = value is string asString
? asString
: (string)parameter.ConvertedValue;

if (buf.WriteSpaceLeft < 4)
return WriteWithLengthLong();

buf.WriteInt32(ValidateObjectAndGetLength(value, ref lengthCache, parameter));
return base.Write(
value is string asString
? asString
: (string)parameter.ConvertedValue,
buf, lengthCache, parameter, async);
return base.Write(convertedValue, buf, lengthCache, parameter, async);

async Task WriteWithLengthLong()
{
await buf.Flush(async);
buf.WriteInt32(ValidateObjectAndGetLength(value, ref lengthCache, parameter));
await base.Write(convertedValue, buf, lengthCache, parameter, async);
}
}

#endregion Write
@@ -82,8 +82,19 @@ protected internal override Task WriteObjectWithLength(object value, NpgsqlWrite
{
if (value == null || value is DBNull)
return WriteWithLengthInternal<DBNull>(null, buf, lengthCache, parameter, async);

if (buf.WriteSpaceLeft < 4)
return WriteWithLengthLong();

buf.WriteInt32(ValidateAndGetLength(value, ref lengthCache, parameter));
return Write(value, buf, lengthCache, parameter, async);

async Task WriteWithLengthLong()
{
await buf.Flush(async);
buf.WriteInt32(ValidateAndGetLength(value, ref lengthCache, parameter));
await Write(value, buf, lengthCache, parameter, async);
}
}

internal Task Write(object value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async)

0 comments on commit 4a0f7d6

Please sign in to comment.