walker83 commented on issue #2229:
URL: https://github.com/apache/age/issues/2229#issuecomment-3537494266

   PostgreSQL 18 + Apache AGE 兼容性修复总结
   
     问题概述
     Apache AGE 目前(截至 2025 年 11 月)尚未正式支持 PostgreSQL 18,编译时会遇到 API 不兼容的问题。
   
     主要问题
     编译错误显示 PostgreSQL 18 中的 ExecInitExtraTupleSlot 函数签名发生了变化。具体错误:
   
      1 error: call to undeclared function 'ExecInitExtraTupleSlot'
   
     修复方案
   
     1. 识别问题函数
     找到三个文件中使用 ExecInitExtraTupleSlot 的位置:
      - src/backend/catalog/ag_label.c (第 313 行)
      - src/backend/executor/cypher_delete.c (第 495 行)
      - src/backend/executor/cypher_merge.c (第 167 行)
   
     2. 实施兼容性修复
     使用条件编译来处理不同版本的 PostgreSQL:
   
     在 `ag_label.c` 中:
   
      1 #if PG_VERSION_NUM >= 180000
      2     slot = 
MakeSingleTupleTableSlot(RelationGetDescr(resultRelInfo->ri_RelationDesc), 
&TTSOpsHeapTuple);
      3 #else
      4     slot = ExecInitExtraTupleSlot(
      5         estate, RelationGetDescr(resultRelInfo->ri_RelationDesc),
      6         &TTSOpsHeapTuple);
      7 #endif
   
     在 `cypher_delete.c` 中:
   
      1 #if PG_VERSION_NUM >= 180000
      2     slot = 
MakeSingleTupleTableSlot(RelationGetDescr(resultRelInfo->ri_RelationDesc), 
&TTSOpsHeapTuple);
      3 #else
      4     slot = ExecInitExtraTupleSlot(
      5         estate, RelationGetDescr(resultRelInfo->ri_RelationDesc),
      6         &TTSOpsHeapTuple);
      7 #endif
   
     在 `cypher_merge.c` 中:
   
      1 #if PG_VERSION_NUM >= 180000
      2     cypher_node->elemTupleSlot = 
MakeSingleTupleTableSlot(RelationGetDescr(cypher_node->resultRelInfo->ri_RelationDesc),
 &TTSOpsHeapTuple);
      3 #else
      4     cypher_node->elemTupleSlot = ExecInitExtraTupleSlot(
      5         estate,
      6         RelationGetDescr(cypher_node->resultRelInfo->ri_RelationDesc),
      7         &TTSOpsHeapTuple);
      8 #endif
   
     修复说明
      - PostgreSQL 18 及更高版本:使用 MakeSingleTupleTableSlot 函数
      - PostgreSQL 17 及更早版本:使用原有的 ExecInitExtraTupleSlot 函数(带 3 个参数)
      - 通过 PG_VERSION_NUM >= 180000 宏进行版本判断
   
     后续问题
     修复初始问题后,还发现了 PostgreSQL 18 中更多的 API 变更,涉及:
      - ExecInitNode, ExecAssignExprContext, ExecInitScanTupleSlot
      - ExecGetResultType, ExecAssignProjectionInfo, InitResultRelInfo
      - ExecOpenIndices, ExecCloseIndices, ExecProject, ExecProcNode
   
     当前状态
      - ✅ 成功修复了初始的 ExecInitExtraTupleSlot 问题
      - ✅ 实现了条件编译兼容性
      - ❌ 发现更多需要修复的 API 变更(需要更彻底的代码适配)
   
     结论
     这个修复可以作为 Apache AGE 官方支持 PostgreSQL 18 的起点


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to