@@ -343,7 +343,7 @@ NAN_METHOD(Connection::Execute)
343
343
executeBaton->maxRows = connection->oracledb_ ->getMaxRows ();
344
344
executeBaton->prefetchRows = connection->oracledb_ ->getPrefetchRows ();
345
345
executeBaton->outFormat = connection->oracledb_ ->getOutFormat ();
346
- executeBaton->autoCommit = connection->oracledb_ ->getAutoCommit ();
346
+ executeBaton->autoCommit = connection->oracledb_ ->getAutoCommit ();
347
347
executeBaton->dpienv = connection->oracledb_ ->getDpiEnv ();
348
348
executeBaton->dpiconn = connection->dpiconn_ ;
349
349
executeBaton->njsconn = connection;
@@ -412,16 +412,16 @@ void Connection::ProcessOptions (_NAN_METHOD_ARGS, unsigned int index,
412
412
if (args[index]->IsObject () && !args[index]->IsArray ())
413
413
{
414
414
options = args[index]->ToObject ();
415
- NJS_GET_UINT_FROM_JSON ( executeBaton->maxRows , executeBaton->error ,
416
- options, " maxRows" , 2 , exitProcessOptions );
417
- NJS_GET_UINT_FROM_JSON ( executeBaton->prefetchRows , executeBaton->error ,
418
- options, " prefetchRows" , 2 , exitProcessOptions );
419
- NJS_GET_UINT_FROM_JSON ( executeBaton->outFormat , executeBaton->error ,
420
- options, " outFormat" , 2 , exitProcessOptions );
421
- NJS_GET_BOOL_FROM_JSON ( executeBaton->getRS , executeBaton->error ,
422
- options, " resultSet" , 2 , exitProcessOptions );
423
- NJS_GET_BOOL_FROM_JSON ( executeBaton->autoCommit , executeBaton->error ,
424
- options, " autoCommit" , 2 , exitProcessOptions );
415
+ NJS_GET_UINT_FROM_JSON ( executeBaton->maxRows , executeBaton->error ,
416
+ options, " maxRows" , 2 , exitProcessOptions );
417
+ NJS_GET_UINT_FROM_JSON ( executeBaton->prefetchRows , executeBaton->error ,
418
+ options, " prefetchRows" , 2 , exitProcessOptions );
419
+ NJS_GET_UINT_FROM_JSON ( executeBaton->outFormat , executeBaton->error ,
420
+ options, " outFormat" , 2 , exitProcessOptions );
421
+ NJS_GET_BOOL_FROM_JSON ( executeBaton->getRS , executeBaton->error ,
422
+ options, " resultSet" , 2 , exitProcessOptions );
423
+ NJS_GET_BOOL_FROM_JSON ( executeBaton->autoCommit , executeBaton->error ,
424
+ options, " autoCommit" , 2 , exitProcessOptions );
425
425
}
426
426
else
427
427
{
@@ -740,11 +740,12 @@ void Connection::Async_Execute (uv_work_t *req)
740
740
executeBaton->dpistmt ->execute (0 , executeBaton->autoCommit );
741
741
const dpi::MetaData* meta = executeBaton->dpistmt ->getMetaData ();
742
742
executeBaton->numCols = executeBaton->dpistmt ->numCols ();
743
- executeBaton->columnNames = new std::string[executeBaton->numCols ];
744
- Connection::metaData ( executeBaton->columnNames , meta,
743
+ executeBaton->columnNames = new std::string[executeBaton->numCols ];
744
+ Connection::CopyMetaData ( executeBaton->columnNames , meta,
745
745
executeBaton->numCols );
746
746
if ( executeBaton->getRS ) goto exitAsyncExecute;
747
- Connection::GetDefines (executeBaton, meta, executeBaton->numCols );
747
+ Connection::DoDefines (executeBaton, meta, executeBaton->numCols );
748
+ Connection::DoFetch (executeBaton);
748
749
}
749
750
else
750
751
{
@@ -845,7 +846,9 @@ void Connection::PrepareAndBind (eBaton* executeBaton)
845
846
executeBaton->st = executeBaton->dpistmt ->stmtType ();
846
847
executeBaton->stmtIsReturning = executeBaton->dpistmt ->isReturning ();
847
848
848
- if (executeBaton->getRS && executeBaton->prefetchRows > -1 )
849
+ // prefetch is set by user, pass it to DPI.
850
+ if ( executeBaton->getRS &&
851
+ executeBaton->prefetchRows > NJS_PREFETCH_ROWS_NOT_SET )
849
852
executeBaton->dpistmt ->prefetchRows (executeBaton->prefetchRows );
850
853
851
854
if (!executeBaton->binds .empty ())
@@ -955,81 +958,97 @@ void Connection::PrepareAndBind (eBaton* executeBaton)
955
958
/* ****************************************************************************/
956
959
/*
957
960
DESCRIPTION
958
- get meta data into baton
961
+ copy column names from meta data to the string array passed as parameter.
959
962
960
963
PARAMETERS:
961
- string arrat, metaData, numCols
964
+ string array - column names
965
+ metaData - metaData info from DPI
966
+ numCols - number of columns
962
967
*/
963
- void Connection::metaData ( std::string* names, const dpi::MetaData* meta,
964
- unsigned int numCols )
968
+ void Connection::CopyMetaData ( std::string* names, const dpi::MetaData* meta,
969
+ unsigned int numCols )
965
970
{
966
- for (unsigned int i = 0 ; i < numCols; i ++)
971
+ for (unsigned int col = 0 ; col < numCols; col ++)
967
972
{
968
- names[i ] = std::string ( (const char *)meta[i ].colName ,
969
- meta[i ].colNameLen );
973
+ names[col ] = std::string ( (const char *)meta[col ].colName ,
974
+ meta[col ].colNameLen );
970
975
}
971
976
}
972
977
973
978
/* ****************************************************************************/
974
979
/*
975
980
DESCRIPTION
976
- Allocate defines buffer for query output.
977
- Call DPI define and fetch .
981
+ Allocate defines buffer for query output and do fetch .
982
+ Call DPI define.
978
983
979
984
PARAMETERS:
980
985
eBaton struct
981
986
*/
982
- void Connection::GetDefines ( eBaton* executeBaton, const dpi::MetaData* meta,
983
- unsigned int numCols )
987
+ void Connection::DoDefines ( eBaton* executeBaton, const dpi::MetaData* meta,
988
+ unsigned int numCols )
984
989
{
985
990
Define *defines = new Define[numCols];
986
991
987
- for (unsigned int i = 0 ; i < numCols; i ++)
992
+ for (unsigned int col = 0 ; col < numCols; col ++)
988
993
{
989
- switch (meta[i ].dbType )
994
+ switch (meta[col ].dbType )
990
995
{
991
996
case dpi::DpiNumber :
992
997
case dpi::DpiBinaryFloat :
993
998
case dpi::DpiBinaryDouble :
994
- defines[i ].fetchType = dpi::DpiDouble;
995
- defines[i ].maxSize = sizeof (double );
996
- defines[i ].buf = (double *)malloc (defines[i ].maxSize *executeBaton->maxRows );
999
+ defines[col ].fetchType = dpi::DpiDouble;
1000
+ defines[col ].maxSize = sizeof (double );
1001
+ defines[col ].buf = (double *)malloc (defines[col ].maxSize *executeBaton->maxRows );
997
1002
break ;
998
1003
case dpi::DpiVarChar :
999
1004
case dpi::DpiFixedChar :
1000
- defines[i ].fetchType = DpiVarChar;
1001
- defines[i ].maxSize = meta[i ].dbSize ;
1002
- defines[i ].buf = (char *)malloc (defines[i ].maxSize *executeBaton->maxRows );
1005
+ defines[col ].fetchType = DpiVarChar;
1006
+ defines[col ].maxSize = meta[col ].dbSize ;
1007
+ defines[col ].buf = (char *)malloc (defines[col ].maxSize *executeBaton->maxRows );
1003
1008
break ;
1004
1009
case dpi::DpiDate :
1005
1010
case dpi::DpiTimestamp:
1006
1011
case dpi::DpiTimestampLTZ:
1007
- defines[i ].dttmarr = executeBaton->dpienv ->getDateTimeArray (
1012
+ defines[col ].dttmarr = executeBaton->dpienv ->getDateTimeArray (
1008
1013
executeBaton->dpistmt ->getError () );
1009
- defines[i ].fetchType = DpiTimestampLTZ;
1010
- defines[i ].maxSize = meta[i ].dbSize ;
1011
- defines[i ].extbuf = defines[i ].dttmarr ->init (executeBaton->maxRows );
1014
+ defines[col ].fetchType = DpiTimestampLTZ;
1015
+ defines[col ].maxSize = meta[col ].dbSize ;
1016
+ defines[col ].extbuf = defines[col ].dttmarr ->init (executeBaton->maxRows );
1012
1017
break ;
1013
1018
default :
1014
1019
executeBaton->error = NJSMessages::getErrorMsg (errUnsupportedDatType);
1015
1020
return ;
1016
1021
break ;
1017
1022
}
1018
- defines[i ].ind = (short *)malloc (sizeof (short )*(executeBaton->maxRows ));
1019
- defines[i ].len = (DPI_BUFLEN_TYPE *)malloc (sizeof (DPI_BUFLEN_TYPE)*
1023
+ defines[col ].ind = (short *)malloc (sizeof (short )*(executeBaton->maxRows ));
1024
+ defines[col ].len = (DPI_BUFLEN_TYPE *)malloc (sizeof (DPI_BUFLEN_TYPE)*
1020
1025
executeBaton->maxRows );
1021
1026
1022
- executeBaton->dpistmt ->define (i +1 , defines[i ].fetchType ,
1023
- (defines[i ].buf ) ? defines[i ].buf : defines[i ].extbuf ,
1024
- defines[i ].maxSize , defines[i ].ind , defines[i ].len );
1027
+ executeBaton->dpistmt ->define (col +1 , defines[col ].fetchType ,
1028
+ (defines[col ].buf ) ? defines[col ].buf : defines[col ].extbuf ,
1029
+ defines[col ].maxSize , defines[col ].ind , defines[col ].len );
1025
1030
}
1031
+ executeBaton->defines = defines;
1032
+ executeBaton->numCols = numCols;
1033
+ }
1034
+
1035
+ /* ****************************************************************************/
1036
+ /*
1037
+ DESCRIPTION
1038
+ Fetch rows into defines buffer for query output.
1039
+ Call DPI fetch.
1040
+
1041
+ PARAMETERS:
1042
+ eBaton struct
1043
+ */
1044
+ void Connection::DoFetch (eBaton* executeBaton)
1045
+ {
1026
1046
executeBaton->dpistmt ->fetch (executeBaton->maxRows );
1027
- executeBaton->defines = defines;
1028
- executeBaton->numCols = numCols;
1029
1047
executeBaton->rowsFetched = executeBaton->dpistmt ->rowsFetched ();
1030
- Connection::descr2Dbl (executeBaton->defines , numCols,
1031
- executeBaton->rowsFetched ,
1032
- executeBaton->getRS );
1048
+ Connection::Descr2Dbl ( executeBaton->defines ,
1049
+ executeBaton->numCols ,
1050
+ executeBaton->rowsFetched ,
1051
+ executeBaton->getRS );
1033
1052
}
1034
1053
1035
1054
/* ****************************************************************************/
@@ -1040,7 +1059,7 @@ void Connection::GetDefines ( eBaton* executeBaton, const dpi::MetaData* meta,
1040
1059
PARAMETERS:
1041
1060
Define struct, numCols
1042
1061
*/
1043
- void Connection::descr2Dbl ( Define* defines, unsigned int numCols,
1062
+ void Connection::Descr2Dbl ( Define* defines, unsigned int numCols,
1044
1063
unsigned int rowsFetched, bool getRS )
1045
1064
{
1046
1065
for (unsigned int col = 0 ; col < numCols; col ++ )
0 commit comments