From: | Brendan Jurd <direvus(at)gmail(dot)com> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: WIP: to_char, support for EEEE format |
Date: | 2009-04-22 16:19:39 |
Message-ID: | 37ed240d0904220919h2ab65f87w1822cff9a246881@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Apr 22, 2009 at 10:13 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
> 2009/4/21 Brendan Jurd <direvus(at)gmail(dot)com>:
>> numstr = orgnum = (char *) palloc(MAXDOUBLEWIDTH + 1);
>> if (Num.pre != 1)
>> ereport(ERROR,
>> (errcode(ERRCODE_SYNTAX_ERROR),
>> errmsg("invalid using of format EEEE")));
>>
>> Rather than rewording all four copies of the message, I wonder if this
>> test might be better factored out into a separate function?
>
> maybe macro is better - it is too short and without any semantic for
> function, but maybe not. The length of source code is not problem -
> the short function will be inlined, so total length will be same. What
> should be name for this function or for this macro? It hasn't any
> semantic. There should be readable macro only for ereport function -
> some
I was thinking of factoring out the *test*, not just the error message.
If I've been reading this code correctly, the purpose of
if (Num.pre != 1)
is to make sure that the numeric format has been given with one digit
before the decimal place (so 9.99EEEE would be acceptable but
99.999EEEE would cause the ERROR).
Because this check is made from various places in the code, it makes
sense to me that it should be a function. Duplicated code makes me
itchy. Perhaps called something like
sci_notation_check_format(NUMDesc *).
Cheers,
BJ
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2009-04-22 16:33:07 | Re: BUG #4774: Bug with use execute+xml+xml_encode_special_chars |
Previous Message | Obe, Regina | 2009-04-22 16:07:32 | Re: Workaround for bug #4608? |