node-firebird 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/lib/index.d.ts +2 -2
- package/lib/index.js +44 -69
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -230,7 +230,7 @@ Firebird.attach(options, (err, db) => {
|
|
|
230
230
|
if (err)
|
|
231
231
|
throw err;
|
|
232
232
|
|
|
233
|
-
db.transaction(Firebird.
|
|
233
|
+
db.transaction(Firebird.ISOLATION_READ_COMMITTED, (err, transaction) => {
|
|
234
234
|
if (err) {
|
|
235
235
|
throw err;
|
|
236
236
|
}
|
|
@@ -318,10 +318,10 @@ Firebird.attach(options, function(err, db) {
|
|
|
318
318
|
__Transaction types:__
|
|
319
319
|
|
|
320
320
|
- `Firebird.ISOLATION_READ_UNCOMMITTED`
|
|
321
|
-
- `Firebird.
|
|
321
|
+
- `Firebird.ISOLATION_READ_COMMITTED`
|
|
322
322
|
- `Firebird.ISOLATION_REPEATABLE_READ`
|
|
323
323
|
- `Firebird.ISOLATION_SERIALIZABLE`
|
|
324
|
-
- `Firebird.
|
|
324
|
+
- `Firebird.ISOLATION_READ_COMMITTED_READ_ONLY`
|
|
325
325
|
|
|
326
326
|
```js
|
|
327
327
|
Firebird.attach(options, function(err, db) {
|
|
@@ -330,7 +330,7 @@ Firebird.attach(options, function(err, db) {
|
|
|
330
330
|
throw err;
|
|
331
331
|
|
|
332
332
|
// db = DATABASE
|
|
333
|
-
db.transaction(Firebird.
|
|
333
|
+
db.transaction(Firebird.ISOLATION_READ_COMMITTED, function(err, transaction) {
|
|
334
334
|
transaction.query('INSERT INTO users VALUE(?,?)', [1, 'Janko'], function(err, result) {
|
|
335
335
|
|
|
336
336
|
if (err) {
|
package/lib/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ declare module 'node-firebird' {
|
|
|
19
19
|
/** A transaction sees changes done by uncommitted transactions. */
|
|
20
20
|
export const ISOLATION_READ_UNCOMMITTED: number[];
|
|
21
21
|
/** A transaction sees only data committed before the statement has been executed. */
|
|
22
|
-
export const
|
|
22
|
+
export const ISOLATION_READ_COMMITTED: number[];
|
|
23
23
|
/** A transaction sees during its lifetime only data committed before the transaction has been started. */
|
|
24
24
|
export const ISOLATION_REPEATABLE_READ: number[];
|
|
25
25
|
/**
|
|
@@ -27,7 +27,7 @@ declare module 'node-firebird' {
|
|
|
27
27
|
* Data accessed in the context of a serializable transaction cannot be accessed by any other transaction.
|
|
28
28
|
*/
|
|
29
29
|
export const ISOLATION_SERIALIZABLE: number[];
|
|
30
|
-
export const
|
|
30
|
+
export const ISOLATION_READ_COMMITTED_READ_ONLY: number[];
|
|
31
31
|
|
|
32
32
|
export type Isolation = number[];
|
|
33
33
|
|
package/lib/index.js
CHANGED
|
@@ -810,10 +810,10 @@ const DESCRIBE = [
|
|
|
810
810
|
|
|
811
811
|
const
|
|
812
812
|
ISOLATION_READ_UNCOMMITTED = [isc_tpb_version3, isc_tpb_write, isc_tpb_wait, isc_tpb_read_committed, isc_tpb_rec_version],
|
|
813
|
-
|
|
813
|
+
ISOLATION_READ_COMMITTED = [isc_tpb_version3, isc_tpb_write, isc_tpb_wait, isc_tpb_read_committed, isc_tpb_no_rec_version],
|
|
814
814
|
ISOLATION_REPEATABLE_READ = [isc_tpb_version3, isc_tpb_write, isc_tpb_wait, isc_tpb_concurrency],
|
|
815
815
|
ISOLATION_SERIALIZABLE = [isc_tpb_version3, isc_tpb_write, isc_tpb_wait, isc_tpb_consistency],
|
|
816
|
-
|
|
816
|
+
ISOLATION_READ_COMMITTED_READ_ONLY = [isc_tpb_version3, isc_tpb_read, isc_tpb_wait, isc_tpb_read_committed, isc_tpb_no_rec_version];
|
|
817
817
|
|
|
818
818
|
const
|
|
819
819
|
DEFAULT_HOST = '127.0.0.1',
|
|
@@ -845,10 +845,10 @@ exports.WIRE_CRYPT_DISABLE = WIRE_CRYPT_DISABLE;
|
|
|
845
845
|
exports.WIRE_CRYPT_ENABLE = WIRE_CRYPT_ENABLE;
|
|
846
846
|
|
|
847
847
|
exports.ISOLATION_READ_UNCOMMITTED = ISOLATION_READ_UNCOMMITTED;
|
|
848
|
-
exports.
|
|
848
|
+
exports.ISOLATION_READ_COMMITTED = ISOLATION_READ_COMMITTED;
|
|
849
849
|
exports.ISOLATION_REPEATABLE_READ = ISOLATION_REPEATABLE_READ;
|
|
850
850
|
exports.ISOLATION_SERIALIZABLE = ISOLATION_SERIALIZABLE;
|
|
851
|
-
exports.
|
|
851
|
+
exports.ISOLATION_READ_COMMITTED_READ_ONLY = ISOLATION_READ_COMMITTED_READ_ONLY;
|
|
852
852
|
|
|
853
853
|
if (!String.prototype.padLeft) {
|
|
854
854
|
String.prototype.padLeft = function(max, c) {
|
|
@@ -3230,81 +3230,60 @@ function decodeResponse(data, callback, cnx, lowercase_keys, cb) {
|
|
|
3230
3230
|
data.frows = data.frows || [];
|
|
3231
3231
|
|
|
3232
3232
|
if (custom.asObject && !data.fcols) {
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3233
|
+
if (lowercase_keys) {
|
|
3234
|
+
data.fcols = output.map((column) => column.alias.toLowerCase());
|
|
3235
|
+
} else {
|
|
3236
|
+
data.fcols = output.map((column) => column.alias);
|
|
3236
3237
|
}
|
|
3237
3238
|
}
|
|
3238
3239
|
|
|
3239
3240
|
const arrBlob = [];
|
|
3241
|
+
const lowerV13 = statement.connection.accept.protocolVersion < PROTOCOL_VERSION13;
|
|
3240
3242
|
|
|
3241
3243
|
while (data.fcount && (data.fstatus !== 100)) {
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
} else {
|
|
3258
|
-
value = fetch_blob_async(statement, value, key, row);
|
|
3259
|
-
}
|
|
3260
|
-
}
|
|
3261
|
-
data.frow[key] = value;
|
|
3262
|
-
} catch (e) {
|
|
3263
|
-
// uncomplete packet read
|
|
3264
|
-
data.pos = _xdrpos;
|
|
3265
|
-
data.r = r;
|
|
3266
|
-
return cb(new Error("Packet is not complete"));
|
|
3244
|
+
let nullBitSet;
|
|
3245
|
+
if (!lowerV13) {
|
|
3246
|
+
const nullBitsLen = Math.floor((output.length + 7) / 8);
|
|
3247
|
+
nullBitSet = new BitSet(data.readBuffer(nullBitsLen, false));
|
|
3248
|
+
data.readBuffer((4 - nullBitsLen) & 3, false); // Skip padding
|
|
3249
|
+
}
|
|
3250
|
+
|
|
3251
|
+
for (length = output.length; data.fcolumn < length; data.fcolumn++) {
|
|
3252
|
+
item = output[data.fcolumn];
|
|
3253
|
+
|
|
3254
|
+
if (!lowerV13 && nullBitSet.get(data.fcolumn)) {
|
|
3255
|
+
if (custom.asObject) {
|
|
3256
|
+
data.frow[data.fcols[data.fcolumn]] = null;
|
|
3257
|
+
} else {
|
|
3258
|
+
data.frow[data.fcolumn] = null;
|
|
3267
3259
|
}
|
|
3268
3260
|
|
|
3261
|
+
continue;
|
|
3269
3262
|
}
|
|
3270
|
-
} else {
|
|
3271
|
-
var nullBitsLen = Math.floor((output.length + 7) / 8);
|
|
3272
|
-
var nullBitSet = new BitSet(data.readBuffer(nullBitsLen, false));
|
|
3273
|
-
data.readBuffer((4 - nullBitsLen) & 3, false); // Skip padding
|
|
3274
3263
|
|
|
3275
|
-
|
|
3276
|
-
|
|
3264
|
+
try {
|
|
3265
|
+
_xdrpos = data.pos;
|
|
3266
|
+
const key = custom.asObject ? data.fcols[data.fcolumn] : data.fcolumn;
|
|
3267
|
+
const row = data.frows.length;
|
|
3268
|
+
let value = item.decode(data, lowerV13);
|
|
3277
3269
|
|
|
3278
|
-
if (
|
|
3279
|
-
if (
|
|
3280
|
-
|
|
3270
|
+
if (item.type === SQL_BLOB && value !== null) {
|
|
3271
|
+
if (item.subType === isc_blob_text && cnx.options.blobAsText) {
|
|
3272
|
+
value = fetch_blob_async_transaction(statement, value, key, row);
|
|
3273
|
+
arrBlob.push(value);
|
|
3281
3274
|
} else {
|
|
3282
|
-
|
|
3275
|
+
value = fetch_blob_async(statement, value, key, row);
|
|
3283
3276
|
}
|
|
3284
|
-
|
|
3285
|
-
continue;
|
|
3286
3277
|
}
|
|
3287
3278
|
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
value = fetch_blob_async_transaction(statement, value, key, data);
|
|
3295
|
-
arrBlob.push(value);
|
|
3296
|
-
} else {
|
|
3297
|
-
value = fetch_blob_async(statement, value, key);
|
|
3298
|
-
}
|
|
3299
|
-
}
|
|
3300
|
-
data.frow[key] = value;
|
|
3301
|
-
} catch (e) {
|
|
3302
|
-
// uncomplete packet read
|
|
3303
|
-
data.pos = _xdrpos;
|
|
3304
|
-
data.r = r;
|
|
3305
|
-
return cb(new Error("Packet is not complete"));
|
|
3306
|
-
}
|
|
3279
|
+
data.frow[key] = value;
|
|
3280
|
+
} catch (e) {
|
|
3281
|
+
// uncomplete packet read
|
|
3282
|
+
data.pos = _xdrpos;
|
|
3283
|
+
data.r = r;
|
|
3284
|
+
return cb(new Error('Packet is not complete'));
|
|
3307
3285
|
}
|
|
3286
|
+
|
|
3308
3287
|
}
|
|
3309
3288
|
|
|
3310
3289
|
data.fcolumn = 0;
|
|
@@ -4466,12 +4445,8 @@ Connection.prototype.sendExecute = function (op, statement, transaction, callbac
|
|
|
4466
4445
|
this._queueEvent(callback);
|
|
4467
4446
|
}
|
|
4468
4447
|
|
|
4469
|
-
function fetch_blob_async_transaction(statement, id,
|
|
4470
|
-
const infoValue = {
|
|
4471
|
-
row,
|
|
4472
|
-
column: name,
|
|
4473
|
-
value: ''
|
|
4474
|
-
};
|
|
4448
|
+
function fetch_blob_async_transaction(statement, id, column, row) {
|
|
4449
|
+
const infoValue = { row, column, value: '' };
|
|
4475
4450
|
|
|
4476
4451
|
return (transactionArg) => {
|
|
4477
4452
|
const singleTransaction = transactionArg === undefined;
|