velocious 1.0.551 → 1.0.552
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/build/background-jobs/json-socket.js +25 -0
- package/build/background-jobs/socket-request.js +48 -6
- package/build/background-jobs/status-reporter.js +14 -2
- package/build/configuration-types.js +1 -0
- package/build/database/drivers/base.js +12 -0
- package/build/database/drivers/mssql/index.js +52 -3
- package/build/database/drivers/mysql/index.js +34 -0
- package/build/database/structure-sql-loader.js +12 -6
- package/build/src/background-jobs/json-socket.d.ts +20 -0
- package/build/src/background-jobs/json-socket.d.ts.map +1 -1
- package/build/src/background-jobs/json-socket.js +25 -1
- package/build/src/background-jobs/socket-request.d.ts +13 -1
- package/build/src/background-jobs/socket-request.d.ts.map +1 -1
- package/build/src/background-jobs/socket-request.js +44 -7
- package/build/src/background-jobs/status-reporter.d.ts +12 -1
- package/build/src/background-jobs/status-reporter.d.ts.map +1 -1
- package/build/src/background-jobs/status-reporter.js +14 -3
- package/build/src/configuration-types.d.ts +5 -0
- package/build/src/configuration-types.d.ts.map +1 -1
- package/build/src/configuration-types.js +2 -1
- package/build/src/database/drivers/base.d.ts +9 -0
- package/build/src/database/drivers/base.d.ts.map +1 -1
- package/build/src/database/drivers/base.js +12 -1
- package/build/src/database/drivers/mssql/index.d.ts +9 -0
- package/build/src/database/drivers/mssql/index.d.ts.map +1 -1
- package/build/src/database/drivers/mssql/index.js +45 -2
- package/build/src/database/drivers/mysql/index.d.ts.map +1 -1
- package/build/src/database/drivers/mysql/index.js +35 -1
- package/build/src/database/structure-sql-loader.d.ts.map +1 -1
- package/build/src/database/structure-sql-loader.js +14 -8
- package/package.json +1 -1
- package/src/background-jobs/json-socket.js +25 -0
- package/src/background-jobs/socket-request.js +48 -6
- package/src/background-jobs/status-reporter.js +14 -2
- package/src/configuration-types.js +1 -0
- package/src/database/drivers/base.js +12 -0
- package/src/database/drivers/mssql/index.js +52 -3
- package/src/database/drivers/mysql/index.js +34 -0
- package/src/database/structure-sql-loader.js +12 -6
|
@@ -190,6 +190,10 @@ export default class VelociousDatabaseDriversMysql extends Base{
|
|
|
190
190
|
|
|
191
191
|
if ("username" in args) connectArgs["user"] = args["username"]
|
|
192
192
|
if ("charset" in args) connectArgs["charset"] = args["charset"]
|
|
193
|
+
// Opt-in only. Lets a whole structure SQL dump run in one round-trip via
|
|
194
|
+
// {@link execStructureScript}; off by default so ordinary queries keep rejecting
|
|
195
|
+
// stacked statements.
|
|
196
|
+
if ("multipleStatements" in args) connectArgs["multipleStatements"] = Boolean(digg(args, "multipleStatements"))
|
|
193
197
|
|
|
194
198
|
return connectArgs
|
|
195
199
|
}
|
|
@@ -417,6 +421,36 @@ export default class VelociousDatabaseDriversMysql extends Base{
|
|
|
417
421
|
})
|
|
418
422
|
}
|
|
419
423
|
|
|
424
|
+
/**
|
|
425
|
+
* Executes a full multi-statement structure SQL script in one round-trip when the
|
|
426
|
+
* connection was configured with `multipleStatements: true`. Runs on the pooled
|
|
427
|
+
* connection so the caller's `SET FOREIGN_KEY_CHECKS = 0` applies. Returns false so
|
|
428
|
+
* the caller runs statements individually when multi-statement queries are off.
|
|
429
|
+
* @param {string} structureSql - Full multi-statement structure SQL.
|
|
430
|
+
* @returns {Promise<boolean>} - Whether the script was executed as one batch.
|
|
431
|
+
*/
|
|
432
|
+
async execStructureScript(structureSql) {
|
|
433
|
+
if (!this.getArgs().multipleStatements) return false
|
|
434
|
+
|
|
435
|
+
// The batched pool call below bypasses Base#query, so re-run the same read-only
|
|
436
|
+
// write guard the per-statement path applies before executing the dump.
|
|
437
|
+
this._assertWritableQuery(structureSql)
|
|
438
|
+
|
|
439
|
+
if (!this.pool) await this.connect()
|
|
440
|
+
if (!this.pool) throw new Error("MySQL pool failed to initialize")
|
|
441
|
+
|
|
442
|
+
const pool = this.pool
|
|
443
|
+
|
|
444
|
+
await new Promise((resolve, reject) => {
|
|
445
|
+
pool.query(structureSql, (error) => {
|
|
446
|
+
if (error) reject(error)
|
|
447
|
+
else resolve(undefined)
|
|
448
|
+
})
|
|
449
|
+
})
|
|
450
|
+
|
|
451
|
+
return true
|
|
452
|
+
}
|
|
453
|
+
|
|
420
454
|
/**
|
|
421
455
|
* Runs query to sql.
|
|
422
456
|
* @param {import("../../query/index.js").default} query - Query instance.
|
|
@@ -31,17 +31,23 @@ export default class StructureSqlLoader {
|
|
|
31
31
|
await db.disableForeignKeys()
|
|
32
32
|
|
|
33
33
|
try {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
// Prefer a single round-trip for the whole dump: a driver-native multi-statement
|
|
35
|
+
// batch (e.g. MySQL with `multipleStatements`) first, then a native `exec`
|
|
36
|
+
// connection (e.g. SQLite), and finally per-statement execution. Running the
|
|
37
|
+
// whole dump at once is far faster than issuing every CREATE separately.
|
|
38
|
+
if (!await db.execStructureScript(structureSql)) {
|
|
39
|
+
if (executableConnection) {
|
|
40
|
+
await executableConnection.exec(structureSql)
|
|
41
|
+
} else {
|
|
42
|
+
for (const statement of statements) {
|
|
43
|
+
await db.query(statement)
|
|
44
|
+
}
|
|
39
45
|
}
|
|
40
46
|
}
|
|
41
47
|
} finally {
|
|
42
48
|
await db.enableForeignKeys()
|
|
43
49
|
|
|
44
|
-
// The native `exec`
|
|
50
|
+
// The batch / native `exec` paths mutate the schema outside `Base#query`, so the
|
|
45
51
|
// usual post-DDL schema-cache invalidation never runs. Clear it here so a
|
|
46
52
|
// caller that read schema metadata before provisioning (e.g. an empty table
|
|
47
53
|
// list) does not keep seeing the pre-load schema afterwards. Harmless for the
|