X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fdbi.c;h=223e159f3f9ab88293a8a7edd4d68df1bc661459;hb=9614ef2432c6cd728c7a4511c80dc534ea6ec391;hp=7fec73c549c5249feef63ae4dd194a3071aa3ab6;hpb=84dd85dc85cc2325f9c54100ca3fd7d4842db06f;p=collectd.git diff --git a/src/dbi.c b/src/dbi.c index 7fec73c5..223e159f 100644 --- a/src/dbi.c +++ b/src/dbi.c @@ -32,6 +32,9 @@ #include +#ifdef HAVE_LIBDBI_R + dbi_inst inst = NULL; +#endif /* * Data types */ @@ -131,7 +134,7 @@ static int cdbi_result_get_field (dbi_result res, /* {{{ */ else if (src_type == DBI_TYPE_STRING) { const char *value; - + value = dbi_result_get_string_idx (res, index); if (value == NULL) sstrncpy (buffer, "", buffer_size); @@ -197,7 +200,7 @@ static void cdbi_database_free (cdbi_database_t *db) /* {{{ */ * * ... * - * + * * * Driver "mysql" * DriverOption "hostname" "localhost" @@ -451,7 +454,11 @@ static int cdbi_init (void) /* {{{ */ return (-1); } +#ifdef HAVE_LIBDBI_R + status = dbi_initialize_r (NULL, &inst); +#else status = dbi_initialize (NULL); +#endif if (status < 0) { ERROR ("dbi plugin: cdbi_init: dbi_initialize failed with status %i.", @@ -672,16 +679,26 @@ static int cdbi_connect_database (cdbi_database_t *db) /* {{{ */ db->connection = NULL; } +#ifdef HAVE_LIBDBI_R + driver = dbi_driver_open_r (db->driver, inst); +#else driver = dbi_driver_open (db->driver); +#endif if (driver == NULL) { ERROR ("dbi plugin: cdbi_connect_database: dbi_driver_open (%s) failed.", db->driver); INFO ("dbi plugin: Maybe the driver isn't installed? " "Known drivers are:"); +#ifdef HAVE_LIBDBI_R + for (driver = dbi_driver_list_r (NULL, inst); + driver != NULL; + driver = dbi_driver_list_r (driver, inst)) +#else for (driver = dbi_driver_list (NULL); driver != NULL; driver = dbi_driver_list (driver)) +#endif { INFO ("dbi plugin: * %s", dbi_driver_get_name (driver)); }