Skip to content

Commit 556fcab

Browse files
committed
Fix merge
1 parent acfb7fb commit 556fcab

File tree

6 files changed

+19
-27
lines changed

6 files changed

+19
-27
lines changed

src/dpi/include/dpiStmt.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,15 @@ typedef enum
101101

102102

103103
/* OCI Stmt Handle state
104-
* For REFCURSORS state should be DpiStmtStateExecuted
104+
* For REFCURSORS state should be DPI_STMT_STATE_EXECUTED
105105
*/
106106
#define DPI_STMT_STATE_UNDEFINED (0) // Undefined
107107
#define DPI_STMT_STATE_INITIALIZED (1) // Initialized
108108
#define DPI_STMT_STATE_EXECUTED (2) // Executed
109109
#define DPI_STMT_STATE_ENDOFFETCH (3) // End of Fetch
110110

111111

112+
112113
/*
113114
* For 11g/12c Compatability BIND/DEFINE calls expect ub8 in 12c & ub4 in 11g
114115
* Using this type makes is compile-time selction of 11g or 12c.
@@ -197,7 +198,7 @@ class Stmt
197198

198199
virtual OCIError *getError () = 0;
199200

200-
virtual DpiStmtState getState () = 0;
201+
virtual unsigned long getState () = 0;
201202

202203
virtual ~Stmt(){};
203204

src/dpi/src/dpiStmtImpl.cpp

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ StmtImpl::StmtImpl (EnvImpl *env, OCIEnv *envh, ConnImpl *conn,
8989
try : conn_(conn), errh_(NULL), svch_(svch),
9090
stmth_(NULL), numCols_ (0),meta_(NULL), stmtType_ (DpiStmtUnknown),
9191
isReturning_(false), isReturningSet_(false), refCursor_(false),
92-
state_(0)
92+
state_(DPI_STMT_STATE_UNDEFINED)
9393
{
9494
// create an OCIError object for this execution
9595
ociCallEnv (OCIHandleAlloc ((void *)envh, (dvoid **)&errh_,
@@ -729,27 +729,15 @@ bool StmtImpl::isReturning ()
729729
One of the possible values DpiStmtState
730730
(DpiStmtStateInitialized, DpiStmtStateExecute, DpiStmtEndOfFetch)
731731
*/
732-
DpiStmtState StmtImpl::getState ()
732+
unsigned long StmtImpl::getState ()
733733
{
734-
DpiStmtState ret = DpiStmtStateUndefined ;
735-
736-
if ( !state_ )
734+
if ( state_ == DPI_STMT_STATE_UNDEFINED )
737735
{
738736
ociCall (OCIAttrGet (stmth_, OCI_HTYPE_STMT, (ub4*)&state_, NULL,
739737
OCI_ATTR_STMT_STATE, errh_ ), errh_ );
740738
}
741739

742-
if ( ( state_ & OCI_STMT_STATE_INITIALIZED ) == OCI_STMT_STATE_INITIALIZED )
743-
ret = DpiStmtStateInitialized;
744-
745-
if ( ( state_ & OCI_STMT_STATE_EXECUTED ) == OCI_STMT_STATE_EXECUTED )
746-
ret = DpiStmtStateExecuted;
747-
748-
if ( ( state_ & OCI_STMT_STATE_END_OF_FETCH ) ==
749-
OCI_STMT_STATE_END_OF_FETCH )
750-
ret = DpiStmtStateEndOfFetch;
751-
752-
return ret;
740+
return state_;
753741
}
754742

755743

src/dpi/src/dpiStmtImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class StmtImpl : public Stmt
9494

9595
virtual OCIError * getError () { return errh_; }
9696

97-
virtual DpiStmtState getState ();
97+
virtual unsigned long getState ();
9898

9999

100100
// Is the SQL statement DML or not ?

src/njs/src/njsConnection.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -935,12 +935,13 @@ void Connection::Async_Execute (uv_work_t *req)
935935
}
936936
}
937937

938-
/* For each OUT Binds of CURSOR type, get the number of columns */
938+
/* For each OUT Binds of CURSOR type, get the dpistmt state */
939939
for ( unsigned int b = 0; b < executeBaton->binds.size (); b ++ )
940940
{
941941
Bind *bind = executeBaton->binds[b];
942942

943-
if ( bind->isOut && bind->type == dpi::DpiRSet )
943+
/* Here bind->isOut is expected to be TRUE, and is checked earlier */
944+
if ( bind->type == dpi::DpiRSet )
944945
{
945946
unsigned long state = ((Stmt*)bind->value)->getState ();
946947

@@ -1424,14 +1425,14 @@ void Connection::DoDefines ( eBaton* executeBaton, const dpi::MetaData* meta,
14241425
defines[col].fetchType = Connection::GetTargetType ( executeBaton,
14251426
executeBaton->columnNames[col],
14261427
meta[col].dbType );
1428+
14271429
/*
14281430
* the buffer size is increased to account for possible character
14291431
* size expansion when data is converted from the DB character set
14301432
* to AL32UTF8
14311433
*/
14321434

1433-
defines[col].maxSize = (meta[col].dbSize) * csratio;
1434-
1435+
defines[col].maxSize = (meta[col].dbSize) * csratio;
14351436

14361437
if ( NJS_SIZE_T_OVERFLOW ( defines[col].maxSize,
14371438
executeBaton->maxRows ) )
@@ -2064,6 +2065,10 @@ Handle<Value> Connection::GetValueRefCursor ( eBaton *executeBaton,
20642065
{
20652066
resultSet = NanNew(ResultSet::resultSetTemplate_s)->
20662067
GetFunction() ->NewInstance();
2068+
/*
2069+
* IN case of REFCURSOR, bind->flags will indicate whether we got
2070+
* a valid handle, based on that numCols, metaData are queried.
2071+
*/
20672072
(ObjectWrap::Unwrap<ResultSet> (resultSet))->
20682073
setResultSet( (dpi::Stmt*)(bind->value),
20692074
executeBaton);
@@ -2827,7 +2832,7 @@ void Connection::cbDynBufferAllocate ( void *ctx, bool dmlReturning,
28272832
}
28282833
else
28292834
{
2830-
bind->ind = (short *)malloc ( nRows * sizeof ( short ) ) ;
2835+
bind->ind = (short *)malloc ( (size_t)nRows * sizeof ( short ) ) ;
28312836
if( !bind->ind )
28322837
{
28332838
executeBaton->error = NJSMessages::getErrorMsg( errInsufficientMemory );

src/njs/src/njsResultSet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ void ResultSet::setResultSet ( dpi::Stmt *stmt, eBaton *executeBaton )
8787
*/
8888
this->numCols_ = 0;
8989
this->meta_ = NULL;
90+
this->state_ = INVALID;
9091
}
9192

92-
this->state_ = INACTIVE;
9393
this->outFormat_ = executeBaton->outFormat;
9494
this->fetchRowCount_ = 0;
9595
this->rsEmpty_ = false;

src/njs/src/njsResultSet.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ class ResultSet: public ObjectWrap {
133133

134134
static void clearFetchBuffer( Define* defineBuffers,
135135
unsigned int numCols );
136-
137-
static void Init ();
138136

139137

140138
dpi::Stmt *dpistmt_;

0 commit comments

Comments
 (0)