| 1 | // For license of this file, see <project-root-folder>/LICENSE.md.cxx . . $ `<file>/src/librssguard/database/mariadbdriver.cpp`/ |
| 2 | |
| 3 | #include "database/mariadbdriver.h"cxx . . $ `<file>/src/librssguard/database/mariadbdriver.h`/ |
| 4 | |
| 5 | #include "definitions/definitions.h"cxx . . $ `<file>/src/librssguard/definitions/definitions.h`/ |
| 6 | #include "exceptions/applicationexception.h"cxx . . $ `<file>/src/librssguard/exceptions/applicationexception.h`/ |
| 7 | #include "miscellaneous/application.h"cxx . . $ `<file>/src/librssguard/miscellaneous/application.h`/ |
| 8 | #include "miscellaneous/settings.h"cxx . . $ `<file>/src/librssguard/miscellaneous/settings.h`/ |
| 9 | |
| 10 | #include <QDir> |
| 11 | #include <QSqlError> |
| 12 | #include <QSqlQuery> |
| 13 | |
| 14 | MariaDbDrivercxx . . $ MariaDbDriver#::MariaDbDrivercxx . . $ MariaDbDriver#MariaDbDriver(749de1b6ae65bddd).(QObjectcxx . . $ QObject#* parent) : DatabaseDrivercxx . . $ DatabaseDriver#(parent), m_databaseInitializedcxx . . $ MariaDbDriver#m_databaseInitialized.(false) {} |
| 15 | |
| 16 | QStringcxx . . $ QString# MariaDbDrivercxx . . $ MariaDbDriver#::ddlFilePrefixcxx . . $ MariaDbDriver#ddlFilePrefix(6ef7b6c27b00b43d).() const { |
| 17 | return QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("mysql"); |
| 18 | } |
| 19 | |
| 20 | MariaDbDrivercxx . . $ MariaDbDriver#::MariaDbErrorcxx . . $ MariaDbDriver#MariaDbError# MariaDbDrivercxx . . $ MariaDbDriver#::testConnectioncxx . . $ MariaDbDriver#testConnection(448e532f876e32bb).(const QStringcxx . . $ QString#& hostname, |
| 21 | int port, |
| 22 | const QStringcxx . . $ QString#& w_database, |
| 23 | const QStringcxx . . $ QString#& username, |
| 24 | const QStringcxx . . $ QString#& password) { |
| 25 | QSqlDatabasecxx . . $ QSqlDatabase# database = QSqlDatabasecxx . . $ QSqlDatabase#::addDatabasecxx . . $ QSqlDatabase#addDatabase(660a07b34cb8c61b).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!(APP_DB_MYSQL_DRIVERcxx . . $ `src/librssguard/definitions/definitions.h:222:9`!), QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!(APP_DB_MYSQL_TESTcxx . . $ `src/librssguard/definitions/definitions.h:224:9`!)); |
| 26 | |
| 27 | database.setHostNamecxx . . $ QSqlDatabase#setHostName(3520e46b33348bf6).(hostname); |
| 28 | database.setPortcxx . . $ QSqlDatabase#setPort(d4f767463ce0a6b3).(port); |
| 29 | database.setUserNamecxx . . $ QSqlDatabase#setUserName(3520e46b33348bf6).(username); |
| 30 | database.setPasswordcxx . . $ QSqlDatabase#setPassword(3520e46b33348bf6).(password); |
| 31 | database.setDatabaseNamecxx . . $ QSqlDatabase#setDatabaseName(3520e46b33348bf6).(w_database); |
| 32 | |
| 33 | if (database.opencxx . . $ QSqlDatabase#open(c9857a73d68e59ba).() && !database.lastErrorcxx . . $ QSqlDatabase#lastError(b02d9d6c0f4da678).().isValidcxx . . $ QSqlError#isValid(50ce9a9e25b4a850).()) { |
| 34 | QSqlQuerycxx . . $ QSqlQuery# querycxx . . $ QSqlQuery#QSqlQuery(c76688c450d56ca3).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("SELECT version();"), database); |
| 35 | |
| 36 | if (!query.lastErrorcxx . . $ QSqlQuery#lastError(b02d9d6c0f4da678).().isValidcxx . . $ QSqlError#isValid(50ce9a9e25b4a850).() && query.nextcxx . . $ QSqlQuery#next(c9857a73d68e59ba).()) { |
| 37 | qDebugNNcxx . . $ `src/librssguard/definitions/definitions.h:413:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_DBcxx . . $ `src/librssguard/definitions/definitions.h:180:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Checked MySQL database, version is" <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). QUOTE_W_SPACE_DOTcxx . . $ `src/librssguard/definitions/definitions.h:430:9`!(query.value(0).toString()); |
| 38 | |
| 39 | // Connection succeeded, clean up the mess and return OK status. |
| 40 | database.closecxx . . $ QSqlDatabase#close(49f6e7a06ebc5aa8).(); |
| 41 | return MariaDbErrorcxx . . $ MariaDbDriver#MariaDbError#::Okcxx . . $ MariaDbDriver#MariaDbError#Ok.; |
| 42 | } |
| 43 | else { |
| 44 | database.closecxx . . $ QSqlDatabase#close(49f6e7a06ebc5aa8).(); |
| 45 | return MariaDbErrorcxx . . $ MariaDbDriver#MariaDbError#::UnknownErrorcxx . . $ MariaDbDriver#MariaDbError#UnknownError.; |
| 46 | } |
| 47 | } |
| 48 | else if (database.lastErrorcxx . . $ QSqlDatabase#lastError(b02d9d6c0f4da678).().isValidcxx . . $ QSqlError#isValid(50ce9a9e25b4a850).()) { |
| 49 | auto nat = database.lastErrorcxx . . $ QSqlDatabase#lastError(b02d9d6c0f4da678).().nativeErrorCodecxx . . $ QSqlError#nativeErrorCode(6ef7b6c27b00b43d).(); |
| 50 | bool nat_converted = false; |
| 51 | auto nat_int = nat.toIntcxx . . $ QString#toInt(d7972accae11ee1f).(&nat_converted); |
| 52 | |
| 53 | if (nat_converted) { |
| 54 | return static_cast<MariaDbErrorcxx . . $ MariaDbDriver#MariaDbError#>(nat_int); |
| 55 | } |
| 56 | else { |
| 57 | qWarningNNcxx . . $ `src/librssguard/definitions/definitions.h:417:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_DBcxx . . $ `src/librssguard/definitions/definitions.h:180:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Failed to recognize MySQL error code:" <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). QUOTE_W_SPACE_DOTcxx . . $ `src/librssguard/definitions/definitions.h:430:9`!(nat); |
| 58 | |
| 59 | return MariaDbErrorcxx . . $ MariaDbDriver#MariaDbError#::UnknownErrorcxx . . $ MariaDbDriver#MariaDbError#UnknownError.; |
| 60 | } |
| 61 | } |
| 62 | else { |
| 63 | return MariaDbErrorcxx . . $ MariaDbDriver#MariaDbError#::UnknownErrorcxx . . $ MariaDbDriver#MariaDbError#UnknownError.; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | QStringcxx . . $ QString# MariaDbDrivercxx . . $ MariaDbDriver#::locationcxx . . $ MariaDbDriver#location(6ef7b6c27b00b43d).() const { |
| 68 | return QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("%1/%2").argcxx . . $ QString#arg(89b093bd48b6d6c0).(qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->settingscxx . . $ Application#settings(951936487a2d9252).()->valuecxx . . $ Settings#value(8f1f29a69568d71a).(GROUPcxx . . $ `src/librssguard/miscellaneous/settings.h:32:9`!(Database), SETTINGcxx . . $ `src/librssguard/miscellaneous/settings.h:30:9`!(Database::MySQLHostname)).toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).(), |
| 69 | qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->settingscxx . . $ Application#settings(951936487a2d9252).()->valuecxx . . $ Settings#value(8f1f29a69568d71a).(GROUPcxx . . $ `src/librssguard/miscellaneous/settings.h:32:9`!(Database), SETTINGcxx . . $ `src/librssguard/miscellaneous/settings.h:30:9`!(Database::MySQLDatabase)).toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).()); |
| 70 | } |
| 71 | |
| 72 | QStringcxx . . $ QString# MariaDbDrivercxx . . $ MariaDbDriver#::interpretErrorCodecxx . . $ MariaDbDriver#interpretErrorCode(5b8c6d2996ae752c).(MariaDbDrivercxx . . $ MariaDbDriver#::MariaDbErrorcxx . . $ MariaDbDriver#MariaDbError# error_code) const { |
| 73 | switch (error_code) { |
| 74 | case MariaDbErrorcxx . . $ MariaDbDriver#MariaDbError#::Okcxx . . $ MariaDbDriver#MariaDbError#Ok.: |
| 75 | return trcxx . . $ MariaDbDriver#tr(75d9f1c324b4579d).("MySQL server works as expected."); |
| 76 | |
| 77 | case MariaDbErrorcxx . . $ MariaDbDriver#MariaDbError#::UnknownDatabasecxx . . $ MariaDbDriver#MariaDbError#UnknownDatabase.: |
| 78 | return trcxx . . $ MariaDbDriver#tr(75d9f1c324b4579d).("Selected database does not exist (yet). It will be created. It's okay."); |
| 79 | |
| 80 | case MariaDbErrorcxx . . $ MariaDbDriver#MariaDbError#::CantConnectcxx . . $ MariaDbDriver#MariaDbError#CantConnect.: |
| 81 | case MariaDbErrorcxx . . $ MariaDbDriver#MariaDbError#::ConnectionErrorcxx . . $ MariaDbDriver#MariaDbError#ConnectionError.: |
| 82 | case MariaDbErrorcxx . . $ MariaDbDriver#MariaDbError#::UnknownHostcxx . . $ MariaDbDriver#MariaDbError#UnknownHost.: |
| 83 | return trcxx . . $ MariaDbDriver#tr(75d9f1c324b4579d).("No MySQL server is running in the target destination."); |
| 84 | |
| 85 | case MariaDbErrorcxx . . $ MariaDbDriver#MariaDbError#::AccessDeniedcxx . . $ MariaDbDriver#MariaDbError#AccessDenied.: |
| 86 | return trcxx . . $ MariaDbDriver#tr(75d9f1c324b4579d).("Access denied. Invalid username or password used."); |
| 87 | |
| 88 | default: |
| 89 | return trcxx . . $ MariaDbDriver#tr(75d9f1c324b4579d).("Unknown error: '%1'.").argcxx . . $ QString#arg(ed67e9a87de2cd4e).(int(error_code)); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | QStringcxx . . $ QString# MariaDbDrivercxx . . $ MariaDbDriver#::humanDriverTypecxx . . $ MariaDbDriver#humanDriverType(6ef7b6c27b00b43d).() const { |
| 94 | return QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("MariaDB"); |
| 95 | } |
| 96 | |
| 97 | QStringcxx . . $ QString# MariaDbDrivercxx . . $ MariaDbDriver#::qtDriverCodecxx . . $ MariaDbDriver#qtDriverCode(6ef7b6c27b00b43d).() const { |
| 98 | return QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!(APP_DB_MYSQL_DRIVERcxx . . $ `src/librssguard/definitions/definitions.h:222:9`!); |
| 99 | } |
| 100 | |
| 101 | DatabaseDrivercxx . . $ DatabaseDriver#::DriverTypecxx . . $ DatabaseDriver#DriverType# MariaDbDrivercxx . . $ MariaDbDriver#::driverTypecxx . . $ MariaDbDriver#driverType(2f4784d5e94eaa66).() const { |
| 102 | return DatabaseDrivercxx . . $ DatabaseDriver#::DriverTypecxx . . $ DatabaseDriver#DriverType#::MySQLcxx . . $ DatabaseDriver#DriverType#MySQL.; |
| 103 | } |
| 104 | |
| 105 | bool MariaDbDrivercxx . . $ MariaDbDriver#::vacuumDatabasecxx . . $ MariaDbDriver#vacuumDatabase(c9857a73d68e59ba).() { |
| 106 | QSqlDatabasecxx . . $ QSqlDatabase# database = connectioncxx . . $ MariaDbDriver#connection(32d6d64cc6e35a97).(objectNamecxx . . $ QObject#objectName(6ef7b6c27b00b43d).()); |
| 107 | QSqlQuerycxx . . $ QSqlQuery# query_vacuumcxx . . $ QSqlQuery#QSqlQuery(b3df2939303ae7a3).(database); |
| 108 | |
| 109 | return query_vacuum.execcxx . . $ QSqlQuery#exec(e1defb592416720d).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("OPTIMIZE TABLE Feeds;")) && query_vacuum.execcxx . . $ QSqlQuery#exec(e1defb592416720d).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("OPTIMIZE TABLE Messages;")); |
| 110 | } |
| 111 | |
| 112 | bool MariaDbDrivercxx . . $ MariaDbDriver#::saveDatabasecxx . . $ MariaDbDriver#saveDatabase(c9857a73d68e59ba).() { |
| 113 | return true; |
| 114 | } |
| 115 | |
| 116 | void MariaDbDrivercxx . . $ MariaDbDriver#::backupDatabasecxx . . $ MariaDbDriver#backupDatabase(c1427772cd1877b0).(const QStringcxx . . $ QString#& backup_folder, const QStringcxx . . $ QString#& backup_name) { |
| 117 | Q_UNUSEDcxx . . $ `<external>/17563275351362271547/qtpreprocessorsupport.h:20:9`!(backup_folder) |
| 118 | Q_UNUSEDcxx . . $ `<external>/17563275351362271547/qtpreprocessorsupport.h:20:9`!(backup_name) |
| 119 | |
| 120 | saveDatabasecxx . . $ MariaDbDriver#saveDatabase(c9857a73d68e59ba).(); |
| 121 | } |
| 122 | |
| 123 | bool MariaDbDrivercxx . . $ MariaDbDriver#::initiateRestorationcxx . . $ MariaDbDriver#initiateRestoration(e1defb592416720d).(const QStringcxx . . $ QString#& database_package_file) { |
| 124 | Q_UNUSEDcxx . . $ `<external>/17563275351362271547/qtpreprocessorsupport.h:20:9`!(database_package_file) |
| 125 | return true; |
| 126 | } |
| 127 | |
| 128 | bool MariaDbDrivercxx . . $ MariaDbDriver#::finishRestorationcxx . . $ MariaDbDriver#finishRestoration(c9857a73d68e59ba).() { |
| 129 | return true; |
| 130 | } |
| 131 | |
| 132 | qint64cxx . . $ qint64# MariaDbDrivercxx . . $ MariaDbDriver#::databaseDataSizecxx . . $ MariaDbDriver#databaseDataSize(a5d9f2bf8849668d).() { |
| 133 | QSqlDatabasecxx . . $ QSqlDatabase# database = connectioncxx . . $ MariaDbDriver#connection(32d6d64cc6e35a97).(metaObjectcxx . . $ QString#QString(85c52e162fed56f9).()->classNamecxx . . $ QMetaObject#className(a9f41ea0e82d88cf).()); |
| 134 | QSqlQuerycxx . . $ QSqlQuery# querycxx . . $ QSqlQuery#QSqlQuery(b3df2939303ae7a3).(database); |
| 135 | |
| 136 | query.preparecxx . . $ QSqlQuery#prepare(e1defb592416720d).("SELECT Round(Sum(data_length + index_length), 1) "cxx . . $ QString#QString(85c52e162fed56f9). |
| 137 | "FROM information_schema.tables " |
| 138 | "WHERE table_schema = :db " |
| 139 | "GROUP BY table_schema;"); |
| 140 | query.bindValuecxx . . $ QSqlQuery#bindValue(45793ecdf640d4c).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!(":db"), databasecxx . . $ QVariant#QVariant(132dd6869045752b)..databaseNamecxx . . $ QSqlDatabase#databaseName(6ef7b6c27b00b43d).()); |
| 141 | |
| 142 | if (query.execcxx . . $ QSqlQuery#exec(c9857a73d68e59ba).() && query.nextcxx . . $ QSqlQuery#next(c9857a73d68e59ba).()) { |
| 143 | return query.valuecxx . . $ QSqlQuery#value(fb36142a814bbf95).(0).valuecxx . . $ QVariant#value(1e6269539e51e84a).<qint64cxx . . $ qint64#>(); |
| 144 | } |
| 145 | else { |
| 146 | return 0; |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | QSqlDatabasecxx . . $ QSqlDatabase# MariaDbDrivercxx . . $ MariaDbDriver#::initializeDatabasecxx . . $ MariaDbDriver#initializeDatabase(595cbf0763205266).(const QStringcxx . . $ QString#& connection_name) { |
| 151 | // Folders are created. Create new QSqlDatabase object. |
| 152 | QSqlDatabasecxx . . $ QSqlDatabase# database = QSqlDatabasecxx . . $ QSqlDatabase#::addDatabasecxx . . $ QSqlDatabase#addDatabase(660a07b34cb8c61b).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!(APP_DB_MYSQL_DRIVERcxx . . $ `src/librssguard/definitions/definitions.h:222:9`!), connection_name); |
| 153 | const QStringcxx . . $ QString# database_name = qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->settingscxx . . $ Application#settings(951936487a2d9252).()->valuecxx . . $ Settings#value(8f1f29a69568d71a).(GROUPcxx . . $ `src/librssguard/miscellaneous/settings.h:32:9`!(Database), SETTINGcxx . . $ `src/librssguard/miscellaneous/settings.h:30:9`!(Database::MySQLDatabase)).toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).(); |
| 154 | |
| 155 | database.setHostNamecxx . . $ QSqlDatabase#setHostName(3520e46b33348bf6).(qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->settingscxx . . $ Application#settings(951936487a2d9252).()->valuecxx . . $ Settings#value(8f1f29a69568d71a).(GROUPcxx . . $ `src/librssguard/miscellaneous/settings.h:32:9`!(Database), SETTINGcxx . . $ `src/librssguard/miscellaneous/settings.h:30:9`!(Database::MySQLHostname)).toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).()); |
| 156 | database.setPortcxx . . $ QSqlDatabase#setPort(d4f767463ce0a6b3).(qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->settingscxx . . $ Application#settings(951936487a2d9252).()->valuecxx . . $ Settings#value(8f1f29a69568d71a).(GROUPcxx . . $ `src/librssguard/miscellaneous/settings.h:32:9`!(Database), SETTINGcxx . . $ `src/librssguard/miscellaneous/settings.h:30:9`!(Database::MySQLPort)).toIntcxx . . $ QVariant#toInt(5bd9a3493f6a7a21).()); |
| 157 | database.setUserNamecxx . . $ QSqlDatabase#setUserName(3520e46b33348bf6).(qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->settingscxx . . $ Application#settings(951936487a2d9252).()->valuecxx . . $ Settings#value(8f1f29a69568d71a).(GROUPcxx . . $ `src/librssguard/miscellaneous/settings.h:32:9`!(Database), SETTINGcxx . . $ `src/librssguard/miscellaneous/settings.h:30:9`!(Database::MySQLUsername)).toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).()); |
| 158 | database.setPasswordcxx . . $ QSqlDatabase#setPassword(3520e46b33348bf6).(qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->settingscxx . . $ Application#settings(951936487a2d9252).()->passwordcxx . . $ Settings#password(8f1f29a69568d71a).(GROUPcxx . . $ `src/librssguard/miscellaneous/settings.h:32:9`!(Database), SETTINGcxx . . $ `src/librssguard/miscellaneous/settings.h:30:9`!(Database::MySQLPassword)).toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).()); |
| 159 | |
| 160 | if (!database.opencxx . . $ QSqlDatabase#open(c9857a73d68e59ba).()) { |
| 161 | // NOTE: In this case throw exception and fallback SQL backend will be used. |
| 162 | throw ApplicationExceptioncxx . . $ ApplicationException#(database.lastErrorcxx . . $ QSqlDatabase#lastError(b02d9d6c0f4da678).().textcxx . . $ QSqlError#text(6ef7b6c27b00b43d).()); |
| 163 | } |
| 164 | else { |
| 165 | QSqlQuerycxx . . $ QSqlQuery# query_dbcxx . . $ QSqlQuery#QSqlQuery(b3df2939303ae7a3).(database); |
| 166 | |
| 167 | query_db.setForwardOnlycxx . . $ QSqlQuery#setForwardOnly(b45ddcbc8423892c).(true); |
| 168 | setPragmascxx . . $ MariaDbDriver#setPragmas(81e83dc7d107a009).(query_db); |
| 169 | |
| 170 | if (!query_db.execcxx . . $ QSqlQuery#exec(e1defb592416720d).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("USE %1").argcxx . . $ QString#arg(ad0bca07273edcc2).(database_name)) || |
| 171 | !query_db.execcxx . . $ QSqlQuery#exec(e1defb592416720d).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("SELECT inf_value FROM Information WHERE inf_key = 'schema_version'"))) { |
| 172 | // If no "rssguard" database exists or schema version is wrong, then initialize it. |
| 173 | qWarningNNcxx . . $ `src/librssguard/definitions/definitions.h:417:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_DBcxx . . $ `src/librssguard/definitions/definitions.h:180:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Error occurred. MySQL database is not initialized. Initializing now."; |
| 174 | |
| 175 | try { |
| 176 | const QStringListcxx . . $ QStringList# statements = prepareScriptcxx . . $ DatabaseDriver#prepareScript(ed4e22612e5af09b).(APP_SQL_PATHcxx . . $ `src/librssguard/definitions/definitions.h:376:9`!, QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!(APP_DB_MYSQL_INITcxx . . $ `src/librssguard/definitions/definitions.h:223:9`!), database_name); |
| 177 | |
| 178 | for (const QStringcxx . . $ QString#& statement : statements) { |
| 179 | query_db.execcxx . . $ QSqlQuery#exec(e1defb592416720d).(statement); |
| 180 | |
| 181 | if (query_db.lastErrorcxx . . $ QSqlQuery#lastError(b02d9d6c0f4da678).().isValidcxx . . $ QSqlError#isValid(50ce9a9e25b4a850).()) { |
| 182 | throw ApplicationExceptioncxx . . $ ApplicationException#(query_db.lastErrorcxx . . $ QSqlQuery#lastError(b02d9d6c0f4da678).().textcxx . . $ QSqlError#text(6ef7b6c27b00b43d).()); |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | setSchemaVersioncxx . . $ DatabaseDriver#setSchemaVersion(450228c7fd3bc0ee).(query_db, QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!(APP_DB_SCHEMA_VERSIONcxx . . $ `src/librssguard/definitions/definitions.h:233:9`!).toIntcxx . . $ QString#toInt(d7972accae11ee1f).(), true); |
| 187 | } |
| 188 | catch (const ApplicationExceptioncxx . . $ ApplicationException#& ex) { |
| 189 | qFatalcxx . . $ `<external>/7280663963939302026/qlogging.h:172:9`!("Error when running SQL scripts: %s.", qPrintablecxx . . $ `<external>/13954984326995544643/qstring.h:1647:11`!(ex.message())); |
| 190 | } |
| 191 | |
| 192 | qDebugNNcxx . . $ `src/librssguard/definitions/definitions.h:413:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_DBcxx . . $ `src/librssguard/definitions/definitions.h:180:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "MySQL database backend should be ready now."; |
| 193 | } |
| 194 | else { |
| 195 | // Database was previously initialized. Now just check the schema version. |
| 196 | query_db.nextcxx . . $ QSqlQuery#next(c9857a73d68e59ba).(); |
| 197 | const int installed_db_schema = query_db.valuecxx . . $ QSqlQuery#value(fb36142a814bbf95).(0).toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).().toIntcxx . . $ QString#toInt(d7972accae11ee1f).(); |
| 198 | |
| 199 | if (installed_db_schema < QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!(APP_DB_SCHEMA_VERSIONcxx . . $ `src/librssguard/definitions/definitions.h:233:9`!).toIntcxx . . $ QString#toInt(d7972accae11ee1f).()) { |
| 200 | try { |
| 201 | updateDatabaseSchemacxx . . $ DatabaseDriver#updateDatabaseSchema(2edae70a7e32756e).(query_db, installed_db_schema, database_name); |
| 202 | qDebugNNcxx . . $ `src/librssguard/definitions/definitions.h:413:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_DBcxx . . $ `src/librssguard/definitions/definitions.h:180:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Database schema was updated from" <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). QUOTE_W_SPACEcxx . . $ `src/librssguard/definitions/definitions.h:432:9`!(installed_db_schema) <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "to" |
| 203 | <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). QUOTE_W_SPACEcxx . . $ `src/librssguard/definitions/definitions.h:432:9`!(APP_DB_SCHEMA_VERSIONcxx . . $ `src/librssguard/definitions/definitions.h:233:9`!) <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "successully."; |
| 204 | } |
| 205 | catch (const ApplicationExceptioncxx . . $ ApplicationException#& ex) { |
| 206 | qFatalcxx . . $ `<external>/7280663963939302026/qlogging.h:172:9`!("Error when updating DB schema from %d: %s.", installed_db_schema, qPrintablecxx . . $ `<external>/13954984326995544643/qstring.h:1647:11`!(ex.message())); |
| 207 | } |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | query_db.finishcxx . . $ QSqlQuery#finish(49f6e7a06ebc5aa8).(); |
| 212 | } |
| 213 | |
| 214 | m_databaseInitializedcxx . . $ MariaDbDriver#m_databaseInitialized. = true; |
| 215 | return databasecxx . . $ QSqlDatabase#QSqlDatabase(b3df2939303ae7a3).; |
| 216 | } |
| 217 | |
| 218 | void MariaDbDrivercxx . . $ MariaDbDriver#::setPragmascxx . . $ MariaDbDriver#setPragmas(81e83dc7d107a009).(QSqlQuerycxx . . $ QSqlQuery#& query) { |
| 219 | query.execcxx . . $ QSqlQuery#exec(e1defb592416720d).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("SET NAMES 'utf8mb4';")); |
| 220 | query.execcxx . . $ QSqlQuery#exec(e1defb592416720d).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("SET CHARACTER SET utf8mb4;")); |
| 221 | } |
| 222 | |
| 223 | QSqlDatabasecxx . . $ QSqlDatabase# MariaDbDrivercxx . . $ MariaDbDriver#::connectioncxx . . $ MariaDbDriver#connection(32d6d64cc6e35a97).(const QStringcxx . . $ QString#& connection_name, |
| 224 | DatabaseDrivercxx . . $ DatabaseDriver#::DesiredStorageTypecxx . . $ DatabaseDriver#DesiredStorageType# desired_type) { |
| 225 | Q_UNUSEDcxx . . $ `<external>/17563275351362271547/qtpreprocessorsupport.h:20:9`!(desired_type) |
| 226 | |
| 227 | if (!m_databaseInitializedcxx . . $ MariaDbDriver#m_databaseInitialized.) { |
| 228 | // Return initialized database. |
| 229 | return initializeDatabasecxx . . $ MariaDbDriver#initializeDatabase(595cbf0763205266).(connection_name); |
| 230 | } |
| 231 | else { |
| 232 | QSqlDatabasecxx . . $ QSqlDatabase# databasecxx . . $ QSqlDatabase#QSqlDatabase(49f6e7a06ebc5aa8).; |
| 233 | |
| 234 | if (QSqlDatabasecxx . . $ QSqlDatabase#::containscxx . . $ QSqlDatabase#contains(e1defb592416720d).(connection_name)) { |
| 235 | qDebugNNcxx . . $ `src/librssguard/definitions/definitions.h:413:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_DBcxx . . $ `src/librssguard/definitions/definitions.h:180:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "MySQL connection '" <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). connection_name <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "' is already active."; |
| 236 | |
| 237 | // This database connection was added previously, no need to |
| 238 | // setup its properties. |
| 239 | database =cxx . . $ QSqlDatabase#`operator=`(2177ac2a3cc07b15). QSqlDatabasecxx . . $ QSqlDatabase#::databasecxx . . $ QSqlDatabase#database(798f65c2bb0fade).(connection_name); |
| 240 | } |
| 241 | else { |
| 242 | // Database connection with this name does not exist |
| 243 | // yet, add it and set it up. |
| 244 | database =cxx . . $ QSqlDatabase#`operator=`(2177ac2a3cc07b15). QSqlDatabasecxx . . $ QSqlDatabase#::addDatabasecxx . . $ QSqlDatabase#addDatabase(660a07b34cb8c61b).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!(APP_DB_MYSQL_DRIVERcxx . . $ `src/librssguard/definitions/definitions.h:222:9`!), connection_name); |
| 245 | database.setHostNamecxx . . $ QSqlDatabase#setHostName(3520e46b33348bf6).(qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->settingscxx . . $ Application#settings(951936487a2d9252).()->valuecxx . . $ Settings#value(8f1f29a69568d71a).(GROUPcxx . . $ `src/librssguard/miscellaneous/settings.h:32:9`!(Database), SETTINGcxx . . $ `src/librssguard/miscellaneous/settings.h:30:9`!(Database::MySQLHostname)).toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).()); |
| 246 | database.setPortcxx . . $ QSqlDatabase#setPort(d4f767463ce0a6b3).(qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->settingscxx . . $ Application#settings(951936487a2d9252).()->valuecxx . . $ Settings#value(8f1f29a69568d71a).(GROUPcxx . . $ `src/librssguard/miscellaneous/settings.h:32:9`!(Database), SETTINGcxx . . $ `src/librssguard/miscellaneous/settings.h:30:9`!(Database::MySQLPort)).toIntcxx . . $ QVariant#toInt(5bd9a3493f6a7a21).()); |
| 247 | database.setUserNamecxx . . $ QSqlDatabase#setUserName(3520e46b33348bf6).(qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->settingscxx . . $ Application#settings(951936487a2d9252).()->valuecxx . . $ Settings#value(8f1f29a69568d71a).(GROUPcxx . . $ `src/librssguard/miscellaneous/settings.h:32:9`!(Database), SETTINGcxx . . $ `src/librssguard/miscellaneous/settings.h:30:9`!(Database::MySQLUsername)).toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).()); |
| 248 | database.setPasswordcxx . . $ QSqlDatabase#setPassword(3520e46b33348bf6).(qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->settingscxx . . $ Application#settings(951936487a2d9252).()->passwordcxx . . $ Settings#password(8f1f29a69568d71a).(GROUPcxx . . $ `src/librssguard/miscellaneous/settings.h:32:9`!(Database), SETTINGcxx . . $ `src/librssguard/miscellaneous/settings.h:30:9`!(Database::MySQLPassword)).toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).()); |
| 249 | database.setDatabaseNamecxx . . $ QSqlDatabase#setDatabaseName(3520e46b33348bf6).(qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->settingscxx . . $ Application#settings(951936487a2d9252).()->valuecxx . . $ Settings#value(8f1f29a69568d71a).(GROUPcxx . . $ `src/librssguard/miscellaneous/settings.h:32:9`!(Database), SETTINGcxx . . $ `src/librssguard/miscellaneous/settings.h:30:9`!(Database::MySQLDatabase)).toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).()); |
| 250 | } |
| 251 | |
| 252 | if (!database.isOpencxx . . $ QSqlDatabase#isOpen(50ce9a9e25b4a850).() && !database.opencxx . . $ QSqlDatabase#open(c9857a73d68e59ba).()) { |
| 253 | // NOTE: In this case throw exception and fallback SQL backend will be used. |
| 254 | throw ApplicationExceptioncxx . . $ ApplicationException#(database.lastErrorcxx . . $ QSqlDatabase#lastError(b02d9d6c0f4da678).().textcxx . . $ QSqlError#text(6ef7b6c27b00b43d).()); |
| 255 | } |
| 256 | else { |
| 257 | qDebugNNcxx . . $ `src/librssguard/definitions/definitions.h:413:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_DBcxx . . $ `src/librssguard/definitions/definitions.h:180:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "MySQL database connection" <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). QUOTE_W_SPACEcxx . . $ `src/librssguard/definitions/definitions.h:432:9`!(connection_name) <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "to file" |
| 258 | <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). QUOTE_W_SPACEcxx . . $ `src/librssguard/definitions/definitions.h:432:9`!(QDir::toNativeSeparators(database.databaseName())) <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "seems to be established."; |
| 259 | } |
| 260 | |
| 261 | QSqlQuerycxx . . $ QSqlQuery# query_dbcxx . . $ QSqlQuery#QSqlQuery(b3df2939303ae7a3).(database); |
| 262 | |
| 263 | query_db.setForwardOnlycxx . . $ QSqlQuery#setForwardOnly(b45ddcbc8423892c).(true); |
| 264 | setPragmascxx . . $ MariaDbDriver#setPragmas(81e83dc7d107a009).(query_db); |
| 265 | |
| 266 | return databasecxx . . $ QSqlDatabase#QSqlDatabase(b3df2939303ae7a3).; |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | QStringcxx . . $ QString# MariaDbDrivercxx . . $ MariaDbDriver#::autoIncrementPrimaryKeycxx . . $ MariaDbDriver#autoIncrementPrimaryKey(6ef7b6c27b00b43d).() const { |
| 271 | return QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("INTEGER AUTO_INCREMENT PRIMARY KEY"); |
| 272 | } |
| 273 | |
| 274 | QStringcxx . . $ QString# MariaDbDrivercxx . . $ MariaDbDriver#::blobcxx . . $ MariaDbDriver#blob(6ef7b6c27b00b43d).() const { |
| 275 | return QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("MEDIUMBLOB"); |
| 276 | } |
| 277 | |
| 278 | QStringcxx . . $ QString# MariaDbDrivercxx . . $ MariaDbDriver#::textcxx . . $ MariaDbDriver#text(6ef7b6c27b00b43d).() const { |
| 279 | return QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("MEDIUMTEXT"); |
| 280 | } |