# HG changeset patch # User Timo Sirainen # Date 1451528761 -7200 # Node ID a7fcd12d0d83d65c27c372c716535ca88449fd4c # Parent 207586dae1e15ddd858490793d5175a409154b4e mysql: Don't require connect setting to have host-parameter if option_file is set. The option_file could also specify the host. diff -r 207586dae1e1 -r a7fcd12d0d83 src/lib-sql/driver-mysql.c --- a/src/lib-sql/driver-mysql.c Wed Dec 30 08:21:46 2015 -0500 +++ b/src/lib-sql/driver-mysql.c Thu Dec 31 04:26:01 2015 +0200 @@ -72,7 +72,8 @@ static const char *mysql_prefix(struct mysql_db *db) { - return t_strdup_printf("mysql(%s)", db->host); + return db->host == NULL ? "mysql" : + t_strdup_printf("mysql(%s)", db->host); } static int driver_mysql_connect(struct sql_db *_db) @@ -88,7 +89,12 @@ sql_db_set_state(&db->api, SQL_DB_STATE_CONNECTING); - if (*db->host == '/') { + if (db->host == NULL) { + /* assume option_file overrides the host, or if not we'll just + connect to localhost */ + unix_socket = NULL; + host = NULL; + } else if (*db->host == '/') { unix_socket = db->host; host = NULL; } else { @@ -235,7 +241,7 @@ *field = p_strdup(db->pool, value); } - if (db->host == NULL) + if (db->host == NULL && db->option_file == NULL) i_fatal("mysql: No hosts given in connect string"); db->mysql = mysql_init(NULL);