兼容性判定
公开资料依据 · 建议 PoC 复核支持度partial
严重度major
置信度low
依据规则ora.func.harvest_ora2pg_substr_nonnegative
怎么改
SUBSTR(text,start[,len]) -> substring(text from start [for len]);orafce 目标可改 oracle.substr
判定说明
core 可组合 trim/length/ltrim/rtrim/position/substr,但 Oracle 的 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.oracle.com/en/database/oracle/oracle-database/19/sqlrf/Functions.html
- https://www.postgresql.org/docs/16/functions-string.html
- https://www.postgresql.org/docs/16/datatype.html
- https://www.postgresql.org/docs/16/functions.html
- https://www.postgresql.org/docs/16/sql-commands.html
- https://github.com/darold/ora2pg/blob/97015451a4d1cfbee888f2e6efe7ff68c239a9b5/lib/Ora2Pg/PLSQL.pm#L835-L1076
相关改造点
- ORACLE → postgresql 16 全部改造点
- postgresql 16 兼容性总览
- ORACLE 迁移国产库总览
- ORACLE ADD_MONTHS 函数 迁移 postgresql 16 怎么改
- ORACLE ALTER SESSION SET 会话参数 迁移 postgresql 16 怎么改
- ORACLE ANYDATA 动态类型列 迁移 postgresql 16 怎么改
- ORACLE ASCIISTR Unicode 转义函数 迁移 postgresql 16 怎么改
- ORACLE 关联数组(INDEX BY 表) 迁移 postgresql 16 怎么改
- ORACLE AT TIME ZONE 时区表达式 迁移 postgresql 16 怎么改