On 2019-12-26 18:43, Mark Rotteveel wrote:
128-bit literal - is it Numeric or Decimal?
Given the lack of an int128, we should consider it an exact numeric
literal of either DECIMAL or NUMERIC. The standard says (5.3 <literal>):
"""
22) The declared type of an <exact numeric literal> ENL is an
implementation-defined exact numeric type whose scale is the number of
<digit>s to the right of the <period>. There shall be an exact numeric
type capable of representing the value of ENL exactly.
"""
In addition, 4.4.1 Introduction to numbers, says:
"""
An SQL-implementation is permitted to regard certain <exact numeric
type>s as equivalent, if they have the same precision, scale, and
radix, as permitted by the Syntax Rules of Subclause 6.1, “<data
type>”. When two or more <exact numeric type>s are equivalent, the
SQL-implementation chooses one of these equivalent <exact numeric
type>s as the normal form representing that equivalence class of
<exact numeric type>s. The normal form determines the name of the
exact numeric type in the numeric type descriptor.
"""
See also rule 24 in 6.1 <data type>
Formally, I take this to mean we should choose one type, eg DECIMAL,
Done it for literals that do not fit in BIGINT.
but that would probably not match people assuming that literal without
decimal points are integral literals.
We could consider a middle ground where literals without decimal point
with 18 or less digits are BIGINT, that longer literals are DECIMAL,
and that literals with decimal point are DECIMAL.
I'm choosing DECIMAL here, because Firebird's NUMERIC doesn't conform
to the standard requirements for NUMERIC, although literals with a
decimal point are currently represented as scaled bigints **without**
subtype which I believe historically are usually interpreted as NUMERIC.
That's interpreted as scaled integer - any exact type in firebird is
'scaled' with scale==0 being a special case.
What appears a bit strange is that running
select 1, 1.5 from rdb$database;
I get first column represented as INT but second as BIGINT. But as long
as this did not change at least since 2.5 I will nopt touch it in order
not to break applications for nothing.
Firebird-Devel mailing list, web interface at
https://lists.sourceforge.net/lists/listinfo/firebird-devel