zoukankan      html  css  js  c++  java
  • MySQL5.7在JSON解析后丢失小数部分的Bug

    在MySQL Bugs上提交了 https://bugs.mysql.com/bug.php?id=84935 . 已经在MySQL8.0.1中修复

    重现步骤

    -- Prepare the table and populate it with records
    
    CREATE TABLE `voucher` (
      `id` varchar(32) NOT NULL COMMENT 'ID',
      `vals` mediumtext NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    
    INSERT INTO `voucher` VALUES ('1', '{"period":90,"amount":5.45}');
    INSERT INTO `voucher` VALUES ('2', '{"period":90,"amount":3.99}');
    
    -- Execute queries
    
    mysql> SELECT vals FROM voucher WHERE id='1';
    +-----------------------------+
    | vals                        |
    +-----------------------------+
    | {"period":90,"amount":5.45} |
    +-----------------------------+
    1 row in set (0.00 sec)
    
    mysql> SELECT json_extract(vals, '$.amount') FROM voucher WHERE id='1';
    +--------------------------------+
    | json_extract(vals, '$.amount') |
    +--------------------------------+
    | 5.45                           |
    +--------------------------------+
    1 row in set (0.00 sec)
    
    -- The result of this one is not correct
    mysql> SELECT SUM(json_extract(vals, '$.amount')) FROM voucher WHERE id='1'; 
    +-------------------------------------+
    | SUM(json_extract(vals, '$.amount')) |
    +-------------------------------------+
    |                                   5 |
    +-------------------------------------+
    1 row in set (0.00 sec)
    
    mysql> SELECT ROUND(SUM(json_extract(vals, '$.amount')), 2) FROM voucher WHERE id='1';
    +-----------------------------------------------+
    | ROUND(SUM(json_extract(vals, '$.amount')), 2) |
    +-----------------------------------------------+
    |                                          5.45 |
    +-----------------------------------------------+
    1 row in set (0.00 sec)
    

      

  • 相关阅读:
    Jxl 简单运用 Excel创建,插入数据,图片,更新数据,
    tomcat端口号被占用
    QQ、MSN、淘包旺旺、Skype临时对话的html链接代码
    验证信息
    wpf学习笔记数据绑定功能总结
    wpfStyle注意点
    wpf轻量绘图DrawingVisual
    wpfDrawingBrush注意点
    wpf容易误解的Image
    wpf装饰器
  • 原文地址:https://www.cnblogs.com/milton/p/9976881.html
Copyright © 2011-2022 走看看