From a68d919b6d2cf26f0626e520d9c1e5869dd1a7ac Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 26 Jan 2012 11:36:03 +0100 Subject: [PATCH] oracle plugin: Fix use of the OCIErrorGet() function. Change-Id: I9899b98517fe0c239bffcf7a75681560029aa2ba --- src/oracle.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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); } -- 2.30.2