Skip to content

Commit c41ed21

Browse files
committed
Fix tpcRecover to work with Thick mode
1 parent 0fac480 commit c41ed21

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

doc/src/release_notes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ Thin Mode Changes
2929
provided for `Issue #1565 <https://github.com/oracle/node-oracledb/issues/
3030
1565>`__.
3131

32+
Thick Mode Changes
33+
+++++++++++++++++++
34+
35+
#) Fixed bug that causes Two-Phase Commit `tpcRecover` execution to fail.
36+
3237
node-oracledb `v6.5.1 <https://github.com/oracle/node-oracledb/compare/v6.5.0...v6.5.1>`__ (23 May 2024)
3338
---------------------------------------------------------------------------------------------------------
3439

lib/connection.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1570,6 +1570,8 @@ class Connection extends EventEmitter {
15701570
// NOTE: breakExecution() should not be serialized
15711571
Connection.prototype.break =
15721572
nodbUtil.callbackify(Connection.prototype.breakExecution);
1573+
Connection.prototype.tpcRecover =
1574+
nodbUtil.callbackify(Connection.prototype.tpcRecover);
15731575
nodbUtil.wrapFns(Connection.prototype,
15741576
"changePassword",
15751577
"close",
@@ -1590,7 +1592,6 @@ nodbUtil.wrapFns(Connection.prototype,
15901592
"tpcEnd",
15911593
"tpcForget",
15921594
"tpcPrepare",
1593-
"tpcRecover",
15941595
"tpcRollback",
15951596
"unsubscribe");
15961597

test/tpc.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ describe('259. tpc.js', function() {
6767

6868
describe('259.2 TPC Functions', function() {
6969
let conn = null;
70+
let dbaConn = null;
7071
const sql = `BEGIN
7172
DECLARE
7273
e_table_missing EXCEPTION;
@@ -84,13 +85,24 @@ describe('259. tpc.js', function() {
8485
return this.skip();
8586
conn = await oracledb.getConnection(dbConfig);
8687
await conn.execute(sql);
88+
89+
const dbaCredential = {
90+
user: dbConfig.test.DBA_user,
91+
password: dbConfig.test.DBA_password,
92+
connectString: dbConfig.connectString,
93+
privilege: oracledb.SYSDBA,
94+
};
95+
dbaConn = await oracledb.getConnection(dbaCredential);
8796
});
8897

8998
after(async function() {
9099
if (conn) {
91100
conn.execute(`DROP TABLE TBL_259_2 PURGE`);
92101
await conn.close();
93102
}
103+
if (dbaConn) {
104+
await dbaConn.close();
105+
}
94106
});
95107

96108
it('259.2.1 test tpcBegin, tpcPrepare, tpcRollback', async function() {
@@ -265,6 +277,25 @@ describe('259. tpc.js', function() {
265277
);
266278
await conn.tpcRollback(xid);
267279
});
280+
281+
it('259.2.10 tpcRecover', async function() {
282+
if (!dbConfig.test.DBA_PRIVILEGE)
283+
this.skip();
284+
285+
const xid = {
286+
formatId: 5000,
287+
globalTransactionId: "txn5000",
288+
branchQualifier: "branchId"
289+
};
290+
291+
await conn.tpcBegin(xid, oracledb.TPC_BEGIN_NEW, 60);
292+
await conn.tpcPrepare(xid);
293+
const promise = dbaConn.tpcRecover();
294+
const res = await Promise.resolve(promise);
295+
assert.strictEqual(res[0].formatId, 5000);
296+
assert.strictEqual(res[0].globalTransactionId, "txn5000");
297+
assert.strictEqual(res[0].branchQualifier, "branchId");
298+
});
268299
});
269300

270301
describe('259.3 TPC Functions with no default values', function() {

0 commit comments

Comments
 (0)