From de927d535d38fc584659fdea3935ea9834dab34b Mon Sep 17 00:00:00 2001 From: John Ralls Date: Fri, 13 Jul 2018 16:34:42 -0700 Subject: [PATCH] Fix test-backend-dbi for Postgress and MySQL. Pass MySQL database exists errors and skip creating the database if it exists. --- libgnucash/backend/dbi/gnc-backend-dbi.cpp | 9 ++++++++- po/POTFILES.in | 1 - 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libgnucash/backend/dbi/gnc-backend-dbi.cpp b/libgnucash/backend/dbi/gnc-backend-dbi.cpp index c67e5679d2..b3d9d2a913 100644 --- a/libgnucash/backend/dbi/gnc-backend-dbi.cpp +++ b/libgnucash/backend/dbi/gnc-backend-dbi.cpp @@ -531,6 +531,12 @@ error_handler (dbi_conn conn, void* user_data) dbi_be->set_dbi_error (ERR_BACKEND_CANT_CONNECT, 1, true); dbi_be->retry_connection (msg); } + else if (err_num == 1007) //Database exists + { + dbi_be->set_exists(true); + return; + } + else // Any other error { PERR ("DBI error: %s\n", msg); @@ -700,7 +706,8 @@ GncDbiBackend::session_begin (QofSession* session, const char* book_id, if (create) { - if (!create_database(conn, uri.quote_dbname(Type).c_str())) + if (!m_exists && + !create_database(conn, uri.quote_dbname(Type).c_str())) { dbi_conn_close(conn); LEAVE("Error"); diff --git a/po/POTFILES.in b/po/POTFILES.in index c7924e8212..3e5dfbf8b8 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -344,7 +344,6 @@ gnucash/import-export/log-replay/gncmod-log-replay.c gnucash/import-export/log-replay/gnc-plugin-log-replay.c gnucash/import-export/ofx/gncmod-ofx-import.c gnucash/import-export/ofx/gnc-ofx-import.c -gnucash/import-export/ofx/gnc-ofx-kvp.c gnucash/import-export/ofx/gnc-plugin-ofx.c gnucash/import-export/ofx/gschemas/org.gnucash.dialogs.import.ofx.gschema.xml.in gnucash/import-export/qif-imp/assistant-qif-import.c