pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Remove useless pstrdups in untransformRelOptions
Date: Tue, 13 Sep 2022 10:00:15 +0000
Message-ID: <E1oY2iF-0008wJ-00@gemulon.postgresql.org> (raw)

Remove useless pstrdups in untransformRelOptions

The two strings are already a single palloc'd chunk, not freed; there's
no reason to allocate separate copies that have the same lifetime.

This code is only called in short-lived memory contexts (except in some
cases in TopTransactionContext, which is still short-lived enough not to
really matter), and typically only for short arrays, so the memory or
computation saved is likely negligible.  However, let's fix it to avoid
leaving a bad example of code to copy.  This is the only place I could
find where we're doing this with makeDefElem().

Reported-by: Junwang Zhao <zhjwpku@gmail.com>
Discussion: https://postgr.es/m/20220909142050.3vv2hjekppk265dd@alvherre.pgsql

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6710e83a675eda798544fea4cdcb89eef7f39403

Modified Files
--------------
src/backend/access/common/reloptions.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)



Message-ID: <E1oY2iF-0008wJ-00@gemulon.postgresql.org>
Permalink:  ../E1oY2iF-0008wJ-00@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1oY2iF-0008wJ-00@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: alvherre@alvh.no-ip.org
  Subject: Re: pgsql: Remove useless pstrdups in untransformRelOptions
  In-Reply-To: <E1oY2iF-0008wJ-00@gemulon.postgresql.org>
  References: <E1oY2iF-0008wJ-00@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