From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
---|---|
To: | Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com> |
Cc: | Justin Pryzby <pryzby(at)telsasoft(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Fix possible bogus array out of bonds (src/backend/access/brin/brin_minmax_multi.c) |
Date: | 2022-09-05 13:40:43 |
Message-ID: | CAApHDvqT=v15PRz0YXFJzczi6NirzR_vrk-ekCz9VEeTP84Fmw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, 5 Sept 2022 at 22:15, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
> On Sat, 3 Sept 2022 at 00:37, Ranier Vilela <ranier(dot)vf(at)gmail(dot)com> wrote:
> > 6. Avoid overhead when using unnecessary StringInfoData to convert Datum a to Text b.
>
> I've ripped out #4 and #6 for now. I think we should do #6 in master
> only, probably as part of a wider cleanup of StringInfo misusages.
I've attached a patch which does various other string operation cleanups.
* This changes cstring_to_text() to use cstring_to_text_with_len when
we're working with a StringInfo and can just access the .len field.
* Uses appendStringInfoString instead of appendStringInfo when there
is special formatting.
* Uses pstrdup(str) instead of psprintf("%s", str). In many cases
this will save a bit of memory
* Uses appendPQExpBufferChar instead of appendPQExpBufferStr() when
appending a 1 byte string.
* Uses appendStringInfoChar() instead of appendStringInfo() when no
formatting and string is 1 byte.
* Uses appendStringInfoChar() instead of appendStringInfoString() when
string is 1 byte.
* Uses appendPQExpBuffer(b , ...) instead of appendPQExpBufferStr(b, "%s" ...)
I'm aware there are a few other places that we could use
cstring_to_text_with_len() instead of cstring_to_text(). For example,
using the return value of snprintf() to obtain the length. I just
didn't do that because we need to take care to check the return value
isn't -1.
My grep patterns didn't account for these function calls spanning
multiple lines, so I may have missed a few.
David
Attachment | Content-Type | Size |
---|---|---|
string_fixes.patch | text/plain | 7.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | David Rowley | 2022-09-05 13:41:55 | Re: Reducing the chunk header sizes on all memory context types |
Previous Message | Kazutaka Onishi | 2022-09-05 13:32:19 | Re: Asynchronous execution support for Custom Scan |