Skip to content

Commit 39701c9

Browse files
committed
Treat OCI_SUCCESS_WITH_INFO as success (PR #250)
1 parent 07fa200 commit 39701c9

File tree

4 files changed

+106
-11
lines changed

4 files changed

+106
-11
lines changed

src/dpi/src/dpiUtils.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@
5858

5959
static void ociCallCommon(sword rc, void *handle, ub4 errType)
6060
{
61-
if (!rc)
61+
// OCI_SUCCESS_WITH_INFO - warnings are reported in some cases.
62+
// Treat these warnings as success as the OCI call succeeded and
63+
// ignore the error message
64+
if ( (rc == OCI_SUCCESS) || (rc == OCI_SUCCESS_WITH_INFO ) )
6265
return;
6366

6467
if (rc == OCI_INVALID_HANDLE)

src/njs/src/njsConnection.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2615,24 +2615,21 @@ NAN_METHOD(Connection::Release)
26152615
switch ( connStat )
26162616
{
26172617
case CONN_NOT_BUSY:
2618-
break; // Nothing to do in this case
2618+
connection->isValid_ = false;
2619+
releaseBaton->dpiconn = connection->dpiconn_;
2620+
break;
26192621
case CONN_BUSY_LOB:
26202622
releaseBaton->error = NJSMessages::getErrorMsg( errBusyConnLOB );
2621-
goto exitRelease;
2623+
break;
26222624
case CONN_BUSY_RS:
26232625
releaseBaton->error = NJSMessages::getErrorMsg( errBusyConnRS );
2624-
goto exitRelease;
2626+
break;
26252627
case CONN_BUSY_DB:
26262628
releaseBaton->error = NJSMessages::getErrorMsg( errBusyConnDB );
2627-
goto exitRelease;
2628-
2629-
default:
26302629
break;
26312630
}
26322631

2633-
connection->isValid_ = false;
2634-
releaseBaton->dpiconn = connection->dpiconn_;
2635-
exitRelease:
2632+
exitRelease:
26362633
releaseBaton->req.data = (void*) releaseBaton;
26372634

26382635
int status = uv_queue_work(uv_default_loop(), &releaseBaton->req,

src/njs/src/njsMessages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static const char *errMsg[] =
6969
" in progress",
7070
"NJS-032: Connection cannot be released because a database call is in"
7171
" progress",
72-
"NJS-033: An internal error occurred.[%s][%s]",
72+
"NJS-033: An internal error occurred. [%s][%s]",
7373

7474
};
7575

test/warning.js

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */
2+
3+
/******************************************************************************
4+
*
5+
* You may not use the identified files except in compliance with the Apache
6+
* License, Version 2.0 (the "License.")
7+
*
8+
* You may obtain a copy of the License at
9+
* http://www.apache.org/licenses/LICENSE-2.0.
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
*
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* The node-oracledb test suite uses 'mocha', 'should' and 'async'.
19+
* See LICENSE.md for relevant licenses.
20+
*
21+
* NAME
22+
* 64. warning.js
23+
*
24+
* DESCRIPTION
25+
* Testing to make sure OCI_SUCCESS_WITH_INFO is treated as OCI_SUCCESS
26+
* Creating a PLSQL procedure with a SELECT query from a non-existing
27+
* table will result in warnings (OCI_SUCCESS_WITH_INFO).
28+
*
29+
* NUMBERING RULE
30+
* Test numbers follow this numbering rule:
31+
* 1 - 20 are reserved for basic functional tests
32+
* 21 - 50 are reserved for data type supporting tests
33+
* 51 onwards are for other tests
34+
*
35+
*****************************************************************************/
36+
"use strict";
37+
38+
var oracledb = require('oracledb');
39+
var fs = require('fs');
40+
var should = require('should');
41+
var async = require('async');
42+
var dbConfig = require('./dbConfig.js');
43+
var assist = require('./dataTypeAssist.js');
44+
45+
describe('64. warning.js', function() {
46+
47+
if(dbConfig.externalAuth){
48+
var credential = { externalAuth: true, connectString: dbConfig.connectString };
49+
} else {
50+
var credential = dbConfig;
51+
}
52+
53+
describe('64.1 Success With Info', function() {
54+
var connection = null;
55+
56+
before('get one connection', function(done) {
57+
oracledb.getConnection(credential, function(err, conn) {
58+
should.not.exist(err);
59+
connection = conn;
60+
done();
61+
});
62+
})
63+
64+
after('release connection', function(done) {
65+
connection.release( function(err) {
66+
should.not.exist(err);
67+
done();
68+
});
69+
})
70+
71+
it('64.1 Execute SQL Statement to create PLSQL procedure with warnings',
72+
function(done) {
73+
connection.should.be.an.Object;
74+
75+
connection.execute (
76+
"CREATE OR REPLACE PROCEDURE get_emp_rs_inout " +
77+
"(p_in IN NUMBER, p_out OUT SYS_REFCURSOR ) AS " +
78+
"BEGIN " +
79+
" OPEN p_out FOR SELECT * FROM oracledb_employees " +
80+
"END;",
81+
{
82+
},
83+
{
84+
},
85+
function ( err, result )
86+
{
87+
should.not.exist ( err );
88+
done();
89+
}
90+
);
91+
})
92+
}) // 64.1
93+
94+
95+
})

0 commit comments

Comments
 (0)