Re: [PATCH] pg_convert improvement

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: "Drouvot, Bertrand" <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: Yurii Rashkovskii <yrashk(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] pg_convert improvement
Date: 2023-12-01 21:50:39
Message-ID: 20231201215039.GA1668447@nathanxps13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tristan Partin 2023-12-01 21:55:29 Re: pgsql: meson: docs: Add {html,man} targets, rename install-doc-*
Previous Message Tristan Partin 2023-12-01 21:48:54 Re: Improving asan/ubsan support