Skip to content

Commit 6a2ad30

Browse files
committed
Fixed intermittent crash while setting fetchAsString, and incorrect output while reading the value.
1 parent 88b6423 commit 6a2ad30

File tree

5 files changed

+42
-29
lines changed

5 files changed

+42
-29
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## node-oracledb v1.2.0 (DD Mon YYYY)
44

5+
- Fixed intermittent crash while setting `fetchAsString`, and incorrect output while reading the value.
6+
57
- Changed write-only attributes to allow console.log() on Connection objects. Note the attribute values will show as null; refer to the documentation.
68

79
- Remove non-portable memory allocation for queries that return NULL.

src/njs/src/njsOracle.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ Oracledb::~Oracledb()
101101
if ( fetchAsStringTypes_ )
102102
{
103103
free ( fetchAsStringTypes_ );
104+
fetchAsStringTypes_ = NULL ;
105+
fetchAsStringTypesCount_ = 0;
104106
}
105107

106108
if (this->dpienv_)
@@ -557,11 +559,8 @@ NAN_PROPERTY_GETTER(Oracledb::GetFetchAsString)
557559

558560
if ( oracledb->fetchAsStringTypes_ )
559561
{
560-
unsigned int nCount = sizeof ( oracledb->fetchAsStringTypes_ ) /
561-
sizeof ( oracledb->fetchAsStringTypes_[0] ) ;
562-
563-
typeArray = NanNew<v8::Array>( nCount );
564-
for ( unsigned int t = 0; t < nCount ; t ++ )
562+
typeArray = NanNew<v8::Array>( oracledb->fetchAsStringTypesCount_ );
563+
for ( unsigned int t = 0; t < oracledb->fetchAsStringTypesCount_ ; t ++ )
565564
{
566565
typeArray->Set (t, NanNew<v8::Integer>(oracledb->fetchAsStringTypes_[t]));
567566
}
@@ -596,14 +595,17 @@ NAN_SETTER(Oracledb::SetFetchAsString)
596595
{
597596
free ( oracledb->fetchAsStringTypes_ ) ;
598597
oracledb->fetchAsStringTypesCount_ = 0 ;
599-
return;
598+
oracledb->fetchAsStringTypes_ = NULL ;
600599
}
600+
return;
601601
}
602602

603603
// If already defined, clear the array.
604604
if ( oracledb->fetchAsStringTypes_ )
605605
{
606606
free ( oracledb->fetchAsStringTypes_ );
607+
oracledb->fetchAsStringTypes_ = NULL ;
608+
oracledb->fetchAsStringTypesCount_ = 0 ;
607609
}
608610

609611
oracledb->fetchAsStringTypesCount_ = array->Length ();

test/connection.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,14 @@ describe('1. connection.js', function(){
248248
);
249249
})
250250

