Feature #1249
ストレージモードでdecimal型のデータを扱えない
| Status: | 完了 | Start date: | 01/14/2012 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 100% |
||
| Category: | - | |||
| Target version: | 1.2x |
Description
問題¶
ALTER TABLE ... ENGINE = mroonga でdecimal型のカラムの扱いに問題があるのではないか、という報告があった。
https://twitter.com/#!/Kiske/status/157763598649798656
decimal型のカラムを持ってるテーブルに対してALTER TABLE ~ ENGINE = groongaでストレージエンジン切り替えるとdecimal型のカラムデータが壊れてもた。これはバグなのかな? #groonga
が、確認してみると、そもそもdecimal型を扱えていないようだ。
以下のようにdecimal型のデータをinsertしてselectするとwarningがでる。
CREATE TABLE diaries (
id INT PRIMARY KEY AUTO_INCREMENT,
title TEXT,
temperature DECIMAL(6, 3)
) DEFAULT CHARSET UTF8;
SHOW CREATE TABLE diaries;
INSERT INTO diaries (title, temperature) VALUES ("clear day", 21.281);
INSERT INTO diaries (title, temperature) VALUES ("rainy day", 14.213);
INSERT INTO diaries (title, temperature) VALUES ("cloudy day", 17.821);
SELECT * FROM diaries;
id title temperature
1 clear day 0.000
2 rainy day 0.000
3 cloudy day 0.000
Warnings:
Warning 1366 Incorrect decimal value: 'clear day' for column 'temperature' at row 1
Warning 1366 Incorrect decimal value: 'rainy day' for column 'temperature' at row 2
Warning 1366 Incorrect decimal value: 'cloudy day' for column 'temperature' at row 3
期待する状態¶
insertしたdecimal型の値をselectで取得できる。
CREATE TABLE diaries (
id INT PRIMARY KEY AUTO_INCREMENT,
title TEXT,
temperature DECIMAL(6, 3)
) DEFAULT CHARSET UTF8;
SHOW CREATE TABLE diaries;
INSERT INTO diaries (title, temperature) VALUES ("clear day", 21.281);
INSERT INTO diaries (title, temperature) VALUES ("rainy day", 14.213);
INSERT INTO diaries (title, temperature) VALUES ("cloudy day", 17.821);
SELECT * FROM diaries;
id title temperature
1 clear day 21.281
2 rainy day 14.213
3 cloudy day 17.821
解決方法¶
データをgroongaに格納している部分か、groongaからデータを取得してMySQL用のデータにしているところのどちらかに問題があると思われるので、まずは、どちらが問題かを調べる。
History
Updated by Kouhei Sutou 4 months ago
- Status changed from 新規 to 完了チェック待ち
- % Done changed from 0 to 80
Applied in changeset commit:3af2a01221952ae94a51b190845b7187ab128662.
Updated by Kouhei Sutou 4 months ago
- Status changed from 完了チェック待ち to 完了
- Assignee changed from Kentoku SHIBA to Kouhei Sutou
- % Done changed from 80 to 100
どっちも対応していなかったので対応した。