Re: Fixup some appendStringInfo and appendPQExpBuffer calls

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
Cc: "houzj(dot)fnst(at)fujitsu(dot)com" <houzj(dot)fnst(at)fujitsu(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fixup some appendStringInfo and appendPQExpBuffer calls
Date: 2021-06-03 03:51:48
Message-ID: CAApHDvq1D=ehZ8hey8Hz67N+_Zth0GHO5wiVCfv1YcGPMXJq0A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 3 Jun 2021 at 15:06, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
>
> On Thu, 3 Jun 2021 at 15:01, Michael Paquier <michael(at)paquier(dot)xyz> wrote:
> > As you already did
> > 110d817, perhaps you would prefer taking care of it?
>
> Ok. I'll take care of it.

I looked at this and couldn't help but notice how the following used
DatumGetPointer() instead of DatumGetCString():

appendStringInfo(&str, "%s ... %s",
DatumGetPointer(a),
DatumGetPointer(b));

However, looking a bit further it looks like instead of using
FunctionCall1 to call the type's output function, that the code should
use OutputFunctionCall and get a char * directly.

e.g the attached.

There are quite a few other places in that file that should be using
DatumGetCString() instead of DatumGetPointer().

Should we fix those too for PG14?

In the meantime, I'll push a version of this with just the StringInfo
fixes first. If we do anything else it can be done as a separate
commit.

David

Attachment Content-Type Size
appendstringinfo_fixes_v2.patch application/octet-stream 4.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2021-06-03 03:59:28 Re: Decoding of two-phase xacts missing from CREATE_REPLICATION_SLOT command
Previous Message osumi.takamichi@fujitsu.com 2021-06-03 03:48:20 RE: locking [user] catalog tables vs 2pc vs logical rep