Re: Avoid repeated scans of the output buffer in oidvectortypes()

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Japin Li <japinli(at)hotmail(dot)com>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Avoid repeated scans of the output buffer in oidvectortypes()
Date: 2026-10-15 10:43:21
Message-ID: CAApHDvrohiJTHJHpyvV48KJh4S_-gB3bu21LKqC7jmDy1K9aGQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 15 Oct 2026 at 23:20, Japin Li <japinli(at)hotmail(dot)com> wrote:
> I believe the current patch is the smallest correct fix. Introducing StringInfo
> would be unnecessary over-engineering.

I'm assuming this is master only, so why does it need to be a minimal
fix? StringInfo is just the way we normally do incremental building of
strings. It's an API that most people who work on our code understand.
Manually calling repalloc() is tedious and more likely to have bugs.

Using StringInfo will also cut down on the number of reallocs due to
the size doubling. It'll also allow the
PG_RETURN_TEXT_P(cstring_to_text(result)); to be updated to use
cstring_to_text_with_len using the StringInfo's len field.

David

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2026-10-15 10:51:46 Re: SUM(int2)/SUM(int4) do not detect overflow of the int8 accumulator
Previous Message Matthias van de Meent 2026-10-15 10:41:19 Re: Fix numeric log() with an infinite value and 0<base<=1