diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/config.c | 5 | ||||
-rw-r--r-- | src/sql.c | 10 | ||||
-rw-r--r-- | src/sql.h | 2 |
3 files changed, 16 insertions, 1 deletions
diff --git a/src/config.c b/src/config.c index 28734d0..e46c2f5 100644 --- a/src/config.c +++ b/src/config.c | |||
@@ -630,6 +630,11 @@ cb_sql (enum grecs_callback_command cmd, | |||
630 | } | 630 | } |
631 | 631 | ||
632 | static struct grecs_keyword sql_kw[] = { | 632 | static struct grecs_keyword sql_kw[] = { |
633 | { "config-file", N_("file"), N_("Read MySQL configuration from <file>"), | ||
634 | grecs_type_string, NULL, offsetof(struct sqlconn, config_file) }, | ||
635 | { "config-group", N_("name"), | ||
636 | N_("Read the named group from the SQL configuration file"), | ||
637 | grecs_type_string, NULL, offsetof(struct sqlconn, config_group) }, | ||
633 | { "host", N_("host"), N_("Set SQL server hostname or IP address"), | 638 | { "host", N_("host"), N_("Set SQL server hostname or IP address"), |
634 | grecs_type_string, NULL, 0, cb_sql_host }, | 639 | grecs_type_string, NULL, 0, cb_sql_host }, |
635 | { "database", N_("dbname"), N_("Set database name"), | 640 | { "database", N_("dbname"), N_("Set database name"), |
@@ -70,12 +70,20 @@ sql_init_dictionary (struct dictionary *dict) | |||
70 | if (conn->initcount++ == 0) | 70 | if (conn->initcount++ == 0) |
71 | { | 71 | { |
72 | mysql_init (&conn->mysql); | 72 | mysql_init (&conn->mysql); |
73 | |||
74 | if (conn->config_file) | ||
75 | mysql_options (&conn->mysql, MYSQL_READ_DEFAULT_FILE, | ||
76 | conn->config_file); | ||
77 | if (conn->config_group) | ||
78 | mysql_options (&conn->mysql, MYSQL_READ_DEFAULT_GROUP, | ||
79 | conn->config_group); | ||
80 | |||
73 | if (conn->cacert) | 81 | if (conn->cacert) |
74 | mysql_ssl_set (&conn->mysql, NULL, NULL, conn->cacert, | 82 | mysql_ssl_set (&conn->mysql, NULL, NULL, conn->cacert, |
75 | NULL, NULL); | 83 | NULL, NULL); |
76 | if (!mysql_real_connect (&conn->mysql, conn->host, conn->user, | 84 | if (!mysql_real_connect (&conn->mysql, conn->host, conn->user, |
77 | conn->password, conn->database, conn->port, | 85 | conn->password, conn->database, conn->port, |
78 | conn->socket, 0)) | 86 | conn->socket, CLIENT_MULTI_RESULTS)) |
79 | { | 87 | { |
80 | logmsg (LOG_ERR, _("failed to connect to database %s: error: %s\n"), | 88 | logmsg (LOG_ERR, _("failed to connect to database %s: error: %s\n"), |
81 | dict->parmv[0], mysql_error (&conn->mysql)); | 89 | dict->parmv[0], mysql_error (&conn->mysql)); |
@@ -19,6 +19,8 @@ | |||
19 | struct sqlconn | 19 | struct sqlconn |
20 | { | 20 | { |
21 | char *ident; | 21 | char *ident; |
22 | char *config_file; | ||
23 | char *config_group; | ||
22 | char *host; | 24 | char *host; |
23 | char *socket; | 25 | char *socket; |
24 | short port; | 26 | short port; |