diff --git a/src/utils/dbi.c b/src/utils/dbi.c
index c8eb81616454a3078eb768f16b1affd32b81f1d9..de2348e713d34e82924bbf4870d252d186626803 100644 (file)
--- a/src/utils/dbi.c
+++ b/src/utils/dbi.c
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif /* HAVE_CONFIG_H */
+
#include "utils/dbi.h"
#include "utils/error.h"
char *database;
dbi_conn conn;
+ dbi_inst inst;
sdb_dbi_options_t *options;
};
continue;
status = callback(client, num_fields, data, user_data);
- for (i = 0; i < num_fields; ++i) {
- if ((data[i].type == SDB_TYPE_STRING) && (data[i].data.string))
- free(data[i].data.string);
- else if ((data[i].type == SDB_TYPE_BINARY)
- && (data[i].data.binary.datum))
- free(data[i].data.binary.datum);
- }
+ for (i = 0; i < num_fields; ++i)
+ sdb_data_free_datum(&data[i]);
if (status)
continue;
client->conn = NULL;
client->options = NULL;
+ if (dbi_initialize_r(/* driverdir = */ NULL, &client->inst) < 0) {
+ free(client);
+ return NULL;
+ }
+
client->driver = strdup(driver);
client->database = strdup(database);
if ((! client->driver) || (! client->database)) {
client->conn = NULL;
}
- driver = dbi_driver_open(client->driver);
+ driver = dbi_driver_open_r(client->driver, client->inst);
if (! driver) {
sdb_error_set("dbi: failed to open DBI driver '%s'; "
"possibly it's not installed.\n",
client->driver);
sdb_error_append("dbi: known drivers:\n");
- for (driver = dbi_driver_list(NULL); driver;
- driver = dbi_driver_list(driver)) {
+ for (driver = dbi_driver_list_r(NULL, client->inst); driver;
+ driver = dbi_driver_list_r(driver, client->inst)) {
sdb_error_append("\t- %s\n", dbi_driver_get_name(driver));
}
sdb_error_chomp();
dbi_conn_close(client->conn);
client->conn = NULL;
+ dbi_shutdown_r(client->inst);
+
if (client->options)
sdb_dbi_options_destroy(client->options);
client->options = NULL;