Use appendStringInfoString and appendPQExpBufferStr where possible

Started by Hou, Zhijieabout 6 years ago7 messageshackers
Jump to latest
#1Hou, Zhijie
houzj.fnst@cn.fujitsu.com

Hi hackers

In(/src/bin/scripts/reindexdb.c; /src/backend/access/rmgrdesc/dbasedesc.c; /src/pl/plpython/plpy_elog.c)

I found some more places that should use appendPQExrBufferStr instead of appendPQExpBuffer.

Here is the patch.

Previous Discussion:
/messages/by-id/CAKJS1f9P=M-3ULmPvr8iCno8yvfDViHibJjpriHU8+SXUgeZ=w@mail.gmail.com

Best regards,
Houzj/huangj

Attachments:

0001-appendPQExpBufferStr-instead-of-appendPQExpBuffer.patchapplication/octet-stream; name=0001-appendPQExpBufferStr-instead-of-appendPQExpBuffer.patchDownload+4-5
0001-Use-appendStringInfoString-instead-of-appendStringIn.patchapplication/octet-stream; name=0001-Use-appendStringInfoString-instead-of-appendStringIn.patchDownload+2-3
#2David Rowley
dgrowleyml@gmail.com
In reply to: Hou, Zhijie (#1)
Re: Use appendStringInfoString and appendPQExpBufferStr where possible

On Tue, 22 Sep 2020 at 17:00, Hou, Zhijie <houzj.fnst@cn.fujitsu.com> wrote:

I found some more places that should use appendPQExrBufferStr instead of appendPQExpBuffer.

Here is the patch.

Seems like a good idea. Please add it to the next commitfest.

David

#3Hou, Zhijie
houzj.fnst@cn.fujitsu.com
In reply to: David Rowley (#2)
RE: Use appendStringInfoString and appendPQExpBufferStr where possible

On Tue, 22 Sep 2020 at 17:00, Hou, Zhijie <houzj.fnst@cn.fujitsu.com> wrote:

I found some more places that should use appendPQExrBufferStr instead

of appendPQExpBuffer.

Here is the patch.

Seems like a good idea. Please add it to the next commitfest.

Thanks, added it to the next commitfest.
https://commitfest.postgresql.org/30/2735/

Best regards,
houzj

#4Hou, Zhijie
houzj.fnst@cn.fujitsu.com
In reply to: Hou, Zhijie (#1)
RE: Use appendStringInfoString and appendPQExpBufferStr where possible

Hi

I made a slight update to the patch

I found some more places that should use appendPQExrBufferStr instead

of appendPQExpBuffer.

Here is the patch.

Seems like a good idea. Please add it to the next commitfest.

Thanks, added it to the next commitfest.
https://commitfest.postgresql.org/30/2735/

Best regards,
houzj

Attachments:

0001-Latest-appendStringInfoString-instead-of-appendStringInfo.patchapplication/octet-stream; name=0001-Latest-appendStringInfoString-instead-of-appendStringInfo.patchDownload+3-5
0001-Latest-appendPQExpBufferStr-instead-of-appendPQExpBuffer.patchapplication/octet-stream; name=0001-Latest-appendPQExpBufferStr-instead-of-appendPQExpBuffer.patchDownload+4-5
#5Hou, Zhijie
houzj.fnst@cn.fujitsu.com
In reply to: Hou, Zhijie (#4)
RE: Use appendStringInfoString and appendPQExpBufferStr where possible

Good point. There's another one:

$ git grep -E 'appendStringInfoString.*".{,1}");'
src/backend/utils/adt/ruleutils.c: appendStringInfoString(buf, "(");

I noticed you added a similar thread here.
https://commitfest.postgresql.org/30/

I think this one could be combined as a single patchset with the existing CF entry for the other thread.

Thanks for your response, combined them as a single patchset now.

Best regards,

Attachments:

0001-Latest-appendStringInfoString-instead-of-appendStringInfo.patchapplication/octet-stream; name=0001-Latest-appendStringInfoString-instead-of-appendStringInfo.patchDownload+3-5
0001-appendStringInfoChar-instead-of-appendStringInfoString.patchapplication/octet-stream; name=0001-appendStringInfoChar-instead-of-appendStringInfoString.patchDownload+4-5
0001-Latest-appendPQExpBufferStr-instead-of-appendPQExpBuffer.patchapplication/octet-stream; name=0001-Latest-appendPQExpBufferStr-instead-of-appendPQExpBuffer.patchDownload+4-5
#6David Rowley
dgrowleyml@gmail.com
In reply to: Hou, Zhijie (#5)
Re: Use appendStringInfoString and appendPQExpBufferStr where possible

On Mon, 28 Sep 2020 at 13:47, Hou, Zhijie <houzj.fnst@cn.fujitsu.com> wrote:

Thanks for your response, combined them as a single patchset now.

I had a look over the three patches. All the changes look fine.
Thanks for working on it.

After a bit of grep work, I found about 6 times more calls that could
be improved. These involved searching for appendStringInfo calls that
could become appendStringInfoString calls and also appendPQExpBuffer
that could be converted to appendPQExpBufferStr.

I didn't really go hunting for any other calls that append a 1 char
string that don't use the Char variant of the function. So perhaps
there's more of those to be found.

I've attached the patch I ended up with. I plan on pushing this in the
next few days.

David

Attachments:

fixup_some_appendStringInfo_calls.patchtext/plain; charset=US-ASCII; name=fixup_some_appendStringInfo_calls.patchDownload+210-216
#7David Rowley
dgrowleyml@gmail.com
In reply to: David Rowley (#6)
Re: Use appendStringInfoString and appendPQExpBufferStr where possible

On Wed, 14 Oct 2020 at 21:05, David Rowley <dgrowleyml@gmail.com> wrote:

I've attached the patch I ended up with. I plan on pushing this in the
next few days.

Pushed.

David