@@ -36,6 +36,7 @@ const assert = require('assert');
36
36
const fs = require ( 'fs' ) ;
37
37
const dbConfig = require ( './dbconfig.js' ) ;
38
38
const random = require ( './random.js' ) ;
39
+ const testsUtil = require ( './testsUtil.js' ) ;
39
40
40
41
describe ( '75. clobPlsqlBindAsString_bindout.js' , function ( ) {
41
42
@@ -162,13 +163,17 @@ describe('75. clobPlsqlBindAsString_bindout.js', function() {
162
163
"END nodb_clobs_out_741; " ;
163
164
const sqlRun = "BEGIN nodb_clobs_out_741 (:i, :c); END;" ;
164
165
const proc_drop = "DROP PROCEDURE nodb_clobs_out_741" ;
166
+ let sysDBAConn ;
165
167
166
168
before ( async function ( ) {
167
169
await connection . execute ( proc ) ;
168
170
} ) ;
169
171
170
172
after ( async function ( ) {
171
173
await connection . execute ( proc_drop ) ;
174
+ if ( sysDBAConn ) {
175
+ await sysDBAConn . close ( ) ;
176
+ }
172
177
} ) ;
173
178
174
179
it ( '75.1.1 works with EMPTY_LOB' , async function ( ) {
@@ -546,6 +551,51 @@ describe('75. clobPlsqlBindAsString_bindout.js', function() {
546
551
) ;
547
552
} ) ; // 75.1.28
548
553
554
+ it ( '75.1.29 Verify Cursor leak is not there for Bind Error' , async function ( ) {
555
+ if ( ! dbConfig . test . DBA_PRIVILEGE ) {
556
+ this . skip ( ) ;
557
+ }
558
+ const len = 32769 ;
559
+ const sequence = insertID ++ ;
560
+ const specialStr = "75.1.24.1" ;
561
+ const clobStr = random . getRandomString ( len , specialStr ) ;
562
+ const bindVar = {
563
+ i : { val : sequence , type : oracledb . NUMBER , dir : oracledb . BIND_IN } ,
564
+ c : { type : oracledb . STRING , dir : oracledb . BIND_OUT , maxSize : len - 1 }
565
+ } ;
566
+ await insertClobWithString ( sequence , clobStr ) ;
567
+
568
+ // Remove the sqlRun statement from cache before checking leak.
569
+ // It will also let server open any internal cursors for this statement
570
+ // and hence the actual cursor count for this statement can be verified
571
+ // after running in loop below.
572
+ await assert . rejects (
573
+ async ( ) => await connection . execute ( sqlRun , bindVar , { keepInStmtCache : false } ) ,
574
+ / N J S - 0 1 6 : /
575
+ ) ;
576
+
577
+ const sid = await testsUtil . getSid ( connection ) ;
578
+ const dbaConfig = {
579
+ user : dbConfig . test . DBA_user ,
580
+ password : dbConfig . test . DBA_password ,
581
+ connectionString : dbConfig . connectString ,
582
+ privilege : oracledb . SYSDBA
583
+ } ;
584
+ sysDBAConn = await oracledb . getConnection ( dbaConfig ) ;
585
+ const openCount = await testsUtil . getOpenCursorCount ( sysDBAConn , sid ) ;
586
+
587
+ // Running in loop should not result in opening more than 1 cursor
588
+ // additionally on server.
589
+ for ( let i = 0 ; i < 15 ; i ++ ) {
590
+ await assert . rejects (
591
+ async ( ) => await connection . execute ( sqlRun , bindVar ) ,
592
+ / N J S - 0 1 6 : /
593
+ ) ;
594
+ }
595
+ const newOpenCount = await testsUtil . getOpenCursorCount ( sysDBAConn , sid ) ;
596
+ assert . strictEqual ( newOpenCount - openCount , 1 ) ;
597
+ } ) ; // 75.1.29
598
+
549
599
} ) ; // 75.1
550
600
551
601
describe ( '75.2 CLOB, PLSQL, BIND_OUT to VARCHAR2' , function ( ) {
0 commit comments