Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown time zone ID. [DNET987] #905

Closed
firebird-automations opened this issue Dec 5, 2020 · 9 comments
Closed

Unknown time zone ID. [DNET987] #905

firebird-automations opened this issue Dec 5, 2020 · 9 comments

Comments

@firebird-automations
Copy link

Submitted by: fish (fishcodelib)

Execute the statement: SELECT * FROM "RDB$TRANSACTIONS"
Got the error message: Unknown time zone ID.

@firebird-automations
Copy link
Author

Commented by: @cincuranet

I'm testing on 4.0.0.2192, because I needed specific bug fixes. So maybe try that version. I hope "official" RC1/2 becomes available soon and hence some stable ground will be defined.

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Open [ 1 ] => In Progress [ 3 ]

@firebird-automations
Copy link
Author

Commented by: fish (fishcodelib)

This issue can be reproduced in all builds of firebird 4 by following these easy steps:
1.
CREATE TABLE "test" (
"ctimestamptz" timestamp with time zone,
"ctimetz" time with time zone
);
2.
SELECT * FROM "test";

When the table is empty, the variable 'tzId' will return the value 0 and then throw the error
public static FbZonedDateTime CreateZonedDateTime(DateTime dateTime, ushort tzId, short? offset)
{
if (!TimeZoneMapping.TryGetById(tzId, out var tz))
{
throw new ArgumentException("Unknown time zone ID.");
}
return new FbZonedDateTime(dateTime, tz, offset != null ? TimeSpan.FromMinutes((short)offset) : (TimeSpan?)null);
}

public static FbZonedTime CreateZonedTime(TimeSpan time, ushort tzId, short? offset)
{
if (!TimeZoneMapping.TryGetById(tzId, out var tz))
{
throw new ArgumentException("Unknown time zone ID.");
}
return new FbZonedTime(time, tz, offset != null ? TimeSpan.FromMinutes((short)offset) : (TimeSpan?)null);
}

@firebird-automations
Copy link
Author

Commented by: @cincuranet

Empty table. Interesting. Let me check that.

@firebird-automations
Copy link
Author

Commented by: @cincuranet

I can't replicate that on "WI-V4.0.0.2192 Firebird 4.0 Release Candidate 1/tcp (x2pc)/P13:C". This code runs fine on 7.10.1.

		FbConnection\.CreateDatabase\(ConnectionString, true\);
		using \(var conn = new FbConnection\(ConnectionString\)\)
		\{
			conn\.Open\(\);
			Console\.WriteLine\(conn\.ServerVersion\);
			using \(var cmd = conn\.CreateCommand\(\)\)
			\{
				cmd\.CommandText = @"CREATE TABLE ""test"" \(""ctimestamptz"" timestamp with time zone, ""ctimetz"" time with time zone\)";
				cmd\.ExecuteNonQuery\(\);
				cmd\.CommandText = @"select \* from ""test""";
				using \(var reader = cmd\.ExecuteReader\(\)\)
				\{
					while \(reader\.Read\(\)\)
					\{
						Console\.WriteLine\(reader\[0\]\);
					\}
				\}
			\}
		\}

@firebird-automations
Copy link
Author

Commented by: fish (fishcodelib)

This issue can be reproduced on the latest version Firebird-4.0.0.2288-0_x64.
while (reader.Read()) //--> Here will throw the error 'Unknown time zone ID.'
https://fishcodelib.com/test.png

@firebird-automations
Copy link
Author

Commented by: @cincuranet

You originally reported 2136 and told you that tests are running now on 2192, because of lack of official version RC/RTM version. Hence this could happen because the TZ data is in flux in nightly builds.

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: In Progress [ 3 ] => Closed [ 6 ]

resolution: Incomplete [ 4 ]

@firebird-automations
Copy link
Author

Commented by: fish (fishcodelib)

I've tested many versions, even the latest version 2290 from http://web.firebirdsql.org/download/snapshot_builds/win/4.0/
I don't think this is a problem of Firebird,
As I said,
"When the table is empty, the variable 'tzId' will return the value `0` and then throw the error."
The following code is from the source file 'TypeHelper.cs'
https://github.com/cincuranet/FirebirdSql.Data.FirebirdClient/blob/master/Provider/src/FirebirdSql.Data.FirebirdClient/Common/TypeHelper.cs

public static FbZonedDateTime CreateZonedDateTime(DateTime dateTime, ushort tzId, short? offset)
{
if (!TimeZoneMapping.TryGetById(tzId, out var tz))
{
throw new ArgumentException("Unknown time zone ID.");
}
return new FbZonedDateTime(dateTime, tz, offset != null ? TimeSpan.FromMinutes((short)offset) : (TimeSpan?)null);
}

public static FbZonedTime CreateZonedTime(TimeSpan time, ushort tzId, short? offset)
{
if (!TimeZoneMapping.TryGetById(tzId, out var tz))
{
throw new ArgumentException("Unknown time zone ID.");
}
return new FbZonedTime(time, tz, offset != null ? TimeSpan.FromMinutes((short)offset) : (TimeSpan?)null);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants