merge fdw_bugfix_6.0.0 into 6.0.0

postgres_fdw拓展适配XACT_EVENT_PRE_COMMIT和XACT_EVENT_PRE_PREPARE处理逻辑

Created-by: wofanzheng
Commit-by: wofanzheng
Merged-by: opengauss_bot
Description: 【标题】(请简要描述下实现的内容)
postgres_fdw拓展适配XACT_EVENT_PRE_COMMIT和XACT_EVENT_PRE_PREPARE处理逻辑

【实现内容】:
postgres_fdw拓展适配XACT_EVENT_PRE_COMMIT和XACT_EVENT_PRE_PREPARE处理逻辑

【根因分析】:
49059a76ef 新增两种事件类型XACT_EVENT_PRE_COMMIT和XACT_EVENT_PRE_PREPARE,但是postgres_fdw拓展没有做相应适配,导致pgfdw_xact_callback函数接受到事件XACT_EVENT_PRE_COMMIT之后直接结束了事务。导致外表没有更新成功。

【实现方案】:
pgfdw_xact_callback函数接受到事件XACT_EVENT_PRE_COMMIT之后,直接提交事务
【关联需求或issue】:
https://gitcode.com/opengauss/openGauss-server/issues/7202
【开发自验报告】:
1. 请附上自验结果(内容或者截图)
![image.png](https://raw.gitcode.com/user-images/assets/5089689/ebf2ddb6-8555-4ea8-82ac-507160b76e09/image.png 'image.png')
2. 是否可以添加fastcheck测试用例,如是,请补充fastcheck用例
不涉及
3. 是否涉及资料修改,如是,在docs仓库补充资料
不涉及
4. 是否考虑升级场景(系统表修改、日志持久化以及修改执行态数据格式)
不涉及
5. 是否考虑在线扩容等扩展场景
不涉及
6. 是否考虑异常场景/并发场景/前向兼容/性能场景
不涉及
7. 是否对其他模块产生影响
不涉及
【其他说明】:无

See merge request: opengauss/openGauss-server!7998
This commit is contained in:
opengauss_bot
2025-06-28 09:37:46 +08:00

View File

@ -822,9 +822,22 @@ static void pgfdw_xact_callback(XactEvent event, void *arg)
elog(DEBUG3, "closing remote transaction on connection %p", entry->conn);
switch (event) {
case XACT_EVENT_COMMIT:
case XACT_EVENT_PRE_COMMIT:
pgfdw_xact_callback_commit(entry);
break;
case XACT_EVENT_PRE_PREPARE:
/*
* We disallow any remote transactions, since it's not
* very reasonable to hold them open until the prepared
* transaction is committed. For the moment, throw error
* unconditionally; later we might allow read-only cases.
* Note that the error will cause us to come right back
* here with event == XACT_EVENT_ABORT, so we'll clean up
* the connection state at that point.
*/
elog(ERROR, "cannot PREPARE a transaction that has operated on postgres_fdw foreign tables");
break;
case XACT_EVENT_COMMIT:
case XACT_EVENT_PREPARE:
/* Pre-commit should have closed the open transaction */
elog(ERROR, "missed cleaning up connection during pre-commit");