Re: [PATCH v1] PQputCopyEnd never returns 0, fix the inaccurate comment

From: Aleksander Alekseev <aleksander(at)timescale(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Junwang Zhao <zhjwpku(at)gmail(dot)com>
Subject: Re: [PATCH v1] PQputCopyEnd never returns 0, fix the inaccurate comment
Date: 2023-08-28 11:48:05
Message-ID: CAJ7c6TOBaqrah+coyWEH4FvNUmdXd9=3WgALVNRPGOfjpYae2g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Junwang,

> PQputCopyEnd returns 1 or -1, never 0, I guess the comment was
> copy/paste from PQputCopyData's comment, this should be fixed.

The patch LGTM but I wonder whether we should also change all the
existing calls of PQputCopyEnd() from:

```
PQputCopyEnd(...) <= 0
```

... to:

```
PQputCopyEnd(...) < 0
```

Given the circumstances, checking for equality to zero seems to be at
least strange.

On top of that, none of the PQputCopyData() callers cares whether the
function returns 0 or -1, both are treated the same way. I suspect the
function does some extra work no one asked to do and no one cares
about. Perhaps this function should be refactored too for consistency.

Thoughts?

--
Best regards,
Aleksander Alekseev

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hayato Kuroda (Fujitsu) 2023-08-28 11:48:14 RE: persist logical slots to disk during shutdown checkpoint
Previous Message Pavel Stehule 2023-08-28 11:38:57 Wrong usage of pqMsg_Close message code?