From: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
---|---|
To: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> |
Cc: | Ali Akbar <the(dot)apaan(at)gmail(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Marti Raudsepp <marti(at)juffo(dot)org>, Платон Малюгин <malugin(dot)p(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Add generate_series(numeric, numeric) |
Date: | 2014-12-18 12:35:11 |
Message-ID: | CAHGQGwHDFxh1g8zcbc1BfiX4TeWKdwOuhou7_S5N4D5jHip5tA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Dec 15, 2014 at 2:38 PM, Andrew Gierth
<andrew(at)tao11(dot)riddles(dot)org(dot)uk> wrote:
>>>>>> "Ali" == Ali Akbar <the(dot)apaan(at)gmail(dot)com> writes:
>
> Ali> I think yes, it will be good. The alternative is restructuring
> Ali> this paragraph in the SRF docs:
>
> >> The memory context that is current when the SRF is called is a
> >> transient context that will be cleared between calls. This means
> >> that you do not need to call pfree on everything you allocated
> >> using palloc; it will go away anyway. However, if you want to
> >> allocate any data structures to live across calls, you need to put
> >> them somewhere else. The memory context referenced by
> >> multi_call_memory_ctx is a suitable location for any data that
> >> needs to survive until the SRF is finished running. In most cases,
> >> this means that you should switch into multi_call_memory_ctx while
> >> doing the first-call setup.
>
> Ali> The important part "However, if you want to allocate any data
> Ali> structures to live across calls, you need to put them somewhere
> Ali> else." is buried in the docs.
>
> Ali> But i think explicit warning is more noticeable for new
> Ali> developer like me.
>
> I was thinking something like this, added just after that para:
>
> <warning>
> <para>
> While the actual arguments to the function remain unchanged between
> calls, if you detoast the argument values (which is normally done
> transparently by the
> <function>PG_GETARG_<replaceable>xxx</replaceable></function> macro)
> in the transient context then the detoasted copies will be freed on
> each cycle. Accordingly, if you keep references to such values in
> your <structfield>user_fctx</>, you must either copy them into the
> <structfield>multi_call_memory_ctx</> after detoasting, or ensure
> that you detoast the values only in that context.
> </para>
> </warning>
I'm OK with this.
Regards,
--
Fujii Masao
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2014-12-18 12:45:08 | Re: no test programs in contrib |
Previous Message | Fujii Masao | 2014-12-18 12:21:18 | Re: Add generate_series(numeric, numeric) |