Skip to content

Commit 6f48ca6

Browse files
committed
changes for adding new flags for enabling oci statement cache
1 parent a8540a7 commit 6f48ca6

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

worker/cppworker/worker/OCCChild.cpp

+18-3
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,11 @@ OCCChild::OCCChild(const InitParams& _params) : Worker(_params),
205205
enable_hb_fix(false),
206206
hb_sender(NULL),
207207
enable_cache(true),
208+
enable_oci_stmt_cache(true),
208209
stmt_cache(NULL),
209210
cur_stmt(NULL),
210211
max_cache_size(0),
212+
max_oci_stmt_cache_size(0)
211213
max_statement_age(0),
212214
cache_size(0),
213215
cache_size_peak(0),
@@ -340,6 +342,9 @@ OCCChild::OCCChild(const InitParams& _params) : Worker(_params),
340342
// initialize statement cache vars
341343
// check if statement caching is enabled
342344
enable_cache = config->is_switch_enabled("enable_cache", FALSE);
345+
346+
//Enable OCI statement cache
347+
enable_oci_stmt_cache = config->is_switch_enabled("enable_oci_stmt_cache", FALSE);
343348
enable_whitelist_test = config->is_switch_enabled("enable_whitelist_test", FALSE);
344349

345350
// PPSCR00377721
@@ -356,6 +361,16 @@ OCCChild::OCCChild(const InitParams& _params) : Worker(_params),
356361
return;
357362
}
358363

364+
//MAX OCI statement cache size parameter and it should be > 0
365+
if(config->get_value("max_oci_stmt_cache_size", cval))
366+
max_oci_stmt_cache_size = StringUtil::to_int(c_val);
367+
368+
if (enable_oci_stmt_cache && max_oci_stmt_cache_size < 1)
369+
{
370+
WRITE_LOG_ENTRY(logfile, LOG_ALERT, "max_oci_stmt_cache_size undefined or invalid");
371+
constructor_success = 0;
372+
return;
373+
}
359374
// if global caching is enabled or session caching is enabled
360375
if (enable_cache || max_cache_size > 0)
361376
{
@@ -1654,12 +1669,12 @@ int OCCChild::connect(const std::string& db_username, const std::string& db_pass
16541669
}
16551670

16561671
// Enable statement cache
1657-
if (enable_cache)
1672+
if (enable_oci_stmt_cache)
16581673
{
1659-
rc = OCIAttrSet(svchp, OCI_HTYPE_SVCCTX, &max_cache_size, (ub4)0, (ub4)OCI_ATTR_STMTCACHESIZE, errhp);
1674+
rc = OCIAttrSet(svchp, OCI_HTYPE_SVCCTX, &max_oci_stmt_cache_size, (ub4)0, (ub4)OCI_ATTR_STMTCACHESIZE, errhp);
16601675
if (rc != OCI_SUCCESS)
16611676
{
1662-
log_oracle_error(rc, "Failed to set statement cache.");
1677+
log_oracle_error(rc, "Failed to set OCI statement cache.");
16631678
}
16641679
}
16651680

worker/cppworker/worker/OCCChild.h

+1
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ class OCCChild : public Worker
189189

190190
// our statment cache
191191
bool enable_cache;
192+
bool enable_oci_cache; //Enable OCI default statement cache
192193
StmtCacheEntry** stmt_cache;
193194
StmtCacheEntry* cur_stmt;
194195
StmtCacheEntry one_stmt;

0 commit comments

Comments
 (0)