From: Sebastian Harl Date: Mon, 16 Feb 2009 21:41:19 +0000 (+0100) Subject: postgresql: Fixed calculation of a database's max_params_num. X-Git-Tag: collectd-4.6.0^2 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=878bbfa128acf19da369452f12db5609e2b7d037;p=collectd.git postgresql: Fixed calculation of a database's max_params_num. This parameter is used to store the size of a frequently used temporary list and allows that it may be efficiently stored on the stack. It was accidentally lost in commit 4d380d9, triggering an assertion in c_psql_exec_query_params(). --- diff --git a/src/postgresql.c b/src/postgresql.c index 4e1c1e0c..adddc00a 100644 --- a/src/postgresql.c +++ b/src/postgresql.c @@ -289,7 +289,7 @@ static int c_psql_exec_query (c_psql_database_t *db, udb_query_t *q) int status; int i; - /* The user data may hold parameter information */ + /* The user data may hold parameter information, but may be NULL. */ data = udb_query_get_user_data (q); /* Versions up to `3' don't know how to handle parameters. */ @@ -631,6 +631,12 @@ static int c_psql_config_database (oconfig_item_t *ci) &db->queries, &db->queries_num); } + for (i = 0; (size_t)i < db->queries_num; ++i) { + c_psql_user_data_t *data; + data = udb_query_get_user_data (db->queries[i]); + if ((data != NULL) && (data->params_num > db->max_params_num)) + db->max_params_num = data->params_num; + } return 0; } /* c_psql_config_database */