pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Use psprintf to simplify gtsvectorout()
Date: Tue, 06 Aug 2024 20:11:45 +0000
Message-ID: <E1sbQX3-00315U-A8@gemulon.postgresql.org> (raw)

Use psprintf to simplify gtsvectorout()

The buffer allocation was correct, but looked archaic and scary:

- It was weird to calculate the buffer size before determining which
  format string was used. With the same effort, we could've used the
  right-sized buffer for each branch.

- Commit aa0d3504560 added one more possible return string ("all true
  bits"), but didn't adjust the code at the top of the function to
  calculate the returned string's max size. It was not a live bug,
  because the new string was smaller than the existing ones, but
  seemed wrong in principle.

- Use of sprintf() is generally eyebrow-raising these days

Switch to psprintf(). psprintf() allocates a larger buffer than what
was allocated before, 128 bytes vs 80 bytes, which is acceptable as
this code is not performance or space critical.

Reviewed-by: Andres Freund
Discussion: https://www.postgresql.org/message-id/54c29fb0-edf2-48ea-9814-44e918bbd6e8@iki.fi

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3ab2668d48476e31d8809fbb36c9ee739cc444e1

Modified Files
--------------
src/backend/utils/adt/tsgistidx.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)



Message-ID: <E1sbQX3-00315U-A8@gemulon.postgresql.org>
Permalink:  ../E1sbQX3-00315U-A8@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1sbQX3-00315U-A8@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: heikki.linnakangas@iki.fi, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Use psprintf to simplify gtsvectorout()
  In-Reply-To: <E1sbQX3-00315U-A8@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox