From: Florian Forster Date: Thu, 26 Jan 2012 10:36:03 +0000 (+0100) Subject: oracle plugin: Fix use of the OCIErrorGet() function. X-Git-Tag: collectd-4.10.6~12 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=a68d919b6d2cf26f0626e520d9c1e5869dd1a7ac;p=collectd.git oracle plugin: Fix use of the OCIErrorGet() function. Change-Id: I9899b98517fe0c239bffcf7a75681560029aa2ba --- diff --git a/src/oracle.c b/src/oracle.c index 1332da27..4c85e293 100644 --- a/src/oracle.c +++ b/src/oracle.c @@ -91,15 +91,16 @@ static void o_report_error (const char *where, /* {{{ */ char buffer[2048]; sb4 error_code; int status; + unsigned int record_number; /* An operation may cause / return multiple errors. Loop until we have - * handled all errors available. */ - while (42) + * handled all errors available (with a fail-save limit of 16). */ + for (record_number = 1; record_number <= 16; record_number++) { memset (buffer, 0, sizeof (buffer)); error_code = -1; - status = OCIErrorGet (eh, /* record number = */ 1, + status = OCIErrorGet (eh, (ub4) record_number, /* sqlstate = */ NULL, &error_code, (text *) &buffer[0], @@ -121,8 +122,7 @@ static void o_report_error (const char *where, /* {{{ */ buffer[buffer_length] = 0; } - ERROR ("oracle plugin: %s: %s failed: %s", - where, what, buffer); + ERROR ("oracle plugin: %s: %s failed: %s", where, what, buffer); } else { @@ -700,7 +700,7 @@ static int o_read_database (o_database_t *db) /* {{{ */ (OraText *) db->username, (ub4) strlen (db->username), (OraText *) db->password, (ub4) strlen (db->password), (OraText *) db->connect_id, (ub4) strlen (db->connect_id)); - if (status != OCI_SUCCESS) + if ((status != OCI_SUCCESS) && (status != OCI_SUCCESS_WITH_INFO)) { o_report_error ("o_read_database", "OCILogon", oci_error); DEBUG ("oracle plugin: OCILogon (%s): db->oci_service_context = %p;", @@ -708,6 +708,10 @@ static int o_read_database (o_database_t *db) /* {{{ */ db->oci_service_context = NULL; return (-1); } + else if (status == OCI_SUCCESS_WITH_INFO) + { + /* TODO: Print NOTIFY message. */ + } assert (db->oci_service_context != NULL); }