On Wed, Apr 22, 2009 at 10:13 AM, Pavel Stehule <pavel.steh...@gmail.com> wrote: > 2009/4/21 Brendan Jurd <dire...@gmail.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 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers