兼容性判定
公开资料依据 · 建议 PoC 复核支持度partial
严重度major
置信度low
依据规则ora.func.harvest_ora2pg_substr_nonnegative
怎么改
SUBSTR(text,start[,len]) -> substring(text from start [for len]);orafce 目标可改 oracle.substr
判定说明
A 兼容模式文档提供本批 trim/length/ltrim/rtrim/instr/substr 字符函数;CHAR、空串、NULL、start=0 和多字节边界建议 PoC 复核
库侧 / 应用侧路径
库侧改造
可行:按 rewrite 重构并显式保留参数顺序、类型、NULL 与异常语义
应用侧改造
可行:在应用适配层封装等价逻辑,并统一替换调用点
推荐路线:db_side。验证建议:建议 PoC 复核正常值、NULL、边界值、返回类型与异常行为,并与 Oracle 逐项比对
规则样例
SELECT SUBSTR(TRIM(NVL(code, ' ')), 1, 4) FROM orders
SELECT SUBSTR(code, :start_pos, :amount) FROM orders
SELECT SUBSTR(code, -4, 4) FROM orders
参考来源
- https://docs.opengauss.org/en/docs/6.0.0/docs/SQLReference/character-processing-functions-and-operators.html
- https://github.com/darold/ora2pg/blob/97015451a4d1cfbee888f2e6efe7ff68c239a9b5/lib/Ora2Pg/PLSQL.pm#L835-L1076
- https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/Functions.html
- https://www.postgresql.org/docs/16/functions.html
相关改造点
- ORACLE → opengauss 6.0 A 模式 全部改造点
- opengauss 6.0 A 模式 兼容性总览
- ORACLE 迁移国产库总览
- ORACLE ALTER SESSION SET 会话参数 迁移 opengauss 6.0 A 模式 怎么改
- ORACLE 关联数组(INDEX BY 表) 迁移 opengauss 6.0 A 模式 怎么改
- ORACLE AT TIME ZONE 时区表达式 迁移 opengauss 6.0 A 模式 怎么改
- ORACLE 自治事务(PRAGMA AUTONOMOUS_TRANSACTION) 迁移 opengauss 6.0 A 模式 怎么改
- ORACLE 视图 BEQUEATH 子句 迁移 opengauss 6.0 A 模式 怎么改
- ORACLE BFILE 外部文件类型 迁移 opengauss 6.0 A 模式 怎么改