@clickup/pg-microsharding
Version:
Microshards support for PostgreSQL
31 lines • 1.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.runSqlProgressNonTransactional = runSqlProgressNonTransactional;
exports.runSqlProgressTransactional = runSqlProgressTransactional;
const names_1 = require("./names");
const runShell_1 = require("./runShell");
/**
* SLOW: runs a psql with the provided SQL query (or queries) passed as stdin.
* - Does NOT run in a single-transaction mode.
* - Suitable for slow queries, like indexes and FKs creation.
* - Prints progress as it goes (suitable for slow queries).
* - Logs the progress unique lines to the log file if it's attached.
*/
async function runSqlProgressNonTransactional(dsn, query, comment) {
await (0, runShell_1.runShell)(`${(0, names_1.psql)(dsn)} -a`, query.toString(), comment, "progress", [
"PGOPTIONS",
]);
}
/**
* FAST: runs a psql with the provided SQL query (or queries) passed as stdin.
* - Runs in a single-transaction mode.
* - Suitable for fast queries, like pre-data dump restoration.
* - Prints progress as it goes (suitable for slow queries).
* - Does NOT log the progress unique lines to the log file (assuming that the
* SQL queries are so bulky that it makes no sense to log them).
*/
async function runSqlProgressTransactional(dsn, query, comment) {
await (0, runShell_1.runShell)(`${(0, names_1.psql)(dsn)} -a -1`, // -1 means "single-transaction"
query.toString(), comment, "progress.unlogged");
}
//# sourceMappingURL=runSqlProgress.js.map