mssql 12.7.8 → 12.7.10
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 +10 -2
- package/lib/base/prepared-statement.js +9 -1
- package/lib/base/transaction.js +10 -2
- package/lib/msnodesqlv8/request.js +10 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1382,7 +1382,9 @@ transaction.begin(err => {
|
|
|
1382
1382
|
```
|
|
1383
1383
|
|
|
1384
1384
|
__Errors__
|
|
1385
|
+
- ENOCONN (`TransactionError`) - No connection is specified for that transaction.
|
|
1385
1386
|
- ENOTOPEN (`ConnectionError`) - Connection not yet open.
|
|
1387
|
+
- ECONNCLOSED (`ConnectionError`) - Connection is closed.
|
|
1386
1388
|
- EALREADYBEGUN (`TransactionError`) - Transaction has already begun.
|
|
1387
1389
|
|
|
1388
1390
|
If the transaction fails to begin once it has a connection, the error is a `TransactionError`, with the error it comes from as its `originalError`. The connection goes back to the pool, and the transaction can be begun again. A connection that may have sent the request to begin the transaction is closed rather than lent out again, as the server may have begun the transaction even though the request failed (for example, when it timed out).
|
|
@@ -1544,9 +1546,11 @@ ps.prepare('select @param as value', err => {
|
|
|
1544
1546
|
```
|
|
1545
1547
|
|
|
1546
1548
|
__Errors__
|
|
1547
|
-
-
|
|
1549
|
+
- ENOCONN (`PreparedStatementError`) - No connection is specified for that prepared statement.
|
|
1550
|
+
- ECONNCLOSED (`ConnectionError`) - Connection is closed.
|
|
1548
1551
|
- EALREADYPREPARED (`PreparedStatementError`) - Statement is already prepared.
|
|
1549
1552
|
- ENOTBEGUN (`TransactionError`) - Transaction has not begun.
|
|
1553
|
+
- EREQINPROG (`TransactionError`) - Can't acquire connection for the request. There is another request in progress.
|
|
1550
1554
|
|
|
1551
1555
|
---------------------------------------
|
|
1552
1556
|
|
|
@@ -1623,6 +1627,7 @@ __Errors__
|
|
|
1623
1627
|
- EREQUEST (`RequestError`) - *Message from SQL Server*
|
|
1624
1628
|
- EPARAM (`RequestError`) - A parameter value is not valid for its type.
|
|
1625
1629
|
- ECANCEL (`RequestError`) - Cancelled.
|
|
1630
|
+
- EREQINPROG (`TransactionError`) - Can't acquire connection for the request. There is another request in progress.
|
|
1626
1631
|
|
|
1627
1632
|
---------------------------------------
|
|
1628
1633
|
|
|
@@ -1651,6 +1656,7 @@ ps.prepare('select @param as value', err => {
|
|
|
1651
1656
|
|
|
1652
1657
|
__Errors__
|
|
1653
1658
|
- ENOTPREPARED (`PreparedStatementError`) - Statement is not prepared.
|
|
1659
|
+
- EREQINPROG (`TransactionError`) - Can't unprepare the statement. There is a request in progress.
|
|
1654
1660
|
|
|
1655
1661
|
## CLI
|
|
1656
1662
|
|
|
@@ -2219,8 +2225,9 @@ Name | Code | Message
|
|
|
2219
2225
|
`ConnectionError` | ECONNCLOSED | Connection is closed.
|
|
2220
2226
|
`TransactionError` | ENOTBEGUN | Transaction has not begun.
|
|
2221
2227
|
`TransactionError` | EALREADYBEGUN | Transaction has already begun.
|
|
2222
|
-
`TransactionError` | EREQINPROG | Can't commit/rollback transaction or acquire connection for the request. There is a request in progress.
|
|
2228
|
+
`TransactionError` | EREQINPROG | Can't commit/rollback transaction, unprepare the statement or acquire connection for the request. There is a request in progress.
|
|
2223
2229
|
`TransactionError` | EABORT | Transaction has been aborted.
|
|
2230
|
+
`TransactionError` | ENOCONN | No connection is specified for that transaction.
|
|
2224
2231
|
`RequestError` | EREQUEST | Message from SQL Server. Error object contains additional details.
|
|
2225
2232
|
`RequestError` | ECANCEL | Cancelled.
|
|
2226
2233
|
`RequestError` | ETIMEOUT | Request timeout.
|
|
@@ -2231,6 +2238,7 @@ Name | Code | Message
|
|
|
2231
2238
|
`PreparedStatementError` | EINJECT | Parameter name is not a valid identifier.
|
|
2232
2239
|
`PreparedStatementError` | EALREADYPREPARED | Statement is already prepared.
|
|
2233
2240
|
`PreparedStatementError` | ENOTPREPARED | Statement is not prepared.
|
|
2241
|
+
`PreparedStatementError` | ENOCONN | No connection is specified for that prepared statement.
|
|
2234
2242
|
|
|
2235
2243
|
### Detailed SQL Errors
|
|
2236
2244
|
|
|
@@ -4,7 +4,7 @@ const debug = require('debug')('mssql:base')
|
|
|
4
4
|
const { EventEmitter } = require('node:events')
|
|
5
5
|
const { IDS, objectHasProperty, getPoolId, isValidParameterName } = require('../utils')
|
|
6
6
|
const globalConnection = require('../global-connection')
|
|
7
|
-
const { TransactionError, PreparedStatementError } = require('../error')
|
|
7
|
+
const { ConnectionError, TransactionError, PreparedStatementError } = require('../error')
|
|
8
8
|
const shared = require('../shared')
|
|
9
9
|
const { TYPES, declare } = require('../datatypes')
|
|
10
10
|
const { CHANNELS, tracePromise, traceCallback, publish } = require('../diagnostics')
|
|
@@ -244,6 +244,14 @@ class PreparedStatement extends EventEmitter {
|
|
|
244
244
|
|
|
245
245
|
this.statement = statement || this.statement
|
|
246
246
|
|
|
247
|
+
if (!this.parent) {
|
|
248
|
+
return setImmediate(callback, new PreparedStatementError('No connection is specified for that prepared statement.', 'ENOCONN'))
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (!this.parent.connected) {
|
|
252
|
+
return setImmediate(callback, new ConnectionError('Connection is closed.', 'ECONNCLOSED'))
|
|
253
|
+
}
|
|
254
|
+
|
|
247
255
|
this.parent.acquire(this, (err, connection, config) => {
|
|
248
256
|
if (err) return callback(err)
|
|
249
257
|
|
package/lib/base/transaction.js
CHANGED
|
@@ -4,7 +4,7 @@ const debug = require('debug')('mssql:base')
|
|
|
4
4
|
const { EventEmitter } = require('node:events')
|
|
5
5
|
const { IDS, getPoolId } = require('../utils')
|
|
6
6
|
const globalConnection = require('../global-connection')
|
|
7
|
-
const { TransactionError } = require('../error')
|
|
7
|
+
const { ConnectionError, TransactionError } = require('../error')
|
|
8
8
|
const shared = require('../shared')
|
|
9
9
|
const ISOLATION_LEVEL = require('../isolationlevel')
|
|
10
10
|
const { CHANNELS, publish } = require('../diagnostics')
|
|
@@ -52,7 +52,7 @@ class Transaction extends EventEmitter {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
get connected () {
|
|
55
|
-
return this.parent.connected
|
|
55
|
+
return this.parent ? this.parent.connected : false
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/**
|
|
@@ -164,6 +164,14 @@ class Transaction extends EventEmitter {
|
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
if (!this.parent) {
|
|
168
|
+
return setImmediate(callback, new TransactionError('No connection is specified for that transaction.', 'ENOCONN'))
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (!this.parent.connected) {
|
|
172
|
+
return setImmediate(callback, new ConnectionError('Connection is closed.', 'ECONNCLOSED'))
|
|
173
|
+
}
|
|
174
|
+
|
|
167
175
|
setImmediate(callback)
|
|
168
176
|
}
|
|
169
177
|
|
|
@@ -248,10 +248,14 @@ class Request extends BaseRequest {
|
|
|
248
248
|
|
|
249
249
|
this.parent.release(connection)
|
|
250
250
|
|
|
251
|
+
// msnodesqlv8's table manager calls `done` from within promise chains, which would
|
|
252
|
+
// catch what the caller's callback throws and pass it back here as the driver's
|
|
253
|
+
// error, to be dropped. The caller is called back outside them, so that what its
|
|
254
|
+
// callback throws reaches the process as it would from any other callback.
|
|
251
255
|
if (err) {
|
|
252
|
-
callback
|
|
256
|
+
process.nextTick(callback, err)
|
|
253
257
|
} else {
|
|
254
|
-
callback
|
|
258
|
+
process.nextTick(callback, null, table.rows.length)
|
|
255
259
|
}
|
|
256
260
|
}
|
|
257
261
|
|
|
@@ -697,6 +701,10 @@ class Request extends BaseRequest {
|
|
|
697
701
|
cancelHeld = false
|
|
698
702
|
cancel()
|
|
699
703
|
}
|
|
704
|
+
// a stream resumed meanwhile left the query held back. msnodesqlv8 fetches as soon as
|
|
705
|
+
// it is resumed, and again once 'meta' is handled, so the query is resumed a tick
|
|
706
|
+
// later, once it has stopped at the result set
|
|
707
|
+
if (!this.paused && driverPaused && !cancelRequested) setImmediate(this._resumeStream)
|
|
700
708
|
}
|
|
701
709
|
|
|
702
710
|
if (row) {
|