feat(schema): show table properties in object browser

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-09-23 14:43:33 +08:00
1 parent 12ed7a49b3
commit 13d2db6191
22 files changed
+284 -12

No files matched your search

@@ -59,6 +59,18 @@ const overviewRows = computed(() => {
{ label: t("structureEditor.comment"), value: props.overviewComment ?? "" }, { label: t("structureEditor.comment"), value: props.overviewComment ?? "" },
{ label: t("grid.tableInfoEstimatedRows"), value: formatObjectBrowserCount(props.overviewStats?.estimated_rows), mono: true }, { label: t("grid.tableInfoEstimatedRows"), value: formatObjectBrowserCount(props.overviewStats?.estimated_rows), mono: true },
{ label: t("grid.tableInfoTotalSize"), value: formatObjectBrowserBytes(props.overviewStats?.total_bytes), mono: true }, { label: t("grid.tableInfoTotalSize"), value: formatObjectBrowserBytes(props.overviewStats?.total_bytes), mono: true },
{ label: t("grid.tableInfoDataLength"), value: formatObjectBrowserBytes(props.overviewStats?.data_length), mono: true },
{ label: t("grid.tableInfoEngine"), value: props.overviewStats?.engine ?? "", mono: true },
{ label: t("grid.tableInfoCreatedAt"), value: props.overviewStats?.created_at ?? "", mono: true },
{ label: t("grid.tableInfoUpdatedAt"), value: props.overviewStats?.updated_at ?? "", mono: true },
{ label: t("grid.tableInfoCollation"), value: props.overviewStats?.collation ?? "", mono: true },
{ label: t("grid.tableInfoRowFormat"), value: props.overviewStats?.row_format ?? "", mono: true },
{ label: t("grid.tableInfoAvgRowLength"), value: formatObjectBrowserBytes(props.overviewStats?.avg_row_length), mono: true },
{ label: t("grid.tableInfoMaxDataLength"), value: formatObjectBrowserBytes(props.overviewStats?.max_data_length), mono: true },
{ label: t("grid.tableInfoCheckTime"), value: props.overviewStats?.check_time ?? "", mono: true },
{ label: t("grid.tableInfoIndexLength"), value: formatObjectBrowserBytes(props.overviewStats?.index_length), mono: true },
{ label: t("grid.tableInfoAutoIncrement"), value: props.overviewStats?.auto_increment ?? "", mono: true },
{ label: t("grid.tableInfoDataFree"), value: formatObjectBrowserBytes(props.overviewStats?.data_free), mono: true },
]; ];
const query = props.searchQuery.trim().toLowerCase(); const query = props.searchQuery.trim().toLowerCase();
return rows.filter((row) => row.value && (!query || row.label.toLowerCase().includes(query) || row.value.toLowerCase().includes(query))); return rows.filter((row) => row.value && (!query || row.label.toLowerCase().includes(query) || row.value.toLowerCase().includes(query)));
@@ -78,6 +78,7 @@ import { isSchemaAware, supportsTableVacuum, supportsTransfer } from "@/lib/data
import { supportsAiAssistantContext, supportsSchemaDiagram, supportsTableImport, supportsTableStructureEditing, supportsTableTruncate } from "@/lib/database/databaseFeatureSupport"; import { supportsAiAssistantContext, supportsSchemaDiagram, supportsTableImport, supportsTableStructureEditing, supportsTableTruncate } from "@/lib/database/databaseFeatureSupport";
import { codeMirrorSqlDialect, connectionObjectTreeNodeSchema, connectionTableSqlSchema, connectionUsesDatabaseObjectTreeMode, effectiveDatabaseTypeForConnection, objectListSchemaForConnection, tableStructureDatabaseTypeForConnection } from "@/lib/database/jdbcDialect"; import { codeMirrorSqlDialect, connectionObjectTreeNodeSchema, connectionTableSqlSchema, connectionUsesDatabaseObjectTreeMode, effectiveDatabaseTypeForConnection, objectListSchemaForConnection, tableStructureDatabaseTypeForConnection } from "@/lib/database/jdbcDialect";
import { getTableMetadataCapabilities, type TableMetadataCapabilities } from "@/lib/table/tableMetadataCapabilities"; import { getTableMetadataCapabilities, type TableMetadataCapabilities } from "@/lib/table/tableMetadataCapabilities";
import { findTableStatistics } from "@/lib/dataGrid/tableInfoOverview";
import { constraintsForConstraintsTab } from "@/lib/table/constraintPresentation"; import { constraintsForConstraintsTab } from "@/lib/table/constraintPresentation";
import { buildTableSelectSql } from "@/lib/table/tableSelectSql"; import { buildTableSelectSql } from "@/lib/table/tableSelectSql";
import { PARTITION_TREE_INDENT_PX } from "@/lib/table/pgPartitionPresentation"; import { PARTITION_TREE_INDENT_PX } from "@/lib/table/pgPartitionPresentation";
@@ -248,7 +249,11 @@ const eventEditorKey = computed(() =>
}), }),
); );
// Table info panel state // Table info panel state
const tableInfoTab = ref<TableInfoTab>("ddl"); const tableInfoTab = ref<TableInfoTab>("info");
const tableOverviewStats = ref<ObjectStatistics | null>(null);
const tableOverviewComment = ref<string | null>(null);
const tableOverviewLoading = ref(false);
const tableOverviewLoaded = ref(false);
const tableColumns = ref<ColumnInfo[]>([]); const tableColumns = ref<ColumnInfo[]>([]);
const tableColumnsLoading = ref(false); const tableColumnsLoading = ref(false);
const tableColumnsLoaded = ref(false); const tableColumnsLoaded = ref(false);
@@ -281,6 +286,7 @@ const tableConstraintsForTab = computed(() => constraintsForConstraintsTab(table
const tableInfoSearchQuery = ref(""); const tableInfoSearchQuery = ref("");
const tableInfoDdlPreRef = ref<HTMLPreElement | null>(null); const tableInfoDdlPreRef = ref<HTMLPreElement | null>(null);
const activeTableInfoLoading = computed(() => { const activeTableInfoLoading = computed(() => {
if (tableInfoTab.value === "info") return tableOverviewLoading.value;
if (tableInfoTab.value === "ddl") return tableDdlLoading.value; if (tableInfoTab.value === "ddl") return tableDdlLoading.value;
if (tableInfoTab.value === "columns") return tableColumnsLoading.value; if (tableInfoTab.value === "columns") return tableColumnsLoading.value;
if (tableInfoTab.value === "indexes") return tableIndexesLoading.value; if (tableInfoTab.value === "indexes") return tableIndexesLoading.value;
@@ -1063,6 +1069,7 @@ type TableInfoTabItem = { id: TableInfoTab; label: string; icon: Component; coun
const tableInfoTabs = computed<TableInfoTabItem[]>(() => { const tableInfoTabs = computed<TableInfoTabItem[]>(() => {
const tabs: TableInfoTabItem[] = []; const tabs: TableInfoTabItem[] = [];
tabs.push({ id: "info", label: t("grid.tableInfoOverview"), icon: Info });
if (tableMetadataCapabilities.value.ddl) { if (tableMetadataCapabilities.value.ddl) {
tabs.push({ id: "ddl", label: "DDL", icon: Code2 }); tabs.push({ id: "ddl", label: "DDL", icon: Code2 });
} }
@@ -1092,6 +1099,31 @@ const tableInfoTabListStyle = computed(() => ({
})); }));
const filteredTableColumns = computed(() => filterObjectBrowserTableColumns(tableColumns.value, tableInfoSearchQuery.value)); const filteredTableColumns = computed(() => filterObjectBrowserTableColumns(tableColumns.value, tableInfoSearchQuery.value));
const tableOverviewRows = computed(() => {
const stats = tableOverviewStats.value;
const rows = [
{ label: t("common.table"), value: sidePanelRow.value?.name ?? "" },
{ label: t("common.schema"), value: sidePanelRow.value?.schema || selectedSchema.value || props.database },
{ label: t("common.database"), value: props.database },
{ label: t("structureEditor.comment"), value: tableOverviewComment.value ?? "" },
{ label: t("grid.tableInfoEstimatedRows"), value: formatObjectBrowserCount(stats?.estimated_rows) },
{ label: t("grid.tableInfoTotalSize"), value: formatObjectBrowserBytes(stats?.total_bytes) },
{ label: t("grid.tableInfoDataLength"), value: formatObjectBrowserBytes(stats?.data_length) },
{ label: t("grid.tableInfoEngine"), value: stats?.engine ?? "" },
{ label: t("grid.tableInfoCreatedAt"), value: stats?.created_at ?? "" },
{ label: t("grid.tableInfoUpdatedAt"), value: stats?.updated_at ?? "" },
{ label: t("grid.tableInfoCollation"), value: stats?.collation ?? "" },
{ label: t("grid.tableInfoRowFormat"), value: stats?.row_format ?? "" },
{ label: t("grid.tableInfoAvgRowLength"), value: formatObjectBrowserBytes(stats?.avg_row_length) },
{ label: t("grid.tableInfoMaxDataLength"), value: formatObjectBrowserBytes(stats?.max_data_length) },
{ label: t("grid.tableInfoCheckTime"), value: stats?.check_time ?? "" },
{ label: t("grid.tableInfoIndexLength"), value: formatObjectBrowserBytes(stats?.index_length) },
{ label: t("grid.tableInfoAutoIncrement"), value: stats?.auto_increment ?? "" },
{ label: t("grid.tableInfoDataFree"), value: formatObjectBrowserBytes(stats?.data_free) },
];
const query = tableInfoSearchQuery.value.trim().toLowerCase();
return rows.filter((row) => row.value && (!query || row.label.toLowerCase().includes(query) || row.value.toLowerCase().includes(query)));
});
const filteredTableIndexes = computed(() => { const filteredTableIndexes = computed(() => {
if (!tableInfoSearchQuery.value) return tableIndexes.value; if (!tableInfoSearchQuery.value) return tableIndexes.value;
@@ -1140,6 +1172,9 @@ async function openTableInfo(row: ObjectBrowserRow, initialTab?: TableInfoTab) {
sidePanelGuard.bump(); sidePanelGuard.bump();
// Reset state // Reset state
tableColumns.value = []; tableColumns.value = [];
tableOverviewStats.value = null;
tableOverviewComment.value = null;
tableOverviewLoaded.value = false;
rawTableDdlContent.value = ""; rawTableDdlContent.value = "";
tableIndexes.value = []; tableIndexes.value = [];
tableForeignKeys.value = []; tableForeignKeys.value = [];
@@ -1173,7 +1208,8 @@ async function selectTableInfoTab(tab: TableInfoTab) {
if (!nextTab) return; if (!nextTab) return;
tableInfoTab.value = nextTab; tableInfoTab.value = nextTab;
tableInfoSearchQuery.value = ""; tableInfoSearchQuery.value = "";
if (nextTab === "ddl") await fetchTableDdl(); if (nextTab === "info") await fetchTableOverview();
else if (nextTab === "ddl") await fetchTableDdl();
else if (nextTab === "columns") await fetchTableColumns(); else if (nextTab === "columns") await fetchTableColumns();
else if (nextTab === "indexes") await fetchTableIndexes(); else if (nextTab === "indexes") await fetchTableIndexes();
else if (nextTab === "foreignKeys") await fetchTableForeignKeys(); else if (nextTab === "foreignKeys") await fetchTableForeignKeys();
@@ -1182,6 +1218,23 @@ async function selectTableInfoTab(tab: TableInfoTab) {
else if (nextTab === "partitions") await fetchTablePartitions(); else if (nextTab === "partitions") await fetchTablePartitions();
} }
async function fetchTableOverview(force = false) {
const row = sidePanelRow.value;
if (!row || (!force && tableOverviewLoaded.value)) return;
const epoch = sidePanelGuard.capture();
const schema = row.schema || selectedSchema.value || props.database;
tableOverviewLoading.value = true;
try {
const [statistics, comment] = await Promise.all([api.listObjectStatistics(props.connection.id, props.database, schema).catch(() => [] as ObjectStatistics[]), api.getTableComment(props.connection.id, props.database, schema, row.name, props.catalog).catch(() => null)]);
if (sidePanelGuard.isStale(epoch)) return;
tableOverviewStats.value = findTableStatistics(statistics, row.name, schema) ?? null;
tableOverviewComment.value = comment;
tableOverviewLoaded.value = true;
} finally {
if (sidePanelGuard.isFresh(epoch)) tableOverviewLoading.value = false;
}
}
function tableMetadataRequest(row: ObjectBrowserRow): ObjectDdlRequest { function tableMetadataRequest(row: ObjectBrowserRow): ObjectDdlRequest {
return { return {
connectionId: props.connection.id, connectionId: props.connection.id,
@@ -1392,7 +1445,12 @@ async function refreshActiveTableInfo() {
if (sidePanelMode.value !== "table-info" || !sidePanelRow.value) return; if (sidePanelMode.value !== "table-info" || !sidePanelRow.value) return;
sidePanelGuard.bump(); sidePanelGuard.bump();
if (tableInfoTab.value === "ddl") { if (tableInfoTab.value === "info") {
tableOverviewStats.value = null;
tableOverviewComment.value = null;
tableOverviewLoaded.value = false;
await fetchTableOverview(true);
} else if (tableInfoTab.value === "ddl") {
rawTableDdlContent.value = ""; rawTableDdlContent.value = "";
tableDdlLoaded.value = false; tableDdlLoaded.value = false;
await fetchTableDdl(true); await fetchTableDdl(true);
@@ -3893,7 +3951,17 @@ function getObjectBrowserMenuItems(item: ObjectBrowserRow): ContextMenuItem[] {
<div v-if="tableInfoTab === 'ddl' && effectiveDatabaseType === 'oceanbase-oracle'" class="border-b px-3 py-2"> <div v-if="tableInfoTab === 'ddl' && effectiveDatabaseType === 'oceanbase-oracle'" class="border-b px-3 py-2">
<DdlStorageToggle :database-type="effectiveDatabaseType" :disabled="tableDdlLoading" /> <DdlStorageToggle :database-type="effectiveDatabaseType" :disabled="tableDdlLoading" />
</div> </div>
<div v-if="tableInfoTab === 'columns'" class="flex-1 min-h-0 overflow-auto"> <div v-if="tableInfoTab === 'info'" class="flex-1 min-h-0 overflow-auto">
<div v-if="tableOverviewLoading" class="h-full flex items-center justify-center"><Loader2 class="w-4 h-4 animate-spin text-muted-foreground" /></div>
<div v-else-if="tableInfoSearchQuery && tableOverviewRows.length === 0" class="p-6 text-center text-xs text-muted-foreground">{{ t("grid.tableInfoNoResults") }}</div>
<div v-else class="divide-y">
<div v-for="row in tableOverviewRows" :key="row.label" class="flex items-baseline gap-3 px-3 py-2 text-xs">
<span class="w-24 shrink-0 text-muted-foreground">{{ row.label }}</span>
<span class="min-w-0 flex-1 select-text break-words font-mono text-[11px]" :title="row.value">{{ row.value }}</span>
</div>
</div>
</div>
<div v-else-if="tableInfoTab === 'columns'" class="flex-1 min-h-0 overflow-auto">
<div v-if="tableColumnsLoading" class="h-full flex items-center justify-center"> <div v-if="tableColumnsLoading" class="h-full flex items-center justify-center">
<Loader2 class="w-4 h-4 animate-spin text-muted-foreground" /> <Loader2 class="w-4 h-4 animate-spin text-muted-foreground" />
</div> </div>
+12
View File
@@ -2345,6 +2345,18 @@ export default withEnglishFallback({
tableInfoOverview: "Ümumi baxış", tableInfoOverview: "Ümumi baxış",
tableInfoEstimatedRows: "Təxmini sətirlər", tableInfoEstimatedRows: "Təxmini sətirlər",
tableInfoTotalSize: "Ümumi həcm", tableInfoTotalSize: "Ümumi həcm",
tableInfoDataLength: "Məlumat uzunluğu",
tableInfoEngine: "Mühərrik",
tableInfoCreatedAt: "Yaradılma tarixi",
tableInfoUpdatedAt: "Dəyişdirilmə tarixi",
tableInfoCollation: "Müqayisə qaydası",
tableInfoRowFormat: "Sətir formatı",
tableInfoAvgRowLength: "Orta sətir uzunluğu",
tableInfoMaxDataLength: "Maksimum məlumat uzunluğu",
tableInfoCheckTime: "Yoxlanma vaxtı",
tableInfoIndexLength: "İndeks uzunluğu",
tableInfoAutoIncrement: "Avtomatik artım",
tableInfoDataFree: "Boş məlumat sahəsi",
pinTableInfo: "Cədvəl məlumatları panelini bərkit", pinTableInfo: "Cədvəl məlumatları panelini bərkit",
unpinTableInfo: "Cədvəl məlumatları panelinin bərkidilməsini ləğv et", unpinTableInfo: "Cədvəl məlumatları panelinin bərkidilməsini ləğv et",
tableInfoColumns: "Sütunlar", tableInfoColumns: "Sütunlar",
+12
View File
@@ -2579,6 +2579,18 @@ export default {
tableInfoOverview: "Overview", tableInfoOverview: "Overview",
tableInfoEstimatedRows: "Estimated rows", tableInfoEstimatedRows: "Estimated rows",
tableInfoTotalSize: "Total size", tableInfoTotalSize: "Total size",
tableInfoDataLength: "Data length",
tableInfoEngine: "Engine",
tableInfoCreatedAt: "Created at",
tableInfoUpdatedAt: "Updated at",
tableInfoCollation: "Collation",
tableInfoRowFormat: "Row format",
tableInfoAvgRowLength: "Average row length",
tableInfoMaxDataLength: "Maximum data length",
tableInfoCheckTime: "Check time",
tableInfoIndexLength: "Index length",
tableInfoAutoIncrement: "Auto increment",
tableInfoDataFree: "Data free",
pinTableInfo: "Pin table info panel", pinTableInfo: "Pin table info panel",
unpinTableInfo: "Unpin table info panel", unpinTableInfo: "Unpin table info panel",
tableInfoColumns: "Columns", tableInfoColumns: "Columns",
+12
View File
@@ -2420,6 +2420,18 @@ export default withEnglishFallback({
tableInfoOverview: "Resumen", tableInfoOverview: "Resumen",
tableInfoEstimatedRows: "Filas estimadas", tableInfoEstimatedRows: "Filas estimadas",
tableInfoTotalSize: "Tamaño total", tableInfoTotalSize: "Tamaño total",
tableInfoDataLength: "Longitud de datos",
tableInfoEngine: "Motor",
tableInfoCreatedAt: "Fecha de creación",
tableInfoUpdatedAt: "Fecha de modificación",
tableInfoCollation: "Intercalación",
tableInfoRowFormat: "Formato de fila",
tableInfoAvgRowLength: "Longitud media de fila",
tableInfoMaxDataLength: "Longitud máxima de datos",
tableInfoCheckTime: "Fecha de comprobación",
tableInfoIndexLength: "Longitud de índices",
tableInfoAutoIncrement: "Incremento automático",
tableInfoDataFree: "Espacio libre de datos",
pinTableInfo: "Fijar el panel de información de la tabla", pinTableInfo: "Fijar el panel de información de la tabla",
unpinTableInfo: "Desfijar el panel de información de la tabla", unpinTableInfo: "Desfijar el panel de información de la tabla",
tableInfoColumns: "Columnas", tableInfoColumns: "Columnas",
+12
View File
@@ -2406,6 +2406,18 @@ export default withEnglishFallback({
tableInfoOverview: "Panoramica", tableInfoOverview: "Panoramica",
tableInfoEstimatedRows: "Righe stimate", tableInfoEstimatedRows: "Righe stimate",
tableInfoTotalSize: "Dimensione totale", tableInfoTotalSize: "Dimensione totale",
tableInfoDataLength: "Lunghezza dati",
tableInfoEngine: "Motore",
tableInfoCreatedAt: "Data di creazione",
tableInfoUpdatedAt: "Data di modifica",
tableInfoCollation: "Regole di confronto",
tableInfoRowFormat: "Formato riga",
tableInfoAvgRowLength: "Lunghezza media riga",
tableInfoMaxDataLength: "Lunghezza massima dati",
tableInfoCheckTime: "Data di controllo",
tableInfoIndexLength: "Lunghezza indici",
tableInfoAutoIncrement: "Incremento automatico",
tableInfoDataFree: "Spazio dati libero",
pinTableInfo: "Blocca il pannello delle informazioni sulla tabella", pinTableInfo: "Blocca il pannello delle informazioni sulla tabella",
unpinTableInfo: "Sblocca il pannello delle informazioni sulla tabella", unpinTableInfo: "Sblocca il pannello delle informazioni sulla tabella",
tableInfoColumns: "Colonne", tableInfoColumns: "Colonne",
+12
View File
@@ -2417,6 +2417,18 @@ export default withEnglishFallback({
tableInfoOverview: "概要", tableInfoOverview: "概要",
tableInfoEstimatedRows: "推定行数", tableInfoEstimatedRows: "推定行数",
tableInfoTotalSize: "合計サイズ", tableInfoTotalSize: "合計サイズ",
tableInfoDataLength: "データ長",
tableInfoEngine: "エンジン",
tableInfoCreatedAt: "作成日時",
tableInfoUpdatedAt: "更新日時",
tableInfoCollation: "照合順序",
tableInfoRowFormat: "行形式",
tableInfoAvgRowLength: "平均行長",
tableInfoMaxDataLength: "最大データ長",
tableInfoCheckTime: "検査日時",
tableInfoIndexLength: "インデックス長",
tableInfoAutoIncrement: "自動増分",
tableInfoDataFree: "空き領域",
pinTableInfo: "テーブル情報パネルを固定", pinTableInfo: "テーブル情報パネルを固定",
unpinTableInfo: "テーブル情報パネルの固定を解除", unpinTableInfo: "テーブル情報パネルの固定を解除",
tableInfoColumns: "列", tableInfoColumns: "列",
+12
View File
@@ -2400,6 +2400,18 @@ export default withEnglishFallback({
tableInfoOverview: "개요", tableInfoOverview: "개요",
tableInfoEstimatedRows: "예상 행 수", tableInfoEstimatedRows: "예상 행 수",
tableInfoTotalSize: "전체 크기", tableInfoTotalSize: "전체 크기",
tableInfoDataLength: "데이터 길이",
tableInfoEngine: "엔진",
tableInfoCreatedAt: "생성 일시",
tableInfoUpdatedAt: "수정 일시",
tableInfoCollation: "정렬 규칙",
tableInfoRowFormat: "행 형식",
tableInfoAvgRowLength: "평균 행 길이",
tableInfoMaxDataLength: "최대 데이터 길이",
tableInfoCheckTime: "검사 일시",
tableInfoIndexLength: "인덱스 길이",
tableInfoAutoIncrement: "자동 증가",
tableInfoDataFree: "사용 가능한 공간",
pinTableInfo: "테이블 정보 패널 고정", pinTableInfo: "테이블 정보 패널 고정",
unpinTableInfo: "테이블 정보 패널 고정 해제", unpinTableInfo: "테이블 정보 패널 고정 해제",
tableInfoColumns: "컬럼", tableInfoColumns: "컬럼",
+12
View File
@@ -2408,6 +2408,18 @@ export default withEnglishFallback({
tableInfoOverview: "Visão geral", tableInfoOverview: "Visão geral",
tableInfoEstimatedRows: "Linhas estimadas", tableInfoEstimatedRows: "Linhas estimadas",
tableInfoTotalSize: "Tamanho total", tableInfoTotalSize: "Tamanho total",
tableInfoDataLength: "Tamanho dos dados",
tableInfoEngine: "Mecanismo",
tableInfoCreatedAt: "Data de criação",
tableInfoUpdatedAt: "Data de modificação",
tableInfoCollation: "Ordenação",
tableInfoRowFormat: "Formato da linha",
tableInfoAvgRowLength: "Tamanho médio da linha",
tableInfoMaxDataLength: "Tamanho máximo dos dados",
tableInfoCheckTime: "Data de verificação",
tableInfoIndexLength: "Tamanho dos índices",
tableInfoAutoIncrement: "Incremento automático",
tableInfoDataFree: "Espaço livre de dados",
pinTableInfo: "Fixar painel de informações da tabela", pinTableInfo: "Fixar painel de informações da tabela",
unpinTableInfo: "Desafixar painel de informações da tabela", unpinTableInfo: "Desafixar painel de informações da tabela",
tableInfoColumns: "Colunas", tableInfoColumns: "Colunas",
+12
View File
@@ -2340,6 +2340,18 @@ export default withEnglishFallback({
tableInfoOverview: "Genel bakış", tableInfoOverview: "Genel bakış",
tableInfoEstimatedRows: "Tahmini satır", tableInfoEstimatedRows: "Tahmini satır",
tableInfoTotalSize: "Toplam boyut", tableInfoTotalSize: "Toplam boyut",
tableInfoDataLength: "Veri uzunluğu",
tableInfoEngine: "Motor",
tableInfoCreatedAt: "Oluşturulma tarihi",
tableInfoUpdatedAt: "Değiştirilme tarihi",
tableInfoCollation: "Karşılaştırma düzeni",
tableInfoRowFormat: "Satır biçimi",
tableInfoAvgRowLength: "Ortalama satır uzunluğu",
tableInfoMaxDataLength: "En fazla veri uzunluğu",
tableInfoCheckTime: "Denetim zamanı",
tableInfoIndexLength: "Dizin uzunluğu",
tableInfoAutoIncrement: "Otomatik artış",
tableInfoDataFree: "Boş veri alanı",
pinTableInfo: "Tablo bilgileri panelini sabitle", pinTableInfo: "Tablo bilgileri panelini sabitle",
unpinTableInfo: "Tablo bilgileri panelinin sabitlemesini kaldır", unpinTableInfo: "Tablo bilgileri panelinin sabitlemesini kaldır",
tableInfoColumns: "Sütunlar", tableInfoColumns: "Sütunlar",
+12
View File
@@ -2492,6 +2492,18 @@ export default withEnglishFallback({
tableInfoOverview: "表信息", tableInfoOverview: "表信息",
tableInfoEstimatedRows: "估算行数", tableInfoEstimatedRows: "估算行数",
tableInfoTotalSize: "总大小", tableInfoTotalSize: "总大小",
tableInfoDataLength: "数据长度",
tableInfoEngine: "引擎",
tableInfoCreatedAt: "创建日期",
tableInfoUpdatedAt: "修改日期",
tableInfoCollation: "排序规则",
tableInfoRowFormat: "行格式",
tableInfoAvgRowLength: "平均长度",
tableInfoMaxDataLength: "最大数据长度",
tableInfoCheckTime: "检查时间",
tableInfoIndexLength: "索引长度",
tableInfoAutoIncrement: "自动递增",
tableInfoDataFree: "数据可用空间",
pinTableInfo: "固定表属性面板", pinTableInfo: "固定表属性面板",
unpinTableInfo: "取消固定表属性面板", unpinTableInfo: "取消固定表属性面板",
tableInfoColumns: "字段", tableInfoColumns: "字段",
+12
View File
@@ -2411,6 +2411,18 @@ export default withEnglishFallback({
tableInfoOverview: "資料表資訊", tableInfoOverview: "資料表資訊",
tableInfoEstimatedRows: "預估列數", tableInfoEstimatedRows: "預估列數",
tableInfoTotalSize: "總大小", tableInfoTotalSize: "總大小",
tableInfoDataLength: "資料長度",
tableInfoEngine: "引擎",
tableInfoCreatedAt: "建立日期",
tableInfoUpdatedAt: "修改日期",
tableInfoCollation: "定序規則",
tableInfoRowFormat: "列格式",
tableInfoAvgRowLength: "平均長度",
tableInfoMaxDataLength: "最大資料長度",
tableInfoCheckTime: "檢查時間",
tableInfoIndexLength: "索引長度",
tableInfoAutoIncrement: "自動遞增",
tableInfoDataFree: "資料可用空間",
pinTableInfo: "固定資料表屬性面板", pinTableInfo: "固定資料表屬性面板",
unpinTableInfo: "取消固定資料表屬性面板", unpinTableInfo: "取消固定資料表屬性面板",
tableInfoColumns: "欄位", tableInfoColumns: "欄位",
+12
View File
@@ -857,6 +857,18 @@ export interface ObjectStatistics {
schema?: string | null; schema?: string | null;
estimated_rows?: number | null; estimated_rows?: number | null;
total_bytes?: number | null; total_bytes?: number | null;
data_length?: number | null;
engine?: string | null;
created_at?: string | null;
updated_at?: string | null;
collation?: string | null;
row_format?: string | null;
avg_row_length?: number | null;
max_data_length?: number | null;
check_time?: string | null;
index_length?: number | null;
auto_increment?: string | null;
data_free?: number | null;
} }
export type ObjectSourceKind = "VIEW" | "MATERIALIZED_VIEW" | "PROCEDURE" | "FUNCTION" | "TRIGGER" | "EVENT" | "SEQUENCE" | "SYNONYM" | "JOB" | "PACKAGE" | "PACKAGE_BODY" | "TYPE" | "TYPE_BODY"; export type ObjectSourceKind = "VIEW" | "MATERIALIZED_VIEW" | "PROCEDURE" | "FUNCTION" | "TRIGGER" | "EVENT" | "SEQUENCE" | "SYNONYM" | "JOB" | "PACKAGE" | "PACKAGE_BODY" | "TYPE" | "TYPE_BODY";
+5 -1
View File
@@ -1873,6 +1873,7 @@ fn oracle_object_statistics_from_query_result(result: db::QueryResult) -> Vec<db
schema: query_result_cell_string(&row, 1), schema: query_result_cell_string(&row, 1),
estimated_rows: query_result_cell_i64(&row, 2), estimated_rows: query_result_cell_i64(&row, 2),
total_bytes: query_result_cell_i64(&row, 3), total_bytes: query_result_cell_i64(&row, 3),
..Default::default()
}) })
}) })
.collect() .collect()
@@ -6376,7 +6377,10 @@ async fn list_object_statistics_once(
if *mode == MysqlMode::OceanBaseOracle || db_config.as_ref().is_some_and(db::manticoresearch::is_config) { if *mode == MysqlMode::OceanBaseOracle || db_config.as_ref().is_some_and(db::manticoresearch::is_config) {
Ok(vec![]) Ok(vec![])
} else { } else {
db::mysql::list_object_statistics(p, database).await let include_mysql_details = db_config.as_ref().is_some_and(|config| {
config.db_type == DatabaseType::Mysql && !db::mysql_compatible::uses_show_metadata(config)
});
db::mysql::list_object_statistics(p, database, include_mysql_details).await
} }
} }
PoolKind::Postgres(p) if db_config.as_ref().is_some_and(is_questdb_config) => Ok(vec![]), PoolKind::Postgres(p) if db_config.as_ref().is_some_and(is_questdb_config) => Ok(vec![]),
@@ -554,6 +554,7 @@ fn clickhouse_object_statistics_from_row(row: &[serde_json::Value], database: &s
schema: Some(database.to_string()), schema: Some(database.to_string()),
estimated_rows: json_value_as_i64(row.get(1)), estimated_rows: json_value_as_i64(row.get(1)),
total_bytes: json_value_as_i64(row.get(2)), total_bytes: json_value_as_i64(row.get(2)),
..Default::default()
}) })
} }
@@ -321,6 +321,7 @@ pub fn object_statistics_from_collection_stats(name: &str, database: &str, resul
(None, None) => None, (None, None) => None,
(data, index) => Some(data.unwrap_or(0).saturating_add(index.unwrap_or(0))), (data, index) => Some(data.unwrap_or(0).saturating_add(index.unwrap_or(0))),
}, },
..Default::default()
} }
} }
+32 -5
View File
@@ -3820,10 +3820,18 @@ pub async fn list_objects_with_logical_tables(
Ok(PagedObjectList { objects, paging_applied }) Ok(PagedObjectList { objects, paging_applied })
} }
pub async fn list_object_statistics(pool: &MySqlPool, database: &str) -> Result<Vec<ObjectStatistics>, String> { pub async fn list_object_statistics(
pool: &MySqlPool,
database: &str,
include_mysql_details: bool,
) -> Result<Vec<ObjectStatistics>, String> {
let columns = if include_mysql_details {
"TABLE_NAME, TABLE_ROWS, DATA_LENGTH, ENGINE, CREATE_TIME, UPDATE_TIME, TABLE_COLLATION, ROW_FORMAT, AVG_ROW_LENGTH, MAX_DATA_LENGTH, CHECK_TIME, INDEX_LENGTH, AUTO_INCREMENT, DATA_FREE, COALESCE(DATA_LENGTH, 0) + COALESCE(INDEX_LENGTH, 0) AS TOTAL_BYTES"
} else {
"TABLE_NAME, TABLE_ROWS, COALESCE(DATA_LENGTH, 0) + COALESCE(INDEX_LENGTH, 0) AS TOTAL_BYTES"
};
let sql = format!( let sql = format!(
"SELECT TABLE_NAME, TABLE_ROWS, COALESCE(DATA_LENGTH, 0) + COALESCE(INDEX_LENGTH, 0) AS TOTAL_BYTES \ "SELECT {columns} FROM information_schema.TABLES \
FROM information_schema.TABLES \
WHERE TABLE_SCHEMA = {} AND TABLE_TYPE <> 'VIEW' \ WHERE TABLE_SCHEMA = {} AND TABLE_TYPE <> 'VIEW' \
ORDER BY TABLE_NAME", ORDER BY TABLE_NAME",
quote_value(database), quote_value(database),
@@ -3838,12 +3846,31 @@ pub async fn list_object_statistics(pool: &MySqlPool, database: &str) -> Result<
.iter() .iter()
.filter_map(|row| { .filter_map(|row| {
let name = get_str_by_name(row, "TABLE_NAME").trim().to_string(); let name = get_str_by_name(row, "TABLE_NAME").trim().to_string();
(!name.is_empty()).then_some(ObjectStatistics { if name.is_empty() {
return None;
}
let mut statistics = ObjectStatistics {
name, name,
schema: Some(database.to_string()), schema: Some(database.to_string()),
estimated_rows: get_opt_i64(row, "TABLE_ROWS"), estimated_rows: get_opt_i64(row, "TABLE_ROWS"),
total_bytes: get_opt_i64(row, "TOTAL_BYTES"), total_bytes: get_opt_i64(row, "TOTAL_BYTES"),
}) ..Default::default()
};
if include_mysql_details {
statistics.data_length = get_opt_i64(row, "DATA_LENGTH");
statistics.engine = get_opt_str(row, "ENGINE");
statistics.created_at = get_opt_metadata_string(row, "CREATE_TIME");
statistics.updated_at = get_opt_metadata_string(row, "UPDATE_TIME");
statistics.collation = get_opt_str(row, "TABLE_COLLATION");
statistics.row_format = get_opt_str(row, "ROW_FORMAT");
statistics.avg_row_length = get_opt_i64(row, "AVG_ROW_LENGTH");
statistics.max_data_length = get_opt_i64(row, "MAX_DATA_LENGTH");
statistics.check_time = get_opt_metadata_string(row, "CHECK_TIME");
statistics.index_length = get_opt_i64(row, "INDEX_LENGTH");
statistics.auto_increment = get_opt_unsigned_metadata_string(row, "AUTO_INCREMENT");
statistics.data_free = get_opt_i64(row, "DATA_FREE");
}
Some(statistics)
}) })
.collect()) .collect())
} }
+1
View File
@@ -7248,6 +7248,7 @@ pub async fn list_object_statistics(pool: &Pool, schema: &str) -> Result<Vec<Obj
schema: Some(schema.to_string()), schema: Some(schema.to_string()),
estimated_rows: row.try_get::<_, i64>(1).ok(), estimated_rows: row.try_get::<_, i64>(1).ok(),
total_bytes: row.try_get::<_, i64>(2).ok(), total_bytes: row.try_get::<_, i64>(2).ok(),
..Default::default()
}) })
.collect()) .collect())
} }
+1
View File
@@ -2836,6 +2836,7 @@ pub async fn list_object_statistics(
.ok() .ok()
.flatten() .flatten()
.or_else(|| row.try_get::<i32, _>(2).ok().flatten().map(i64::from)), .or_else(|| row.try_get::<i32, _>(2).ok().flatten().map(i64::from)),
..Default::default()
}) })
.filter(|stat| !stat.name.is_empty()) .filter(|stat| !stat.name.is_empty())
.collect()) .collect())
@@ -270,6 +270,7 @@ pub async fn list_object_statistics(client: &VictoriaMetricsClient) -> Result<Ve
estimated_rows: item.value.as_i64().or_else(|| item.value.as_str().and_then(|value| value.parse().ok())), estimated_rows: item.value.as_i64().or_else(|| item.value.as_str().and_then(|value| value.parse().ok())),
// VictoriaMetrics exposes series counts here, but no per-metric storage size. // VictoriaMetrics exposes series counts here, but no per-metric storage size.
total_bytes: None, total_bytes: None,
..Default::default()
}) })
.collect()) .collect())
} }
+1 -1
View File
@@ -442,7 +442,7 @@ mod tests {
async fn http_inactivity_expiry_rolls_back_and_disconnects_inner_owner() { async fn http_inactivity_expiry_rolls_back_and_disconnects_inner_owner() {
let backend = Arc::new(HttpTestBackend::new()); let backend = Arc::new(HttpTestBackend::new());
let (url, manager, cancellation, server_task) = let (url, manager, cancellation, server_task) =
start_http_test_server(backend.clone(), std::time::Duration::from_millis(50)).await; start_http_test_server(backend.clone(), std::time::Duration::from_millis(500)).await;
let (client, _) = open_active_transaction(&url).await; let (client, _) = open_active_transaction(&url).await;
wait_for_disposal(&backend).await; wait_for_disposal(&backend).await;
+25 -1
View File
@@ -145,12 +145,36 @@ pub struct ExtensionInfo {
pub schema: Option<String>, pub schema: Option<String>,
} }
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ObjectStatistics { pub struct ObjectStatistics {
pub name: String, pub name: String,
pub schema: Option<String>, pub schema: Option<String>,
pub estimated_rows: Option<i64>, pub estimated_rows: Option<i64>,
pub total_bytes: Option<i64>, pub total_bytes: Option<i64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub data_length: Option<i64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub engine: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub created_at: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub updated_at: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub collation: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub row_format: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub avg_row_length: Option<i64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_data_length: Option<i64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub check_time: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub index_length: Option<i64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub auto_increment: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub data_free: Option<i64>,
} }
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]