Skip to content

Commit b7741db

Browse files
committed
Merge ../working/jones-maintenance
2 parents 42dae45 + 7c93256 commit b7741db

File tree

5 files changed

+32
-8
lines changed

5 files changed

+32
-8
lines changed

database-jones/API-documentation/Session

+2-1
Original file line numberDiff line numberDiff line change
@@ -550,10 +550,11 @@ Error setPartitionKey(mapping, keys);
550550
* and will remain in effect until this session is closed or this method
551551
* is called again.
552552
* @param lockmode the LockMode: 'EXCLUSIVE', 'SHARED', or 'NONE'
553+
* @return an Error object or null if no error
553554
*
554555
* IMMEDIATE
555556
*/
556-
void setLockMode(lockmode);
557+
Error setLockMode(lockmode);
557558

558559

559560
/** listTables(database, callback)

database-jones/Adapter/api/Batch.js

-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ exports.Batch.prototype.execute = function() {
162162
};
163163

164164
exports.Batch.prototype.isBatch = function() {
165-
this.assertOpen();
166165
return true;
167166
};
168167

database-jones/Adapter/api/Session.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2012, 2016 Oracle and/or its affiliates. All rights
2+
Copyright (c) 2012, 2017 Oracle and/or its affiliates. All rights
33
reserved.
44
55
This program is free software; you can redistribute it and/or
@@ -149,7 +149,6 @@ exports.Session.prototype.createBatch = function() {
149149
};
150150

151151
exports.Session.prototype.isBatch = function() {
152-
this.assertOpen();
153152
return false;
154153
};
155154

@@ -158,7 +157,13 @@ exports.Session.prototype.isClosed = function() {
158157
return this.closed;
159158
};
160159

160+
161161
exports.Session.prototype.currentTransaction = function() {
162162
return this.tx;
163163
};
164164

165+
166+
/* setLockMode() immediate */
167+
exports.Session.prototype.setLockMode = function(lockMode) {
168+
return this.dbSession.setLockMode(lockMode);
169+
};

jones-ndb/impl/ndb/NdbOperation.js

+9
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,14 @@ function newScanOperation(tx, QueryTree, properties) {
10081008
}
10091009

10101010

1011+
function setLockMode(ndbSession, lockMode) {
1012+
if(doc.LockModes.indexOf(lockMode) !== -1) {
1013+
return new DBOperationError("Invalid Lock Mode");
1014+
}
1015+
ndbSession.lockMode = lockMode;
1016+
return null;
1017+
}
1018+
10111019
exports.DBOperation = DBOperation;
10121020
exports.DBOperationError = DBOperationError;
10131021
exports.newReadOperation = newReadOperation;
@@ -1021,3 +1029,4 @@ exports.completeExecutedOps = completeExecutedOps;
10211029
exports.getScanResults = getScanResults;
10221030
exports.prepareOperations = prepareOperations;
10231031
exports.getQueryResults = getQueryResults;
1032+
exports.setLockMode = setLockMode;

jones-ndb/impl/ndb/NdbSession.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights
2+
Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights
33
reserved.
44
55
This program is free software; you can redistribute it and/or
@@ -21,7 +21,7 @@
2121
"use strict";
2222

2323
var stats = {
24-
"created" : 0,
24+
"created" : 0,
2525
"seizeTransactionContext" : {
2626
"immediate" : 0 , "queued" : 0
2727
},
@@ -74,6 +74,7 @@ NdbSession = function(pool) {
7474
this.maxTxContexts = pool.properties.ndb_session_concurrency;
7575
this.openTxContexts = 0; // currently opened
7676
this.isOpenNdbSession = false;
77+
this.lockMode = "SHARED";
7778
};
7879

7980
/* fetch SessionImpl. Undocumented - private to NdbConnectionPool.
@@ -183,8 +184,8 @@ NdbSession.prototype.buildReadOperation = function(dbIndexHandler, keys,
183184
dbIndexHandler.tableHandler.dbTable.name,
184185
"using", dbIndexHandler.dbIndex.name);
185186
}
186-
var lockMode = "SHARED";
187-
var op = ndboperation.newReadOperation(tx, dbIndexHandler, keys, lockMode, isLoad);
187+
var op = ndboperation.newReadOperation(tx, dbIndexHandler, keys,
188+
this.lockMode, isLoad);
188189
op.userCallback = callback;
189190
return op;
190191
};
@@ -362,5 +363,14 @@ NdbSession.prototype.rollback = function (userCallback) {
362363
this.tx.rollback(userCallback);
363364
};
364365

366+
/* setLockMode(lockMode)
367+
IMMEDIATE
368+
369+
Set Lock Mode for subsequent read operations
370+
*/
371+
NdbSession.prototype.setLockMode = function (lockMode) {
372+
return ndboperation.setLockMode(this, lockMode);
373+
};
374+
365375

366376
exports.DBSession = NdbSession;

0 commit comments

Comments
 (0)