summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ed36560)
raw | patch | inline | side by side (parent: ed36560)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 17 Aug 2008 12:10:29 +0000 (14:10 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Tue, 19 Aug 2008 08:12:00 +0000 (10:12 +0200) |
When adding the default queries to a database definition, 'max_params_num' has
not been updated at all, resulting in a failed assertion during query
execution. This is now fixed by splitting the common code for adding a query
definition to a database definition into a new function and using that
function where appropriate.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
not been updated at all, resulting in a failed assertion during query
execution. This is now fixed by splitting the common code for adding a query
definition to a database definition into a new function and using that
function where appropriate.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
src/postgresql.c | patch | blob | history |
diff --git a/src/postgresql.c b/src/postgresql.c
index f326a2342192a6c2c3de69126aaf0025eaaae8e0..eb7587ff22b5b6d1e98d124141b045bab64764ea 100644 (file)
--- a/src/postgresql.c
+++ b/src/postgresql.c
@@ -621,20 +621,14 @@ static int config_set_column (c_psql_query_t *query, const oconfig_item_t *ci)
return 0;
} /* config_set_column */
-static int config_set_query (c_psql_database_t *db, const oconfig_item_t *ci)
+static int set_query (c_psql_database_t *db, const char *name)
{
c_psql_query_t *query;
- if ((0 != ci->children_num) || (1 != ci->values_num)
- || (OCONFIG_TYPE_STRING != ci->values[0].type)) {
- log_err ("Query expects a single string argument.");
- return 1;
- }
-
- query = c_psql_query_get (ci->values[0].value.string);
+ query = c_psql_query_get (name);
if (NULL == query) {
log_err ("Query \"%s\" not found - please check your configuration.",
- ci->values[0].value.string);
+ name);
return 1;
}
db->queries[db->queries_num - 1] = query;
return 0;
+} /* set_query */
+
+static int config_set_query (c_psql_database_t *db, const oconfig_item_t *ci)
+{
+ if ((0 != ci->children_num) || (1 != ci->values_num)
+ || (OCONFIG_TYPE_STRING != ci->values[0].type)) {
+ log_err ("Query expects a single string argument.");
+ return 1;
+ }
+ return set_query (db, ci->values[0].value.string);
} /* config_set_query */
static int c_psql_config_query (oconfig_item_t *ci)
}
if (NULL == db->queries) {
- db->queries = (c_psql_query_t **)malloc (def_queries_num
- * sizeof (*db->queries));
-
- for (i = 0; i < def_queries_num; ++i) {
- db->queries[i] = c_psql_query_get (def_queries[i]);
- if (NULL == db->queries[i])
- log_err ("Query \"%s\" not found - "
- "please check your installation.",
- def_queries[i]);
- else
- ++db->queries_num;
- }
+ for (i = 0; i < def_queries_num; ++i)
+ set_query (db, def_queries[i]);
}
return 0;
}