Subject Re: [IB-Architect] System table change
Author Chris Jewell
> From: Ann Harrison <harrison@...>
> Date: Tue, 07 Nov 2000 09:59:13 -0500
>
> I am considering making a short term change to the way
> the sub_type field is used on numeric datatypes. The
> change would define a sub_type of 0 or NULL as the native
> type (short, int, int64, float, double). Sub_type 1
> indicates that the column was defined as decimal. Sub_type
> 2 indicates that the column was defined as numeric.
>
> When we make an ODS change, I'd like to add a column to
> rdb$fields called rdb$precision, to hold, (surprise) the
> defined precision. That will involve extending dyn and
> a few other things.
>
>
> Comments?
>
> Ann

Search for dsc_num_type_decimal in jrd/dsc.h. I chose numeric=1 and
decimal=2 so that the subtype of the result of an arithmetic operation
on mixed exact types is the MAX of the subtypes of the operands.
Putting DECIMAL between "the base storage type" and NUMERIC would make
it mildly annoying to follow the type promotion rules in the standard.

At present, the numeric subtypes only apply if the stored type is
SMALLINT, INTEGER, or INT64. I suppose that we could apply the
subtypes when the stored type is DOUBLE PRECISION, to accomodate
NUMERIC or DECIMAL declarations in SQL dialect 1. I didn't think of
it at the time. Do you think it's worth it? I tend to expect that
most people will move ASAP to dialect 3, so that their "exact numerics"
can actually *be* exact, but perhaps I'm too optimistic, and such
things as NUMERIC(13,0) fields stored in DOUBLE PRECISION are going to
be with us for a long time.

The proposed rdb$precision is now called rdb$field_precision, to match
the previously-existing rdb$field_scale.

ISQL's "SHOW TABLE" in 6.0 correctly reconstructs the declared type of
an exact numeric datum from the subtype, field_precision, and
field_scale columns of rdb$fields, unlike previous releases, which
guessed a precision of 4, 9, or 15 depending on the stored type,
and guessed "numeric" if the scale was non-zero.

--
Chris Jewell developer/sysadmin voice: 831-431-6531
cjewell@... InterBase Software, Borland-Inprise fax: 831-431-6510