251-
it('1.2.3 can set maxRows to be 0', function(done){
251+
it.only('1.2.3 can not set maxRows to be 0', function(done){
252252
connection.should.be.ok;
253253
connection.execute(
254254
"SELECT * FROM oracledb_employees",
255255
{}, { maxRows: 0 },
256256
function(err, result){
257257
should.exist(err);
258-
err.message.should.startWith('NJS-026:');
258+
err.message.should.startWith('NJS-026:'); // NJS-026: maxRows must be greater than zero
259259
done();
260260
}
261261
);

test/list.txt

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
1.2 limits the number of rows fetched
88
1.2.1 by default, the number is 100
99
1.2.2 can also specify for each execution
10-
1.2.3 can set maxRows to be 0
10+
1.2.3 can not set maxRows to be 0
1111
1.2.4 cannot set maxRows to be a negative number
1212
1.2.5 sets maxRows to be very large value
1313
1.3 can call PL/SQL procedures
@@ -411,10 +411,15 @@
411411
- 55.12.1 should work
412412

413413
56. fetchAs.js
414-
56.1 FetchAs - DATE type as STRING
415-
56.2 FetchAs NUMBER & DATE type as STRING
416-
56.3 FetchAs Oracledb property by-type
417-
56.4 FetchAs override oracledb by-type (for DATE) at execute time
414+
56.1 property value check
415+
56.2 Fetch DATE column values as STRING - by-Column name
416+
56.3 Fetch DATE, NUMBER column values STRING - by Column-name
417+
56.4 Fetch DATE, NUMBER as STRING by-time configuration and by-name
418+
56.5 Fetch DATE, NUMBER column as STRING by-type and override at execute time
419+
56.6 Fetch ROWID column values STRING - non-ResultSet
420+
56.7 Fetch ROWID column values STRING - ResultSet
421+
56.8 large numbers with fetchInfo
422+
56.9 large numbers with setting fetchAsString property
418423

419424
57. nestedCursor.js
420425
57.1 testing nested cursor support - result set
@@ -442,7 +447,8 @@
442447
58.2.4 poolTimeout
443448
58.2.5 stmtCacheSize
444449
58.3 connection properties
445-
58.3.1 stmtCacheSize
446-
58.3.2 clientId
447-
58.3.3 action
448-
58.3.4 module
450+
58.3.1 Connection object intial toString values
451+
58.3.2 stmtCacheSize
452+
58.3.3 clientId
453+
58.3.4 action
454+
58.3.5 module

test/properties.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var should = require('should');
3939
var async = require('async');
4040
var dbConfig = require('./dbConfig.js');
4141

42-
describe.skip('58. properties.js', function() {
42+
describe('58. properties.js', function() {
4343

4444
if(dbConfig.externalAuth){
4545
var credential = { externalAuth: true, connectString: dbConfig.connectString };
@@ -66,10 +66,6 @@ describe.skip('58. properties.js', function() {
6666
defaultValues.outFormat = oracledb.outFormat;
6767
defaultValues.lobPrefetchSize = oracledb.lobPrefetchSize;
6868

69-
console.log("default fetchAsString value: ", defaultValues.fetchAsString);
70-
console.log("default type of fetchAsString", typeof (defaultValues.fetchAsString) ) ;
71-
console.log("original value of fetchAsString: ", oracledb.fetchAsString);
72-
console.log("original type of fetchAsString: ", typeof (oracledb.fetchAsString) );
7369
/*
7470
* lobPrefetchSize property is currently disabled.
7571
* Resetting it to default will lead to uncaught error "NJS-021: invalid type for conversion specified"
@@ -90,9 +86,6 @@ describe.skip('58. properties.js', function() {
9086
oracledb.fetchAsString = defaultValues.fetchAsString;
9187
oracledb.outFormat = defaultValues.outFormat;
9288
oracledb.lobPrefetchSize = defaultValues.lobPrefetchSize;
93-
94-
console.log("at last, fetchAsString value", oracledb.fetchAsString);
95-
console.log("at last, type of fetchAsString", typeof oracledb.fetchAsString);
9689
})
9790

9891
it('58.1.1 poolMin', function() {
@@ -301,7 +294,17 @@ describe.skip('58. properties.js', function() {
301294
});
302295
})
303296

304-
it('58.3.1 stmtCacheSize', function() {
297+
it('58.3.1 Connection object intial toString values', function() {
298+
connection.should.be.an.Object;
299+
300+
should.equal(connection.action, null);
301+
should.equal(connection.module, null);
302+
should.equal(connection.clientId, null);
303+
304+
(connection.stmtCacheSize).should.be.a.Number.and.be.above(0);
305+
})
306+
307+
it('58.3.2 stmtCacheSize', function() {
305308
var t = connection.stmtCacheSize;
306309
t.should.be.a.Number;
307310

@@ -313,7 +316,7 @@ describe.skip('58. properties.js', function() {
313316
}
314317
})
315318

316-
it('58.3.2 clientId', function() {
319+
it('58.3.3 clientId', function() {
317320

318321
try {
319322
var t = connection.clientId;
@@ -332,7 +335,7 @@ describe.skip('58. properties.js', function() {
332335
connection.clientId = "103.3";
333336
})
334337

335-
it('58.3.3 action', function() {
338+
it('58.3.4 action', function() {
336339

337340
try {
338341
var t = connection.action;
@@ -351,7 +354,7 @@ describe.skip('58. properties.js', function() {
351354
connection.action = "103.3 action";
352355
})
353356

354-
it('58.3.4 module', function() {
357+
it('58.3.5 module', function() {
355358

356359
try {
357360
var t = connection.module;

0 commit comments

Comments
 (0)