This issue requires an assignee. Since you haven't specified one, we've assigned TestManager as the default assignee for this issue.


Welcome To openGauss Community
Hey @Rourou2285 , thanks for your contribution to the community.
Bot Usage Manual
I'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands. You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
Contact Guide
If you have any questions, please contact the SIG: Plugin ,
and any of the maintainers: @CarrotGo, @chendong76, @chenxiaobin19, @congzhou2603, @dodders, @hwworkholic, @jemappellehc, @libiao2024, @muyulinzhong, @quemingjian, @shenzheng4, @shirley_zhengx, @superlchf, @totaj, @wlff234, @wofanzheng, @ywzq1161327784 ,
and any of the committers: @dreamalloc, @huyinghao, @libiao2024, @wangfeihuo, @wmy_ld, @wuyuechuan, @xiong_xjun, @zhangxubo, @zhaojunv3z810 .


推荐逻辑
在 Datum format_type() 中:修改
1.判断当前会话是否是 Dolphin/MySQL 协议;
2.如果是 MySQL 协议,再执行 PostgreSQL 类型名到 MySQL 类型名的转换;
3.如果是 PostgreSQL 协议,保持原输出完全不变。


This issue requires an assignee. Since you haven't specified one, we've assigned TestManager as the default assignee for this issue.


验证结果:通过(PASS)
测例:Diesel metadata 模块(examples 测例链接 https://atomgit.com/opengauss/examples/merge_requests/108)
| 用例 | 覆盖 | 结果 |
|---|---|---|
| T-Meta-Setup | 创建元数据探针表(16 种类型) | PASS |
| T-Meta-1 | information_schema.columns 返回 MySQL 类型名 |
PASS |
| T-Meta-2 | 类型名无 openGauss 原生名泄漏(负向断言) | PASS |
| T-Meta-3 | diesel print-schema 生成 Diesel 核心类型 |
PASS |
| T-Meta-4a | SHOW COLUMNS 的 Type 返回 MySQL 类型名 |
PASS |
| T-Meta-4b | SHOW COLUMNS 无 openGauss 原生名泄漏 |
PASS |
| T-Meta-5 | nvarchar2 列类型名映射为 varchar |
PASS |
| T-Meta-6 | DESCRIBE 与 SHOW COLUMNS 类型名一致 |
PASS |
| T-Meta-7 | format_type() 会话感知返回 MySQL 名 |
PASS |
Diesel 全量矩阵:85 例 = 85 PASS / 0 FAIL。


问题描述
通过 MySQL 协议(dolphin 3306)连接 openGauss B 兼容库后,执行结构内省(
DESCRIBE/SHOW COLUMNS、查询information_schema.columns的data_type/column_type)时,返回的是 PostgreSQL 原生类型名,而非 MySQL 类型名:SHOW COLUMNS的 Typecharacter varying(50)、double precision、timestamp without time zonevarchar(50)、double、datetimeinformation_schema.columns.data_typecharacter varying、double precision、boolean、real、numbervarchar、double、tinyint/tinyint(1)、float、decimalinformation_schema.columns.column_type这导致依赖
information_schema/SHOW COLUMNS做自动内省的 MySQL ORM(如 Rust Diesel 2.3)无法识别类型名并中止:复现步骤
enable_dolphin_proto=on、dolphin_server_port=3306),连接 B 兼容库。CREATE TABLE t8_mig (id INT AUTO_INCREMENT PRIMARY KEY, v VARCHAR(50), d DOUBLE, ts TIMESTAMP, dt DATETIME);返回SELECT column_name, data_type, column_type FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 't8_mig' ORDER BY ordinal_position;character varying/double precision/timestamp with time zone/timestamp without time zone。diesel print-schema --only-tables t8_mig,报Unsupported type: \character varying``。环境
根因
dolphin 的 MySQL 协议边界两条内省出口直接输出了 PG 侧
format_type()文本:plugin_parser/parse_describe.cpp::makeTypeColumn():DESCRIBE/SHOW COLUMNS的 Type 列调用format_type(atttypid, atttypmod);information_schema.columns(共享视图):data_type/column_type同样来自format_type(...)。而协议层
b_type_items[]只提供结果集字段的类型码/字符集,没有“MySQL 可读类型名”字段,因此两条路径长期缺少 PG→MySQL 名称映射。影响
DOLPHIN_TYPE_*类型码)。information_schema.columns/SHOW COLUMNS做自动内省的 ORM/工具(Diesel、不少 MySQL 驱动/迁移工具)会因无法识别类型名而中止或生成错误模型。data_type分派(区分文本/数值/日期),会因拿到 PG 名而走错分支。期望行为
MySQL 协议内省返回 MySQL 类型名,并保留长度/精度:
character varying→varchar、character→char、boolean→tinyint(1)、real→float、double precision→double、numeric/number→decimal、timestamp without time zone→datetime、timestamp with time zone→timestamp、time without time zone→time、bit varying→bit、integer→int、bytea→blob。建议修复
TypeItem增加mysql_typname,以b_type_items[]作为 PG→MySQL 类型名映射(单一真源)。mysql_type_name(oid, typmod)与mysql_type_name(text)两个 SQL 函数,统一转换。DESCRIBE/SHOW COLUMNS的 Type 列改用mysql_type_name。transformStmt包装,仅对 MySQL 协议连接改写information_schema.columns.column_type/data_type;PG 协议与共享视图不受影响。验证
diesel print-schema报Unsupported type: \character varying`;information_schema.columns` 返回 PG 名。varchar/double/datetime等 MySQL 名,print-schema 正常生成 Diesel 核心类型(Varchar/Double/Datetime/Timestamp)。