没有合适的资源?快使用搜索试试~ 我知道了~
Decimal测试案例文档1
需积分: 0 1 下载量 101 浏览量
2022-08-08
21:51:52
上传
评论
收藏 931KB DOCX 举报
温馨提示
试读
26页
Decimal测试案例文档1
资源详情
资源评论
资源推荐
1. 针对一个 decimal 类型属性,在插入数据时(未超精度范围),插入结果会出
错。示例如下:
drop table if exists t1;
create table t1(c1 int, c2 decimal(38,0), primary key(c1));
insert into t1 values (1, 99999999999999999999);
select * from t1;
结果错误(已知错误,其使用手册中有说明)
按照其使用手册的使用方法,在上述数据后面加上小数,就可正常插入,但是实
际执行结果依然错误。
insert into t1 values (2, 99999999999999999999.0);
select * from t1;
insert into t1 values (3, 99999999999999999999999999999999999999.0);
select * from t1;
该错误已解决
2. 针对一个 decimal 类型属性,插入一个整数部分超过精度范围的数据,未报
错,没有越界判断。示例如下:
drop table if exists t1;
create table t1(c1 int, c2 decimal(38,0), primary key(c1));
insert into t1 values (1, 99999999999999999999);
insert into t1 values (2, 99999999999999999999.0);
insert into t1 values (3, 99999999999999999999999999999999999999.0);
insert into t1 values (4, 199999999999999999999999999999999999999.0);
select * from t1;
该错误已解决
3. 针对一个 decimal 类型属性,插入一个小数位数较多但未超过其小数位精度
的数据时,会报异常,正常情况应该可以执行。示例如下:
drop table if exists t1;
create table t1(c1 int, c2 decimal(37,37), primary key(c1));
insert into t1 values (4, 0.9999999999999999999999999999999999999); (小数位
为 37 个 9)
该错误已解决
4. 针对一个 decimal 类型属性,无法插入一个负数。示例如下:
drop table if exists t1;
create table t1(c1 int primary key, c2 decimal(5,1));
insert into t1 values (1, -1111.1);
该错误已解决
5. 两个 decimal 类型属性做加法运算时,精度控制与文档描述不符。示例如
下:
drop table if exists t1;
create table t1(c1 int, c2 decimal(32,10), c3 decimal(20,17), primary key(c1));
insert into t1 values (1, 1190000000000000000000.00000000011,
999.11111111111111111111111111111);
select c2+c3 from t1;
p=min(38,39)=38,s=17
实际结果是小数位 16,整数位 22。
(文档已经解释)
6. 报错信息不规范:
drop table if exists t1;
create table t1(k int primary key, c2 decimal(39,0));
注意:首先,逗号后面应有空格,最后一个等号两边也应有空格;并且应该提示
39 大于目前 decimal 可支持的最大精度 38。
(报错不规范问题)
drop table if exists t1;
create table t1(k int primary key, c2 decimal(-1,-1));
与上面的报错形式不一致。
(负数报错在不同的位置)
drop table if exists t1;
create table t1(k int primary key, c2 decimal(1,0));
insert into t1 values (2, 10);
应该报-57。-58 指十进制数不合法,而-57 指十进制数溢出
(-58 是 decimal 溢出问题)
7. 当属性定义为 decimal(p, 0)时,若插入的数字中仅含有小数部分或为 0,则会
导致插入的数据有误,并且都为最大值(38 个 9)。
drop table if exists t1;
create table t1(k int primary key, c2 decimal(5,0));
insert into t1 values (1, 0);
insert into t1 values (2, 0.1);
insert into t1 values (3, 1.1);
insert into t1 values (4, -1);
select * from t1;
(已经修改)
8. decimal 加法运算正确性有误,示例如下:
Cedar:
drop table if exists t1;
create table t1(k int primary key, c2 decimal(15,5), c3 decimal(38,0));
insert into t1 values (1, 9999999999.99999,
99999999999999999999999999999999999991.99);
select * from t1;
select c2+c3 from t1;
select c2+c3+1 from t1;
MySQL:
drop table if exists t1;
create table t1(k int primary key, c2 decimal(15,5), c3 decimal(65,0));
insert into t1 values (1, 9999999999.99999,
99999999999999999999999999999999999999999999999999999999999999999);
select * from t1;
select c2+c3 from t1;
select c2+c3+1 from t1;
注意:MySQL 对于运算结果没有最大值的概念,但是 Cedar 有,并且在运算过
程中如果出现最大值,计算结果就会由于不正确的截取策略而出错。建议遇此情
况,给出适当提示信息。
(文档已经说明)
9. decimal 减法运算正确性有误,示例如下:
drop table if exists t1;
create table t1(k int primary key, c2 decimal(15,5), c3 decimal(10,3));
insert into t1 values (3, -9999999999.99999, -9999999.999);
select * from t1;
select c2+c3 from t1;
select -c2-c3 from t1;
注意:其中加法的计算结果是正确的,减法的结算结果是错误的。
(已解决)
10. 除法的计算结果精度控制与文档中描述不符,示例如下:
drop table if exists t1;
create table t1(k int primary key, c2 decimal(15,5), c3 decimal(10,3));
insert into t1 values (1, 9999999999.99999, 9999999.999);
insert into t1 values (2, -9999999999.99999, 9999999.999);
insert into t1 values (3, -9999999999.99999, -9999999.999);
replace into t1 values (4, -1111111111.99999, 9999999.999);
select c2/c3 from t1;
select c3/c2 from t1;
剩余25页未读,继续阅读
奔跑的楠子
- 粉丝: 23
- 资源: 299
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0