From: Florian Forster Date: Tue, 3 Feb 2009 20:35:01 +0000 (+0100) Subject: dbi plugin: Use the server version to only use appropriate queries. X-Git-Tag: collectd-4.6.0~74 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=a1aa2b8813ff52e017e9686034010c045aea59fe;p=collectd.git dbi plugin: Use the server version to only use appropriate queries. --- diff --git a/src/dbi.c b/src/dbi.c index ee436023..a542df32 100644 --- a/src/dbi.c +++ b/src/dbi.c @@ -712,14 +712,25 @@ static int cdbi_read_database (cdbi_database_t *db) /* {{{ */ int success; int status; + unsigned int db_version; + status = cdbi_connect_database (db); if (status != 0) return (status); assert (db->connection != NULL); + db_version = dbi_conn_get_engine_version (db->connection); + /* TODO: Complain if `db_version == 0' */ + success = 0; for (i = 0; i < db->queries_num; i++) { + /* Check if we know the database's version and if so, if this query applies + * to that version. */ + if ((db_version != 0) + && (udb_query_check_version (db->queries[i], db_version) == 0)) + continue; + status = cdbi_read_database_query (db, db->queries[i]); if (status == 0) success++;