Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(grid): 无主键表行定位器降级覆盖首开与刷新路径,修复 Hologres 单击表仍报错 (#12647) (#13007)

ericbyzfa93cfeb675a
diff --git a/apps/desktop/src/components/grid/DataGrid.vue b/apps/desktop/src/components/grid/DataGrid.vue
index 38c6ee2e8a..fddde248ff 100644
--- a/apps/desktop/src/components/grid/DataGrid.vue
+++ b/apps/desktop/src/components/grid/DataGrid.vue
@@ -140,6 +140,7 @@ import {
shouldIncludeSyntheticRowId,
showsKeylessEditWarning,
} from "@/lib/table/tableEditing";
+import { rowIdLocatorUnsupported } from "@/lib/table/tableRowIdSupport";
import { buildDataGridConditionalUpdateSql, buildDataGridContextFilterCondition, buildDataGridCountSql, buildHiveTablePropertiesSql, type DataGridContextFilterMode } from "@/lib/dataGrid/dataGridSql";
import { sumGridCountValues } from "@/lib/dataGrid/dataGridCountValue";
import {
@@ -4538,7 +4539,7 @@ async function refreshSavedRows(request: { dirtyRows: ReadonlyMap<number, Readon
...largeValuePreviewOptions,
whereInput: identityConditions.join(" OR "),
limit: planResult.plan.sourceIndexes.length + 1,
- includeRowId: shouldIncludeSyntheticRowId(resolvedDatabaseType.value, tableMeta.primaryKeys, tableMeta.tableType),
+ includeRowId: shouldIncludeSyntheticRowId(resolvedDatabaseType.value, tableMeta.primaryKeys, tableMeta.tableType) && !(props.connectionId && rowIdLocatorUnsupported(props.connectionId)),
});
const refreshed = await executeDataGridSavedRowRefreshQuery(api, {
connectionId,
@@ -7724,7 +7725,7 @@ async function applyOrderBySearch(_value?: string, structuredOrderByOverride?: s
injectDefaultTimeSeriesWhere: true,
limit: pageSize.value,
whereInput: currentWhereInput(),
- includeRowId: shouldIncludeSyntheticRowId(resolvedDatabaseType.value, tableMeta.primaryKeys, tableMeta.tableType),
+ includeRowId: shouldIncludeSyntheticRowId(resolvedDatabaseType.value, tableMeta.primaryKeys, tableMeta.tableType) && !(props.connectionId && rowIdLocatorUnsupported(props.connectionId)),
});
markConditionInputsApplied();
await props.onExecuteSql(sql);
@@ -7767,7 +7768,7 @@ async function applyWhereFilter() {
limit: pageSize.value,
injectDefaultTimeSeriesWhere: true,
whereInput,
- includeRowId: shouldIncludeSyntheticRowId(resolvedDatabaseType.value, tableMeta.primaryKeys, tableMeta.tableType),
+ includeRowId: shouldIncludeSyntheticRowId(resolvedDatabaseType.value, tableMeta.primaryKeys, tableMeta.tableType) && !(props.connectionId && rowIdLocatorUnsupported(props.connectionId)),
});
markConditionInputsApplied();
await props.onExecuteSql(sql);
diff --git a/apps/desktop/src/composables/__tests__/useSidebarDataOpenRuntime.spec.ts b/apps/desktop/src/composables/__tests__/useSidebarDataOpenRuntime.spec.ts
index 9709e5a7e3..6145601c0b 100644
--- a/apps/desktop/src/composables/__tests__/useSidebarDataOpenRuntime.spec.ts
+++ b/apps/desktop/src/composables/__tests__/useSidebarDataOpenRuntime.spec.ts
@@ -1,5 +1,6 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { useSidebarDataOpenRuntime } from "@/composables/useSidebarDataOpenRuntime";
+import { markRowIdLocatorUnsupported, resetRowIdLocatorStateForTests, rowIdLocatorUnsupported } from "@/lib/table/tableRowIdSupport";
import type { DataTabReuseMode } from "@/lib/tabs/dataTabReuseMode";
import type { QueryTab, TreeNode } from "@/types/database";
@@ -14,6 +15,7 @@ const mocks = vi.hoisted(() => ({
dataTabReuseMode: "same-table" as DataTabReuseMode,
openDataTabsNextToActive: false,
metadataGeneration: 0,
+ includeSyntheticRowId: false,
ensureConnected: vi.fn(),
warmConnection: vi.fn(),
executeTabSql: vi.fn(),
@@ -135,12 +137,13 @@ vi.mock("@/lib/backend/debugLog", () => ({ appendDebugLog: vi.fn(), isDebugLoggi
vi.mock("@/lib/sidebar/treeNodeContext", () => ({ hasTreeNodeDatabaseContext: () => true }));
vi.mock("@/lib/table/tableSelectSql", async (importOriginal) => ({ ...(await importOriginal<typeof import("@/lib/table/tableSelectSql")>()), buildTableSelectSql: mocks.buildTableSelectSql }));
vi.mock("@/lib/table/tableEditing", () => ({
+ DBX_ROWID_COLUMN: "__DBX_ROWID",
physicalTablePrimaryKeys: (columns: Array<{ name: string; is_primary_key: boolean }>, indexes: Array<{ columns: string[]; is_primary: boolean }> = []) => {
const columnPrimaryKeys = columns.filter((column) => column.is_primary_key).map((column) => column.name);
return columnPrimaryKeys.length > 0 ? columnPrimaryKeys : (indexes.find((index) => index.is_primary && index.columns.length > 0)?.columns ?? []);
},
usesSyntheticRowIdKey: () => false,
- shouldIncludeSyntheticRowId: () => false,
+ shouldIncludeSyntheticRowId: () => mocks.includeSyntheticRowId,
}));
vi.mock("@/lib/table/tableOpenPageLimit", () => ({ tableOpenPageLimit: () => 100 }));
vi.mock("@/lib/tabs/dataTabActivation", () => ({ canActivateExistingDataTableTab: () => false }));
@@ -175,10 +178,18 @@ describe("useSidebarDataOpenRuntime", () => {
mocks.dataTabReuseMode = "same-table";
mocks.openDataTabsNextToActive = false;
mocks.metadataGeneration = 0;
+ mocks.includeSyntheticRowId = false;
+ resetRowIdLocatorStateForTests();
mocks.ensureConnected.mockResolvedValue(undefined);
mocks.buildTableSelectSql.mockResolvedValue("SELECT * FROM users");
- mocks.executeTabSql.mockImplementation(async () => {
+ mocks.executeTabSql.mockImplementation(async (tabId: string) => {
mocks.callOrder.push("query");
+ const tab = mocks.tabs.find((candidate) => candidate.id === tabId);
+ if (tab) {
+ tab.isExecuting = false;
+ tab.executionId = undefined;
+ }
+ return true;
});
mocks.loadTableMetadata.mockImplementation(async () => {
mocks.callOrder.push("metadata");
@@ -263,6 +274,230 @@ describe("useSidebarDataOpenRuntime", () => {
});
});
+ it("does not let a stale row-id fallback overwrite a newer navigation", async () => {
+ mocks.databaseType = "postgres";
+ mocks.includeSyntheticRowId = true;
+ mocks.loadTableMetadata.mockResolvedValue({
+ metadata: {
+ schema: "public",
+ tableName: "users",
+ tableType: "TABLE",
+ database: "app",
+ columns: [{ name: "value", data_type: "text", is_nullable: true, column_default: null, is_primary_key: false, extra: null }],
+ indexes: [],
+ primaryKeys: [],
+ cachedAt: Date.now(),
+ },
+ cacheStatus: "miss",
+ ageMs: 0,
+ });
+ const locatorSql = 'SELECT tableoid::text AS "__DBX_ROWID", * FROM public.users';
+ const fallbackSql = "SELECT * FROM public.users";
+ let releaseFallbackSql!: (sql: string) => void;
+ mocks.buildTableSelectSql.mockResolvedValueOnce(locatorSql).mockReturnValueOnce(
+ new Promise((resolve) => {
+ releaseFallbackSql = resolve;
+ }),
+ );
+ mocks.executeTabSql.mockImplementationOnce(async (tabId: string, sql: string) => {
+ const tab = mocks.tabs.find((candidate) => candidate.id === tabId)!;
+ tab.lastExecutedSql = sql;
+ tab.result = { columns: ["Error"], rows: [["column tableoid does not exist"]], affected_rows: 0, execution_time_ms: 1, execution_error: true } as any;
+ tab.resultViewGeneration = "failed-locator";
+ tab.isExecuting = false;
+ tab.executionId = undefined;
+ return true;
+ });
+
+ let current = true;
+ const request = {
+ isCurrent: () => current,
+ signal: new AbortController().signal,
+ registerCancel: () => {},
+ };
+ const open = useSidebarDataOpenRuntime().openData(tableNode, request);
+ await vi.waitFor(() => expect(mocks.buildTableSelectSql).toHaveBeenCalledTimes(2));
+ const tab = mocks.tabs[0]!;
+ current = false;
+ tab.sql = "SELECT 'newer'";
+ tab.lastExecutedSql = "SELECT 'newer'";
+ tab.result = { columns: ["newer"], rows: [[1]], affected_rows: 0, execution_time_ms: 1 } as any;
+ tab.resultViewGeneration = "newer-result";
+
+ releaseFallbackSql(fallbackSql);
+ await open;
+
+ expect(tab.sql).toBe("SELECT 'newer'");
+ expect(tab.result?.columns).toEqual(["newer"]);
+ expect(mocks.executeTabSql).toHaveBeenCalledTimes(1);
+ expect(rowIdLocatorUnsupported("connection-1")).toBe(false);
+ });
+
+ it("does not start a row-id fallback when the failed execution was superseded before publishing", async () => {
+ mocks.databaseType = "postgres";
+ mocks.includeSyntheticRowId = true;
+ const locatorSql = 'SELECT tableoid::text AS "__DBX_ROWID", * FROM public.users';
+ mocks.buildTableSelectSql.mockResolvedValue(locatorSql);
+ let releaseFailedExecution!: (published: boolean) => void;
+ mocks.executeTabSql.mockReturnValueOnce(
+ new Promise((resolve) => {
+ releaseFailedExecution = resolve;
+ }),
+ );
+ let current = true;
+ const request = {
+ isCurrent: () => current,
+ signal: new AbortController().signal,
+ registerCancel: () => {},
+ };
+
+ const open = useSidebarDataOpenRuntime().openData(tableNode, request);
+ await vi.waitFor(() => expect(mocks.executeTabSql).toHaveBeenCalledTimes(1));
+ const tab = mocks.tabs[0]!;
+ current = false;
+ tab.sql = "SELECT 'newer'";
+ tab.result = { columns: ["newer"], rows: [[1]], affected_rows: 0, execution_time_ms: 1 } as any;
+ tab.resultViewGeneration = "newer-result";
+ tab.isExecuting = false;
+ tab.executionId = undefined;
+ releaseFailedExecution(false);
+ await open;
+
+ expect(mocks.buildTableSelectSql).toHaveBeenCalledTimes(1);
+ expect(mocks.executeTabSql).toHaveBeenCalledTimes(1);
+ expect(tab.sql).toBe("SELECT 'newer'");
+ expect(rowIdLocatorUnsupported("connection-1")).toBe(false);
+ });
+
+ it("still lands preparation failures while the flow owns the tab", async () => {
+ mocks.ensureConnected.mockRejectedValue(new Error("connection refused"));
+
+ await useSidebarDataOpenRuntime().openData(tableNode);
+
+ expect(mocks.setErrorResult).toHaveBeenCalledTimes(1);
+ expect(mocks.setErrorResult).toHaveBeenCalledWith("tab-1", expect.any(Error));
+ });
+
+ it("does not land a late ensure-connected failure over a newer execution on the same tab", async () => {
+ let rejectEnsureConnected!: (error: unknown) => void;
+ mocks.ensureConnected.mockImplementation(
+ () =>
+ new Promise((_resolve, reject) => {
+ rejectEnsureConnected = reject;
+ }),
+ );
+
+ const open = useSidebarDataOpenRuntime().openData(tableNode);
+ await vi.waitFor(() => expect(mocks.ensureConnected).toHaveBeenCalledTimes(1));
+ const tab = mocks.tabs[0]!;
+ // 同页签的手动执行接管:替换 executionId 并进入执行态,导航代次不变
+ tab.executionId = "newer-execution";
+ tab.isExecuting = true;
+
+ rejectEnsureConnected(new Error("old preparation failed"));
+ await open;
+
+ expect(mocks.setErrorResult).not.toHaveBeenCalled();
+ expect(tab.executionId).toBe("newer-execution");
+ expect(tab.isExecuting).toBe(true);
+ });
+
+ it("does not land a late first-SQL-build failure over a newer execution on the same tab", async () => {
+ let rejectBuildOpenSql!: (error: unknown) => void;
+ mocks.buildTableSelectSql.mockImplementation(
+ () =>
+ new Promise((_resolve, reject) => {
+ rejectBuildOpenSql = reject;
+ }),
+ );
+
+ const open = useSidebarDataOpenRuntime().openData(tableNode);
+ await vi.waitFor(() => expect(mocks.buildTableSelectSql).toHaveBeenCalledTimes(1));
+ const tab = mocks.tabs[0]!;
+ tab.executionId = "newer-execution";
+ tab.isExecuting = true;
+
+ rejectBuildOpenSql(new Error("old preparation failed"));
+ await open;
+
+ expect(mocks.setErrorResult).not.toHaveBeenCalled();
+ expect(mocks.buildTableSelectSql).toHaveBeenCalledTimes(1);
+ expect(tab.executionId).toBe("newer-execution");
+ expect(tab.isExecuting).toBe(true);
+ });
+
+ it("retries an already-issued row-id query after another request caches the unsupported capability", async () => {
+ mocks.databaseType = "postgres";
+ mocks.includeSyntheticRowId = true;
+ const locatorSql = 'SELECT tableoid::text AS "__DBX_ROWID", * FROM public.users';
+ const fallbackSql = "SELECT * FROM public.users";
+ mocks.buildTableSelectSql.mockResolvedValueOnce(locatorSql).mockResolvedValueOnce(fallbackSql);
+ let releaseLocatorFailure!: () => void;
+ mocks.executeTabSql
+ .mockImplementationOnce(
+ (tabId: string) =>
+ new Promise<boolean>((resolve) => {
+ releaseLocatorFailure = () => {
+ const tab = mocks.tabs.find((candidate) => candidate.id === tabId)!;
+ tab.result = { columns: ["Error"], rows: [["column tableoid does not exist"]], affected_rows: 0, execution_time_ms: 1, execution_error: true } as any;
+ tab.resultViewGeneration = "failed-locator";
+ tab.isExecuting = false;
+ tab.executionId = undefined;
+ resolve(true);
+ };
+ }),
+ )
+ .mockImplementationOnce(async (tabId: string) => {
+ const tab = mocks.tabs.find((candidate) => candidate.id === tabId)!;
+ tab.result = { columns: ["value"], rows: [["ok"]], affected_rows: 0, execution_time_ms: 1 } as any;
+ tab.resultViewGeneration = "fallback-result";
+ tab.isExecuting = false;
+ tab.executionId = undefined;
+ return true;
+ });
+
+ const open = useSidebarDataOpenRuntime().openData(tableNode);
+ await vi.waitFor(() => expect(mocks.executeTabSql).toHaveBeenCalledTimes(1));
+ markRowIdLocatorUnsupported("connection-1");
+ releaseLocatorFailure();
+ await open;
+
+ expect(mocks.executeTabSql).toHaveBeenCalledTimes(2);
+ expect(mocks.executeTabSql).toHaveBeenLastCalledWith("tab-1", fallbackSql, expect.any(Object));
+ expect(mocks.tabs[0]?.result?.columns).toEqual(["value"]);
+ });
+
+ it("applies the default sort to a successful row-id fallback result", async () => {
+ mocks.databaseType = "postgres";
+ mocks.includeSyntheticRowId = true;
+ mocks.tableOpenSortMode = "local";
+ const locatorSql = 'SELECT tableoid::text AS "__DBX_ROWID", * FROM public.users';
+ const fallbackSql = "SELECT * FROM public.users";
+ mocks.buildTableSelectSql.mockResolvedValueOnce(locatorSql).mockResolvedValueOnce(fallbackSql);
+ mocks.executeTabSql
+ .mockImplementationOnce(async (tabId: string) => {
+ const tab = mocks.tabs.find((candidate) => candidate.id === tabId)!;
+ tab.result = { columns: ["Error"], rows: [["column tableoid does not exist"]], affected_rows: 0, execution_time_ms: 1, execution_error: true } as any;
+ tab.resultViewGeneration = "failed-locator";
+ tab.isExecuting = false;
+ tab.executionId = undefined;
+ return true;
+ })
+ .mockImplementationOnce(async (tabId: string) => {
+ const tab = mocks.tabs.find((candidate) => candidate.id === tabId)!;
+ tab.result = { columns: ["id"], rows: [[2], [1]], affected_rows: 0, execution_time_ms: 1 } as any;
+ tab.resultViewGeneration = "fallback-result";
+ tab.isExecuting = false;
+ tab.executionId = undefined;
+ return true;
+ });
+
+ await useSidebarDataOpenRuntime().openData(tableNode);
+
+ expect(mocks.tabs[0]?.sql).toBe(fallbackSql);
+ expect(mocks.sortTabResultLocally).toHaveBeenCalledWith("tab-1", "id", 0, "asc");
+ });
+
it("keeps adjacent placement for every tab created in always-new mode", async () => {
mocks.dataTabReuseMode = "always-new";
mocks.openDataTabsNextToActive = true;
diff --git a/apps/desktop/src/composables/useDataGridActions.ts b/apps/desktop/src/composables/useDataGridActions.ts
index fa8b90e1d5..c38cfbce28 100644
--- a/apps/desktop/src/composables/useDataGridActions.ts
+++ b/apps/desktop/src/composables/useDataGridActions.ts
@@ -9,7 +9,7 @@ import { tableOpenPageLimit } from "@/lib/table/tableOpenPageLimit";
import { tableDataLargeValuePreviewOptions, tableDataPreviewRowBudget } from "@/lib/dataGrid/dataGridLargeValues";
import { elasticsearchCursorPageJumpRequestCount } from "@/lib/dataGrid/dataGridPagination";
import { editablePrimaryKeys, shouldIncludeSyntheticRowId } from "@/lib/table/tableEditing";
-import { markRowIdLocatorSupported, markRowIdLocatorUnsupported, rowIdLocatorUnsupported, shouldKeepRowIdLocatorDisabled, shouldRetryWithoutRowIdLocator } from "@/lib/table/tableRowIdSupport";
+import { markRowIdLocatorUnsupported, rowIdLocatorUnsupported, shouldKeepRowIdLocatorDisabled, shouldRetryWithoutRowIdLocator } from "@/lib/table/tableRowIdSupport";
import { tableMetaForDataTab } from "@/lib/table/tableDataTabMeta";
import { loadVirtualRowIdentifier } from "@/lib/table/virtualRowIdentifier";
import * as api from "@/lib/backend/api";
@@ -110,15 +110,15 @@ export function useDataGridActions(activeTab: ComputedRef<QueryTab | undefined>)
return typeof limit === "number" && limit > 0 ? { limit, offset: 0 } : undefined;
}
- function buildTableSql(tab: QueryTab, options: { orderBy?: string; limit?: number; offset?: number; whereInput?: string; previewPageSize?: number } = {}): Promise<string> {
- const { previewPageSize, ...sqlOptions } = options;
+ function buildTableSql(tab: QueryTab, options: { orderBy?: string; limit?: number; offset?: number; whereInput?: string; previewPageSize?: number; includeRowId?: boolean } = {}): Promise<string> {
+ const { previewPageSize, includeRowId, ...sqlOptions } = options;
const config = connectionStore.getConfig(tab.connectionId);
const effectiveDbType = effectiveDatabaseTypeForConnection(config);
const tableMeta = tableMetaForDataTab(tab);
const primaryKeys = tab.tableMeta ? tab.tableMeta.primaryKeys : (tableMeta?.primaryKeys ?? []);
// 已确认该连接拒绝合成行定位器(如 Hologres 拒绝 tableoid,#12647)时不再注入,
// 避免无主键表每次打开都报错。
- const useRowId = shouldIncludeSyntheticRowId(effectiveDbType, primaryKeys, tableMeta?.tableType) && !rowIdLocatorUnsupported(tab.connectionId);
+ const useRowId = includeRowId ?? (shouldIncludeSyntheticRowId(effectiveDbType, primaryKeys, tableMeta?.tableType) && !rowIdLocatorUnsupported(tab.connectionId));
// 列投影只信任真实元数据列:tableMetaForDataTab 的 fallback 列来自查询
// 结果(可能是失败结果的 ["Error"]),进入 SQL 会生成非法投影;
// 真实列缺失时省略 columns 让 builder 生成 SELECT *
@@ -149,18 +149,17 @@ export function useDataGridActions(activeTab: ComputedRef<QueryTab | undefined>)
// 行定位器被服务端拒绝时的降级执行(#12647):首次带定位器的加载失败后,
// 去掉定位器重试一次;重试成功才记住该连接,之后由 buildTableSql 直接跳过
- // 定位器。重试也失败则还原标记,让真实的服务端错误可见。
+ // 定位器。重试失败不改共享能力状态,让真实的服务端错误可见。
async function executeTableDataSqlWithRowIdFallback(tab: QueryTab, sql: string, executeOptions: Parameters<typeof queryStore.executeTabSql>[2], rebuildSql: () => Promise<string>): Promise<void> {
await queryStore.executeTabSql(tab.id, sql, executeOptions);
- if (!shouldRetryWithoutRowIdLocator(sql, tab.connectionId, tabResultFor(tab))) return;
- markRowIdLocatorUnsupported(tab.connectionId);
+ if (!shouldRetryWithoutRowIdLocator(sql, tabResultFor(tab))) return;
try {
const fallbackSql = await rebuildSql();
queryStore.updateSql(tab.id, fallbackSql);
await queryStore.executeTabSql(tab.id, fallbackSql, executeOptions);
- if (!shouldKeepRowIdLocatorDisabled(tabResultFor(tab))) markRowIdLocatorSupported(tab.connectionId);
+ if (shouldKeepRowIdLocatorDisabled(tabResultFor(tab))) markRowIdLocatorUnsupported(tab.connectionId);
} catch {
- markRowIdLocatorSupported(tab.connectionId);
+ // Keep the fallback/build error visible without changing shared capability memory.
}
}
@@ -460,7 +459,7 @@ export function useDataGridActions(activeTab: ComputedRef<QueryTab | undefined>)
pagination: { limit: pageLimit, offset: pageOffset },
preserveResultDuringExecution: true,
},
- () => buildTableSql(tab, { whereInput, orderBy: incomingSortMissing ? undefined : orderBy, limit: pageLimit, offset: pageOffset }),
+ () => buildTableSql(tab, { whereInput, orderBy: incomingSortMissing ? undefined : orderBy, limit: pageLimit, offset: pageOffset, includeRowId: false }),
);
} else {
await queryStore.executeTabSql(tab.id, nextSql, {
@@ -683,6 +682,7 @@ export function useDataGridActions(activeTab: ComputedRef<QueryTab | undefined>)
offset,
whereInput,
orderBy: orderBy ?? tab.orderByInput,
+ includeRowId: false,
previewPageSize: tableDataPreviewRowBudget({
limit,
offset,
diff --git a/apps/desktop/src/composables/useSidebarDataOpenRuntime.ts b/apps/desktop/src/composables/useSidebarDataOpenRuntime.ts
index 6a36f71a53..1a039629cd 100644
--- a/apps/desktop/src/composables/useSidebarDataOpenRuntime.ts
+++ b/apps/desktop/src/composables/useSidebarDataOpenRuntime.ts
@@ -14,6 +14,7 @@ import { hasTreeNodeDatabaseContext } from "@/lib/sidebar/treeNodeContext";
import { buildTableSelectSql, requiresEagerTableMetadataForDataOpen } from "@/lib/table/tableSelectSql";
import { resolveTableDefaultSort, applyTableDefaultSortResult } from "@/lib/table/tableDefaultSort";
import { physicalTablePrimaryKeys, shouldIncludeSyntheticRowId } from "@/lib/table/tableEditing";
+import { markRowIdLocatorUnsupported, rowIdLocatorUnsupported, shouldKeepRowIdLocatorDisabled, shouldRetryWithoutRowIdLocator } from "@/lib/table/tableRowIdSupport";
import { tableOpenPageLimit } from "@/lib/table/tableOpenPageLimit";
import { tableDataLargeValuePreviewOptions } from "@/lib/dataGrid/dataGridLargeValues";
import { canActivateExistingDataTableTab } from "@/lib/tabs/dataTabActivation";
@@ -266,6 +267,7 @@ export function useSidebarDataOpenRuntime() {
// 接管该 tab:登记本次导航代次,作废在途的 openTableTarget/openData 旧代次
// ——旧导航即使目标身份相同(同表不同 whereInput)也不得再落地
const navigationToken = beginDataTabNavigation(tabId);
+ const ownsNavigation = () => isCurrentDataTabNavigation(tabId, navigationToken) && (request?.isCurrent() ?? true) && options.isCurrent?.() !== false;
// Cancel any previous execution on this tab before starting a new one
const existingTab = queryStore.tabs.find((t) => t.id === tabId);
@@ -274,14 +276,12 @@ export function useSidebarDataOpenRuntime() {
logPhase("previous-execution-cancelled", { tabId });
// 取消等待期间可能有更晚的导航(openTableTarget/openData)接管本 tab:
// 本代次已作废,不得再写占位元数据/executionId 覆盖新导航
- if (!isCurrentDataTabNavigation(tabId, navigationToken) || options.isCurrent?.() === false) {
+ if (!ownsNavigation()) {
logPhase("superseded-during-cancel", { tabId });
+ endDataTabNavigation(tabId, navigationToken);
return;
}
}
- // 取消窗口之后由 executionId 比对(isActive)保护,代次使命完成即注销;
- // 已作废的旧 token 不因删除而复活(比对按 token 同一性)
- endDataTabNavigation(tabId, navigationToken);
const openDataId = uuid();
// Clear previous result so DataGrid doesn't show its internal loading overlay (without stop button)
@@ -350,7 +350,21 @@ export function useSidebarDataOpenRuntime() {
await nextTick();
// Helper to check if this openData call is still active (not superseded by a newer click)
- const isActive = () => (request?.isCurrent() ?? true) && queryStore.tabs.find((t) => t.id === tabId)?.executionId === openDataId;
+ const isActive = () => ownsNavigation() && queryStore.tabs.find((t) => t.id === tabId)?.executionId === openDataId;
+
+ // 执行发布后的结果身份:executeTabSql 启动即把 tab.executionId 换成其内部
+ // 执行 id,此后 isActive 不再可用。执行后的错误落地改按"本流程发布的
+ // 结果仍在 tab 上"判定,而不是仅靠导航 token——导航 token 识别不了
+ // 同页签新手动执行对 executionId 的替换(#13007 复审 P1)。
+ let publishedTab: (typeof queryStore.tabs)[number] | undefined;
+ let publishedResult: (typeof queryStore.tabs)[number]["result"];
+ let publishedResultGeneration: (typeof queryStore.tabs)[number]["resultViewGeneration"];
+ let ownsPublishedResult = false;
+ const stillOwnsPublishedResult = () => {
+ if (!ownsPublishedResult) return false;
+ const current = queryStore.tabs.find((item) => item.id === tabId);
+ return !!current && ownsNavigation() && current === publishedTab && !current.isExecuting && current.executionId === undefined && current.result === publishedResult && current.resultViewGeneration === publishedResultGeneration;
+ };
try {
openDataLog("info", "ensure-connected:start", { traceId, elapsed: elapsed() });
@@ -403,26 +417,31 @@ export function useSidebarDataOpenRuntime() {
const primaryKeys = loadedTableMeta?.primaryKeys ?? [];
const defaultSort = resolveTableDefaultSort(settingsStore.editorSettings, effectiveDbType, loadedTableMeta?.physicalPrimaryKeys ?? physicalTablePrimaryKeys(columns), connectionStore.connectionIdentifierQuote?.(node.connectionId));
const defaultOrderBy = defaultSort.orderBy;
- const includeRowId = shouldIncludeSyntheticRowId(effectiveDbType, primaryKeys, tableType);
- const sql = await buildTableSelectSql({
- databaseType: effectiveDbType,
- driverProfile: config?.driver_profile || (config?.db_type === "gbase8s" ? "gbase8s" : undefined),
- serverVersion: connectionStore.getConfig(node.connectionId)?.database_info?.productVersion,
- identifierQuote: connectionStore.connectionIdentifierQuote?.(node.connectionId),
- schema: connectionTableSqlSchema(config, tableSchema),
- database: node.database,
- tableName: node.label,
- tableType,
- catalog: node.catalog,
- columns: columns.map((column) => column.name),
- primaryKeys,
- ...tableDataLargeValuePreviewOptions(effectiveDbType, columns, primaryKeys, limit),
- includeDatabaseName: settingsStore.editorSettings.generateSqlIncludeDatabaseName,
- limit,
- includeRowId,
- injectDefaultTimeSeriesWhere: true,
- orderBy: defaultOrderBy,
- });
+ // #12647:首开路径同样尊重"该连接的行定位器已被引擎拒绝"的记忆,否则
+ // 被降级过的连接每次重新单击表都会再发一次注定失败的定位器查询。
+ const includeRowId = shouldIncludeSyntheticRowId(effectiveDbType, primaryKeys, tableType) && !rowIdLocatorUnsupported(node.connectionId);
+ const buildOpenSql = (withRowId: boolean) =>
+ buildTableSelectSql({
+ databaseType: effectiveDbType,
+ driverProfile: config?.driver_profile || (config?.db_type === "gbase8s" ? "gbase8s" : undefined),
+ serverVersion: connectionStore.getConfig(node.connectionId)?.database_info?.productVersion,
+ identifierQuote: connectionStore.connectionIdentifierQuote?.(node.connectionId),
+ schema: connectionTableSqlSchema(config, tableSchema),
+ database: node.database,
+ tableName: node.label,
+ tableType,
+ catalog: node.catalog,
+ columns: columns.map((column) => column.name),
+ primaryKeys,
+ ...tableDataLargeValuePreviewOptions(effectiveDbType, columns, primaryKeys, limit),
+ includeDatabaseName: settingsStore.editorSettings.generateSqlIncludeDatabaseName,
+ limit,
+ includeRowId: withRowId,
+ injectDefaultTimeSeriesWhere: true,
+ orderBy: defaultOrderBy,
+ });
+ const sql = await buildOpenSql(includeRowId);
+ let finalExecutedSql = sql;
// SQL 构建是异步后端调用:期间更晚的导航(openData/openTableTarget)
// 接管会替换 executionId,旧流程不得再覆盖 SQL/启动查询
if (!isActive()) {
@@ -443,14 +462,59 @@ export function useSidebarDataOpenRuntime() {
logPhase("sql-updated", { tabId });
openDataLog("info", "execute:start", { traceId, tabId, elapsed: elapsed() });
- await queryStore.executeTabSql(tabId, sql, {
- sourceTraceId: traceId,
- skipEnsureConnected: true,
- pagination: { limit, offset: 0 },
- });
+ const executeOptions = { sourceTraceId: traceId, skipEnsureConnected: true, pagination: { limit, offset: 0 } };
+ let openExecuteError: unknown = undefined;
+ let openExecutePublished: boolean | undefined;
+ let landedOpenExecuteError = false;
+ try {
+ openExecutePublished = await queryStore.executeTabSql(tabId, sql, executeOptions);
+ } catch (error) {
+ openExecuteError = error;
+ }
+ // 行定位器被引擎拒绝时的降级(#12647):首开路径与 reload 路径保持同一
+ // 降级语义——去掉定位器重试一次,成功后才记住该连接;失败不更新能力
+ // 标记,让真实的服务端错误可见。执行失败既可能以异常上抛,也可能落成带
+ // execution_error 的结果,两种形态都归一到结果上再判定。
+ if (openExecuteError !== undefined) {
+ const failedTab = queryStore.tabs.find((item) => item.id === tabId);
+ if (ownsNavigation() && failedTab && openedTab && failedTab === openedTab && !failedTab.isExecuting && !failedTab.result) {
+ queryStore.setErrorResult(tabId, openExecuteError);
+ landedOpenExecuteError = true;
+ }
+ }
+ const failedTab = queryStore.tabs.find((item) => item.id === tabId);
+ if (openExecutePublished === false || !ownsNavigation() || !failedTab || !openedTab || failedTab !== openedTab || failedTab.isExecuting) return;
+ // 只有能证明当前结果是本流程发布/归一的,才把它登记为本流程的结果身
+ // 份:执行以异常收场且上方的 setErrorResult 没有落地(结果已被占用,
+ // 可能属于已完成的同页签新执行)时,本流程不得再基于当前结果降级或
+ // 落地错误。执行成功发布(true)或结果为空时当前结果即本流程的。
+ if (openExecuteError !== undefined && !landedOpenExecuteError) return;
+ publishedTab = failedTab;
+ publishedResult = failedTab.result;
+ publishedResultGeneration = failedTab.resultViewGeneration;
+ ownsPublishedResult = true;
+ if (shouldRetryWithoutRowIdLocator(sql, publishedResult)) {
+ try {
+ const fallbackSql = await buildOpenSql(false);
+ if (!stillOwnsPublishedResult()) return;
+ queryStore.updateSql(tabId, fallbackSql);
+ const fallbackPublished = await queryStore.executeTabSql(tabId, fallbackSql, executeOptions);
+ const retryTab = queryStore.tabs.find((item) => item.id === tabId);
+ if (fallbackPublished === false || !ownsNavigation() || !retryTab || retryTab !== openedTab || retryTab.isExecuting) {
+ return;
+ }
+ finalExecutedSql = fallbackSql;
+ if (shouldKeepRowIdLocatorDisabled(retryTab.result)) markRowIdLocatorUnsupported(node.connectionId);
+ } catch {
+ // Fallback execution keeps its own error result visible and must not
+ // change the connection capability memory.
+ }
+ } else if (openExecuteError !== undefined) {
+ throw openExecuteError;
+ }
openDataLog("info", "execute:done", { traceId, tabId, elapsed: elapsed() });
const sortedTab = queryStore.tabs.find((item) => item.id === tabId);
- if ((request?.isCurrent() ?? true) && sortedTab && sortedTab === openedTab && sortedTab.sql === sql) {
+ if ((request?.isCurrent() ?? true) && sortedTab && sortedTab === openedTab && sortedTab.sql === finalExecutedSql) {
applyTableDefaultSortResult(sortedTab, defaultSort, queryStore.sortTabResultLocally);
}
logPhase("execute-tab-sql", { tabId });
@@ -459,13 +523,20 @@ export function useSidebarDataOpenRuntime() {
logPhase("metadata-started", { tabId, deferredForTransport: isNavicatMysqlTunnel ? "navicat_mysql" : "driver" });
}
} catch (e: any) {
- if (!isActive()) {
+ // 准备阶段(连接/元数据/SQL 构建)的失败仍按执行身份判定所有权:同页签
+ // 的新手动执行会替换 executionId,导航 token 看不见这次替换,旧流程不得
+ // 用 setErrorResult 覆盖新执行的执行状态。执行已发布后的失败(上面的
+ // openExecuteError 重抛、结果后处理)改按结果身份判定。
+ const ownsErrorLanding = ownsPublishedResult ? stillOwnsPublishedResult() : isActive();
+ if (!ownsErrorLanding) {
logPhase("superseded-after-error", { tabId });
return;
}
openDataLog("error", "error", { traceId, elapsed: elapsed(), error: e });
logPhase("error", { tabId });
queryStore.setErrorResult(tabId, e);
+ } finally {
+ endDataTabNavigation(tabId, navigationToken);
}
}
diff --git a/apps/desktop/src/lib/table/__tests__/tableRowIdSupport.spec.ts b/apps/desktop/src/lib/table/__tests__/tableRowIdSupport.spec.ts
index e8ca49ecf7..5c4572f583 100644
--- a/apps/desktop/src/lib/table/__tests__/tableRowIdSupport.spec.ts
+++ b/apps/desktop/src/lib/table/__tests__/tableRowIdSupport.spec.ts
@@ -15,15 +15,18 @@ describe("tableRowIdSupport", () => {
});
it("retries once for a failed load whose SQL carried the locator", () => {
- expect(shouldRetryWithoutRowIdLocator(locatorSql, "conn-1", resultOf(true))).toBe(true);
+ expect(shouldRetryWithoutRowIdLocator(locatorSql, resultOf(true))).toBe(true);
});
- it("does not retry successful loads, plain SQL, or already-disabled connections", () => {
- expect(shouldRetryWithoutRowIdLocator(locatorSql, "conn-1", resultOf(false))).toBe(false);
- expect(shouldRetryWithoutRowIdLocator(plainSql, "conn-1", resultOf(true))).toBe(false);
- expect(shouldRetryWithoutRowIdLocator(locatorSql, "conn-1", undefined)).toBe(false);
+ it("does not retry successful loads, plain SQL, or missing results", () => {
+ expect(shouldRetryWithoutRowIdLocator(locatorSql, resultOf(false))).toBe(false);
+ expect(shouldRetryWithoutRowIdLocator(plainSql, resultOf(true))).toBe(false);
+ expect(shouldRetryWithoutRowIdLocator(locatorSql, undefined)).toBe(false);
+ });
+
+ it("still retries an already-issued locator query after another request disables the connection", () => {
markRowIdLocatorUnsupported("conn-1");
- expect(shouldRetryWithoutRowIdLocator(locatorSql, "conn-1", resultOf(true))).toBe(false);
+ expect(shouldRetryWithoutRowIdLocator(locatorSql, resultOf(true))).toBe(true);
});
it("keeps the flag only after a successful fallback and restores it on a failed one", () => {
diff --git a/apps/desktop/src/lib/table/tableRowIdSupport.ts b/apps/desktop/src/lib/table/tableRowIdSupport.ts
index 44c17736d6..7928c72f38 100644
--- a/apps/desktop/src/lib/table/tableRowIdSupport.ts
+++ b/apps/desktop/src/lib/table/tableRowIdSupport.ts
@@ -33,8 +33,12 @@ export function resetRowIdLocatorStateForTests(): void {
}
/** A failed data load whose SQL carried the locator is the retry trigger. */
-export function shouldRetryWithoutRowIdLocator(sql: string, connectionId: string, result: QueryResult | undefined | null): boolean {
- return sql.includes(DBX_ROWID_COLUMN) && !rowIdLocatorUnsupported(connectionId) && !!result && isQueryExecutionErrorResult(result);
+export function shouldRetryWithoutRowIdLocator(sql: string, result: QueryResult | undefined | null): boolean {
+ // The connection capability may have been updated by another tab while this
+ // locator query was already in flight. The SQL itself is the authoritative
+ // record of what was sent; every failed locator-bearing request still needs
+ // its own fallback.
+ return sql.includes(DBX_ROWID_COLUMN) && !!result && isQueryExecutionErrorResult(result);
}
/** Only a successful fallback keeps the flag; a failed one shows the real error. */
diff --git a/apps/desktop/src/stores/__tests__/queryStore.tableDataRefresh.spec.ts b/apps/desktop/src/stores/__tests__/queryStore.tableDataRefresh.spec.ts
index 428a58c5c4..4bf4f2fc33 100644
--- a/apps/desktop/src/stores/__tests__/queryStore.tableDataRefresh.spec.ts
+++ b/apps/desktop/src/stores/__tests__/queryStore.tableDataRefresh.spec.ts
@@ -3,6 +3,7 @@ import { effectScope, nextTick } from "vue";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { clearDataGridStructuredFilterStates, loadDataGridStructuredFilterState, saveDataGridStructuredFilterState } from "@/lib/dataGrid/dataGridFilterBuilderPersistence";
import { clearDataGridSortBuilderMemoryCache, useDataGridSortBuilder } from "@/composables/useDataGridSortBuilder";
+import { resetRowIdLocatorStateForTests, rowIdLocatorUnsupported } from "@/lib/table/tableRowIdSupport";
const mocks = vi.hoisted(() => ({
buildTableSelectSql: vi.fn(),
@@ -64,6 +65,7 @@ describe("queryStore table data refresh", () => {
installLocalStorage();
clearDataGridStructuredFilterStates();
clearDataGridSortBuilderMemoryCache();
+ resetRowIdLocatorStateForTests();
setActivePinia(createPinia());
mocks.metadataGeneration = 0;
mocks.prepareQueryPaginationExecutionPlan.mockResolvedValue({ useAgentResultSession: false });
@@ -1137,6 +1139,52 @@ describe("queryStore table data refresh", () => {
expect(mocks.executeMulti).toHaveBeenCalledTimes(1);
});
+ it.each(["new execution", "closed tab"] as const)("abandons a pending row-id fallback after the tab is owned by a %s", async (supersedingAction) => {
+ const { useQueryStore } = await import("@/stores/queryStore");
+ const store = useQueryStore();
+ const tabId = store.createTab("pg-1", "app", "users", "data", "public");
+ store.setTableMeta(tabId, {
+ schema: "public",
+ tableName: "users",
+ tableType: "TABLE",
+ columns: [{ name: "value", data_type: "text", is_nullable: true, column_default: null, is_primary_key: false, extra: null }],
+ primaryKeys: [],
+ });
+ const locatorSql = 'SELECT tableoid::text AS "__DBX_ROWID", * FROM public.users';
+ const fallbackSql = "SELECT * FROM public.users";
+ let releaseFallbackSql!: (sql: string) => void;
+ mocks.buildTableSelectSql.mockResolvedValueOnce(locatorSql).mockReturnValueOnce(
+ new Promise((resolve) => {
+ releaseFallbackSql = resolve;
+ }),
+ );
+ mocks.executeMulti.mockRejectedValueOnce(new Error("column tableoid does not exist"));
+
+ const refresh = store.refreshDataTab(tabId);
+ await vi.waitFor(() => expect(mocks.buildTableSelectSql).toHaveBeenCalledTimes(2));
+
+ if (supersedingAction === "new execution") {
+ store.updateSql(tabId, "SELECT 'newer'");
+ mocks.executeMulti.mockResolvedValueOnce([{ columns: ["newer"], rows: [[1]], affected_rows: 0, execution_time_ms: 1 }]);
+ await store.executeTabSql(tabId, "SELECT 'newer'");
+ } else {
+ store.closeTab(tabId, { force: true });
+ }
+
+ releaseFallbackSql(fallbackSql);
+ await expect(refresh).resolves.toBe(false);
+
+ expect(mocks.executeMulti).toHaveBeenCalledTimes(supersedingAction === "new execution" ? 2 : 1);
+ if (supersedingAction === "new execution") {
+ const tab = store.tabs.find((candidate) => candidate.id === tabId)!;
+ expect(tab.sql).toBe("SELECT 'newer'");
+ expect(tab.result?.columns).toEqual(["newer"]);
+ } else {
+ expect(store.tabs.some((candidate) => candidate.id === tabId)).toBe(false);
+ }
+ expect(rowIdLocatorUnsupported("pg-1")).toBe(false);
+ });
+
it("returns false for SQL build failures, stores an error result, and clears the busy state", async () => {
const { useQueryStore } = await import("@/stores/queryStore");
const store = useQueryStore();
diff --git a/apps/desktop/src/stores/queryStore.ts b/apps/desktop/src/stores/queryStore.ts
index 0e55af651b..aba974110f 100644
--- a/apps/desktop/src/stores/queryStore.ts
+++ b/apps/desktop/src/stores/queryStore.ts
@@ -84,6 +84,7 @@ import { formatRedisConsoleValue } from "@/lib/redis/redisValuePresentation";
import { usesAgentCursorForQuery, usesAgentCursorForTableData } from "@/lib/database/databaseDriverManifest";
import { connectionIsDorisFamilyCatalogCapable, defaultAutoCommitForDbType, supportsClearableQuerySchema, supportsTransaction, usesOracleStickyTransactionState, usesProvenReadOnlyStickyTransactionState } from "@/lib/database/databaseFeatureSupport";
import { canInsertTableRows, canUseKeylessRowPredicate, DBX_ROWID_COLUMN, shouldIncludeSyntheticRowId, usesSyntheticRowIdKey } from "@/lib/table/tableEditing";
+import { markRowIdLocatorUnsupported, rowIdLocatorUnsupported, shouldKeepRowIdLocatorDisabled, shouldRetryWithoutRowIdLocator } from "@/lib/table/tableRowIdSupport";
import { TABLE_DATA_EXPORT_PAGE_SIZE } from "@/lib/table/tableDataExport";
import { repairRestoredDataTabTableIdentity, tableMetaForDataTab } from "@/lib/table/tableDataTabMeta";
import { isDataTabMetadataLifecycleStale } from "@/lib/sidebar/dataTabOpenPolicy";
@@ -5475,37 +5476,82 @@ export const useQueryStore = defineStore("query", () => {
const offset = tab.resultPageOffset ?? 0;
const useDriverRowOffset = jdbcConnectionUsesDriverRowOffset(conn, effectiveDbType);
- const sql = await buildTableSelectSql({
- databaseType: effectiveDbType,
- driverProfile: conn?.driver_profile,
- serverVersion: conn?.database_info?.productVersion,
- identifierQuote,
- database: tableMeta.database,
- schema: tableMeta.schema,
- tableName: tableMeta.tableName,
- tableType: tableMeta.tableType,
- catalog: tableMeta.catalog,
- columns: tableMeta.columns.map((column) => column.name),
- primaryKeys,
- ...tableDataLargeValuePreviewOptions(effectiveDbType, tableMeta.columns, primaryKeys, limit),
- includeDatabaseName: settingsStore.editorSettings.generateSqlIncludeDatabaseName,
- includeRowId: shouldIncludeSyntheticRowId(effectiveDbType, primaryKeys, tableMeta.tableType),
- whereInput: tab.whereInput,
- injectDefaultTimeSeriesWhere: true,
- orderBy,
- limit,
- offset,
- ...(useDriverRowOffset ? { useDriverRowOffset: true } : {}),
- });
+ // #12647:首开路径同样尊重"该连接的行定位器已被引擎拒绝"的记忆,否则
+ // 被降级过的连接每次重新单击表都会再发一次注定失败的定位器查询。
+ const useRowId = shouldIncludeSyntheticRowId(effectiveDbType, primaryKeys, tableMeta.tableType) && !rowIdLocatorUnsupported(tab.connectionId);
+ const buildRefreshSql = (includeRowId: boolean) =>
+ buildTableSelectSql({
+ databaseType: effectiveDbType,
+ driverProfile: conn?.driver_profile,
+ serverVersion: conn?.database_info?.productVersion,
+ identifierQuote,
+ database: tableMeta.database,
+ schema: tableMeta.schema,
+ tableName: tableMeta.tableName,
+ tableType: tableMeta.tableType,
+ catalog: tableMeta.catalog,
+ columns: tableMeta.columns.map((column) => column.name),
+ primaryKeys,
+ ...tableDataLargeValuePreviewOptions(effectiveDbType, tableMeta.columns, primaryKeys, limit),
+ includeDatabaseName: settingsStore.editorSettings.generateSqlIncludeDatabaseName,
+ includeRowId,
+ whereInput: tab.whereInput,
+ injectDefaultTimeSeriesWhere: true,
+ orderBy,
+ limit,
+ offset,
+ ...(useDriverRowOffset ? { useDriverRowOffset: true } : {}),
+ });
+ const sql = await buildRefreshSql(useRowId);
if (!sql.trim()) throw new Error("Failed to build table refresh SQL");
const current = tabs.value.find((candidate) => candidate.id === id);
if (!current || current.executionId !== refreshPreparationId) return false;
updateSql(tab.id, sql);
- await executeTabSql(tab.id, sql, {
+ const executeOptions = {
pagination: { limit, offset },
preserveResultDuringExecution: true,
- publicationOrigin: "refresh",
- });
+ publicationOrigin: "refresh" as const,
+ };
+ let refreshExecuteError: unknown = undefined;
+ let refreshExecutePublished: boolean | undefined;
+ try {
+ refreshExecutePublished = await executeTabSql(tab.id, sql, executeOptions);
+ } catch (error) {
+ refreshExecuteError = error;
+ }
+ const executedTab = tabs.value.find((candidate) => candidate.id === id);
+ if (refreshExecuteError !== undefined && executedTab === tab && !executedTab.isExecuting && !executedTab.result) {
+ // 执行失败以异常上抛且尚未落结果时,先转成标准错误结果再统一判定。
+ setErrorResult(id, refreshExecuteError);
+ }
+ if (refreshExecutePublished === false || executedTab !== tab || executedTab.isExecuting) return false;
+ const failedResult = executedTab.result;
+ const failedResultGeneration = executedTab.resultViewGeneration;
+ const stillOwnsFailedResult = () => {
+ const current = tabs.value.find((candidate) => candidate.id === id);
+ return current === executedTab && !current.isExecuting && current.executionId === undefined && current.result === failedResult && current.resultViewGeneration === failedResultGeneration;
+ };
+ // 行定位器被引擎拒绝时的降级(#12647):首开/刷新路径与 reload 路径保持
+ // 同一降级语义——去掉定位器重试一次,成功后才记住该连接;失败不更新
+ // 能力标记,让真实的服务端错误可见。
+ if (shouldRetryWithoutRowIdLocator(sql, failedResult)) {
+ try {
+ const fallbackSql = await buildRefreshSql(false);
+ if (!stillOwnsFailedResult()) return false;
+ updateSql(tab.id, fallbackSql);
+ const fallbackPublished = await executeTabSql(tab.id, fallbackSql, executeOptions);
+ const retryTab = tabs.value.find((candidate) => candidate.id === id);
+ if (fallbackPublished === false || retryTab !== tab || retryTab.isExecuting) {
+ return false;
+ }
+ if (shouldKeepRowIdLocatorDisabled(retryTab.result)) markRowIdLocatorUnsupported(tab.connectionId);
+ } catch {
+ // Fallback execution keeps its own error result visible and must not
+ // change the connection capability memory.
+ }
+ } else if (refreshExecuteError !== undefined) {
+ throw refreshExecuteError;
+ }
return true;
} catch (error) {
const current = tabs.value.find((candidate) => candidate.id === id);