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+is4cyfz5ny1b...@mail.gmail.com

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/




Attachment: v1-0001-Fix-reversed-slot-types-in-copy_replication_slot-.patch
Description: Binary data

Reply via email to