From 878bbfa128acf19da369452f12db5609e2b7d037 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Mon, 16 Feb 2009 22:41:19 +0100 Subject: [PATCH] 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(). --- src/postgresql.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 */ -- 2.30.2