The original problem from where this discussion comes from is that type
INTEGER
has been split into many types (SMALLINT, INT, BIGINT...) because of
historical implementation concerns.
Java has made the same archaic mistake (short, int, long...).
The best solution would be to have an Integer type that can (in
principle) scale up to infinity.
(Of course it would be wise for the database to define some limit so
that erroneous code would not end up creating an infinite value.)
Then one could set some further constraints on the INTEGER type eg.
CHECK COL > 3 AND COL < 7 or whatever.
The heart of the problem is that in mathematics the plus operator when
applied to 2 integers ALWAYS produces an integer.
This is called the closure property.
The set of integers is closed over addition (multiplication).
But this is obviously not true for SMALLINT, INT or BIGINT.
Just my 5 cents.
- rami
On 2.5.2011 17:48, Maaartin G wrote:
On Monday, May 2, 2011 3:53:47 PM UTC+2, Andreas Henningsson wrote:
> On Mon, May 2, 2011 at 3:43 PM, Noel Grandin <[email protected]> wrote:
> > Its not a schema change, it will only apply to result sets i.e. if a
> > computation in a select would result in an overflow, the result column
> > gets automatically promoted to the next larger numeric type.
>
> that sounds more ok to me.
To me it does NOT. Nearly any computation may overflow, so the result
of int+int should be long and long+long should be BigInteger? In
general surely not. But then you have a result type depending not only
on the type of included variables, but also an their actual values.
Would you do this globally or on a per-row bases? The former is
impractical, since you'd need to compute the whole ResultSet before
returning anything. The latter is weird, weird, weird....
--
You received this message because you are subscribed to the Google
Groups "H2 Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en.
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en.