2020年9月6日日曜日

apt upgradeしたら、mysqlがアップデートされて、epgrecでキーワード登録できなくなった

 表題どおりなのですが....

apt upgradeして、mysqlが更新されたらしくその影響かキーワード登録したら下記のようなエラーが出るようになりました

__query:DBクエリ失敗:UPDATE Recorder_keywordTbl SET keyword='test', kw_enable='1', typeGR='1', typeBS='1', typeCS='1', typeEX='', channel_id='0', category_id='0', sub_genre='16', use_regexp='', collate_ci='', ena_title='1', ena_desc='1', autorec_mode='1', weekofdays='127', prgtime='24', period='1', first_genre='1', priority='10', overlap='0', split_time='0', sft_start='0', sft_end='0', discontinuity='0', duration_chg='0', directory='', filename_format='', criterion_dura='0', rest_alert='0', smart_repeat='0' WHERE id=37

epgrecソースを見ると DBRecord.class.php で出している様子

動きから見て、キーワードの登録以外、過去のキーワードに基づく録画番組の自動登録は問題なく動いているみたい。

ソースを見ると発行している SQL 文そのものをエラーメッセージに表示してるようなのでコピペして実行します


hogehoge@foo:/etc/mysql$ mysql -u epgrec -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.31-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use epgrec;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> UPDATE Recorder_keywordTbl SET keyword='test', kw_enable='1', typeGR='1', typeBS='1', typeCS='1', typeEX='', channel_id='0', category_id='0', sub_genre='16', use_regexp='', collate_ci='', ena_title='1', ena_desc='1', autorec_mode='1', weekofdays='127', prgtime='24', period='1', first_genre='1', priority='10', overlap='0', split_time='0', sft_start='0', sft_end='0', discontinuity='0', duration_chg='0', directory='', filename_format='', criterion_dura='0', rest_alert='0', smart_repeat='0' WHERE id=38;
ERROR 1366 (HY000): Incorrect integer value: '' for column 'typeEX' at row 1
mysql>

これが原因ですね
Incorrect integer value: '' for column 'typeEX' at row 

値を厳密解釈するようになって、' 'はintegerじゃねぇ、って言っている模様。

このあたりを見ると STRICT_TRANS_TABLESっていうのが勝手に設定された、ということか。
ひとまずどう設定されているのかを見てみる

mysql> select @@GLOBAL.sql_mode;
+-------------------------------------------------------------------------------------------------------------------------------------------+
| @@GLOBAL.sql_mode                                                                                                                         |
+-------------------------------------------------------------------------------------------------------------------------------------------+
| ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+-------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

しかし、/etc/my.cnfにはこの設定を行っているはずの sql-mode という項目がなかった。
defaultでこれらが設定されているということか。
ちゃんと各オプションを調べるべきなんだろうけど、えい、まぁーいいや

[mysqld]
 sql-mode = ''

のようにsql-modeを”なし”で設定してお茶を濁す

mysql再起動して動作確認 -> OK!