appendBinaryStringInfo stuff

From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: appendBinaryStringInfo stuff
Date: 2022-12-19 06:13:40
Message-ID: a0086cfc-ff0f-2827-20fe-52b591d2666c@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I found a couple of adjacent weird things:

There are a bunch of places in the json code that use
appendBinaryStringInfo() where appendStringInfoString() could be used, e.g.,

appendBinaryStringInfo(buf, ".size()", 7);

Is there a reason for this? Are we that stretched for performance? I
find this kind of code very fragile.

Also, the argument type of appendBinaryStringInfo() is char *. There is
some code that uses this function to assemble some kind of packed binary
layout, which requires a bunch of casts because of this. I think
functions taking binary data plus length should take void * instead,
like memcpy() for example.

Attached are two patches that illustrate these issues and show proposed
changes.

Attachment Content-Type Size
0001-Use-appendStringInfoString-instead-of-appendBinarySt.patch text/plain 6.8 KB
0002-Change-argument-of-appendBinaryStringInfo-from-char-.patch text/plain 5.4 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2022-12-19 06:22:59 Re: [PATCH] Teach pg_waldump to extract FPIs from the WAL
Previous Message Tom Lane 2022-12-19 06:04:08 Re: isolationtester - allow a session specific connection string