@voltro/sql-mysql 0.33.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1968 -0
- package/dist/index.d.ts +74 -0
- package/dist/index.js +305 -239
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,27 +1,60 @@
|
|
|
1
1
|
import { MysqlClient as e } from "@effect/sql-mysql2";
|
|
2
2
|
import { Config as t, Effect as n, Layer as r, ManagedRuntime as i, Option as a, Redacted as o, Schedule as s } from "effect";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { CDC_OFFSETS_TABLE as c, DEFAULT_ACQUIRE_TIMEOUT_MS as l, EagerCardinalityError as u, _voltroCdcOffsetsTable as d, attachEagerLoads as f, attributionFields as p, attributionKey as m, beginLocalWrite as h, bulkInsertLimitsFor as g, chunkRowsForInsert as _, compileEagerJson as v, compilePredicate as y, compileRawFragment as b, compileSelect as x, decodeRowsFromSchema as S, encodeRowForSchema as C, endLocalWrite as w, externalChangeEvent as T, hasEagerLoads as E, isTableReactive as D, makeEagerFallbackReporter as ee, observeDbOp as O, qualifyTable as te, raiseChangeListenerCeiling as ne, recordsTable as re, registerPendingAttribution as ie, requireTable as k, resolveEchoAttribution as A, runStoreTransaction as j, runWriteRecorders as ae, stampGeneratedId as M, stampGeneratedIds as oe, withCapturedAttribution as N } from "@voltro/database";
|
|
4
|
+
import { EventEmitter as se } from "node:events";
|
|
5
|
+
import { createLogger as P } from "@voltro/logger";
|
|
6
|
+
import { SqlClient as F, TransactionConnection as I } from "@effect/sql/SqlClient";
|
|
7
7
|
//#region src/sqlLayer.ts
|
|
8
|
-
var
|
|
8
|
+
var ce = (e) => e ? { rejectUnauthorized: !1 } : void 0, le = (e) => {
|
|
9
|
+
let t = e.acquireTimeoutMs ?? l;
|
|
10
|
+
return t > 0 ? t : void 0;
|
|
11
|
+
}, L = (e) => {
|
|
12
|
+
let t = e.acquireQueueLimit;
|
|
13
|
+
return t !== void 0 && t > 0 ? t : void 0;
|
|
14
|
+
}, R = (e) => {
|
|
15
|
+
let t = e.ssl === void 0 ? void 0 : ce(e.ssl), n = le(e), r = L(e);
|
|
16
|
+
return {
|
|
17
|
+
...t === void 0 ? {} : { ssl: t },
|
|
18
|
+
...n === void 0 ? {} : { connectTimeout: n },
|
|
19
|
+
...r === void 0 ? {} : { queueLimit: r }
|
|
20
|
+
};
|
|
21
|
+
}, z = (n) => e.layerConfig({
|
|
9
22
|
host: t.succeed(n.host),
|
|
10
23
|
port: t.succeed(n.port),
|
|
11
24
|
username: t.succeed(n.username),
|
|
12
25
|
password: t.succeed(o.make(n.password)),
|
|
13
26
|
database: t.succeed(n.database),
|
|
27
|
+
poolConfig: t.succeed(R(n)),
|
|
14
28
|
...n.maxConnections === void 0 ? {} : { maxConnections: t.succeed(n.maxConnections) }
|
|
15
|
-
}),
|
|
29
|
+
}), B = (e) => {
|
|
30
|
+
let t = e.get("sslmode");
|
|
31
|
+
if (t !== null) {
|
|
32
|
+
if (t === "require") return !0;
|
|
33
|
+
if (t === "disable") return !1;
|
|
34
|
+
throw Error(`DB_URL '?sslmode=${t}' is not supported by the mysql/mariadb dialect — use 'require' (TLS without certificate verification) or 'disable' (plaintext).`);
|
|
35
|
+
}
|
|
36
|
+
let n = e.get("ssl");
|
|
37
|
+
if (n !== null) {
|
|
38
|
+
if (n === "true" || n === "1") return !0;
|
|
39
|
+
if (n === "false" || n === "0") return !1;
|
|
40
|
+
throw Error(`DB_URL '?ssl=${n}' is not supported by the mysql/mariadb dialect — use 'true'/'1' or 'false'/'0'.`);
|
|
41
|
+
}
|
|
42
|
+
}, V = (e) => {
|
|
43
|
+
let t = {
|
|
44
|
+
...e.acquireTimeoutMs === void 0 ? {} : { acquireTimeoutMs: e.acquireTimeoutMs },
|
|
45
|
+
...e.acquireQueueLimit === void 0 ? {} : { acquireQueueLimit: e.acquireQueueLimit }
|
|
46
|
+
};
|
|
16
47
|
if (e.url) {
|
|
17
|
-
let
|
|
48
|
+
let n = new URL(e.url), r = e.ssl ?? B(n.searchParams);
|
|
18
49
|
return {
|
|
19
|
-
host:
|
|
20
|
-
port:
|
|
21
|
-
username: decodeURIComponent(
|
|
22
|
-
password: decodeURIComponent(
|
|
23
|
-
database:
|
|
24
|
-
...e.maxConnections === void 0 ? {} : { maxConnections: e.maxConnections }
|
|
50
|
+
host: n.hostname || "localhost",
|
|
51
|
+
port: n.port ? Number(n.port) : 3306,
|
|
52
|
+
username: decodeURIComponent(n.username || "app"),
|
|
53
|
+
password: decodeURIComponent(n.password || "app"),
|
|
54
|
+
database: n.pathname.replace(/^\//, "") || "app",
|
|
55
|
+
...e.maxConnections === void 0 ? {} : { maxConnections: e.maxConnections },
|
|
56
|
+
...r === void 0 ? {} : { ssl: r },
|
|
57
|
+
...t
|
|
25
58
|
};
|
|
26
59
|
}
|
|
27
60
|
return {
|
|
@@ -30,48 +63,50 @@ var N = (n) => e.layerConfig({
|
|
|
30
63
|
username: e.username ?? "app",
|
|
31
64
|
password: e.password ?? "app",
|
|
32
65
|
database: e.database ?? "app",
|
|
33
|
-
...e.maxConnections === void 0 ? {} : { maxConnections: e.maxConnections }
|
|
66
|
+
...e.maxConnections === void 0 ? {} : { maxConnections: e.maxConnections },
|
|
67
|
+
...e.ssl === void 0 ? {} : { ssl: e.ssl },
|
|
68
|
+
...t
|
|
34
69
|
};
|
|
35
|
-
},
|
|
70
|
+
}, H = (e) => z(V(e)), U = (e, t) => e === null ? !1 : t === null ? !0 : e.filename === t.filename ? e.position > t.position : e.filename > t.filename, W = (e) => e.msSinceProgress < e.stallThresholdMs ? "healthy" : e.primary !== null && !U(e.primary, e.reader) ? "idle-caught-up" : "reconnect", ue = (e) => (e instanceof Error ? e.message : String(e ?? "")).includes("schema changed between binlog event and metadata fetch"), de = (e) => {
|
|
36
71
|
let t = e instanceof Error ? e.message : String(e ?? "");
|
|
37
72
|
return /Table\s+[^\s.]+\.(\S+)\s+schema changed between binlog event and metadata fetch/.exec(t)?.[1] ?? null;
|
|
38
|
-
},
|
|
39
|
-
let n = [...e.filter((e) => t - e <
|
|
73
|
+
}, fe = "\n SELECT DISTINCT s.TABLE_NAME AS tableName\n FROM information_schema.STATISTICS s\n JOIN information_schema.COLUMNS c\n ON c.TABLE_SCHEMA = s.TABLE_SCHEMA\n AND c.TABLE_NAME = s.TABLE_NAME\n AND c.COLUMN_NAME = s.COLUMN_NAME\n WHERE s.TABLE_SCHEMA = DATABASE()\n AND s.NON_UNIQUE = 0\n AND s.SUB_PART IS NULL\n AND c.DATA_TYPE IN ('text','tinytext','mediumtext','longtext','blob','tinyblob','mediumblob','longblob')\n", G = (e) => `cdc: table '${e}' is EXCLUDED from binlog capture — its row image carries a hidden column the reader cannot account for. Cause: a UNIQUE constraint on an UNBOUNDED text column, which MariaDB backs with a HASH long-unique index; that index adds a hidden DB_ROW_HASH_n column to the row, present in the binlog and absent from information_schema.COLUMNS. Remedy: bound the column — text().maxLength(n) — so the constraint becomes an ordinary B-tree index with no hidden column. ALTER TABLE FORCE does NOT help: the rebuild recreates the index and the hidden column. Until then, cross-instance change events for this table are lost; own-node reactivity is unaffected (writes still emit inline).`, pe = 5 * 6e4, me = 3, he = (e, t) => {
|
|
74
|
+
let n = [...e.filter((e) => t - e < pe), t];
|
|
40
75
|
return {
|
|
41
|
-
verdict: n.length >=
|
|
76
|
+
verdict: n.length >= me ? "persistent" : "backlog",
|
|
42
77
|
hits: n
|
|
43
78
|
};
|
|
44
|
-
},
|
|
79
|
+
}, ge = /* @__PURE__ */ new Set([
|
|
45
80
|
"writerows",
|
|
46
81
|
"updaterows",
|
|
47
82
|
"deleterows"
|
|
48
|
-
]),
|
|
49
|
-
let t =
|
|
83
|
+
]), _e = /\b(alter|rename|drop|create)\s+(table|column)?/i, K = (e) => new Promise((t) => setTimeout(t, e)), q = async (e) => {
|
|
84
|
+
let t = P({ scope: `voltro:${e.variant}:cdc` }), n;
|
|
50
85
|
try {
|
|
51
86
|
n = (await import("@vlasky/zongji")).default;
|
|
52
87
|
} catch (t) {
|
|
53
88
|
throw Error(`changeStrategy='cdc' on ${e.variant} requires the '@vlasky/zongji' optional dependency. Install it (it ships as an optionalDependency of @voltro/sql-mysql) to enable binlog CDC.`, { cause: t });
|
|
54
89
|
}
|
|
55
|
-
let r = new Set(e.undecodableTables ?? []), i = e.includeTables ? new Set(e.includeTables.filter((e) => !r.has(e))) : null, a = e.connection.database, o = e.startPosition?.filename ?? null, s = e.startPosition ?? null, c = (t, n) =>
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
|
|
90
|
+
let r = new Set(e.undecodableTables ?? []), i = e.includeTables ? new Set(e.includeTables.filter((e) => !r.has(e))) : null, a = e.connection.database, o = e.startPosition?.filename ?? null, s = e.startPosition ?? null, c = (t, n) => S([n], t, e.variant)[0], l = null, u = !1, d = 0, f = Date.now(), p = !1, m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Set(), g = null, _ = e.stallThresholdMs ?? 25e3, v = e.watchdogIntervalMs ?? 15e3, y = () => {
|
|
91
|
+
f = Date.now();
|
|
92
|
+
}, b = (n) => {
|
|
93
|
+
y();
|
|
59
94
|
let r = n.getEventName();
|
|
60
95
|
if (r === "rotate" && n.binlogName) {
|
|
61
96
|
o = n.binlogName;
|
|
62
97
|
return;
|
|
63
98
|
}
|
|
64
|
-
if (r === "query" && n.query &&
|
|
65
|
-
|
|
99
|
+
if (r === "query" && n.query && _e.test(n.query)) {
|
|
100
|
+
l && (l.tableMap = {});
|
|
66
101
|
return;
|
|
67
102
|
}
|
|
68
103
|
if (n.nextPosition && o && (s = {
|
|
69
104
|
filename: o,
|
|
70
105
|
position: n.nextPosition
|
|
71
|
-
}, e.onPosition?.(s)), !
|
|
72
|
-
let
|
|
73
|
-
if (!
|
|
74
|
-
let d =
|
|
106
|
+
}, e.onPosition?.(s)), !ge.has(r)) return;
|
|
107
|
+
let u = n.tableMap[n.tableId];
|
|
108
|
+
if (!u || u.parentSchema !== a) return;
|
|
109
|
+
let d = u.tableName;
|
|
75
110
|
if (!d.startsWith("_voltro_") && !(i && !i.has(d))) try {
|
|
76
111
|
if (r === "writerows") for (let t of n.rows) e.onChange({
|
|
77
112
|
table: d,
|
|
@@ -97,7 +132,7 @@ var N = (n) => e.layerConfig({
|
|
|
97
132
|
name: r
|
|
98
133
|
}, n), e.onError?.(n);
|
|
99
134
|
}
|
|
100
|
-
},
|
|
135
|
+
}, x = (t) => {
|
|
101
136
|
let n = {
|
|
102
137
|
serverId: e.serverId,
|
|
103
138
|
includeEvents: [
|
|
@@ -114,7 +149,7 @@ var N = (n) => e.layerConfig({
|
|
|
114
149
|
}, C = (e) => {
|
|
115
150
|
let t = e;
|
|
116
151
|
return t?.errno === 1236 || String(t?.code ?? "").includes("ER_MASTER_FATAL_ERROR_READING_BINLOG");
|
|
117
|
-
},
|
|
152
|
+
}, w = (r) => new Promise((i, a) => {
|
|
118
153
|
let o = new n({
|
|
119
154
|
host: e.connection.host,
|
|
120
155
|
port: e.connection.port,
|
|
@@ -123,10 +158,10 @@ var N = (n) => e.layerConfig({
|
|
|
123
158
|
enableKeepAlive: !0,
|
|
124
159
|
keepAliveInitialDelay: e.keepAliveInitialDelayMs ?? 1e4
|
|
125
160
|
});
|
|
126
|
-
|
|
161
|
+
l = o;
|
|
127
162
|
let s = !1;
|
|
128
|
-
o.on("binlog",
|
|
129
|
-
|
|
163
|
+
o.on("binlog", b), o.on("ready", () => {
|
|
164
|
+
y(), !s && (s = !0, d = 0, t.info("cdc: binlog reader attached", {
|
|
130
165
|
serverId: e.serverId,
|
|
131
166
|
from: r ?? "current-end"
|
|
132
167
|
}), i());
|
|
@@ -135,82 +170,82 @@ var N = (n) => e.layerConfig({
|
|
|
135
170
|
s = !0, a(e instanceof Error ? e : Error(String(e)));
|
|
136
171
|
return;
|
|
137
172
|
}
|
|
138
|
-
|
|
139
|
-
}), o.start(
|
|
140
|
-
}),
|
|
141
|
-
if (!(
|
|
142
|
-
|
|
173
|
+
T("binlog reader error", e);
|
|
174
|
+
}), o.start(x(r));
|
|
175
|
+
}), T = async (n, i) => {
|
|
176
|
+
if (!(u || p)) {
|
|
177
|
+
p = !0, t.warn(`cdc: reconnecting — ${n}`, {}, i instanceof Error ? i : void 0), e.onError?.(i);
|
|
143
178
|
try {
|
|
144
179
|
let n = i;
|
|
145
|
-
for (; !
|
|
180
|
+
for (; !u;) {
|
|
146
181
|
try {
|
|
147
|
-
|
|
182
|
+
l?.stop();
|
|
148
183
|
} catch {}
|
|
149
|
-
if (
|
|
150
|
-
let i = s, a = C(n), c = !a &&
|
|
184
|
+
if (d++, await K(Math.min(3e4, 500 * 2 ** Math.min(d, 6))), u) return;
|
|
185
|
+
let i = s, a = C(n), c = !a && ue(n), f = !1;
|
|
151
186
|
if (c) {
|
|
152
|
-
let e =
|
|
153
|
-
|
|
187
|
+
let e = de(n), i = e ?? "<unknown>", { verdict: a, hits: o } = he(m.get(i) ?? [], Date.now());
|
|
188
|
+
m.set(i, o), f = a === "persistent", f && !h.has(i) && (h.add(i), e !== null && r.add(e), t.error(G(i)));
|
|
154
189
|
}
|
|
155
|
-
(a || c) && (
|
|
190
|
+
(a || c) && (f || t.warn(c ? "cdc: un-replayable backlog event (schema moved past it) — jumping to current end + self-heal" : "cdc: binlog gap (purged/failover) — jumping to current end + self-heal"), i = e.resolveStartPosition ? await e.resolveStartPosition().catch(() => null) : null, o = i?.filename ?? null, f || e.onResync?.());
|
|
156
191
|
try {
|
|
157
|
-
await
|
|
192
|
+
await w(i), d = 0, y();
|
|
158
193
|
return;
|
|
159
194
|
} catch (e) {
|
|
160
195
|
n = e;
|
|
161
196
|
}
|
|
162
197
|
}
|
|
163
198
|
} finally {
|
|
164
|
-
|
|
199
|
+
p = !1;
|
|
165
200
|
}
|
|
166
201
|
}
|
|
167
202
|
};
|
|
168
203
|
try {
|
|
169
|
-
await
|
|
204
|
+
await w(e.startPosition ?? null);
|
|
170
205
|
} catch (n) {
|
|
171
206
|
if (C(n) && e.startPosition) {
|
|
172
207
|
t.warn("cdc: persisted offset purged — starting at current end + self-heal");
|
|
173
208
|
try {
|
|
174
|
-
|
|
209
|
+
l?.stop();
|
|
175
210
|
} catch {}
|
|
176
211
|
let n = e.resolveStartPosition ? await e.resolveStartPosition().catch(() => null) : null;
|
|
177
|
-
o = n?.filename ?? null, e.onResync?.(), await K(500), await
|
|
212
|
+
o = n?.filename ?? null, e.onResync?.(), await K(500), await w(n);
|
|
178
213
|
} else throw n;
|
|
179
214
|
}
|
|
180
|
-
let
|
|
181
|
-
if (
|
|
215
|
+
let E = async () => {
|
|
216
|
+
if (u || p || Date.now() - f < _) return;
|
|
182
217
|
let n = null;
|
|
183
|
-
if (e.resolveStartPosition && (n = await e.resolveStartPosition().catch(() => null)),
|
|
184
|
-
let r =
|
|
185
|
-
msSinceProgress: Date.now() -
|
|
186
|
-
stallThresholdMs:
|
|
218
|
+
if (e.resolveStartPosition && (n = await e.resolveStartPosition().catch(() => null)), u || p) return;
|
|
219
|
+
let r = W({
|
|
220
|
+
msSinceProgress: Date.now() - f,
|
|
221
|
+
stallThresholdMs: _,
|
|
187
222
|
primary: n,
|
|
188
223
|
reader: s
|
|
189
224
|
});
|
|
190
225
|
if (r !== "reconnect") {
|
|
191
|
-
r === "idle-caught-up" &&
|
|
226
|
+
r === "idle-caught-up" && y();
|
|
192
227
|
return;
|
|
193
228
|
}
|
|
194
229
|
t.warn("cdc: watchdog detected a stalled reader — forcing reconnect", {
|
|
195
230
|
reader: s,
|
|
196
231
|
primary: n,
|
|
197
|
-
stalledForMs: Date.now() -
|
|
198
|
-
}),
|
|
232
|
+
stalledForMs: Date.now() - f
|
|
233
|
+
}), T("watchdog: stream stalled (no events while primary advanced)", /* @__PURE__ */ Error("cdc watchdog stall"));
|
|
199
234
|
};
|
|
200
|
-
return
|
|
201
|
-
|
|
202
|
-
},
|
|
235
|
+
return g = setInterval(() => {
|
|
236
|
+
E();
|
|
237
|
+
}, v), g.unref && g.unref(), {
|
|
203
238
|
stop: async () => {
|
|
204
|
-
|
|
239
|
+
u = !0, g &&= (clearInterval(g), null);
|
|
205
240
|
try {
|
|
206
|
-
|
|
241
|
+
l?.stop();
|
|
207
242
|
} catch (e) {
|
|
208
243
|
t.warn("cdc: error stopping binlog reader", {}, e);
|
|
209
244
|
}
|
|
210
245
|
},
|
|
211
246
|
currentPosition: () => s
|
|
212
247
|
};
|
|
213
|
-
},
|
|
248
|
+
}, ve = /* @__PURE__ */ new Set(["1213", "1205"]), ye = (e) => {
|
|
214
249
|
let t = e;
|
|
215
250
|
for (let e = 0; e < 5 && typeof t == "object" && t; e++) {
|
|
216
251
|
let e = t.errno;
|
|
@@ -220,8 +255,8 @@ var N = (n) => e.layerConfig({
|
|
|
220
255
|
t = t.cause;
|
|
221
256
|
}
|
|
222
257
|
}, J = (e) => {
|
|
223
|
-
let t =
|
|
224
|
-
return t !== void 0 &&
|
|
258
|
+
let t = ye(e);
|
|
259
|
+
return t !== void 0 && ve.has(t);
|
|
225
260
|
}, Y = (e) => J(e) ? "retry" : "noRetry", X = (e) => {
|
|
226
261
|
if (e == null) return "null";
|
|
227
262
|
let t = typeof e;
|
|
@@ -231,19 +266,19 @@ var N = (n) => e.layerConfig({
|
|
|
231
266
|
if (Array.isArray(e)) return `[${e.map(X).join(",")}]`;
|
|
232
267
|
let n = e;
|
|
233
268
|
return `{${Object.keys(n).sort().map((e) => `${JSON.stringify(e)}:${X(n[e])}`).join(",")}}`;
|
|
234
|
-
},
|
|
269
|
+
}, be = (e) => {
|
|
235
270
|
let t = X(e), n = 2166136261;
|
|
236
271
|
for (let e = 0; e < t.length; e++) n ^= t.charCodeAt(e), n = Math.imul(n, 16777619);
|
|
237
272
|
return (n >>> 0).toString(36);
|
|
238
|
-
},
|
|
273
|
+
}, xe = (e, t) => {
|
|
239
274
|
let n = setTimeout(e, t);
|
|
240
275
|
typeof n.unref == "function" && n.unref();
|
|
241
|
-
},
|
|
276
|
+
}, Se = class {
|
|
242
277
|
variant;
|
|
243
278
|
ttlMs;
|
|
244
279
|
schedule;
|
|
245
280
|
seen = /* @__PURE__ */ new Map();
|
|
246
|
-
constructor(e, t = 6e4, n =
|
|
281
|
+
constructor(e, t = 6e4, n = xe) {
|
|
247
282
|
this.variant = e, this.ttlMs = t, this.schedule = n;
|
|
248
283
|
}
|
|
249
284
|
key(e) {
|
|
@@ -253,11 +288,11 @@ var N = (n) => e.layerConfig({
|
|
|
253
288
|
if (n == null) return null;
|
|
254
289
|
let r = t;
|
|
255
290
|
try {
|
|
256
|
-
r =
|
|
291
|
+
r = S([t], e.table, this.variant)[0] ?? t;
|
|
257
292
|
} catch {
|
|
258
293
|
r = t;
|
|
259
294
|
}
|
|
260
|
-
return `${e.table} ${e.op} ${String(n)} ${
|
|
295
|
+
return `${e.table} ${e.op} ${String(n)} ${be(r)}`;
|
|
261
296
|
}
|
|
262
297
|
admit(e) {
|
|
263
298
|
let t = this.key(e);
|
|
@@ -272,19 +307,16 @@ var N = (n) => e.layerConfig({
|
|
|
272
307
|
get pending() {
|
|
273
308
|
return this.seen.size;
|
|
274
309
|
}
|
|
275
|
-
},
|
|
310
|
+
}, Z = /* @__PURE__ */ new Set([
|
|
276
311
|
1022,
|
|
277
312
|
1062,
|
|
278
313
|
1586
|
|
279
314
|
]), Q = async (e) => {
|
|
280
|
-
let t = e.variant ?? "mysql", n =
|
|
315
|
+
let t = e.variant ?? "mysql", n = P({ scope: `voltro:${t}` }), a = e.changeStrategy ?? "inline", o = a;
|
|
281
316
|
a === "cdc" && !e.cdcConfig && (n.warn("changeStrategy='cdc' requires cdcConfig (serverId + connection); falling back to 'inline'."), o = "inline");
|
|
282
|
-
let s = e.tracerLayer ? r.mergeAll(e.sqlLayer, e.tracerLayer) : e.sqlLayer, c = i.make(s),
|
|
283
|
-
return o === "cdc" && e.cdcConfig && await
|
|
284
|
-
},
|
|
285
|
-
let e = C();
|
|
286
|
-
return e === void 0 ? (e) => e() : (t) => ie(e, t);
|
|
287
|
-
}, he = class e {
|
|
317
|
+
let s = e.tracerLayer ? r.mergeAll(e.sqlLayer, e.tracerLayer) : e.sqlLayer, c = i.make(s), l = new Ce(await c.runPromise(F), c, t, o);
|
|
318
|
+
return o === "cdc" && e.cdcConfig && await l.startCdcConsumer(e.cdcConfig), l;
|
|
319
|
+
}, Ce = class e {
|
|
288
320
|
sql;
|
|
289
321
|
runtime;
|
|
290
322
|
variant;
|
|
@@ -299,14 +331,15 @@ var N = (n) => e.layerConfig({
|
|
|
299
331
|
cdcReplicaId = "";
|
|
300
332
|
cdcStreamName = "default";
|
|
301
333
|
cdcGate;
|
|
334
|
+
reportEagerFallback;
|
|
302
335
|
constructor(e, t, n, r = "inline", i = null, a, o) {
|
|
303
|
-
this.sql = e, this.runtime = t, this.variant = n, this.changeStrategy = r, this.namespace = i, this.log =
|
|
336
|
+
this.sql = e, this.runtime = t, this.variant = n, this.changeStrategy = r, this.namespace = i, this.log = P({ scope: `voltro:${n}` }), this.reportEagerFallback = ee(this.log), this.emitter = a ?? new se(), ne(this.emitter), this.cdcGate = o ?? new Se(n);
|
|
304
337
|
}
|
|
305
338
|
withNamespace(t) {
|
|
306
339
|
return t === this.namespace ? this : new e(this.sql, this.runtime, this.variant, this.changeStrategy, t, this.emitter, this.cdcGate);
|
|
307
340
|
}
|
|
308
341
|
nsT(e) {
|
|
309
|
-
return
|
|
342
|
+
return te(this.namespace, e);
|
|
310
343
|
}
|
|
311
344
|
get dialectId() {
|
|
312
345
|
return this.variant;
|
|
@@ -318,8 +351,8 @@ var N = (n) => e.layerConfig({
|
|
|
318
351
|
};
|
|
319
352
|
}
|
|
320
353
|
async executeQuery(e, t, r) {
|
|
321
|
-
let i =
|
|
322
|
-
return
|
|
354
|
+
let i = x(e, this.sql, this.namespace), a = t ? n.provideService(i, I, t) : i;
|
|
355
|
+
return S(await O(this.variant, "select", () => this.runtime.runPromise(a)), e.table, this.variant);
|
|
323
356
|
}
|
|
324
357
|
get supportsInsertReturning() {
|
|
325
358
|
return this.variant === "mariadb";
|
|
@@ -331,10 +364,10 @@ var N = (n) => e.layerConfig({
|
|
|
331
364
|
return !1;
|
|
332
365
|
}
|
|
333
366
|
async executeInsert(e, t, r, i, a) {
|
|
334
|
-
t =
|
|
367
|
+
t = M(e, t);
|
|
335
368
|
let o = this.sql;
|
|
336
369
|
if (this.supportsInsertReturning) {
|
|
337
|
-
let s = o`INSERT INTO ${o(this.nsT(e))} ${o.insert(
|
|
370
|
+
let s = o`INSERT INTO ${o(this.nsT(e))} ${o.insert(C(t, e))} RETURNING *`, c = r ? n.provideService(s, I, r) : s, l = (await this.runtime.runPromise(c))[0];
|
|
338
371
|
if (!l) throw Error(`MysqlStore.insert: no row returned for table '${e}'`);
|
|
339
372
|
return await this.routeEvent({
|
|
340
373
|
table: e,
|
|
@@ -343,7 +376,7 @@ var N = (n) => e.layerConfig({
|
|
|
343
376
|
new: l
|
|
344
377
|
}, i, r, a), l;
|
|
345
378
|
}
|
|
346
|
-
let s =
|
|
379
|
+
let s = C(t, e), c = t.id;
|
|
347
380
|
if (c === void 0) {
|
|
348
381
|
let t = await this.insertRecoverAutoId(e, s, r);
|
|
349
382
|
return await this.routeEvent({
|
|
@@ -353,31 +386,31 @@ var N = (n) => e.layerConfig({
|
|
|
353
386
|
new: t
|
|
354
387
|
}, i, r, a), t;
|
|
355
388
|
}
|
|
356
|
-
let l = o`INSERT INTO ${o(this.nsT(e))} ${o.insert(s)}`, u = r ? n.provideService(l,
|
|
389
|
+
let l = o`INSERT INTO ${o(this.nsT(e))} ${o.insert(s)}`, u = r ? n.provideService(l, I, r) : l;
|
|
357
390
|
await this.runtime.runPromise(u);
|
|
358
|
-
let
|
|
359
|
-
if (!
|
|
391
|
+
let d = o`SELECT * FROM ${o(this.nsT(e))} WHERE ${o("id")} = ${c}`, f = r ? n.provideService(d, I, r) : d, p = (await this.runtime.runPromise(f))[0];
|
|
392
|
+
if (!p) throw Error(`MysqlStore.insert: row not found post-insert in '${e}'`);
|
|
360
393
|
return await this.routeEvent({
|
|
361
394
|
table: e,
|
|
362
395
|
op: "insert",
|
|
363
396
|
old: null,
|
|
364
|
-
new:
|
|
365
|
-
}, i, r, a),
|
|
397
|
+
new: p
|
|
398
|
+
}, i, r, a), p;
|
|
366
399
|
}
|
|
367
400
|
async insertRecoverAutoId(e, t, r) {
|
|
368
401
|
let i = this.sql;
|
|
369
402
|
return this.runPinned(r, (r) => n.gen(this, function* () {
|
|
370
403
|
let a = i`INSERT INTO ${i(this.nsT(e))} ${i.insert(t)}`;
|
|
371
|
-
yield* n.provideService(a,
|
|
372
|
-
let o = (yield* n.provideService(i`SELECT LAST_INSERT_ID() AS ${i("lastId")}`,
|
|
373
|
-
return o === void 0 || Number(o) === 0 ? yield* n.fail(/* @__PURE__ */ Error(`MysqlStore.insert: LAST_INSERT_ID() returned no id for '${e}' — is the primary key AUTO_INCREMENT?`)) : (yield* n.provideService(i`SELECT * FROM ${i(this.nsT(e))} WHERE ${i("id")} = ${o}`,
|
|
404
|
+
yield* n.provideService(a, I, r);
|
|
405
|
+
let o = (yield* n.provideService(i`SELECT LAST_INSERT_ID() AS ${i("lastId")}`, I, r))[0]?.lastId;
|
|
406
|
+
return o === void 0 || Number(o) === 0 ? yield* n.fail(/* @__PURE__ */ Error(`MysqlStore.insert: LAST_INSERT_ID() returned no id for '${e}' — is the primary key AUTO_INCREMENT?`)) : (yield* n.provideService(i`SELECT * FROM ${i(this.nsT(e))} WHERE ${i("id")} = ${o}`, I, r))[0] || (yield* n.fail(/* @__PURE__ */ Error(`MysqlStore.insert: row not found post-insert in '${e}'`)));
|
|
374
407
|
}), "insert");
|
|
375
408
|
}
|
|
376
409
|
async runPinned(e, t, r) {
|
|
377
410
|
if (e) return this.runtime.runPromise(t(e));
|
|
378
411
|
this.inflightTxns++;
|
|
379
412
|
try {
|
|
380
|
-
let e = n.suspend(() => this.sql.withTransaction(n.flatMap(n.serviceOption(
|
|
413
|
+
let e = n.suspend(() => this.sql.withTransaction(n.flatMap(n.serviceOption(I), (e) => a.isNone(e) ? n.fail(/* @__PURE__ */ Error("MysqlStore.insert: TransactionConnection missing.")) : t(e.value)))), i = s.exponential("10 millis").pipe(s.compose(s.recurs(3)), s.whileInput(J)), o = e.pipe(n.retry(i), n.withSpan("store.insert", { attributes: {
|
|
381
414
|
"db.system": this.variant,
|
|
382
415
|
"db.operation": r
|
|
383
416
|
} }));
|
|
@@ -387,17 +420,25 @@ var N = (n) => e.layerConfig({
|
|
|
387
420
|
}
|
|
388
421
|
}
|
|
389
422
|
async executeInsertMany(e, t, r, i, a) {
|
|
390
|
-
if (t =
|
|
391
|
-
let o = this.sql, s = t.map((t) =>
|
|
423
|
+
if (t = oe(e, t), t.length === 0) return [];
|
|
424
|
+
let o = this.sql, s = _(t.map((t) => C(t, e)), g(this.variant));
|
|
392
425
|
if (this.supportsInsertReturning) {
|
|
393
|
-
let t = o`INSERT INTO ${o(this.nsT(e))} ${o.insert(
|
|
394
|
-
|
|
426
|
+
let t = (t) => o`INSERT INTO ${o(this.nsT(e))} ${o.insert(t)} RETURNING *`, c;
|
|
427
|
+
if (s.length === 1) {
|
|
428
|
+
let e = t(s[0]), i = r ? n.provideService(e, I, r) : e;
|
|
429
|
+
c = await this.runtime.runPromise(i);
|
|
430
|
+
} else if (r) {
|
|
431
|
+
let e = [];
|
|
432
|
+
for (let i of s) e.push(...await this.runtime.runPromise(n.provideService(t(i), I, r)));
|
|
433
|
+
c = e;
|
|
434
|
+
} else c = await this.runtime.runPromise(o.withTransaction(n.map(n.forEach(s, t, { concurrency: 1 }), (e) => e.flat())));
|
|
435
|
+
for (let t of c) await this.routeEvent({
|
|
395
436
|
table: e,
|
|
396
437
|
op: "insert",
|
|
397
438
|
old: null,
|
|
398
439
|
new: t
|
|
399
440
|
}, i, r, a);
|
|
400
|
-
return
|
|
441
|
+
return c;
|
|
401
442
|
}
|
|
402
443
|
let c = t.map((e) => e.id);
|
|
403
444
|
if (c.every((e) => e === void 0)) {
|
|
@@ -411,43 +452,59 @@ var N = (n) => e.layerConfig({
|
|
|
411
452
|
return t;
|
|
412
453
|
}
|
|
413
454
|
if (c.some((e) => e === void 0)) throw Error("MysqlStore.insertMany: rows mix client-supplied and missing 'id's — supply an id for every row or none (AUTO_INCREMENT recovery).");
|
|
414
|
-
let l = o`INSERT INTO ${o(this.nsT(e))} ${o.insert(
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
455
|
+
let l = (t) => o`INSERT INTO ${o(this.nsT(e))} ${o.insert(t)}`;
|
|
456
|
+
if (s.length === 1) {
|
|
457
|
+
let e = r ? n.provideService(l(s[0]), I, r) : l(s[0]);
|
|
458
|
+
await this.runtime.runPromise(e);
|
|
459
|
+
} else if (r) for (let e of s) await this.runtime.runPromise(n.provideService(l(e), I, r));
|
|
460
|
+
else await this.runtime.runPromise(o.withTransaction(n.forEach(s, l, {
|
|
461
|
+
concurrency: 1,
|
|
462
|
+
discard: !0
|
|
463
|
+
})));
|
|
464
|
+
let u = _(c.map((e) => ({ id: e })), g(this.variant)), d = [];
|
|
465
|
+
for (let t of u) {
|
|
466
|
+
let i = o`SELECT * FROM ${o(this.nsT(e))} WHERE ${o("id")} IN ${o.in(t.map((e) => e.id))}`, a = r ? n.provideService(i, I, r) : i;
|
|
467
|
+
d.push(...await this.runtime.runPromise(a));
|
|
468
|
+
}
|
|
469
|
+
let f = new Map(d.map((e) => [e.id, e])), p = c.map((e) => f.get(e)).filter((e) => e !== void 0);
|
|
470
|
+
for (let t of p) await this.routeEvent({
|
|
418
471
|
table: e,
|
|
419
472
|
op: "insert",
|
|
420
473
|
old: null,
|
|
421
474
|
new: t
|
|
422
475
|
}, i, r, a);
|
|
423
|
-
return
|
|
476
|
+
return p;
|
|
424
477
|
}
|
|
425
478
|
async insertManyRecoverAutoIds(e, t, r) {
|
|
426
|
-
let i = this.sql
|
|
479
|
+
let i = this.sql;
|
|
427
480
|
return this.runPinned(r, (r) => n.gen(this, function* () {
|
|
428
|
-
let
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
481
|
+
let a = [];
|
|
482
|
+
for (let o of t) {
|
|
483
|
+
let t = i`INSERT INTO ${i(this.nsT(e))} ${i.insert(o)}`;
|
|
484
|
+
yield* n.provideService(t, I, r);
|
|
485
|
+
let s = (yield* n.provideService(i`SELECT LAST_INSERT_ID() AS ${i("firstId")}`, I, r))[0]?.firstId;
|
|
486
|
+
if (s === void 0 || Number(s) === 0) return yield* n.fail(/* @__PURE__ */ Error(`MysqlStore.insertMany: LAST_INSERT_ID() returned no id for '${e}' — is the primary key AUTO_INCREMENT?`));
|
|
487
|
+
let c = Number(s), l = yield* n.provideService(i`SELECT * FROM ${i(this.nsT(e))} WHERE ${i("id")} BETWEEN ${c} AND ${c + o.length - 1} ORDER BY ${i("id")} ASC`, I, r);
|
|
488
|
+
a.push(...l);
|
|
489
|
+
}
|
|
490
|
+
return a;
|
|
434
491
|
}), "insert");
|
|
435
492
|
}
|
|
436
493
|
async executePatchJson(e, t, r, i, a, o, s) {
|
|
437
|
-
let c = this.sql, l = r.split("."), u = l[0],
|
|
438
|
-
if (
|
|
439
|
-
let
|
|
440
|
-
return
|
|
494
|
+
let c = this.sql, l = r.split("."), u = l[0], d = l.slice(1), f = JSON.stringify(i ?? null), p = d.length === 0 ? "$" : `$.${d.join(".")}`, m = c`UPDATE ${c(this.nsT(e))} SET ${c(u)} = JSON_SET(COALESCE(${c(u)}, '{}'), ${p}, CAST(${f} AS JSON)) WHERE ${c("id")} = ${t}`, h = a ? n.provideService(m, I, a) : m, g = await this.runtime.runPromise(h);
|
|
495
|
+
if (g && typeof g.affectedRows == "number" && g.affectedRows === 0) return null;
|
|
496
|
+
let _ = c`SELECT * FROM ${c(this.nsT(e))} WHERE ${c("id")} = ${t}`, v = a ? n.provideService(_, I, a) : _, y = (await this.runtime.runPromise(v))[0];
|
|
497
|
+
return y ? (await this.routeEvent({
|
|
441
498
|
table: e,
|
|
442
499
|
op: "update",
|
|
443
500
|
old: null,
|
|
444
|
-
new:
|
|
445
|
-
}, o, a, s),
|
|
501
|
+
new: y
|
|
502
|
+
}, o, a, s), y) : null;
|
|
446
503
|
}
|
|
447
504
|
async executeUpdate(e, t, r, i, a, o) {
|
|
448
505
|
let s = this.sql;
|
|
449
506
|
if (this.supportsUpdateReturning) {
|
|
450
|
-
let c = s`UPDATE ${s(this.nsT(e))} SET ${s.update(
|
|
507
|
+
let c = s`UPDATE ${s(this.nsT(e))} SET ${s.update(C(r, e))} WHERE ${s("id")} = ${t} RETURNING *`, l = i ? n.provideService(c, I, i) : c, u = (await this.runtime.runPromise(l))[0];
|
|
451
508
|
return u ? (await this.routeEvent({
|
|
452
509
|
table: e,
|
|
453
510
|
op: "update",
|
|
@@ -455,20 +512,20 @@ var N = (n) => e.layerConfig({
|
|
|
455
512
|
new: u
|
|
456
513
|
}, a, i, o), u) : null;
|
|
457
514
|
}
|
|
458
|
-
let c = s`UPDATE ${s(this.nsT(e))} SET ${s.update(
|
|
515
|
+
let c = s`UPDATE ${s(this.nsT(e))} SET ${s.update(C(r, e))} WHERE ${s("id")} = ${t}`, l = i ? n.provideService(c, I, i) : c, u = await this.runtime.runPromise(l);
|
|
459
516
|
if (u && typeof u.affectedRows == "number" && u.affectedRows === 0) return null;
|
|
460
|
-
let
|
|
461
|
-
return
|
|
517
|
+
let d = s`SELECT * FROM ${s(this.nsT(e))} WHERE ${s("id")} = ${t}`, f = i ? n.provideService(d, I, i) : d, p = (await this.runtime.runPromise(f))[0];
|
|
518
|
+
return p ? (await this.routeEvent({
|
|
462
519
|
table: e,
|
|
463
520
|
op: "update",
|
|
464
521
|
old: null,
|
|
465
|
-
new:
|
|
466
|
-
}, a, i, o),
|
|
522
|
+
new: p
|
|
523
|
+
}, a, i, o), p) : null;
|
|
467
524
|
}
|
|
468
525
|
async executeDelete(e, t, r, i, a) {
|
|
469
526
|
let o = this.sql;
|
|
470
527
|
if (this.supportsDeleteReturning) {
|
|
471
|
-
let s = o`DELETE FROM ${o(this.nsT(e))} WHERE ${o("id")} = ${t} RETURNING *`, c = r ? n.provideService(s,
|
|
528
|
+
let s = o`DELETE FROM ${o(this.nsT(e))} WHERE ${o("id")} = ${t} RETURNING *`, c = r ? n.provideService(s, I, r) : s, l = (await this.runtime.runPromise(c))[0];
|
|
472
529
|
return l ? (await this.routeEvent({
|
|
473
530
|
table: e,
|
|
474
531
|
op: "delete",
|
|
@@ -476,10 +533,10 @@ var N = (n) => e.layerConfig({
|
|
|
476
533
|
new: null
|
|
477
534
|
}, i, r, a), !0) : !1;
|
|
478
535
|
}
|
|
479
|
-
let s = o`SELECT * FROM ${o(this.nsT(e))} WHERE ${o("id")} = ${t}`, c = r ? n.provideService(s,
|
|
536
|
+
let s = o`SELECT * FROM ${o(this.nsT(e))} WHERE ${o("id")} = ${t}`, c = r ? n.provideService(s, I, r) : s, l = (await this.runtime.runPromise(c))[0];
|
|
480
537
|
if (!l) return !1;
|
|
481
|
-
let u = o`DELETE FROM ${o(this.nsT(e))} WHERE ${o("id")} = ${t}`,
|
|
482
|
-
return await this.runtime.runPromise(
|
|
538
|
+
let u = o`DELETE FROM ${o(this.nsT(e))} WHERE ${o("id")} = ${t}`, d = r ? n.provideService(u, I, r) : u;
|
|
539
|
+
return await this.runtime.runPromise(d), await this.routeEvent({
|
|
483
540
|
table: e,
|
|
484
541
|
op: "delete",
|
|
485
542
|
old: l,
|
|
@@ -487,18 +544,18 @@ var N = (n) => e.layerConfig({
|
|
|
487
544
|
}, i, r, a), !0;
|
|
488
545
|
}
|
|
489
546
|
async appendInTxn(e, t, r) {
|
|
490
|
-
let i = this.sql, a = i`INSERT INTO ${i(this.nsT(e))} ${i.insert(
|
|
491
|
-
await this.runtime.runPromise(r ? n.provideService(a,
|
|
547
|
+
let i = this.sql, a = i`INSERT INTO ${i(this.nsT(e))} ${i.insert(C(t, e))}`;
|
|
548
|
+
await this.runtime.runPromise(r ? n.provideService(a, I, r) : a);
|
|
492
549
|
}
|
|
493
550
|
async maxInTxn(e, t, r, i) {
|
|
494
|
-
let a = this.sql, o = Object.entries(r).map(([e, t]) => a`${a(e)} = ${t}`), s = a`SELECT MAX(${a(t)}) AS ${a("m")} FROM ${a(this.nsT(e))} WHERE ${a.and(o)}`, c = (await this.runtime.runPromise(i ? n.provideService(s,
|
|
551
|
+
let a = this.sql, o = Object.entries(r).map(([e, t]) => a`${a(e)} = ${t}`), s = a`SELECT MAX(${a(t)}) AS ${a("m")} FROM ${a(this.nsT(e))} WHERE ${a.and(o)}`, c = (await this.runtime.runPromise(i ? n.provideService(s, I, i) : s))[0]?.m;
|
|
495
552
|
return c == null ? null : Number(c);
|
|
496
553
|
}
|
|
497
554
|
async routeEvent(e, t, n = null, r) {
|
|
498
555
|
if (e = {
|
|
499
|
-
...
|
|
556
|
+
...p(r),
|
|
500
557
|
...e
|
|
501
|
-
},
|
|
558
|
+
}, re(e.table) && await ae({
|
|
502
559
|
append: (e, t) => this.appendInTxn(e, t, n),
|
|
503
560
|
maxOf: (e, t, r) => this.maxInTxn(e, t, r, n)
|
|
504
561
|
}, {
|
|
@@ -510,7 +567,7 @@ var N = (n) => e.layerConfig({
|
|
|
510
567
|
subjectId: e.subjectId
|
|
511
568
|
}), this.changeStrategy === "cdc") {
|
|
512
569
|
let t = (e.op === "delete" ? e.old : e.new)?.id;
|
|
513
|
-
t != null &&
|
|
570
|
+
t != null && ie(m(e.table, e.op, t), {
|
|
514
571
|
...e.traceId === void 0 ? {} : { traceId: e.traceId },
|
|
515
572
|
...e.subjectId === void 0 ? {} : { subjectId: e.subjectId }
|
|
516
573
|
});
|
|
@@ -541,41 +598,41 @@ var N = (n) => e.layerConfig({
|
|
|
541
598
|
}
|
|
542
599
|
return await this.executeUpdate(e, o.id, a, r, i) ?? o;
|
|
543
600
|
}
|
|
544
|
-
return
|
|
601
|
+
return N((n) => this.executeInsert(e, t, r, i, n));
|
|
545
602
|
}
|
|
546
603
|
async executeMariadbUpsert(e, t, r, i, a, o) {
|
|
547
|
-
let s = this.sql, c =
|
|
548
|
-
if (!
|
|
549
|
-
let
|
|
604
|
+
let s = this.sql, c = C(t, e), l = Object.keys(c).filter((e) => c[e] !== void 0), u = r.update === void 0 ? l.filter((e) => e !== "id" && !r.conflictColumns.includes(e)) : r.update, d = u.length > 0 ? s.csv(u.map((e) => s`${s(e)} = VALUES(${s(e)})`)) : s`${s(r.conflictColumns[0])} = VALUES(${s(r.conflictColumns[0])})`, f = s`INSERT INTO ${s(this.nsT(e))} ${s.insert(c)} ON DUPLICATE KEY UPDATE ${d} RETURNING *`, p = i ? n.provideService(f, I, i) : f, m = (await this.runtime.runPromise(p))[0];
|
|
605
|
+
if (!m) throw Error(`MysqlStore.upsert: no row returned for table '${e}'`);
|
|
606
|
+
let h = t.id !== void 0 && t.id === m.id ? "insert" : "update";
|
|
550
607
|
return await this.routeEvent({
|
|
551
608
|
table: e,
|
|
552
|
-
op:
|
|
609
|
+
op: h,
|
|
553
610
|
old: null,
|
|
554
|
-
new:
|
|
555
|
-
}, a, i, o),
|
|
611
|
+
new: m
|
|
612
|
+
}, a, i, o), m;
|
|
556
613
|
}
|
|
557
614
|
async executeInsertIgnore(e, t, r, i, a, o) {
|
|
558
|
-
if (t =
|
|
559
|
-
let s = this.sql, c = s`INSERT IGNORE INTO ${s(this.nsT(e))} ${s.insert(
|
|
615
|
+
if (t = M(e, t), this.variant === "mariadb") {
|
|
616
|
+
let s = this.sql, c = s`INSERT IGNORE INTO ${s(this.nsT(e))} ${s.insert(C(t, e))} RETURNING *`, l = i ? n.provideService(c, I, i) : c, u = (await this.runtime.runPromise(l))[0];
|
|
560
617
|
if (u) return await this.routeEvent({
|
|
561
618
|
table: e,
|
|
562
619
|
op: "insert",
|
|
563
620
|
old: null,
|
|
564
621
|
new: u
|
|
565
622
|
}, a, i, o), u;
|
|
566
|
-
let
|
|
567
|
-
if (
|
|
568
|
-
let
|
|
569
|
-
if (
|
|
570
|
-
let
|
|
571
|
-
throw Error(`MysqlStore.insertIgnore: the insert was skipped as a conflict, but no existing row matches conflictColumns [${r.conflictColumns.join(", ")}] on '${e}'. ` + (
|
|
623
|
+
let d = await this.readWarnings(i), f = d.find((e) => !Z.has(e.code));
|
|
624
|
+
if (f !== void 0) throw Error(`MysqlStore.insertIgnore: the insert into '${e}' was REJECTED, not skipped as a conflict. INSERT IGNORE downgrades every error to a warning, and the warning was: [${f.code}] ${f.message}. Nothing was written and nothing conflicted — fix the cause above.`);
|
|
625
|
+
let p = await this.findByConflict(e, t, r.conflictColumns, i);
|
|
626
|
+
if (p) return p;
|
|
627
|
+
let m = d[0];
|
|
628
|
+
throw Error(`MysqlStore.insertIgnore: the insert was skipped as a conflict, but no existing row matches conflictColumns [${r.conflictColumns.join(", ")}] on '${e}'. ` + (m === void 0 ? "The warning could not be read on this connection, so the constraint that fired is unknown — it may be a second unique index, or the primary key under another name. " : `The constraint that actually fired: [${m.code}] ${m.message}. `) + "insertIgnore models ONE conflict target: name the columns of the constraint that actually collides, or handle the violation yourself.");
|
|
572
629
|
}
|
|
573
|
-
return await this.findByConflict(e, t, r.conflictColumns, i) ||
|
|
630
|
+
return await this.findByConflict(e, t, r.conflictColumns, i) || N((n) => this.executeInsert(e, t, i, a, n));
|
|
574
631
|
}
|
|
575
632
|
async findUndecodableCdcTables(e) {
|
|
576
633
|
if (this.variant !== "mariadb") return [];
|
|
577
634
|
try {
|
|
578
|
-
let t = (await this.runtime.runPromise(this.sql.unsafe(
|
|
635
|
+
let t = (await this.runtime.runPromise(this.sql.unsafe(fe))).map((e) => String(e.tableName ?? e.TABLE_NAME ?? "")).filter((e) => e !== "");
|
|
579
636
|
return e === void 0 ? t : t.filter((t) => e.includes(t));
|
|
580
637
|
} catch (e) {
|
|
581
638
|
return this.log.debug(`cdc: could not probe for undecodable tables — ${e?.message ?? String(e)}`), [];
|
|
@@ -585,7 +642,7 @@ var N = (n) => e.layerConfig({
|
|
|
585
642
|
if (e === null) return [];
|
|
586
643
|
try {
|
|
587
644
|
let t = this.sql`SHOW WARNINGS`;
|
|
588
|
-
return (await this.runtime.runPromise(n.provideService(t,
|
|
645
|
+
return (await this.runtime.runPromise(n.provideService(t, I, e))).map((e) => ({
|
|
589
646
|
code: Number(e.Code ?? e.code ?? 0),
|
|
590
647
|
message: String(e.Message ?? e.message ?? "")
|
|
591
648
|
}));
|
|
@@ -595,64 +652,76 @@ var N = (n) => e.layerConfig({
|
|
|
595
652
|
}
|
|
596
653
|
async findByConflict(e, t, r, i) {
|
|
597
654
|
if (r.length === 0) return;
|
|
598
|
-
let a = this.sql, o = r.map((e) => a`${a(e)} = ${t[e]}`), s = a`SELECT * FROM ${a(this.nsT(e))} WHERE ${a.and(o)} LIMIT 1`, c = i ? n.provideService(s,
|
|
655
|
+
let a = this.sql, o = r.map((e) => a`${a(e)} = ${t[e]}`), s = a`SELECT * FROM ${a(this.nsT(e))} WHERE ${a.and(o)} LIMIT 1`, c = i ? n.provideService(s, I, i) : s;
|
|
599
656
|
return (await this.runtime.runPromise(c))[0];
|
|
600
657
|
}
|
|
601
658
|
query(e) {
|
|
602
659
|
return this.runWithEager(e, null);
|
|
603
660
|
}
|
|
604
661
|
raw(e, t) {
|
|
605
|
-
let n =
|
|
606
|
-
return this.runtime.runPromise(n);
|
|
662
|
+
let n = b(e, this.sql);
|
|
663
|
+
return O(this.variant, "raw", () => this.runtime.runPromise(n));
|
|
607
664
|
}
|
|
608
665
|
async runWithEager(e, t) {
|
|
609
|
-
if (!
|
|
610
|
-
let r = this.variant === "mariadb" ? "mariadb" : "mysql", i = this.namespace === null ?
|
|
666
|
+
if (!E(e)) return this.executeQuery(e, t);
|
|
667
|
+
let r = this.variant === "mariadb" ? "mariadb" : "mysql", i = this.namespace === null ? v(e, this.sql, r) : null;
|
|
611
668
|
if (i !== null) try {
|
|
612
|
-
let e = t ? n.provideService(i.fragment,
|
|
669
|
+
let e = t ? n.provideService(i.fragment, I, t) : i.fragment, r = await O(this.variant, "select", () => this.runtime.runPromise(e));
|
|
613
670
|
return i.decode(r);
|
|
614
|
-
} catch (
|
|
615
|
-
if (
|
|
616
|
-
this.
|
|
671
|
+
} catch (t) {
|
|
672
|
+
if (t instanceof u) throw t;
|
|
673
|
+
this.reportEagerFallback({
|
|
674
|
+
dialect: r,
|
|
675
|
+
table: e.table,
|
|
676
|
+
reason: "execute-failed",
|
|
677
|
+
error: t
|
|
678
|
+
});
|
|
617
679
|
}
|
|
618
|
-
|
|
680
|
+
else this.reportEagerFallback({
|
|
681
|
+
dialect: r,
|
|
682
|
+
table: e.table,
|
|
683
|
+
reason: "not-compilable"
|
|
684
|
+
});
|
|
685
|
+
return f(await this.executeQuery(e, t), e.eager, e.sourceTable ?? k(e.table), (e) => this.executeQuery(e, t));
|
|
619
686
|
}
|
|
620
687
|
getInternalRunWithEager() {
|
|
621
688
|
return this.runWithEager.bind(this);
|
|
622
689
|
}
|
|
623
|
-
async localWrite(e, t) {
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
690
|
+
async localWrite(e, t, n) {
|
|
691
|
+
return O(this.variant, e, async () => {
|
|
692
|
+
if (this.changeStrategy !== "cdc") return N(n);
|
|
693
|
+
h(t);
|
|
694
|
+
try {
|
|
695
|
+
return await N(n);
|
|
696
|
+
} finally {
|
|
697
|
+
w(t);
|
|
698
|
+
}
|
|
699
|
+
});
|
|
631
700
|
}
|
|
632
701
|
insert(e, t) {
|
|
633
|
-
return this.localWrite(e, (n) => this.executeInsert(e, t, null, null, n));
|
|
702
|
+
return this.localWrite("insert", e, (n) => this.executeInsert(e, t, null, null, n));
|
|
634
703
|
}
|
|
635
704
|
insertMany(e, t) {
|
|
636
|
-
return this.localWrite(e, (n) => this.executeInsertMany(e, t, null, null, n));
|
|
705
|
+
return this.localWrite("insert", e, (n) => this.executeInsertMany(e, t, null, null, n));
|
|
637
706
|
}
|
|
638
707
|
patchJson(e, t, n, r) {
|
|
639
|
-
return this.localWrite(e, (i) => this.executePatchJson(e, t, n, r, null, null, i));
|
|
708
|
+
return this.localWrite("update", e, (i) => this.executePatchJson(e, t, n, r, null, null, i));
|
|
640
709
|
}
|
|
641
710
|
upsert(e, t, n) {
|
|
642
|
-
return this.localWrite(e, (r) => this.executeUpsert(e, t, n, null, null, r));
|
|
711
|
+
return this.localWrite("upsert", e, (r) => this.executeUpsert(e, t, n, null, null, r));
|
|
643
712
|
}
|
|
644
713
|
insertIgnore(e, t, n) {
|
|
645
|
-
return this.localWrite(e, (r) => this.executeInsertIgnore(e, t, n, null, null, r));
|
|
714
|
+
return this.localWrite("upsert", e, (r) => this.executeInsertIgnore(e, t, n, null, null, r));
|
|
646
715
|
}
|
|
647
716
|
update(e, t, n) {
|
|
648
|
-
return this.localWrite(e, (r) => this.executeUpdate(e, t, n, null, null, r));
|
|
717
|
+
return this.localWrite("update", e, (r) => this.executeUpdate(e, t, n, null, null, r));
|
|
649
718
|
}
|
|
650
719
|
delete(e, t) {
|
|
651
|
-
return this.localWrite(e, (n) => this.executeDelete(e, t, null, null, n));
|
|
720
|
+
return this.localWrite("delete", e, (n) => this.executeDelete(e, t, null, null, n));
|
|
652
721
|
}
|
|
653
722
|
async updateMany(e, t, r) {
|
|
654
723
|
if (this.supportsUpdateReturning) {
|
|
655
|
-
let n = this.sql, i =
|
|
724
|
+
let n = this.sql, i = y(r.where, n, this.namespace), a = n`UPDATE ${n(this.nsT(e))} SET ${n.update(C(t, e))} WHERE ${i} RETURNING *`, o = await this.runtime.runPromise(a);
|
|
656
725
|
for (let t of o) await this.routeEvent({
|
|
657
726
|
table: e,
|
|
658
727
|
op: "update",
|
|
@@ -661,38 +730,38 @@ var N = (n) => e.layerConfig({
|
|
|
661
730
|
}, null, null);
|
|
662
731
|
return o.length;
|
|
663
732
|
}
|
|
664
|
-
let i = this.sql, o =
|
|
665
|
-
this.changeStrategy === "cdc" &&
|
|
733
|
+
let i = this.sql, o = y(r.where, i, this.namespace);
|
|
734
|
+
this.changeStrategy === "cdc" && h(e), this.inflightTxns++;
|
|
666
735
|
try {
|
|
667
|
-
let r = n.suspend(() => this.sql.withTransaction(n.flatMap(n.serviceOption(
|
|
736
|
+
let r = n.suspend(() => this.sql.withTransaction(n.flatMap(n.serviceOption(I), (r) => {
|
|
668
737
|
if (a.isNone(r)) return n.fail(/* @__PURE__ */ Error("MysqlStore.updateMany: TransactionConnection missing."));
|
|
669
|
-
let s = r.value, c = i`SELECT id FROM ${i(this.nsT(e))} WHERE ${o} FOR UPDATE`, l = i`UPDATE ${i(this.nsT(e))} SET ${i.update(
|
|
670
|
-
return n.flatMap(n.provideService(c,
|
|
738
|
+
let s = r.value, c = i`SELECT id FROM ${i(this.nsT(e))} WHERE ${o} FOR UPDATE`, l = i`UPDATE ${i(this.nsT(e))} SET ${i.update(C(t, e))} WHERE ${o}`;
|
|
739
|
+
return n.flatMap(n.provideService(c, I, s), (t) => {
|
|
671
740
|
if (t.length === 0) return n.succeed([]);
|
|
672
741
|
let r = t.map((e) => e.id), a = i`SELECT * FROM ${i(this.nsT(e))} WHERE ${i("id")} IN ${i.in(r)}`;
|
|
673
|
-
return n.flatMap(n.provideService(l,
|
|
742
|
+
return n.flatMap(n.provideService(l, I, s), () => n.provideService(a, I, s));
|
|
674
743
|
});
|
|
675
744
|
}))), c = s.exponential("10 millis").pipe(s.compose(s.recurs(3)), s.whileInput(J)), l = r.pipe(n.retry(c), n.withSpan("store.updateMany", { attributes: {
|
|
676
745
|
"db.system": this.variant,
|
|
677
746
|
"db.operation": "update"
|
|
678
747
|
} })), u = await this.runtime.runPromise(l);
|
|
679
748
|
if (u.length === 0) return 0;
|
|
680
|
-
let
|
|
681
|
-
for (let t of
|
|
749
|
+
let d = S(u, e, this.variant);
|
|
750
|
+
for (let t of d) await this.routeEvent({
|
|
682
751
|
table: e,
|
|
683
752
|
op: "update",
|
|
684
753
|
old: null,
|
|
685
754
|
new: t
|
|
686
755
|
}, null, null);
|
|
687
|
-
return
|
|
756
|
+
return d.length;
|
|
688
757
|
} finally {
|
|
689
|
-
this.inflightTxns--, this.changeStrategy === "cdc" &&
|
|
758
|
+
this.inflightTxns--, this.changeStrategy === "cdc" && w(e);
|
|
690
759
|
}
|
|
691
760
|
}
|
|
692
761
|
async deleteMany(e, t) {
|
|
693
|
-
let r = this.sql, i =
|
|
762
|
+
let r = this.sql, i = y(t.where, r, this.namespace);
|
|
694
763
|
if (this.supportsDeleteReturning) {
|
|
695
|
-
let t = r`DELETE FROM ${r(this.nsT(e))} WHERE ${i} RETURNING *`, n =
|
|
764
|
+
let t = r`DELETE FROM ${r(this.nsT(e))} WHERE ${i} RETURNING *`, n = S(await this.runtime.runPromise(t), e, this.variant);
|
|
696
765
|
for (let t of n) await this.routeEvent({
|
|
697
766
|
table: e,
|
|
698
767
|
op: "delete",
|
|
@@ -701,18 +770,18 @@ var N = (n) => e.layerConfig({
|
|
|
701
770
|
}, null, null);
|
|
702
771
|
return n.length;
|
|
703
772
|
}
|
|
704
|
-
this.changeStrategy === "cdc" &&
|
|
773
|
+
this.changeStrategy === "cdc" && h(e), this.inflightTxns++;
|
|
705
774
|
try {
|
|
706
|
-
let t = n.suspend(() => this.sql.withTransaction(n.flatMap(n.serviceOption(
|
|
775
|
+
let t = n.suspend(() => this.sql.withTransaction(n.flatMap(n.serviceOption(I), (t) => {
|
|
707
776
|
if (a.isNone(t)) return n.fail(/* @__PURE__ */ Error("MysqlStore.deleteMany: TransactionConnection missing."));
|
|
708
777
|
let o = t.value, s = r`SELECT * FROM ${r(this.nsT(e))} WHERE ${i} FOR UPDATE`, c = r`DELETE FROM ${r(this.nsT(e))} WHERE ${i}`;
|
|
709
|
-
return n.flatMap(n.provideService(s,
|
|
778
|
+
return n.flatMap(n.provideService(s, I, o), (e) => e.length === 0 ? n.succeed(e) : n.as(n.provideService(c, I, o), e));
|
|
710
779
|
}))), o = s.exponential("10 millis").pipe(s.compose(s.recurs(3)), s.whileInput(J)), c = t.pipe(n.retry(o), n.withSpan("store.deleteMany", { attributes: {
|
|
711
780
|
"db.system": this.variant,
|
|
712
781
|
"db.operation": "delete"
|
|
713
782
|
} })), l = await this.runtime.runPromise(c);
|
|
714
783
|
if (l.length === 0) return 0;
|
|
715
|
-
let u =
|
|
784
|
+
let u = S(l, e, this.variant);
|
|
716
785
|
for (let t of u) await this.routeEvent({
|
|
717
786
|
table: e,
|
|
718
787
|
op: "delete",
|
|
@@ -721,17 +790,17 @@ var N = (n) => e.layerConfig({
|
|
|
721
790
|
}, null, null);
|
|
722
791
|
return u.length;
|
|
723
792
|
} finally {
|
|
724
|
-
this.inflightTxns--, this.changeStrategy === "cdc" &&
|
|
793
|
+
this.inflightTxns--, this.changeStrategy === "cdc" && w(e);
|
|
725
794
|
}
|
|
726
795
|
}
|
|
727
796
|
emitChange(e) {
|
|
728
|
-
|
|
797
|
+
D(e.table) && (this.changeStrategy === "cdc" && !this.cdcGate.admit(e) || this.emitter.emit("change", e));
|
|
729
798
|
}
|
|
730
799
|
async startCdcConsumer(e) {
|
|
731
800
|
if (this.cdcHandle) return;
|
|
732
801
|
await this.assertBinlogConfig(), this.cdcReplicaId = e.replicaId;
|
|
733
802
|
let t = await this.readCdcOffset(e.replicaId) ?? await this.resolveBinlogEnd(), n = await this.findUndecodableCdcTables(e.includeTables);
|
|
734
|
-
for (let e of n) this.log.error(
|
|
803
|
+
for (let e of n) this.log.error(G(e));
|
|
735
804
|
this.cdcHandle = await q({
|
|
736
805
|
connection: e.connection,
|
|
737
806
|
serverId: e.serverId,
|
|
@@ -784,7 +853,7 @@ var N = (n) => e.layerConfig({
|
|
|
784
853
|
try {
|
|
785
854
|
let t = this.sql, n = (await this.runtime.runPromise(t`
|
|
786
855
|
SELECT ${t("binlogFile")}, ${t("binlogPosition")}
|
|
787
|
-
FROM ${t(
|
|
856
|
+
FROM ${t(c)}
|
|
788
857
|
WHERE ${t("id")} = ${e} LIMIT 1`))[0];
|
|
789
858
|
if (!n) return null;
|
|
790
859
|
let r = Number(n.binlogPosition);
|
|
@@ -806,7 +875,7 @@ var N = (n) => e.layerConfig({
|
|
|
806
875
|
this.cdcPendingPosition = null;
|
|
807
876
|
try {
|
|
808
877
|
let t = this.sql, n = this.cdcReplicaId;
|
|
809
|
-
await this.runtime.runPromise(t`INSERT INTO ${t(
|
|
878
|
+
await this.runtime.runPromise(t`INSERT INTO ${t(c)} ${t.insert({
|
|
810
879
|
id: n,
|
|
811
880
|
replicaId: n,
|
|
812
881
|
streamName: this.cdcStreamName,
|
|
@@ -849,31 +918,32 @@ var N = (n) => e.layerConfig({
|
|
|
849
918
|
}
|
|
850
919
|
async transactional(e) {
|
|
851
920
|
this.inflightTxns++;
|
|
852
|
-
let t = C(), r = me(), i = 0, o = n.suspend(() => {
|
|
853
|
-
let o = ++i;
|
|
854
|
-
return this.sql.withTransaction(n.flatMap(n.serviceOption(d), (i) => {
|
|
855
|
-
if (a.isNone(i)) return n.fail(/* @__PURE__ */ Error("MysqlStore.transactional: TransactionConnection missing."));
|
|
856
|
-
let s = new ge(this, i.value, t);
|
|
857
|
-
return n.tryPromise({
|
|
858
|
-
try: () => r(() => e(s)).then((e) => ({
|
|
859
|
-
result: e,
|
|
860
|
-
view: s,
|
|
861
|
-
attempt: o
|
|
862
|
-
})),
|
|
863
|
-
catch: (e) => e
|
|
864
|
-
});
|
|
865
|
-
}));
|
|
866
|
-
}), c = s.exponential("10 millis").pipe(s.compose(s.recurs(3)), s.whileInput(J)), l = o.pipe(n.retry(c), n.withSpan("store.transactional", { attributes: {
|
|
867
|
-
"db.system": this.variant,
|
|
868
|
-
"db.operation": "transaction"
|
|
869
|
-
} }));
|
|
870
921
|
try {
|
|
871
|
-
|
|
872
|
-
|
|
922
|
+
return await j({
|
|
923
|
+
...this.txnSpec("MysqlStore.transactional"),
|
|
924
|
+
work: e,
|
|
925
|
+
makeView: (e, t) => new we(this, e, t)
|
|
926
|
+
});
|
|
873
927
|
} finally {
|
|
874
928
|
this.inflightTxns--;
|
|
875
929
|
}
|
|
876
930
|
}
|
|
931
|
+
txnSpec(e) {
|
|
932
|
+
return {
|
|
933
|
+
label: e,
|
|
934
|
+
dialect: this.variant === "mariadb" ? "mariadb" : "mysql",
|
|
935
|
+
withTransaction: (e) => this.sql.withTransaction(e),
|
|
936
|
+
runPromiseExit: (e) => this.runtime.runPromiseExit(e),
|
|
937
|
+
isRetryable: J,
|
|
938
|
+
span: {
|
|
939
|
+
name: "store.transactional",
|
|
940
|
+
attributes: {
|
|
941
|
+
"db.system": this.variant,
|
|
942
|
+
"db.operation": "transaction"
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
};
|
|
946
|
+
}
|
|
877
947
|
onChange(e) {
|
|
878
948
|
return this.emitter.on("change", e), () => {
|
|
879
949
|
this.emitter.off("change", e);
|
|
@@ -883,14 +953,10 @@ var N = (n) => e.layerConfig({
|
|
|
883
953
|
return this.changeStrategy === "cdc" ? "fleet" : "local";
|
|
884
954
|
}
|
|
885
955
|
injectExternalChange(e) {
|
|
886
|
-
if (this.changeStrategy === "cdc" && !this.cdcGate.admit(e) || !
|
|
956
|
+
if (this.changeStrategy === "cdc" && !this.cdcGate.admit(e) || !D(e.table)) return;
|
|
887
957
|
let t = (e.op === "delete" ? e.old : e.new)?.id;
|
|
888
958
|
A(e.table, e.op, t, (t) => {
|
|
889
|
-
this.emitter.emit("change",
|
|
890
|
-
...t,
|
|
891
|
-
...e,
|
|
892
|
-
origin: "injected"
|
|
893
|
-
});
|
|
959
|
+
this.emitter.emit("change", T(e, t));
|
|
894
960
|
});
|
|
895
961
|
}
|
|
896
962
|
run(e) {
|
|
@@ -914,7 +980,7 @@ var N = (n) => e.layerConfig({
|
|
|
914
980
|
async ping() {
|
|
915
981
|
await this.runtime.runPromise(this.sql`SELECT 1`);
|
|
916
982
|
}
|
|
917
|
-
},
|
|
983
|
+
}, we = class {
|
|
918
984
|
parent;
|
|
919
985
|
txn;
|
|
920
986
|
attr;
|
|
@@ -987,12 +1053,12 @@ var N = (n) => e.layerConfig({
|
|
|
987
1053
|
this.events.length = 0;
|
|
988
1054
|
}
|
|
989
1055
|
}
|
|
990
|
-
}, $ = (e) => e.__mysqlReplicationFriend ?? null,
|
|
1056
|
+
}, $ = (e) => e.__mysqlReplicationFriend ?? null, Te = () => ({
|
|
991
1057
|
async capturePrimaryPosition(e) {
|
|
992
1058
|
let t = $(e);
|
|
993
1059
|
if (t === null) throw Error("mysqlReplicationAdapter: primary is not a MysqlStore (missing __mysqlReplicationFriend).");
|
|
994
1060
|
return t.runEffect(n.gen(function* () {
|
|
995
|
-
let e = yield*
|
|
1061
|
+
let e = yield* F, r = (t.variant === "mariadb" ? yield* e`SELECT @@global.gtid_current_pos AS gtid` : yield* e`SELECT @@global.gtid_executed AS gtid`)[0]?.gtid;
|
|
996
1062
|
return typeof r == "string" ? r : yield* n.die("mysql/mariadb did not return a GTID set");
|
|
997
1063
|
}));
|
|
998
1064
|
},
|
|
@@ -1000,25 +1066,25 @@ var N = (n) => e.layerConfig({
|
|
|
1000
1066
|
let t = $(e);
|
|
1001
1067
|
if (t === null) throw Error("mysqlReplicationAdapter: replica is not a MysqlStore.");
|
|
1002
1068
|
return t.runEffect(n.gen(function* () {
|
|
1003
|
-
let e = yield*
|
|
1069
|
+
let e = yield* F, r = (t.variant === "mariadb" ? yield* e`SELECT @@global.gtid_current_pos AS gtid` : yield* e`SELECT @@global.gtid_executed AS gtid`)[0]?.gtid;
|
|
1004
1070
|
return typeof r == "string" ? r : yield* n.die("mysql/mariadb replica did not return a GTID set");
|
|
1005
1071
|
}));
|
|
1006
1072
|
},
|
|
1007
1073
|
compare(e, t) {
|
|
1008
1074
|
return "behind";
|
|
1009
1075
|
}
|
|
1010
|
-
}),
|
|
1076
|
+
}), Ee = {
|
|
1011
1077
|
id: "mysql",
|
|
1012
|
-
makeSqlLayer: (e) =>
|
|
1078
|
+
makeSqlLayer: (e) => H(e),
|
|
1013
1079
|
makeStore: (e) => Q({
|
|
1014
1080
|
...e,
|
|
1015
1081
|
variant: "mysql"
|
|
1016
1082
|
}),
|
|
1017
1083
|
compileContains: (e, t, n) => n`${e} LIKE ${`%${t.replace(/[\\%_]/g, (e) => `\\${e}`)}%`} ESCAPE '\\'`,
|
|
1018
1084
|
retryFilter: Y
|
|
1019
|
-
},
|
|
1085
|
+
}, De = {
|
|
1020
1086
|
id: "mariadb",
|
|
1021
|
-
makeSqlLayer: (e) =>
|
|
1087
|
+
makeSqlLayer: (e) => H(e),
|
|
1022
1088
|
makeStore: (e) => Q({
|
|
1023
1089
|
...e,
|
|
1024
1090
|
variant: "mariadb"
|
|
@@ -1027,4 +1093,4 @@ var N = (n) => e.layerConfig({
|
|
|
1027
1093
|
retryFilter: Y
|
|
1028
1094
|
};
|
|
1029
1095
|
//#endregion
|
|
1030
|
-
export {
|
|
1096
|
+
export { c as CDC_OFFSETS_TABLE, e as MysqlClient, d as _voltroCdcOffsetsTable, V as connectionFromConfig, z as makeMysqlSqlLayer, H as makeMysqlSqlLayerFromConfig, Q as makeMysqlStore, De as mariadbDialect, Ee as mysqlDialect, Te as mysqlReplicationAdapter, Y as mysqlRetryFilter, q as startBinlogCdc };
|