-
Notifications
You must be signed in to change notification settings - Fork 877
Milestone
Description
I tried upgrading to Npgsql 8.0.0 from 7.0.6, but all my code using NpgsqlBinaryExporter broke.
Steps to reproduce
The following code works as expected on 7.0.6 but breaks on 8.0.0.
var reader = conn.BeginBinaryExport("""
COPY (values ('foo', 1), ('bar', null), (null, 2)) TO STDOUT BINARY
""");
while(reader.StartRow() != -1)
{
string? col1 = null;
int? col2 = null;
if (reader.IsNull)
{
reader.Skip();
}
else
{
col1 = reader.Read<string>();
}
if (reader.IsNull)
{
reader.Skip();
}
else
{
col2 = reader.Read<int>(); // this throws
}
}The issue
The above code throws in the first iteration of the loop when reading the second column.
System.InvalidOperationException
The read on this field has consumed all of its bytes and read into the subsequent bytes (pos: 4, len: 1)
at Npgsql.Internal.PgReader.ThrowNotConsumedExactly()
at Npgsql.Internal.PgReader.EndRead()
at Npgsql.NpgsqlBinaryExporter.Read[T](Boolean async, Nullable`1 type, CancellationToken cancellationToken)
at Npgsql.NpgsqlBinaryExporter.Read[T]()
at Integrations.Test.PgDal.ManualStagingTests.NpgsqlDataReaderNoSkip() in /Users/hks/biq/daffy/tests/Integrations.Test/PgDal/ManualStagingTests.cs:line 437
at Xunit.Sdk.TestInvoker`1.<>c__DisplayClass48_0.<<InvokeTestMethodAsync>b__1>d.MoveNext() in /_/src/xunit.execution/Sdk/Frameworks/Runners/TestInvoker.cs:line 285
Further technical details
Npgsql version: 8.0.0
PostgreSQL version: 16.1
Operating system: MacOS 13.6.2 (22G320)
.NET 8.0.100
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels