mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 12:35:59 +00:00
SYNC: commit/rollback - control commands
This commit is contained in:
committed by
Diflow
parent
f81207737c
commit
11d193a6dd
@@ -245,6 +245,46 @@ async function handleStopProfiler({ jslid }) {
|
||||
currentProfiler = null;
|
||||
}
|
||||
|
||||
async function handleExecuteControlCommand({ command }) {
|
||||
lastActivity = new Date().getTime();
|
||||
|
||||
await waitConnected();
|
||||
const driver = requireEngineDriver(storedConnection);
|
||||
|
||||
if (command == 'commitTransaction' && !allowExecuteCustomScript(driver)) {
|
||||
process.send({
|
||||
msgtype: 'info',
|
||||
info: {
|
||||
message: 'Connection without read-only sessions is read only',
|
||||
severity: 'error',
|
||||
},
|
||||
});
|
||||
process.send({ msgtype: 'done', skipFinishedMessage: true });
|
||||
return;
|
||||
//process.send({ msgtype: 'error', error: e.message });
|
||||
}
|
||||
|
||||
executingScripts++;
|
||||
try {
|
||||
const dmp = driver.createDumper();
|
||||
switch (command) {
|
||||
case 'commitTransaction':
|
||||
await dmp.commitTransaction();
|
||||
break;
|
||||
case 'rollbackTransaction':
|
||||
await dmp.rollbackTransaction();
|
||||
break;
|
||||
case 'beginTransaction':
|
||||
await dmp.beginTransaction();
|
||||
break;
|
||||
}
|
||||
await driver.query(dbhan, dmp.s, { discardResult: true });
|
||||
process.send({ msgtype: 'done', controlCommand: command });
|
||||
} finally {
|
||||
executingScripts--;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleExecuteQuery({ sql }) {
|
||||
lastActivity = new Date().getTime();
|
||||
|
||||
@@ -323,6 +363,7 @@ function handlePing() {
|
||||
const messageHandlers = {
|
||||
connect: handleConnect,
|
||||
executeQuery: handleExecuteQuery,
|
||||
executeControlCommand: handleExecuteControlCommand,
|
||||
executeReader: handleExecuteReader,
|
||||
startProfiler: handleStartProfiler,
|
||||
stopProfiler: handleStopProfiler,
|
||||
|
||||
Reference in New Issue
Block a user