From 2d0c4c77126d75a18bd4fff582a45f7fa313f845 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 3 Mar 2010 14:01:30 +0100 Subject: [PATCH] oracle plugin: Fix semantics of OCIAttrGet. Apparently it returns success if it could fetch the parameter value and doesn't interpret the value itself. So returning NULL when querying for OCI_ATTR_SERVER_STATUS does not result in an error. Handle this as a lost connection. Thanks to Sven for pointing this out :) --- src/oracle.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/oracle.c b/src/oracle.c index 49cf6571..7a8ccc6b 100644 --- a/src/oracle.c +++ b/src/oracle.c @@ -612,16 +612,22 @@ static int o_read_database (o_database_t *db) /* {{{ */ o_report_error ("o_read_database", "OCIAttrGet", oci_error); return (-1); } - assert (server_handle != NULL); - connection_status = 0; - status = OCIAttrGet ((void *) server_handle, OCI_HTYPE_SERVER, - (void *) &connection_status, /* size pointer = */ NULL, - OCI_ATTR_SERVER_STATUS, oci_error); - if (status != OCI_SUCCESS) + if (server_handle == NULL) { - o_report_error ("o_read_database", "OCIAttrGet", oci_error); - return (-1); + connection_status = OCI_SERVER_NOT_CONNECTED; + } + else /* if (server_handle != NULL) */ + { + connection_status = 0; + status = OCIAttrGet ((void *) server_handle, OCI_HTYPE_SERVER, + (void *) &connection_status, /* size pointer = */ NULL, + OCI_ATTR_SERVER_STATUS, oci_error); + if (status != OCI_SUCCESS) + { + o_report_error ("o_read_database", "OCIAttrGet", oci_error); + return (-1); + } } if (connection_status != OCI_SERVER_NORMAL) -- 2.11.0