From 28c57d6ae3f9c31aff88c1bb292b471c9d5f9c38 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 1 May 2020 22:57:49 -0700 Subject: [PATCH] Server programs: try to print error message if can't connect to DB --- db/db_base.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/db/db_base.cpp b/db/db_base.cpp index c527345671..05bcd44727 100644 --- a/db/db_base.cpp +++ b/db/db_base.cpp @@ -85,10 +85,14 @@ int DB_CONN::open( // CLIENT_FOUND_ROWS means that the # of affected rows for an update // is the # matched by the where, rather than the # actually changed // - mysql = mysql_real_connect( + MYSQL* mysql2 = mysql_real_connect( mysql, host, db_user, dbpassword, db_name, port, 0, CLIENT_FOUND_ROWS ); - if (mysql == 0) return ERR_DB_CANT_CONNECT; + if (mysql2 == 0) { + fprintf(stderr, "mysql_real_connect(): %d: %s\n", mysql_errno(mysql), mysql_error(mysql)); + return ERR_DB_CANT_CONNECT; + } + mysql = mysql2; if (set_opt_after) { bool mbReconnect = 1;