兼容性判定
公开资料依据 · 建议 PoC 复核支持度none
严重度major
置信度medium
依据规则ora.func.first_value_ignore_nulls
怎么改
在原 frame 内为非空值编号并定位第一条,再回连到每个源行
判定说明
PostgreSQL 16 的 FIRST_VALUE 始终 RESPECT NULLS,删除选项会静默改变结果;建议 PoC 复核
库侧 / 应用侧路径
库侧改造
可行:用带序号的非空子查询重建窗口结果
应用侧改造
可行:小结果集可在应用窗口计算
推荐路线:db_side。验证建议:覆盖首值非空/为空、全空分区、并列排序键和 ROWS/RANGE 不同 frame;结果行数、空值位置与源端逐行对照
规则样例
SELECT FIRST_VALUE(status) IGNORE NULLS OVER (PARTITION BY id ORDER BY ts) FROM t
SELECT FIRST_VALUE(price) IGNORE NULLS OVER (ORDER BY day ROWS UNBOUNDED PRECEDING) FROM prices
SELECT FIRST_VALUE(status) OVER (PARTITION BY id ORDER BY ts) FROM t
参考来源
- https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/FIRST_VALUE.html
- https://www.postgresql.org/docs/16/functions-window.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://support.huaweicloud.com/intl/en-us/usermanual-ugo/ugo_conv_01_0026.html
相关改造点
- 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 怎么改