-
Notifications
You must be signed in to change notification settings - Fork 874
Closed
Milestone
Description
This bug is solved by the resolution of issue #437 in v3.0, but I did not see this bug reported before.
It is still present in (at least) v2.2.x, and causes a crash.
When a point coordinate is lower than 0.001ish (I don't know the exact point), there is an automatic switch to the scientific notation by Postgres. The insertion goes well, but the read from the db fails with a FormatException in ExtendedBackendToNativeTypeConverter.
Test to reproduce it (in CommandTests):
[Test]
public void TestPointScientificSupport()
{
ExecuteNonQuery("INSERT INTO data (field_point) VALUES ( '(4, 0.00003)' )");
var command = new NpgsqlCommand("select field_point from data", Conn);
var p = (NpgsqlPoint)command.ExecuteScalar();
Assert.AreEqual(4, p.X);
Assert.AreEqual(0.00003, p.Y);
}
StackTrace:
System.InvalidCastException : Le format de la chaîne d'entrée est incorrect.
----> System.FormatException : Le format de la chaîne d'entrée est incorrect.
à Npgsql.ForwardsOnlyDataReader.GetProviderSpecificValue(Int32 ordinal) dans NpgsqlDataReader.cs: line 1443
à Npgsql.ForwardsOnlyDataReader.GetValue(Int32 Index) dans NpgsqlDataReader.cs: line 1416
à Npgsql.NpgsqlCommand.ExecuteScalar() dans NpgsqlCommand.PrepareExecute.cs: line 420
à NpgsqlTests.CommandTests.TestPointScientificSupport() dans CommandTests.cs: line 1718
--FormatException
à System.Number.ParseSingle(String value, NumberStyles options, NumberFormatInfo numfmt)
à System.Single.Parse(String s, NumberStyles style, IFormatProvider provider)
à NpgsqlTypes.ExtendedBackendToNativeTypeConverter.ToPoint(NpgsqlBackendTypeInfo TypeInfo, Byte[] bBackendData, Int16 TypeSize, Int32 TypeModifier) dans NpgsqlTypeConvBackendToNative.cs: line 341
à NpgsqlTypes.NpgsqlBackendTypeInfo.ConvertBackendTextToNative(Byte[] BackendData, Int16 TypeSize, Int32 TypeModifier) dans NpgsqlTypeInfoBackend.cs: line 210
à NpgsqlTypes.NpgsqlTypesHelper.ConvertBackendStringToSystemType(NpgsqlBackendTypeInfo TypeInfo, Byte[] data, Int16 typeSize, Int32 typeModifier) dans NpgsqlTypesHelper.cs: line 248
à Npgsql.StringRowReader.ReadNext() dans NpgsqlAsciiRow.cs: line 84
Again, this is solved by #437, so is a bugfix in 2.2.x doable?