summaryrefslogtreecommitdiffabout
path: root/src
authorSergey Poznyakoff <gray@gnu.org.ua>2010-01-06 11:25:39 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2010-01-06 11:25:39 (GMT)
commit1a0f319a747220e48bde4fae8b80c0b00d22e69c (patch) (side-by-side diff)
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') (more/less context) (ignore whitespace changes)
-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,
}
static struct grecs_keyword sql_kw[] = {
+ { "config-file", N_("file"), N_("Read MySQL configuration from <file>"),
+ grecs_type_string, NULL, offsetof(struct sqlconn, config_file) },
+ { "config-group", N_("name"),
+ N_("Read the named group from the SQL configuration file"),
+ grecs_type_string, NULL, offsetof(struct sqlconn, config_group) },
{ "host", N_("host"), N_("Set SQL server hostname or IP address"),
grecs_type_string, NULL, 0, cb_sql_host },
{ "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)
if (conn->initcount++ == 0)
{
mysql_init (&conn->mysql);
+
+ if (conn->config_file)
+ mysql_options (&conn->mysql, MYSQL_READ_DEFAULT_FILE,
+ conn->config_file);
+ if (conn->config_group)
+ mysql_options (&conn->mysql, MYSQL_READ_DEFAULT_GROUP,
+ conn->config_group);
+
if (conn->cacert)
mysql_ssl_set (&conn->mysql, NULL, NULL, conn->cacert,
NULL, NULL);
if (!mysql_real_connect (&conn->mysql, conn->host, conn->user,
conn->password, conn->database, conn->port,
- conn->socket, 0))
+ conn->socket, CLIENT_MULTI_RESULTS))
{
logmsg (LOG_ERR, _("failed to connect to database %s: error: %s\n"),
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 @@
struct sqlconn
{
char *ident;
+ char *config_file;
+ char *config_group;
char *host;
char *socket;
short port;

Return to:

Send suggestions and report system problems to the System administrator.