> For the complete documentation index, see [llms.txt](https://docs.postgresql.tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.postgresql.tw/19/server-administration/logical-replication/logical-replication-row-filter/logical-replication-row-filter-transformations.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# 29.4.3. UPDATE 轉換

## 29.4.3. UPDATE 轉換 [#](#logical-replication-row-filter-transformations) <a href="#logical-replication-row-filter-transformations" id="logical-replication-row-filter-transformations"></a>

每當處理一筆 `UPDATE` 時，會分別以更新前與更新後的資料列（即舊資料與新資料）來求值資料列篩選運算式。若兩者求值結果皆為 `true`，則複寫該筆 `UPDATE` 異動。若兩者求值結果皆為 `false`，則不複寫該筆異動。若只有其中一筆（舊資料或新資料）符合資料列篩選運算式，則該筆 `UPDATE` 會被轉換為 `INSERT` 或 `DELETE`，以避免資料不一致。訂閱者上的資料列應反映發布者上資料列篩選運算式所定義的結果。

若舊資料列滿足篩選運算式（因此已送至訂閱者），但新資料列不滿足，則從資料一致性的角度來看，應將該舊資料列從訂閱者移除。因此該 `UPDATE` 會被轉換為 `DELETE`。

若舊資料列不滿足篩選運算式（因此未送至訂閱者），但新資料列滿足，則從資料一致性的角度來看，應將該新資料列加入訂閱者。因此該 `UPDATE` 會被轉換為 `INSERT`。

[表 29.1](#logical-replication-row-filter-transformations-summary) 彙整了套用的轉換規則。

### 表 29.1. `UPDATE` 轉換彙整 [#](#logical-replication-row-filter-transformations-summary) <a href="#logical-replication-row-filter-transformations-summary" id="logical-replication-row-filter-transformations-summary"></a>

| 舊資料列 | 新資料列 | 轉換方式     |
| ---- | ---- | -------- |
| 不符合  | 不符合  | 不複寫      |
| 不符合  | 符合   | `INSERT` |
| 符合   | 不符合  | `DELETE` |
| 符合   | 符合   | `UPDATE` |

<br>

[返回 29.4. 資料列篩選器](https://docs.postgresql.tw/19/server-administration/logical-replication/logical-replication-row-filter.md#logical-replication-row-filter)

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/logical-replication-row-filter.html)（原文版本：18.6；核對日期：2026-09-25）


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.postgresql.tw/19/server-administration/logical-replication/logical-replication-row-filter/logical-replication-row-filter-transformations.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
