tedious 1.12.3 → 1.14.0

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.
Files changed (62) hide show
  1. package/README.md +1 -1
  2. package/appveyor.yml +9 -5
  3. package/benchmarks/README.md +33 -0
  4. package/benchmarks/common.js +82 -0
  5. package/benchmarks/index.js +34 -0
  6. package/benchmarks/query/many-result-rows.js +49 -0
  7. package/benchmarks/query/nvarchar-large.js +44 -0
  8. package/benchmarks/query/nvarchar-small.js +44 -0
  9. package/benchmarks/query/varbinary-4.js +42 -0
  10. package/benchmarks/query/varbinary-huge.js +46 -0
  11. package/benchmarks/query/varbinary-large.js +46 -0
  12. package/benchmarks/query/varbinary-small.js +42 -0
  13. package/benchmarks/token-parser/colmetadata-token.js +42 -0
  14. package/benchmarks/token-parser/done-token.js +42 -0
  15. package/benchmarks/token-parser/simple-tokens.js +366 -0
  16. package/lib/all-headers.js +9 -11
  17. package/lib/buffertools.js +17 -13
  18. package/lib/bulk-load.js +196 -169
  19. package/lib/collation.js +80 -2
  20. package/lib/connection.js +1086 -1060
  21. package/lib/data-type.js +450 -253
  22. package/lib/debug.js +57 -51
  23. package/lib/errors.js +40 -55
  24. package/lib/guid-parser.js +12 -36
  25. package/lib/instance-lookup.js +57 -54
  26. package/lib/library.js +3 -2
  27. package/lib/login7-payload.js +187 -180
  28. package/lib/message-io.js +169 -199
  29. package/lib/metadata-parser.js +169 -255
  30. package/lib/ntlm-payload.js +173 -160
  31. package/lib/packet.js +166 -152
  32. package/lib/prelogin-payload.js +170 -160
  33. package/lib/request.js +122 -122
  34. package/lib/rpcrequest-payload.js +64 -38
  35. package/lib/special-stored-procedure.js +3 -2
  36. package/lib/sqlbatch-payload.js +20 -16
  37. package/lib/stream-parser.js +116 -104
  38. package/lib/tds-versions.js +5 -8
  39. package/lib/tedious.js +8 -14
  40. package/lib/token/colmetadata-token-parser.js +79 -125
  41. package/lib/token/done-token-parser.js +47 -129
  42. package/lib/token/env-change-token-parser.js +90 -126
  43. package/lib/token/infoerror-token-parser.js +47 -125
  44. package/lib/token/loginack-token-parser.js +36 -74
  45. package/lib/token/nbcrow-token-parser.js +40 -64
  46. package/lib/token/order-token-parser.js +26 -43
  47. package/lib/token/returnstatus-token-parser.js +11 -23
  48. package/lib/token/returnvalue-token-parser.js +31 -54
  49. package/lib/token/row-token-parser.js +39 -52
  50. package/lib/token/sspi-token-parser.js +14 -32
  51. package/lib/token/stream-parser.js +424 -304
  52. package/lib/token/token-stream-parser.js +39 -34
  53. package/lib/token/token.js +3 -6
  54. package/lib/tracking-buffer/bigint.js +45 -48
  55. package/lib/tracking-buffer/readable-tracking-buffer.js +238 -223
  56. package/lib/tracking-buffer/tracking-buffer.js +3 -9
  57. package/lib/tracking-buffer/writable-tracking-buffer.js +272 -244
  58. package/lib/transaction.js +112 -102
  59. package/lib/value-parser.js +559 -1154
  60. package/package.json +10 -9
  61. package/benchmarks/benchmarks.coffee +0 -122
  62. package/benchmarks/query.coffee +0 -57
@@ -1,7 +1,10 @@
1
- // Generated by CoffeeScript 1.10.0
2
- var ReadableTrackingBuffer, convertLEBytesToString;
1
+ 'use strict';
3
2
 
4
- convertLEBytesToString = require('./bigint').convertLEBytesToString;
3
+ var _createClass = require('babel-runtime/helpers/create-class')['default'];
4
+
5
+ var _classCallCheck = require('babel-runtime/helpers/class-call-check')['default'];
6
+
7
+ var convertLEBytesToString = require('./bigint').convertLEBytesToString;
5
8
 
6
9
  /*
7
10
  A Buffer-like class that tracks position.
@@ -10,10 +13,12 @@ convertLEBytesToString = require('./bigint').convertLEBytesToString;
10
13
  When reading, if the read would pass the end of the buffer, an error object is thrown.
11
14
  */
12
15
 
13
- ReadableTrackingBuffer = (function () {
14
- function ReadableTrackingBuffer(buffer1, encoding1) {
15
- this.buffer = buffer1;
16
- this.encoding = encoding1;
16
+ module.exports = (function () {
17
+ function ReadableTrackingBuffer(buffer, encoding) {
18
+ _classCallCheck(this, ReadableTrackingBuffer);
19
+
20
+ this.buffer = buffer;
21
+ this.encoding = encoding;
17
22
  if (!this.buffer) {
18
23
  this.buffer = new Buffer(0);
19
24
  this.encoding = void 0;
@@ -22,222 +27,232 @@ ReadableTrackingBuffer = (function () {
22
27
  this.position = 0;
23
28
  }
24
29
 
25
- ReadableTrackingBuffer.prototype.add = function (buffer) {
26
- this.buffer = Buffer.concat([this.buffer.slice(this.position), buffer]);
27
- return this.position = 0;
28
- };
29
-
30
- ReadableTrackingBuffer.prototype.assertEnoughLeftFor = function (lengthRequired) {
31
- var available, e;
32
- this.previousPosition = this.position;
33
- available = this.buffer.length - this.position;
34
- if (available < lengthRequired) {
35
- e = new Error("required : " + lengthRequired + ", available : " + available);
36
- e.code = 'oob';
37
- throw e;
38
- }
39
- };
40
-
41
- ReadableTrackingBuffer.prototype.empty = function () {
42
- return this.position === this.buffer.length;
43
- };
44
-
45
- ReadableTrackingBuffer.prototype.rollback = function () {
46
- return this.position = this.previousPosition;
47
- };
48
-
49
- ReadableTrackingBuffer.prototype.readUInt8 = function () {
50
- var length, value;
51
- length = 1;
52
- this.assertEnoughLeftFor(length);
53
- this.position += length;
54
- return value = this.buffer.readUInt8(this.position - length);
55
- };
56
-
57
- ReadableTrackingBuffer.prototype.readUInt16LE = function () {
58
- var length;
59
- length = 2;
60
- this.assertEnoughLeftFor(length);
61
- this.position += length;
62
- return this.buffer.readUInt16LE(this.position - length);
63
- };
64
-
65
- ReadableTrackingBuffer.prototype.readUInt16BE = function () {
66
- var length;
67
- length = 2;
68
- this.assertEnoughLeftFor(length);
69
- this.position += length;
70
- return this.buffer.readUInt16BE(this.position - length);
71
- };
72
-
73
- ReadableTrackingBuffer.prototype.readUInt32LE = function () {
74
- var length;
75
- length = 4;
76
- this.assertEnoughLeftFor(length);
77
- this.position += length;
78
- return this.buffer.readUInt32LE(this.position - length);
79
- };
80
-
81
- ReadableTrackingBuffer.prototype.readUInt32BE = function () {
82
- var length;
83
- length = 4;
84
- this.assertEnoughLeftFor(length);
85
- this.position += length;
86
- return this.buffer.readUInt32BE(this.position - length);
87
- };
88
-
89
- ReadableTrackingBuffer.prototype.readInt8 = function () {
90
- var length, value;
91
- length = 1;
92
- this.assertEnoughLeftFor(length);
93
- this.position += length;
94
- return value = this.buffer.readInt8(this.position - length);
95
- };
96
-
97
- ReadableTrackingBuffer.prototype.readInt16LE = function () {
98
- var length;
99
- length = 2;
100
- this.assertEnoughLeftFor(length);
101
- this.position += length;
102
- return this.buffer.readInt16LE(this.position - length);
103
- };
104
-
105
- ReadableTrackingBuffer.prototype.readInt16BE = function () {
106
- var length;
107
- length = 2;
108
- this.assertEnoughLeftFor(length);
109
- this.position += length;
110
- return this.buffer.readInt16BE(this.position - length);
111
- };
112
-
113
- ReadableTrackingBuffer.prototype.readInt32LE = function () {
114
- var length;
115
- length = 4;
116
- this.assertEnoughLeftFor(length);
117
- this.position += length;
118
- return this.buffer.readInt32LE(this.position - length);
119
- };
120
-
121
- ReadableTrackingBuffer.prototype.readInt32BE = function () {
122
- var length;
123
- length = 4;
124
- this.assertEnoughLeftFor(length);
125
- this.position += length;
126
- return this.buffer.readInt32BE(this.position - length);
127
- };
128
-
129
- ReadableTrackingBuffer.prototype.readFloatLE = function () {
130
- var length;
131
- length = 4;
132
- this.assertEnoughLeftFor(length);
133
- this.position += length;
134
- return this.buffer.readFloatLE(this.position - length);
135
- };
136
-
137
- ReadableTrackingBuffer.prototype.readDoubleLE = function () {
138
- var length;
139
- length = 8;
140
- this.assertEnoughLeftFor(length);
141
- this.position += length;
142
- return this.buffer.readDoubleLE(this.position - length);
143
- };
144
-
145
- ReadableTrackingBuffer.prototype.readUInt24LE = function () {
146
- var length, val;
147
- length = 3;
148
- this.assertEnoughLeftFor(length);
149
- val |= this.buffer[this.position + 1] << 8;
150
- val |= this.buffer[this.position];
151
- val = val + (this.buffer[this.position + 2] << 16 >>> 0);
152
- this.position += length;
153
- return val;
154
- };
155
-
156
- ReadableTrackingBuffer.prototype.readUInt40LE = function () {
157
- var high, low;
158
- low = this.readBuffer(4).readUInt32LE(0);
159
- high = Buffer.concat([this.readBuffer(1), new Buffer([0x00, 0x00, 0x00])]).readUInt32LE(0);
160
- return low + 0x100000000 * high;
161
- };
162
-
163
- ReadableTrackingBuffer.prototype.readUInt64LE = function () {
164
- var high, low;
165
- low = this.readUInt32LE();
166
- high = this.readUInt32LE();
167
- if (high >= 2 << 53 - 32) {
168
- console.warn("Read UInt64LE > 53 bits : high=" + high + ", low=" + low);
169
- }
170
- return low + 0x100000000 * high;
171
- };
172
-
173
- ReadableTrackingBuffer.prototype.readUNumeric64LE = function () {
174
- var high, low;
175
- low = this.readUInt32LE();
176
- high = this.readUInt32LE();
177
- return low + 0x100000000 * high;
178
- };
179
-
180
- ReadableTrackingBuffer.prototype.readUNumeric96LE = function () {
181
- var dword1, dword2, dword3;
182
- dword1 = this.readUInt32LE();
183
- dword2 = this.readUInt32LE();
184
- dword3 = this.readUInt32LE();
185
- return dword1 + 0x100000000 * dword2 + 0x100000000 * 0x100000000 * dword3;
186
- };
187
-
188
- ReadableTrackingBuffer.prototype.readUNumeric128LE = function () {
189
- var dword1, dword2, dword3, dword4;
190
- dword1 = this.readUInt32LE();
191
- dword2 = this.readUInt32LE();
192
- dword3 = this.readUInt32LE();
193
- dword4 = this.readUInt32LE();
194
- return dword1 + 0x100000000 * dword2 + 0x100000000 * 0x100000000 * dword3 + 0x100000000 * 0x100000000 * 0x100000000 * dword4;
195
- };
196
-
197
- ReadableTrackingBuffer.prototype.readString = function (length, encoding) {
198
- encoding || (encoding = this.encoding);
199
- this.assertEnoughLeftFor(length);
200
- this.position += length;
201
- return this.buffer.toString(encoding, this.position - length, this.position);
202
- };
203
-
204
- ReadableTrackingBuffer.prototype.readBVarchar = function (encoding) {
205
- var length, multiplier;
206
- encoding || (encoding = this.encoding);
207
- multiplier = encoding === 'ucs2' ? 2 : 1;
208
- length = this.readUInt8() * multiplier;
209
- return this.readString(length, encoding);
210
- };
211
-
212
- ReadableTrackingBuffer.prototype.readUsVarchar = function (encoding) {
213
- var length, multiplier;
214
- encoding || (encoding = this.encoding);
215
- multiplier = encoding === 'ucs2' ? 2 : 1;
216
- length = this.readUInt16LE() * multiplier;
217
- return this.readString(length, encoding);
218
- };
219
-
220
- ReadableTrackingBuffer.prototype.readBuffer = function (length) {
221
- this.assertEnoughLeftFor(length);
222
- this.position += length;
223
- return this.buffer.slice(this.position - length, this.position);
224
- };
225
-
226
- ReadableTrackingBuffer.prototype.readArray = function (length) {
227
- return Array.prototype.slice.call(this.readBuffer(length), 0, length);
228
- };
229
-
230
- ReadableTrackingBuffer.prototype.readAsStringBigIntLE = function (length) {
231
- this.assertEnoughLeftFor(length);
232
- this.position += length;
233
- return convertLEBytesToString(this.buffer.slice(this.position - length, this.position));
234
- };
30
+ _createClass(ReadableTrackingBuffer, [{
31
+ key: 'add',
32
+ value: function add(buffer) {
33
+ this.buffer = Buffer.concat([this.buffer.slice(this.position), buffer]);
34
+ return this.position = 0;
35
+ }
36
+ }, {
37
+ key: 'assertEnoughLeftFor',
38
+ value: function assertEnoughLeftFor(lengthRequired) {
39
+ this.previousPosition = this.position;
40
+ var available = this.buffer.length - this.position;
41
+ if (available < lengthRequired) {
42
+ var e = new Error('required : ' + lengthRequired + ', available : ' + available);
43
+ e.code = 'oob';
44
+ throw e;
45
+ }
46
+ }
47
+ }, {
48
+ key: 'empty',
49
+ value: function empty() {
50
+ return this.position === this.buffer.length;
51
+ }
52
+ }, {
53
+ key: 'rollback',
54
+ value: function rollback() {
55
+ return this.position = this.previousPosition;
56
+ }
57
+ }, {
58
+ key: 'readUInt8',
59
+ value: function readUInt8() {
60
+ var length = 1;
61
+ this.assertEnoughLeftFor(length);
62
+ this.position += length;
63
+ return this.buffer.readUInt8(this.position - length);
64
+ }
65
+ }, {
66
+ key: 'readUInt16LE',
67
+ value: function readUInt16LE() {
68
+ var length = 2;
69
+ this.assertEnoughLeftFor(length);
70
+ this.position += length;
71
+ return this.buffer.readUInt16LE(this.position - length);
72
+ }
73
+ }, {
74
+ key: 'readUInt16BE',
75
+ value: function readUInt16BE() {
76
+ var length = 2;
77
+ this.assertEnoughLeftFor(length);
78
+ this.position += length;
79
+ return this.buffer.readUInt16BE(this.position - length);
80
+ }
81
+ }, {
82
+ key: 'readUInt32LE',
83
+ value: function readUInt32LE() {
84
+ var length = 4;
85
+ this.assertEnoughLeftFor(length);
86
+ this.position += length;
87
+ return this.buffer.readUInt32LE(this.position - length);
88
+ }
89
+ }, {
90
+ key: 'readUInt32BE',
91
+ value: function readUInt32BE() {
92
+ var length = 4;
93
+ this.assertEnoughLeftFor(length);
94
+ this.position += length;
95
+ return this.buffer.readUInt32BE(this.position - length);
96
+ }
97
+ }, {
98
+ key: 'readInt8',
99
+ value: function readInt8() {
100
+ var length = 1;
101
+ this.assertEnoughLeftFor(length);
102
+ this.position += length;
103
+ return this.buffer.readInt8(this.position - length);
104
+ }
105
+ }, {
106
+ key: 'readInt16LE',
107
+ value: function readInt16LE() {
108
+ var length = 2;
109
+ this.assertEnoughLeftFor(length);
110
+ this.position += length;
111
+ return this.buffer.readInt16LE(this.position - length);
112
+ }
113
+ }, {
114
+ key: 'readInt16BE',
115
+ value: function readInt16BE() {
116
+ var length = 2;
117
+ this.assertEnoughLeftFor(length);
118
+ this.position += length;
119
+ return this.buffer.readInt16BE(this.position - length);
120
+ }
121
+ }, {
122
+ key: 'readInt32LE',
123
+ value: function readInt32LE() {
124
+ var length = 4;
125
+ this.assertEnoughLeftFor(length);
126
+ this.position += length;
127
+ return this.buffer.readInt32LE(this.position - length);
128
+ }
129
+ }, {
130
+ key: 'readInt32BE',
131
+ value: function readInt32BE() {
132
+ var length = 4;
133
+ this.assertEnoughLeftFor(length);
134
+ this.position += length;
135
+ return this.buffer.readInt32BE(this.position - length);
136
+ }
137
+ }, {
138
+ key: 'readFloatLE',
139
+ value: function readFloatLE() {
140
+ var length = 4;
141
+ this.assertEnoughLeftFor(length);
142
+ this.position += length;
143
+ return this.buffer.readFloatLE(this.position - length);
144
+ }
145
+ }, {
146
+ key: 'readDoubleLE',
147
+ value: function readDoubleLE() {
148
+ var length = 8;
149
+ this.assertEnoughLeftFor(length);
150
+ this.position += length;
151
+ return this.buffer.readDoubleLE(this.position - length);
152
+ }
153
+ }, {
154
+ key: 'readUInt24LE',
155
+ value: function readUInt24LE() {
156
+ var length = 3;
157
+ this.assertEnoughLeftFor(length);
158
+ var val = this.buffer[this.position + 1] << 8;
159
+ val |= this.buffer[this.position];
160
+ val += this.buffer[this.position + 2] << 16 >>> 0;
161
+ this.position += length;
162
+ return val;
163
+ }
164
+ }, {
165
+ key: 'readUInt40LE',
166
+ value: function readUInt40LE() {
167
+ var low = this.readBuffer(4).readUInt32LE(0);
168
+ var high = Buffer.concat([this.readBuffer(1), new Buffer([0x00, 0x00, 0x00])]).readUInt32LE(0);
169
+ return low + 0x100000000 * high;
170
+ }
235
171
 
236
- ReadableTrackingBuffer.prototype.readAsStringInt64LE = function (length) {
237
- return this.readAsStringBigIntLE(8);
238
- };
172
+ // If value > 53 bits then it will be incorrect (because Javascript uses IEEE_754 for number representation).
173
+ }, {
174
+ key: 'readUInt64LE',
175
+ value: function readUInt64LE() {
176
+ var low = this.readUInt32LE();
177
+ var high = this.readUInt32LE();
178
+ if (high >= 2 << 53 - 32) {
179
+ console.warn('Read UInt64LE > 53 bits : high=' + high + ', low=' + low);
180
+ }
181
+ return low + 0x100000000 * high;
182
+ }
183
+ }, {
184
+ key: 'readUNumeric64LE',
185
+ value: function readUNumeric64LE() {
186
+ var low = this.readUInt32LE();
187
+ var high = this.readUInt32LE();
188
+ return low + 0x100000000 * high;
189
+ }
190
+ }, {
191
+ key: 'readUNumeric96LE',
192
+ value: function readUNumeric96LE() {
193
+ var dword1 = this.readUInt32LE();
194
+ var dword2 = this.readUInt32LE();
195
+ var dword3 = this.readUInt32LE();
196
+ return dword1 + 0x100000000 * dword2 + 0x100000000 * 0x100000000 * dword3;
197
+ }
198
+ }, {
199
+ key: 'readUNumeric128LE',
200
+ value: function readUNumeric128LE() {
201
+ var dword1 = this.readUInt32LE();
202
+ var dword2 = this.readUInt32LE();
203
+ var dword3 = this.readUInt32LE();
204
+ var dword4 = this.readUInt32LE();
205
+ return dword1 + 0x100000000 * dword2 + 0x100000000 * 0x100000000 * dword3 + 0x100000000 * 0x100000000 * 0x100000000 * dword4;
206
+ }
207
+ }, {
208
+ key: 'readString',
209
+ value: function readString(length, encoding) {
210
+ encoding || (encoding = this.encoding);
211
+ this.assertEnoughLeftFor(length);
212
+ this.position += length;
213
+ return this.buffer.toString(encoding, this.position - length, this.position);
214
+ }
215
+ }, {
216
+ key: 'readBVarchar',
217
+ value: function readBVarchar(encoding) {
218
+ encoding || (encoding = this.encoding);
219
+ var multiplier = encoding === 'ucs2' ? 2 : 1;
220
+ var length = this.readUInt8() * multiplier;
221
+ return this.readString(length, encoding);
222
+ }
223
+ }, {
224
+ key: 'readUsVarchar',
225
+ value: function readUsVarchar(encoding) {
226
+ encoding || (encoding = this.encoding);
227
+ var multiplier = encoding === 'ucs2' ? 2 : 1;
228
+ var length = this.readUInt16LE() * multiplier;
229
+ return this.readString(length, encoding);
230
+ }
231
+ }, {
232
+ key: 'readBuffer',
233
+ value: function readBuffer(length) {
234
+ this.assertEnoughLeftFor(length);
235
+ this.position += length;
236
+ return this.buffer.slice(this.position - length, this.position);
237
+ }
238
+ }, {
239
+ key: 'readArray',
240
+ value: function readArray(length) {
241
+ return Array.prototype.slice.call(this.readBuffer(length), 0, length);
242
+ }
243
+ }, {
244
+ key: 'readAsStringBigIntLE',
245
+ value: function readAsStringBigIntLE(length) {
246
+ this.assertEnoughLeftFor(length);
247
+ this.position += length;
248
+ return convertLEBytesToString(this.buffer.slice(this.position - length, this.position));
249
+ }
250
+ }, {
251
+ key: 'readAsStringInt64LE',
252
+ value: function readAsStringInt64LE() {
253
+ return this.readAsStringBigIntLE(8);
254
+ }
255
+ }]);
239
256
 
240
257
  return ReadableTrackingBuffer;
241
- })();
242
-
243
- module.exports = ReadableTrackingBuffer;
258
+ })();
@@ -1,10 +1,4 @@
1
- // Generated by CoffeeScript 1.10.0
2
- var ReadableTrackingBuffer, WritableTrackingBuffer;
1
+ 'use strict';
3
2
 
4
- ReadableTrackingBuffer = require('./readable-tracking-buffer');
5
-
6
- WritableTrackingBuffer = require('./writable-tracking-buffer');
7
-
8
- module.exports.ReadableTrackingBuffer = ReadableTrackingBuffer;
9
-
10
- module.exports.WritableTrackingBuffer = WritableTrackingBuffer;
3
+ module.exports.ReadableTrackingBuffer = require('./readable-tracking-buffer');
4
+ module.exports.WritableTrackingBuffer = require('./writable-tracking-buffer');