fix(editor): hide commit/rollback for clean mysql/pg manual transactions

Closes #9018
This commit is contained in:
Abeautifulsnow authored and GitHub committed 2026-09-16 20:17:55 +08:00
1 parent 91b8fa0aa8
commit e9be6d0419
15 files changed
+1016 -137

No files matched your search

@@ -259,11 +259,21 @@ export function usesPostgresLikeStructureCopy(dbType?: DatabaseType): boolean {
const TRANSACTION_SUPPORTED_TYPES: readonly string[] = ["postgres", "mysql", "oracle", "jdbc", "oceanbase-oracle"];
/** Oracle-family databases that use the sticky manual-transaction UX. OceanBase
* Oracle mode runs the same transaction model as Oracle, so it shares the
* commit/rollback dirty-state behavior rather than the generic transaction path. */
/** Oracle-family databases, kept ONLY for the Oracle-specific ALTER SESSION SET
* CURRENT_SCHEMA compensation in queryStore. Do not use for toolbar/dirty-bit
* gating — that is {@link usesProvenReadOnlyStickyTransactionState} so MySQL and
* PostgreSQL participate without dragging Oracle schema-change compensation in. */
const ORACLE_STICKY_TRANSACTION_TYPES: ReadonlySet<string> = new Set(["oracle", "oceanbase-oracle"]);
/** Databases whose manual-transaction toolbar hides Commit/Rollback until an
* unproven statement dirties the session. Mirrors the Rust proof gate
* (crates/dbx-core/src/query.rs + sql_risk.rs `prove_read_only_for_database`).
* Every member must also be in TRANSACTION_SUPPORTED_TYPES above: a database
* cannot reach manual mode (and this UX) without explicit transaction control
* (#9018). Family members like doris/kingbase join only when their transaction
* support lands. */
const PROVEN_READ_ONLY_STICKY_TYPES: ReadonlySet<string> = new Set(["oracle", "oceanbase-oracle", "mysql", "postgres"]);
/**
* Returns true if the given database type supports explicit transaction control
* (i.e. toggling between auto-commit and manual transaction mode via BEGIN/COMMIT).
@@ -317,13 +327,22 @@ export function rejectsAliasReferenceInHaving(dbType?: string): boolean {
}
/**
* Returns true if the database type uses Oracle's sticky manual-transaction state
* (commit/rollback hidden until an unproven statement dirties the session).
* Returns true if the database type participates in Oracle's schema-change
* compensation under manual transactions. Toolbar/dirty-bit gating must use
* `usesProvenReadOnlyStickyTransactionState` instead.
*/
export function usesOracleStickyTransactionState(dbType?: string): boolean {
return !!dbType && ORACLE_STICKY_TRANSACTION_TYPES.has(dbType);
}
/**
* Returns true if the database type uses the sticky manual-transaction UX:
* commit/rollback hidden while the session is clean (no unproven statement).
*/
export function usesProvenReadOnlyStickyTransactionState(dbType?: string): boolean {
return !!dbType && PROVEN_READ_ONLY_STICKY_TYPES.has(dbType);
}
/**
* Default auto-commit mode when opening a query tab for the given database type.
* Query tabs default to auto-commit; users can explicitly switch to manual transactions.