diff -ur postfix-2.2.3.orig/src/global/dict_mysql.c postfix-2.2.3/src/global/dict_mysql.c
--- postfix-2.2.3.orig/src/global/dict_mysql.c	2005-03-09 03:58:45.000000000 +0900
+++ postfix-2.2.3/src/global/dict_mysql.c	2005-05-17 20:36:03.667328610 +0900
@@ -222,6 +222,8 @@
     char   *username;
     char   *password;
     char   *dbname;
+    char   *default_file;
+    char   *default_group;
     ARGV   *hosts;
     PLMYSQL *pldb;
 } DICT_MYSQL;
@@ -239,11 +241,11 @@
 
 /* internal function declarations */
 static PLMYSQL *plmysql_init(ARGV *);
-static MYSQL_RES *plmysql_query(PLMYSQL *, const char *, char *, char *, char *);
+static MYSQL_RES *plmysql_query(PLMYSQL *, const char *, char *, char *, char *, char *, char *);
 static void plmysql_dealloc(PLMYSQL *);
 static void plmysql_close_host(HOST *);
 static void plmysql_down_host(HOST *);
-static void plmysql_connect_single(HOST *, char *, char *, char *);
+static void plmysql_connect_single(HOST *, char *, char *, char *, char *, char *);
 static const char *dict_mysql_lookup(DICT *, const char *);
 DICT   *dict_mysql_open(const char *, int, int);
 static void dict_mysql_close(DICT *);
@@ -329,7 +331,9 @@
     if ((query_res = plmysql_query(pldb, vstring_str(query),
 				   dict_mysql->dbname,
 				   dict_mysql->username,
-				   dict_mysql->password)) == 0) {
+				   dict_mysql->password,
+				   dict_mysql->default_file,
+				   dict_mysql->default_group)) == 0) {
 	dict_errno = DICT_ERR_RETRY;
 	return (0);
     }
@@ -412,7 +416,8 @@
 /* dict_mysql_get_active - get an active connection */
 
 static HOST *dict_mysql_get_active(PLMYSQL *PLDB, char *dbname,
-				   char *username, char *password)
+				   char *username, char *password,
+				   char *default_file, char *default_group)
 {
     const char *myname = "dict_mysql_get_active";
     HOST   *host;
@@ -440,7 +445,7 @@
 	if (msg_verbose)
 	    msg_info("%s: attempting to connect to host %s", myname,
 		     host->hostname);
-	plmysql_connect_single(host, dbname, username, password);
+	plmysql_connect_single(host, dbname, username, password, default_file, default_group);
 	if (host->stat == STATACTIVE)
 	    return host;
     }
@@ -470,12 +475,14 @@
 				        const char *query,
 				        char *dbname,
 				        char *username,
-				        char *password)
+				        char *password,
+				        char *default_file,
+				        char *default_group)
 {
     HOST   *host;
     MYSQL_RES *res = 0;
 
-    while ((host = dict_mysql_get_active(PLDB, dbname, username, password)) != NULL) {
+    while ((host = dict_mysql_get_active(PLDB, dbname, username, password, default_file, default_group)) != NULL) {
 	if (!(mysql_query(host->db, query))) {
 	    if ((res = mysql_store_result(host->db)) == 0) {
 		msg_warn("mysql query failed: %s", mysql_error(host->db));
@@ -500,10 +507,14 @@
  * used to reconnect to a single database when one is down or none is
  * connected yet. Log all errors and set the stat field of host accordingly
  */
-static void plmysql_connect_single(HOST *host, char *dbname, char *username, char *password)
+static void plmysql_connect_single(HOST *host, char *dbname, char *username, char *password, char *default_file, char *default_group)
 {
     if ((host->db = mysql_init(NULL)) == NULL)
 	msg_fatal("dict_mysql: insufficient memory");
+    if (default_file && *default_file)
+	mysql_options(host->db, MYSQL_READ_DEFAULT_FILE, default_file);
+    if (default_group && *default_group)
+	mysql_options(host->db, MYSQL_READ_DEFAULT_GROUP, default_group);
     if (mysql_real_connect(host->db,
 			   (host->type == TYPEINET ? host->name : 0),
 			   username,
@@ -557,9 +568,11 @@
     
     p = dict_mysql->parser = cfg_parser_alloc(mysqlcf);
     dict_mysql->username = cfg_get_str(p, "user", "", 0, 0);
-    dict_mysql->password = cfg_get_str(p, "password", "", 0, 0);
-    dict_mysql->dbname = cfg_get_str(p, "dbname", "", 1, 0);
+    dict_mysql->password = cfg_get_str(p, "password", NULL, 0, 0);
+    dict_mysql->dbname = cfg_get_str(p, "dbname", "", 0, 0);
     dict_mysql->result_format = cfg_get_str(p, "result_format", "%s", 1, 0);
+    dict_mysql->default_file = cfg_get_str(p, "default_file", "", 0, 0);
+    dict_mysql->default_group = cfg_get_str(p, "default_group", "", 0, 0);
     /*
      * XXX: The default should be non-zero for safety, but that is not
      * backwards compatible.
@@ -713,8 +726,10 @@
     plmysql_dealloc(dict_mysql->pldb);
     cfg_parser_free(dict_mysql->parser);
     myfree(dict_mysql->username);
-    myfree(dict_mysql->password);
+    if (dict_mysql->password) myfree(dict_mysql->password);
     myfree(dict_mysql->dbname);
+    myfree(dict_mysql->default_file);
+    myfree(dict_mysql->default_group);
     myfree(dict_mysql->query);
     myfree(dict_mysql->result_format);
     if (dict_mysql->domain)
