aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2010-01-06 13:25:39 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2010-01-06 13:25:39 +0200
commit1a0f319a747220e48bde4fae8b80c0b00d22e69c (patch)
tree5912bfb14ac3d26b29eff947ded1eefa008e80be /src
parentfa78a9f21ff4fd85fb568232c9bee957b9c83497 (diff)
downloadwydawca-1a0f319a747220e48bde4fae8b80c0b00d22e69c.tar.gz
wydawca-1a0f319a747220e48bde4fae8b80c0b00d22e69c.tar.bz2
Improve SQL configuration.
* src/config.c (sql_kw): New statements: config-file and config-group. * src/sql.c (sql_init_dictionary): Handle config-file and config-group. Set CLIENT_MULTI_RESULTS option. * src/sql.h (struct sqlconn): New members: config_file and config_group. * NEWS, doc/wydawca.texi: Update.
Diffstat (limited to 'src')
-rw-r--r--src/config.c5
-rw-r--r--src/sql.c10
-rw-r--r--src/sql.h2
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
632static struct grecs_keyword sql_kw[] = { 632static 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"),
diff --git a/src/sql.c b/src/sql.c
index 0ccc2e7..a4b311e 100644
--- a/src/sql.c
+++ b/src/sql.c
@@ -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));
diff --git a/src/sql.h b/src/sql.h
index cf7d636..a4ab2ee 100644
--- a/src/sql.h
+++ b/src/sql.h
@@ -19,6 +19,8 @@
19struct sqlconn 19struct 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;

Return to:

Send suggestions and report system problems to the System administrator.