Re: [PATCH] pg_convert improvement - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: [PATCH] pg_convert improvement
Date
Msg-id 20231201215039.GA1668447@nathanxps13
Whole thread Raw
In response to Re: [PATCH] pg_convert improvement  ("Drouvot, Bertrand" <bertranddrouvot.pg@gmail.com>)
Responses Re: [PATCH] pg_convert improvement
List pgsql-hackers
On Mon, Nov 27, 2023 at 08:11:06AM +0100, Drouvot, Bertrand wrote:
> +        PG_RETURN_BYTEA_P(string);

I looked around to see whether there was some sort of project policy about
returning arguments without copying them, but the only strict rule I see is
to avoid scribbling on argument data without first copying it.  However, I
do see functions that return unmodified arguments both with and without
copying.  For example, unaccent_dict() is careful to copy the argument
before returning it:

    PG_RETURN_TEXT_P(PG_GETARG_TEXT_P_COPY(strArg));

But replace_text() is not:

    /* Return unmodified source string if empty source or pattern */
    if (src_text_len < 1 || from_sub_text_len < 1)
    {
        PG_RETURN_TEXT_P(src_text);
    }

I don't have any specific concerns about doing this, though.  Otherwise,
the patch looks pretty good to me, so I will plan on committing it shortly.

-- 
Nathan Bossart
Amazon Web Services: https://aws.amazon.com



pgsql-hackers by date:

Previous
From: "Tristan Partin"
Date:
Subject: Re: Improving asan/ubsan support
Next
From: "Tristan Partin"
Date:
Subject: Re: pgsql: meson: docs: Add {html,man} targets, rename install-doc-*