commit:     fcd29d4494974a776c442fafed0e1782d60a824d
Author:     Michael Palimaka <kensington <AT> gentoo <DOT> org>
AuthorDate: Mon Sep 25 13:18:26 2017 +0000
Commit:     Michael Palimaka <kensington <AT> gentoo <DOT> org>
CommitDate: Mon Sep 25 13:18:41 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fcd29d44

dev-qt/qtsql: backport patch from upstream solving runtime failure with 
>=dev-db/mariadb-10.2

Bug: https://bugs.gentoo.org/626464
Package-Manager: Portage-2.3.8, Repoman-2.3.3

 dev-qt/qtsql/files/qtsql-5.7.1-mariadb.patch | 56 ++++++++++++++++++++++++++++
 dev-qt/qtsql/qtsql-5.7.1-r1.ebuild           | 55 +++++++++++++++++++++++++++
 2 files changed, 111 insertions(+)

diff --git a/dev-qt/qtsql/files/qtsql-5.7.1-mariadb.patch 
b/dev-qt/qtsql/files/qtsql-5.7.1-mariadb.patch
new file mode 100644
index 00000000000..8aede46c3b4
--- /dev/null
+++ b/dev-qt/qtsql/files/qtsql-5.7.1-mariadb.patch
@@ -0,0 +1,56 @@
+From d25346417238b7dc0fb37359a9b56eff2908a5dc Mon Sep 17 00:00:00 2001
+From: =?utf8?q?Daniel=20Vr=C3=A1til?= <[email protected]>
+Date: Mon, 18 Sep 2017 22:33:55 +0200
+Subject: [PATCH] Only call mysql_library_end() once when using MariaDB
+
+MariaDB allows only a single call to mysql_library_end(), all subsequent calls
+to mysql_library_init() or any other API call will fail. Since QMYSQLDriver
+calls mysql_library_end() function whenever the refcount drops to 0, this
+breaks applications that close and reopen database connections.
+
+This change registers call to mysql_library_init() via qAddPostRoutine()
+when compiled against MariaDB, so that we only call it once.
+
+Task-number: QTBUG-63108
+Change-Id: I22c1f0c5b081216f12596a32748dca25cae919e9
+Reviewed-by: Andy Shaw <[email protected]>
+---
+ src/plugins/sqldrivers/mysql/qsql_mysql.cpp | 18 ++++++++++++------
+ 1 file changed, 12 insertions(+), 6 deletions(-)
+
+diff --git a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp 
b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index ee439fa..6e428fb 100644
+--- a/src/sql/drivers/mysql/qsql_mysql.cpp
++++ b/src/sql/drivers/mysql/qsql_mysql.cpp
+@@ -1158,16 +1158,22 @@ static void qLibraryInit()
+     }
+ # endif // MYSQL_VERSION_ID
+ #endif // Q_NO_MYSQL_EMBEDDED
++
++#ifdef MARIADB_BASE_VERSION
++    qAddPostRoutine(mysql_server_end);
++#endif
+ }
+ 
+ static void qLibraryEnd()
+ {
+-#ifndef Q_NO_MYSQL_EMBEDDED
+-# if MYSQL_VERSION_ID > 40000
+-#  if (MYSQL_VERSION_ID >= 40110 && MYSQL_VERSION_ID < 50000) || 
MYSQL_VERSION_ID >= 50003
+-    mysql_library_end();
+-#  else
+-    mysql_server_end();
++#if !defined(MARIADB_BASE_VERSION)
++# if !defined(Q_NO_MYSQL_EMBEDDED)
++#  if MYSQL_VERSION_ID > 40000
++#   if (MYSQL_VERSION_ID >= 40110 && MYSQL_VERSION_ID < 50000) || 
MYSQL_VERSION_ID >= 50003
++     mysql_library_end();
++#   else
++     mysql_server_end();
++#   endif
+ #  endif
+ # endif
+ #endif
+-- 
+2.7.4
+

diff --git a/dev-qt/qtsql/qtsql-5.7.1-r1.ebuild 
b/dev-qt/qtsql/qtsql-5.7.1-r1.ebuild
new file mode 100644
index 00000000000..c0f66a04ad4
--- /dev/null
+++ b/dev-qt/qtsql/qtsql-5.7.1-r1.ebuild
@@ -0,0 +1,55 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+QT5_MODULE="qtbase"
+inherit qt5-build
+
+DESCRIPTION="SQL abstraction library for the Qt5 tooolkit"
+
+if [[ ${QT5_BUILD_TYPE} == release ]]; then
+       KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ppc ~ppc64 ~x86"
+fi
+
+IUSE="freetds mysql oci8 odbc postgres +sqlite"
+
+REQUIRED_USE="
+       || ( freetds mysql oci8 odbc postgres sqlite )
+"
+
+DEPEND="
+       ~dev-qt/qtcore-${PV}
+       freetds? ( dev-db/freetds )
+       mysql? ( virtual/libmysqlclient:= )
+       oci8? ( dev-db/oracle-instantclient-basic )
+       odbc? ( || ( dev-db/unixODBC dev-db/libiodbc ) )
+       postgres? ( dev-db/postgresql:* )
+       sqlite? ( >=dev-db/sqlite-3.8.10.2:3 )
+"
+RDEPEND="${DEPEND}"
+
+PATCHES=( "${FILESDIR}/${PN}-5.7.1-mariadb.patch" )
+
+QT5_TARGET_SUBDIRS=(
+       src/sql
+       src/plugins/sqldrivers
+)
+
+src_configure() {
+       local myconf=(
+               $(qt_use freetds  sql-tds    plugin)
+               $(qt_use mysql    sql-mysql  plugin)
+               $(qt_use oci8     sql-oci    plugin)
+               $(qt_use odbc     sql-odbc   plugin)
+               $(qt_use postgres sql-psql   plugin)
+               $(qt_use sqlite   sql-sqlite plugin)
+               $(usex sqlite -system-sqlite '')
+       )
+
+       use mysql && myconf+=("-I${EPREFIX}/usr/include/mysql" 
"-L${EPREFIX}/usr/$(get_libdir)/mysql")
+       use oci8 && myconf+=("-I${ORACLE_HOME}/include" 
"-L${ORACLE_HOME}/$(get_libdir)")
+       use odbc && myconf+=("-I${EPREFIX}/usr/include/iodbc")
+       use postgres && myconf+=("-I${EPREFIX}/usr/include/postgresql/pgsql")
+
+       qt5-build_src_configure
+}

Reply via email to