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

Changing FLOAT to a SQL standard compliant FLOAT datatype [CORE6109] #6358

Closed
firebird-automations opened this issue Jul 27, 2019 · 9 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @mrotteveel

Is related to JDBC591
Replaces CORE5734
Replaces CORE5733

Currently Firebird has two documented floating point datatypes:

- FLOAT (a 32 bit single precision)
- DOUBLE PRECISION (a 64 bit double precision)

Firebird also has the - undocumented - datatypes
- REAL (a 32 bit single precision), essentially an alias for FLOAT. REAL is a SQL standard type.
- LONG FLOAT (a 64 bit double precision), essentially an alias for DOUBLE PRECISION

In addition, Firebird supports - again, undocumented - FLOAT(p) with p in decimal precision, where
- p in [0,7] is a 32 bit single precision float
- p in [8,..) is a 64 bit double precision float

The SQL standard however defines FLOAT differently. From SQL:2016 6.1 <data type>:

"""
Syntax Rules

20) If a <precision> is omitted, then an implementation-defined <precision> is implicit.

21) The value of a <precision> shall be greater than 0 (zero). [..]
[..]
29) FLOAT specifies the data type approximate numeric, with binary precision equal to or greater than the value of the specified <precision>. The maximum value of <precision> is implementation-defined. <precision> shall not be greater than this value.

30) REAL specifies the data type approximate numeric, with implementation-defined precision.

31) DOUBLE PRECISION specifies the data type approximate numeric, with implementation-defined precision that is greater than the implementation-defined precision of REAL.

32) For the <approximate numeric type>s FLOAT, REAL, and DOUBLE PRECISION, the maximum and minimum values of the exponent are implementation-defined.
"""

I propose that for Firebird 4 we bring this inline with the standard:

1. Change and document FLOAT(p) to apply precision in binary digits, that is:
- p in [1, 24] is a 32 bit single precision
- p in [25, 53] is a 64 bit double precision
- p < 1 and p > 53 are an error (in the future we could consider adding support for higher precision formats like binary128 (p in [54, 113]) and binary256 (p in [114, 237]))
2. Document that FLOAT(p) with 1<=p<=24 is a synonym for FLOAT.
3. Document that FLOAT(p) with 25<=p<=53 is a synonym for DOUBLE PRECISION.
4. Document REAL as a synonym for FLOAT
5. Document LONG FLOAT and LONG FLOAT(p) with 1<=p<=53 as a deprecated synonym for DOUBLE PRECISION

This change will break backwards compatibility for FLOAT(p), but as the precision syntax for FLOAT was never documented, I think that is an acceptable tradeoff to gain better standard compliance.

Commits: 426aeb5 FirebirdSQL/jaybird@0fb5a02

@firebird-automations
Copy link
Collaborator Author

Commented by: @mrotteveel

Pull request #218

@firebird-automations
Copy link
Collaborator Author

Modified by: @mrotteveel

Fix Version: 4.0 Beta 2 [ 10888 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @mrotteveel

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @mrotteveel

Link: This issue is related to JDBC591 [ JDBC591 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Resolved [ 5 ]

QA Status: No test => Done successfully

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Closed [ 6 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

assignee: Mark Rotteveel [ avalanche1979 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @mrotteveel

Link: This issue replaces CORE5734 [ CORE5734 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @mrotteveel

Link: This issue replaces CORE5733 [ CORE5733 ]

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