@prisma/orm-target-mysql 8.0.0-rc.23-dev.7 → 8.0.0-rc.23-dev.8
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/adapter-D0qXT1lj.d.mts +57 -0
- package/dist/adapter-D0qXT1lj.d.mts.map +1 -0
- package/dist/adapter.d.mts +6 -6
- package/dist/adapter.mjs +3 -3
- package/dist/adapter__adapter.d.mts +2 -2
- package/dist/adapter__adapter.mjs +2 -2
- package/dist/adapter__codec-types.d.mts +2 -2
- package/dist/adapter__control.d.mts +2 -2
- package/dist/adapter__control.mjs +2 -2
- package/dist/adapter__runtime.d.mts +1 -1
- package/dist/adapter__runtime.mjs +9 -9
- package/dist/adapter__runtime.mjs.map +1 -1
- package/dist/{codec-descriptor-3xp1XvVH-yVLnNzZ8.mjs → codec-descriptor-3xp1XvVH-DfPKpYeP.mjs} +2 -2
- package/dist/codec-descriptor-3xp1XvVH-DfPKpYeP.mjs.map +1 -0
- package/dist/codec-descriptor-BRcKIX3h.d.mts +2 -0
- package/dist/{codec-descriptor-DXyubAS6-siA0R8Ow.d.mts → codec-descriptor-DXyubAS6-XDBj6Yet.d.mts} +2 -2
- package/dist/codec-descriptor-DXyubAS6-XDBj6Yet.d.mts.map +1 -0
- package/dist/codec-descriptor-J3TP08l8-BmdgkIU6.d.mts +1 -0
- package/dist/{codec-ids-CrR9Xi7r-CarpqbNM.mjs → codec-ids-CrR9Xi7r-CjbGCS3o.mjs} +2 -2
- package/dist/codec-ids-CrR9Xi7r-CjbGCS3o.mjs.map +1 -0
- package/dist/{codec-ids-Dgh5IpML-76oBMuwK.d.mts → codec-ids-Dgh5IpML-DGXIq6j8.d.mts} +2 -2
- package/dist/codec-ids-Dgh5IpML-DGXIq6j8.d.mts.map +1 -0
- package/dist/codec-types-BS-lWfda.d.mts +1 -0
- package/dist/{codec-types-Bai_CFkk-Blx2GxCH.d.mts → codec-types-Bai_CFkk-DmZ74URd.d.mts} +5 -5
- package/dist/codec-types-Bai_CFkk-DmZ74URd.d.mts.map +1 -0
- package/dist/codec-types-Dk2h5dBB.d.mts +1 -0
- package/dist/{codecs-BMidk26M-DsKq6wt5.d.mts → codecs-BMidk26M-B_iWNti6.d.mts} +5 -5
- package/dist/codecs-BMidk26M-B_iWNti6.d.mts.map +1 -0
- package/dist/{codecs-C_twedMx.d.mts → codecs-CIJRyUd3.d.mts} +4 -4
- package/dist/codecs-CIJRyUd3.d.mts.map +1 -0
- package/dist/{codecs-BfiB79-5.mjs → codecs-wVJlFapM.mjs} +7 -7
- package/dist/codecs-wVJlFapM.mjs.map +1 -0
- package/dist/{contract-free-Cw9Mjcro.d.mts → contract-free-BnJBWENn.d.mts} +3 -3
- package/dist/contract-free-BnJBWENn.d.mts.map +1 -0
- package/dist/{contract-free-BvCdx_Ee.mjs → contract-free-DekbHRyr.mjs} +4 -4
- package/dist/contract-free-DekbHRyr.mjs.map +1 -0
- package/dist/control-BBuy6yt5.mjs +73 -0
- package/dist/control-BBuy6yt5.mjs.map +1 -0
- package/dist/control-BiZaCqna.mjs +89 -0
- package/dist/control-BiZaCqna.mjs.map +1 -0
- package/dist/{control-BBhWaGnH.mjs → control-CyGJDPay.mjs} +102 -77
- package/dist/control-CyGJDPay.mjs.map +1 -0
- package/dist/control-D7_IpeiU.d.mts +31 -0
- package/dist/control-D7_IpeiU.d.mts.map +1 -0
- package/dist/{control-BvSM7mGR.d.mts → control-Dj8nIA1M.d.mts} +13 -4
- package/dist/control-Dj8nIA1M.d.mts.map +1 -0
- package/dist/{control-MoPFgSaQ.d.mts → control-WNuLF2Wh.d.mts} +29 -56
- package/dist/control-WNuLF2Wh.d.mts.map +1 -0
- package/dist/{control-tables-CHw2F-rg.d.mts → control-tables-CWJyQ3dZ.d.mts} +2 -2
- package/dist/control-tables-CWJyQ3dZ.d.mts.map +1 -0
- package/dist/{control-tables-CcQ77JE7-CxTQYoQJ.mjs → control-tables-CcQ77JE7-DKb3ubVU.mjs} +2 -2
- package/dist/control-tables-CcQ77JE7-DKb3ubVU.mjs.map +1 -0
- package/dist/{data-type-entries-C7VH2IHc-D1d5I8zF.mjs → data-type-entries-C7VH2IHc-DM6TbTaz.mjs} +3 -3
- package/dist/data-type-entries-C7VH2IHc-DM6TbTaz.mjs.map +1 -0
- package/dist/{data-types-C-rfxpgB.d.mts → data-types-65iVc7q1.d.mts} +3 -3
- package/dist/data-types-65iVc7q1.d.mts.map +1 -0
- package/dist/{data-types-D2HAT-Qf-CRI506c0.d.mts → data-types-D2HAT-Qf-CSdDz1Pk.d.mts} +2 -2
- package/dist/data-types-D2HAT-Qf-CSdDz1Pk.d.mts.map +1 -0
- package/dist/{data-types-DOaaPS93-DBkMJyh1.mjs → data-types-DOaaPS93-lycGybNk.mjs} +4 -4
- package/dist/data-types-DOaaPS93-lycGybNk.mjs.map +1 -0
- package/dist/{date-time-now-generators-DY-8Bodc-DcQ3h4Fg.mjs → date-time-now-generators-DY-8Bodc-DpQ5Se1u.mjs} +4 -4
- package/dist/date-time-now-generators-DY-8Bodc-DpQ5Se1u.mjs.map +1 -0
- package/dist/ddl-Bobm-S7I.d.mts +1 -0
- package/dist/{ddl-DDmMHyA_-Bb8sXoS0.mjs → ddl-DDmMHyA_-grdUmU3J.mjs} +3 -3
- package/dist/ddl-DDmMHyA_-grdUmU3J.mjs.map +1 -0
- package/dist/{default-normalizer-C8pc7SbL-CKgOEnGl.mjs → default-normalizer-C8pc7SbL-BXd70q02.mjs} +3 -3
- package/dist/default-normalizer-C8pc7SbL-BXd70q02.mjs.map +1 -0
- package/dist/{default-normalizer-CGIwQiKB.d.mts → default-normalizer-D-8Ii0df.d.mts} +2 -2
- package/dist/default-normalizer-D-8Ii0df.d.mts.map +1 -0
- package/dist/{descriptor-meta-CsMPRsxp-DhK87vlc.mjs → descriptor-meta-CsMPRsxp-QVV7vNY8.mjs} +6 -6
- package/dist/descriptor-meta-CsMPRsxp-QVV7vNY8.mjs.map +1 -0
- package/dist/descriptor-meta-pVdZBI-g-BJN4T_on.mjs +32 -0
- package/dist/descriptor-meta-pVdZBI-g-BJN4T_on.mjs.map +1 -0
- package/dist/driver.d.mts +3 -3
- package/dist/driver.mjs +3 -2
- package/dist/driver__control.d.mts +2 -2
- package/dist/driver__control.mjs +2 -2
- package/dist/driver__runtime.d.mts +2 -2
- package/dist/driver__runtime.mjs +2 -564
- package/dist/{errors-Cng94tYg-D02Eud2d.mjs → errors-Cng94tYg-DTH51xWG.mjs} +2 -2
- package/dist/errors-Cng94tYg-DTH51xWG.mjs.map +1 -0
- package/dist/{errors-DfrC_yfG.d.mts → errors-DjCkC9IM.d.mts} +2 -2
- package/dist/errors-DjCkC9IM.d.mts.map +1 -0
- package/dist/{marker-lock-Bwew7cAs-CZ20Y_tA.mjs → marker-lock-Bwew7cAs-ElLxlCQp.mjs} +3 -3
- package/dist/marker-lock-Bwew7cAs-ElLxlCQp.mjs.map +1 -0
- package/dist/{marker-lock-su6IxinO.d.mts → marker-lock-Px2qK06F.d.mts} +2 -2
- package/dist/marker-lock-Px2qK06F.d.mts.map +1 -0
- package/dist/{marker-read-Cf80LSbG-CUp3v1e5.mjs → marker-read-D1hp62hF-3-4fEgDD.mjs} +6 -23
- package/dist/marker-read-D1hp62hF-3-4fEgDD.mjs.map +1 -0
- package/dist/{migration-DmlblTTw.d.mts → migration-DILkj7kB.d.mts} +41 -29
- package/dist/migration-DILkj7kB.d.mts.map +1 -0
- package/dist/{mysql-contract-serializer-BnTKRSsN-B2O3EreV.mjs → mysql-contract-serializer-BnTKRSsN-BnV7fdYd.mjs} +4 -4
- package/dist/mysql-contract-serializer-BnTKRSsN-BnV7fdYd.mjs.map +1 -0
- package/dist/{mysql-database-CHl9-oSL-CWZLDXt6.mjs → mysql-database-CHl9-oSL-B1arvq6Q.mjs} +5 -5
- package/dist/mysql-database-CHl9-oSL-B1arvq6Q.mjs.map +1 -0
- package/dist/{nodes-CvcX47ot-B-ZaUYRj.mjs → nodes-CvcX47ot-CcCy0Oh4.mjs} +2 -2
- package/dist/nodes-CvcX47ot-CcCy0Oh4.mjs.map +1 -0
- package/dist/{nodes-xc0cR0_c-2YbhgEjb.d.mts → nodes-xc0cR0_c-CLET35o0.d.mts} +2 -2
- package/dist/nodes-xc0cR0_c-CLET35o0.d.mts.map +1 -0
- package/dist/{now-expression-DVD18CUc-00buJUto.mjs → now-expression-DVD18CUc-DJqdZY96.mjs} +3 -3
- package/dist/now-expression-DVD18CUc-DJqdZY96.mjs.map +1 -0
- package/dist/{pack-BXvLVBWP.d.mts → pack-COnjX17N.d.mts} +6 -6
- package/dist/pack-COnjX17N.d.mts.map +1 -0
- package/dist/{planner-target-details-D6g2uSp--C5NKHmCc.d.mts → planner-target-details-D6g2uSp--6VJKSGxe.d.mts} +2 -2
- package/dist/planner-target-details-D6g2uSp--6VJKSGxe.d.mts.map +1 -0
- package/dist/{require-temporal-DeDQhbTn-Bxc65WbA.mjs → require-temporal-DeDQhbTn-CdpjEWCB.mjs} +3 -3
- package/dist/require-temporal-DeDQhbTn-CdpjEWCB.mjs.map +1 -0
- package/dist/{runner-C39AEe6--BVG3xPYw.mjs → runner-BIjAWX-E-BgTmrD8f.mjs} +146 -124
- package/dist/runner-BIjAWX-E-BgTmrD8f.mjs.map +1 -0
- package/dist/runtime-BGF0cSIt.mjs +569 -0
- package/dist/runtime-BGF0cSIt.mjs.map +1 -0
- package/dist/{runtime-ClRDfPiY.d.mts → runtime-Cm-T3hbP.d.mts} +4 -4
- package/dist/runtime-Cm-T3hbP.d.mts.map +1 -0
- package/dist/{runtime-BGyTXcQH.d.mts → runtime-DN20lWEg.d.mts} +7 -5
- package/dist/runtime-DN20lWEg.d.mts.map +1 -0
- package/dist/{runtime-CrB5DXx4.d.mts → runtime-sPIp-JgC.d.mts} +2 -2
- package/dist/runtime-sPIp-JgC.d.mts.map +1 -0
- package/dist/{sql-utils-bD4SfgX0.mjs → sql-utils-BE8tDXHs.mjs} +3 -3
- package/dist/sql-utils-BE8tDXHs.mjs.map +1 -0
- package/dist/{sql-utils-Cmv_TVa8-BetrIUcj.mjs → sql-utils-Cmv_TVa8-CNW3UmfQ.mjs} +3 -3
- package/dist/sql-utils-Cmv_TVa8-CNW3UmfQ.mjs.map +1 -0
- package/dist/{sql-utils-BOS1c2QT.d.mts → sql-utils-DBvre8Ar.d.mts} +2 -2
- package/dist/sql-utils-DBvre8Ar.d.mts.map +1 -0
- package/dist/{statement-DC62oiSx-Buzptbpk.mjs → statement-CT5tB4uX-CHqHFM3z.mjs} +17 -14
- package/dist/statement-CT5tB4uX-CHqHFM3z.mjs.map +1 -0
- package/dist/target.d.mts +24 -24
- package/dist/target.mjs +22 -21
- package/dist/target__codec-descriptor.d.mts +2 -2
- package/dist/target__codec-descriptor.mjs +1 -1
- package/dist/target__codec-ids.d.mts +1 -1
- package/dist/target__codec-ids.mjs +1 -1
- package/dist/target__codec-types.d.mts +2 -2
- package/dist/target__codecs.d.mts +2 -2
- package/dist/target__codecs.mjs +2 -2
- package/dist/target__contract-free.d.mts +1 -1
- package/dist/target__contract-free.mjs +2 -2
- package/dist/target__control-tables.d.mts +1 -1
- package/dist/target__control-tables.mjs +1 -1
- package/dist/target__control.d.mts +3 -3
- package/dist/target__control.mjs +3 -64
- package/dist/target__data-types.d.mts +2 -2
- package/dist/target__data-types.mjs +2 -2
- package/dist/target__ddl.d.mts +2 -2
- package/dist/target__ddl.mjs +1 -1
- package/dist/target__default-normalizer.d.mts +1 -1
- package/dist/target__default-normalizer.mjs +1 -1
- package/dist/target__errors.d.mts +1 -1
- package/dist/target__errors.mjs +1 -1
- package/dist/target__marker-lock.d.mts +1 -1
- package/dist/target__marker-lock.mjs +1 -1
- package/dist/target__migration.d.mts +2 -2
- package/dist/target__migration.mjs +2 -2
- package/dist/target__pack.d.mts +1 -1
- package/dist/target__pack.mjs +1 -1
- package/dist/target__runtime.d.mts +1 -1
- package/dist/target__runtime.mjs +3 -3
- package/dist/target__runtime.mjs.map +1 -1
- package/dist/target__sql-utils.d.mts +1 -1
- package/dist/target__sql-utils.mjs +2 -2
- package/dist/target__types.d.mts +1 -1
- package/dist/target__types.mjs +1 -1
- package/dist/{types-CgrFHUdk.d.mts → types-gXYDzQXs.d.mts} +2 -2
- package/dist/types-gXYDzQXs.d.mts.map +1 -0
- package/package.json +10 -10
- package/dist/adapter-Dl4Wwz1I.d.mts +0 -29
- package/dist/adapter-Dl4Wwz1I.d.mts.map +0 -1
- package/dist/codec-descriptor-3xp1XvVH-yVLnNzZ8.mjs.map +0 -1
- package/dist/codec-descriptor-DXyubAS6-siA0R8Ow.d.mts.map +0 -1
- package/dist/codec-descriptor-J3TP08l8-ekLvUVxW.d.mts +0 -1
- package/dist/codec-descriptor-oLRh9E29.d.mts +0 -2
- package/dist/codec-ids-CrR9Xi7r-CarpqbNM.mjs.map +0 -1
- package/dist/codec-ids-Dgh5IpML-76oBMuwK.d.mts.map +0 -1
- package/dist/codec-types-BH5moCD9.d.mts +0 -1
- package/dist/codec-types-Bai_CFkk-Blx2GxCH.d.mts.map +0 -1
- package/dist/codec-types-zzVcrnbk.d.mts +0 -1
- package/dist/codecs-BMidk26M-DsKq6wt5.d.mts.map +0 -1
- package/dist/codecs-BfiB79-5.mjs.map +0 -1
- package/dist/codecs-C_twedMx.d.mts.map +0 -1
- package/dist/contract-contributions-ChiX6W0F-CAng98bZ.mjs +0 -15
- package/dist/contract-contributions-ChiX6W0F-CAng98bZ.mjs.map +0 -1
- package/dist/contract-free-BvCdx_Ee.mjs.map +0 -1
- package/dist/contract-free-Cw9Mjcro.d.mts.map +0 -1
- package/dist/control-5eVF1TXc.mjs +0 -74
- package/dist/control-5eVF1TXc.mjs.map +0 -1
- package/dist/control-BBhWaGnH.mjs.map +0 -1
- package/dist/control-BvSM7mGR.d.mts.map +0 -1
- package/dist/control-DHkZbo58.d.mts +0 -25
- package/dist/control-DHkZbo58.d.mts.map +0 -1
- package/dist/control-MoPFgSaQ.d.mts.map +0 -1
- package/dist/control-tables-CHw2F-rg.d.mts.map +0 -1
- package/dist/control-tables-CcQ77JE7-CxTQYoQJ.mjs.map +0 -1
- package/dist/data-type-entries-C7VH2IHc-D1d5I8zF.mjs.map +0 -1
- package/dist/data-types-C-rfxpgB.d.mts.map +0 -1
- package/dist/data-types-D2HAT-Qf-CRI506c0.d.mts.map +0 -1
- package/dist/data-types-DOaaPS93-DBkMJyh1.mjs.map +0 -1
- package/dist/date-time-now-generators-DY-8Bodc-DcQ3h4Fg.mjs.map +0 -1
- package/dist/ddl-CT6DPEqg.d.mts +0 -1
- package/dist/ddl-DDmMHyA_-Bb8sXoS0.mjs.map +0 -1
- package/dist/default-normalizer-C8pc7SbL-CKgOEnGl.mjs.map +0 -1
- package/dist/default-normalizer-CGIwQiKB.d.mts.map +0 -1
- package/dist/descriptor-meta-CsMPRsxp-DhK87vlc.mjs.map +0 -1
- package/dist/driver__runtime.mjs.map +0 -1
- package/dist/errors-Cng94tYg-D02Eud2d.mjs.map +0 -1
- package/dist/errors-DfrC_yfG.d.mts.map +0 -1
- package/dist/marker-lock-Bwew7cAs-CZ20Y_tA.mjs.map +0 -1
- package/dist/marker-lock-su6IxinO.d.mts.map +0 -1
- package/dist/marker-read-Cf80LSbG-CUp3v1e5.mjs.map +0 -1
- package/dist/migration-DmlblTTw.d.mts.map +0 -1
- package/dist/mysql-contract-serializer-BnTKRSsN-B2O3EreV.mjs.map +0 -1
- package/dist/mysql-database-CHl9-oSL-CWZLDXt6.mjs.map +0 -1
- package/dist/nodes-CvcX47ot-B-ZaUYRj.mjs.map +0 -1
- package/dist/nodes-xc0cR0_c-2YbhgEjb.d.mts.map +0 -1
- package/dist/now-expression-DVD18CUc-00buJUto.mjs.map +0 -1
- package/dist/pack-BXvLVBWP.d.mts.map +0 -1
- package/dist/planner-target-details-D6g2uSp--C5NKHmCc.d.mts.map +0 -1
- package/dist/require-temporal-DeDQhbTn-Bxc65WbA.mjs.map +0 -1
- package/dist/runner-C39AEe6--BVG3xPYw.mjs.map +0 -1
- package/dist/runtime-BGyTXcQH.d.mts.map +0 -1
- package/dist/runtime-ClRDfPiY.d.mts.map +0 -1
- package/dist/runtime-CrB5DXx4.d.mts.map +0 -1
- package/dist/sql-utils-BOS1c2QT.d.mts.map +0 -1
- package/dist/sql-utils-Cmv_TVa8-BetrIUcj.mjs.map +0 -1
- package/dist/sql-utils-bD4SfgX0.mjs.map +0 -1
- package/dist/statement-DC62oiSx-Buzptbpk.mjs.map +0 -1
- package/dist/target__control.mjs.map +0 -1
- package/dist/types-CgrFHUdk.d.mts.map +0 -1
|
@@ -0,0 +1,569 @@
|
|
|
1
|
+
import { c as mysqlConnectionOptions, d as mysqlPoolOptions, f as normalizeMysqlError, i as connectingCannotSucceed, l as mysqlDriverDescriptorMetaFor, m as statementFor, n as acquireClientQueryLock, s as isFatal, t as SessionSettingsGuard, u as mysqlPoolIdleTimeoutMillis } from "./statement-CT5tB4uX-CHqHFM3z.mjs";
|
|
2
|
+
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
3
|
+
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
4
|
+
import { errorRuntime } from "@prisma/orm-framework/errors/execution";
|
|
5
|
+
import { createConnection, createPool } from "mariadb";
|
|
6
|
+
import { EventEmitter } from "node:events";
|
|
7
|
+
import { finished } from "node:stream/promises";
|
|
8
|
+
//#region ../../../3-targets/mysql/1-mysql/3-driver/dist/runtime.mjs
|
|
9
|
+
/** How long the canceller waits to open its connection, and for MySQL to answer a `KILL QUERY`. */
|
|
10
|
+
const CANCEL_TIMEOUT_MILLIS = 2e3;
|
|
11
|
+
function timeout(millis) {
|
|
12
|
+
let timer;
|
|
13
|
+
return {
|
|
14
|
+
expired: new Promise((resolve) => {
|
|
15
|
+
timer = setTimeout(() => resolve("expired"), millis);
|
|
16
|
+
}),
|
|
17
|
+
clear: () => clearTimeout(timer)
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Cancels statements with `KILL QUERY`, which MySQL takes only from another connection. It keeps one connection of its own, outside the pool, so a cancel neither waits for a pooled connection nor normally opens one; it opens it on first need, and ends it once it has been idle for the pool's idle timeout, as the pool ends its own; with a timeout of 0 it keeps it open, as the pool keeps its own. Opening it and each `KILL QUERY` are bounded by two seconds. The connection is never destroyed: the package's `destroy()` sends a `KILL` of its own whose failure it does not handle (`mariadb` 3.5.4). A connection that stops answering is set aside and ended with `end()` once its statement settles.
|
|
22
|
+
*/
|
|
23
|
+
var Canceller = class {
|
|
24
|
+
#url;
|
|
25
|
+
#idleTimeoutMillis;
|
|
26
|
+
#connection;
|
|
27
|
+
#pending = /* @__PURE__ */ new WeakMap();
|
|
28
|
+
#closed = false;
|
|
29
|
+
#idleTimer;
|
|
30
|
+
constructor(url, idleTimeoutMillis) {
|
|
31
|
+
this.#url = url;
|
|
32
|
+
this.#idleTimeoutMillis = idleTimeoutMillis;
|
|
33
|
+
}
|
|
34
|
+
/** Sends `KILL QUERY` for `threadId`. Never rejects. A kept connection that is no longer valid is replaced once. */
|
|
35
|
+
async cancel(threadId, replaced = false) {
|
|
36
|
+
if (this.#closed || threadId === null) return "unsent";
|
|
37
|
+
clearTimeout(this.#idleTimer);
|
|
38
|
+
const opening = this.#connection ?? this.#open();
|
|
39
|
+
this.#connection = opening;
|
|
40
|
+
const connection = await opening;
|
|
41
|
+
if (connection === void 0) {
|
|
42
|
+
this.#setAside(opening);
|
|
43
|
+
return "unsent";
|
|
44
|
+
}
|
|
45
|
+
if (!connection.isValid()) {
|
|
46
|
+
this.#setAside(opening);
|
|
47
|
+
return replaced ? "unsent" : this.cancel(threadId, true);
|
|
48
|
+
}
|
|
49
|
+
this.#pending.set(connection, this.#pendingOn(connection) + 1);
|
|
50
|
+
const killing = connection.query("KILL QUERY ?", [threadId]).then(() => "sent", (error) => isFatal(error) ? "unconfirmed" : "unsent");
|
|
51
|
+
killing.then(() => {
|
|
52
|
+
this.#pending.set(connection, this.#pendingOn(connection) - 1);
|
|
53
|
+
this.#idleLater(opening, connection);
|
|
54
|
+
});
|
|
55
|
+
const limit = timeout(CANCEL_TIMEOUT_MILLIS);
|
|
56
|
+
const result = await Promise.race([killing, limit.expired]);
|
|
57
|
+
limit.clear();
|
|
58
|
+
if (result === "sent" || result === "unsent") return result;
|
|
59
|
+
this.#setAside(opening);
|
|
60
|
+
connection.end().catch(() => void 0);
|
|
61
|
+
return "unconfirmed";
|
|
62
|
+
}
|
|
63
|
+
/** Ends the connection: `end()` sends `QUIT` once any `KILL QUERY` on it settles. Waits for that only when no `KILL QUERY` is pending on it, so a connection that stopped answering cannot hold `close()` up. */
|
|
64
|
+
async close() {
|
|
65
|
+
this.#closed = true;
|
|
66
|
+
clearTimeout(this.#idleTimer);
|
|
67
|
+
const connection = await this.#connection;
|
|
68
|
+
this.#connection = void 0;
|
|
69
|
+
if (connection === void 0) return;
|
|
70
|
+
const ending = connection.end().catch(() => void 0);
|
|
71
|
+
if (this.#pendingOn(connection) === 0) await ending;
|
|
72
|
+
}
|
|
73
|
+
#idleLater(opening, connection) {
|
|
74
|
+
if (this.#idleTimeoutMillis === 0 || this.#pendingOn(connection) > 0 || this.#connection !== opening) return;
|
|
75
|
+
clearTimeout(this.#idleTimer);
|
|
76
|
+
this.#idleTimer = setTimeout(() => {
|
|
77
|
+
if (this.#pendingOn(connection) > 0 || this.#connection !== opening) return;
|
|
78
|
+
this.#connection = void 0;
|
|
79
|
+
connection.end().catch(() => void 0);
|
|
80
|
+
}, this.#idleTimeoutMillis);
|
|
81
|
+
this.#idleTimer.unref();
|
|
82
|
+
}
|
|
83
|
+
#pendingOn(connection) {
|
|
84
|
+
return this.#pending.get(connection) ?? 0;
|
|
85
|
+
}
|
|
86
|
+
#setAside(opening) {
|
|
87
|
+
if (this.#connection === opening) this.#connection = void 0;
|
|
88
|
+
}
|
|
89
|
+
async #open() {
|
|
90
|
+
try {
|
|
91
|
+
const connection = await createConnection(mysqlConnectionOptions(this.#url, { connectTimeoutMs: CANCEL_TIMEOUT_MILLIS }));
|
|
92
|
+
connection.on("error", () => void 0);
|
|
93
|
+
if (this.#closed) {
|
|
94
|
+
await connection.end().catch(() => void 0);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
return connection;
|
|
98
|
+
} catch {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
function notConnected(message) {
|
|
104
|
+
return errorRuntime("DRIVER.NOT_CONNECTED", message, { fix: "Call connect(binding) before running queries, and do not use the driver after close()." });
|
|
105
|
+
}
|
|
106
|
+
/** Runs `request` on `client` in one round trip and returns its result: its `?N` placeholders written as `?`, and its values handed to the package, which writes them into the statement. Throws the package's error as it is. */
|
|
107
|
+
async function run(client, request) {
|
|
108
|
+
const { sql, values } = statementFor(client, request.sql, request.params ?? []);
|
|
109
|
+
return client.query(sql, values);
|
|
110
|
+
}
|
|
111
|
+
/** Starts streaming the rows of `request` on `client`, sent as {@link run} sends it. Throws the error to report, after noting in `outcome` whether it left the client unusable. */
|
|
112
|
+
function startStream(client, request, outcome) {
|
|
113
|
+
try {
|
|
114
|
+
const { sql, values } = statementFor(client, request.sql, request.params ?? []);
|
|
115
|
+
return client.queryStream(sql, values);
|
|
116
|
+
} catch (error) {
|
|
117
|
+
throw settle(error, outcome);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/** What a statement's result reports: the rows it changed, and, when it changed one row, the value MySQL numbered for it. MySQL reports 0 when it numbered none. */
|
|
121
|
+
function statementStats(result) {
|
|
122
|
+
if (typeof result !== "object" || result === null) return { affectedRows: 0 };
|
|
123
|
+
const affectedRows = "affectedRows" in result && typeof result.affectedRows === "number" ? result.affectedRows : 0;
|
|
124
|
+
const insertId = "insertId" in result ? result.insertId : void 0;
|
|
125
|
+
return affectedRows === 1 && (typeof insertId === "bigint" || typeof insertId === "number") && insertId > 0 ? {
|
|
126
|
+
affectedRows,
|
|
127
|
+
insertId: String(insertId)
|
|
128
|
+
} : { affectedRows };
|
|
129
|
+
}
|
|
130
|
+
/** The error to report for `error`, after noting in `outcome` whether it left the client unusable. */
|
|
131
|
+
function settle(error, outcome) {
|
|
132
|
+
if (isFatal(error)) outcome.destroy = true;
|
|
133
|
+
return normalizeMysqlError(error);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Whether the package has received the end of the result, so that any rows the caller has not read are already in the stream's buffer. The package pushes the end of the stream when MySQL's last packet arrives; Node records that in `_readableState.ended`, and its public API reports the end only after the caller has read every row.
|
|
137
|
+
*/
|
|
138
|
+
function resultReceived(rows) {
|
|
139
|
+
const state = Reflect.get(rows, "_readableState");
|
|
140
|
+
return typeof state === "object" && state !== null && "ended" in state && state.ended === true;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Reads and drops what is left of a stream's result. The package's `close()` stops it keeping new rows; the rows already buffered are read here with `read()`, which works whether or not the caller's iterator is still attached to the stream, so an iterator the caller abandoned cannot hold the drain up.
|
|
144
|
+
*/
|
|
145
|
+
async function dropRest(rows) {
|
|
146
|
+
rows.close?.();
|
|
147
|
+
const drain = () => {
|
|
148
|
+
while (rows.read() !== null);
|
|
149
|
+
};
|
|
150
|
+
rows.on("readable", drain);
|
|
151
|
+
try {
|
|
152
|
+
drain();
|
|
153
|
+
await finished(rows);
|
|
154
|
+
} finally {
|
|
155
|
+
rows.off("readable", drain);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function cancelNotConfirmed() {
|
|
159
|
+
return errorRuntime("DRIVER.NOT_CONNECTED", "A cancel on this MySQL connection could not be confirmed, so the connection can no longer be used", {
|
|
160
|
+
why: "The driver cancelled a stream the caller stopped early, and MySQL did not answer the KILL QUERY in time. It may still arrive and would interrupt whatever statement the connection runs then.",
|
|
161
|
+
fix: "Release the connection, which closes it; MySQL rolls back an open transaction on it. Acquire another connection and run the work again."
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
function connectionReleased() {
|
|
165
|
+
return errorRuntime("DRIVER.NOT_CONNECTED", "MySQL connection was released", { fix: "Send statements on a connection only until you release it, and await each one before release()." });
|
|
166
|
+
}
|
|
167
|
+
/** The package can report an error on a stream after the caller stopped reading it, such as MySQL's for a statement the driver cancelled; the generator has already settled by then. */
|
|
168
|
+
function ignoreAfterStop() {}
|
|
169
|
+
/** MySQL's error for a statement `KILL QUERY` cancelled (`ER_QUERY_INTERRUPTED`). The package marks it fatal when it arrives in the middle of a result, but the connection stays usable. */
|
|
170
|
+
function isQueryInterrupted(error) {
|
|
171
|
+
return error instanceof Error && "errno" in error && error.errno === 1317;
|
|
172
|
+
}
|
|
173
|
+
var MysqlQueryable = class {
|
|
174
|
+
streams;
|
|
175
|
+
constructor(streams) {
|
|
176
|
+
this.streams = streams;
|
|
177
|
+
}
|
|
178
|
+
/** Records a stream that is open, and returns the call that records its end. */
|
|
179
|
+
streamOpened(_rows) {
|
|
180
|
+
return () => {};
|
|
181
|
+
}
|
|
182
|
+
/** Takes the client's lock, which keeps statements on it one at a time in the order sent. */
|
|
183
|
+
lockClient(client) {
|
|
184
|
+
return acquireClientQueryLock(client);
|
|
185
|
+
}
|
|
186
|
+
/** Runs one statement that is not a stream, under the client's lock. */
|
|
187
|
+
runStatement(work) {
|
|
188
|
+
return work();
|
|
189
|
+
}
|
|
190
|
+
/** Whether the client went back to the pool under this queryable, so it must send nothing more on it. */
|
|
191
|
+
get handedBack() {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
async *query(request) {
|
|
195
|
+
if (this.streams) {
|
|
196
|
+
yield* this.#streamRows(request);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const result = await this.#runReleasing(request);
|
|
200
|
+
for (const row of Array.isArray(result) ? result : []) yield blindCast(row);
|
|
201
|
+
}
|
|
202
|
+
async execute(request) {
|
|
203
|
+
return statementStats(await this.#runReleasing(request));
|
|
204
|
+
}
|
|
205
|
+
async #runReleasing(request) {
|
|
206
|
+
const client = await this.acquireClient();
|
|
207
|
+
const outcome = { destroy: false };
|
|
208
|
+
try {
|
|
209
|
+
const releaseLock = await this.lockClient(client);
|
|
210
|
+
try {
|
|
211
|
+
return await this.runStatement(() => run(client, request));
|
|
212
|
+
} finally {
|
|
213
|
+
releaseLock();
|
|
214
|
+
}
|
|
215
|
+
} catch (error) {
|
|
216
|
+
throw settle(error, outcome);
|
|
217
|
+
} finally {
|
|
218
|
+
await this.releaseClient(client, outcome);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Streams the rows of `request` as they arrive; the package pauses the socket while the caller is busy. A caller that stops reading early is handled by {@link MysqlQueryable.#stopEarly}. A fatal error, such as a lost connection, destroys the client.
|
|
223
|
+
*/
|
|
224
|
+
async *#streamRows(request) {
|
|
225
|
+
const client = await this.acquireClient();
|
|
226
|
+
const outcome = { destroy: false };
|
|
227
|
+
let releaseLock;
|
|
228
|
+
try {
|
|
229
|
+
releaseLock = await this.lockClient(client);
|
|
230
|
+
} catch (error) {
|
|
231
|
+
await this.releaseClient(client, outcome);
|
|
232
|
+
throw error;
|
|
233
|
+
}
|
|
234
|
+
try {
|
|
235
|
+
const rows = startStream(client, request, outcome);
|
|
236
|
+
rows.on("error", ignoreAfterStop);
|
|
237
|
+
const streamClosed = this.streamOpened(rows);
|
|
238
|
+
let settled = false;
|
|
239
|
+
try {
|
|
240
|
+
for await (const row of rows.iterator({ destroyOnReturn: false })) yield blindCast(row);
|
|
241
|
+
settled = true;
|
|
242
|
+
} catch (error) {
|
|
243
|
+
settled = true;
|
|
244
|
+
throw settle(error, outcome);
|
|
245
|
+
} finally {
|
|
246
|
+
if (!settled && !this.handedBack) await this.#stopEarly(client, rows, outcome);
|
|
247
|
+
if (outcome.destroy) rows.destroy();
|
|
248
|
+
streamClosed();
|
|
249
|
+
}
|
|
250
|
+
} finally {
|
|
251
|
+
releaseLock();
|
|
252
|
+
await this.releaseClient(client, outcome);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Ends a stream the caller stopped reading early, and keeps the client usable. While its result is still arriving, the statement is first cancelled with `KILL QUERY`, so a large result is not downloaded only to be thrown away; MySQL does not say how many rows remain. On a held connection or in a transaction, as on a pooled one: `KILL QUERY` ends only the statement, the session survives, and in a transaction MySQL rolls back only that statement. The rest of the result is then read and dropped, MySQL's error for the cancelled statement among it. The client is never destroyed while its statement runs: the package's `destroy()` would send `KILL` itself, on a connection whose failure it does not handle.
|
|
257
|
+
*/
|
|
258
|
+
async #stopEarly(client, rows, outcome) {
|
|
259
|
+
const cancel = resultReceived(rows) ? "unsent" : await this.cancelStatement(client.threadId);
|
|
260
|
+
await dropRest(rows).catch((error) => {
|
|
261
|
+
if (isFatal(error) && !(cancel !== "unsent" && isQueryInterrupted(error))) outcome.destroy = true;
|
|
262
|
+
});
|
|
263
|
+
if (cancel === "unconfirmed") this.cancelUnconfirmed(outcome);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* A cancel that went out without an answer may still reach MySQL and interrupt the next statement on the client, so the client must not serve another caller. Once its rest has been read, nothing is receiving on it, so closing it sends no `KILL` of the package's own; a late `KILL QUERY` then finds no thread.
|
|
267
|
+
*/
|
|
268
|
+
cancelUnconfirmed(outcome) {
|
|
269
|
+
outcome.destroy = true;
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
function handedBackState() {
|
|
273
|
+
let refuse = () => {};
|
|
274
|
+
const signal = new Promise((_, reject) => {
|
|
275
|
+
refuse = () => reject(connectionReleased());
|
|
276
|
+
});
|
|
277
|
+
signal.catch(() => void 0);
|
|
278
|
+
const state = {
|
|
279
|
+
done: false,
|
|
280
|
+
signal,
|
|
281
|
+
refuse: () => {
|
|
282
|
+
state.done = true;
|
|
283
|
+
refuse();
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
return state;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* A queryable on a connection the caller holds, whose statements all run on the same session, in the order they are sent, under the client's lock. A statement sent while a stream on the connection is open waits for that stream to end; one awaited inside the stream's own loop never finishes, as on Postgres with a cursor.
|
|
290
|
+
*/
|
|
291
|
+
var MysqlHeldQueryable = class extends MysqlQueryable {
|
|
292
|
+
client;
|
|
293
|
+
held;
|
|
294
|
+
holdsClient = true;
|
|
295
|
+
get cancelStatement() {
|
|
296
|
+
return this.held.cancel;
|
|
297
|
+
}
|
|
298
|
+
streamOpened(rows) {
|
|
299
|
+
this.held.streams.add(rows);
|
|
300
|
+
return () => this.held.streams.delete(rows);
|
|
301
|
+
}
|
|
302
|
+
get handedBack() {
|
|
303
|
+
return this.held.handedBack.done;
|
|
304
|
+
}
|
|
305
|
+
cancelUnconfirmed() {
|
|
306
|
+
this.held.cancelUnconfirmed = true;
|
|
307
|
+
}
|
|
308
|
+
/** Takes the client's lock, or fails once the connection is handed back, whether the statement was sent after that or was still waiting for the lock. A lock taken after that is given straight back. */
|
|
309
|
+
async lockClient(client) {
|
|
310
|
+
this.#refuseIfUnusable();
|
|
311
|
+
const locking = acquireClientQueryLock(client);
|
|
312
|
+
try {
|
|
313
|
+
const releaseLock = await Promise.race([locking, this.held.handedBack.signal]);
|
|
314
|
+
if (!this.held.handedBack.done && !this.held.cancelUnconfirmed) return releaseLock;
|
|
315
|
+
releaseLock();
|
|
316
|
+
} catch {
|
|
317
|
+
locking.then((releaseLock) => releaseLock());
|
|
318
|
+
}
|
|
319
|
+
this.#refuseIfUnusable();
|
|
320
|
+
throw connectionReleased();
|
|
321
|
+
}
|
|
322
|
+
/** Refuses a statement on a connection that was handed back, or whose cancel went out without an answer: a late `KILL QUERY` would interrupt it. */
|
|
323
|
+
#refuseIfUnusable() {
|
|
324
|
+
if (this.held.handedBack.done) throw connectionReleased();
|
|
325
|
+
if (this.held.cancelUnconfirmed) throw cancelNotConfirmed();
|
|
326
|
+
}
|
|
327
|
+
runStatement(work) {
|
|
328
|
+
const running = work();
|
|
329
|
+
this.held.running.add(running);
|
|
330
|
+
running.then(() => this.held.running.delete(running), () => this.held.running.delete(running));
|
|
331
|
+
return running;
|
|
332
|
+
}
|
|
333
|
+
constructor(client, held, streams) {
|
|
334
|
+
super(streams);
|
|
335
|
+
this.client = client;
|
|
336
|
+
this.held = held;
|
|
337
|
+
}
|
|
338
|
+
async acquireClient() {
|
|
339
|
+
this.#refuseIfUnusable();
|
|
340
|
+
return this.client;
|
|
341
|
+
}
|
|
342
|
+
async releaseClient() {}
|
|
343
|
+
/** Runs one of the package's transaction calls under the client's lock, taken as a statement takes it, so it keeps its place among the statements sent. */
|
|
344
|
+
async underLock(call) {
|
|
345
|
+
const client = await this.acquireClient();
|
|
346
|
+
const releaseLock = await this.lockClient(client);
|
|
347
|
+
try {
|
|
348
|
+
await this.runStatement(call);
|
|
349
|
+
} catch (error) {
|
|
350
|
+
throw normalizeMysqlError(error);
|
|
351
|
+
} finally {
|
|
352
|
+
releaseLock();
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
var MysqlConnectionImpl = class extends MysqlHeldQueryable {
|
|
357
|
+
#onRelease;
|
|
358
|
+
constructor(client, streams, cancel, onRelease) {
|
|
359
|
+
super(client, {
|
|
360
|
+
streams: /* @__PURE__ */ new Set(),
|
|
361
|
+
cancelUnconfirmed: false,
|
|
362
|
+
running: /* @__PURE__ */ new Set(),
|
|
363
|
+
cancel,
|
|
364
|
+
handedBack: handedBackState()
|
|
365
|
+
}, streams);
|
|
366
|
+
this.#onRelease = onRelease;
|
|
367
|
+
}
|
|
368
|
+
#released() {
|
|
369
|
+
const onRelease = this.#onRelease;
|
|
370
|
+
this.#onRelease = void 0;
|
|
371
|
+
onRelease?.();
|
|
372
|
+
}
|
|
373
|
+
async beginTransaction() {
|
|
374
|
+
await this.underLock(() => this.client.beginTransaction());
|
|
375
|
+
return new MysqlTransactionImpl(this.client, this.held, this.streams);
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Returns the connection to the pool, as the Postgres driver's `release()` does. From then on the connection refuses every statement, those still waiting for its lock included, so none runs later in another caller's session. A statement that is not a stream and is already running finishes, as on Postgres. A stream still open, such as one the caller dropped, is cancelled and read to its end by the driver: the package's release sends `ROLLBACK` behind that statement and waits for it, which would otherwise never finish, where `pg`'s release does not wait on the server.
|
|
379
|
+
*/
|
|
380
|
+
async release() {
|
|
381
|
+
if (this.held.handedBack.done) return;
|
|
382
|
+
this.held.handedBack.refuse();
|
|
383
|
+
try {
|
|
384
|
+
if (this.held.streams.size > 0) await this.#cancelRunning();
|
|
385
|
+
await this.#runningSettled();
|
|
386
|
+
if (this.held.cancelUnconfirmed) await this.#close();
|
|
387
|
+
else await this.client.release();
|
|
388
|
+
} finally {
|
|
389
|
+
this.#released();
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
/** Closes the connection instead of returning it. It refuses every statement from then on, cancels whatever still runs and waits for it to end, so the package's `destroy()` never sends a `KILL` of its own. */
|
|
393
|
+
async destroy(_reason) {
|
|
394
|
+
if (this.held.handedBack.done) return;
|
|
395
|
+
this.held.handedBack.refuse();
|
|
396
|
+
try {
|
|
397
|
+
if (this.held.streams.size > 0 || this.held.running.size > 0) await this.#cancelRunning();
|
|
398
|
+
await this.#runningSettled();
|
|
399
|
+
await this.#close();
|
|
400
|
+
} finally {
|
|
401
|
+
this.#released();
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
/** Closes the client once the `ping` queued behind anything left on it has answered, so nothing is receiving and the package's `destroy()` sends no `KILL` of its own. */
|
|
405
|
+
async #close() {
|
|
406
|
+
await this.client.ping().catch(() => void 0);
|
|
407
|
+
this.client.destroy();
|
|
408
|
+
}
|
|
409
|
+
async #cancelRunning() {
|
|
410
|
+
if (await this.held.cancel(this.client.threadId) === "unconfirmed") this.held.cancelUnconfirmed = true;
|
|
411
|
+
await Promise.all([...this.held.streams].map((rows) => dropRest(rows).catch(() => void 0)));
|
|
412
|
+
}
|
|
413
|
+
async #runningSettled() {
|
|
414
|
+
await Promise.allSettled([...this.held.running]);
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
var MysqlTransactionImpl = class extends MysqlHeldQueryable {
|
|
418
|
+
async commit() {
|
|
419
|
+
await this.underLock(() => this.client.commit());
|
|
420
|
+
}
|
|
421
|
+
async rollback() {
|
|
422
|
+
await this.underLock(() => this.client.rollback());
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
/** How many clients the driver has handed out and not had back, a held connection or one lent to a single statement, so `close()` can wait until every one is back. */
|
|
426
|
+
var ClientsInUse = class {
|
|
427
|
+
#count = 0;
|
|
428
|
+
#idle = [];
|
|
429
|
+
acquired() {
|
|
430
|
+
this.#count += 1;
|
|
431
|
+
}
|
|
432
|
+
released() {
|
|
433
|
+
this.#count -= 1;
|
|
434
|
+
if (this.#count === 0) for (const resolve of this.#idle.splice(0)) resolve();
|
|
435
|
+
}
|
|
436
|
+
none() {
|
|
437
|
+
return this.#count === 0 ? Promise.resolve() : new Promise((resolve) => this.#idle.push(resolve));
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
/** The pool reports a connection it failed to open on its `'error'` event, and again as the cause of a `getConnection` that times out; the driver reports it there. */
|
|
441
|
+
function ignoreConnectionFailure() {}
|
|
442
|
+
/**
|
|
443
|
+
* The statements waiting for a connection from the pool. The pool keeps retrying a connection it cannot open, with a growing pause between attempts, and fails a waiting `getConnection` only when `connectionTimeoutMillis` ends; the package reports each failure to its `logger.error` as it happens, together with every failed statement. `pg.Pool` instead rejects a pending connect whose connection fails, at once. So the driver fails the waiting statements at once with a failure no retry can get past. It keeps no failure: a later statement waits for the pool's next attempt.
|
|
444
|
+
*/
|
|
445
|
+
var WaitingForConnection = class {
|
|
446
|
+
#fail = /* @__PURE__ */ new Set();
|
|
447
|
+
async race(getting) {
|
|
448
|
+
let fail = () => {};
|
|
449
|
+
const failed = new Promise((_, reject) => {
|
|
450
|
+
fail = reject;
|
|
451
|
+
});
|
|
452
|
+
this.#fail.add(fail);
|
|
453
|
+
try {
|
|
454
|
+
return await Promise.race([getting, failed]);
|
|
455
|
+
} finally {
|
|
456
|
+
this.#fail.delete(fail);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
/** Reacts to an error the package reports: only a failure to connect, which the package marks fatal, that no retry can get past. A statement can fail with the same error number, such as 1524 for a missing authentication plugin, but not fatally. */
|
|
460
|
+
reported(error) {
|
|
461
|
+
if (!isFatal(error) || !connectingCannotSucceed(error)) return;
|
|
462
|
+
for (const fail of this.#fail) fail(error);
|
|
463
|
+
this.#fail.clear();
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
/** Gives a connection the pool hands over after its statement stopped waiting back to the pool. */
|
|
467
|
+
function releaseLate(getting) {
|
|
468
|
+
getting.then((late) => late.release(), ignoreConnectionFailure).catch(ignoreConnectionFailure);
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* The MySQL runtime driver: a `mariadb` pool. Every statement takes one round trip over the text protocol, the package writing its values into it. A query reads its whole result before the first row unless `stream` is set. The pool runs the session setup once on each physical connection, and the driver then sets the target's session settings on it; a connection goes back to the pool after each statement as it is; a broken connection is destroyed. `close()` waits for every connection and stream it has handed out before it ends the pool.
|
|
472
|
+
*/
|
|
473
|
+
var MysqlDriver = class extends MysqlQueryable {
|
|
474
|
+
familyId = "sql";
|
|
475
|
+
targetId;
|
|
476
|
+
holdsClient = false;
|
|
477
|
+
#state = { kind: "unbound" };
|
|
478
|
+
#inUse = new ClientsInUse();
|
|
479
|
+
#canceller;
|
|
480
|
+
cancelStatement = (threadId) => this.#canceller?.cancel(threadId) ?? Promise.resolve("unsent");
|
|
481
|
+
#options;
|
|
482
|
+
#sessionSettings;
|
|
483
|
+
constructor(options, targetId) {
|
|
484
|
+
super(options.stream ?? false);
|
|
485
|
+
this.targetId = targetId;
|
|
486
|
+
this.#options = options;
|
|
487
|
+
this.#sessionSettings = new SessionSettingsGuard(options.sessionSettings ?? {});
|
|
488
|
+
}
|
|
489
|
+
get state() {
|
|
490
|
+
return this.#state.kind;
|
|
491
|
+
}
|
|
492
|
+
async connect(binding) {
|
|
493
|
+
if (this.#state.kind === "connected") throw errorRuntime("DRIVER.ALREADY_CONNECTED", "MySQL driver already connected", { fix: "Call close() before connecting again." });
|
|
494
|
+
const waiting = new WaitingForConnection();
|
|
495
|
+
const pool = createPool({
|
|
496
|
+
...mysqlPoolOptions(binding.url, this.#options.poolOptions),
|
|
497
|
+
logger: { error: (error) => waiting.reported(error) }
|
|
498
|
+
});
|
|
499
|
+
if (pool instanceof EventEmitter) pool.on("error", ignoreConnectionFailure);
|
|
500
|
+
this.#state = {
|
|
501
|
+
kind: "connected",
|
|
502
|
+
pool,
|
|
503
|
+
waiting
|
|
504
|
+
};
|
|
505
|
+
this.#canceller = new Canceller(binding.url, mysqlPoolIdleTimeoutMillis(this.#options.poolOptions));
|
|
506
|
+
}
|
|
507
|
+
async acquireConnection() {
|
|
508
|
+
return new MysqlConnectionImpl(await this.acquireClient(), this.streams, this.cancelStatement, () => this.#inUse.released());
|
|
509
|
+
}
|
|
510
|
+
async close() {
|
|
511
|
+
if (this.#state.kind !== "connected") return;
|
|
512
|
+
const { pool } = this.#state;
|
|
513
|
+
this.#state = { kind: "closed" };
|
|
514
|
+
await this.#inUse.none();
|
|
515
|
+
await this.#canceller?.close();
|
|
516
|
+
this.#canceller = void 0;
|
|
517
|
+
await pool.end();
|
|
518
|
+
}
|
|
519
|
+
async acquireClient() {
|
|
520
|
+
if (this.#state.kind !== "connected") throw notConnected(this.#state.kind === "closed" ? "MySQL driver is closed" : "MySQL driver not connected");
|
|
521
|
+
const { pool, waiting } = this.#state;
|
|
522
|
+
this.#inUse.acquired();
|
|
523
|
+
const getting = pool.getConnection();
|
|
524
|
+
let client;
|
|
525
|
+
try {
|
|
526
|
+
client = await waiting.race(getting);
|
|
527
|
+
} catch (error) {
|
|
528
|
+
releaseLate(getting);
|
|
529
|
+
this.#inUse.released();
|
|
530
|
+
throw normalizeMysqlError(error);
|
|
531
|
+
}
|
|
532
|
+
try {
|
|
533
|
+
await this.#sessionSettings.ensure(client);
|
|
534
|
+
} catch (error) {
|
|
535
|
+
client.destroy();
|
|
536
|
+
this.#inUse.released();
|
|
537
|
+
throw normalizeMysqlError(error);
|
|
538
|
+
}
|
|
539
|
+
return client;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Destroys a client only after an error the package marks fatal, or after a cancel that went out without an answer once the rest of its result was read (`cancelUnconfirmed`). The package marks an error fatal when the connection's socket is gone or can no longer be trusted, and it has then already set the connection closed and failed every command on it (`fatalError` in its `connection.js`), so no command is receiving and its `destroy()` sends no `KILL`. A statement the caller stopped early is cancelled and read to its end instead (`#stopEarly`).
|
|
543
|
+
*/
|
|
544
|
+
async releaseClient(client, { destroy }) {
|
|
545
|
+
try {
|
|
546
|
+
if (destroy) client.destroy();
|
|
547
|
+
else await client.release();
|
|
548
|
+
} finally {
|
|
549
|
+
this.#inUse.released();
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
/** The runtime driver descriptor of MySQL, or of a target that extends it, whose drivers carry `targetId`. */
|
|
554
|
+
function createMysqlRuntimeDriverDescriptor(targetId) {
|
|
555
|
+
return {
|
|
556
|
+
...mysqlDriverDescriptorMetaFor(targetId),
|
|
557
|
+
create(options, sessionSettings) {
|
|
558
|
+
return new MysqlDriver({
|
|
559
|
+
...options,
|
|
560
|
+
...ifDefined("sessionSettings", sessionSettings)
|
|
561
|
+
}, targetId);
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
const mysqlRuntimeDriverDescriptor = createMysqlRuntimeDriverDescriptor("mysql");
|
|
566
|
+
//#endregion
|
|
567
|
+
export { mysqlRuntimeDriverDescriptor as n, createMysqlRuntimeDriverDescriptor as t };
|
|
568
|
+
|
|
569
|
+
//# sourceMappingURL=runtime-BGF0cSIt.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-BGF0cSIt.mjs","names":["#url","#idleTimeoutMillis","#closed","#idleTimer","#connection","#open","#setAside","#pending","#pendingOn","#idleLater","#streamRows","#runReleasing","#stopEarly","#refuseIfUnusable","#onRelease","#cancelRunning","#runningSettled","#close","#released","#count","#idle","#fail","#canceller","#options","#sessionSettings","#state","#inUse"],"sources":["../../../../3-targets/mysql/1-mysql/3-driver/dist/runtime.mjs"],"sourcesContent":["import { a as connectingCannotSucceed, c as isFatal, d as mysqlConnectionOptions, f as mysqlPoolIdleTimeoutMillis, l as normalizeMysqlError, m as acquireClientQueryLock, n as SessionSettingsGuard, p as mysqlPoolOptions, t as statementFor, u as mysqlDriverDescriptorMetaFor } from \"./statement-CT5tB4uX.mjs\";\nimport { errorRuntime } from \"@internal/errors/execution\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { createConnection, createPool } from \"mariadb\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { EventEmitter } from \"node:events\";\nimport { finished } from \"node:stream/promises\";\n//#region src/core/runtime/canceller.ts\n/** How long the canceller waits to open its connection, and for MySQL to answer a `KILL QUERY`. */\nconst CANCEL_TIMEOUT_MILLIS = 2e3;\nfunction timeout(millis) {\n\tlet timer;\n\treturn {\n\t\texpired: new Promise((resolve) => {\n\t\t\ttimer = setTimeout(() => resolve(\"expired\"), millis);\n\t\t}),\n\t\tclear: () => clearTimeout(timer)\n\t};\n}\n/**\n* Cancels statements with `KILL QUERY`, which MySQL takes only from another connection. It keeps one connection of its own, outside the pool, so a cancel neither waits for a pooled connection nor normally opens one; it opens it on first need, and ends it once it has been idle for the pool's idle timeout, as the pool ends its own; with a timeout of 0 it keeps it open, as the pool keeps its own. Opening it and each `KILL QUERY` are bounded by two seconds. The connection is never destroyed: the package's `destroy()` sends a `KILL` of its own whose failure it does not handle (`mariadb` 3.5.4). A connection that stops answering is set aside and ended with `end()` once its statement settles.\n*/\nvar Canceller = class {\n\t#url;\n\t#idleTimeoutMillis;\n\t#connection;\n\t#pending = /* @__PURE__ */ new WeakMap();\n\t#closed = false;\n\t#idleTimer;\n\tconstructor(url, idleTimeoutMillis) {\n\t\tthis.#url = url;\n\t\tthis.#idleTimeoutMillis = idleTimeoutMillis;\n\t}\n\t/** Sends `KILL QUERY` for `threadId`. Never rejects. A kept connection that is no longer valid is replaced once. */\n\tasync cancel(threadId, replaced = false) {\n\t\tif (this.#closed || threadId === null) return \"unsent\";\n\t\tclearTimeout(this.#idleTimer);\n\t\tconst opening = this.#connection ?? this.#open();\n\t\tthis.#connection = opening;\n\t\tconst connection = await opening;\n\t\tif (connection === void 0) {\n\t\t\tthis.#setAside(opening);\n\t\t\treturn \"unsent\";\n\t\t}\n\t\tif (!connection.isValid()) {\n\t\t\tthis.#setAside(opening);\n\t\t\treturn replaced ? \"unsent\" : this.cancel(threadId, true);\n\t\t}\n\t\tthis.#pending.set(connection, this.#pendingOn(connection) + 1);\n\t\tconst killing = connection.query(\"KILL QUERY ?\", [threadId]).then(() => \"sent\", (error) => isFatal(error) ? \"unconfirmed\" : \"unsent\");\n\t\tkilling.then(() => {\n\t\t\tthis.#pending.set(connection, this.#pendingOn(connection) - 1);\n\t\t\tthis.#idleLater(opening, connection);\n\t\t});\n\t\tconst limit = timeout(CANCEL_TIMEOUT_MILLIS);\n\t\tconst result = await Promise.race([killing, limit.expired]);\n\t\tlimit.clear();\n\t\tif (result === \"sent\" || result === \"unsent\") return result;\n\t\tthis.#setAside(opening);\n\t\tconnection.end().catch(() => void 0);\n\t\treturn \"unconfirmed\";\n\t}\n\t/** Ends the connection: `end()` sends `QUIT` once any `KILL QUERY` on it settles. Waits for that only when no `KILL QUERY` is pending on it, so a connection that stopped answering cannot hold `close()` up. */\n\tasync close() {\n\t\tthis.#closed = true;\n\t\tclearTimeout(this.#idleTimer);\n\t\tconst connection = await this.#connection;\n\t\tthis.#connection = void 0;\n\t\tif (connection === void 0) return;\n\t\tconst ending = connection.end().catch(() => void 0);\n\t\tif (this.#pendingOn(connection) === 0) await ending;\n\t}\n\t#idleLater(opening, connection) {\n\t\tif (this.#idleTimeoutMillis === 0 || this.#pendingOn(connection) > 0 || this.#connection !== opening) return;\n\t\tclearTimeout(this.#idleTimer);\n\t\tthis.#idleTimer = setTimeout(() => {\n\t\t\tif (this.#pendingOn(connection) > 0 || this.#connection !== opening) return;\n\t\t\tthis.#connection = void 0;\n\t\t\tconnection.end().catch(() => void 0);\n\t\t}, this.#idleTimeoutMillis);\n\t\tthis.#idleTimer.unref();\n\t}\n\t#pendingOn(connection) {\n\t\treturn this.#pending.get(connection) ?? 0;\n\t}\n\t#setAside(opening) {\n\t\tif (this.#connection === opening) this.#connection = void 0;\n\t}\n\tasync #open() {\n\t\ttry {\n\t\t\tconst connection = await createConnection(mysqlConnectionOptions(this.#url, { connectTimeoutMs: CANCEL_TIMEOUT_MILLIS }));\n\t\t\tconnection.on(\"error\", () => void 0);\n\t\t\tif (this.#closed) {\n\t\t\t\tawait connection.end().catch(() => void 0);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treturn connection;\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\t}\n};\n//#endregion\n//#region src/core/runtime/mysql-driver.ts\nfunction notConnected(message) {\n\treturn errorRuntime(\"DRIVER.NOT_CONNECTED\", message, { fix: \"Call connect(binding) before running queries, and do not use the driver after close().\" });\n}\n/** Runs `request` on `client` in one round trip and returns its result: its `?N` placeholders written as `?`, and its values handed to the package, which writes them into the statement. Throws the package's error as it is. */\nasync function run(client, request) {\n\tconst { sql, values } = statementFor(client, request.sql, request.params ?? []);\n\treturn client.query(sql, values);\n}\n/** Starts streaming the rows of `request` on `client`, sent as {@link run} sends it. Throws the error to report, after noting in `outcome` whether it left the client unusable. */\nfunction startStream(client, request, outcome) {\n\ttry {\n\t\tconst { sql, values } = statementFor(client, request.sql, request.params ?? []);\n\t\treturn client.queryStream(sql, values);\n\t} catch (error) {\n\t\tthrow settle(error, outcome);\n\t}\n}\n/** What a statement's result reports: the rows it changed, and, when it changed one row, the value MySQL numbered for it. MySQL reports 0 when it numbered none. */\nfunction statementStats(result) {\n\tif (typeof result !== \"object\" || result === null) return { affectedRows: 0 };\n\tconst affectedRows = \"affectedRows\" in result && typeof result.affectedRows === \"number\" ? result.affectedRows : 0;\n\tconst insertId = \"insertId\" in result ? result.insertId : void 0;\n\treturn affectedRows === 1 && (typeof insertId === \"bigint\" || typeof insertId === \"number\") && insertId > 0 ? {\n\t\taffectedRows,\n\t\tinsertId: String(insertId)\n\t} : { affectedRows };\n}\n/** The error to report for `error`, after noting in `outcome` whether it left the client unusable. */\nfunction settle(error, outcome) {\n\tif (isFatal(error)) outcome.destroy = true;\n\treturn normalizeMysqlError(error);\n}\n/**\n* Whether the package has received the end of the result, so that any rows the caller has not read are already in the stream's buffer. The package pushes the end of the stream when MySQL's last packet arrives; Node records that in `_readableState.ended`, and its public API reports the end only after the caller has read every row.\n*/\nfunction resultReceived(rows) {\n\tconst state = Reflect.get(rows, \"_readableState\");\n\treturn typeof state === \"object\" && state !== null && \"ended\" in state && state.ended === true;\n}\n/**\n* Reads and drops what is left of a stream's result. The package's `close()` stops it keeping new rows; the rows already buffered are read here with `read()`, which works whether or not the caller's iterator is still attached to the stream, so an iterator the caller abandoned cannot hold the drain up.\n*/\nasync function dropRest(rows) {\n\trows.close?.();\n\tconst drain = () => {\n\t\twhile (rows.read() !== null);\n\t};\n\trows.on(\"readable\", drain);\n\ttry {\n\t\tdrain();\n\t\tawait finished(rows);\n\t} finally {\n\t\trows.off(\"readable\", drain);\n\t}\n}\nfunction cancelNotConfirmed() {\n\treturn errorRuntime(\"DRIVER.NOT_CONNECTED\", \"A cancel on this MySQL connection could not be confirmed, so the connection can no longer be used\", {\n\t\twhy: \"The driver cancelled a stream the caller stopped early, and MySQL did not answer the KILL QUERY in time. It may still arrive and would interrupt whatever statement the connection runs then.\",\n\t\tfix: \"Release the connection, which closes it; MySQL rolls back an open transaction on it. Acquire another connection and run the work again.\"\n\t});\n}\nfunction connectionReleased() {\n\treturn errorRuntime(\"DRIVER.NOT_CONNECTED\", \"MySQL connection was released\", { fix: \"Send statements on a connection only until you release it, and await each one before release().\" });\n}\n/** The package can report an error on a stream after the caller stopped reading it, such as MySQL's for a statement the driver cancelled; the generator has already settled by then. */\nfunction ignoreAfterStop() {}\n/** MySQL's error for a statement `KILL QUERY` cancelled (`ER_QUERY_INTERRUPTED`). The package marks it fatal when it arrives in the middle of a result, but the connection stays usable. */\nfunction isQueryInterrupted(error) {\n\treturn error instanceof Error && \"errno\" in error && error.errno === 1317;\n}\nvar MysqlQueryable = class {\n\tstreams;\n\tconstructor(streams) {\n\t\tthis.streams = streams;\n\t}\n\t/** Records a stream that is open, and returns the call that records its end. */\n\tstreamOpened(_rows) {\n\t\treturn () => {};\n\t}\n\t/** Takes the client's lock, which keeps statements on it one at a time in the order sent. */\n\tlockClient(client) {\n\t\treturn acquireClientQueryLock(client);\n\t}\n\t/** Runs one statement that is not a stream, under the client's lock. */\n\trunStatement(work) {\n\t\treturn work();\n\t}\n\t/** Whether the client went back to the pool under this queryable, so it must send nothing more on it. */\n\tget handedBack() {\n\t\treturn false;\n\t}\n\tasync *query(request) {\n\t\tif (this.streams) {\n\t\t\tyield* this.#streamRows(request);\n\t\t\treturn;\n\t\t}\n\t\tconst result = await this.#runReleasing(request);\n\t\tfor (const row of Array.isArray(result) ? result : []) yield blindCast(row);\n\t}\n\tasync execute(request) {\n\t\treturn statementStats(await this.#runReleasing(request));\n\t}\n\tasync #runReleasing(request) {\n\t\tconst client = await this.acquireClient();\n\t\tconst outcome = { destroy: false };\n\t\ttry {\n\t\t\tconst releaseLock = await this.lockClient(client);\n\t\t\ttry {\n\t\t\t\treturn await this.runStatement(() => run(client, request));\n\t\t\t} finally {\n\t\t\t\treleaseLock();\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow settle(error, outcome);\n\t\t} finally {\n\t\t\tawait this.releaseClient(client, outcome);\n\t\t}\n\t}\n\t/**\n\t* Streams the rows of `request` as they arrive; the package pauses the socket while the caller is busy. A caller that stops reading early is handled by {@link MysqlQueryable.#stopEarly}. A fatal error, such as a lost connection, destroys the client.\n\t*/\n\tasync *#streamRows(request) {\n\t\tconst client = await this.acquireClient();\n\t\tconst outcome = { destroy: false };\n\t\tlet releaseLock;\n\t\ttry {\n\t\t\treleaseLock = await this.lockClient(client);\n\t\t} catch (error) {\n\t\t\tawait this.releaseClient(client, outcome);\n\t\t\tthrow error;\n\t\t}\n\t\ttry {\n\t\t\tconst rows = startStream(client, request, outcome);\n\t\t\trows.on(\"error\", ignoreAfterStop);\n\t\t\tconst streamClosed = this.streamOpened(rows);\n\t\t\tlet settled = false;\n\t\t\ttry {\n\t\t\t\tfor await (const row of rows.iterator({ destroyOnReturn: false })) yield blindCast(row);\n\t\t\t\tsettled = true;\n\t\t\t} catch (error) {\n\t\t\t\tsettled = true;\n\t\t\t\tthrow settle(error, outcome);\n\t\t\t} finally {\n\t\t\t\tif (!settled && !this.handedBack) await this.#stopEarly(client, rows, outcome);\n\t\t\t\tif (outcome.destroy) rows.destroy();\n\t\t\t\tstreamClosed();\n\t\t\t}\n\t\t} finally {\n\t\t\treleaseLock();\n\t\t\tawait this.releaseClient(client, outcome);\n\t\t}\n\t}\n\t/**\n\t* Ends a stream the caller stopped reading early, and keeps the client usable. While its result is still arriving, the statement is first cancelled with `KILL QUERY`, so a large result is not downloaded only to be thrown away; MySQL does not say how many rows remain. On a held connection or in a transaction, as on a pooled one: `KILL QUERY` ends only the statement, the session survives, and in a transaction MySQL rolls back only that statement. The rest of the result is then read and dropped, MySQL's error for the cancelled statement among it. The client is never destroyed while its statement runs: the package's `destroy()` would send `KILL` itself, on a connection whose failure it does not handle.\n\t*/\n\tasync #stopEarly(client, rows, outcome) {\n\t\tconst cancel = resultReceived(rows) ? \"unsent\" : await this.cancelStatement(client.threadId);\n\t\tawait dropRest(rows).catch((error) => {\n\t\t\tif (isFatal(error) && !(cancel !== \"unsent\" && isQueryInterrupted(error))) outcome.destroy = true;\n\t\t});\n\t\tif (cancel === \"unconfirmed\") this.cancelUnconfirmed(outcome);\n\t}\n\t/**\n\t* A cancel that went out without an answer may still reach MySQL and interrupt the next statement on the client, so the client must not serve another caller. Once its rest has been read, nothing is receiving on it, so closing it sends no `KILL` of the package's own; a late `KILL QUERY` then finds no thread.\n\t*/\n\tcancelUnconfirmed(outcome) {\n\t\toutcome.destroy = true;\n\t}\n};\nfunction handedBackState() {\n\tlet refuse = () => {};\n\tconst signal = new Promise((_, reject) => {\n\t\trefuse = () => reject(connectionReleased());\n\t});\n\tsignal.catch(() => void 0);\n\tconst state = {\n\t\tdone: false,\n\t\tsignal,\n\t\trefuse: () => {\n\t\t\tstate.done = true;\n\t\t\trefuse();\n\t\t}\n\t};\n\treturn state;\n}\n/**\n* A queryable on a connection the caller holds, whose statements all run on the same session, in the order they are sent, under the client's lock. A statement sent while a stream on the connection is open waits for that stream to end; one awaited inside the stream's own loop never finishes, as on Postgres with a cursor.\n*/\nvar MysqlHeldQueryable = class extends MysqlQueryable {\n\tclient;\n\theld;\n\tholdsClient = true;\n\tget cancelStatement() {\n\t\treturn this.held.cancel;\n\t}\n\tstreamOpened(rows) {\n\t\tthis.held.streams.add(rows);\n\t\treturn () => this.held.streams.delete(rows);\n\t}\n\tget handedBack() {\n\t\treturn this.held.handedBack.done;\n\t}\n\tcancelUnconfirmed() {\n\t\tthis.held.cancelUnconfirmed = true;\n\t}\n\t/** Takes the client's lock, or fails once the connection is handed back, whether the statement was sent after that or was still waiting for the lock. A lock taken after that is given straight back. */\n\tasync lockClient(client) {\n\t\tthis.#refuseIfUnusable();\n\t\tconst locking = acquireClientQueryLock(client);\n\t\ttry {\n\t\t\tconst releaseLock = await Promise.race([locking, this.held.handedBack.signal]);\n\t\t\tif (!this.held.handedBack.done && !this.held.cancelUnconfirmed) return releaseLock;\n\t\t\treleaseLock();\n\t\t} catch {\n\t\t\tlocking.then((releaseLock) => releaseLock());\n\t\t}\n\t\tthis.#refuseIfUnusable();\n\t\tthrow connectionReleased();\n\t}\n\t/** Refuses a statement on a connection that was handed back, or whose cancel went out without an answer: a late `KILL QUERY` would interrupt it. */\n\t#refuseIfUnusable() {\n\t\tif (this.held.handedBack.done) throw connectionReleased();\n\t\tif (this.held.cancelUnconfirmed) throw cancelNotConfirmed();\n\t}\n\trunStatement(work) {\n\t\tconst running = work();\n\t\tthis.held.running.add(running);\n\t\trunning.then(() => this.held.running.delete(running), () => this.held.running.delete(running));\n\t\treturn running;\n\t}\n\tconstructor(client, held, streams) {\n\t\tsuper(streams);\n\t\tthis.client = client;\n\t\tthis.held = held;\n\t}\n\tasync acquireClient() {\n\t\tthis.#refuseIfUnusable();\n\t\treturn this.client;\n\t}\n\tasync releaseClient() {}\n\t/** Runs one of the package's transaction calls under the client's lock, taken as a statement takes it, so it keeps its place among the statements sent. */\n\tasync underLock(call) {\n\t\tconst client = await this.acquireClient();\n\t\tconst releaseLock = await this.lockClient(client);\n\t\ttry {\n\t\t\tawait this.runStatement(call);\n\t\t} catch (error) {\n\t\t\tthrow normalizeMysqlError(error);\n\t\t} finally {\n\t\t\treleaseLock();\n\t\t}\n\t}\n};\nvar MysqlConnectionImpl = class extends MysqlHeldQueryable {\n\t#onRelease;\n\tconstructor(client, streams, cancel, onRelease) {\n\t\tsuper(client, {\n\t\t\tstreams: /* @__PURE__ */ new Set(),\n\t\t\tcancelUnconfirmed: false,\n\t\t\trunning: /* @__PURE__ */ new Set(),\n\t\t\tcancel,\n\t\t\thandedBack: handedBackState()\n\t\t}, streams);\n\t\tthis.#onRelease = onRelease;\n\t}\n\t#released() {\n\t\tconst onRelease = this.#onRelease;\n\t\tthis.#onRelease = void 0;\n\t\tonRelease?.();\n\t}\n\tasync beginTransaction() {\n\t\tawait this.underLock(() => this.client.beginTransaction());\n\t\treturn new MysqlTransactionImpl(this.client, this.held, this.streams);\n\t}\n\t/**\n\t* Returns the connection to the pool, as the Postgres driver's `release()` does. From then on the connection refuses every statement, those still waiting for its lock included, so none runs later in another caller's session. A statement that is not a stream and is already running finishes, as on Postgres. A stream still open, such as one the caller dropped, is cancelled and read to its end by the driver: the package's release sends `ROLLBACK` behind that statement and waits for it, which would otherwise never finish, where `pg`'s release does not wait on the server.\n\t*/\n\tasync release() {\n\t\tif (this.held.handedBack.done) return;\n\t\tthis.held.handedBack.refuse();\n\t\ttry {\n\t\t\tif (this.held.streams.size > 0) await this.#cancelRunning();\n\t\t\tawait this.#runningSettled();\n\t\t\tif (this.held.cancelUnconfirmed) await this.#close();\n\t\t\telse await this.client.release();\n\t\t} finally {\n\t\t\tthis.#released();\n\t\t}\n\t}\n\t/** Closes the connection instead of returning it. It refuses every statement from then on, cancels whatever still runs and waits for it to end, so the package's `destroy()` never sends a `KILL` of its own. */\n\tasync destroy(_reason) {\n\t\tif (this.held.handedBack.done) return;\n\t\tthis.held.handedBack.refuse();\n\t\ttry {\n\t\t\tif (this.held.streams.size > 0 || this.held.running.size > 0) await this.#cancelRunning();\n\t\t\tawait this.#runningSettled();\n\t\t\tawait this.#close();\n\t\t} finally {\n\t\t\tthis.#released();\n\t\t}\n\t}\n\t/** Closes the client once the `ping` queued behind anything left on it has answered, so nothing is receiving and the package's `destroy()` sends no `KILL` of its own. */\n\tasync #close() {\n\t\tawait this.client.ping().catch(() => void 0);\n\t\tthis.client.destroy();\n\t}\n\tasync #cancelRunning() {\n\t\tif (await this.held.cancel(this.client.threadId) === \"unconfirmed\") this.held.cancelUnconfirmed = true;\n\t\tawait Promise.all([...this.held.streams].map((rows) => dropRest(rows).catch(() => void 0)));\n\t}\n\tasync #runningSettled() {\n\t\tawait Promise.allSettled([...this.held.running]);\n\t}\n};\nvar MysqlTransactionImpl = class extends MysqlHeldQueryable {\n\tasync commit() {\n\t\tawait this.underLock(() => this.client.commit());\n\t}\n\tasync rollback() {\n\t\tawait this.underLock(() => this.client.rollback());\n\t}\n};\n/** How many clients the driver has handed out and not had back, a held connection or one lent to a single statement, so `close()` can wait until every one is back. */\nvar ClientsInUse = class {\n\t#count = 0;\n\t#idle = [];\n\tacquired() {\n\t\tthis.#count += 1;\n\t}\n\treleased() {\n\t\tthis.#count -= 1;\n\t\tif (this.#count === 0) for (const resolve of this.#idle.splice(0)) resolve();\n\t}\n\tnone() {\n\t\treturn this.#count === 0 ? Promise.resolve() : new Promise((resolve) => this.#idle.push(resolve));\n\t}\n};\n/** The pool reports a connection it failed to open on its `'error'` event, and again as the cause of a `getConnection` that times out; the driver reports it there. */\nfunction ignoreConnectionFailure() {}\n/**\n* The statements waiting for a connection from the pool. The pool keeps retrying a connection it cannot open, with a growing pause between attempts, and fails a waiting `getConnection` only when `connectionTimeoutMillis` ends; the package reports each failure to its `logger.error` as it happens, together with every failed statement. `pg.Pool` instead rejects a pending connect whose connection fails, at once. So the driver fails the waiting statements at once with a failure no retry can get past. It keeps no failure: a later statement waits for the pool's next attempt.\n*/\nvar WaitingForConnection = class {\n\t#fail = /* @__PURE__ */ new Set();\n\tasync race(getting) {\n\t\tlet fail = () => {};\n\t\tconst failed = new Promise((_, reject) => {\n\t\t\tfail = reject;\n\t\t});\n\t\tthis.#fail.add(fail);\n\t\ttry {\n\t\t\treturn await Promise.race([getting, failed]);\n\t\t} finally {\n\t\t\tthis.#fail.delete(fail);\n\t\t}\n\t}\n\t/** Reacts to an error the package reports: only a failure to connect, which the package marks fatal, that no retry can get past. A statement can fail with the same error number, such as 1524 for a missing authentication plugin, but not fatally. */\n\treported(error) {\n\t\tif (!isFatal(error) || !connectingCannotSucceed(error)) return;\n\t\tfor (const fail of this.#fail) fail(error);\n\t\tthis.#fail.clear();\n\t}\n};\n/** Gives a connection the pool hands over after its statement stopped waiting back to the pool. */\nfunction releaseLate(getting) {\n\tgetting.then((late) => late.release(), ignoreConnectionFailure).catch(ignoreConnectionFailure);\n}\n/**\n* The MySQL runtime driver: a `mariadb` pool. Every statement takes one round trip over the text protocol, the package writing its values into it. A query reads its whole result before the first row unless `stream` is set. The pool runs the session setup once on each physical connection, and the driver then sets the target's session settings on it; a connection goes back to the pool after each statement as it is; a broken connection is destroyed. `close()` waits for every connection and stream it has handed out before it ends the pool.\n*/\nvar MysqlDriver = class extends MysqlQueryable {\n\tfamilyId = \"sql\";\n\ttargetId;\n\tholdsClient = false;\n\t#state = { kind: \"unbound\" };\n\t#inUse = new ClientsInUse();\n\t#canceller;\n\tcancelStatement = (threadId) => this.#canceller?.cancel(threadId) ?? Promise.resolve(\"unsent\");\n\t#options;\n\t#sessionSettings;\n\tconstructor(options, targetId) {\n\t\tsuper(options.stream ?? false);\n\t\tthis.targetId = targetId;\n\t\tthis.#options = options;\n\t\tthis.#sessionSettings = new SessionSettingsGuard(options.sessionSettings ?? {});\n\t}\n\tget state() {\n\t\treturn this.#state.kind;\n\t}\n\tasync connect(binding) {\n\t\tif (this.#state.kind === \"connected\") throw errorRuntime(\"DRIVER.ALREADY_CONNECTED\", \"MySQL driver already connected\", { fix: \"Call close() before connecting again.\" });\n\t\tconst waiting = new WaitingForConnection();\n\t\tconst pool = createPool({\n\t\t\t...mysqlPoolOptions(binding.url, this.#options.poolOptions),\n\t\t\tlogger: { error: (error) => waiting.reported(error) }\n\t\t});\n\t\tif (pool instanceof EventEmitter) pool.on(\"error\", ignoreConnectionFailure);\n\t\tthis.#state = {\n\t\t\tkind: \"connected\",\n\t\t\tpool,\n\t\t\twaiting\n\t\t};\n\t\tthis.#canceller = new Canceller(binding.url, mysqlPoolIdleTimeoutMillis(this.#options.poolOptions));\n\t}\n\tasync acquireConnection() {\n\t\treturn new MysqlConnectionImpl(await this.acquireClient(), this.streams, this.cancelStatement, () => this.#inUse.released());\n\t}\n\tasync close() {\n\t\tif (this.#state.kind !== \"connected\") return;\n\t\tconst { pool } = this.#state;\n\t\tthis.#state = { kind: \"closed\" };\n\t\tawait this.#inUse.none();\n\t\tawait this.#canceller?.close();\n\t\tthis.#canceller = void 0;\n\t\tawait pool.end();\n\t}\n\tasync acquireClient() {\n\t\tif (this.#state.kind !== \"connected\") throw notConnected(this.#state.kind === \"closed\" ? \"MySQL driver is closed\" : \"MySQL driver not connected\");\n\t\tconst { pool, waiting } = this.#state;\n\t\tthis.#inUse.acquired();\n\t\tconst getting = pool.getConnection();\n\t\tlet client;\n\t\ttry {\n\t\t\tclient = await waiting.race(getting);\n\t\t} catch (error) {\n\t\t\treleaseLate(getting);\n\t\t\tthis.#inUse.released();\n\t\t\tthrow normalizeMysqlError(error);\n\t\t}\n\t\ttry {\n\t\t\tawait this.#sessionSettings.ensure(client);\n\t\t} catch (error) {\n\t\t\tclient.destroy();\n\t\t\tthis.#inUse.released();\n\t\t\tthrow normalizeMysqlError(error);\n\t\t}\n\t\treturn client;\n\t}\n\t/**\n\t* Destroys a client only after an error the package marks fatal, or after a cancel that went out without an answer once the rest of its result was read (`cancelUnconfirmed`). The package marks an error fatal when the connection's socket is gone or can no longer be trusted, and it has then already set the connection closed and failed every command on it (`fatalError` in its `connection.js`), so no command is receiving and its `destroy()` sends no `KILL`. A statement the caller stopped early is cancelled and read to its end instead (`#stopEarly`).\n\t*/\n\tasync releaseClient(client, { destroy }) {\n\t\ttry {\n\t\t\tif (destroy) client.destroy();\n\t\t\telse await client.release();\n\t\t} finally {\n\t\t\tthis.#inUse.released();\n\t\t}\n\t}\n};\n//#endregion\n//#region src/core/runtime/runtime-driver.ts\n/** The runtime driver descriptor of MySQL, or of a target that extends it, whose drivers carry `targetId`. */\nfunction createMysqlRuntimeDriverDescriptor(targetId) {\n\treturn {\n\t\t...mysqlDriverDescriptorMetaFor(targetId),\n\t\tcreate(options, sessionSettings) {\n\t\t\treturn new MysqlDriver({\n\t\t\t\t...options,\n\t\t\t\t...ifDefined(\"sessionSettings\", sessionSettings)\n\t\t\t}, targetId);\n\t\t}\n\t};\n}\nconst mysqlRuntimeDriverDescriptor = createMysqlRuntimeDriverDescriptor(\"mysql\");\n//#endregion\nexport { createMysqlRuntimeDriverDescriptor, mysqlRuntimeDriverDescriptor as default };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;AASA,MAAM,wBAAwB;AAC9B,SAAS,QAAQ,QAAQ;CACxB,IAAI;CACJ,OAAO;EACN,SAAS,IAAI,SAAS,YAAY;GACjC,QAAQ,iBAAiB,QAAQ,SAA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