Re: Extract numeric filed in JSONB more effectively

From: Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Extract numeric filed in JSONB more effectively
Date: 2023-08-08 02:28:18
Message-ID: CAKU4AWoiVeBAQNXC-ih20Ck2W8=e=WT0J+OixuuC4X0ROFvrqA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi:

On Mon, Aug 7, 2023 at 7:51 PM Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com> wrote:

> Hi Jian:
>
> Thanks for the review!
>
> compared with jsonb_numeric. I am wondering if you need a free *jb.
>> elog(INFO,"jb=%p arg pointer=%p ", jb, PG_GETARG_POINTER(0));
>> says there two are not the same.
>>
>
> Thanks for pointing this out, I am not sure what to do right now.
> Basically the question is that shall we free the memory which
> is allocated in a function call. The proof to do it is obvious, but the
> proof to NOT do it may be usually the memory is allocated under
> ExprContext Memorycontext, it will be reset once the current
> tuple is proceed, and MemoryContextReset will be more effective
> than pfrees;
>

I just found Andres's opinion on this, it looks like he would suggest
not free it [1], and the reason is similar here [2], so I would like to
keep it as it is.

[1]
https://www.postgresql.org/message-id/20230216213554.vintskinrqqrxf6d%40awork3.anarazel.de

[2]
https://www.postgresql.org/message-id/20230217202626.ihd55rgxgkr2uqim%40awork3.anarazel.de

--
Best Regards
Andy Fan

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro Horiguchi 2023-08-08 02:53:32 Re: WIP: new system catalog pg_wait_event
Previous Message David Rowley 2023-08-08 02:25:16 Re: [PATCH] [zh_CN.po] fix a typo in simplified Chinese translation file