36 lines
2.0 KiB
Diff
36 lines
2.0 KiB
Diff
References: https://jira.zarafa.com/browse/ZCP-11934
|
|
References: https://jira.zarafa.com/browse/ZCP-12219
|
|
References: https://jira.zarafa.com/browse/ZCP-12381
|
|
References: https://forums.zarafa.com/showthread.php?7980-SQL-error-on-Zarafa-7-1-with-MariaDB-5-5-25/page3.There
|
|
References: https://bugzilla.novell.com/show_bug.cgi?id=880272
|
|
---
|
|
provider/libserver/ECDatabaseMySQL.cpp | 15 +++++++++++----
|
|
1 file changed, 11 insertions(+), 4 deletions(-)
|
|
|
|
Index: zarafa-7.1.9/provider/libserver/ECDatabaseMySQL.cpp
|
|
===================================================================
|
|
--- zarafa-7.1.9.orig/provider/libserver/ECDatabaseMySQL.cpp
|
|
+++ zarafa-7.1.9/provider/libserver/ECDatabaseMySQL.cpp
|
|
@@ -626,10 +626,17 @@ ECRESULT ECDatabaseMySQL::Connect()
|
|
if (m_ulMaxAllowedPacket < MAX_ALLOWED_PACKET)
|
|
m_lpLogger->Log(EC_LOGLEVEL_WARNING, "max_allowed_packet is smaller than 16M (%d). You are advised to increase this value by adding max_allowed_packet=16M in the [mysqld] section of my.cnf.", m_ulMaxAllowedPacket);
|
|
|
|
- if (m_lpMySQL.server_version && m_lpMySQL.server_version[0] >= '5') {
|
|
- // this option was introduced in mysql 5.0, so let's not even try on 4.1 servers
|
|
- strQuery = "SET SESSION sql_mode = 'STRICT_ALL_TABLES'";
|
|
- Query(strQuery); // ignore error
|
|
+ if (m_lpMySQL.server_version) {
|
|
+ // m_lpMySQL.server_version is a C type string (char*) containing something like "5.5.37-0+wheezy1" (MySQL),
|
|
+ // "5.5.37-MariaDB-1~wheezy-log" or "10.0.11-MariaDB=1~wheezy-log" (MariaDB)
|
|
+ // The following code may look funny, but it is correct, see http://www.cplusplus.com/reference/cstdlib/strtol/
|
|
+ long int majorversion = strtol(m_lpMySQL.server_version, NULL, 10);
|
|
+ // Check for over/underflow and version.
|
|
+ if ((errno != ERANGE) && (majorversion >= 5)) {
|
|
+ // this option was introduced in mysql 5.0, so let's not even try on 4.1 servers
|
|
+ strQuery = "SET SESSION sql_mode = 'STRICT_ALL_TABLES,NO_UNSIGNED_SUBTRACTION'";
|
|
+ Query(strQuery); // ignore error
|
|
+ }
|
|
}
|
|
|
|
exit:
|