Re: review: Reduce palloc's in numeric operations

From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp
Subject: Re: review: Reduce palloc's in numeric operations
Date: 2012-11-21 14:17:50
Message-ID: 50ACE28E.1060404@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 20.11.2012 21:44, Tom Lane wrote:
> init_var_from_num's header comment could use some more work. The
> statement that one "must not modify the returned var" is false in some
> sense, since for instance numeric_ceil() does that. The key is that you
> have to replace the digit buffer not modify it in-place, but most
> computational routines do that anyway. Also it might be worth pointing
> out explicitly that free_var() is not required unless the var is
> modified subsequently. (There are instances of both cases, and it might
> not be clear to the reader why.)

Added those points to the comment.

>> * get_str_from_var() no longer scribbles on its input. I noticed that
>> it's always called with a dscale that comes from the input var itself.
>> In other words, the rounding was unnecessary to begin with.
>
> Hmm, it may have been necessary once upon a time, but I agree getting
> rid of the rounding step is a win now. Suggest adding a comment though
> that the var is displayed to the number of digits indicated by its dscale.
>
> Looks good otherwise.

Committed, thanks to everyone involved.

- Heikki

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-11-21 14:23:11 Re: ERROR: volatile EquivalenceClass has no sortref
Previous Message Boszormenyi Zoltan 2012-11-21 14:12:21 Re: [PATCH] Make pg_basebackup configure and start standby [Review]