-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
BugIncorrect or unexpected behaviorIncorrect or unexpected behaviorPostgres WireIssues or changes relating to Postgres wire protocolIssues or changes relating to Postgres wire protocol
Description
To reproduce
Consider the following C# program:
using Npgsql;
await using var dataSource = new NpgsqlDataSourceBuilder(
"Host=127.0.0.1;Port=8812;Username=admin;Password=quest;Database=qdb;ServerCompatibilityMode=NoTypeLoading;"
).Build();
await using var connection = await dataSource.OpenConnectionAsync();
await using var batch = new NpgsqlBatch(connection);
var cmd1 = new NpgsqlBatchCommand("SELECT @time;");
cmd1.Parameters.AddWithValue("time", DateTime.UtcNow);
batch.BatchCommands.Add(cmd1);
var cmd2 = new NpgsqlBatchCommand("SELECT @time;");
cmd2.Parameters.AddWithValue("time", DateTime.UtcNow);
batch.BatchCommands.Add(cmd2);
await batch.PrepareAsync(); // It works if we do not prepare the batch
await using var reader = await batch.ExecuteReaderAsync();
while (await reader.ReadAsync())
{
Console.WriteLine(reader.GetDateTime(0));
}
await reader.NextResultAsync();
while (await reader.ReadAsync())
{
Console.WriteLine(reader.GetDateTime(0));
}I get this exception when processing the second result:
System.InvalidCastException
$>d__0.MoveNext() in C:\Source\ConsoleApp1\ConsoleApp1\Program.cs:line 29
HResult=0x80004002
Message=Out of range of DateTime (year must be between 1 and 9999).
Source=Npgsql
StackTrace:
at Npgsql.Internal.Converters.PgTimestamp.Decode(Int64 value, DateTimeKind kind, Boolean dateTimeInfinityConversions)
at Npgsql.Internal.Converters.DateTimeConverter.ReadCore(PgReader reader)
at Npgsql.Internal.PgBufferedConverter`1.Read(PgReader reader)
at Npgsql.NpgsqlDataReader.GetFieldValueCore[T](Int32 ordinal)
at Npgsql.NpgsqlDataReader.GetDateTime(Int32 ordinal)
at Program.<
at Program.<$>d__0.MoveNext() in C:\Source\ConsoleApp1\ConsoleApp1\Program.cs:line 27
at Program.<$>d__0.MoveNext() in C:\Source\ConsoleApp1\ConsoleApp1\Program.cs:line 27
at Program.<$>d__0.MoveNext() in C:\Source\ConsoleApp1\ConsoleApp1\Program.cs:line 27
at Program.<$>d__0.MoveNext() in C:\Source\ConsoleApp1\ConsoleApp1\Program.cs:line 27
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
ArgumentOutOfRangeException: Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. (Parameter 'ticks')
Maybe related issue #6123.
QuestDB version:
9.3.1
OS, in case of Docker specify Docker and the Host OS:
Windows
File System, in case of Docker specify Host File System:
ntfs
Full Name:
Rasmus Melchior Jacobsen
Affiliation:
Utiliread ApS
Have you followed Linux, MacOs kernel configuration steps to increase Maximum open files and Maximum virtual memory areas limit?
- Yes, I have
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugIncorrect or unexpected behaviorIncorrect or unexpected behaviorPostgres WireIssues or changes relating to Postgres wire protocolIssues or changes relating to Postgres wire protocol