Skip to content

Commit e3e74b0

Browse files
committed
changes for fixing function scope for real_oci_handle_free
1 parent 8f63ac9 commit e3e74b0

File tree

2 files changed

+11
-26
lines changed

2 files changed

+11
-26
lines changed

worker/cppworker/worker/OCCChild.cpp

+8-24
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ namespace
105105
using namespace occ;
106106

107107
//-----------------------------------------------------------------------------
108-
#define DO_OCI_HANDLE_FREE(res, t, l, errhp2) real_oci_handle_free(reinterpret_cast<dvoid*&>(res), t, #res, l, errhp2)
108+
#define DO_OCI_HANDLE_FREE(res, t, l, errhp) real_oci_handle_free(reinterpret_cast<dvoid*&>(res), t, #res, l, errhp)
109109

110110
#define NUM_INDICATOR_BUF 64
111111
#define NUM_STR_SIZE_BUF 64
@@ -209,7 +209,7 @@ OCCChild::OCCChild(const InitParams& _params) : Worker(_params),
209209
stmt_cache(NULL),
210210
cur_stmt(NULL),
211211
max_cache_size(0),
212-
max_oci_stmt_cache_size(0)
212+
max_oci_stmt_cache_size(0),
213213
max_statement_age(0),
214214
cache_size(0),
215215
cache_size_peak(0),
@@ -363,7 +363,7 @@ OCCChild::OCCChild(const InitParams& _params) : Worker(_params),
363363

364364
//MAX OCI statement cache size parameter and it should be > 0
365365
if(config->get_value("max_oci_stmt_cache_size", cval))
366-
max_oci_stmt_cache_size = StringUtil::to_int(c_val);
366+
max_oci_stmt_cache_size = StringUtil::to_int(cval);
367367

368368
if (enable_oci_stmt_cache && max_oci_stmt_cache_size < 1)
369369
{
@@ -4779,41 +4779,25 @@ int OCCChild::clear_indicators()
47794779
return 0;
47804780
}
47814781

4782-
4783-
bool real_oci_handle_free(dvoid *&hndlp, ub4 type, const char *res, LogLevelEnum level, OCIError *errhp = NULL)
4782+
bool OCCChild::real_oci_handle_free(dvoid *&hndlp, ub4 type, const char *res, LogLevelEnum level, OCIError *errhp)
47844783
{
47854784
int rc;
4786-
47874785
if (hndlp == NULL) return true;
4788-
4789-
// Special handling for statement handles when caching is enabled
47904786
if (type == OCI_HTYPE_STMT && errhp != NULL) {
4791-
// Release to cache instead of freeing (assuming caching is enabled)
47924787
rc = OCIStmtRelease((OCIStmt*)hndlp, errhp, NULL, 0, OCI_DEFAULT);
4793-
if (rc != OCI_SUCCESS) {
4794-
std::ostringstream os;
4795-
os << "failed to OCIStmtRelease(" << (res ? res : "(null)") << ")";
4796-
log_oracle_error(rc, os.str().c_str(), level);
4797-
return false;
4798-
}
4799-
// Note: Do not set hndlp = NULL here if you want to allow reuse in cache
4800-
// The cache manages the handle; it will be freed with the session
4801-
return true;
4788+
} else {
4789+
rc = OCIHandleFree(hndlp, type);
4790+
hndlp = NULL;
48024791
}
4803-
4804-
// For all other handle types, use OCIHandleFree
4805-
rc = OCIHandleFree(hndlp, type);
4806-
hndlp = NULL;
48074792
if (rc != OCI_SUCCESS) {
48084793
std::ostringstream os;
4809-
os << "failed to OCIHandleFree(" << (res ? res : "(null)") << ")";
4794+
os << "failed to " << (type == OCI_HTYPE_STMT ? "OCIStmtRelease" : "OCIHandleFree") << "(" << (res ? res : "(null)") << ")";
48104795
log_oracle_error(rc, os.str().c_str(), level);
48114796
return false;
48124797
}
48134798
return true;
48144799
}
48154800

4816-
48174801
int OCCChild::get_column_size(int *size, ub2 *type, ub4 pos, bool use_datetime)
48184802
{
48194803
int rc = 0;

worker/cppworker/worker/OCCChild.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,14 @@ class OCCChild : public Worker
189189

190190
// our statment cache
191191
bool enable_cache;
192-
bool enable_oci_cache; //Enable OCI default statement cache
192+
bool enable_oci_stmt_cache; //Enable OCI default statement cache
193193
StmtCacheEntry** stmt_cache;
194194
StmtCacheEntry* cur_stmt;
195195
StmtCacheEntry one_stmt;
196196
int max_cache_size;
197197
int max_statement_age;
198198
int cache_size;
199+
int max_oci_stmt_cache_size; //MAx OCI statement cache size
199200
int cache_size_peak;
200201
ulong cache_hits, cache_misses, cache_expires, cache_dumps;
201202
int cache_expire_frequency;
@@ -433,7 +434,7 @@ class OCCChild : public Worker
433434
// frees oci resources and logs messages
434435
// if the hndlp is NULL, then do nothing and return true
435436
// returns false if error was detected
436-
bool real_oci_handle_free(dvoid *&hndlp, ub4 type, const char *name, LogLevelEnum level);
437+
bool real_oci_handle_free(dvoid *&hndlp, ub4 type, const char *name, LogLevelEnum level, OCIError *errhp = NULL);
437438

438439
// set or clear non-blocking mode
439440
int set_oci_nonblocking(bool _nonblock, const StmtCacheEntry *_stmt = NULL);

0 commit comments

Comments
 (0)