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)
    

      

  • 相关阅读:
    matlab如何写一个类
    最大稳定极值区域(MSER)检测
    Excel中公式的绝对引用和相对引用单元格
    c++中自增(++)和自减(--)操作符
    C++中的c_str()函数用法
    一些常用的图像数据库
    浅谈C++中指针和引用的区别
    selenium之find_element_by_xpath定位元素
    python selenium使用
    H5页面调用手机扫一扫功能
  • 原文地址:https://www.cnblogs.com/milton/p/9976881.html
Copyright © 2011-2022 走看看