-
Notifications
You must be signed in to change notification settings - Fork 874
BinaryExporter exception when read char values #5110
Copy link
Copy link
Milestone
Description
Steps to reproduce
using (var connection = new NpgsqlConnection(root.GetConnectionString("SqlConnection")))
{
connection.Open();
var cmd = connection.CreateCommand();
cmd.CommandText = @"
CREATE TABLE IF NOT EXISTS public.charTable
(
id serial NOT NULL,
value char NOT NULL,
CONSTRAINT charTable_pkey PRIMARY KEY (id)
);
";
cmd.ExecuteNonQuery();
cmd.CommandText = @"
INSERT INTO public.charTable
(value)
VALUES
($1)
";
var parametr = new NpgsqlParameter<char>();
parametr.NpgsqlValue = 'd';
cmd.Parameters.Add(parametr);
cmd.ExecuteNonQuery();
parametr.NpgsqlValue = 's';
cmd.ExecuteNonQuery();
using (var export = connection.BeginBinaryExport(@"
COPY public.charTable
(
id,
value
) TO STDOUT (FORMAT BINARY)
"))
{
while (export.StartRow() != -1)
{
var id = export.Read<int>();//got NullReferenceException on second iteration
var value = export.Read<char>();
}
}
}The issue
First iteration is works fine, but when i excpect on the second iteration where value must be 's' I get throw Exception(some times nullreference, some times Npgsql.NpgsqlException : Unknown message code: 100 seems 100 is 'd')
Exception message:
Stack trace:
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Npgsql
StackTrace:
at Npgsql.NpgsqlBinaryExporter.<DoRead>d__29`1.MoveNext()
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Runtime.CompilerServices.ValueTaskAwaiter`1.GetResult()
at Npgsql.NpgsqlBinaryExporter.Read[T]()
at NpgsqlBenchmark.Tests.CharExportTest.Test() in E:\Work\SoftStoneDevelop github\NpgsqlBinaryExporter\Src\NpgsqlBenchmark\Tests\CharExportTest.cs:line 57
This exception was originally thrown at this call stack:
[External Code]
NpgsqlBenchmark.Tests.CharExportTest.Test() in CharExportTest.cs
Further technical details
Npgsql version: 7.0.4
PostgreSQL version: PostgreSQL 15.2, compiled by Visual C++ build 1914, 64-bit
Operating system:
Edition Windows 10 Pro
Version 22H2
OS build 19045.3086
Reactions are currently unavailable