@@ -122,7 +122,7 @@ static const unsigned int DEFAULT_TRANS_TIMEOUT = 5; //!< Default global transac
122
122
static const char *const DEFAULT_MODULE_NAME = " Unknown" ; // !< Default module name
123
123
124
124
// !<Key that occ client sends client machine name, should match OCCClient::send_client_info
125
- static const std::string SERVER_VERSION = " 10g " ;
125
+ static const std::string SERVER_VERSION = " 19c " ;
126
126
static const std::string SERVER_RELEASE_PREFIX = " Enterprise Edition Release " ;
127
127
static const std::string SERVER_DB_PREFIX = " Oracle Database " ;
128
128
static const std::string CLIENT_NAME_PREFIX = " Name: " ;
@@ -1033,6 +1033,7 @@ int OCCChild::handle_command(const int _cmd, std::string &_line)
1033
1033
if (m_sql_rewritten) {
1034
1034
c->AddData (" sqlhash" , m_orig_query_hash);
1035
1035
}
1036
+ c->AddData (" SQL_ID" , sql_id.c_str ());
1036
1037
}
1037
1038
OCIAttrSet ((dvoid *)authp, OCI_HTYPE_SESSION, (dvoid *) const_cast <char *>(m_bind_data.c_str ()),
1038
1039
m_bind_data.length (), OCI_ATTR_CLIENT_IDENTIFIER, errhp);
@@ -1170,6 +1171,7 @@ int OCCChild::handle_command(const int _cmd, std::string &_line)
1170
1171
CalTransaction cal_trans (" FETCH" );
1171
1172
cal_trans.SetName (m_query_hash);
1172
1173
cal_trans.AddData (" HOST" , m_dbhost_name);
1174
+ cal_trans.AddData (" SQL_ID" , sql_id.c_str ());
1173
1175
1174
1176
// fetch a block of rows
1175
1177
long long fetched_bsize = fetch (_line);
@@ -1651,6 +1653,16 @@ int OCCChild::connect(const std::string& db_username, const std::string& db_pass
1651
1653
log_oracle_error (rc," Failed to set failover callback." );
1652
1654
}
1653
1655
1656
+ // Enable statement cache
1657
+ if (enable_cache)
1658
+ {
1659
+ rc = OCIAttrSet (svchp, OCI_HTYPE_SVCCTX, &max_cache_size, (ub4)0 , (ub4)OCI_ATTR_STMTCACHESIZE, errhp);
1660
+ if (rc != OCI_SUCCESS)
1661
+ {
1662
+ log_oracle_error (rc, " Failed to set statement cache." );
1663
+ }
1664
+ }
1665
+
1654
1666
has_session = true ;
1655
1667
cal_trans.Completed ();
1656
1668
@@ -2377,10 +2389,10 @@ int OCCChild::execute_query(const std::string& query)
2377
2389
return -1 ;
2378
2390
}
2379
2391
2380
- rc = OCIStmtPrepare (
2381
- stmthp, errhp, (text *) const_cast <char *>(query.c_str ()),
2382
- (ub4) query.length (),
2383
- (ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT);
2392
+ rc = OCIStmtPrepare2 (svchp,
2393
+ stmthp, errhp, (text *)const_cast <char *>(query.c_str ()),
2394
+ (ub4)query.length (),
2395
+ (ub4)OCI_NTV_SYNTAX, (ub4)OCI_DEFAULT);
2384
2396
if (rc != OCI_SUCCESS)
2385
2397
{
2386
2398
DO_OCI_HANDLE_FREE (stmthp, OCI_HTYPE_STMT, LOG_WARNING);
@@ -3131,13 +3143,13 @@ int OCCChild::prepare(const std::string& _statement, occ::ApiVersion _version)
3131
3143
cache_misses++;
3132
3144
3133
3145
// prepare the new statement
3134
- rc = OCIStmtPrepare (
3135
- entry->stmthp ,
3136
- errhp,
3137
- (text *) const_cast <char *> (statement.c_str ()),
3138
- (ub4) statement.length (),
3139
- (ub4) OCI_NTV_SYNTAX,
3140
- (ub4) OCI_DEFAULT);
3146
+ rc = OCIStmtPrepare2 (svchp,
3147
+ entry->stmthp ,
3148
+ errhp,
3149
+ (text *)const_cast <char *>(statement.c_str ()),
3150
+ (ub4)statement.length (),
3151
+ (ub4)OCI_NTV_SYNTAX,
3152
+ OCI_DEFAULT | OCI_PREP2_GET_SQL_ID );
3141
3153
if (rc != OCI_SUCCESS)
3142
3154
{
3143
3155
sql_error (rc, entry);
@@ -3160,6 +3172,18 @@ int OCCChild::prepare(const std::string& _statement, occ::ApiVersion _version)
3160
3172
return -1 ;
3161
3173
}
3162
3174
3175
+ // Get SQL_ID
3176
+ char sql_id_data[32 ];
3177
+ ub4 sql_id_len = sizeof (sql_id_data);
3178
+ rc = OCIAttrGet ((CONST dvoid *)entry->stmthp , OCI_HTYPE_STMT, sql_id_data, &sql_id_len, OCI_ATTR_SQL_ID, errhp);
3179
+ if (rc != OCI_SUCCESS)
3180
+ {
3181
+ WRITE_LOG_ENTRY (logfile, LOG_INFO, " failed to fetch sql_id from statement." );
3182
+ sql_error (rc, entry);
3183
+ free_stmt (entry);
3184
+ return -1 ;
3185
+ }
3186
+ sql_id = std::string (sql_id_data, sql_id_len);
3163
3187
// // Delineate between SELECT and SELECT ... FOR UPDATE
3164
3188
// if ((entry->type == SELECT_STMT) &&
3165
3189
// statement.contains(" FOR UPDATE"))
@@ -5393,7 +5417,7 @@ int OCCChild::get_db_charset(std::string& _charset)
5393
5417
sys_context('USERENV', 'DB_UNIQUE_NAME') AS db_uname, \
5394
5418
sys_context('USERENV', 'SID') AS sid \
5395
5419
FROM nls_database_parameters WHERE parameter = 'NLS_CHARACTERSET'" ;
5396
- rc = OCIStmtPrepare ( stmthp, errhp, (text *) const_cast <char *>(sql), strlen (sql), OCI_NTV_SYNTAX, OCI_DEFAULT);
5420
+ rc = OCIStmtPrepare2 (svchp, stmthp, errhp, (text *)const_cast <char *>(sql), strlen (sql), OCI_NTV_SYNTAX, OCI_DEFAULT);
5397
5421
if (rc != OCI_SUCCESS)
5398
5422
{
5399
5423
DO_OCI_HANDLE_FREE (stmthp, OCI_HTYPE_STMT, LOG_WARNING);
@@ -5504,7 +5528,7 @@ int OCCChild::execute_query_with_n_binds( const std::string & _sql, const std::v
5504
5528
return -1 ;
5505
5529
}
5506
5530
5507
- rc = OCIStmtPrepare ( m_session_var_stmthp, errhp, (text *) const_cast <char *>(_sql.c_str ()), (ub4) _sql.length (), OCI_NTV_SYNTAX, OCI_DEFAULT);
5531
+ rc = OCIStmtPrepare2 (svchp, m_session_var_stmthp, errhp, (text *)const_cast <char *>(_sql.c_str ()), (ub4)_sql.length (), OCI_NTV_SYNTAX, OCI_DEFAULT);
5508
5532
if (rc != OCI_SUCCESS)
5509
5533
{
5510
5534
DO_OCI_HANDLE_FREE (m_session_var_stmthp, OCI_HTYPE_STMT, LOG_WARNING);
0 commit comments