Skip to content

Commit 9fbafce

Browse files
committed
Prefetching support
1 parent ceebb54 commit 9fbafce

File tree

7 files changed

+14
-13
lines changed

7 files changed

+14
-13
lines changed

src/dpi/include/dpiStmt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class Stmt
147147
virtual DpiStmtType stmtType() const = 0;
148148

149149
// If NJS layer doesn't set any value, default prefetch is done by OCI.
150-
virtual void prefetchRows ( int prefetchRows ) = 0;
150+
virtual void prefetchRows ( unsigned int prefetchRows ) = 0;
151151

152152
virtual bool isDML() const = 0 ;
153153

src/dpi/src/dpiStmtImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ unsigned int StmtImpl::numCols ()
208208
NONE
209209
210210
*/
211-
void StmtImpl::prefetchRows (int prefetchRows)
211+
void StmtImpl::prefetchRows (unsigned int prefetchRows)
212212
{
213213
ociCall(OCIAttrSet(stmth_, OCI_HTYPE_STMT, &prefetchRows, 0,
214214
OCI_ATTR_PREFETCH_ROWS, errh_), errh_);

src/dpi/src/dpiStmtImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class StmtImpl : public Stmt
6666
virtual DpiStmtType stmtType () const;
6767
virtual DPI_SZ_TYPE rowsAffected () const;
6868
virtual unsigned int numCols() ;
69-
virtual void prefetchRows( int prefetchRows ) ;
69+
virtual void prefetchRows( unsigned int prefetchRows ) ;
7070
virtual unsigned int rowsFetched () const ;
7171

7272
// Methods

src/njs/src/njsConnection.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -849,10 +849,8 @@ void Connection::PrepareAndBind (eBaton* executeBaton)
849849
executeBaton->st = executeBaton->dpistmt->stmtType ();
850850
executeBaton->stmtIsReturning = executeBaton->dpistmt->isReturning ();
851851

852-
// prefetch is set by user, pass it to DPI.
853-
if( executeBaton->getRS &&
854-
executeBaton->prefetchRows > NJS_PREFETCH_ROWS_NOT_SET )
855-
executeBaton->dpistmt->prefetchRows(executeBaton->prefetchRows);
852+
// set prefetch
853+
executeBaton->dpistmt->prefetchRows(executeBaton->prefetchRows);
856854

857855
if(!executeBaton->binds.empty())
858856
{

src/njs/src/njsConnection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ typedef struct eBaton
118118
Connection *njsconn;
119119
DPI_SZ_TYPE rowsAffected;
120120
unsigned int maxRows;
121-
int prefetchRows;
121+
unsigned int prefetchRows;
122122
bool getRS;
123123
bool autoCommit;
124124
unsigned int rowsFetched;

src/njs/src/njsOracle.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Persistent<FunctionTemplate> Oracledb::oracledbTemplate_s;
6464
#define NJS_POOL_MAX 4
6565
#define NJS_POOL_INCR 1
6666
#define NJS_POOL_TIMEOUT 60
67+
#define NJS_PREFETCH_ROWS 100
6768

6869
/*****************************************************************************/
6970
/*
@@ -81,7 +82,7 @@ Oracledb::Oracledb()
8182
poolMin_ = NJS_POOL_MIN;
8283
poolIncrement_ = NJS_POOL_INCR;
8384
poolTimeout_ = NJS_POOL_TIMEOUT;
84-
prefetchRows_ = NJS_PREFETCH_ROWS_NOT_SET;
85+
prefetchRows_ = NJS_PREFETCH_ROWS;
8586
connClass_ = "";
8687
externalAuth_ = false;
8788
}
@@ -137,6 +138,10 @@ void Oracledb::Init(Handle<Object> target)
137138
NanNew<v8::String>("stmtCacheSize"),
138139
Oracledb::GetStmtCacheSize,
139140
Oracledb::SetStmtCacheSize );
141+
temp->InstanceTemplate()->SetAccessor(
142+
NanNew<v8::String>("prefetchRows"),
143+
Oracledb::GetPrefetchRows,
144+
Oracledb::SetPrefetchRows );
140145
temp->InstanceTemplate()->SetAccessor(
141146
NanNew<v8::String>("autoCommit"),
142147
Oracledb::GetAutoCommit,

src/njs/src/njsOracle.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ using namespace v8;
7777
(NJS_NODE_ORACLEDB_MINOR * 100) + \
7878
(NJS_NODE_ORACLEDB_PATCH) )
7979

80-
#define NJS_PREFETCH_ROWS_NOT_SET -1 // by default prefetch is not set, so -1
81-
8280
class Oracledb: public ObjectWrap
8381
{
8482
public:
@@ -95,7 +93,7 @@ class Oracledb: public ObjectWrap
9593
unsigned int getPoolMax () const { return poolMax_; }
9694
unsigned int getPoolIncrement () const { return poolIncrement_; }
9795
unsigned int getPoolTimeout () const { return poolTimeout_; }
98-
signed int getPrefetchRows () const { return prefetchRows_; }
96+
unsigned int getPrefetchRows () const { return prefetchRows_; }
9997
const std::string& getConnectionClass () const { return connClass_; }
10098

10199

@@ -153,7 +151,7 @@ class Oracledb: public ObjectWrap
153151
unsigned int maxRows_;
154152

155153
unsigned int stmtCacheSize_;
156-
signed int prefetchRows_;
154+
unsigned int prefetchRows_;
157155

158156
unsigned int poolMin_;
159157
unsigned int poolMax_;

0 commit comments

Comments
 (0)