Re: Add generate_series(numeric, numeric) - Mailing list pgsql-hackers

From Ali Akbar
Subject Re: Add generate_series(numeric, numeric)
Date
Msg-id CACQjQLpHYymSnF4prwaJN3Wa9ppfEtDTqR0BNVuQ0FjeUgTVNw@mail.gmail.com
Whole thread Raw
In response to Re: Add generate_series(numeric, numeric)  (Marti Raudsepp <marti@juffo.org>)
Responses Re: Add generate_series(numeric, numeric)
List pgsql-hackers
2014-10-06 22:51 GMT+07:00 Marti Raudsepp <marti@juffo.org>:
That's fine I think, it's just for tracking who made the changes in
the CommitFest app. What actually matters is what you write in the
"Author" field, which could contain all 3 names separated by commas.

 
> the one that tests values just before numeric overflow

Actually I don't know if that's too useful. I think you should add a
test case that causes an error to be thrown.
 
Actually i added the test case because in the code, when adding step into current for the last value, i expected it to overflow:

/* increment current in preparation for next iteration */
add_var(&fctx->current, &fctx->step, &fctx->current);

where in the last calculation, current is 9 * 10^131071. Plus 10^131071, it will be 10^131072, which i expected to overflow numeric type (in the doc, numeric's range is "up to 131072 digits before the decimal point").

In attached patch, i narrowed the test case to produce smaller result.

Also, I noticed that there are a few trailing spaces in the patch that
should be removed:

+generate_series_numeric(PG_FUNCTION_ARGS)
...
+               if (NUMERIC_IS_NAN(start_num) || NUMERIC_IS_NAN(finish_num))
...
+               if (PG_NARGS() == 3)
...
+                       if (NUMERIC_IS_NAN(step_num))

Ah, didn't see it. Thanks. Fixed in this patch.


Regards,
--
Ali Akbar
Attachment

pgsql-hackers by date:

Previous
From: Jim Nasby
Date:
Subject: Re: Proposal for better support of time-varying timezone abbreviations
Next
From: Jim Nasby
Date:
Subject: Re: Add regression tests for autocommit-off mode for psql and fix some omissions