Timo Sirainen wrote:
> On 31.12.2007, at 15.23, Luca Longinotti wrote:
> 
>> +    mysql_options(conn->mysql, MYSQL_READ_DEFAULT_GROUP, "client");
> 
> Is "client" always the correct group to read? Would there be any point
> in making this configurable?
> 
Well, "client" is the default group. It can of course be made
configurable, which might be interesting... In that case I'd also make
the location of the configuration file configurable, for maximum
flexibility. Attached is a patch to do just that, and use "client" if
nothing is set.
-- 
Best regards,
Luca Longinotti aka CHTEKK

LongiTEKK Networks Admin: [EMAIL PROTECTED]
Gentoo Dev: [EMAIL PROTECTED]
SysCP Dev: [EMAIL PROTECTED]
TILUG Supporter: [EMAIL PROTECTED]
--- src/lib-sql/driver-mysql.c	2007-12-11 19:52:08.000000000 +0100
+++ src/lib-sql/driver-mysql.c	2008-01-01 18:20:31.082648859 +0100
@@ -31,6 +31,7 @@
 	pool_t pool;
 	const char *user, *password, *dbname, *unix_socket;
 	const char *ssl_cert, *ssl_key, *ssl_ca, *ssl_ca_path, *ssl_cipher;
+	const char *def_file, *def_group;
 	unsigned int port, client_flags;
 
 	array_t ARRAY_DEFINE(connections, struct mysql_connection);
@@ -106,6 +107,14 @@
 		host = conn->host;
 	}
 
+	if (db->def_file != NULL)
+		mysql_options(conn->mysql, MYSQL_READ_DEFAULT_FILE, db->def_file);
+
+	if (db->def_group != NULL)
+		mysql_options(conn->mysql, MYSQL_READ_DEFAULT_GROUP, db->def_group);
+	else
+		mysql_options(conn->mysql, MYSQL_READ_DEFAULT_GROUP, "client");
+
 	if (!conn->ssl_set && (db->ssl_ca != NULL || db->ssl_ca_path != NULL)) {
 #ifdef HAVE_MYSQL_SSL
 		mysql_ssl_set(conn->mysql, db->ssl_key, db->ssl_cert,
@@ -230,6 +239,10 @@
 			field = &db->ssl_ca_path;
 		else if (strcmp(name, "ssl_cipher") == 0)
 			field = &db->ssl_cipher;
+		else if (strcmp(name, "default_file") == 0)
+			field = &db->def_file;
+		else if (strcmp(name, "default_group") == 0)
+			field = &db->def_group;
 		else
 			i_fatal("mysql: Unknown connect string: %s", name);
 

Reply via email to