| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Cc: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
| Subject: | Fix reversed slot types in copy_replication_slot() error messages |
| Date: | 2026-12-02 07:52:36 |
| Message-ID: | 898A4341-1EDA-4A4C-A3AF-532156B78CCF@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
While reviewing patch [1], I spotted an incorrect error message in copy_replication_slot().
```
/* Check type of replication slot */
if (src_islogical != logical_slot)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
src_islogical ?
errmsg("cannot copy physical replication slot \"%s\" as a logical replication slot",
NameStr(*src_name)) :
errmsg("cannot copy logical replication slot \"%s\" as a physical replication slot",
NameStr(*src_name))));
```
The two errmsg() calls are reversed. The existing test output in contrib/test_decoding/expected/slot.out shows the bug:
```
-- Cannot copy a logical slot to a physical slot
SELECT 'copy' FROM pg_copy_physical_replication_slot('orig_slot2', 'failed'); -- error
ERROR: cannot copy physical replication slot "orig_slot2" as a logical replication slot
-- Cannot copy a physical slot to a logical slot
SELECT 'copy' FROM pg_copy_logical_replication_slot('orig_slot1', 'failed'); -- error
ERROR: cannot copy logical replication slot "orig_slot1" as a physical replication slot
```
In both cases, the error message and the comment say opposite directions.
The fix is straightforward. The attached patch swaps the two errmsg() calls and updates the expected output. This was an oversight in 9f06d79e, so it may be worth back-patching to v15.
[1] https://postgr.es/m/CA+sbV4ggbjOQDjREuy1kH4nzGR+qBcNoSe+iS4cyFz5Ny1bu2Q@mail.gmail.com
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Fix-reversed-slot-types-in-copy_replication_slot-.patch | application/octet-stream | 2.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Paul Kim | 2026-12-02 07:59:00 | Re: Be strict when request to flush past end of WAL in WaitXLogInsertionsToFinish |
| Previous Message | Amit Langote | 2026-12-02 07:44:28 | executor startup doesn't skip sub-partitions of a pruned partition |