Lists: | pgsql-hackers |
---|
From: | Anton Voloshin <a(dot)voloshin(at)postgrespro(dot)ru> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | possible repalloc() in icu_convert_case() |
Date: | 2021-04-04 15:34:47 |
Message-ID: | f21e4ba9-8db8-91bf-067a-fcacb429ac55@postgrespro.ru |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hello,
in src/backend/utils/adt/formatting.c, in icu_convert_case() I see:
if (status == U_BUFFER_OVERFLOW_ERROR)
{
/* try again with adjusted length */
pfree(*buff_dest);
*buff_dest = palloc(len_dest * sizeof(**buff_dest));
...
Is there any reason why this should not be repalloc()?
In case it should be, I've attached a corresponding patch.
--
Anton Voloshin
Postgres Professional: https://www.postgrespro.com
Russian Postgres Company
Attachment | Content-Type | Size |
---|---|---|
repalloc-in-adt-formatting.patch | text/plain | 721 bytes |
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Anton Voloshin <a(dot)voloshin(at)postgrespro(dot)ru> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: possible repalloc() in icu_convert_case() |
Date: | 2021-04-04 16:20:38 |
Message-ID: | 172640.1617553238@sss.pgh.pa.us |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-hackers |
Anton Voloshin <a(dot)voloshin(at)postgrespro(dot)ru> writes:
> in src/backend/utils/adt/formatting.c, in icu_convert_case() I see:
> if (status == U_BUFFER_OVERFLOW_ERROR)
> {
> /* try again with adjusted length */
> pfree(*buff_dest);
> *buff_dest = palloc(len_dest * sizeof(**buff_dest));
> ...
> Is there any reason why this should not be repalloc()?
repalloc is likely to be more expensive, since it implies copying
data which isn't helpful here. I think this code is fine as-is.
regards, tom lane
From: | Anton Voloshin <a(dot)voloshin(at)postgrespro(dot)ru> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: possible repalloc() in icu_convert_case() |
Date: | 2021-04-04 18:09:33 |
Message-ID: | 89faaa6f-1b80-a983-235a-f3173f834359@postgrespro.ru |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 04.04.2021 19:20, Tom Lane wrote:
> repalloc is likely to be more expensive, since it implies copying
> data which isn't helpful here. I think this code is fine as-is.
Oh, you are right, thanks. I did not think properly about copying in
repalloc.
--
Anton Voloshin
Postgres Professional: https://www.postgrespro.com
Russian Postgres Company