sqlite-executor 4.0.4 → 4.0.6
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/dist/cjs/core/lruCache.d.cts +8 -1
- package/dist/cjs/core/pipelineEngine.d.cts +2 -0
- package/dist/cjs/core/readerPool.d.cts +2 -2
- package/dist/cjs/index.cjs +650 -519
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/utils/interpolate.d.cts +11 -0
- package/dist/cjs/utils/normalize.d.cts +24 -0
- package/dist/cjs/utils/timeout.d.cts +2 -1
- package/dist/esm/core/lruCache.d.mts +8 -1
- package/dist/esm/core/pipelineEngine.d.mts +2 -0
- package/dist/esm/core/readerPool.d.mts +2 -2
- package/dist/esm/index.mjs +650 -519
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/utils/interpolate.d.mts +11 -0
- package/dist/esm/utils/normalize.d.mts +24 -0
- package/dist/esm/utils/timeout.d.mts +2 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -56,218 +56,9 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
var external_node_events_namespaceObject = require("node:events");
|
|
59
|
-
function _check_private_redeclaration(obj, privateCollection) {
|
|
60
|
-
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
61
|
-
}
|
|
62
|
-
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
63
|
-
if (descriptor.get) return descriptor.get.call(receiver);
|
|
64
|
-
return descriptor.value;
|
|
65
|
-
}
|
|
66
|
-
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
67
|
-
if (descriptor.set) descriptor.set.call(receiver, value);
|
|
68
|
-
else {
|
|
69
|
-
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
70
|
-
descriptor.value = value;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
function _class_call_check(instance, Constructor) {
|
|
74
|
-
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
75
|
-
}
|
|
76
|
-
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
77
|
-
if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
78
|
-
return privateMap.get(receiver);
|
|
79
|
-
}
|
|
80
|
-
function _class_private_field_get(receiver, privateMap) {
|
|
81
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
82
|
-
return _class_apply_descriptor_get(receiver, descriptor);
|
|
83
|
-
}
|
|
84
|
-
function _class_private_field_init(obj, privateMap, value) {
|
|
85
|
-
_check_private_redeclaration(obj, privateMap);
|
|
86
|
-
privateMap.set(obj, value);
|
|
87
|
-
}
|
|
88
|
-
function _class_private_field_set(receiver, privateMap, value) {
|
|
89
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
90
|
-
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
91
|
-
return value;
|
|
92
|
-
}
|
|
93
|
-
function _defineProperties(target, props) {
|
|
94
|
-
for(var i = 0; i < props.length; i++){
|
|
95
|
-
var descriptor = props[i];
|
|
96
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
97
|
-
descriptor.configurable = true;
|
|
98
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
99
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
103
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
104
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
105
|
-
return Constructor;
|
|
106
|
-
}
|
|
107
|
-
var _maxSize = /*#__PURE__*/ new WeakMap(), _maxKeyLength = /*#__PURE__*/ new WeakMap(), _map = /*#__PURE__*/ new WeakMap();
|
|
108
|
-
var lruCache_LRUCache = /*#__PURE__*/ function() {
|
|
109
|
-
"use strict";
|
|
110
|
-
function LRUCache() {
|
|
111
|
-
var _ref = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, _ref_maxSize = _ref.maxSize, maxSize = void 0 === _ref_maxSize ? 256 : _ref_maxSize, _ref_maxKeyLength = _ref.maxKeyLength, maxKeyLength = void 0 === _ref_maxKeyLength ? 4096 : _ref_maxKeyLength;
|
|
112
|
-
_class_call_check(this, LRUCache);
|
|
113
|
-
_class_private_field_init(this, _maxSize, {
|
|
114
|
-
writable: true,
|
|
115
|
-
value: void 0
|
|
116
|
-
});
|
|
117
|
-
_class_private_field_init(this, _maxKeyLength, {
|
|
118
|
-
writable: true,
|
|
119
|
-
value: void 0
|
|
120
|
-
});
|
|
121
|
-
_class_private_field_init(this, _map, {
|
|
122
|
-
writable: true,
|
|
123
|
-
value: new Map()
|
|
124
|
-
});
|
|
125
|
-
_class_private_field_set(this, _maxSize, Math.max(1, maxSize));
|
|
126
|
-
_class_private_field_set(this, _maxKeyLength, maxKeyLength);
|
|
127
|
-
}
|
|
128
|
-
_create_class(LRUCache, [
|
|
129
|
-
{
|
|
130
|
-
key: "get",
|
|
131
|
-
value: function(key) {
|
|
132
|
-
if ("string" != typeof key || key.length > _class_private_field_get(this, _maxKeyLength)) return;
|
|
133
|
-
var value = _class_private_field_get(this, _map).get(key);
|
|
134
|
-
if (void 0 === value) return;
|
|
135
|
-
_class_private_field_get(this, _map)["delete"](key);
|
|
136
|
-
_class_private_field_get(this, _map).set(key, value);
|
|
137
|
-
return value;
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
key: "set",
|
|
142
|
-
value: function(key, value) {
|
|
143
|
-
if ("string" != typeof key || key.length > _class_private_field_get(this, _maxKeyLength)) return;
|
|
144
|
-
if (_class_private_field_get(this, _map).size >= _class_private_field_get(this, _maxSize)) {
|
|
145
|
-
var firstKey = _class_private_field_get(this, _map).keys().next().value;
|
|
146
|
-
_class_private_field_get(this, _map)["delete"](firstKey);
|
|
147
|
-
}
|
|
148
|
-
_class_private_field_get(this, _map).set(key, value);
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
key: "size",
|
|
153
|
-
get: function() {
|
|
154
|
-
return _class_private_field_get(this, _map).size;
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
key: "clear",
|
|
159
|
-
value: function() {
|
|
160
|
-
_class_private_field_get(this, _map).clear();
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
]);
|
|
164
|
-
return LRUCache;
|
|
165
|
-
}();
|
|
166
|
-
var CC_SINGLE_QUOTE = 39;
|
|
167
|
-
var CC_DOUBLE_QUOTE = 34;
|
|
168
|
-
var CC_DASH = 45;
|
|
169
|
-
var CC_SLASH = 47;
|
|
170
|
-
var CC_STAR = 42;
|
|
171
|
-
var CC_NEWLINE = 10;
|
|
172
|
-
var CC_QUESTION = 63;
|
|
173
|
-
var CC_SEMICOLON = 59;
|
|
174
|
-
var CC_SPACE = 32;
|
|
175
|
-
var STATE_NORMAL = 0;
|
|
176
|
-
var STATE_SINGLE_QUOTE = 1;
|
|
177
|
-
var STATE_DOUBLE_QUOTE = 2;
|
|
178
|
-
var STATE_LINE_COMMENT = 3;
|
|
179
|
-
var STATE_BLOCK_COMMENT = 4;
|
|
180
|
-
var _normBuf = new Uint16Array(1024);
|
|
181
|
-
var _normDecoder = new TextDecoder("utf-16le");
|
|
182
|
-
var _normCache = new lruCache_LRUCache({
|
|
183
|
-
maxSize: 256,
|
|
184
|
-
maxKeyLength: 4096
|
|
185
|
-
});
|
|
186
|
-
function normalizeSQL(sql) {
|
|
187
|
-
var cached = _normCache.get(sql);
|
|
188
|
-
if (void 0 !== cached) return cached;
|
|
189
|
-
var len = sql.length;
|
|
190
|
-
var needed = len + 1;
|
|
191
|
-
if (_normBuf.length < needed) _normBuf = new Uint16Array(needed);
|
|
192
|
-
var outCodes = _normBuf;
|
|
193
|
-
var writePos = 0;
|
|
194
|
-
var pendingSpace = false;
|
|
195
|
-
var state = STATE_NORMAL;
|
|
196
|
-
for(var i = 0; i < len; i++){
|
|
197
|
-
var code = sql.charCodeAt(i);
|
|
198
|
-
var nextCode = sql.charCodeAt(i + 1);
|
|
199
|
-
if (state === STATE_BLOCK_COMMENT) {
|
|
200
|
-
if (code === CC_STAR && nextCode === CC_SLASH) {
|
|
201
|
-
state = STATE_NORMAL;
|
|
202
|
-
i++;
|
|
203
|
-
if (writePos > 0) pendingSpace = true;
|
|
204
|
-
}
|
|
205
|
-
continue;
|
|
206
|
-
}
|
|
207
|
-
if (state === STATE_LINE_COMMENT) {
|
|
208
|
-
if (code === CC_NEWLINE) {
|
|
209
|
-
state = STATE_NORMAL;
|
|
210
|
-
if (writePos > 0) pendingSpace = true;
|
|
211
|
-
}
|
|
212
|
-
continue;
|
|
213
|
-
}
|
|
214
|
-
if (state === STATE_NORMAL) {
|
|
215
|
-
if (code === CC_DASH && nextCode === CC_DASH) {
|
|
216
|
-
state = STATE_LINE_COMMENT;
|
|
217
|
-
i++;
|
|
218
|
-
continue;
|
|
219
|
-
}
|
|
220
|
-
if (code === CC_SLASH && nextCode === CC_STAR) {
|
|
221
|
-
state = STATE_BLOCK_COMMENT;
|
|
222
|
-
i++;
|
|
223
|
-
continue;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
if (32 === code || 9 === code || 10 === code || 11 === code || 12 === code || 13 === code) {
|
|
227
|
-
if (writePos > 0) pendingSpace = true;
|
|
228
|
-
continue;
|
|
229
|
-
}
|
|
230
|
-
if (pendingSpace && writePos > 0) {
|
|
231
|
-
outCodes[writePos++] = CC_SPACE;
|
|
232
|
-
pendingSpace = false;
|
|
233
|
-
}
|
|
234
|
-
outCodes[writePos++] = code;
|
|
235
|
-
if (state === STATE_NORMAL) {
|
|
236
|
-
if (code === CC_SINGLE_QUOTE) state = STATE_SINGLE_QUOTE;
|
|
237
|
-
else if (code === CC_DOUBLE_QUOTE) state = STATE_DOUBLE_QUOTE;
|
|
238
|
-
continue;
|
|
239
|
-
}
|
|
240
|
-
if (state === STATE_SINGLE_QUOTE) {
|
|
241
|
-
if (code === CC_SINGLE_QUOTE && nextCode === CC_SINGLE_QUOTE) {
|
|
242
|
-
outCodes[writePos++] = nextCode;
|
|
243
|
-
i++;
|
|
244
|
-
continue;
|
|
245
|
-
}
|
|
246
|
-
if (code === CC_SINGLE_QUOTE) state = STATE_NORMAL;
|
|
247
|
-
continue;
|
|
248
|
-
}
|
|
249
|
-
if (state === STATE_DOUBLE_QUOTE) {
|
|
250
|
-
if (code === CC_DOUBLE_QUOTE && nextCode === CC_DOUBLE_QUOTE) {
|
|
251
|
-
outCodes[writePos++] = nextCode;
|
|
252
|
-
i++;
|
|
253
|
-
continue;
|
|
254
|
-
}
|
|
255
|
-
if (code === CC_DOUBLE_QUOTE) state = STATE_NORMAL;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
var result;
|
|
259
|
-
if (0 === writePos) result = ";";
|
|
260
|
-
else {
|
|
261
|
-
while(writePos > 0 && outCodes[writePos - 1] === CC_SEMICOLON)writePos--;
|
|
262
|
-
outCodes[writePos++] = CC_SEMICOLON;
|
|
263
|
-
result = _normDecoder.decode(outCodes.subarray(0, writePos));
|
|
264
|
-
}
|
|
265
|
-
_normCache.set(sql, result);
|
|
266
|
-
return result;
|
|
267
|
-
}
|
|
268
59
|
var DEFAULT_STATEMENT_TIMEOUT = 30000;
|
|
269
60
|
function createTimeoutError(timeout, sql) {
|
|
270
|
-
return new Error("SQLite statement timed out after ".concat(timeout, "ms: ").concat(
|
|
61
|
+
return new Error("SQLite statement timed out after ".concat(timeout, "ms: ").concat(sql));
|
|
271
62
|
}
|
|
272
63
|
function toError(value) {
|
|
273
64
|
return value instanceof Error ? value : new Error(String(value));
|
|
@@ -298,55 +89,65 @@ function createJsonValueParser(onValue) {
|
|
|
298
89
|
feed: function(chunk) {
|
|
299
90
|
this.buffer += chunk;
|
|
300
91
|
var consumeUntil = 0;
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
92
|
+
var buffer = this.buffer;
|
|
93
|
+
var start = this.start;
|
|
94
|
+
var nesting = this.nesting;
|
|
95
|
+
var inString = this.inString;
|
|
96
|
+
var escaped = this.escaped;
|
|
97
|
+
for(var index = this.readPos; index < buffer.length; index++){
|
|
98
|
+
var code = buffer.charCodeAt(index);
|
|
99
|
+
if (-1 === start) {
|
|
304
100
|
if (isWhitespaceCode(code)) continue;
|
|
305
101
|
if (code !== CHAR_OPEN_BRACKET && code !== CHAR_OPEN_BRACE) continue;
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
102
|
+
start = index;
|
|
103
|
+
nesting = 1;
|
|
104
|
+
inString = false;
|
|
105
|
+
escaped = false;
|
|
310
106
|
continue;
|
|
311
107
|
}
|
|
312
|
-
if (
|
|
313
|
-
if (
|
|
314
|
-
else if (code === CHAR_BACKSLASH)
|
|
315
|
-
else if (code === CHAR_QUOTE)
|
|
108
|
+
if (inString) {
|
|
109
|
+
if (escaped) escaped = false;
|
|
110
|
+
else if (code === CHAR_BACKSLASH) escaped = true;
|
|
111
|
+
else if (code === CHAR_QUOTE) inString = false;
|
|
316
112
|
continue;
|
|
317
113
|
}
|
|
318
114
|
if (code === CHAR_QUOTE) {
|
|
319
|
-
|
|
115
|
+
inString = true;
|
|
320
116
|
continue;
|
|
321
117
|
}
|
|
322
118
|
if (code === CHAR_OPEN_BRACKET || code === CHAR_OPEN_BRACE) {
|
|
323
|
-
|
|
119
|
+
nesting++;
|
|
324
120
|
continue;
|
|
325
121
|
}
|
|
326
122
|
if (code === CHAR_CLOSE_BRACKET || code === CHAR_CLOSE_BRACE) {
|
|
327
|
-
|
|
328
|
-
if (0 ===
|
|
329
|
-
if (index ===
|
|
330
|
-
|
|
123
|
+
nesting--;
|
|
124
|
+
if (0 === nesting) {
|
|
125
|
+
if (index === start + 1) {
|
|
126
|
+
start = -1;
|
|
331
127
|
consumeUntil = index + 1;
|
|
332
128
|
continue;
|
|
333
129
|
}
|
|
334
|
-
var raw =
|
|
335
|
-
|
|
130
|
+
var raw = buffer.slice(start, index + 1);
|
|
131
|
+
start = -1;
|
|
336
132
|
onValue(raw);
|
|
337
133
|
consumeUntil = index + 1;
|
|
338
134
|
}
|
|
339
135
|
}
|
|
340
136
|
}
|
|
137
|
+
this.start = start;
|
|
138
|
+
this.nesting = nesting;
|
|
139
|
+
this.inString = inString;
|
|
140
|
+
this.escaped = escaped;
|
|
341
141
|
if (consumeUntil > 0) {
|
|
342
142
|
this._consumed = consumeUntil;
|
|
343
|
-
this.readPos = this._consumed;
|
|
143
|
+
this.readPos = -1 !== this.start ? buffer.length : this._consumed;
|
|
344
144
|
if (this._consumed > 65536) {
|
|
145
|
+
if (-1 !== this.start) this.start -= this._consumed;
|
|
345
146
|
this.buffer = this.buffer.slice(this._consumed);
|
|
346
|
-
this.readPos =
|
|
147
|
+
this.readPos = this.buffer.length;
|
|
347
148
|
this._consumed = 0;
|
|
348
149
|
}
|
|
349
|
-
} else this.readPos =
|
|
150
|
+
} else this.readPos = buffer.length;
|
|
350
151
|
},
|
|
351
152
|
reset: function() {
|
|
352
153
|
this.buffer = "";
|
|
@@ -374,10 +175,18 @@ function createRowStreamParser(onRow) {
|
|
|
374
175
|
feed: function(chunk) {
|
|
375
176
|
if (this.finished) return chunk;
|
|
376
177
|
this.buffer += chunk;
|
|
178
|
+
var buffer = this.buffer;
|
|
179
|
+
var started = this.started;
|
|
180
|
+
var inString = this.inString;
|
|
181
|
+
var escaped = this.escaped;
|
|
182
|
+
var elementStart = this.elementStart;
|
|
183
|
+
var elementEnd = this.elementEnd;
|
|
184
|
+
var nesting = this.nesting;
|
|
185
|
+
var consumed = this._consumed;
|
|
377
186
|
var index = this.readPos;
|
|
378
|
-
while(index <
|
|
379
|
-
var code =
|
|
380
|
-
if (!
|
|
187
|
+
while(index < buffer.length){
|
|
188
|
+
var code = buffer.charCodeAt(index);
|
|
189
|
+
if (!started) {
|
|
381
190
|
if (isWhitespaceCode(code)) {
|
|
382
191
|
index++;
|
|
383
192
|
continue;
|
|
@@ -386,74 +195,81 @@ function createRowStreamParser(onRow) {
|
|
|
386
195
|
index++;
|
|
387
196
|
continue;
|
|
388
197
|
}
|
|
389
|
-
|
|
198
|
+
started = true;
|
|
390
199
|
index++;
|
|
391
200
|
continue;
|
|
392
201
|
}
|
|
393
|
-
if (
|
|
394
|
-
if (
|
|
395
|
-
else if (code === CHAR_BACKSLASH)
|
|
396
|
-
else if (code === CHAR_QUOTE)
|
|
202
|
+
if (inString) {
|
|
203
|
+
if (escaped) escaped = false;
|
|
204
|
+
else if (code === CHAR_BACKSLASH) escaped = true;
|
|
205
|
+
else if (code === CHAR_QUOTE) inString = false;
|
|
397
206
|
index++;
|
|
398
207
|
continue;
|
|
399
208
|
}
|
|
400
|
-
if (-1 ===
|
|
209
|
+
if (-1 === elementStart) {
|
|
401
210
|
if (isWhitespaceCode(code) || code === CHAR_COMMA) {
|
|
402
211
|
index++;
|
|
403
212
|
continue;
|
|
404
213
|
}
|
|
405
214
|
if (code === CHAR_CLOSE_BRACKET) {
|
|
406
215
|
this.finished = true;
|
|
407
|
-
var leftover = this.buffer.slice(index + 1);
|
|
408
|
-
this.buffer = "";
|
|
409
216
|
this.readPos = 0;
|
|
410
|
-
|
|
217
|
+
this.buffer = "";
|
|
218
|
+
this.started = false;
|
|
219
|
+
return buffer.slice(index + 1);
|
|
411
220
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
221
|
+
elementStart = index;
|
|
222
|
+
elementEnd = -1;
|
|
223
|
+
nesting = code === CHAR_OPEN_BRACE || code === CHAR_OPEN_BRACKET ? 1 : 0;
|
|
224
|
+
inString = code === CHAR_QUOTE;
|
|
225
|
+
escaped = false;
|
|
416
226
|
index++;
|
|
417
227
|
continue;
|
|
418
228
|
}
|
|
419
229
|
if (code === CHAR_QUOTE) {
|
|
420
|
-
|
|
230
|
+
inString = true;
|
|
421
231
|
index++;
|
|
422
232
|
continue;
|
|
423
233
|
}
|
|
424
234
|
if (code === CHAR_OPEN_BRACE || code === CHAR_OPEN_BRACKET) {
|
|
425
|
-
|
|
235
|
+
nesting++;
|
|
426
236
|
index++;
|
|
427
237
|
continue;
|
|
428
238
|
}
|
|
429
239
|
if (code === CHAR_CLOSE_BRACE || code === CHAR_CLOSE_BRACKET) {
|
|
430
|
-
|
|
431
|
-
if (0 ===
|
|
240
|
+
nesting--;
|
|
241
|
+
if (0 === nesting) elementEnd = index + 1;
|
|
432
242
|
}
|
|
433
|
-
if (-1 !==
|
|
243
|
+
if (-1 !== elementEnd) {
|
|
434
244
|
var lookAhead = index + 1;
|
|
435
|
-
while(lookAhead <
|
|
436
|
-
if (lookAhead <
|
|
437
|
-
var delimiter =
|
|
245
|
+
while(lookAhead < buffer.length && isWhitespaceCode(buffer.charCodeAt(lookAhead)))lookAhead++;
|
|
246
|
+
if (lookAhead < buffer.length) {
|
|
247
|
+
var delimiter = buffer.charCodeAt(lookAhead);
|
|
438
248
|
if (delimiter === CHAR_COMMA || delimiter === CHAR_CLOSE_BRACKET) {
|
|
439
|
-
onRow(
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
249
|
+
onRow(buffer.slice(elementStart, elementEnd));
|
|
250
|
+
consumed = lookAhead + 1;
|
|
251
|
+
elementStart = -1;
|
|
252
|
+
elementEnd = -1;
|
|
253
|
+
nesting = 0;
|
|
444
254
|
if (delimiter === CHAR_CLOSE_BRACKET) {
|
|
445
255
|
this.finished = true;
|
|
446
|
-
var tail = this.buffer.slice(this._consumed);
|
|
447
256
|
this.buffer = "";
|
|
257
|
+
this.started = false;
|
|
258
|
+
this.inString = false;
|
|
259
|
+
this.escaped = false;
|
|
260
|
+
this.elementStart = -1;
|
|
261
|
+
this.elementEnd = -1;
|
|
262
|
+
this.nesting = 0;
|
|
448
263
|
this._consumed = 0;
|
|
449
264
|
this.readPos = 0;
|
|
450
|
-
return
|
|
265
|
+
return buffer.slice(consumed);
|
|
451
266
|
}
|
|
452
|
-
index =
|
|
453
|
-
if (
|
|
454
|
-
this.buffer =
|
|
455
|
-
index = 0;
|
|
267
|
+
index = consumed;
|
|
268
|
+
if (consumed > 65536) {
|
|
269
|
+
this.buffer = buffer.slice(consumed);
|
|
456
270
|
this._consumed = 0;
|
|
271
|
+
index = 0;
|
|
272
|
+
consumed = 0;
|
|
457
273
|
}
|
|
458
274
|
continue;
|
|
459
275
|
}
|
|
@@ -461,12 +277,19 @@ function createRowStreamParser(onRow) {
|
|
|
461
277
|
}
|
|
462
278
|
index++;
|
|
463
279
|
}
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
280
|
+
this.started = started;
|
|
281
|
+
this.inString = inString;
|
|
282
|
+
this.escaped = escaped;
|
|
283
|
+
this.elementStart = elementStart;
|
|
284
|
+
this.elementEnd = elementEnd;
|
|
285
|
+
this.nesting = nesting;
|
|
286
|
+
this._consumed = consumed;
|
|
287
|
+
if (consumed > 0) {
|
|
288
|
+
if (-1 !== elementStart) {
|
|
289
|
+
this.elementStart -= consumed;
|
|
290
|
+
if (-1 !== elementEnd) this.elementEnd -= consumed;
|
|
468
291
|
}
|
|
469
|
-
this.buffer =
|
|
292
|
+
this.buffer = buffer.slice(consumed);
|
|
470
293
|
this._consumed = 0;
|
|
471
294
|
}
|
|
472
295
|
if (this.elementStart > 0) {
|
|
@@ -494,14 +317,14 @@ function createRowStreamParser(onRow) {
|
|
|
494
317
|
var TOKEN_COLUMN = "__sqlite_executor_token__";
|
|
495
318
|
var DEFAULT_BATCH_SIZE = 10;
|
|
496
319
|
var DEFAULT_MAX_INFLIGHT = 50;
|
|
497
|
-
function
|
|
320
|
+
function _check_private_redeclaration(obj, privateCollection) {
|
|
498
321
|
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
499
322
|
}
|
|
500
|
-
function
|
|
323
|
+
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
501
324
|
if (descriptor.get) return descriptor.get.call(receiver);
|
|
502
325
|
return descriptor.value;
|
|
503
326
|
}
|
|
504
|
-
function
|
|
327
|
+
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
505
328
|
if (descriptor.set) descriptor.set.call(receiver, value);
|
|
506
329
|
else {
|
|
507
330
|
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
@@ -524,31 +347,31 @@ function _class_apply_descriptor_update(receiver, descriptor) {
|
|
|
524
347
|
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
525
348
|
return descriptor;
|
|
526
349
|
}
|
|
527
|
-
function
|
|
350
|
+
function _class_call_check(instance, Constructor) {
|
|
528
351
|
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
529
352
|
}
|
|
530
|
-
function
|
|
353
|
+
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
531
354
|
if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
532
355
|
return privateMap.get(receiver);
|
|
533
356
|
}
|
|
534
|
-
function
|
|
535
|
-
var descriptor =
|
|
536
|
-
return
|
|
357
|
+
function _class_private_field_get(receiver, privateMap) {
|
|
358
|
+
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
359
|
+
return _class_apply_descriptor_get(receiver, descriptor);
|
|
537
360
|
}
|
|
538
|
-
function
|
|
539
|
-
|
|
361
|
+
function _class_private_field_init(obj, privateMap, value) {
|
|
362
|
+
_check_private_redeclaration(obj, privateMap);
|
|
540
363
|
privateMap.set(obj, value);
|
|
541
364
|
}
|
|
542
|
-
function
|
|
543
|
-
var descriptor =
|
|
544
|
-
|
|
365
|
+
function _class_private_field_set(receiver, privateMap, value) {
|
|
366
|
+
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
367
|
+
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
545
368
|
return value;
|
|
546
369
|
}
|
|
547
370
|
function _class_private_field_update(receiver, privateMap) {
|
|
548
|
-
var descriptor =
|
|
371
|
+
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "update");
|
|
549
372
|
return _class_apply_descriptor_update(receiver, descriptor);
|
|
550
373
|
}
|
|
551
|
-
function
|
|
374
|
+
function _defineProperties(target, props) {
|
|
552
375
|
for(var i = 0; i < props.length; i++){
|
|
553
376
|
var descriptor = props[i];
|
|
554
377
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
@@ -557,9 +380,9 @@ function stream_defineProperties(target, props) {
|
|
|
557
380
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
558
381
|
}
|
|
559
382
|
}
|
|
560
|
-
function
|
|
561
|
-
if (protoProps)
|
|
562
|
-
if (staticProps)
|
|
383
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
384
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
385
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
563
386
|
return Constructor;
|
|
564
387
|
}
|
|
565
388
|
function _type_of(obj) {
|
|
@@ -589,50 +412,50 @@ var _computedKey1 = _computedKey;
|
|
|
589
412
|
var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
590
413
|
"use strict";
|
|
591
414
|
function AsyncRowBuffer() {
|
|
592
|
-
|
|
593
|
-
|
|
415
|
+
_class_call_check(this, AsyncRowBuffer);
|
|
416
|
+
_class_private_field_init(this, _buffer, {
|
|
594
417
|
writable: true,
|
|
595
418
|
value: []
|
|
596
419
|
});
|
|
597
|
-
|
|
420
|
+
_class_private_field_init(this, _index, {
|
|
598
421
|
writable: true,
|
|
599
422
|
value: 0
|
|
600
423
|
});
|
|
601
|
-
|
|
424
|
+
_class_private_field_init(this, _done, {
|
|
602
425
|
writable: true,
|
|
603
426
|
value: false
|
|
604
427
|
});
|
|
605
|
-
|
|
428
|
+
_class_private_field_init(this, _error, {
|
|
606
429
|
writable: true,
|
|
607
430
|
value: null
|
|
608
431
|
});
|
|
609
|
-
|
|
432
|
+
_class_private_field_init(this, _pending, {
|
|
610
433
|
writable: true,
|
|
611
434
|
value: null
|
|
612
435
|
});
|
|
613
436
|
}
|
|
614
|
-
|
|
437
|
+
_create_class(AsyncRowBuffer, [
|
|
615
438
|
{
|
|
616
439
|
key: "push",
|
|
617
440
|
value: function(row) {
|
|
618
|
-
if (
|
|
619
|
-
if (
|
|
620
|
-
var resolve =
|
|
621
|
-
|
|
441
|
+
if (_class_private_field_get(this, _done) || _class_private_field_get(this, _error)) return;
|
|
442
|
+
if (_class_private_field_get(this, _pending)) {
|
|
443
|
+
var resolve = _class_private_field_get(this, _pending).resolve;
|
|
444
|
+
_class_private_field_set(this, _pending, null);
|
|
622
445
|
resolve({
|
|
623
446
|
value: row,
|
|
624
447
|
done: false
|
|
625
448
|
});
|
|
626
|
-
} else
|
|
449
|
+
} else _class_private_field_get(this, _buffer).push(row);
|
|
627
450
|
}
|
|
628
451
|
},
|
|
629
452
|
{
|
|
630
453
|
key: "end",
|
|
631
454
|
value: function() {
|
|
632
|
-
|
|
633
|
-
if (
|
|
634
|
-
var resolve =
|
|
635
|
-
|
|
455
|
+
_class_private_field_set(this, _done, true);
|
|
456
|
+
if (_class_private_field_get(this, _pending)) {
|
|
457
|
+
var resolve = _class_private_field_get(this, _pending).resolve;
|
|
458
|
+
_class_private_field_set(this, _pending, null);
|
|
636
459
|
resolve({
|
|
637
460
|
value: void 0,
|
|
638
461
|
done: true
|
|
@@ -643,10 +466,10 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
643
466
|
{
|
|
644
467
|
key: "error",
|
|
645
468
|
value: function(err) {
|
|
646
|
-
|
|
647
|
-
if (
|
|
648
|
-
var reject =
|
|
649
|
-
|
|
469
|
+
_class_private_field_set(this, _error, err);
|
|
470
|
+
if (_class_private_field_get(this, _pending)) {
|
|
471
|
+
var reject = _class_private_field_get(this, _pending).reject;
|
|
472
|
+
_class_private_field_set(this, _pending, null);
|
|
650
473
|
reject(err);
|
|
651
474
|
}
|
|
652
475
|
}
|
|
@@ -655,17 +478,17 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
655
478
|
key: "next",
|
|
656
479
|
value: function() {
|
|
657
480
|
var _this = this;
|
|
658
|
-
if (
|
|
659
|
-
value:
|
|
481
|
+
if (_class_private_field_get(this, _index) < _class_private_field_get(this, _buffer).length) return Promise.resolve({
|
|
482
|
+
value: _class_private_field_get(this, _buffer)[_class_private_field_update(this, _index).value++],
|
|
660
483
|
done: false
|
|
661
484
|
});
|
|
662
|
-
if (
|
|
485
|
+
if (_class_private_field_get(this, _done)) return Promise.resolve({
|
|
663
486
|
value: void 0,
|
|
664
487
|
done: true
|
|
665
488
|
});
|
|
666
|
-
if (
|
|
489
|
+
if (_class_private_field_get(this, _error)) return Promise.reject(_class_private_field_get(this, _error));
|
|
667
490
|
return new Promise(function(resolve, reject) {
|
|
668
|
-
|
|
491
|
+
_class_private_field_set(_this, _pending, {
|
|
669
492
|
resolve: resolve,
|
|
670
493
|
reject: reject
|
|
671
494
|
});
|
|
@@ -675,12 +498,12 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
675
498
|
{
|
|
676
499
|
key: "return",
|
|
677
500
|
value: function() {
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
if (
|
|
682
|
-
var resolve =
|
|
683
|
-
|
|
501
|
+
_class_private_field_set(this, _done, true);
|
|
502
|
+
_class_private_field_set(this, _buffer, []);
|
|
503
|
+
_class_private_field_set(this, _index, 0);
|
|
504
|
+
if (_class_private_field_get(this, _pending)) {
|
|
505
|
+
var resolve = _class_private_field_get(this, _pending).resolve;
|
|
506
|
+
_class_private_field_set(this, _pending, null);
|
|
684
507
|
resolve({
|
|
685
508
|
value: void 0,
|
|
686
509
|
done: true
|
|
@@ -1220,6 +1043,119 @@ function generateToken() {
|
|
|
1220
1043
|
_counter = _counter + 1 >>> 0;
|
|
1221
1044
|
return "".concat(_PREFIX).concat(_counter.toString(36), "_").concat(_PID36);
|
|
1222
1045
|
}
|
|
1046
|
+
function lruCache_check_private_redeclaration(obj, privateCollection) {
|
|
1047
|
+
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
1048
|
+
}
|
|
1049
|
+
function lruCache_class_apply_descriptor_get(receiver, descriptor) {
|
|
1050
|
+
if (descriptor.get) return descriptor.get.call(receiver);
|
|
1051
|
+
return descriptor.value;
|
|
1052
|
+
}
|
|
1053
|
+
function lruCache_class_apply_descriptor_set(receiver, descriptor, value) {
|
|
1054
|
+
if (descriptor.set) descriptor.set.call(receiver, value);
|
|
1055
|
+
else {
|
|
1056
|
+
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
1057
|
+
descriptor.value = value;
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
function lruCache_class_call_check(instance, Constructor) {
|
|
1061
|
+
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
1062
|
+
}
|
|
1063
|
+
function lruCache_class_extract_field_descriptor(receiver, privateMap, action) {
|
|
1064
|
+
if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
1065
|
+
return privateMap.get(receiver);
|
|
1066
|
+
}
|
|
1067
|
+
function lruCache_class_private_field_get(receiver, privateMap) {
|
|
1068
|
+
var descriptor = lruCache_class_extract_field_descriptor(receiver, privateMap, "get");
|
|
1069
|
+
return lruCache_class_apply_descriptor_get(receiver, descriptor);
|
|
1070
|
+
}
|
|
1071
|
+
function lruCache_class_private_field_init(obj, privateMap, value) {
|
|
1072
|
+
lruCache_check_private_redeclaration(obj, privateMap);
|
|
1073
|
+
privateMap.set(obj, value);
|
|
1074
|
+
}
|
|
1075
|
+
function lruCache_class_private_field_set(receiver, privateMap, value) {
|
|
1076
|
+
var descriptor = lruCache_class_extract_field_descriptor(receiver, privateMap, "set");
|
|
1077
|
+
lruCache_class_apply_descriptor_set(receiver, descriptor, value);
|
|
1078
|
+
return value;
|
|
1079
|
+
}
|
|
1080
|
+
function lruCache_defineProperties(target, props) {
|
|
1081
|
+
for(var i = 0; i < props.length; i++){
|
|
1082
|
+
var descriptor = props[i];
|
|
1083
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
1084
|
+
descriptor.configurable = true;
|
|
1085
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
1086
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
function lruCache_create_class(Constructor, protoProps, staticProps) {
|
|
1090
|
+
if (protoProps) lruCache_defineProperties(Constructor.prototype, protoProps);
|
|
1091
|
+
if (staticProps) lruCache_defineProperties(Constructor, staticProps);
|
|
1092
|
+
return Constructor;
|
|
1093
|
+
}
|
|
1094
|
+
var _maxSize = /*#__PURE__*/ new WeakMap(), _maxKeyLength = /*#__PURE__*/ new WeakMap(), _maxValueLength = /*#__PURE__*/ new WeakMap(), _map = /*#__PURE__*/ new WeakMap();
|
|
1095
|
+
var lruCache_LRUCache = /*#__PURE__*/ function() {
|
|
1096
|
+
"use strict";
|
|
1097
|
+
function LRUCache() {
|
|
1098
|
+
var _ref = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, _ref_maxSize = _ref.maxSize, maxSize = void 0 === _ref_maxSize ? 256 : _ref_maxSize, _ref_maxKeyLength = _ref.maxKeyLength, maxKeyLength = void 0 === _ref_maxKeyLength ? 4096 : _ref_maxKeyLength, _ref_maxValueLength = _ref.maxValueLength, maxValueLength = void 0 === _ref_maxValueLength ? 1 / 0 : _ref_maxValueLength;
|
|
1099
|
+
lruCache_class_call_check(this, LRUCache);
|
|
1100
|
+
lruCache_class_private_field_init(this, _maxSize, {
|
|
1101
|
+
writable: true,
|
|
1102
|
+
value: void 0
|
|
1103
|
+
});
|
|
1104
|
+
lruCache_class_private_field_init(this, _maxKeyLength, {
|
|
1105
|
+
writable: true,
|
|
1106
|
+
value: void 0
|
|
1107
|
+
});
|
|
1108
|
+
lruCache_class_private_field_init(this, _maxValueLength, {
|
|
1109
|
+
writable: true,
|
|
1110
|
+
value: void 0
|
|
1111
|
+
});
|
|
1112
|
+
lruCache_class_private_field_init(this, _map, {
|
|
1113
|
+
writable: true,
|
|
1114
|
+
value: new Map()
|
|
1115
|
+
});
|
|
1116
|
+
lruCache_class_private_field_set(this, _maxSize, Math.max(1, maxSize));
|
|
1117
|
+
lruCache_class_private_field_set(this, _maxKeyLength, maxKeyLength);
|
|
1118
|
+
lruCache_class_private_field_set(this, _maxValueLength, maxValueLength);
|
|
1119
|
+
}
|
|
1120
|
+
lruCache_create_class(LRUCache, [
|
|
1121
|
+
{
|
|
1122
|
+
key: "get",
|
|
1123
|
+
value: function(key) {
|
|
1124
|
+
if ("string" != typeof key || key.length > lruCache_class_private_field_get(this, _maxKeyLength)) return;
|
|
1125
|
+
var value = lruCache_class_private_field_get(this, _map).get(key);
|
|
1126
|
+
if (void 0 === value) return;
|
|
1127
|
+
lruCache_class_private_field_get(this, _map)["delete"](key);
|
|
1128
|
+
lruCache_class_private_field_get(this, _map).set(key, value);
|
|
1129
|
+
return value;
|
|
1130
|
+
}
|
|
1131
|
+
},
|
|
1132
|
+
{
|
|
1133
|
+
key: "set",
|
|
1134
|
+
value: function(key, value) {
|
|
1135
|
+
if ("string" != typeof key || key.length > lruCache_class_private_field_get(this, _maxKeyLength)) return;
|
|
1136
|
+
if (value && value.length > lruCache_class_private_field_get(this, _maxValueLength)) return;
|
|
1137
|
+
if (lruCache_class_private_field_get(this, _map).size >= lruCache_class_private_field_get(this, _maxSize)) {
|
|
1138
|
+
var firstKey = lruCache_class_private_field_get(this, _map).keys().next().value;
|
|
1139
|
+
lruCache_class_private_field_get(this, _map)["delete"](firstKey);
|
|
1140
|
+
}
|
|
1141
|
+
lruCache_class_private_field_get(this, _map).set(key, value);
|
|
1142
|
+
}
|
|
1143
|
+
},
|
|
1144
|
+
{
|
|
1145
|
+
key: "size",
|
|
1146
|
+
get: function() {
|
|
1147
|
+
return lruCache_class_private_field_get(this, _map).size;
|
|
1148
|
+
}
|
|
1149
|
+
},
|
|
1150
|
+
{
|
|
1151
|
+
key: "clear",
|
|
1152
|
+
value: function() {
|
|
1153
|
+
lruCache_class_private_field_get(this, _map).clear();
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
]);
|
|
1157
|
+
return LRUCache;
|
|
1158
|
+
}();
|
|
1223
1159
|
function escape_type_of(obj) {
|
|
1224
1160
|
return obj && "undefined" != typeof Symbol && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
1225
1161
|
}
|
|
@@ -1231,110 +1167,168 @@ function escapeValue(value) {
|
|
|
1231
1167
|
if (value instanceof Date) return "'".concat(value.toISOString(), "'");
|
|
1232
1168
|
throw new TypeError("Unsupported parameter type: ".concat(void 0 === value ? "undefined" : escape_type_of(value)));
|
|
1233
1169
|
}
|
|
1234
|
-
|
|
1170
|
+
new lruCache_LRUCache({
|
|
1235
1171
|
maxSize: 256,
|
|
1236
1172
|
maxKeyLength: 4096
|
|
1237
1173
|
});
|
|
1238
|
-
function
|
|
1239
|
-
var segments =
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1174
|
+
function interpolateFromTemplate(template, params) {
|
|
1175
|
+
var segments = template.segments, paramCount = template.paramCount;
|
|
1176
|
+
if (params.length < paramCount) throw new Error("Too few parameters provided");
|
|
1177
|
+
if (params.length > paramCount) throw new Error("Too many parameters provided");
|
|
1178
|
+
if (0 === paramCount) return segments[0];
|
|
1179
|
+
var parts = [
|
|
1180
|
+
segments[0]
|
|
1181
|
+
];
|
|
1182
|
+
for(var i = 0; i < params.length; i++){
|
|
1183
|
+
parts.push(escapeValue(params[i]));
|
|
1184
|
+
parts.push(segments[i + 1]);
|
|
1185
|
+
}
|
|
1186
|
+
return parts.join("");
|
|
1187
|
+
}
|
|
1188
|
+
var constants_CC_SINGLE_QUOTE = 39;
|
|
1189
|
+
var constants_CC_DOUBLE_QUOTE = 34;
|
|
1190
|
+
var constants_CC_DASH = 45;
|
|
1191
|
+
var constants_CC_SLASH = 47;
|
|
1192
|
+
var constants_CC_STAR = 42;
|
|
1193
|
+
var constants_CC_NEWLINE = 10;
|
|
1194
|
+
var constants_CC_QUESTION = 63;
|
|
1195
|
+
var CC_SEMICOLON = 59;
|
|
1196
|
+
var CC_SPACE = 32;
|
|
1197
|
+
var constants_STATE_NORMAL = 0;
|
|
1198
|
+
var constants_STATE_SINGLE_QUOTE = 1;
|
|
1199
|
+
var constants_STATE_DOUBLE_QUOTE = 2;
|
|
1200
|
+
var constants_STATE_LINE_COMMENT = 3;
|
|
1201
|
+
var constants_STATE_BLOCK_COMMENT = 4;
|
|
1202
|
+
var _normDecoder = new TextDecoder("utf-16le");
|
|
1203
|
+
var _normCache = new lruCache_LRUCache({
|
|
1204
|
+
maxSize: 256,
|
|
1205
|
+
maxKeyLength: 4096
|
|
1206
|
+
});
|
|
1207
|
+
function _normalize(sql) {
|
|
1208
|
+
var len = sql.length;
|
|
1209
|
+
var needed = len + 1;
|
|
1210
|
+
var outCodes = new Uint16Array(needed);
|
|
1211
|
+
var writePos = 0;
|
|
1212
|
+
var pendingSpace = false;
|
|
1213
|
+
var state = constants_STATE_NORMAL;
|
|
1214
|
+
var questionPositions = [];
|
|
1215
|
+
for(var i = 0; i < len; i++){
|
|
1216
|
+
var code = sql.charCodeAt(i);
|
|
1217
|
+
var nextCode = sql.charCodeAt(i + 1);
|
|
1218
|
+
if (state === constants_STATE_BLOCK_COMMENT) {
|
|
1219
|
+
if (code === constants_CC_STAR && nextCode === constants_CC_SLASH) {
|
|
1220
|
+
state = constants_STATE_NORMAL;
|
|
1221
|
+
i++;
|
|
1222
|
+
if (writePos > 0) pendingSpace = true;
|
|
1250
1223
|
}
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1224
|
+
continue;
|
|
1225
|
+
}
|
|
1226
|
+
if (state === constants_STATE_LINE_COMMENT) {
|
|
1227
|
+
if (code === constants_CC_NEWLINE) {
|
|
1228
|
+
state = constants_STATE_NORMAL;
|
|
1229
|
+
if (writePos > 0) pendingSpace = true;
|
|
1255
1230
|
}
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1231
|
+
continue;
|
|
1232
|
+
}
|
|
1233
|
+
if (state === constants_STATE_NORMAL) {
|
|
1234
|
+
if (code === constants_CC_DASH && nextCode === constants_CC_DASH) {
|
|
1235
|
+
state = constants_STATE_LINE_COMMENT;
|
|
1236
|
+
i++;
|
|
1259
1237
|
continue;
|
|
1260
1238
|
}
|
|
1261
|
-
if (code ===
|
|
1262
|
-
state =
|
|
1263
|
-
|
|
1264
|
-
pos++;
|
|
1239
|
+
if (code === constants_CC_SLASH && nextCode === constants_CC_STAR) {
|
|
1240
|
+
state = constants_STATE_BLOCK_COMMENT;
|
|
1241
|
+
i++;
|
|
1265
1242
|
continue;
|
|
1266
1243
|
}
|
|
1267
|
-
if (code === CC_QUESTION) {
|
|
1268
|
-
segments.push(sql.slice(segStart, pos));
|
|
1269
|
-
segStart = pos + 1;
|
|
1270
|
-
}
|
|
1271
|
-
continue;
|
|
1272
1244
|
}
|
|
1273
|
-
if (
|
|
1274
|
-
if (
|
|
1275
|
-
if (sql.charCodeAt(pos + 1) === CC_SINGLE_QUOTE) {
|
|
1276
|
-
pos++;
|
|
1277
|
-
continue;
|
|
1278
|
-
}
|
|
1279
|
-
state = STATE_NORMAL;
|
|
1280
|
-
stateStartPos = -1;
|
|
1281
|
-
}
|
|
1245
|
+
if (32 === code || 9 === code || 10 === code || 11 === code || 12 === code || 13 === code) {
|
|
1246
|
+
if (writePos > 0) pendingSpace = true;
|
|
1282
1247
|
continue;
|
|
1283
1248
|
}
|
|
1284
|
-
if (
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1249
|
+
if (pendingSpace && writePos > 0) {
|
|
1250
|
+
outCodes[writePos++] = CC_SPACE;
|
|
1251
|
+
pendingSpace = false;
|
|
1252
|
+
}
|
|
1253
|
+
if (code === constants_CC_QUESTION && state === constants_STATE_NORMAL) questionPositions.push(writePos);
|
|
1254
|
+
outCodes[writePos++] = code;
|
|
1255
|
+
if (state === constants_STATE_NORMAL) {
|
|
1256
|
+
if (code === constants_CC_SINGLE_QUOTE) state = constants_STATE_SINGLE_QUOTE;
|
|
1257
|
+
else if (code === constants_CC_DOUBLE_QUOTE) state = constants_STATE_DOUBLE_QUOTE;
|
|
1293
1258
|
continue;
|
|
1294
1259
|
}
|
|
1295
|
-
if (state ===
|
|
1296
|
-
if (code ===
|
|
1260
|
+
if (state === constants_STATE_SINGLE_QUOTE) {
|
|
1261
|
+
if (code === constants_CC_SINGLE_QUOTE && nextCode === constants_CC_SINGLE_QUOTE) {
|
|
1262
|
+
outCodes[writePos++] = nextCode;
|
|
1263
|
+
i++;
|
|
1264
|
+
continue;
|
|
1265
|
+
}
|
|
1266
|
+
if (code === constants_CC_SINGLE_QUOTE) state = constants_STATE_NORMAL;
|
|
1297
1267
|
continue;
|
|
1298
1268
|
}
|
|
1299
|
-
if (state ===
|
|
1300
|
-
if (code ===
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1269
|
+
if (state === constants_STATE_DOUBLE_QUOTE) {
|
|
1270
|
+
if (code === constants_CC_DOUBLE_QUOTE && nextCode === constants_CC_DOUBLE_QUOTE) {
|
|
1271
|
+
outCodes[writePos++] = nextCode;
|
|
1272
|
+
i++;
|
|
1273
|
+
continue;
|
|
1304
1274
|
}
|
|
1275
|
+
if (code === constants_CC_DOUBLE_QUOTE) state = constants_STATE_NORMAL;
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
var normalized;
|
|
1279
|
+
if (0 === writePos) normalized = ";";
|
|
1280
|
+
else {
|
|
1281
|
+
while(writePos > 0 && outCodes[writePos - 1] === CC_SEMICOLON)writePos--;
|
|
1282
|
+
outCodes[writePos++] = CC_SEMICOLON;
|
|
1283
|
+
normalized = _normDecoder.decode(outCodes.subarray(0, writePos));
|
|
1284
|
+
}
|
|
1285
|
+
var paramCount = questionPositions.length;
|
|
1286
|
+
if (0 === paramCount) return {
|
|
1287
|
+
normalized: normalized,
|
|
1288
|
+
segments: [
|
|
1289
|
+
normalized
|
|
1290
|
+
],
|
|
1291
|
+
paramCount: 0
|
|
1292
|
+
};
|
|
1293
|
+
var segments = [];
|
|
1294
|
+
var segStart = 0;
|
|
1295
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
1296
|
+
try {
|
|
1297
|
+
for(var _iterator = questionPositions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1298
|
+
var pos = _step.value;
|
|
1299
|
+
segments.push(normalized.slice(segStart, pos));
|
|
1300
|
+
segStart = pos + 1;
|
|
1301
|
+
}
|
|
1302
|
+
} catch (err) {
|
|
1303
|
+
_didIteratorError = true;
|
|
1304
|
+
_iteratorError = err;
|
|
1305
|
+
} finally{
|
|
1306
|
+
try {
|
|
1307
|
+
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
1308
|
+
} finally{
|
|
1309
|
+
if (_didIteratorError) throw _iteratorError;
|
|
1305
1310
|
}
|
|
1306
1311
|
}
|
|
1307
|
-
|
|
1308
|
-
if (state === STATE_DOUBLE_QUOTE) throw new Error("Unterminated double-quoted identifier/string starting at position ".concat(stateStartPos + 1));
|
|
1309
|
-
if (state === STATE_BLOCK_COMMENT) throw new Error("Unterminated block comment starting at position ".concat(stateStartPos + 1));
|
|
1310
|
-
segments.push(sql.slice(segStart));
|
|
1312
|
+
segments.push(normalized.slice(segStart));
|
|
1311
1313
|
return {
|
|
1314
|
+
normalized: normalized,
|
|
1312
1315
|
segments: segments,
|
|
1313
|
-
paramCount:
|
|
1316
|
+
paramCount: paramCount
|
|
1314
1317
|
};
|
|
1315
1318
|
}
|
|
1316
|
-
function
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
var
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
if (0 === paramCount) return segments[0];
|
|
1330
|
-
var parts = [
|
|
1331
|
-
segments[0]
|
|
1332
|
-
];
|
|
1333
|
-
for(var i = 0; i < params.length; i++){
|
|
1334
|
-
parts.push(escapeValue(params[i]));
|
|
1335
|
-
parts.push(segments[i + 1]);
|
|
1336
|
-
}
|
|
1337
|
-
return parts.join("");
|
|
1319
|
+
function normalizeSQL(sql) {
|
|
1320
|
+
var cached = _normCache.get(sql);
|
|
1321
|
+
if (void 0 !== cached) return cached.normalized;
|
|
1322
|
+
var result = _normalize(sql);
|
|
1323
|
+
_normCache.set(sql, result);
|
|
1324
|
+
return result.normalized;
|
|
1325
|
+
}
|
|
1326
|
+
function normalizeSQLTemplate(sql) {
|
|
1327
|
+
var cached = _normCache.get(sql);
|
|
1328
|
+
if (void 0 !== cached) return cached;
|
|
1329
|
+
var result = _normalize(sql);
|
|
1330
|
+
_normCache.set(sql, result);
|
|
1331
|
+
return result;
|
|
1338
1332
|
}
|
|
1339
1333
|
var READ_ONLY_KINDS = new Set([
|
|
1340
1334
|
"SELECT",
|
|
@@ -1353,13 +1347,17 @@ function classifySingle(stmt) {
|
|
|
1353
1347
|
return READ_ONLY_KINDS.has(kind) ? "read" : "write";
|
|
1354
1348
|
}
|
|
1355
1349
|
function classifySQL(sql) {
|
|
1356
|
-
if ("string" != typeof sql
|
|
1350
|
+
if ("string" != typeof sql) return "write";
|
|
1357
1351
|
var cached = _classifyCache.get(sql);
|
|
1358
1352
|
if (void 0 !== cached) return cached;
|
|
1359
1353
|
var trimmed = sql.trim();
|
|
1354
|
+
if (0 === trimmed.length) return "write";
|
|
1360
1355
|
var result;
|
|
1361
1356
|
if (trimmed.includes(";")) {
|
|
1362
|
-
var stmts = trimmed.split(";")
|
|
1357
|
+
var stmts = trimmed.split(";").filter(function(s) {
|
|
1358
|
+
return s.trim().length > 0;
|
|
1359
|
+
});
|
|
1360
|
+
if (0 === stmts.length) return "write";
|
|
1363
1361
|
result = "read";
|
|
1364
1362
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
1365
1363
|
try {
|
|
@@ -1780,8 +1778,11 @@ function buildPayload(sql, token) {
|
|
|
1780
1778
|
return "".concat(normalized).concat(suffix, "\nSELECT '").concat(token, "' AS ").concat(TOKEN_COLUMN, ";\n");
|
|
1781
1779
|
}
|
|
1782
1780
|
function isTransactionControl(sql) {
|
|
1783
|
-
var
|
|
1784
|
-
|
|
1781
|
+
var f = sql.charCodeAt(0);
|
|
1782
|
+
if (66 === f || 98 === f) return "BEGIN" === sql || "BEGIN;" === sql || sql.startsWith("BEGIN ") || sql.startsWith("BEGIN;");
|
|
1783
|
+
if (67 === f || 99 === f) return "COMMIT" === sql || "COMMIT;" === sql || sql.startsWith("COMMIT ") || sql.startsWith("COMMIT;");
|
|
1784
|
+
if (82 === f || 114 === f) return "ROLLBACK" === sql || "ROLLBACK;" === sql || sql.startsWith("ROLLBACK ") || sql.startsWith("ROLLBACK;");
|
|
1785
|
+
return false;
|
|
1785
1786
|
}
|
|
1786
1787
|
function buildBatchPayload(batch) {
|
|
1787
1788
|
var useWalBatch = batch.length > 1 && batch.every(function(t) {
|
|
@@ -1847,43 +1848,21 @@ function buildBatchPayload(batch) {
|
|
|
1847
1848
|
}
|
|
1848
1849
|
return parts1.join("");
|
|
1849
1850
|
}
|
|
1851
|
+
var TC_FIRST_CHAR = TOKEN_COLUMN.charCodeAt(0);
|
|
1852
|
+
function buildSentinelStr(token) {
|
|
1853
|
+
return '[{"'.concat(TOKEN_COLUMN, '":"').concat(token, '"}]');
|
|
1854
|
+
}
|
|
1850
1855
|
function isSentinelRaw(raw, token) {
|
|
1851
|
-
return raw ===
|
|
1856
|
+
return raw.charCodeAt(3) === TC_FIRST_CHAR && raw === buildSentinelStr(token);
|
|
1852
1857
|
}
|
|
1853
1858
|
function isSentinelRow(value, token) {
|
|
1854
1859
|
var _value_;
|
|
1855
1860
|
return Array.isArray(value) && 1 === value.length && (null == (_value_ = value[0]) ? void 0 : _value_[TOKEN_COLUMN]) === token;
|
|
1856
1861
|
}
|
|
1857
|
-
function _array_like_to_array(arr, len) {
|
|
1858
|
-
if (null == len || len > arr.length) len = arr.length;
|
|
1859
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
1860
|
-
return arr2;
|
|
1861
|
-
}
|
|
1862
|
-
function _array_without_holes(arr) {
|
|
1863
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
1864
|
-
}
|
|
1865
|
-
function _iterable_to_array(iter) {
|
|
1866
|
-
if ("undefined" != typeof Symbol && null != iter[Symbol.iterator] || null != iter["@@iterator"]) return Array.from(iter);
|
|
1867
|
-
}
|
|
1868
|
-
function _non_iterable_spread() {
|
|
1869
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1870
|
-
}
|
|
1871
|
-
function _to_consumable_array(arr) {
|
|
1872
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
1873
|
-
}
|
|
1874
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
1875
|
-
if (!o) return;
|
|
1876
|
-
if ("string" == typeof o) return _array_like_to_array(o, minLen);
|
|
1877
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1878
|
-
if ("Object" === n && o.constructor) n = o.constructor.name;
|
|
1879
|
-
if ("Map" === n || "Set" === n) return Array.from(n);
|
|
1880
|
-
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
1881
|
-
}
|
|
1882
1862
|
function collectQueryRows(task, parsed) {
|
|
1883
1863
|
if (Array.isArray(parsed)) {
|
|
1884
|
-
var _task_rows;
|
|
1885
1864
|
if (!task.rows) task.rows = [];
|
|
1886
|
-
(
|
|
1865
|
+
for(var i = 0; i < parsed.length; i++)task.rows.push(parsed[i]);
|
|
1887
1866
|
}
|
|
1888
1867
|
}
|
|
1889
1868
|
function processStreamRows(task, parsed) {
|
|
@@ -1914,7 +1893,6 @@ function settleTask(task, error, value, metrics) {
|
|
|
1914
1893
|
var _ref = arguments.length > 4 && void 0 !== arguments[4] ? arguments[4] : {}, _ref_resetRowParser = _ref.resetRowParser, resetRowParser = void 0 === _ref_resetRowParser ? false : _ref_resetRowParser;
|
|
1915
1894
|
if (task.settled) return;
|
|
1916
1895
|
task.settled = true;
|
|
1917
|
-
clearTimeout(task.timer);
|
|
1918
1896
|
if (resetRowParser) {
|
|
1919
1897
|
var _task_rowParser_reset, _task_rowParser;
|
|
1920
1898
|
null == (_task_rowParser = task.rowParser) || null == (_task_rowParser_reset = _task_rowParser.reset) || _task_rowParser_reset.call(_task_rowParser);
|
|
@@ -1963,18 +1941,16 @@ function finalizePendingTasks(tasks, settle, pumpQueue) {
|
|
|
1963
1941
|
function prepareTaskTimeout(task, metrics) {
|
|
1964
1942
|
if (task.settled) return null;
|
|
1965
1943
|
task.timedout = true;
|
|
1966
|
-
clearTimeout(task.timer);
|
|
1967
|
-
task.timer = null;
|
|
1968
1944
|
null == metrics || metrics.incrementTasksTimeout();
|
|
1969
1945
|
return createTimeoutError(task.timeout, task.sql);
|
|
1970
1946
|
}
|
|
1971
|
-
function
|
|
1947
|
+
function _array_like_to_array(arr, len) {
|
|
1972
1948
|
if (null == len || len > arr.length) len = arr.length;
|
|
1973
1949
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
1974
1950
|
return arr2;
|
|
1975
1951
|
}
|
|
1976
|
-
function
|
|
1977
|
-
if (Array.isArray(arr)) return
|
|
1952
|
+
function _array_without_holes(arr) {
|
|
1953
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
1978
1954
|
}
|
|
1979
1955
|
function taskWorker_check_private_redeclaration(obj, privateCollection) {
|
|
1980
1956
|
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
@@ -1990,6 +1966,22 @@ function taskWorker_class_apply_descriptor_set(receiver, descriptor, value) {
|
|
|
1990
1966
|
descriptor.value = value;
|
|
1991
1967
|
}
|
|
1992
1968
|
}
|
|
1969
|
+
function taskWorker_class_apply_descriptor_update(receiver, descriptor) {
|
|
1970
|
+
if (descriptor.set) {
|
|
1971
|
+
if (!descriptor.get) throw new TypeError("attempted to read set only private field");
|
|
1972
|
+
if (!("__destrWrapper" in descriptor)) descriptor.__destrWrapper = {
|
|
1973
|
+
set value (v){
|
|
1974
|
+
descriptor.set.call(receiver, v);
|
|
1975
|
+
},
|
|
1976
|
+
get value () {
|
|
1977
|
+
return descriptor.get.call(receiver);
|
|
1978
|
+
}
|
|
1979
|
+
};
|
|
1980
|
+
return descriptor.__destrWrapper;
|
|
1981
|
+
}
|
|
1982
|
+
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
1983
|
+
return descriptor;
|
|
1984
|
+
}
|
|
1993
1985
|
function taskWorker_class_call_check(instance, Constructor) {
|
|
1994
1986
|
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
1995
1987
|
}
|
|
@@ -2010,6 +2002,10 @@ function taskWorker_class_private_field_set(receiver, privateMap, value) {
|
|
|
2010
2002
|
taskWorker_class_apply_descriptor_set(receiver, descriptor, value);
|
|
2011
2003
|
return value;
|
|
2012
2004
|
}
|
|
2005
|
+
function taskWorker_class_private_field_update(receiver, privateMap) {
|
|
2006
|
+
var descriptor = taskWorker_class_extract_field_descriptor(receiver, privateMap, "update");
|
|
2007
|
+
return taskWorker_class_apply_descriptor_update(receiver, descriptor);
|
|
2008
|
+
}
|
|
2013
2009
|
function taskWorker_class_private_method_get(receiver, privateSet, fn) {
|
|
2014
2010
|
if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
|
|
2015
2011
|
return fn;
|
|
@@ -2032,35 +2028,39 @@ function taskWorker_create_class(Constructor, protoProps, staticProps) {
|
|
|
2032
2028
|
if (staticProps) taskWorker_defineProperties(Constructor, staticProps);
|
|
2033
2029
|
return Constructor;
|
|
2034
2030
|
}
|
|
2035
|
-
function
|
|
2031
|
+
function _iterable_to_array(iter) {
|
|
2036
2032
|
if ("undefined" != typeof Symbol && null != iter[Symbol.iterator] || null != iter["@@iterator"]) return Array.from(iter);
|
|
2037
2033
|
}
|
|
2038
|
-
function
|
|
2034
|
+
function _non_iterable_spread() {
|
|
2039
2035
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2040
2036
|
}
|
|
2041
|
-
function
|
|
2042
|
-
return
|
|
2037
|
+
function _to_consumable_array(arr) {
|
|
2038
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
2043
2039
|
}
|
|
2044
|
-
function
|
|
2040
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
2045
2041
|
if (!o) return;
|
|
2046
|
-
if ("string" == typeof o) return
|
|
2042
|
+
if ("string" == typeof o) return _array_like_to_array(o, minLen);
|
|
2047
2043
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
2048
2044
|
if ("Object" === n && o.constructor) n = o.constructor.name;
|
|
2049
2045
|
if ("Map" === n || "Set" === n) return Array.from(n);
|
|
2050
|
-
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return
|
|
2046
|
+
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
2051
2047
|
}
|
|
2052
|
-
var _processManager = /*#__PURE__*/ new WeakMap(), _pendingQueue = /*#__PURE__*/ new WeakMap(), _inflightTasks = /*#__PURE__*/ new WeakMap(), _pendingFinalizeTasks = /*#__PURE__*/ new WeakMap(), _scheduledFinalize = /*#__PURE__*/ new WeakMap(), _valueParser = /*#__PURE__*/ new WeakMap(), _statementTimeout = /*#__PURE__*/ new WeakMap(), _logger = /*#__PURE__*/ new WeakMap(), _name = /*#__PURE__*/ new WeakMap(), _batchSize = /*#__PURE__*/ new WeakMap(), _maxInflight = /*#__PURE__*/ new WeakMap(), _metrics = /*#__PURE__*/ new WeakMap(), _startProcess = /*#__PURE__*/ new WeakSet(), _pumpQueue = /*#__PURE__*/ new WeakSet(), _handleParsedValue = /*#__PURE__*/ new WeakSet(), _scheduleFinalizeCheck = /*#__PURE__*/ new WeakSet(), _handleStderrChunk = /*#__PURE__*/ new WeakSet(), _handleTaskTimeout = /*#__PURE__*/ new WeakSet(), _settleTask = /*#__PURE__*/ new WeakSet(), _rejectAll = /*#__PURE__*/ new WeakSet();
|
|
2048
|
+
var _processManager = /*#__PURE__*/ new WeakMap(), _pendingQueue = /*#__PURE__*/ new WeakMap(), _inflightTasks = /*#__PURE__*/ new WeakMap(), _inflightHead = /*#__PURE__*/ new WeakMap(), _pendingFinalizeTasks = /*#__PURE__*/ new WeakMap(), _scheduledFinalize = /*#__PURE__*/ new WeakMap(), _valueParser = /*#__PURE__*/ new WeakMap(), _statementTimeout = /*#__PURE__*/ new WeakMap(), _logger = /*#__PURE__*/ new WeakMap(), _name = /*#__PURE__*/ new WeakMap(), _batchSize = /*#__PURE__*/ new WeakMap(), _maxInflight = /*#__PURE__*/ new WeakMap(), _metrics = /*#__PURE__*/ new WeakMap(), _sweepTimer = /*#__PURE__*/ new WeakMap(), _sweepIntervalMs = /*#__PURE__*/ new WeakMap(), _startProcess = /*#__PURE__*/ new WeakSet(), _inflightCount = /*#__PURE__*/ new WeakSet(), _firstInflight = /*#__PURE__*/ new WeakSet(), _shiftInflight = /*#__PURE__*/ new WeakSet(), _pumpQueue = /*#__PURE__*/ new WeakSet(), _handleParsedValue = /*#__PURE__*/ new WeakSet(), _scheduleFinalizeCheck = /*#__PURE__*/ new WeakSet(), _handleStderrChunk = /*#__PURE__*/ new WeakSet(), _scheduleSweep = /*#__PURE__*/ new WeakSet(), _handleTaskTimeout = /*#__PURE__*/ new WeakSet(), _settleTask = /*#__PURE__*/ new WeakSet(), _rejectAll = /*#__PURE__*/ new WeakSet();
|
|
2053
2049
|
var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
2054
2050
|
"use strict";
|
|
2055
2051
|
function TaskWorker(param) {
|
|
2056
2052
|
var _this = this;
|
|
2057
|
-
var binary = param.binary, database = param.database, statementTimeout = param.statementTimeout, logger = param.logger, name = param.name, initMode = param.initMode, _param_batchSize = param.batchSize, batchSize = void 0 === _param_batchSize ? DEFAULT_BATCH_SIZE : _param_batchSize, _param_maxInflight = param.maxInflight, maxInflight = void 0 === _param_maxInflight ? DEFAULT_MAX_INFLIGHT : _param_maxInflight, metrics = param.metrics;
|
|
2053
|
+
var binary = param.binary, database = param.database, statementTimeout = param.statementTimeout, logger = param.logger, name = param.name, initMode = param.initMode, _param_batchSize = param.batchSize, batchSize = void 0 === _param_batchSize ? DEFAULT_BATCH_SIZE : _param_batchSize, _param_maxInflight = param.maxInflight, maxInflight = void 0 === _param_maxInflight ? DEFAULT_MAX_INFLIGHT : _param_maxInflight, metrics = param.metrics, _param_sweepInterval = param.sweepInterval, sweepInterval = void 0 === _param_sweepInterval ? 100 : _param_sweepInterval;
|
|
2058
2054
|
taskWorker_class_call_check(this, TaskWorker);
|
|
2059
2055
|
taskWorker_class_private_method_init(this, _startProcess);
|
|
2056
|
+
taskWorker_class_private_method_init(this, _inflightCount);
|
|
2057
|
+
taskWorker_class_private_method_init(this, _firstInflight);
|
|
2058
|
+
taskWorker_class_private_method_init(this, _shiftInflight);
|
|
2060
2059
|
taskWorker_class_private_method_init(this, _pumpQueue);
|
|
2061
2060
|
taskWorker_class_private_method_init(this, _handleParsedValue);
|
|
2062
2061
|
taskWorker_class_private_method_init(this, _scheduleFinalizeCheck);
|
|
2063
2062
|
taskWorker_class_private_method_init(this, _handleStderrChunk);
|
|
2063
|
+
taskWorker_class_private_method_init(this, _scheduleSweep);
|
|
2064
2064
|
taskWorker_class_private_method_init(this, _handleTaskTimeout);
|
|
2065
2065
|
taskWorker_class_private_method_init(this, _settleTask);
|
|
2066
2066
|
taskWorker_class_private_method_init(this, _rejectAll);
|
|
@@ -2076,6 +2076,10 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2076
2076
|
writable: true,
|
|
2077
2077
|
value: []
|
|
2078
2078
|
});
|
|
2079
|
+
taskWorker_class_private_field_init(this, _inflightHead, {
|
|
2080
|
+
writable: true,
|
|
2081
|
+
value: 0
|
|
2082
|
+
});
|
|
2079
2083
|
taskWorker_class_private_field_init(this, _pendingFinalizeTasks, {
|
|
2080
2084
|
writable: true,
|
|
2081
2085
|
value: new Set()
|
|
@@ -2112,12 +2116,21 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2112
2116
|
writable: true,
|
|
2113
2117
|
value: void 0
|
|
2114
2118
|
});
|
|
2119
|
+
taskWorker_class_private_field_init(this, _sweepTimer, {
|
|
2120
|
+
writable: true,
|
|
2121
|
+
value: null
|
|
2122
|
+
});
|
|
2123
|
+
taskWorker_class_private_field_init(this, _sweepIntervalMs, {
|
|
2124
|
+
writable: true,
|
|
2125
|
+
value: void 0
|
|
2126
|
+
});
|
|
2115
2127
|
taskWorker_class_private_field_set(this, _name, null != name ? name : "worker");
|
|
2116
2128
|
taskWorker_class_private_field_set(this, _statementTimeout, statementTimeout);
|
|
2117
2129
|
taskWorker_class_private_field_set(this, _logger, logger);
|
|
2118
2130
|
taskWorker_class_private_field_set(this, _batchSize, batchSize);
|
|
2119
2131
|
taskWorker_class_private_field_set(this, _maxInflight, maxInflight);
|
|
2120
2132
|
taskWorker_class_private_field_set(this, _metrics, metrics);
|
|
2133
|
+
taskWorker_class_private_field_set(this, _sweepIntervalMs, sweepInterval);
|
|
2121
2134
|
taskWorker_class_private_field_set(this, _processManager, new process_ProcessManager({
|
|
2122
2135
|
binary: binary,
|
|
2123
2136
|
database: database,
|
|
@@ -2141,13 +2154,13 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2141
2154
|
{
|
|
2142
2155
|
key: "idle",
|
|
2143
2156
|
get: function() {
|
|
2144
|
-
return
|
|
2157
|
+
return taskWorker_class_private_field_get(this, _inflightTasks).length === taskWorker_class_private_field_get(this, _inflightHead) && taskWorker_class_private_field_get(this, _pendingQueue).isEmpty() && 0 === taskWorker_class_private_field_get(this, _pendingFinalizeTasks).size;
|
|
2145
2158
|
}
|
|
2146
2159
|
},
|
|
2147
2160
|
{
|
|
2148
2161
|
key: "pendingStatements",
|
|
2149
2162
|
get: function() {
|
|
2150
|
-
return taskWorker_class_private_field_get(this, _pendingQueue).size + taskWorker_class_private_field_get(this, _inflightTasks).length + taskWorker_class_private_field_get(this, _pendingFinalizeTasks).size;
|
|
2163
|
+
return taskWorker_class_private_field_get(this, _pendingQueue).size + (taskWorker_class_private_field_get(this, _inflightTasks).length - taskWorker_class_private_field_get(this, _inflightHead)) + taskWorker_class_private_field_get(this, _pendingFinalizeTasks).size;
|
|
2151
2164
|
}
|
|
2152
2165
|
},
|
|
2153
2166
|
{
|
|
@@ -2167,8 +2180,6 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2167
2180
|
consumerError: null,
|
|
2168
2181
|
stderrText: "",
|
|
2169
2182
|
settled: false,
|
|
2170
|
-
errorScheduled: false,
|
|
2171
|
-
timer: null,
|
|
2172
2183
|
startTime: 0
|
|
2173
2184
|
};
|
|
2174
2185
|
null == (_$_class_private_field_get = taskWorker_class_private_field_get(this, _metrics)) || _$_class_private_field_get.incrementTasksTotal(config.kind);
|
|
@@ -2176,6 +2187,12 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2176
2187
|
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2177
2188
|
}
|
|
2178
2189
|
},
|
|
2190
|
+
{
|
|
2191
|
+
key: "_sweepTimer",
|
|
2192
|
+
get: function() {
|
|
2193
|
+
return taskWorker_class_private_field_get(this, _sweepTimer);
|
|
2194
|
+
}
|
|
2195
|
+
},
|
|
2179
2196
|
{
|
|
2180
2197
|
key: "_process",
|
|
2181
2198
|
get: function() {
|
|
@@ -2185,6 +2202,8 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2185
2202
|
{
|
|
2186
2203
|
key: "kill",
|
|
2187
2204
|
value: function() {
|
|
2205
|
+
clearTimeout(taskWorker_class_private_field_get(this, _sweepTimer));
|
|
2206
|
+
taskWorker_class_private_field_set(this, _sweepTimer, null);
|
|
2188
2207
|
taskWorker_class_private_method_get(this, _rejectAll, taskWorker_rejectAll).call(this, new Error("".concat(taskWorker_class_private_field_get(this, _name), " is killed")));
|
|
2189
2208
|
taskWorker_class_private_field_get(this, _processManager).kill();
|
|
2190
2209
|
}
|
|
@@ -2213,15 +2232,33 @@ function startProcess() {
|
|
|
2213
2232
|
taskWorker_class_private_method_get(_this, _rejectAll, taskWorker_rejectAll).call(_this, err);
|
|
2214
2233
|
});
|
|
2215
2234
|
}
|
|
2235
|
+
function inflightCount() {
|
|
2236
|
+
return taskWorker_class_private_field_get(this, _inflightTasks).length - taskWorker_class_private_field_get(this, _inflightHead);
|
|
2237
|
+
}
|
|
2238
|
+
function firstInflight() {
|
|
2239
|
+
return taskWorker_class_private_field_get(this, _inflightHead) < taskWorker_class_private_field_get(this, _inflightTasks).length ? taskWorker_class_private_field_get(this, _inflightTasks)[taskWorker_class_private_field_get(this, _inflightHead)] : null;
|
|
2240
|
+
}
|
|
2241
|
+
function shiftInflight() {
|
|
2242
|
+
var task = taskWorker_class_private_field_get(this, _inflightTasks)[taskWorker_class_private_field_get(this, _inflightHead)];
|
|
2243
|
+
taskWorker_class_private_field_get(this, _inflightTasks)[taskWorker_class_private_field_get(this, _inflightHead)] = null;
|
|
2244
|
+
taskWorker_class_private_field_update(this, _inflightHead).value++;
|
|
2245
|
+
if (taskWorker_class_private_field_get(this, _inflightHead) >= taskWorker_class_private_field_get(this, _inflightTasks).length) {
|
|
2246
|
+
taskWorker_class_private_field_set(this, _inflightTasks, []);
|
|
2247
|
+
taskWorker_class_private_field_set(this, _inflightHead, 0);
|
|
2248
|
+
} else if (taskWorker_class_private_field_get(this, _inflightHead) > 128) {
|
|
2249
|
+
taskWorker_class_private_field_set(this, _inflightTasks, taskWorker_class_private_field_get(this, _inflightTasks).slice(taskWorker_class_private_field_get(this, _inflightHead)));
|
|
2250
|
+
taskWorker_class_private_field_set(this, _inflightHead, 0);
|
|
2251
|
+
}
|
|
2252
|
+
return task;
|
|
2253
|
+
}
|
|
2216
2254
|
function taskWorker_pumpQueue() {
|
|
2217
|
-
var _this = this;
|
|
2218
2255
|
var _$_class_private_field_get;
|
|
2219
2256
|
if (taskWorker_class_private_field_get(this, _processManager).draining) return;
|
|
2220
|
-
if (
|
|
2257
|
+
if (taskWorker_class_private_method_get(this, _inflightCount, inflightCount).call(this) >= taskWorker_class_private_field_get(this, _maxInflight)) return;
|
|
2221
2258
|
var batch = [];
|
|
2222
|
-
while(batch.length < taskWorker_class_private_field_get(this, _batchSize) && !taskWorker_class_private_field_get(this, _pendingQueue).isEmpty() &&
|
|
2259
|
+
while(batch.length < taskWorker_class_private_field_get(this, _batchSize) && !taskWorker_class_private_field_get(this, _pendingQueue).isEmpty() && taskWorker_class_private_method_get(this, _inflightCount, inflightCount).call(this) + batch.length < taskWorker_class_private_field_get(this, _maxInflight)){
|
|
2223
2260
|
var task = taskWorker_class_private_field_get(this, _pendingQueue).peek();
|
|
2224
|
-
if ("stream" === task.kind && (batch.length > 0 ||
|
|
2261
|
+
if ("stream" === task.kind && (batch.length > 0 || taskWorker_class_private_method_get(this, _inflightCount, inflightCount).call(this) > 0)) break;
|
|
2225
2262
|
taskWorker_class_private_field_get(this, _pendingQueue).dequeue();
|
|
2226
2263
|
batch.push(task);
|
|
2227
2264
|
}
|
|
@@ -2230,15 +2267,10 @@ function taskWorker_pumpQueue() {
|
|
|
2230
2267
|
var payload = buildBatchPayload(batch);
|
|
2231
2268
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
2232
2269
|
try {
|
|
2233
|
-
var
|
|
2234
|
-
var
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
task.timer = setTimeout(function() {
|
|
2238
|
-
return taskWorker_class_private_method_get(_this, _handleTaskTimeout, handleTaskTimeout).call(_this, task);
|
|
2239
|
-
}, null != (_task_timeout = task.timeout) ? _task_timeout : taskWorker_class_private_field_get(_this1, _statementTimeout));
|
|
2240
|
-
};
|
|
2241
|
-
for(var _iterator = batch[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_this1 = this, _loop();
|
|
2270
|
+
for(var _iterator = batch[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2271
|
+
var task1 = _step.value;
|
|
2272
|
+
task1.startTime = now;
|
|
2273
|
+
}
|
|
2242
2274
|
} catch (err) {
|
|
2243
2275
|
_didIteratorError = true;
|
|
2244
2276
|
_iteratorError = err;
|
|
@@ -2249,15 +2281,15 @@ function taskWorker_pumpQueue() {
|
|
|
2249
2281
|
if (_didIteratorError) throw _iteratorError;
|
|
2250
2282
|
}
|
|
2251
2283
|
}
|
|
2252
|
-
(_$_class_private_field_get = taskWorker_class_private_field_get(this, _inflightTasks)).push.apply(_$_class_private_field_get,
|
|
2284
|
+
(_$_class_private_field_get = taskWorker_class_private_field_get(this, _inflightTasks)).push.apply(_$_class_private_field_get, _to_consumable_array(batch));
|
|
2285
|
+
taskWorker_class_private_method_get(this, _scheduleSweep, scheduleSweep).call(this);
|
|
2253
2286
|
taskWorker_class_private_field_get(this, _processManager).write(payload);
|
|
2254
2287
|
}
|
|
2255
2288
|
function handleParsedValue(raw) {
|
|
2256
|
-
var task =
|
|
2289
|
+
var task = taskWorker_class_private_method_get(this, _firstInflight, firstInflight).call(this);
|
|
2257
2290
|
if (!task) return;
|
|
2258
2291
|
if (isSentinelRaw(raw, task.token)) {
|
|
2259
|
-
|
|
2260
|
-
taskWorker_class_private_field_get(this, _inflightTasks).shift();
|
|
2292
|
+
taskWorker_class_private_method_get(this, _shiftInflight, shiftInflight).call(this);
|
|
2261
2293
|
if (task.timedout) return void taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2262
2294
|
if (task.stderrText) {
|
|
2263
2295
|
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, new Error(task.stderrText.trim()), void 0);
|
|
@@ -2283,8 +2315,7 @@ function handleParsedValue(raw) {
|
|
|
2283
2315
|
return;
|
|
2284
2316
|
}
|
|
2285
2317
|
if (isSentinelRow(parsed, task.token)) {
|
|
2286
|
-
|
|
2287
|
-
taskWorker_class_private_field_get(this, _inflightTasks).shift();
|
|
2318
|
+
taskWorker_class_private_method_get(this, _shiftInflight, shiftInflight).call(this);
|
|
2288
2319
|
if (task.timedout) return void taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2289
2320
|
if (task.stderrText) {
|
|
2290
2321
|
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, new Error(task.stderrText.trim()), void 0);
|
|
@@ -2301,6 +2332,7 @@ function handleParsedValue(raw) {
|
|
|
2301
2332
|
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2302
2333
|
return;
|
|
2303
2334
|
}
|
|
2335
|
+
if (task.timedout) return;
|
|
2304
2336
|
if ("query" === task.kind) return void collectQueryRows(task, parsed);
|
|
2305
2337
|
if ("stream" === task.kind) processStreamRows(task, parsed);
|
|
2306
2338
|
}
|
|
@@ -2318,14 +2350,29 @@ function scheduleFinalizeCheck() {
|
|
|
2318
2350
|
});
|
|
2319
2351
|
}
|
|
2320
2352
|
function taskWorker_handleStderrChunk(chunk) {
|
|
2321
|
-
var
|
|
2322
|
-
var task = null != (
|
|
2353
|
+
var _class_private_field_get_values_next_value;
|
|
2354
|
+
var task = null != (_class_private_field_get_values_next_value = taskWorker_class_private_field_get(this, _pendingFinalizeTasks).values().next().value) ? _class_private_field_get_values_next_value : taskWorker_class_private_method_get(this, _firstInflight, firstInflight).call(this);
|
|
2323
2355
|
if (!task) {
|
|
2324
2356
|
var _class_private_field_get_error, _$_class_private_field_get;
|
|
2325
|
-
null == (_$_class_private_field_get = taskWorker_class_private_field_get(this, _logger)) || null == (_class_private_field_get_error = _$_class_private_field_get.error) || _class_private_field_get_error.call(_$_class_private_field_get,
|
|
2357
|
+
null == (_$_class_private_field_get = taskWorker_class_private_field_get(this, _logger)) || null == (_class_private_field_get_error = _$_class_private_field_get.error) || _class_private_field_get_error.call(_$_class_private_field_get, chunk.trim());
|
|
2326
2358
|
return;
|
|
2327
2359
|
}
|
|
2328
|
-
task.stderrText +=
|
|
2360
|
+
task.stderrText += chunk;
|
|
2361
|
+
}
|
|
2362
|
+
function scheduleSweep() {
|
|
2363
|
+
var _this = this;
|
|
2364
|
+
if (taskWorker_class_private_field_get(this, _sweepTimer)) return;
|
|
2365
|
+
taskWorker_class_private_field_set(this, _sweepTimer, setTimeout(function() {
|
|
2366
|
+
taskWorker_class_private_field_set(_this, _sweepTimer, null);
|
|
2367
|
+
var tasks = taskWorker_class_private_field_get(_this, _inflightTasks);
|
|
2368
|
+
var head = taskWorker_class_private_field_get(_this, _inflightHead);
|
|
2369
|
+
var now = performance.now();
|
|
2370
|
+
for(var i = head; i < tasks.length; i++){
|
|
2371
|
+
var task = tasks[i];
|
|
2372
|
+
if (now - task.startTime > task.timeout) taskWorker_class_private_method_get(_this, _handleTaskTimeout, handleTaskTimeout).call(_this, task);
|
|
2373
|
+
}
|
|
2374
|
+
if (taskWorker_class_private_method_get(_this, _inflightCount, inflightCount).call(_this) > 0) taskWorker_class_private_method_get(_this, _scheduleSweep, scheduleSweep).call(_this);
|
|
2375
|
+
}, taskWorker_class_private_field_get(this, _sweepIntervalMs)).unref());
|
|
2329
2376
|
}
|
|
2330
2377
|
function handleTaskTimeout(task) {
|
|
2331
2378
|
var error = prepareTaskTimeout(task, taskWorker_class_private_field_get(this, _metrics));
|
|
@@ -2335,8 +2382,12 @@ function settleTask1(task, error, value) {
|
|
|
2335
2382
|
settleTask(task, error, value, taskWorker_class_private_field_get(this, _metrics));
|
|
2336
2383
|
}
|
|
2337
2384
|
function taskWorker_rejectAll(error) {
|
|
2338
|
-
|
|
2385
|
+
clearTimeout(taskWorker_class_private_field_get(this, _sweepTimer));
|
|
2386
|
+
taskWorker_class_private_field_set(this, _sweepTimer, null);
|
|
2387
|
+
var activeCount = taskWorker_class_private_field_get(this, _inflightTasks).length - taskWorker_class_private_field_get(this, _inflightHead);
|
|
2388
|
+
var all = activeCount > 0 ? taskWorker_class_private_field_get(this, _inflightTasks).slice(taskWorker_class_private_field_get(this, _inflightHead)) : [];
|
|
2339
2389
|
taskWorker_class_private_field_set(this, _inflightTasks, []);
|
|
2390
|
+
taskWorker_class_private_field_set(this, _inflightHead, 0);
|
|
2340
2391
|
var queued = taskWorker_class_private_field_get(this, _pendingQueue).dequeue();
|
|
2341
2392
|
while(queued){
|
|
2342
2393
|
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, queued, error, void 0);
|
|
@@ -2470,9 +2521,19 @@ var readerPool_ReaderPool = /*#__PURE__*/ function() {
|
|
|
2470
2521
|
{
|
|
2471
2522
|
key: "enqueue",
|
|
2472
2523
|
value: function(task) {
|
|
2473
|
-
var
|
|
2524
|
+
var minLoad = 1 / 0;
|
|
2525
|
+
var candidates = [];
|
|
2526
|
+
for(var i = 0; i < readerPool_class_private_field_get(this, _workers).length; i++){
|
|
2527
|
+
var load = readerPool_class_private_field_get(this, _workers)[i].pendingStatements;
|
|
2528
|
+
if (load < minLoad) {
|
|
2529
|
+
minLoad = load;
|
|
2530
|
+
candidates.length = 0;
|
|
2531
|
+
candidates.push(i);
|
|
2532
|
+
} else if (load === minLoad) candidates.push(i);
|
|
2533
|
+
}
|
|
2534
|
+
var idx = candidates[readerPool_class_private_field_get(this, _rrIndex) % candidates.length];
|
|
2474
2535
|
readerPool_class_private_field_set(this, _rrIndex, readerPool_class_private_field_get(this, _rrIndex) + 1 >>> 0);
|
|
2475
|
-
|
|
2536
|
+
readerPool_class_private_field_get(this, _workers)[idx].enqueue(task);
|
|
2476
2537
|
}
|
|
2477
2538
|
},
|
|
2478
2539
|
{
|
|
@@ -2965,9 +3026,7 @@ var transactionScope_TransactionScope = /*#__PURE__*/ function() {
|
|
|
2965
3026
|
release = resolve;
|
|
2966
3027
|
});
|
|
2967
3028
|
previous = transactionScope_class_private_field_get(_this, _scopeChain);
|
|
2968
|
-
transactionScope_class_private_field_set(_this, _scopeChain,
|
|
2969
|
-
return gate;
|
|
2970
|
-
}));
|
|
3029
|
+
transactionScope_class_private_field_set(_this, _scopeChain, gate);
|
|
2971
3030
|
return [
|
|
2972
3031
|
4,
|
|
2973
3032
|
previous["catch"](function() {})
|
|
@@ -3034,6 +3093,22 @@ function pipelineEngine_class_apply_descriptor_set(receiver, descriptor, value)
|
|
|
3034
3093
|
descriptor.value = value;
|
|
3035
3094
|
}
|
|
3036
3095
|
}
|
|
3096
|
+
function pipelineEngine_class_apply_descriptor_update(receiver, descriptor) {
|
|
3097
|
+
if (descriptor.set) {
|
|
3098
|
+
if (!descriptor.get) throw new TypeError("attempted to read set only private field");
|
|
3099
|
+
if (!("__destrWrapper" in descriptor)) descriptor.__destrWrapper = {
|
|
3100
|
+
set value (v){
|
|
3101
|
+
descriptor.set.call(receiver, v);
|
|
3102
|
+
},
|
|
3103
|
+
get value () {
|
|
3104
|
+
return descriptor.get.call(receiver);
|
|
3105
|
+
}
|
|
3106
|
+
};
|
|
3107
|
+
return descriptor.__destrWrapper;
|
|
3108
|
+
}
|
|
3109
|
+
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
3110
|
+
return descriptor;
|
|
3111
|
+
}
|
|
3037
3112
|
function pipelineEngine_class_call_check(instance, Constructor) {
|
|
3038
3113
|
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
3039
3114
|
}
|
|
@@ -3054,6 +3129,10 @@ function pipelineEngine_class_private_field_set(receiver, privateMap, value) {
|
|
|
3054
3129
|
pipelineEngine_class_apply_descriptor_set(receiver, descriptor, value);
|
|
3055
3130
|
return value;
|
|
3056
3131
|
}
|
|
3132
|
+
function pipelineEngine_class_private_field_update(receiver, privateMap) {
|
|
3133
|
+
var descriptor = pipelineEngine_class_extract_field_descriptor(receiver, privateMap, "update");
|
|
3134
|
+
return pipelineEngine_class_apply_descriptor_update(receiver, descriptor);
|
|
3135
|
+
}
|
|
3057
3136
|
function pipelineEngine_class_private_method_get(receiver, privateSet, fn) {
|
|
3058
3137
|
if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
|
|
3059
3138
|
return fn;
|
|
@@ -3093,16 +3172,20 @@ function pipelineEngine_unsupported_iterable_to_array(o, minLen) {
|
|
|
3093
3172
|
if ("Map" === n || "Set" === n) return Array.from(n);
|
|
3094
3173
|
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return pipelineEngine_array_like_to_array(o, minLen);
|
|
3095
3174
|
}
|
|
3096
|
-
var _queue = /*#__PURE__*/ new WeakMap(), pipelineEngine_inflightTasks = /*#__PURE__*/ new WeakMap(), pipelineEngine_pendingFinalizeTasks = /*#__PURE__*/ new WeakMap(), pipelineEngine_scheduledFinalize = /*#__PURE__*/ new WeakMap(), _sharedValueParser = /*#__PURE__*/ new WeakMap(), pipelineEngine_processManager = /*#__PURE__*/ new WeakMap(), pipelineEngine_metrics = /*#__PURE__*/ new WeakMap(), pipelineEngine_statementTimeout = /*#__PURE__*/ new WeakMap(), pipelineEngine_logger = /*#__PURE__*/ new WeakMap(), pipelineEngine_batchSize = /*#__PURE__*/ new WeakMap(), pipelineEngine_maxInflight = /*#__PURE__*/ new WeakMap(), _onTaskTimeout = /*#__PURE__*/ new WeakMap(), _active = /*#__PURE__*/ new WeakMap(), core_pipelineEngine_pumpQueue = /*#__PURE__*/ new WeakSet(), pipelineEngine_handleParsedValue = /*#__PURE__*/ new WeakSet(), core_pipelineEngine_scheduleFinalizeCheck = /*#__PURE__*/ new WeakSet(), core_pipelineEngine_handleTaskTimeout = /*#__PURE__*/ new WeakSet(), pipelineEngine_settleTask = /*#__PURE__*/ new WeakSet();
|
|
3175
|
+
var _queue = /*#__PURE__*/ new WeakMap(), pipelineEngine_inflightTasks = /*#__PURE__*/ new WeakMap(), pipelineEngine_inflightHead = /*#__PURE__*/ new WeakMap(), pipelineEngine_pendingFinalizeTasks = /*#__PURE__*/ new WeakMap(), pipelineEngine_scheduledFinalize = /*#__PURE__*/ new WeakMap(), _sharedValueParser = /*#__PURE__*/ new WeakMap(), pipelineEngine_processManager = /*#__PURE__*/ new WeakMap(), pipelineEngine_metrics = /*#__PURE__*/ new WeakMap(), pipelineEngine_statementTimeout = /*#__PURE__*/ new WeakMap(), pipelineEngine_logger = /*#__PURE__*/ new WeakMap(), pipelineEngine_batchSize = /*#__PURE__*/ new WeakMap(), pipelineEngine_maxInflight = /*#__PURE__*/ new WeakMap(), _onTaskTimeout = /*#__PURE__*/ new WeakMap(), _active = /*#__PURE__*/ new WeakMap(), pipelineEngine_sweepTimer = /*#__PURE__*/ new WeakMap(), pipelineEngine_sweepIntervalMs = /*#__PURE__*/ new WeakMap(), pipelineEngine_inflightCount = /*#__PURE__*/ new WeakSet(), core_pipelineEngine_firstInflight = /*#__PURE__*/ new WeakSet(), core_pipelineEngine_shiftInflight = /*#__PURE__*/ new WeakSet(), core_pipelineEngine_pumpQueue = /*#__PURE__*/ new WeakSet(), pipelineEngine_handleParsedValue = /*#__PURE__*/ new WeakSet(), core_pipelineEngine_scheduleFinalizeCheck = /*#__PURE__*/ new WeakSet(), pipelineEngine_scheduleSweep = /*#__PURE__*/ new WeakSet(), core_pipelineEngine_handleTaskTimeout = /*#__PURE__*/ new WeakSet(), pipelineEngine_settleTask = /*#__PURE__*/ new WeakSet();
|
|
3097
3176
|
var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
3098
3177
|
"use strict";
|
|
3099
3178
|
function PipelineEngine(processManager, param) {
|
|
3100
3179
|
var _this = this;
|
|
3101
|
-
var metrics = param.metrics, statementTimeout = param.statementTimeout, logger = param.logger, _param_batchSize = param.batchSize, batchSize = void 0 === _param_batchSize ? DEFAULT_BATCH_SIZE : _param_batchSize, _param_maxInflight = param.maxInflight, maxInflight = void 0 === _param_maxInflight ? DEFAULT_MAX_INFLIGHT : _param_maxInflight, onTaskTimeout = param.onTaskTimeout;
|
|
3180
|
+
var metrics = param.metrics, statementTimeout = param.statementTimeout, logger = param.logger, _param_batchSize = param.batchSize, batchSize = void 0 === _param_batchSize ? DEFAULT_BATCH_SIZE : _param_batchSize, _param_maxInflight = param.maxInflight, maxInflight = void 0 === _param_maxInflight ? DEFAULT_MAX_INFLIGHT : _param_maxInflight, onTaskTimeout = param.onTaskTimeout, _param_sweepInterval = param.sweepInterval, sweepInterval = void 0 === _param_sweepInterval ? 100 : _param_sweepInterval;
|
|
3102
3181
|
pipelineEngine_class_call_check(this, PipelineEngine);
|
|
3182
|
+
pipelineEngine_class_private_method_init(this, pipelineEngine_inflightCount);
|
|
3183
|
+
pipelineEngine_class_private_method_init(this, core_pipelineEngine_firstInflight);
|
|
3184
|
+
pipelineEngine_class_private_method_init(this, core_pipelineEngine_shiftInflight);
|
|
3103
3185
|
pipelineEngine_class_private_method_init(this, core_pipelineEngine_pumpQueue);
|
|
3104
3186
|
pipelineEngine_class_private_method_init(this, pipelineEngine_handleParsedValue);
|
|
3105
3187
|
pipelineEngine_class_private_method_init(this, core_pipelineEngine_scheduleFinalizeCheck);
|
|
3188
|
+
pipelineEngine_class_private_method_init(this, pipelineEngine_scheduleSweep);
|
|
3106
3189
|
pipelineEngine_class_private_method_init(this, core_pipelineEngine_handleTaskTimeout);
|
|
3107
3190
|
pipelineEngine_class_private_method_init(this, pipelineEngine_settleTask);
|
|
3108
3191
|
pipelineEngine_class_private_field_init(this, _queue, {
|
|
@@ -3113,6 +3196,10 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3113
3196
|
writable: true,
|
|
3114
3197
|
value: []
|
|
3115
3198
|
});
|
|
3199
|
+
pipelineEngine_class_private_field_init(this, pipelineEngine_inflightHead, {
|
|
3200
|
+
writable: true,
|
|
3201
|
+
value: 0
|
|
3202
|
+
});
|
|
3116
3203
|
pipelineEngine_class_private_field_init(this, pipelineEngine_pendingFinalizeTasks, {
|
|
3117
3204
|
writable: true,
|
|
3118
3205
|
value: new Set()
|
|
@@ -3157,6 +3244,14 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3157
3244
|
writable: true,
|
|
3158
3245
|
value: false
|
|
3159
3246
|
});
|
|
3247
|
+
pipelineEngine_class_private_field_init(this, pipelineEngine_sweepTimer, {
|
|
3248
|
+
writable: true,
|
|
3249
|
+
value: null
|
|
3250
|
+
});
|
|
3251
|
+
pipelineEngine_class_private_field_init(this, pipelineEngine_sweepIntervalMs, {
|
|
3252
|
+
writable: true,
|
|
3253
|
+
value: void 0
|
|
3254
|
+
});
|
|
3160
3255
|
pipelineEngine_class_private_field_set(this, pipelineEngine_processManager, processManager);
|
|
3161
3256
|
pipelineEngine_class_private_field_set(this, pipelineEngine_metrics, metrics);
|
|
3162
3257
|
pipelineEngine_class_private_field_set(this, pipelineEngine_statementTimeout, statementTimeout);
|
|
@@ -3170,8 +3265,15 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3170
3265
|
pipelineEngine_class_private_field_get(this, pipelineEngine_processManager).setOnDrainCallback(function() {
|
|
3171
3266
|
return pipelineEngine_class_private_method_get(_this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(_this);
|
|
3172
3267
|
});
|
|
3268
|
+
pipelineEngine_class_private_field_set(this, pipelineEngine_sweepIntervalMs, sweepInterval);
|
|
3173
3269
|
}
|
|
3174
3270
|
pipelineEngine_create_class(PipelineEngine, [
|
|
3271
|
+
{
|
|
3272
|
+
key: "_sweepTimer",
|
|
3273
|
+
get: function() {
|
|
3274
|
+
return pipelineEngine_class_private_field_get(this, pipelineEngine_sweepTimer);
|
|
3275
|
+
}
|
|
3276
|
+
},
|
|
3175
3277
|
{
|
|
3176
3278
|
key: "mainQueue",
|
|
3177
3279
|
get: function() {
|
|
@@ -3187,7 +3289,7 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3187
3289
|
{
|
|
3188
3290
|
key: "pendingStatements",
|
|
3189
3291
|
get: function() {
|
|
3190
|
-
return pipelineEngine_class_private_field_get(this, _queue).size + pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).length + pipelineEngine_class_private_field_get(this, pipelineEngine_pendingFinalizeTasks).size;
|
|
3292
|
+
return pipelineEngine_class_private_field_get(this, _queue).size + (pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).length - pipelineEngine_class_private_field_get(this, pipelineEngine_inflightHead)) + pipelineEngine_class_private_field_get(this, pipelineEngine_pendingFinalizeTasks).size;
|
|
3191
3293
|
}
|
|
3192
3294
|
},
|
|
3193
3295
|
{
|
|
@@ -3220,9 +3322,9 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3220
3322
|
{
|
|
3221
3323
|
key: "handleStdoutChunk",
|
|
3222
3324
|
value: function(chunk) {
|
|
3223
|
-
var task =
|
|
3325
|
+
var task = pipelineEngine_class_private_method_get(this, core_pipelineEngine_firstInflight, pipelineEngine_firstInflight).call(this);
|
|
3224
3326
|
if (!task) return;
|
|
3225
|
-
if ("stream" === task.kind && task.rowParser && !task.rowParser.finished) {
|
|
3327
|
+
if ("stream" === task.kind && task.rowParser && !task.rowParser.finished && !task.timedout) {
|
|
3226
3328
|
var leftover = task.rowParser.feed(chunk);
|
|
3227
3329
|
if (leftover) pipelineEngine_class_private_field_get(this, _sharedValueParser).feed(leftover);
|
|
3228
3330
|
return;
|
|
@@ -3234,20 +3336,23 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3234
3336
|
key: "handleStderrChunk",
|
|
3235
3337
|
value: function(chunk) {
|
|
3236
3338
|
var _class_private_field_get_values_next_value;
|
|
3237
|
-
var task = null != (_class_private_field_get_values_next_value = pipelineEngine_class_private_field_get(this, pipelineEngine_pendingFinalizeTasks).values().next().value) ? _class_private_field_get_values_next_value :
|
|
3339
|
+
var task = null != (_class_private_field_get_values_next_value = pipelineEngine_class_private_field_get(this, pipelineEngine_pendingFinalizeTasks).values().next().value) ? _class_private_field_get_values_next_value : pipelineEngine_class_private_method_get(this, core_pipelineEngine_firstInflight, pipelineEngine_firstInflight).call(this);
|
|
3238
3340
|
if (!task) {
|
|
3239
3341
|
var _class_private_field_get_error, _$_class_private_field_get;
|
|
3240
|
-
null == (_$_class_private_field_get = pipelineEngine_class_private_field_get(this, pipelineEngine_logger)) || null == (_class_private_field_get_error = _$_class_private_field_get.error) || _class_private_field_get_error.call(_$_class_private_field_get,
|
|
3342
|
+
null == (_$_class_private_field_get = pipelineEngine_class_private_field_get(this, pipelineEngine_logger)) || null == (_class_private_field_get_error = _$_class_private_field_get.error) || _class_private_field_get_error.call(_$_class_private_field_get, chunk.trim());
|
|
3241
3343
|
return;
|
|
3242
3344
|
}
|
|
3243
|
-
task.stderrText +=
|
|
3345
|
+
task.stderrText += chunk;
|
|
3244
3346
|
}
|
|
3245
3347
|
},
|
|
3246
3348
|
{
|
|
3247
3349
|
key: "rejectAll",
|
|
3248
3350
|
value: function(error) {
|
|
3249
|
-
|
|
3351
|
+
pipelineEngine_class_private_field_get(this, _sharedValueParser).reset();
|
|
3352
|
+
var activeCount = pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).length - pipelineEngine_class_private_field_get(this, pipelineEngine_inflightHead);
|
|
3353
|
+
var all = activeCount > 0 ? pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).slice(pipelineEngine_class_private_field_get(this, pipelineEngine_inflightHead)) : [];
|
|
3250
3354
|
pipelineEngine_class_private_field_set(this, pipelineEngine_inflightTasks, []);
|
|
3355
|
+
pipelineEngine_class_private_field_set(this, pipelineEngine_inflightHead, 0);
|
|
3251
3356
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
3252
3357
|
try {
|
|
3253
3358
|
for(var _iterator = all[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
@@ -3292,22 +3397,42 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3292
3397
|
key: "kill",
|
|
3293
3398
|
value: function() {
|
|
3294
3399
|
pipelineEngine_class_private_field_set(this, _active, false);
|
|
3400
|
+
clearTimeout(pipelineEngine_class_private_field_get(this, pipelineEngine_sweepTimer));
|
|
3401
|
+
pipelineEngine_class_private_field_set(this, pipelineEngine_sweepTimer, null);
|
|
3295
3402
|
this.rejectAll(new Error("PipelineEngine is killed"));
|
|
3296
3403
|
}
|
|
3297
3404
|
}
|
|
3298
3405
|
]);
|
|
3299
3406
|
return PipelineEngine;
|
|
3300
3407
|
}();
|
|
3408
|
+
function core_pipelineEngine_inflightCount() {
|
|
3409
|
+
return pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).length - pipelineEngine_class_private_field_get(this, pipelineEngine_inflightHead);
|
|
3410
|
+
}
|
|
3411
|
+
function pipelineEngine_firstInflight() {
|
|
3412
|
+
return pipelineEngine_class_private_field_get(this, pipelineEngine_inflightHead) < pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).length ? pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks)[pipelineEngine_class_private_field_get(this, pipelineEngine_inflightHead)] : null;
|
|
3413
|
+
}
|
|
3414
|
+
function pipelineEngine_shiftInflight() {
|
|
3415
|
+
var task = pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks)[pipelineEngine_class_private_field_get(this, pipelineEngine_inflightHead)];
|
|
3416
|
+
pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks)[pipelineEngine_class_private_field_get(this, pipelineEngine_inflightHead)] = null;
|
|
3417
|
+
pipelineEngine_class_private_field_update(this, pipelineEngine_inflightHead).value++;
|
|
3418
|
+
if (pipelineEngine_class_private_field_get(this, pipelineEngine_inflightHead) >= pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).length) {
|
|
3419
|
+
pipelineEngine_class_private_field_set(this, pipelineEngine_inflightTasks, []);
|
|
3420
|
+
pipelineEngine_class_private_field_set(this, pipelineEngine_inflightHead, 0);
|
|
3421
|
+
} else if (pipelineEngine_class_private_field_get(this, pipelineEngine_inflightHead) > 128) {
|
|
3422
|
+
pipelineEngine_class_private_field_set(this, pipelineEngine_inflightTasks, pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).slice(pipelineEngine_class_private_field_get(this, pipelineEngine_inflightHead)));
|
|
3423
|
+
pipelineEngine_class_private_field_set(this, pipelineEngine_inflightHead, 0);
|
|
3424
|
+
}
|
|
3425
|
+
return task;
|
|
3426
|
+
}
|
|
3301
3427
|
function pipelineEngine_pumpQueue() {
|
|
3302
|
-
var _this = this;
|
|
3303
3428
|
var _$_class_private_field_get;
|
|
3304
3429
|
if (!pipelineEngine_class_private_field_get(this, _active)) return;
|
|
3305
3430
|
if (pipelineEngine_class_private_field_get(this, pipelineEngine_processManager).draining) return;
|
|
3306
|
-
if (
|
|
3431
|
+
if (pipelineEngine_class_private_method_get(this, pipelineEngine_inflightCount, core_pipelineEngine_inflightCount).call(this) >= pipelineEngine_class_private_field_get(this, pipelineEngine_maxInflight)) return;
|
|
3307
3432
|
var batch = [];
|
|
3308
|
-
while(batch.length < pipelineEngine_class_private_field_get(this, pipelineEngine_batchSize) && !pipelineEngine_class_private_field_get(this, _queue).isEmpty() &&
|
|
3433
|
+
while(batch.length < pipelineEngine_class_private_field_get(this, pipelineEngine_batchSize) && !pipelineEngine_class_private_field_get(this, _queue).isEmpty() && pipelineEngine_class_private_method_get(this, pipelineEngine_inflightCount, core_pipelineEngine_inflightCount).call(this) + batch.length < pipelineEngine_class_private_field_get(this, pipelineEngine_maxInflight)){
|
|
3309
3434
|
var task = pipelineEngine_class_private_field_get(this, _queue).peek();
|
|
3310
|
-
if ("stream" === task.kind && (batch.length > 0 ||
|
|
3435
|
+
if ("stream" === task.kind && (batch.length > 0 || pipelineEngine_class_private_method_get(this, pipelineEngine_inflightCount, core_pipelineEngine_inflightCount).call(this) > 0)) break;
|
|
3311
3436
|
pipelineEngine_class_private_field_get(this, _queue).dequeue();
|
|
3312
3437
|
batch.push(task);
|
|
3313
3438
|
}
|
|
@@ -3316,14 +3441,10 @@ function pipelineEngine_pumpQueue() {
|
|
|
3316
3441
|
var payload = buildBatchPayload(batch);
|
|
3317
3442
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
3318
3443
|
try {
|
|
3319
|
-
var
|
|
3320
|
-
var
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
return pipelineEngine_class_private_method_get(_this, core_pipelineEngine_handleTaskTimeout, pipelineEngine_handleTaskTimeout).call(_this, task);
|
|
3324
|
-
}, task.timeout);
|
|
3325
|
-
};
|
|
3326
|
-
for(var _iterator = batch[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
3444
|
+
for(var _iterator = batch[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3445
|
+
var task1 = _step.value;
|
|
3446
|
+
task1.startTime = now;
|
|
3447
|
+
}
|
|
3327
3448
|
} catch (err) {
|
|
3328
3449
|
_didIteratorError = true;
|
|
3329
3450
|
_iteratorError = err;
|
|
@@ -3335,14 +3456,14 @@ function pipelineEngine_pumpQueue() {
|
|
|
3335
3456
|
}
|
|
3336
3457
|
}
|
|
3337
3458
|
(_$_class_private_field_get = pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks)).push.apply(_$_class_private_field_get, pipelineEngine_to_consumable_array(batch));
|
|
3459
|
+
pipelineEngine_class_private_method_get(this, pipelineEngine_scheduleSweep, core_pipelineEngine_scheduleSweep).call(this);
|
|
3338
3460
|
pipelineEngine_class_private_field_get(this, pipelineEngine_processManager).write(payload);
|
|
3339
3461
|
}
|
|
3340
3462
|
function core_pipelineEngine_handleParsedValue(raw) {
|
|
3341
|
-
var task =
|
|
3463
|
+
var task = pipelineEngine_class_private_method_get(this, core_pipelineEngine_firstInflight, pipelineEngine_firstInflight).call(this);
|
|
3342
3464
|
if (!task) return;
|
|
3343
3465
|
if (isSentinelRaw(raw, task.token)) {
|
|
3344
|
-
|
|
3345
|
-
pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).shift();
|
|
3466
|
+
pipelineEngine_class_private_method_get(this, core_pipelineEngine_shiftInflight, pipelineEngine_shiftInflight).call(this);
|
|
3346
3467
|
if (task.timedout) return void pipelineEngine_class_private_method_get(this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(this);
|
|
3347
3468
|
if (task.consumerError) {
|
|
3348
3469
|
pipelineEngine_class_private_method_get(this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(this, task, task.consumerError, void 0);
|
|
@@ -3363,8 +3484,7 @@ function core_pipelineEngine_handleParsedValue(raw) {
|
|
|
3363
3484
|
return;
|
|
3364
3485
|
}
|
|
3365
3486
|
if (isSentinelRow(parsed, task.token)) {
|
|
3366
|
-
|
|
3367
|
-
pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).shift();
|
|
3487
|
+
pipelineEngine_class_private_method_get(this, core_pipelineEngine_shiftInflight, pipelineEngine_shiftInflight).call(this);
|
|
3368
3488
|
if (task.timedout) return void pipelineEngine_class_private_method_get(this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(this);
|
|
3369
3489
|
if (task.consumerError) {
|
|
3370
3490
|
pipelineEngine_class_private_method_get(this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(this, task, task.consumerError, void 0);
|
|
@@ -3393,6 +3513,21 @@ function pipelineEngine_scheduleFinalizeCheck() {
|
|
|
3393
3513
|
});
|
|
3394
3514
|
});
|
|
3395
3515
|
}
|
|
3516
|
+
function core_pipelineEngine_scheduleSweep() {
|
|
3517
|
+
var _this = this;
|
|
3518
|
+
if (pipelineEngine_class_private_field_get(this, pipelineEngine_sweepTimer)) return;
|
|
3519
|
+
pipelineEngine_class_private_field_set(this, pipelineEngine_sweepTimer, setTimeout(function() {
|
|
3520
|
+
pipelineEngine_class_private_field_set(_this, pipelineEngine_sweepTimer, null);
|
|
3521
|
+
var tasks = pipelineEngine_class_private_field_get(_this, pipelineEngine_inflightTasks);
|
|
3522
|
+
var head = pipelineEngine_class_private_field_get(_this, pipelineEngine_inflightHead);
|
|
3523
|
+
var now = performance.now();
|
|
3524
|
+
for(var i = head; i < tasks.length; i++){
|
|
3525
|
+
var task = tasks[i];
|
|
3526
|
+
if (now - task.startTime > task.timeout) pipelineEngine_class_private_method_get(_this, core_pipelineEngine_handleTaskTimeout, pipelineEngine_handleTaskTimeout).call(_this, task);
|
|
3527
|
+
}
|
|
3528
|
+
if (pipelineEngine_class_private_method_get(_this, pipelineEngine_inflightCount, core_pipelineEngine_inflightCount).call(_this) > 0) pipelineEngine_class_private_method_get(_this, pipelineEngine_scheduleSweep, core_pipelineEngine_scheduleSweep).call(_this);
|
|
3529
|
+
}, pipelineEngine_class_private_field_get(this, pipelineEngine_sweepIntervalMs)).unref());
|
|
3530
|
+
}
|
|
3396
3531
|
function pipelineEngine_handleTaskTimeout(task) {
|
|
3397
3532
|
var _this, _this1;
|
|
3398
3533
|
var error = prepareTaskTimeout(task, pipelineEngine_class_private_field_get(this, pipelineEngine_metrics));
|
|
@@ -4001,20 +4136,18 @@ function executor_enqueue(kind, sql, params, options, scopeId) {
|
|
|
4001
4136
|
var token = generateToken();
|
|
4002
4137
|
var _options_onRow;
|
|
4003
4138
|
var onRow = null != (_options_onRow = null == options ? void 0 : options.onRow) ? _options_onRow : null;
|
|
4004
|
-
var
|
|
4139
|
+
var template = normalizeSQLTemplate(sql);
|
|
4005
4140
|
var formatted;
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
if (scopeId) return executor_class_private_method_get(this, _enqueueWriter, enqueueWriter).call(this, kind, formatted, timeout, token, onRow, scopeId, sqlNormalized);
|
|
4141
|
+
formatted = 0 === params.length && 0 === template.paramCount ? template.normalized : interpolateFromTemplate(template, params);
|
|
4142
|
+
if (scopeId) return executor_class_private_method_get(this, _enqueueWriter, enqueueWriter).call(this, kind, formatted, timeout, token, onRow, scopeId);
|
|
4009
4143
|
if (executor_class_private_field_get(this, _readerPool)) {
|
|
4010
4144
|
if ("stream" === kind || "query" === kind) return executor_class_private_method_get(this, _enqueueReader, enqueueReader).call(this, kind, formatted, timeout, token, onRow);
|
|
4011
|
-
if ("execute" === kind && "read" === classifySQL(normalized)) return executor_class_private_method_get(this, _enqueueReader, enqueueReader).call(this, kind, formatted, timeout, token, onRow);
|
|
4145
|
+
if ("execute" === kind && "read" === classifySQL(template.normalized)) return executor_class_private_method_get(this, _enqueueReader, enqueueReader).call(this, kind, formatted, timeout, token, onRow);
|
|
4012
4146
|
}
|
|
4013
|
-
return executor_class_private_method_get(this, _enqueueWriter, enqueueWriter).call(this, kind, formatted, timeout, token, onRow, null
|
|
4147
|
+
return executor_class_private_method_get(this, _enqueueWriter, enqueueWriter).call(this, kind, formatted, timeout, token, onRow, null);
|
|
4014
4148
|
}
|
|
4015
4149
|
function enqueueWriter(kind, sql, timeout, token, onRow, scopeId) {
|
|
4016
4150
|
var _this = this;
|
|
4017
|
-
var sqlNormalized = arguments.length > 6 && void 0 !== arguments[6] ? arguments[6] : false;
|
|
4018
4151
|
executor_class_private_field_get(this, executor_metrics).incrementTasksTotal(kind);
|
|
4019
4152
|
return new Promise(function(resolve, reject) {
|
|
4020
4153
|
var task = {
|
|
@@ -4024,17 +4157,15 @@ function enqueueWriter(kind, sql, timeout, token, onRow, scopeId) {
|
|
|
4024
4157
|
token: token,
|
|
4025
4158
|
onRow: onRow,
|
|
4026
4159
|
scopeId: scopeId,
|
|
4027
|
-
sqlNormalized: sqlNormalized,
|
|
4028
4160
|
resolve: resolve,
|
|
4029
4161
|
reject: reject,
|
|
4030
4162
|
consumerError: null,
|
|
4031
4163
|
stderrText: "",
|
|
4032
4164
|
settled: false,
|
|
4033
|
-
timer: null,
|
|
4034
4165
|
startTime: 0,
|
|
4035
|
-
rowParser: null
|
|
4166
|
+
rowParser: null,
|
|
4167
|
+
rows: "query" === kind ? [] : null
|
|
4036
4168
|
};
|
|
4037
|
-
if ("query" === kind) task.rows = [];
|
|
4038
4169
|
if ("stream" === kind) task.rowParser = setupStreamParser(task, executor_class_private_field_get(_this, _pipeline));
|
|
4039
4170
|
if (executor_class_private_field_get(_this, _txScope).isDeferred(scopeId)) executor_class_private_field_get(_this, _txScope).defer(task);
|
|
4040
4171
|
else executor_class_private_field_get(_this, _pipeline).enqueue(task);
|