Skip to content

feat(auditplan): add CatalogName field to schema_meta for PG-family databases#3315

Closed
actiontech-bot wants to merge 1 commit into
mainfrom
sqle/feat-2894
Closed

feat(auditplan): add CatalogName field to schema_meta for PG-family databases#3315
actiontech-bot wants to merge 1 commit into
mainfrom
sqle/feat-2894

Conversation

@actiontech-bot
Copy link
Copy Markdown
Member

Summary

为 TBase(TDSQL PostgreSQL 版)库表元数据扫描任务做配套的 CE 侧基础扩展:在 SchemaMetaSQLaudit_plan_sqls Info 中新增独立的 CatalogName(PG 系语义下指 database 名)字段与 MetricNameMetaCatalog 指标,并在任务详情页 Head() 中暴露一列 catalog

PostgreSQL 系数据库的 catalog(database)与 schema(namespace)是两层独立命名空间,原实现将 db 名误写入 SchemaName,本次改为两个字段分别承载;genSQLId 也将 Catalog 纳入 hash key,防止跨 catalog 同名对象被合并。

对不存在 catalog/schema 双层命名空间的数据库(MySQL / TiDB / Oracle 等),CatalogName 保持空字符串,UI 列渲染为 -,行为完全不变。

Changes

  • sqle/server/auditplan/task_type_mysql_schema_meta.go
    • SchemaMetaSQL 增加 CatalogName string
    • Metrics() / mergeSQL / ExtractSQL 接入 MetricNameMetaCatalog
    • genSQLId hash 输入加 Catalog
    • Head() 新增 catalog 列;GetSQLData 写出 schema_meta_catalog
  • sqle/server/auditplan/metrics.go:新增 MetricNameMetaCatalog 常量与 ALLMetric 注册
  • sqle/locale/active.zh.toml / active.en.toml / message_zh.go:新增 i18n 键 ApMetricNameMetaCatalog

Test plan

  • go vet ./...(docker golang:1.24.1)通过
  • go test ./sqle/server/auditplan/... 通过
  • 配套 EE PR actiontech/sqle-ee#2894 依赖本 PR 合并后自动同步到 main-ee 方可通过 CI;本 PR 单独合并不会改变现有 MySQL / Oracle / TiDB schema_meta 任务行为

Fixes actiontech/sqle-ee#2894

…olumn

The schema meta scan task detail page used to show PostgreSQL database
name under the 'schema' column, which is actually the catalog and not
the PG schema/namespace. In PostgreSQL semantics catalog (database) and
schema (namespace) are two independent layers, so they must be carried
separately:

- Add CatalogName to SchemaMetaSQL so that PG-family extractors can
  populate the catalog (database) name independently from the schema
  (namespace) name.
- Persist the catalog via a new MetricNameMetaCatalog metric so that it
  flows through ExtractSQL / mergeSQL / genSQLId / GetSQLData without
  reusing the existing SchemaName field.
- Expose a new 'catalog' column on the schema meta task detail page via
  Head(), backed by ApMetricNameMetaCatalog in zh/en locale.
- Include CatalogName in genSQLId so that the same (schema, table,
  type) tuple living in different catalogs is no longer merged into one
  row, which would otherwise hide cross-database objects.

For databases without a catalog/schema two-layer namespace (MySQL,
TiDB, Oracle etc.) CatalogName stays empty and the catalog column
renders as '-' in the UI, keeping the existing behaviour intact.

Refs: actiontech/sqle-ee#2894
@iwanghc iwanghc closed this May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants