Re: Fix possible bogus array out of bonds (src/backend/access/brin/brin_minmax_multi.c)
От | David Rowley |
---|---|
Тема | Re: Fix possible bogus array out of bonds (src/backend/access/brin/brin_minmax_multi.c) |
Дата | |
Msg-id | CAApHDvqT=v15PRz0YXFJzczi6NirzR_vrk-ekCz9VEeTP84Fmw@mail.gmail.com обсуждение исходный текст |
Ответ на | Fix possible bogus array out of bonds (src/backend/access/brin/brin_minmax_multi.c) (Ranier Vilela <ranier.vf@gmail.com>) |
Список | pgsql-hackers |
On Mon, 5 Sept 2022 at 22:15, David Rowley <dgrowleyml@gmail.com> wrote: > On Sat, 3 Sept 2022 at 00:37, Ranier Vilela <ranier.vf@gmail.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
Вложения
В списке pgsql-hackers по дате отправления: