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/esm/index.mjs
CHANGED
|
@@ -3,218 +3,9 @@ import * as __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__ from "node:c
|
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__ from "node:os";
|
|
6
|
-
function _check_private_redeclaration(obj, privateCollection) {
|
|
7
|
-
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
8
|
-
}
|
|
9
|
-
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
10
|
-
if (descriptor.get) return descriptor.get.call(receiver);
|
|
11
|
-
return descriptor.value;
|
|
12
|
-
}
|
|
13
|
-
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
14
|
-
if (descriptor.set) descriptor.set.call(receiver, value);
|
|
15
|
-
else {
|
|
16
|
-
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
17
|
-
descriptor.value = value;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function _class_call_check(instance, Constructor) {
|
|
21
|
-
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
22
|
-
}
|
|
23
|
-
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
24
|
-
if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
25
|
-
return privateMap.get(receiver);
|
|
26
|
-
}
|
|
27
|
-
function _class_private_field_get(receiver, privateMap) {
|
|
28
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
29
|
-
return _class_apply_descriptor_get(receiver, descriptor);
|
|
30
|
-
}
|
|
31
|
-
function _class_private_field_init(obj, privateMap, value) {
|
|
32
|
-
_check_private_redeclaration(obj, privateMap);
|
|
33
|
-
privateMap.set(obj, value);
|
|
34
|
-
}
|
|
35
|
-
function _class_private_field_set(receiver, privateMap, value) {
|
|
36
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
37
|
-
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
38
|
-
return value;
|
|
39
|
-
}
|
|
40
|
-
function _defineProperties(target, props) {
|
|
41
|
-
for(var i = 0; i < props.length; i++){
|
|
42
|
-
var descriptor = props[i];
|
|
43
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
44
|
-
descriptor.configurable = true;
|
|
45
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
46
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
50
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
51
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
52
|
-
return Constructor;
|
|
53
|
-
}
|
|
54
|
-
var _maxSize = /*#__PURE__*/ new WeakMap(), _maxKeyLength = /*#__PURE__*/ new WeakMap(), _map = /*#__PURE__*/ new WeakMap();
|
|
55
|
-
var lruCache_LRUCache = /*#__PURE__*/ function() {
|
|
56
|
-
"use strict";
|
|
57
|
-
function LRUCache() {
|
|
58
|
-
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;
|
|
59
|
-
_class_call_check(this, LRUCache);
|
|
60
|
-
_class_private_field_init(this, _maxSize, {
|
|
61
|
-
writable: true,
|
|
62
|
-
value: void 0
|
|
63
|
-
});
|
|
64
|
-
_class_private_field_init(this, _maxKeyLength, {
|
|
65
|
-
writable: true,
|
|
66
|
-
value: void 0
|
|
67
|
-
});
|
|
68
|
-
_class_private_field_init(this, _map, {
|
|
69
|
-
writable: true,
|
|
70
|
-
value: new Map()
|
|
71
|
-
});
|
|
72
|
-
_class_private_field_set(this, _maxSize, Math.max(1, maxSize));
|
|
73
|
-
_class_private_field_set(this, _maxKeyLength, maxKeyLength);
|
|
74
|
-
}
|
|
75
|
-
_create_class(LRUCache, [
|
|
76
|
-
{
|
|
77
|
-
key: "get",
|
|
78
|
-
value: function(key) {
|
|
79
|
-
if ("string" != typeof key || key.length > _class_private_field_get(this, _maxKeyLength)) return;
|
|
80
|
-
var value = _class_private_field_get(this, _map).get(key);
|
|
81
|
-
if (void 0 === value) return;
|
|
82
|
-
_class_private_field_get(this, _map)["delete"](key);
|
|
83
|
-
_class_private_field_get(this, _map).set(key, value);
|
|
84
|
-
return value;
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
key: "set",
|
|
89
|
-
value: function(key, value) {
|
|
90
|
-
if ("string" != typeof key || key.length > _class_private_field_get(this, _maxKeyLength)) return;
|
|
91
|
-
if (_class_private_field_get(this, _map).size >= _class_private_field_get(this, _maxSize)) {
|
|
92
|
-
var firstKey = _class_private_field_get(this, _map).keys().next().value;
|
|
93
|
-
_class_private_field_get(this, _map)["delete"](firstKey);
|
|
94
|
-
}
|
|
95
|
-
_class_private_field_get(this, _map).set(key, value);
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
key: "size",
|
|
100
|
-
get: function() {
|
|
101
|
-
return _class_private_field_get(this, _map).size;
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
key: "clear",
|
|
106
|
-
value: function() {
|
|
107
|
-
_class_private_field_get(this, _map).clear();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
]);
|
|
111
|
-
return LRUCache;
|
|
112
|
-
}();
|
|
113
|
-
var CC_SINGLE_QUOTE = 39;
|
|
114
|
-
var CC_DOUBLE_QUOTE = 34;
|
|
115
|
-
var CC_DASH = 45;
|
|
116
|
-
var CC_SLASH = 47;
|
|
117
|
-
var CC_STAR = 42;
|
|
118
|
-
var CC_NEWLINE = 10;
|
|
119
|
-
var CC_QUESTION = 63;
|
|
120
|
-
var CC_SEMICOLON = 59;
|
|
121
|
-
var CC_SPACE = 32;
|
|
122
|
-
var STATE_NORMAL = 0;
|
|
123
|
-
var STATE_SINGLE_QUOTE = 1;
|
|
124
|
-
var STATE_DOUBLE_QUOTE = 2;
|
|
125
|
-
var STATE_LINE_COMMENT = 3;
|
|
126
|
-
var STATE_BLOCK_COMMENT = 4;
|
|
127
|
-
var _normBuf = new Uint16Array(1024);
|
|
128
|
-
var _normDecoder = new TextDecoder("utf-16le");
|
|
129
|
-
var _normCache = new lruCache_LRUCache({
|
|
130
|
-
maxSize: 256,
|
|
131
|
-
maxKeyLength: 4096
|
|
132
|
-
});
|
|
133
|
-
function normalizeSQL(sql) {
|
|
134
|
-
var cached = _normCache.get(sql);
|
|
135
|
-
if (void 0 !== cached) return cached;
|
|
136
|
-
var len = sql.length;
|
|
137
|
-
var needed = len + 1;
|
|
138
|
-
if (_normBuf.length < needed) _normBuf = new Uint16Array(needed);
|
|
139
|
-
var outCodes = _normBuf;
|
|
140
|
-
var writePos = 0;
|
|
141
|
-
var pendingSpace = false;
|
|
142
|
-
var state = STATE_NORMAL;
|
|
143
|
-
for(var i = 0; i < len; i++){
|
|
144
|
-
var code = sql.charCodeAt(i);
|
|
145
|
-
var nextCode = sql.charCodeAt(i + 1);
|
|
146
|
-
if (state === STATE_BLOCK_COMMENT) {
|
|
147
|
-
if (code === CC_STAR && nextCode === CC_SLASH) {
|
|
148
|
-
state = STATE_NORMAL;
|
|
149
|
-
i++;
|
|
150
|
-
if (writePos > 0) pendingSpace = true;
|
|
151
|
-
}
|
|
152
|
-
continue;
|
|
153
|
-
}
|
|
154
|
-
if (state === STATE_LINE_COMMENT) {
|
|
155
|
-
if (code === CC_NEWLINE) {
|
|
156
|
-
state = STATE_NORMAL;
|
|
157
|
-
if (writePos > 0) pendingSpace = true;
|
|
158
|
-
}
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
161
|
-
if (state === STATE_NORMAL) {
|
|
162
|
-
if (code === CC_DASH && nextCode === CC_DASH) {
|
|
163
|
-
state = STATE_LINE_COMMENT;
|
|
164
|
-
i++;
|
|
165
|
-
continue;
|
|
166
|
-
}
|
|
167
|
-
if (code === CC_SLASH && nextCode === CC_STAR) {
|
|
168
|
-
state = STATE_BLOCK_COMMENT;
|
|
169
|
-
i++;
|
|
170
|
-
continue;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
if (32 === code || 9 === code || 10 === code || 11 === code || 12 === code || 13 === code) {
|
|
174
|
-
if (writePos > 0) pendingSpace = true;
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
if (pendingSpace && writePos > 0) {
|
|
178
|
-
outCodes[writePos++] = CC_SPACE;
|
|
179
|
-
pendingSpace = false;
|
|
180
|
-
}
|
|
181
|
-
outCodes[writePos++] = code;
|
|
182
|
-
if (state === STATE_NORMAL) {
|
|
183
|
-
if (code === CC_SINGLE_QUOTE) state = STATE_SINGLE_QUOTE;
|
|
184
|
-
else if (code === CC_DOUBLE_QUOTE) state = STATE_DOUBLE_QUOTE;
|
|
185
|
-
continue;
|
|
186
|
-
}
|
|
187
|
-
if (state === STATE_SINGLE_QUOTE) {
|
|
188
|
-
if (code === CC_SINGLE_QUOTE && nextCode === CC_SINGLE_QUOTE) {
|
|
189
|
-
outCodes[writePos++] = nextCode;
|
|
190
|
-
i++;
|
|
191
|
-
continue;
|
|
192
|
-
}
|
|
193
|
-
if (code === CC_SINGLE_QUOTE) state = STATE_NORMAL;
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
if (state === STATE_DOUBLE_QUOTE) {
|
|
197
|
-
if (code === CC_DOUBLE_QUOTE && nextCode === CC_DOUBLE_QUOTE) {
|
|
198
|
-
outCodes[writePos++] = nextCode;
|
|
199
|
-
i++;
|
|
200
|
-
continue;
|
|
201
|
-
}
|
|
202
|
-
if (code === CC_DOUBLE_QUOTE) state = STATE_NORMAL;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
var result;
|
|
206
|
-
if (0 === writePos) result = ";";
|
|
207
|
-
else {
|
|
208
|
-
while(writePos > 0 && outCodes[writePos - 1] === CC_SEMICOLON)writePos--;
|
|
209
|
-
outCodes[writePos++] = CC_SEMICOLON;
|
|
210
|
-
result = _normDecoder.decode(outCodes.subarray(0, writePos));
|
|
211
|
-
}
|
|
212
|
-
_normCache.set(sql, result);
|
|
213
|
-
return result;
|
|
214
|
-
}
|
|
215
6
|
var DEFAULT_STATEMENT_TIMEOUT = 30000;
|
|
216
7
|
function createTimeoutError(timeout, sql) {
|
|
217
|
-
return new Error("SQLite statement timed out after ".concat(timeout, "ms: ").concat(
|
|
8
|
+
return new Error("SQLite statement timed out after ".concat(timeout, "ms: ").concat(sql));
|
|
218
9
|
}
|
|
219
10
|
function toError(value) {
|
|
220
11
|
return value instanceof Error ? value : new Error(String(value));
|
|
@@ -245,55 +36,65 @@ function createJsonValueParser(onValue) {
|
|
|
245
36
|
feed: function(chunk) {
|
|
246
37
|
this.buffer += chunk;
|
|
247
38
|
var consumeUntil = 0;
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
39
|
+
var buffer = this.buffer;
|
|
40
|
+
var start = this.start;
|
|
41
|
+
var nesting = this.nesting;
|
|
42
|
+
var inString = this.inString;
|
|
43
|
+
var escaped = this.escaped;
|
|
44
|
+
for(var index = this.readPos; index < buffer.length; index++){
|
|
45
|
+
var code = buffer.charCodeAt(index);
|
|
46
|
+
if (-1 === start) {
|
|
251
47
|
if (isWhitespaceCode(code)) continue;
|
|
252
48
|
if (code !== CHAR_OPEN_BRACKET && code !== CHAR_OPEN_BRACE) continue;
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
49
|
+
start = index;
|
|
50
|
+
nesting = 1;
|
|
51
|
+
inString = false;
|
|
52
|
+
escaped = false;
|
|
257
53
|
continue;
|
|
258
54
|
}
|
|
259
|
-
if (
|
|
260
|
-
if (
|
|
261
|
-
else if (code === CHAR_BACKSLASH)
|
|
262
|
-
else if (code === CHAR_QUOTE)
|
|
55
|
+
if (inString) {
|
|
56
|
+
if (escaped) escaped = false;
|
|
57
|
+
else if (code === CHAR_BACKSLASH) escaped = true;
|
|
58
|
+
else if (code === CHAR_QUOTE) inString = false;
|
|
263
59
|
continue;
|
|
264
60
|
}
|
|
265
61
|
if (code === CHAR_QUOTE) {
|
|
266
|
-
|
|
62
|
+
inString = true;
|
|
267
63
|
continue;
|
|
268
64
|
}
|
|
269
65
|
if (code === CHAR_OPEN_BRACKET || code === CHAR_OPEN_BRACE) {
|
|
270
|
-
|
|
66
|
+
nesting++;
|
|
271
67
|
continue;
|
|
272
68
|
}
|
|
273
69
|
if (code === CHAR_CLOSE_BRACKET || code === CHAR_CLOSE_BRACE) {
|
|
274
|
-
|
|
275
|
-
if (0 ===
|
|
276
|
-
if (index ===
|
|
277
|
-
|
|
70
|
+
nesting--;
|
|
71
|
+
if (0 === nesting) {
|
|
72
|
+
if (index === start + 1) {
|
|
73
|
+
start = -1;
|
|
278
74
|
consumeUntil = index + 1;
|
|
279
75
|
continue;
|
|
280
76
|
}
|
|
281
|
-
var raw =
|
|
282
|
-
|
|
77
|
+
var raw = buffer.slice(start, index + 1);
|
|
78
|
+
start = -1;
|
|
283
79
|
onValue(raw);
|
|
284
80
|
consumeUntil = index + 1;
|
|
285
81
|
}
|
|
286
82
|
}
|
|
287
83
|
}
|
|
84
|
+
this.start = start;
|
|
85
|
+
this.nesting = nesting;
|
|
86
|
+
this.inString = inString;
|
|
87
|
+
this.escaped = escaped;
|
|
288
88
|
if (consumeUntil > 0) {
|
|
289
89
|
this._consumed = consumeUntil;
|
|
290
|
-
this.readPos = this._consumed;
|
|
90
|
+
this.readPos = -1 !== this.start ? buffer.length : this._consumed;
|
|
291
91
|
if (this._consumed > 65536) {
|
|
92
|
+
if (-1 !== this.start) this.start -= this._consumed;
|
|
292
93
|
this.buffer = this.buffer.slice(this._consumed);
|
|
293
|
-
this.readPos =
|
|
94
|
+
this.readPos = this.buffer.length;
|
|
294
95
|
this._consumed = 0;
|
|
295
96
|
}
|
|
296
|
-
} else this.readPos =
|
|
97
|
+
} else this.readPos = buffer.length;
|
|
297
98
|
},
|
|
298
99
|
reset: function() {
|
|
299
100
|
this.buffer = "";
|
|
@@ -321,10 +122,18 @@ function createRowStreamParser(onRow) {
|
|
|
321
122
|
feed: function(chunk) {
|
|
322
123
|
if (this.finished) return chunk;
|
|
323
124
|
this.buffer += chunk;
|
|
125
|
+
var buffer = this.buffer;
|
|
126
|
+
var started = this.started;
|
|
127
|
+
var inString = this.inString;
|
|
128
|
+
var escaped = this.escaped;
|
|
129
|
+
var elementStart = this.elementStart;
|
|
130
|
+
var elementEnd = this.elementEnd;
|
|
131
|
+
var nesting = this.nesting;
|
|
132
|
+
var consumed = this._consumed;
|
|
324
133
|
var index = this.readPos;
|
|
325
|
-
while(index <
|
|
326
|
-
var code =
|
|
327
|
-
if (!
|
|
134
|
+
while(index < buffer.length){
|
|
135
|
+
var code = buffer.charCodeAt(index);
|
|
136
|
+
if (!started) {
|
|
328
137
|
if (isWhitespaceCode(code)) {
|
|
329
138
|
index++;
|
|
330
139
|
continue;
|
|
@@ -333,74 +142,81 @@ function createRowStreamParser(onRow) {
|
|
|
333
142
|
index++;
|
|
334
143
|
continue;
|
|
335
144
|
}
|
|
336
|
-
|
|
145
|
+
started = true;
|
|
337
146
|
index++;
|
|
338
147
|
continue;
|
|
339
148
|
}
|
|
340
|
-
if (
|
|
341
|
-
if (
|
|
342
|
-
else if (code === CHAR_BACKSLASH)
|
|
343
|
-
else if (code === CHAR_QUOTE)
|
|
149
|
+
if (inString) {
|
|
150
|
+
if (escaped) escaped = false;
|
|
151
|
+
else if (code === CHAR_BACKSLASH) escaped = true;
|
|
152
|
+
else if (code === CHAR_QUOTE) inString = false;
|
|
344
153
|
index++;
|
|
345
154
|
continue;
|
|
346
155
|
}
|
|
347
|
-
if (-1 ===
|
|
156
|
+
if (-1 === elementStart) {
|
|
348
157
|
if (isWhitespaceCode(code) || code === CHAR_COMMA) {
|
|
349
158
|
index++;
|
|
350
159
|
continue;
|
|
351
160
|
}
|
|
352
161
|
if (code === CHAR_CLOSE_BRACKET) {
|
|
353
162
|
this.finished = true;
|
|
354
|
-
var leftover = this.buffer.slice(index + 1);
|
|
355
|
-
this.buffer = "";
|
|
356
163
|
this.readPos = 0;
|
|
357
|
-
|
|
164
|
+
this.buffer = "";
|
|
165
|
+
this.started = false;
|
|
166
|
+
return buffer.slice(index + 1);
|
|
358
167
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
168
|
+
elementStart = index;
|
|
169
|
+
elementEnd = -1;
|
|
170
|
+
nesting = code === CHAR_OPEN_BRACE || code === CHAR_OPEN_BRACKET ? 1 : 0;
|
|
171
|
+
inString = code === CHAR_QUOTE;
|
|
172
|
+
escaped = false;
|
|
363
173
|
index++;
|
|
364
174
|
continue;
|
|
365
175
|
}
|
|
366
176
|
if (code === CHAR_QUOTE) {
|
|
367
|
-
|
|
177
|
+
inString = true;
|
|
368
178
|
index++;
|
|
369
179
|
continue;
|
|
370
180
|
}
|
|
371
181
|
if (code === CHAR_OPEN_BRACE || code === CHAR_OPEN_BRACKET) {
|
|
372
|
-
|
|
182
|
+
nesting++;
|
|
373
183
|
index++;
|
|
374
184
|
continue;
|
|
375
185
|
}
|
|
376
186
|
if (code === CHAR_CLOSE_BRACE || code === CHAR_CLOSE_BRACKET) {
|
|
377
|
-
|
|
378
|
-
if (0 ===
|
|
187
|
+
nesting--;
|
|
188
|
+
if (0 === nesting) elementEnd = index + 1;
|
|
379
189
|
}
|
|
380
|
-
if (-1 !==
|
|
190
|
+
if (-1 !== elementEnd) {
|
|
381
191
|
var lookAhead = index + 1;
|
|
382
|
-
while(lookAhead <
|
|
383
|
-
if (lookAhead <
|
|
384
|
-
var delimiter =
|
|
192
|
+
while(lookAhead < buffer.length && isWhitespaceCode(buffer.charCodeAt(lookAhead)))lookAhead++;
|
|
193
|
+
if (lookAhead < buffer.length) {
|
|
194
|
+
var delimiter = buffer.charCodeAt(lookAhead);
|
|
385
195
|
if (delimiter === CHAR_COMMA || delimiter === CHAR_CLOSE_BRACKET) {
|
|
386
|
-
onRow(
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
196
|
+
onRow(buffer.slice(elementStart, elementEnd));
|
|
197
|
+
consumed = lookAhead + 1;
|
|
198
|
+
elementStart = -1;
|
|
199
|
+
elementEnd = -1;
|
|
200
|
+
nesting = 0;
|
|
391
201
|
if (delimiter === CHAR_CLOSE_BRACKET) {
|
|
392
202
|
this.finished = true;
|
|
393
|
-
var tail = this.buffer.slice(this._consumed);
|
|
394
203
|
this.buffer = "";
|
|
204
|
+
this.started = false;
|
|
205
|
+
this.inString = false;
|
|
206
|
+
this.escaped = false;
|
|
207
|
+
this.elementStart = -1;
|
|
208
|
+
this.elementEnd = -1;
|
|
209
|
+
this.nesting = 0;
|
|
395
210
|
this._consumed = 0;
|
|
396
211
|
this.readPos = 0;
|
|
397
|
-
return
|
|
212
|
+
return buffer.slice(consumed);
|
|
398
213
|
}
|
|
399
|
-
index =
|
|
400
|
-
if (
|
|
401
|
-
this.buffer =
|
|
402
|
-
index = 0;
|
|
214
|
+
index = consumed;
|
|
215
|
+
if (consumed > 65536) {
|
|
216
|
+
this.buffer = buffer.slice(consumed);
|
|
403
217
|
this._consumed = 0;
|
|
218
|
+
index = 0;
|
|
219
|
+
consumed = 0;
|
|
404
220
|
}
|
|
405
221
|
continue;
|
|
406
222
|
}
|
|
@@ -408,12 +224,19 @@ function createRowStreamParser(onRow) {
|
|
|
408
224
|
}
|
|
409
225
|
index++;
|
|
410
226
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
227
|
+
this.started = started;
|
|
228
|
+
this.inString = inString;
|
|
229
|
+
this.escaped = escaped;
|
|
230
|
+
this.elementStart = elementStart;
|
|
231
|
+
this.elementEnd = elementEnd;
|
|
232
|
+
this.nesting = nesting;
|
|
233
|
+
this._consumed = consumed;
|
|
234
|
+
if (consumed > 0) {
|
|
235
|
+
if (-1 !== elementStart) {
|
|
236
|
+
this.elementStart -= consumed;
|
|
237
|
+
if (-1 !== elementEnd) this.elementEnd -= consumed;
|
|
415
238
|
}
|
|
416
|
-
this.buffer =
|
|
239
|
+
this.buffer = buffer.slice(consumed);
|
|
417
240
|
this._consumed = 0;
|
|
418
241
|
}
|
|
419
242
|
if (this.elementStart > 0) {
|
|
@@ -441,14 +264,14 @@ function createRowStreamParser(onRow) {
|
|
|
441
264
|
var TOKEN_COLUMN = "__sqlite_executor_token__";
|
|
442
265
|
var DEFAULT_BATCH_SIZE = 10;
|
|
443
266
|
var DEFAULT_MAX_INFLIGHT = 50;
|
|
444
|
-
function
|
|
267
|
+
function _check_private_redeclaration(obj, privateCollection) {
|
|
445
268
|
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
446
269
|
}
|
|
447
|
-
function
|
|
270
|
+
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
448
271
|
if (descriptor.get) return descriptor.get.call(receiver);
|
|
449
272
|
return descriptor.value;
|
|
450
273
|
}
|
|
451
|
-
function
|
|
274
|
+
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
452
275
|
if (descriptor.set) descriptor.set.call(receiver, value);
|
|
453
276
|
else {
|
|
454
277
|
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
@@ -471,31 +294,31 @@ function _class_apply_descriptor_update(receiver, descriptor) {
|
|
|
471
294
|
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
472
295
|
return descriptor;
|
|
473
296
|
}
|
|
474
|
-
function
|
|
297
|
+
function _class_call_check(instance, Constructor) {
|
|
475
298
|
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
476
299
|
}
|
|
477
|
-
function
|
|
300
|
+
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
478
301
|
if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
479
302
|
return privateMap.get(receiver);
|
|
480
303
|
}
|
|
481
|
-
function
|
|
482
|
-
var descriptor =
|
|
483
|
-
return
|
|
304
|
+
function _class_private_field_get(receiver, privateMap) {
|
|
305
|
+
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
306
|
+
return _class_apply_descriptor_get(receiver, descriptor);
|
|
484
307
|
}
|
|
485
|
-
function
|
|
486
|
-
|
|
308
|
+
function _class_private_field_init(obj, privateMap, value) {
|
|
309
|
+
_check_private_redeclaration(obj, privateMap);
|
|
487
310
|
privateMap.set(obj, value);
|
|
488
311
|
}
|
|
489
|
-
function
|
|
490
|
-
var descriptor =
|
|
491
|
-
|
|
312
|
+
function _class_private_field_set(receiver, privateMap, value) {
|
|
313
|
+
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
314
|
+
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
492
315
|
return value;
|
|
493
316
|
}
|
|
494
317
|
function _class_private_field_update(receiver, privateMap) {
|
|
495
|
-
var descriptor =
|
|
318
|
+
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "update");
|
|
496
319
|
return _class_apply_descriptor_update(receiver, descriptor);
|
|
497
320
|
}
|
|
498
|
-
function
|
|
321
|
+
function _defineProperties(target, props) {
|
|
499
322
|
for(var i = 0; i < props.length; i++){
|
|
500
323
|
var descriptor = props[i];
|
|
501
324
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
@@ -504,9 +327,9 @@ function stream_defineProperties(target, props) {
|
|
|
504
327
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
505
328
|
}
|
|
506
329
|
}
|
|
507
|
-
function
|
|
508
|
-
if (protoProps)
|
|
509
|
-
if (staticProps)
|
|
330
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
331
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
332
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
510
333
|
return Constructor;
|
|
511
334
|
}
|
|
512
335
|
function _type_of(obj) {
|
|
@@ -536,50 +359,50 @@ var _computedKey1 = _computedKey;
|
|
|
536
359
|
var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
537
360
|
"use strict";
|
|
538
361
|
function AsyncRowBuffer() {
|
|
539
|
-
|
|
540
|
-
|
|
362
|
+
_class_call_check(this, AsyncRowBuffer);
|
|
363
|
+
_class_private_field_init(this, _buffer, {
|
|
541
364
|
writable: true,
|
|
542
365
|
value: []
|
|
543
366
|
});
|
|
544
|
-
|
|
367
|
+
_class_private_field_init(this, _index, {
|
|
545
368
|
writable: true,
|
|
546
369
|
value: 0
|
|
547
370
|
});
|
|
548
|
-
|
|
371
|
+
_class_private_field_init(this, _done, {
|
|
549
372
|
writable: true,
|
|
550
373
|
value: false
|
|
551
374
|
});
|
|
552
|
-
|
|
375
|
+
_class_private_field_init(this, _error, {
|
|
553
376
|
writable: true,
|
|
554
377
|
value: null
|
|
555
378
|
});
|
|
556
|
-
|
|
379
|
+
_class_private_field_init(this, _pending, {
|
|
557
380
|
writable: true,
|
|
558
381
|
value: null
|
|
559
382
|
});
|
|
560
383
|
}
|
|
561
|
-
|
|
384
|
+
_create_class(AsyncRowBuffer, [
|
|
562
385
|
{
|
|
563
386
|
key: "push",
|
|
564
387
|
value: function(row) {
|
|
565
|
-
if (
|
|
566
|
-
if (
|
|
567
|
-
var resolve =
|
|
568
|
-
|
|
388
|
+
if (_class_private_field_get(this, _done) || _class_private_field_get(this, _error)) return;
|
|
389
|
+
if (_class_private_field_get(this, _pending)) {
|
|
390
|
+
var resolve = _class_private_field_get(this, _pending).resolve;
|
|
391
|
+
_class_private_field_set(this, _pending, null);
|
|
569
392
|
resolve({
|
|
570
393
|
value: row,
|
|
571
394
|
done: false
|
|
572
395
|
});
|
|
573
|
-
} else
|
|
396
|
+
} else _class_private_field_get(this, _buffer).push(row);
|
|
574
397
|
}
|
|
575
398
|
},
|
|
576
399
|
{
|
|
577
400
|
key: "end",
|
|
578
401
|
value: function() {
|
|
579
|
-
|
|
580
|
-
if (
|
|
581
|
-
var resolve =
|
|
582
|
-
|
|
402
|
+
_class_private_field_set(this, _done, true);
|
|
403
|
+
if (_class_private_field_get(this, _pending)) {
|
|
404
|
+
var resolve = _class_private_field_get(this, _pending).resolve;
|
|
405
|
+
_class_private_field_set(this, _pending, null);
|
|
583
406
|
resolve({
|
|
584
407
|
value: void 0,
|
|
585
408
|
done: true
|
|
@@ -590,10 +413,10 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
590
413
|
{
|
|
591
414
|
key: "error",
|
|
592
415
|
value: function(err) {
|
|
593
|
-
|
|
594
|
-
if (
|
|
595
|
-
var reject =
|
|
596
|
-
|
|
416
|
+
_class_private_field_set(this, _error, err);
|
|
417
|
+
if (_class_private_field_get(this, _pending)) {
|
|
418
|
+
var reject = _class_private_field_get(this, _pending).reject;
|
|
419
|
+
_class_private_field_set(this, _pending, null);
|
|
597
420
|
reject(err);
|
|
598
421
|
}
|
|
599
422
|
}
|
|
@@ -602,17 +425,17 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
602
425
|
key: "next",
|
|
603
426
|
value: function() {
|
|
604
427
|
var _this = this;
|
|
605
|
-
if (
|
|
606
|
-
value:
|
|
428
|
+
if (_class_private_field_get(this, _index) < _class_private_field_get(this, _buffer).length) return Promise.resolve({
|
|
429
|
+
value: _class_private_field_get(this, _buffer)[_class_private_field_update(this, _index).value++],
|
|
607
430
|
done: false
|
|
608
431
|
});
|
|
609
|
-
if (
|
|
432
|
+
if (_class_private_field_get(this, _done)) return Promise.resolve({
|
|
610
433
|
value: void 0,
|
|
611
434
|
done: true
|
|
612
435
|
});
|
|
613
|
-
if (
|
|
436
|
+
if (_class_private_field_get(this, _error)) return Promise.reject(_class_private_field_get(this, _error));
|
|
614
437
|
return new Promise(function(resolve, reject) {
|
|
615
|
-
|
|
438
|
+
_class_private_field_set(_this, _pending, {
|
|
616
439
|
resolve: resolve,
|
|
617
440
|
reject: reject
|
|
618
441
|
});
|
|
@@ -622,12 +445,12 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
622
445
|
{
|
|
623
446
|
key: "return",
|
|
624
447
|
value: function() {
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
if (
|
|
629
|
-
var resolve =
|
|
630
|
-
|
|
448
|
+
_class_private_field_set(this, _done, true);
|
|
449
|
+
_class_private_field_set(this, _buffer, []);
|
|
450
|
+
_class_private_field_set(this, _index, 0);
|
|
451
|
+
if (_class_private_field_get(this, _pending)) {
|
|
452
|
+
var resolve = _class_private_field_get(this, _pending).resolve;
|
|
453
|
+
_class_private_field_set(this, _pending, null);
|
|
631
454
|
resolve({
|
|
632
455
|
value: void 0,
|
|
633
456
|
done: true
|
|
@@ -1160,6 +983,119 @@ function generateToken() {
|
|
|
1160
983
|
_counter = _counter + 1 >>> 0;
|
|
1161
984
|
return "".concat(_PREFIX).concat(_counter.toString(36), "_").concat(_PID36);
|
|
1162
985
|
}
|
|
986
|
+
function lruCache_check_private_redeclaration(obj, privateCollection) {
|
|
987
|
+
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
988
|
+
}
|
|
989
|
+
function lruCache_class_apply_descriptor_get(receiver, descriptor) {
|
|
990
|
+
if (descriptor.get) return descriptor.get.call(receiver);
|
|
991
|
+
return descriptor.value;
|
|
992
|
+
}
|
|
993
|
+
function lruCache_class_apply_descriptor_set(receiver, descriptor, value) {
|
|
994
|
+
if (descriptor.set) descriptor.set.call(receiver, value);
|
|
995
|
+
else {
|
|
996
|
+
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
997
|
+
descriptor.value = value;
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
function lruCache_class_call_check(instance, Constructor) {
|
|
1001
|
+
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
1002
|
+
}
|
|
1003
|
+
function lruCache_class_extract_field_descriptor(receiver, privateMap, action) {
|
|
1004
|
+
if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
1005
|
+
return privateMap.get(receiver);
|
|
1006
|
+
}
|
|
1007
|
+
function lruCache_class_private_field_get(receiver, privateMap) {
|
|
1008
|
+
var descriptor = lruCache_class_extract_field_descriptor(receiver, privateMap, "get");
|
|
1009
|
+
return lruCache_class_apply_descriptor_get(receiver, descriptor);
|
|
1010
|
+
}
|
|
1011
|
+
function lruCache_class_private_field_init(obj, privateMap, value) {
|
|
1012
|
+
lruCache_check_private_redeclaration(obj, privateMap);
|
|
1013
|
+
privateMap.set(obj, value);
|
|
1014
|
+
}
|
|
1015
|
+
function lruCache_class_private_field_set(receiver, privateMap, value) {
|
|
1016
|
+
var descriptor = lruCache_class_extract_field_descriptor(receiver, privateMap, "set");
|
|
1017
|
+
lruCache_class_apply_descriptor_set(receiver, descriptor, value);
|
|
1018
|
+
return value;
|
|
1019
|
+
}
|
|
1020
|
+
function lruCache_defineProperties(target, props) {
|
|
1021
|
+
for(var i = 0; i < props.length; i++){
|
|
1022
|
+
var descriptor = props[i];
|
|
1023
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
1024
|
+
descriptor.configurable = true;
|
|
1025
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
1026
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
function lruCache_create_class(Constructor, protoProps, staticProps) {
|
|
1030
|
+
if (protoProps) lruCache_defineProperties(Constructor.prototype, protoProps);
|
|
1031
|
+
if (staticProps) lruCache_defineProperties(Constructor, staticProps);
|
|
1032
|
+
return Constructor;
|
|
1033
|
+
}
|
|
1034
|
+
var _maxSize = /*#__PURE__*/ new WeakMap(), _maxKeyLength = /*#__PURE__*/ new WeakMap(), _maxValueLength = /*#__PURE__*/ new WeakMap(), _map = /*#__PURE__*/ new WeakMap();
|
|
1035
|
+
var lruCache_LRUCache = /*#__PURE__*/ function() {
|
|
1036
|
+
"use strict";
|
|
1037
|
+
function LRUCache() {
|
|
1038
|
+
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;
|
|
1039
|
+
lruCache_class_call_check(this, LRUCache);
|
|
1040
|
+
lruCache_class_private_field_init(this, _maxSize, {
|
|
1041
|
+
writable: true,
|
|
1042
|
+
value: void 0
|
|
1043
|
+
});
|
|
1044
|
+
lruCache_class_private_field_init(this, _maxKeyLength, {
|
|
1045
|
+
writable: true,
|
|
1046
|
+
value: void 0
|
|
1047
|
+
});
|
|
1048
|
+
lruCache_class_private_field_init(this, _maxValueLength, {
|
|
1049
|
+
writable: true,
|
|
1050
|
+
value: void 0
|
|
1051
|
+
});
|
|
1052
|
+
lruCache_class_private_field_init(this, _map, {
|
|
1053
|
+
writable: true,
|
|
1054
|
+
value: new Map()
|
|
1055
|
+
});
|
|
1056
|
+
lruCache_class_private_field_set(this, _maxSize, Math.max(1, maxSize));
|
|
1057
|
+
lruCache_class_private_field_set(this, _maxKeyLength, maxKeyLength);
|
|
1058
|
+
lruCache_class_private_field_set(this, _maxValueLength, maxValueLength);
|
|
1059
|
+
}
|
|
1060
|
+
lruCache_create_class(LRUCache, [
|
|
1061
|
+
{
|
|
1062
|
+
key: "get",
|
|
1063
|
+
value: function(key) {
|
|
1064
|
+
if ("string" != typeof key || key.length > lruCache_class_private_field_get(this, _maxKeyLength)) return;
|
|
1065
|
+
var value = lruCache_class_private_field_get(this, _map).get(key);
|
|
1066
|
+
if (void 0 === value) return;
|
|
1067
|
+
lruCache_class_private_field_get(this, _map)["delete"](key);
|
|
1068
|
+
lruCache_class_private_field_get(this, _map).set(key, value);
|
|
1069
|
+
return value;
|
|
1070
|
+
}
|
|
1071
|
+
},
|
|
1072
|
+
{
|
|
1073
|
+
key: "set",
|
|
1074
|
+
value: function(key, value) {
|
|
1075
|
+
if ("string" != typeof key || key.length > lruCache_class_private_field_get(this, _maxKeyLength)) return;
|
|
1076
|
+
if (value && value.length > lruCache_class_private_field_get(this, _maxValueLength)) return;
|
|
1077
|
+
if (lruCache_class_private_field_get(this, _map).size >= lruCache_class_private_field_get(this, _maxSize)) {
|
|
1078
|
+
var firstKey = lruCache_class_private_field_get(this, _map).keys().next().value;
|
|
1079
|
+
lruCache_class_private_field_get(this, _map)["delete"](firstKey);
|
|
1080
|
+
}
|
|
1081
|
+
lruCache_class_private_field_get(this, _map).set(key, value);
|
|
1082
|
+
}
|
|
1083
|
+
},
|
|
1084
|
+
{
|
|
1085
|
+
key: "size",
|
|
1086
|
+
get: function() {
|
|
1087
|
+
return lruCache_class_private_field_get(this, _map).size;
|
|
1088
|
+
}
|
|
1089
|
+
},
|
|
1090
|
+
{
|
|
1091
|
+
key: "clear",
|
|
1092
|
+
value: function() {
|
|
1093
|
+
lruCache_class_private_field_get(this, _map).clear();
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
]);
|
|
1097
|
+
return LRUCache;
|
|
1098
|
+
}();
|
|
1163
1099
|
function escape_type_of(obj) {
|
|
1164
1100
|
return obj && "undefined" != typeof Symbol && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
1165
1101
|
}
|
|
@@ -1171,110 +1107,168 @@ function escapeValue(value) {
|
|
|
1171
1107
|
if (value instanceof Date) return "'".concat(value.toISOString(), "'");
|
|
1172
1108
|
throw new TypeError("Unsupported parameter type: ".concat(void 0 === value ? "undefined" : escape_type_of(value)));
|
|
1173
1109
|
}
|
|
1174
|
-
|
|
1110
|
+
new lruCache_LRUCache({
|
|
1175
1111
|
maxSize: 256,
|
|
1176
1112
|
maxKeyLength: 4096
|
|
1177
1113
|
});
|
|
1178
|
-
function
|
|
1179
|
-
var segments =
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1114
|
+
function interpolateFromTemplate(template, params) {
|
|
1115
|
+
var segments = template.segments, paramCount = template.paramCount;
|
|
1116
|
+
if (params.length < paramCount) throw new Error("Too few parameters provided");
|
|
1117
|
+
if (params.length > paramCount) throw new Error("Too many parameters provided");
|
|
1118
|
+
if (0 === paramCount) return segments[0];
|
|
1119
|
+
var parts = [
|
|
1120
|
+
segments[0]
|
|
1121
|
+
];
|
|
1122
|
+
for(var i = 0; i < params.length; i++){
|
|
1123
|
+
parts.push(escapeValue(params[i]));
|
|
1124
|
+
parts.push(segments[i + 1]);
|
|
1125
|
+
}
|
|
1126
|
+
return parts.join("");
|
|
1127
|
+
}
|
|
1128
|
+
var constants_CC_SINGLE_QUOTE = 39;
|
|
1129
|
+
var constants_CC_DOUBLE_QUOTE = 34;
|
|
1130
|
+
var constants_CC_DASH = 45;
|
|
1131
|
+
var constants_CC_SLASH = 47;
|
|
1132
|
+
var constants_CC_STAR = 42;
|
|
1133
|
+
var constants_CC_NEWLINE = 10;
|
|
1134
|
+
var constants_CC_QUESTION = 63;
|
|
1135
|
+
var CC_SEMICOLON = 59;
|
|
1136
|
+
var CC_SPACE = 32;
|
|
1137
|
+
var constants_STATE_NORMAL = 0;
|
|
1138
|
+
var constants_STATE_SINGLE_QUOTE = 1;
|
|
1139
|
+
var constants_STATE_DOUBLE_QUOTE = 2;
|
|
1140
|
+
var constants_STATE_LINE_COMMENT = 3;
|
|
1141
|
+
var constants_STATE_BLOCK_COMMENT = 4;
|
|
1142
|
+
var _normDecoder = new TextDecoder("utf-16le");
|
|
1143
|
+
var _normCache = new lruCache_LRUCache({
|
|
1144
|
+
maxSize: 256,
|
|
1145
|
+
maxKeyLength: 4096
|
|
1146
|
+
});
|
|
1147
|
+
function _normalize(sql) {
|
|
1148
|
+
var len = sql.length;
|
|
1149
|
+
var needed = len + 1;
|
|
1150
|
+
var outCodes = new Uint16Array(needed);
|
|
1151
|
+
var writePos = 0;
|
|
1152
|
+
var pendingSpace = false;
|
|
1153
|
+
var state = constants_STATE_NORMAL;
|
|
1154
|
+
var questionPositions = [];
|
|
1155
|
+
for(var i = 0; i < len; i++){
|
|
1156
|
+
var code = sql.charCodeAt(i);
|
|
1157
|
+
var nextCode = sql.charCodeAt(i + 1);
|
|
1158
|
+
if (state === constants_STATE_BLOCK_COMMENT) {
|
|
1159
|
+
if (code === constants_CC_STAR && nextCode === constants_CC_SLASH) {
|
|
1160
|
+
state = constants_STATE_NORMAL;
|
|
1161
|
+
i++;
|
|
1162
|
+
if (writePos > 0) pendingSpace = true;
|
|
1190
1163
|
}
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1164
|
+
continue;
|
|
1165
|
+
}
|
|
1166
|
+
if (state === constants_STATE_LINE_COMMENT) {
|
|
1167
|
+
if (code === constants_CC_NEWLINE) {
|
|
1168
|
+
state = constants_STATE_NORMAL;
|
|
1169
|
+
if (writePos > 0) pendingSpace = true;
|
|
1195
1170
|
}
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1171
|
+
continue;
|
|
1172
|
+
}
|
|
1173
|
+
if (state === constants_STATE_NORMAL) {
|
|
1174
|
+
if (code === constants_CC_DASH && nextCode === constants_CC_DASH) {
|
|
1175
|
+
state = constants_STATE_LINE_COMMENT;
|
|
1176
|
+
i++;
|
|
1199
1177
|
continue;
|
|
1200
1178
|
}
|
|
1201
|
-
if (code ===
|
|
1202
|
-
state =
|
|
1203
|
-
|
|
1204
|
-
pos++;
|
|
1179
|
+
if (code === constants_CC_SLASH && nextCode === constants_CC_STAR) {
|
|
1180
|
+
state = constants_STATE_BLOCK_COMMENT;
|
|
1181
|
+
i++;
|
|
1205
1182
|
continue;
|
|
1206
1183
|
}
|
|
1207
|
-
if (code === CC_QUESTION) {
|
|
1208
|
-
segments.push(sql.slice(segStart, pos));
|
|
1209
|
-
segStart = pos + 1;
|
|
1210
|
-
}
|
|
1211
|
-
continue;
|
|
1212
1184
|
}
|
|
1213
|
-
if (
|
|
1214
|
-
if (
|
|
1215
|
-
if (sql.charCodeAt(pos + 1) === CC_SINGLE_QUOTE) {
|
|
1216
|
-
pos++;
|
|
1217
|
-
continue;
|
|
1218
|
-
}
|
|
1219
|
-
state = STATE_NORMAL;
|
|
1220
|
-
stateStartPos = -1;
|
|
1221
|
-
}
|
|
1185
|
+
if (32 === code || 9 === code || 10 === code || 11 === code || 12 === code || 13 === code) {
|
|
1186
|
+
if (writePos > 0) pendingSpace = true;
|
|
1222
1187
|
continue;
|
|
1223
1188
|
}
|
|
1224
|
-
if (
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1189
|
+
if (pendingSpace && writePos > 0) {
|
|
1190
|
+
outCodes[writePos++] = CC_SPACE;
|
|
1191
|
+
pendingSpace = false;
|
|
1192
|
+
}
|
|
1193
|
+
if (code === constants_CC_QUESTION && state === constants_STATE_NORMAL) questionPositions.push(writePos);
|
|
1194
|
+
outCodes[writePos++] = code;
|
|
1195
|
+
if (state === constants_STATE_NORMAL) {
|
|
1196
|
+
if (code === constants_CC_SINGLE_QUOTE) state = constants_STATE_SINGLE_QUOTE;
|
|
1197
|
+
else if (code === constants_CC_DOUBLE_QUOTE) state = constants_STATE_DOUBLE_QUOTE;
|
|
1233
1198
|
continue;
|
|
1234
1199
|
}
|
|
1235
|
-
if (state ===
|
|
1236
|
-
if (code ===
|
|
1200
|
+
if (state === constants_STATE_SINGLE_QUOTE) {
|
|
1201
|
+
if (code === constants_CC_SINGLE_QUOTE && nextCode === constants_CC_SINGLE_QUOTE) {
|
|
1202
|
+
outCodes[writePos++] = nextCode;
|
|
1203
|
+
i++;
|
|
1204
|
+
continue;
|
|
1205
|
+
}
|
|
1206
|
+
if (code === constants_CC_SINGLE_QUOTE) state = constants_STATE_NORMAL;
|
|
1237
1207
|
continue;
|
|
1238
1208
|
}
|
|
1239
|
-
if (state ===
|
|
1240
|
-
if (code ===
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1209
|
+
if (state === constants_STATE_DOUBLE_QUOTE) {
|
|
1210
|
+
if (code === constants_CC_DOUBLE_QUOTE && nextCode === constants_CC_DOUBLE_QUOTE) {
|
|
1211
|
+
outCodes[writePos++] = nextCode;
|
|
1212
|
+
i++;
|
|
1213
|
+
continue;
|
|
1244
1214
|
}
|
|
1215
|
+
if (code === constants_CC_DOUBLE_QUOTE) state = constants_STATE_NORMAL;
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
var normalized;
|
|
1219
|
+
if (0 === writePos) normalized = ";";
|
|
1220
|
+
else {
|
|
1221
|
+
while(writePos > 0 && outCodes[writePos - 1] === CC_SEMICOLON)writePos--;
|
|
1222
|
+
outCodes[writePos++] = CC_SEMICOLON;
|
|
1223
|
+
normalized = _normDecoder.decode(outCodes.subarray(0, writePos));
|
|
1224
|
+
}
|
|
1225
|
+
var paramCount = questionPositions.length;
|
|
1226
|
+
if (0 === paramCount) return {
|
|
1227
|
+
normalized: normalized,
|
|
1228
|
+
segments: [
|
|
1229
|
+
normalized
|
|
1230
|
+
],
|
|
1231
|
+
paramCount: 0
|
|
1232
|
+
};
|
|
1233
|
+
var segments = [];
|
|
1234
|
+
var segStart = 0;
|
|
1235
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
1236
|
+
try {
|
|
1237
|
+
for(var _iterator = questionPositions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1238
|
+
var pos = _step.value;
|
|
1239
|
+
segments.push(normalized.slice(segStart, pos));
|
|
1240
|
+
segStart = pos + 1;
|
|
1241
|
+
}
|
|
1242
|
+
} catch (err) {
|
|
1243
|
+
_didIteratorError = true;
|
|
1244
|
+
_iteratorError = err;
|
|
1245
|
+
} finally{
|
|
1246
|
+
try {
|
|
1247
|
+
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
1248
|
+
} finally{
|
|
1249
|
+
if (_didIteratorError) throw _iteratorError;
|
|
1245
1250
|
}
|
|
1246
1251
|
}
|
|
1247
|
-
|
|
1248
|
-
if (state === STATE_DOUBLE_QUOTE) throw new Error("Unterminated double-quoted identifier/string starting at position ".concat(stateStartPos + 1));
|
|
1249
|
-
if (state === STATE_BLOCK_COMMENT) throw new Error("Unterminated block comment starting at position ".concat(stateStartPos + 1));
|
|
1250
|
-
segments.push(sql.slice(segStart));
|
|
1252
|
+
segments.push(normalized.slice(segStart));
|
|
1251
1253
|
return {
|
|
1254
|
+
normalized: normalized,
|
|
1252
1255
|
segments: segments,
|
|
1253
|
-
paramCount:
|
|
1256
|
+
paramCount: paramCount
|
|
1254
1257
|
};
|
|
1255
1258
|
}
|
|
1256
|
-
function
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
var
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
if (0 === paramCount) return segments[0];
|
|
1270
|
-
var parts = [
|
|
1271
|
-
segments[0]
|
|
1272
|
-
];
|
|
1273
|
-
for(var i = 0; i < params.length; i++){
|
|
1274
|
-
parts.push(escapeValue(params[i]));
|
|
1275
|
-
parts.push(segments[i + 1]);
|
|
1276
|
-
}
|
|
1277
|
-
return parts.join("");
|
|
1259
|
+
function normalizeSQL(sql) {
|
|
1260
|
+
var cached = _normCache.get(sql);
|
|
1261
|
+
if (void 0 !== cached) return cached.normalized;
|
|
1262
|
+
var result = _normalize(sql);
|
|
1263
|
+
_normCache.set(sql, result);
|
|
1264
|
+
return result.normalized;
|
|
1265
|
+
}
|
|
1266
|
+
function normalizeSQLTemplate(sql) {
|
|
1267
|
+
var cached = _normCache.get(sql);
|
|
1268
|
+
if (void 0 !== cached) return cached;
|
|
1269
|
+
var result = _normalize(sql);
|
|
1270
|
+
_normCache.set(sql, result);
|
|
1271
|
+
return result;
|
|
1278
1272
|
}
|
|
1279
1273
|
var READ_ONLY_KINDS = new Set([
|
|
1280
1274
|
"SELECT",
|
|
@@ -1293,13 +1287,17 @@ function classifySingle(stmt) {
|
|
|
1293
1287
|
return READ_ONLY_KINDS.has(kind) ? "read" : "write";
|
|
1294
1288
|
}
|
|
1295
1289
|
function classifySQL(sql) {
|
|
1296
|
-
if ("string" != typeof sql
|
|
1290
|
+
if ("string" != typeof sql) return "write";
|
|
1297
1291
|
var cached = _classifyCache.get(sql);
|
|
1298
1292
|
if (void 0 !== cached) return cached;
|
|
1299
1293
|
var trimmed = sql.trim();
|
|
1294
|
+
if (0 === trimmed.length) return "write";
|
|
1300
1295
|
var result;
|
|
1301
1296
|
if (trimmed.includes(";")) {
|
|
1302
|
-
var stmts = trimmed.split(";")
|
|
1297
|
+
var stmts = trimmed.split(";").filter(function(s) {
|
|
1298
|
+
return s.trim().length > 0;
|
|
1299
|
+
});
|
|
1300
|
+
if (0 === stmts.length) return "write";
|
|
1303
1301
|
result = "read";
|
|
1304
1302
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
1305
1303
|
try {
|
|
@@ -1720,8 +1718,11 @@ function buildPayload(sql, token) {
|
|
|
1720
1718
|
return "".concat(normalized).concat(suffix, "\nSELECT '").concat(token, "' AS ").concat(TOKEN_COLUMN, ";\n");
|
|
1721
1719
|
}
|
|
1722
1720
|
function isTransactionControl(sql) {
|
|
1723
|
-
var
|
|
1724
|
-
|
|
1721
|
+
var f = sql.charCodeAt(0);
|
|
1722
|
+
if (66 === f || 98 === f) return "BEGIN" === sql || "BEGIN;" === sql || sql.startsWith("BEGIN ") || sql.startsWith("BEGIN;");
|
|
1723
|
+
if (67 === f || 99 === f) return "COMMIT" === sql || "COMMIT;" === sql || sql.startsWith("COMMIT ") || sql.startsWith("COMMIT;");
|
|
1724
|
+
if (82 === f || 114 === f) return "ROLLBACK" === sql || "ROLLBACK;" === sql || sql.startsWith("ROLLBACK ") || sql.startsWith("ROLLBACK;");
|
|
1725
|
+
return false;
|
|
1725
1726
|
}
|
|
1726
1727
|
function buildBatchPayload(batch) {
|
|
1727
1728
|
var useWalBatch = batch.length > 1 && batch.every(function(t) {
|
|
@@ -1787,43 +1788,21 @@ function buildBatchPayload(batch) {
|
|
|
1787
1788
|
}
|
|
1788
1789
|
return parts1.join("");
|
|
1789
1790
|
}
|
|
1791
|
+
var TC_FIRST_CHAR = TOKEN_COLUMN.charCodeAt(0);
|
|
1792
|
+
function buildSentinelStr(token) {
|
|
1793
|
+
return '[{"'.concat(TOKEN_COLUMN, '":"').concat(token, '"}]');
|
|
1794
|
+
}
|
|
1790
1795
|
function isSentinelRaw(raw, token) {
|
|
1791
|
-
return raw ===
|
|
1796
|
+
return raw.charCodeAt(3) === TC_FIRST_CHAR && raw === buildSentinelStr(token);
|
|
1792
1797
|
}
|
|
1793
1798
|
function isSentinelRow(value, token) {
|
|
1794
1799
|
var _value_;
|
|
1795
1800
|
return Array.isArray(value) && 1 === value.length && (null == (_value_ = value[0]) ? void 0 : _value_[TOKEN_COLUMN]) === token;
|
|
1796
1801
|
}
|
|
1797
|
-
function _array_like_to_array(arr, len) {
|
|
1798
|
-
if (null == len || len > arr.length) len = arr.length;
|
|
1799
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
1800
|
-
return arr2;
|
|
1801
|
-
}
|
|
1802
|
-
function _array_without_holes(arr) {
|
|
1803
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
1804
|
-
}
|
|
1805
|
-
function _iterable_to_array(iter) {
|
|
1806
|
-
if ("undefined" != typeof Symbol && null != iter[Symbol.iterator] || null != iter["@@iterator"]) return Array.from(iter);
|
|
1807
|
-
}
|
|
1808
|
-
function _non_iterable_spread() {
|
|
1809
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1810
|
-
}
|
|
1811
|
-
function _to_consumable_array(arr) {
|
|
1812
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
1813
|
-
}
|
|
1814
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
1815
|
-
if (!o) return;
|
|
1816
|
-
if ("string" == typeof o) return _array_like_to_array(o, minLen);
|
|
1817
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1818
|
-
if ("Object" === n && o.constructor) n = o.constructor.name;
|
|
1819
|
-
if ("Map" === n || "Set" === n) return Array.from(n);
|
|
1820
|
-
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
1821
|
-
}
|
|
1822
1802
|
function collectQueryRows(task, parsed) {
|
|
1823
1803
|
if (Array.isArray(parsed)) {
|
|
1824
|
-
var _task_rows;
|
|
1825
1804
|
if (!task.rows) task.rows = [];
|
|
1826
|
-
(
|
|
1805
|
+
for(var i = 0; i < parsed.length; i++)task.rows.push(parsed[i]);
|
|
1827
1806
|
}
|
|
1828
1807
|
}
|
|
1829
1808
|
function processStreamRows(task, parsed) {
|
|
@@ -1854,7 +1833,6 @@ function settleTask(task, error, value, metrics) {
|
|
|
1854
1833
|
var _ref = arguments.length > 4 && void 0 !== arguments[4] ? arguments[4] : {}, _ref_resetRowParser = _ref.resetRowParser, resetRowParser = void 0 === _ref_resetRowParser ? false : _ref_resetRowParser;
|
|
1855
1834
|
if (task.settled) return;
|
|
1856
1835
|
task.settled = true;
|
|
1857
|
-
clearTimeout(task.timer);
|
|
1858
1836
|
if (resetRowParser) {
|
|
1859
1837
|
var _task_rowParser_reset, _task_rowParser;
|
|
1860
1838
|
null == (_task_rowParser = task.rowParser) || null == (_task_rowParser_reset = _task_rowParser.reset) || _task_rowParser_reset.call(_task_rowParser);
|
|
@@ -1903,18 +1881,16 @@ function finalizePendingTasks(tasks, settle, pumpQueue) {
|
|
|
1903
1881
|
function prepareTaskTimeout(task, metrics) {
|
|
1904
1882
|
if (task.settled) return null;
|
|
1905
1883
|
task.timedout = true;
|
|
1906
|
-
clearTimeout(task.timer);
|
|
1907
|
-
task.timer = null;
|
|
1908
1884
|
null == metrics || metrics.incrementTasksTimeout();
|
|
1909
1885
|
return createTimeoutError(task.timeout, task.sql);
|
|
1910
1886
|
}
|
|
1911
|
-
function
|
|
1887
|
+
function _array_like_to_array(arr, len) {
|
|
1912
1888
|
if (null == len || len > arr.length) len = arr.length;
|
|
1913
1889
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
1914
1890
|
return arr2;
|
|
1915
1891
|
}
|
|
1916
|
-
function
|
|
1917
|
-
if (Array.isArray(arr)) return
|
|
1892
|
+
function _array_without_holes(arr) {
|
|
1893
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
1918
1894
|
}
|
|
1919
1895
|
function taskWorker_check_private_redeclaration(obj, privateCollection) {
|
|
1920
1896
|
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
@@ -1930,6 +1906,22 @@ function taskWorker_class_apply_descriptor_set(receiver, descriptor, value) {
|
|
|
1930
1906
|
descriptor.value = value;
|
|
1931
1907
|
}
|
|
1932
1908
|
}
|
|
1909
|
+
function taskWorker_class_apply_descriptor_update(receiver, descriptor) {
|
|
1910
|
+
if (descriptor.set) {
|
|
1911
|
+
if (!descriptor.get) throw new TypeError("attempted to read set only private field");
|
|
1912
|
+
if (!("__destrWrapper" in descriptor)) descriptor.__destrWrapper = {
|
|
1913
|
+
set value (v){
|
|
1914
|
+
descriptor.set.call(receiver, v);
|
|
1915
|
+
},
|
|
1916
|
+
get value () {
|
|
1917
|
+
return descriptor.get.call(receiver);
|
|
1918
|
+
}
|
|
1919
|
+
};
|
|
1920
|
+
return descriptor.__destrWrapper;
|
|
1921
|
+
}
|
|
1922
|
+
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
1923
|
+
return descriptor;
|
|
1924
|
+
}
|
|
1933
1925
|
function taskWorker_class_call_check(instance, Constructor) {
|
|
1934
1926
|
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
1935
1927
|
}
|
|
@@ -1950,6 +1942,10 @@ function taskWorker_class_private_field_set(receiver, privateMap, value) {
|
|
|
1950
1942
|
taskWorker_class_apply_descriptor_set(receiver, descriptor, value);
|
|
1951
1943
|
return value;
|
|
1952
1944
|
}
|
|
1945
|
+
function taskWorker_class_private_field_update(receiver, privateMap) {
|
|
1946
|
+
var descriptor = taskWorker_class_extract_field_descriptor(receiver, privateMap, "update");
|
|
1947
|
+
return taskWorker_class_apply_descriptor_update(receiver, descriptor);
|
|
1948
|
+
}
|
|
1953
1949
|
function taskWorker_class_private_method_get(receiver, privateSet, fn) {
|
|
1954
1950
|
if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
|
|
1955
1951
|
return fn;
|
|
@@ -1972,35 +1968,39 @@ function taskWorker_create_class(Constructor, protoProps, staticProps) {
|
|
|
1972
1968
|
if (staticProps) taskWorker_defineProperties(Constructor, staticProps);
|
|
1973
1969
|
return Constructor;
|
|
1974
1970
|
}
|
|
1975
|
-
function
|
|
1971
|
+
function _iterable_to_array(iter) {
|
|
1976
1972
|
if ("undefined" != typeof Symbol && null != iter[Symbol.iterator] || null != iter["@@iterator"]) return Array.from(iter);
|
|
1977
1973
|
}
|
|
1978
|
-
function
|
|
1974
|
+
function _non_iterable_spread() {
|
|
1979
1975
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1980
1976
|
}
|
|
1981
|
-
function
|
|
1982
|
-
return
|
|
1977
|
+
function _to_consumable_array(arr) {
|
|
1978
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
1983
1979
|
}
|
|
1984
|
-
function
|
|
1980
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
1985
1981
|
if (!o) return;
|
|
1986
|
-
if ("string" == typeof o) return
|
|
1982
|
+
if ("string" == typeof o) return _array_like_to_array(o, minLen);
|
|
1987
1983
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1988
1984
|
if ("Object" === n && o.constructor) n = o.constructor.name;
|
|
1989
1985
|
if ("Map" === n || "Set" === n) return Array.from(n);
|
|
1990
|
-
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return
|
|
1986
|
+
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
1991
1987
|
}
|
|
1992
|
-
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();
|
|
1988
|
+
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();
|
|
1993
1989
|
var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
1994
1990
|
"use strict";
|
|
1995
1991
|
function TaskWorker(param) {
|
|
1996
1992
|
var _this = this;
|
|
1997
|
-
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;
|
|
1993
|
+
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;
|
|
1998
1994
|
taskWorker_class_call_check(this, TaskWorker);
|
|
1999
1995
|
taskWorker_class_private_method_init(this, _startProcess);
|
|
1996
|
+
taskWorker_class_private_method_init(this, _inflightCount);
|
|
1997
|
+
taskWorker_class_private_method_init(this, _firstInflight);
|
|
1998
|
+
taskWorker_class_private_method_init(this, _shiftInflight);
|
|
2000
1999
|
taskWorker_class_private_method_init(this, _pumpQueue);
|
|
2001
2000
|
taskWorker_class_private_method_init(this, _handleParsedValue);
|
|
2002
2001
|
taskWorker_class_private_method_init(this, _scheduleFinalizeCheck);
|
|
2003
2002
|
taskWorker_class_private_method_init(this, _handleStderrChunk);
|
|
2003
|
+
taskWorker_class_private_method_init(this, _scheduleSweep);
|
|
2004
2004
|
taskWorker_class_private_method_init(this, _handleTaskTimeout);
|
|
2005
2005
|
taskWorker_class_private_method_init(this, _settleTask);
|
|
2006
2006
|
taskWorker_class_private_method_init(this, _rejectAll);
|
|
@@ -2016,6 +2016,10 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2016
2016
|
writable: true,
|
|
2017
2017
|
value: []
|
|
2018
2018
|
});
|
|
2019
|
+
taskWorker_class_private_field_init(this, _inflightHead, {
|
|
2020
|
+
writable: true,
|
|
2021
|
+
value: 0
|
|
2022
|
+
});
|
|
2019
2023
|
taskWorker_class_private_field_init(this, _pendingFinalizeTasks, {
|
|
2020
2024
|
writable: true,
|
|
2021
2025
|
value: new Set()
|
|
@@ -2052,12 +2056,21 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2052
2056
|
writable: true,
|
|
2053
2057
|
value: void 0
|
|
2054
2058
|
});
|
|
2059
|
+
taskWorker_class_private_field_init(this, _sweepTimer, {
|
|
2060
|
+
writable: true,
|
|
2061
|
+
value: null
|
|
2062
|
+
});
|
|
2063
|
+
taskWorker_class_private_field_init(this, _sweepIntervalMs, {
|
|
2064
|
+
writable: true,
|
|
2065
|
+
value: void 0
|
|
2066
|
+
});
|
|
2055
2067
|
taskWorker_class_private_field_set(this, _name, null != name ? name : "worker");
|
|
2056
2068
|
taskWorker_class_private_field_set(this, _statementTimeout, statementTimeout);
|
|
2057
2069
|
taskWorker_class_private_field_set(this, _logger, logger);
|
|
2058
2070
|
taskWorker_class_private_field_set(this, _batchSize, batchSize);
|
|
2059
2071
|
taskWorker_class_private_field_set(this, _maxInflight, maxInflight);
|
|
2060
2072
|
taskWorker_class_private_field_set(this, _metrics, metrics);
|
|
2073
|
+
taskWorker_class_private_field_set(this, _sweepIntervalMs, sweepInterval);
|
|
2061
2074
|
taskWorker_class_private_field_set(this, _processManager, new process_ProcessManager({
|
|
2062
2075
|
binary: binary,
|
|
2063
2076
|
database: database,
|
|
@@ -2081,13 +2094,13 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2081
2094
|
{
|
|
2082
2095
|
key: "idle",
|
|
2083
2096
|
get: function() {
|
|
2084
|
-
return
|
|
2097
|
+
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;
|
|
2085
2098
|
}
|
|
2086
2099
|
},
|
|
2087
2100
|
{
|
|
2088
2101
|
key: "pendingStatements",
|
|
2089
2102
|
get: function() {
|
|
2090
|
-
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;
|
|
2103
|
+
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;
|
|
2091
2104
|
}
|
|
2092
2105
|
},
|
|
2093
2106
|
{
|
|
@@ -2107,8 +2120,6 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2107
2120
|
consumerError: null,
|
|
2108
2121
|
stderrText: "",
|
|
2109
2122
|
settled: false,
|
|
2110
|
-
errorScheduled: false,
|
|
2111
|
-
timer: null,
|
|
2112
2123
|
startTime: 0
|
|
2113
2124
|
};
|
|
2114
2125
|
null == (_$_class_private_field_get = taskWorker_class_private_field_get(this, _metrics)) || _$_class_private_field_get.incrementTasksTotal(config.kind);
|
|
@@ -2116,6 +2127,12 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2116
2127
|
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2117
2128
|
}
|
|
2118
2129
|
},
|
|
2130
|
+
{
|
|
2131
|
+
key: "_sweepTimer",
|
|
2132
|
+
get: function() {
|
|
2133
|
+
return taskWorker_class_private_field_get(this, _sweepTimer);
|
|
2134
|
+
}
|
|
2135
|
+
},
|
|
2119
2136
|
{
|
|
2120
2137
|
key: "_process",
|
|
2121
2138
|
get: function() {
|
|
@@ -2125,6 +2142,8 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2125
2142
|
{
|
|
2126
2143
|
key: "kill",
|
|
2127
2144
|
value: function() {
|
|
2145
|
+
clearTimeout(taskWorker_class_private_field_get(this, _sweepTimer));
|
|
2146
|
+
taskWorker_class_private_field_set(this, _sweepTimer, null);
|
|
2128
2147
|
taskWorker_class_private_method_get(this, _rejectAll, taskWorker_rejectAll).call(this, new Error("".concat(taskWorker_class_private_field_get(this, _name), " is killed")));
|
|
2129
2148
|
taskWorker_class_private_field_get(this, _processManager).kill();
|
|
2130
2149
|
}
|
|
@@ -2153,15 +2172,33 @@ function startProcess() {
|
|
|
2153
2172
|
taskWorker_class_private_method_get(_this, _rejectAll, taskWorker_rejectAll).call(_this, err);
|
|
2154
2173
|
});
|
|
2155
2174
|
}
|
|
2175
|
+
function inflightCount() {
|
|
2176
|
+
return taskWorker_class_private_field_get(this, _inflightTasks).length - taskWorker_class_private_field_get(this, _inflightHead);
|
|
2177
|
+
}
|
|
2178
|
+
function firstInflight() {
|
|
2179
|
+
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;
|
|
2180
|
+
}
|
|
2181
|
+
function shiftInflight() {
|
|
2182
|
+
var task = taskWorker_class_private_field_get(this, _inflightTasks)[taskWorker_class_private_field_get(this, _inflightHead)];
|
|
2183
|
+
taskWorker_class_private_field_get(this, _inflightTasks)[taskWorker_class_private_field_get(this, _inflightHead)] = null;
|
|
2184
|
+
taskWorker_class_private_field_update(this, _inflightHead).value++;
|
|
2185
|
+
if (taskWorker_class_private_field_get(this, _inflightHead) >= taskWorker_class_private_field_get(this, _inflightTasks).length) {
|
|
2186
|
+
taskWorker_class_private_field_set(this, _inflightTasks, []);
|
|
2187
|
+
taskWorker_class_private_field_set(this, _inflightHead, 0);
|
|
2188
|
+
} else if (taskWorker_class_private_field_get(this, _inflightHead) > 128) {
|
|
2189
|
+
taskWorker_class_private_field_set(this, _inflightTasks, taskWorker_class_private_field_get(this, _inflightTasks).slice(taskWorker_class_private_field_get(this, _inflightHead)));
|
|
2190
|
+
taskWorker_class_private_field_set(this, _inflightHead, 0);
|
|
2191
|
+
}
|
|
2192
|
+
return task;
|
|
2193
|
+
}
|
|
2156
2194
|
function taskWorker_pumpQueue() {
|
|
2157
|
-
var _this = this;
|
|
2158
2195
|
var _$_class_private_field_get;
|
|
2159
2196
|
if (taskWorker_class_private_field_get(this, _processManager).draining) return;
|
|
2160
|
-
if (
|
|
2197
|
+
if (taskWorker_class_private_method_get(this, _inflightCount, inflightCount).call(this) >= taskWorker_class_private_field_get(this, _maxInflight)) return;
|
|
2161
2198
|
var batch = [];
|
|
2162
|
-
while(batch.length < taskWorker_class_private_field_get(this, _batchSize) && !taskWorker_class_private_field_get(this, _pendingQueue).isEmpty() &&
|
|
2199
|
+
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)){
|
|
2163
2200
|
var task = taskWorker_class_private_field_get(this, _pendingQueue).peek();
|
|
2164
|
-
if ("stream" === task.kind && (batch.length > 0 ||
|
|
2201
|
+
if ("stream" === task.kind && (batch.length > 0 || taskWorker_class_private_method_get(this, _inflightCount, inflightCount).call(this) > 0)) break;
|
|
2165
2202
|
taskWorker_class_private_field_get(this, _pendingQueue).dequeue();
|
|
2166
2203
|
batch.push(task);
|
|
2167
2204
|
}
|
|
@@ -2170,15 +2207,10 @@ function taskWorker_pumpQueue() {
|
|
|
2170
2207
|
var payload = buildBatchPayload(batch);
|
|
2171
2208
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
2172
2209
|
try {
|
|
2173
|
-
var
|
|
2174
|
-
var
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
task.timer = setTimeout(function() {
|
|
2178
|
-
return taskWorker_class_private_method_get(_this, _handleTaskTimeout, handleTaskTimeout).call(_this, task);
|
|
2179
|
-
}, null != (_task_timeout = task.timeout) ? _task_timeout : taskWorker_class_private_field_get(_this1, _statementTimeout));
|
|
2180
|
-
};
|
|
2181
|
-
for(var _iterator = batch[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_this1 = this, _loop();
|
|
2210
|
+
for(var _iterator = batch[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2211
|
+
var task1 = _step.value;
|
|
2212
|
+
task1.startTime = now;
|
|
2213
|
+
}
|
|
2182
2214
|
} catch (err) {
|
|
2183
2215
|
_didIteratorError = true;
|
|
2184
2216
|
_iteratorError = err;
|
|
@@ -2189,15 +2221,15 @@ function taskWorker_pumpQueue() {
|
|
|
2189
2221
|
if (_didIteratorError) throw _iteratorError;
|
|
2190
2222
|
}
|
|
2191
2223
|
}
|
|
2192
|
-
(_$_class_private_field_get = taskWorker_class_private_field_get(this, _inflightTasks)).push.apply(_$_class_private_field_get,
|
|
2224
|
+
(_$_class_private_field_get = taskWorker_class_private_field_get(this, _inflightTasks)).push.apply(_$_class_private_field_get, _to_consumable_array(batch));
|
|
2225
|
+
taskWorker_class_private_method_get(this, _scheduleSweep, scheduleSweep).call(this);
|
|
2193
2226
|
taskWorker_class_private_field_get(this, _processManager).write(payload);
|
|
2194
2227
|
}
|
|
2195
2228
|
function handleParsedValue(raw) {
|
|
2196
|
-
var task =
|
|
2229
|
+
var task = taskWorker_class_private_method_get(this, _firstInflight, firstInflight).call(this);
|
|
2197
2230
|
if (!task) return;
|
|
2198
2231
|
if (isSentinelRaw(raw, task.token)) {
|
|
2199
|
-
|
|
2200
|
-
taskWorker_class_private_field_get(this, _inflightTasks).shift();
|
|
2232
|
+
taskWorker_class_private_method_get(this, _shiftInflight, shiftInflight).call(this);
|
|
2201
2233
|
if (task.timedout) return void taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2202
2234
|
if (task.stderrText) {
|
|
2203
2235
|
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, new Error(task.stderrText.trim()), void 0);
|
|
@@ -2223,8 +2255,7 @@ function handleParsedValue(raw) {
|
|
|
2223
2255
|
return;
|
|
2224
2256
|
}
|
|
2225
2257
|
if (isSentinelRow(parsed, task.token)) {
|
|
2226
|
-
|
|
2227
|
-
taskWorker_class_private_field_get(this, _inflightTasks).shift();
|
|
2258
|
+
taskWorker_class_private_method_get(this, _shiftInflight, shiftInflight).call(this);
|
|
2228
2259
|
if (task.timedout) return void taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2229
2260
|
if (task.stderrText) {
|
|
2230
2261
|
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, new Error(task.stderrText.trim()), void 0);
|
|
@@ -2241,6 +2272,7 @@ function handleParsedValue(raw) {
|
|
|
2241
2272
|
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2242
2273
|
return;
|
|
2243
2274
|
}
|
|
2275
|
+
if (task.timedout) return;
|
|
2244
2276
|
if ("query" === task.kind) return void collectQueryRows(task, parsed);
|
|
2245
2277
|
if ("stream" === task.kind) processStreamRows(task, parsed);
|
|
2246
2278
|
}
|
|
@@ -2258,14 +2290,29 @@ function scheduleFinalizeCheck() {
|
|
|
2258
2290
|
});
|
|
2259
2291
|
}
|
|
2260
2292
|
function taskWorker_handleStderrChunk(chunk) {
|
|
2261
|
-
var
|
|
2262
|
-
var task = null != (
|
|
2293
|
+
var _class_private_field_get_values_next_value;
|
|
2294
|
+
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);
|
|
2263
2295
|
if (!task) {
|
|
2264
2296
|
var _class_private_field_get_error, _$_class_private_field_get;
|
|
2265
|
-
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,
|
|
2297
|
+
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());
|
|
2266
2298
|
return;
|
|
2267
2299
|
}
|
|
2268
|
-
task.stderrText +=
|
|
2300
|
+
task.stderrText += chunk;
|
|
2301
|
+
}
|
|
2302
|
+
function scheduleSweep() {
|
|
2303
|
+
var _this = this;
|
|
2304
|
+
if (taskWorker_class_private_field_get(this, _sweepTimer)) return;
|
|
2305
|
+
taskWorker_class_private_field_set(this, _sweepTimer, setTimeout(function() {
|
|
2306
|
+
taskWorker_class_private_field_set(_this, _sweepTimer, null);
|
|
2307
|
+
var tasks = taskWorker_class_private_field_get(_this, _inflightTasks);
|
|
2308
|
+
var head = taskWorker_class_private_field_get(_this, _inflightHead);
|
|
2309
|
+
var now = performance.now();
|
|
2310
|
+
for(var i = head; i < tasks.length; i++){
|
|
2311
|
+
var task = tasks[i];
|
|
2312
|
+
if (now - task.startTime > task.timeout) taskWorker_class_private_method_get(_this, _handleTaskTimeout, handleTaskTimeout).call(_this, task);
|
|
2313
|
+
}
|
|
2314
|
+
if (taskWorker_class_private_method_get(_this, _inflightCount, inflightCount).call(_this) > 0) taskWorker_class_private_method_get(_this, _scheduleSweep, scheduleSweep).call(_this);
|
|
2315
|
+
}, taskWorker_class_private_field_get(this, _sweepIntervalMs)).unref());
|
|
2269
2316
|
}
|
|
2270
2317
|
function handleTaskTimeout(task) {
|
|
2271
2318
|
var error = prepareTaskTimeout(task, taskWorker_class_private_field_get(this, _metrics));
|
|
@@ -2275,8 +2322,12 @@ function settleTask1(task, error, value) {
|
|
|
2275
2322
|
settleTask(task, error, value, taskWorker_class_private_field_get(this, _metrics));
|
|
2276
2323
|
}
|
|
2277
2324
|
function taskWorker_rejectAll(error) {
|
|
2278
|
-
|
|
2325
|
+
clearTimeout(taskWorker_class_private_field_get(this, _sweepTimer));
|
|
2326
|
+
taskWorker_class_private_field_set(this, _sweepTimer, null);
|
|
2327
|
+
var activeCount = taskWorker_class_private_field_get(this, _inflightTasks).length - taskWorker_class_private_field_get(this, _inflightHead);
|
|
2328
|
+
var all = activeCount > 0 ? taskWorker_class_private_field_get(this, _inflightTasks).slice(taskWorker_class_private_field_get(this, _inflightHead)) : [];
|
|
2279
2329
|
taskWorker_class_private_field_set(this, _inflightTasks, []);
|
|
2330
|
+
taskWorker_class_private_field_set(this, _inflightHead, 0);
|
|
2280
2331
|
var queued = taskWorker_class_private_field_get(this, _pendingQueue).dequeue();
|
|
2281
2332
|
while(queued){
|
|
2282
2333
|
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, queued, error, void 0);
|
|
@@ -2410,9 +2461,19 @@ var readerPool_ReaderPool = /*#__PURE__*/ function() {
|
|
|
2410
2461
|
{
|
|
2411
2462
|
key: "enqueue",
|
|
2412
2463
|
value: function(task) {
|
|
2413
|
-
var
|
|
2464
|
+
var minLoad = 1 / 0;
|
|
2465
|
+
var candidates = [];
|
|
2466
|
+
for(var i = 0; i < readerPool_class_private_field_get(this, _workers).length; i++){
|
|
2467
|
+
var load = readerPool_class_private_field_get(this, _workers)[i].pendingStatements;
|
|
2468
|
+
if (load < minLoad) {
|
|
2469
|
+
minLoad = load;
|
|
2470
|
+
candidates.length = 0;
|
|
2471
|
+
candidates.push(i);
|
|
2472
|
+
} else if (load === minLoad) candidates.push(i);
|
|
2473
|
+
}
|
|
2474
|
+
var idx = candidates[readerPool_class_private_field_get(this, _rrIndex) % candidates.length];
|
|
2414
2475
|
readerPool_class_private_field_set(this, _rrIndex, readerPool_class_private_field_get(this, _rrIndex) + 1 >>> 0);
|
|
2415
|
-
|
|
2476
|
+
readerPool_class_private_field_get(this, _workers)[idx].enqueue(task);
|
|
2416
2477
|
}
|
|
2417
2478
|
},
|
|
2418
2479
|
{
|
|
@@ -2905,9 +2966,7 @@ var transactionScope_TransactionScope = /*#__PURE__*/ function() {
|
|
|
2905
2966
|
release = resolve;
|
|
2906
2967
|
});
|
|
2907
2968
|
previous = transactionScope_class_private_field_get(_this, _scopeChain);
|
|
2908
|
-
transactionScope_class_private_field_set(_this, _scopeChain,
|
|
2909
|
-
return gate;
|
|
2910
|
-
}));
|
|
2969
|
+
transactionScope_class_private_field_set(_this, _scopeChain, gate);
|
|
2911
2970
|
return [
|
|
2912
2971
|
4,
|
|
2913
2972
|
previous["catch"](function() {})
|
|
@@ -2974,6 +3033,22 @@ function pipelineEngine_class_apply_descriptor_set(receiver, descriptor, value)
|
|
|
2974
3033
|
descriptor.value = value;
|
|
2975
3034
|
}
|
|
2976
3035
|
}
|
|
3036
|
+
function pipelineEngine_class_apply_descriptor_update(receiver, descriptor) {
|
|
3037
|
+
if (descriptor.set) {
|
|
3038
|
+
if (!descriptor.get) throw new TypeError("attempted to read set only private field");
|
|
3039
|
+
if (!("__destrWrapper" in descriptor)) descriptor.__destrWrapper = {
|
|
3040
|
+
set value (v){
|
|
3041
|
+
descriptor.set.call(receiver, v);
|
|
3042
|
+
},
|
|
3043
|
+
get value () {
|
|
3044
|
+
return descriptor.get.call(receiver);
|
|
3045
|
+
}
|
|
3046
|
+
};
|
|
3047
|
+
return descriptor.__destrWrapper;
|
|
3048
|
+
}
|
|
3049
|
+
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
3050
|
+
return descriptor;
|
|
3051
|
+
}
|
|
2977
3052
|
function pipelineEngine_class_call_check(instance, Constructor) {
|
|
2978
3053
|
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
2979
3054
|
}
|
|
@@ -2994,6 +3069,10 @@ function pipelineEngine_class_private_field_set(receiver, privateMap, value) {
|
|
|
2994
3069
|
pipelineEngine_class_apply_descriptor_set(receiver, descriptor, value);
|
|
2995
3070
|
return value;
|
|
2996
3071
|
}
|
|
3072
|
+
function pipelineEngine_class_private_field_update(receiver, privateMap) {
|
|
3073
|
+
var descriptor = pipelineEngine_class_extract_field_descriptor(receiver, privateMap, "update");
|
|
3074
|
+
return pipelineEngine_class_apply_descriptor_update(receiver, descriptor);
|
|
3075
|
+
}
|
|
2997
3076
|
function pipelineEngine_class_private_method_get(receiver, privateSet, fn) {
|
|
2998
3077
|
if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
|
|
2999
3078
|
return fn;
|
|
@@ -3033,16 +3112,20 @@ function pipelineEngine_unsupported_iterable_to_array(o, minLen) {
|
|
|
3033
3112
|
if ("Map" === n || "Set" === n) return Array.from(n);
|
|
3034
3113
|
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return pipelineEngine_array_like_to_array(o, minLen);
|
|
3035
3114
|
}
|
|
3036
|
-
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();
|
|
3115
|
+
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();
|
|
3037
3116
|
var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
3038
3117
|
"use strict";
|
|
3039
3118
|
function PipelineEngine(processManager, param) {
|
|
3040
3119
|
var _this = this;
|
|
3041
|
-
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;
|
|
3120
|
+
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;
|
|
3042
3121
|
pipelineEngine_class_call_check(this, PipelineEngine);
|
|
3122
|
+
pipelineEngine_class_private_method_init(this, pipelineEngine_inflightCount);
|
|
3123
|
+
pipelineEngine_class_private_method_init(this, core_pipelineEngine_firstInflight);
|
|
3124
|
+
pipelineEngine_class_private_method_init(this, core_pipelineEngine_shiftInflight);
|
|
3043
3125
|
pipelineEngine_class_private_method_init(this, core_pipelineEngine_pumpQueue);
|
|
3044
3126
|
pipelineEngine_class_private_method_init(this, pipelineEngine_handleParsedValue);
|
|
3045
3127
|
pipelineEngine_class_private_method_init(this, core_pipelineEngine_scheduleFinalizeCheck);
|
|
3128
|
+
pipelineEngine_class_private_method_init(this, pipelineEngine_scheduleSweep);
|
|
3046
3129
|
pipelineEngine_class_private_method_init(this, core_pipelineEngine_handleTaskTimeout);
|
|
3047
3130
|
pipelineEngine_class_private_method_init(this, pipelineEngine_settleTask);
|
|
3048
3131
|
pipelineEngine_class_private_field_init(this, _queue, {
|
|
@@ -3053,6 +3136,10 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3053
3136
|
writable: true,
|
|
3054
3137
|
value: []
|
|
3055
3138
|
});
|
|
3139
|
+
pipelineEngine_class_private_field_init(this, pipelineEngine_inflightHead, {
|
|
3140
|
+
writable: true,
|
|
3141
|
+
value: 0
|
|
3142
|
+
});
|
|
3056
3143
|
pipelineEngine_class_private_field_init(this, pipelineEngine_pendingFinalizeTasks, {
|
|
3057
3144
|
writable: true,
|
|
3058
3145
|
value: new Set()
|
|
@@ -3097,6 +3184,14 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3097
3184
|
writable: true,
|
|
3098
3185
|
value: false
|
|
3099
3186
|
});
|
|
3187
|
+
pipelineEngine_class_private_field_init(this, pipelineEngine_sweepTimer, {
|
|
3188
|
+
writable: true,
|
|
3189
|
+
value: null
|
|
3190
|
+
});
|
|
3191
|
+
pipelineEngine_class_private_field_init(this, pipelineEngine_sweepIntervalMs, {
|
|
3192
|
+
writable: true,
|
|
3193
|
+
value: void 0
|
|
3194
|
+
});
|
|
3100
3195
|
pipelineEngine_class_private_field_set(this, pipelineEngine_processManager, processManager);
|
|
3101
3196
|
pipelineEngine_class_private_field_set(this, pipelineEngine_metrics, metrics);
|
|
3102
3197
|
pipelineEngine_class_private_field_set(this, pipelineEngine_statementTimeout, statementTimeout);
|
|
@@ -3110,8 +3205,15 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3110
3205
|
pipelineEngine_class_private_field_get(this, pipelineEngine_processManager).setOnDrainCallback(function() {
|
|
3111
3206
|
return pipelineEngine_class_private_method_get(_this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(_this);
|
|
3112
3207
|
});
|
|
3208
|
+
pipelineEngine_class_private_field_set(this, pipelineEngine_sweepIntervalMs, sweepInterval);
|
|
3113
3209
|
}
|
|
3114
3210
|
pipelineEngine_create_class(PipelineEngine, [
|
|
3211
|
+
{
|
|
3212
|
+
key: "_sweepTimer",
|
|
3213
|
+
get: function() {
|
|
3214
|
+
return pipelineEngine_class_private_field_get(this, pipelineEngine_sweepTimer);
|
|
3215
|
+
}
|
|
3216
|
+
},
|
|
3115
3217
|
{
|
|
3116
3218
|
key: "mainQueue",
|
|
3117
3219
|
get: function() {
|
|
@@ -3127,7 +3229,7 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3127
3229
|
{
|
|
3128
3230
|
key: "pendingStatements",
|
|
3129
3231
|
get: function() {
|
|
3130
|
-
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;
|
|
3232
|
+
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;
|
|
3131
3233
|
}
|
|
3132
3234
|
},
|
|
3133
3235
|
{
|
|
@@ -3160,9 +3262,9 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3160
3262
|
{
|
|
3161
3263
|
key: "handleStdoutChunk",
|
|
3162
3264
|
value: function(chunk) {
|
|
3163
|
-
var task =
|
|
3265
|
+
var task = pipelineEngine_class_private_method_get(this, core_pipelineEngine_firstInflight, pipelineEngine_firstInflight).call(this);
|
|
3164
3266
|
if (!task) return;
|
|
3165
|
-
if ("stream" === task.kind && task.rowParser && !task.rowParser.finished) {
|
|
3267
|
+
if ("stream" === task.kind && task.rowParser && !task.rowParser.finished && !task.timedout) {
|
|
3166
3268
|
var leftover = task.rowParser.feed(chunk);
|
|
3167
3269
|
if (leftover) pipelineEngine_class_private_field_get(this, _sharedValueParser).feed(leftover);
|
|
3168
3270
|
return;
|
|
@@ -3174,20 +3276,23 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3174
3276
|
key: "handleStderrChunk",
|
|
3175
3277
|
value: function(chunk) {
|
|
3176
3278
|
var _class_private_field_get_values_next_value;
|
|
3177
|
-
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 :
|
|
3279
|
+
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);
|
|
3178
3280
|
if (!task) {
|
|
3179
3281
|
var _class_private_field_get_error, _$_class_private_field_get;
|
|
3180
|
-
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,
|
|
3282
|
+
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());
|
|
3181
3283
|
return;
|
|
3182
3284
|
}
|
|
3183
|
-
task.stderrText +=
|
|
3285
|
+
task.stderrText += chunk;
|
|
3184
3286
|
}
|
|
3185
3287
|
},
|
|
3186
3288
|
{
|
|
3187
3289
|
key: "rejectAll",
|
|
3188
3290
|
value: function(error) {
|
|
3189
|
-
|
|
3291
|
+
pipelineEngine_class_private_field_get(this, _sharedValueParser).reset();
|
|
3292
|
+
var activeCount = pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).length - pipelineEngine_class_private_field_get(this, pipelineEngine_inflightHead);
|
|
3293
|
+
var all = activeCount > 0 ? pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).slice(pipelineEngine_class_private_field_get(this, pipelineEngine_inflightHead)) : [];
|
|
3190
3294
|
pipelineEngine_class_private_field_set(this, pipelineEngine_inflightTasks, []);
|
|
3295
|
+
pipelineEngine_class_private_field_set(this, pipelineEngine_inflightHead, 0);
|
|
3191
3296
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
3192
3297
|
try {
|
|
3193
3298
|
for(var _iterator = all[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
@@ -3232,22 +3337,42 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3232
3337
|
key: "kill",
|
|
3233
3338
|
value: function() {
|
|
3234
3339
|
pipelineEngine_class_private_field_set(this, _active, false);
|
|
3340
|
+
clearTimeout(pipelineEngine_class_private_field_get(this, pipelineEngine_sweepTimer));
|
|
3341
|
+
pipelineEngine_class_private_field_set(this, pipelineEngine_sweepTimer, null);
|
|
3235
3342
|
this.rejectAll(new Error("PipelineEngine is killed"));
|
|
3236
3343
|
}
|
|
3237
3344
|
}
|
|
3238
3345
|
]);
|
|
3239
3346
|
return PipelineEngine;
|
|
3240
3347
|
}();
|
|
3348
|
+
function core_pipelineEngine_inflightCount() {
|
|
3349
|
+
return pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).length - pipelineEngine_class_private_field_get(this, pipelineEngine_inflightHead);
|
|
3350
|
+
}
|
|
3351
|
+
function pipelineEngine_firstInflight() {
|
|
3352
|
+
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;
|
|
3353
|
+
}
|
|
3354
|
+
function pipelineEngine_shiftInflight() {
|
|
3355
|
+
var task = pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks)[pipelineEngine_class_private_field_get(this, pipelineEngine_inflightHead)];
|
|
3356
|
+
pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks)[pipelineEngine_class_private_field_get(this, pipelineEngine_inflightHead)] = null;
|
|
3357
|
+
pipelineEngine_class_private_field_update(this, pipelineEngine_inflightHead).value++;
|
|
3358
|
+
if (pipelineEngine_class_private_field_get(this, pipelineEngine_inflightHead) >= pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).length) {
|
|
3359
|
+
pipelineEngine_class_private_field_set(this, pipelineEngine_inflightTasks, []);
|
|
3360
|
+
pipelineEngine_class_private_field_set(this, pipelineEngine_inflightHead, 0);
|
|
3361
|
+
} else if (pipelineEngine_class_private_field_get(this, pipelineEngine_inflightHead) > 128) {
|
|
3362
|
+
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)));
|
|
3363
|
+
pipelineEngine_class_private_field_set(this, pipelineEngine_inflightHead, 0);
|
|
3364
|
+
}
|
|
3365
|
+
return task;
|
|
3366
|
+
}
|
|
3241
3367
|
function pipelineEngine_pumpQueue() {
|
|
3242
|
-
var _this = this;
|
|
3243
3368
|
var _$_class_private_field_get;
|
|
3244
3369
|
if (!pipelineEngine_class_private_field_get(this, _active)) return;
|
|
3245
3370
|
if (pipelineEngine_class_private_field_get(this, pipelineEngine_processManager).draining) return;
|
|
3246
|
-
if (
|
|
3371
|
+
if (pipelineEngine_class_private_method_get(this, pipelineEngine_inflightCount, core_pipelineEngine_inflightCount).call(this) >= pipelineEngine_class_private_field_get(this, pipelineEngine_maxInflight)) return;
|
|
3247
3372
|
var batch = [];
|
|
3248
|
-
while(batch.length < pipelineEngine_class_private_field_get(this, pipelineEngine_batchSize) && !pipelineEngine_class_private_field_get(this, _queue).isEmpty() &&
|
|
3373
|
+
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)){
|
|
3249
3374
|
var task = pipelineEngine_class_private_field_get(this, _queue).peek();
|
|
3250
|
-
if ("stream" === task.kind && (batch.length > 0 ||
|
|
3375
|
+
if ("stream" === task.kind && (batch.length > 0 || pipelineEngine_class_private_method_get(this, pipelineEngine_inflightCount, core_pipelineEngine_inflightCount).call(this) > 0)) break;
|
|
3251
3376
|
pipelineEngine_class_private_field_get(this, _queue).dequeue();
|
|
3252
3377
|
batch.push(task);
|
|
3253
3378
|
}
|
|
@@ -3256,14 +3381,10 @@ function pipelineEngine_pumpQueue() {
|
|
|
3256
3381
|
var payload = buildBatchPayload(batch);
|
|
3257
3382
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
3258
3383
|
try {
|
|
3259
|
-
var
|
|
3260
|
-
var
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
return pipelineEngine_class_private_method_get(_this, core_pipelineEngine_handleTaskTimeout, pipelineEngine_handleTaskTimeout).call(_this, task);
|
|
3264
|
-
}, task.timeout);
|
|
3265
|
-
};
|
|
3266
|
-
for(var _iterator = batch[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
3384
|
+
for(var _iterator = batch[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3385
|
+
var task1 = _step.value;
|
|
3386
|
+
task1.startTime = now;
|
|
3387
|
+
}
|
|
3267
3388
|
} catch (err) {
|
|
3268
3389
|
_didIteratorError = true;
|
|
3269
3390
|
_iteratorError = err;
|
|
@@ -3275,14 +3396,14 @@ function pipelineEngine_pumpQueue() {
|
|
|
3275
3396
|
}
|
|
3276
3397
|
}
|
|
3277
3398
|
(_$_class_private_field_get = pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks)).push.apply(_$_class_private_field_get, pipelineEngine_to_consumable_array(batch));
|
|
3399
|
+
pipelineEngine_class_private_method_get(this, pipelineEngine_scheduleSweep, core_pipelineEngine_scheduleSweep).call(this);
|
|
3278
3400
|
pipelineEngine_class_private_field_get(this, pipelineEngine_processManager).write(payload);
|
|
3279
3401
|
}
|
|
3280
3402
|
function core_pipelineEngine_handleParsedValue(raw) {
|
|
3281
|
-
var task =
|
|
3403
|
+
var task = pipelineEngine_class_private_method_get(this, core_pipelineEngine_firstInflight, pipelineEngine_firstInflight).call(this);
|
|
3282
3404
|
if (!task) return;
|
|
3283
3405
|
if (isSentinelRaw(raw, task.token)) {
|
|
3284
|
-
|
|
3285
|
-
pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).shift();
|
|
3406
|
+
pipelineEngine_class_private_method_get(this, core_pipelineEngine_shiftInflight, pipelineEngine_shiftInflight).call(this);
|
|
3286
3407
|
if (task.timedout) return void pipelineEngine_class_private_method_get(this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(this);
|
|
3287
3408
|
if (task.consumerError) {
|
|
3288
3409
|
pipelineEngine_class_private_method_get(this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(this, task, task.consumerError, void 0);
|
|
@@ -3303,8 +3424,7 @@ function core_pipelineEngine_handleParsedValue(raw) {
|
|
|
3303
3424
|
return;
|
|
3304
3425
|
}
|
|
3305
3426
|
if (isSentinelRow(parsed, task.token)) {
|
|
3306
|
-
|
|
3307
|
-
pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).shift();
|
|
3427
|
+
pipelineEngine_class_private_method_get(this, core_pipelineEngine_shiftInflight, pipelineEngine_shiftInflight).call(this);
|
|
3308
3428
|
if (task.timedout) return void pipelineEngine_class_private_method_get(this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(this);
|
|
3309
3429
|
if (task.consumerError) {
|
|
3310
3430
|
pipelineEngine_class_private_method_get(this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(this, task, task.consumerError, void 0);
|
|
@@ -3333,6 +3453,21 @@ function pipelineEngine_scheduleFinalizeCheck() {
|
|
|
3333
3453
|
});
|
|
3334
3454
|
});
|
|
3335
3455
|
}
|
|
3456
|
+
function core_pipelineEngine_scheduleSweep() {
|
|
3457
|
+
var _this = this;
|
|
3458
|
+
if (pipelineEngine_class_private_field_get(this, pipelineEngine_sweepTimer)) return;
|
|
3459
|
+
pipelineEngine_class_private_field_set(this, pipelineEngine_sweepTimer, setTimeout(function() {
|
|
3460
|
+
pipelineEngine_class_private_field_set(_this, pipelineEngine_sweepTimer, null);
|
|
3461
|
+
var tasks = pipelineEngine_class_private_field_get(_this, pipelineEngine_inflightTasks);
|
|
3462
|
+
var head = pipelineEngine_class_private_field_get(_this, pipelineEngine_inflightHead);
|
|
3463
|
+
var now = performance.now();
|
|
3464
|
+
for(var i = head; i < tasks.length; i++){
|
|
3465
|
+
var task = tasks[i];
|
|
3466
|
+
if (now - task.startTime > task.timeout) pipelineEngine_class_private_method_get(_this, core_pipelineEngine_handleTaskTimeout, pipelineEngine_handleTaskTimeout).call(_this, task);
|
|
3467
|
+
}
|
|
3468
|
+
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);
|
|
3469
|
+
}, pipelineEngine_class_private_field_get(this, pipelineEngine_sweepIntervalMs)).unref());
|
|
3470
|
+
}
|
|
3336
3471
|
function pipelineEngine_handleTaskTimeout(task) {
|
|
3337
3472
|
var _this, _this1;
|
|
3338
3473
|
var error = prepareTaskTimeout(task, pipelineEngine_class_private_field_get(this, pipelineEngine_metrics));
|
|
@@ -3941,20 +4076,18 @@ function executor_enqueue(kind, sql, params, options, scopeId) {
|
|
|
3941
4076
|
var token = generateToken();
|
|
3942
4077
|
var _options_onRow;
|
|
3943
4078
|
var onRow = null != (_options_onRow = null == options ? void 0 : options.onRow) ? _options_onRow : null;
|
|
3944
|
-
var
|
|
4079
|
+
var template = normalizeSQLTemplate(sql);
|
|
3945
4080
|
var formatted;
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
if (scopeId) return executor_class_private_method_get(this, _enqueueWriter, enqueueWriter).call(this, kind, formatted, timeout, token, onRow, scopeId, sqlNormalized);
|
|
4081
|
+
formatted = 0 === params.length && 0 === template.paramCount ? template.normalized : interpolateFromTemplate(template, params);
|
|
4082
|
+
if (scopeId) return executor_class_private_method_get(this, _enqueueWriter, enqueueWriter).call(this, kind, formatted, timeout, token, onRow, scopeId);
|
|
3949
4083
|
if (executor_class_private_field_get(this, _readerPool)) {
|
|
3950
4084
|
if ("stream" === kind || "query" === kind) return executor_class_private_method_get(this, _enqueueReader, enqueueReader).call(this, kind, formatted, timeout, token, onRow);
|
|
3951
|
-
if ("execute" === kind && "read" === classifySQL(normalized)) return executor_class_private_method_get(this, _enqueueReader, enqueueReader).call(this, kind, formatted, timeout, token, onRow);
|
|
4085
|
+
if ("execute" === kind && "read" === classifySQL(template.normalized)) return executor_class_private_method_get(this, _enqueueReader, enqueueReader).call(this, kind, formatted, timeout, token, onRow);
|
|
3952
4086
|
}
|
|
3953
|
-
return executor_class_private_method_get(this, _enqueueWriter, enqueueWriter).call(this, kind, formatted, timeout, token, onRow, null
|
|
4087
|
+
return executor_class_private_method_get(this, _enqueueWriter, enqueueWriter).call(this, kind, formatted, timeout, token, onRow, null);
|
|
3954
4088
|
}
|
|
3955
4089
|
function enqueueWriter(kind, sql, timeout, token, onRow, scopeId) {
|
|
3956
4090
|
var _this = this;
|
|
3957
|
-
var sqlNormalized = arguments.length > 6 && void 0 !== arguments[6] ? arguments[6] : false;
|
|
3958
4091
|
executor_class_private_field_get(this, executor_metrics).incrementTasksTotal(kind);
|
|
3959
4092
|
return new Promise(function(resolve, reject) {
|
|
3960
4093
|
var task = {
|
|
@@ -3964,17 +4097,15 @@ function enqueueWriter(kind, sql, timeout, token, onRow, scopeId) {
|
|
|
3964
4097
|
token: token,
|
|
3965
4098
|
onRow: onRow,
|
|
3966
4099
|
scopeId: scopeId,
|
|
3967
|
-
sqlNormalized: sqlNormalized,
|
|
3968
4100
|
resolve: resolve,
|
|
3969
4101
|
reject: reject,
|
|
3970
4102
|
consumerError: null,
|
|
3971
4103
|
stderrText: "",
|
|
3972
4104
|
settled: false,
|
|
3973
|
-
timer: null,
|
|
3974
4105
|
startTime: 0,
|
|
3975
|
-
rowParser: null
|
|
4106
|
+
rowParser: null,
|
|
4107
|
+
rows: "query" === kind ? [] : null
|
|
3976
4108
|
};
|
|
3977
|
-
if ("query" === kind) task.rows = [];
|
|
3978
4109
|
if ("stream" === kind) task.rowParser = setupStreamParser(task, executor_class_private_field_get(_this, _pipeline));
|
|
3979
4110
|
if (executor_class_private_field_get(_this, _txScope).isDeferred(scopeId)) executor_class_private_field_get(_this, _txScope).defer(task);
|
|
3980
4111
|
else executor_class_private_field_get(_this, _pipeline).enqueue(task);
|