Projects tigase _server server-core Issues #752
tig_users not compatible with MySQL server 5.7 (#752)
Daniele Ricci opened 8 years ago
Due Date
2017-03-15

Starting version 5.7, MySQL has enabled strict mode by default. I don't know if this strictly qualifies as a bug for Tigase, but the tig_users table doesn't work anymore. The problem is the last_login field having a default value of 0 which is not permitted.

Right now I don't have a solution at hand because using NULL as default might incur in code problems (although that column is never used in Tigase code base, but it may affect 3rd party code?), anyway a default value of NULL wouldn't work because of another TIMESTAMP column (@acc_create_time@) having CURRENT_TIMESTAMP as default. I don't understand why that could affect last_login having a NULL default, but it does. As a matter of fact, if you don't include acc_create_time in the DDL, last_login with default NULL works just fine.

Artur Hefczyc commented 8 years ago

CURRENT_TIMESTAMP for acc_create_time is necessary. last_login is used by some of our customers but mostly from tools outside Tigase. I do not know what would be most sensible default for this field except NULL which indicates that the user never logged in, which makes sense.

Daniele Ricci commented 8 years ago

That's the problem: you can't use NULL as default:

create table test1 (
    uid bigint unsigned NOT NULL auto_increment,
    acc_create_time timestamp DEFAULT CURRENT_TIMESTAMP,
    last_login timestamp DEFAULT NULL,
    primary key (uid));
ERROR 1067 (42000): Invalid default value for 'last_login'

This is because of strict mode.

wojciech.kapcia@tigase.net commented 8 years ago

Daniele Ricci wrote:

Starting version 5.7, MySQL has enabled strict mode by default.

Could you share exact version? especially in the context of:

anyway a default value of NULL wouldn't work because of another TIMESTAMP column (acc_create_time) having CURRENT_TIMESTAMP as default. I don't understand why that could affect last_login having a NULL default, but it does. As a matter of fact, if you don't include acc_create_time in the DDL, last_login with default NULL works just fine.

One field should not affect another one so maybe it's a bug in MySQL?

Daniele Ricci commented 8 years ago

Could you share exact version? especially in the context of:

Actually, after a few more tests I can say the problem happens everytime. It is not related to any other column, the problem is the default NULL value which is invalid.

And it seems like it's not a bug: https://bugs.mysql.com/bug.php?id=80086

Artur Hefczyc commented 8 years ago

Daniele, we will work on a solution, but, do you have any suggestions on, what would be the best way to resolve this?

Daniele Ricci commented 8 years ago

Artur Hefczyc wrote:

Daniele, we will work on a solution, but, do you have any suggestions on, what would be the best way to resolve this?

I believe converting columns last_login and last_logout to DATETIME (nullable) would be the right fix to this. I tried on MySQL 5.7, it works, however I don't know the impact on Tigase code. JDBC for MySQL returns javax.sql.Timestamp, just like the TIMESTAMP type, so it should not create any issue on reading. I'd focus more on checking the code that writes into that columns.

Artur Hefczyc commented 8 years ago

I think it should be possible. I am assigning this to Wojciech who will be working on the code.

wojciech.kapcia@tigase.net commented 8 years ago

Actually needed change was smaller than expected (thanks Andrzej!)

issue 1 of 1
Type
Bug
Priority
Normal
Assignee
RedmineID
4878
Version
tigase-server-7.1.1
Spent time
41h 15m
Issue Votes (0)
Watchers (0)
Reference
tigase/_server/server-core#752
Please wait...
Page is in error, reload to recover