From: | Ali Akbar <the(dot)apaan(at)gmail(dot)com> |
---|---|
To: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
Cc: | Платон Малюгин <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-10-05 10:39:37 |
Message-ID: | CACQjQLqHgy1Da0K9oYvCEYq1XumRriZhdMyU4o2z+p6pUp7uEw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
2014-10-05 15:21 GMT+07:00 Ali Akbar <the(dot)apaan(at)gmail(dot)com>:
> Hi
> Oops, it seems that I have been too hasty here. With a fresh mind I looked
> at my own patch again and found two bugs:
>
>
>>> - Incorrect calculation of each step's value, making stuff crash, it is
>>> necessary to switch to the context of the function to perform operations on
>>> a temporary variable first
>>>
>>
> - i think you can use the fctx->current variable without temporary
> variable (there's comment in the add_var function: Full version of add
> functionality on variable level (handling signs). result might point to one
> of the operands too without danger.). But you _must_ switch the context
> first because add_var will allocate new array for the data and freeing the
> old one.
>
> - numeric can be NaN. We must reject it as first, finish and last
> parameter.
> - numeric datatype is large, but there are limitations. According to doc,
> the limit is: up to 131072 digits before the decimal point; up to 16383
> digits after the decimal point. How can we check if the next step
> overflows? As a comparison, in int.c, generate_series_step_int4 checks if
> its overflows, and stop the next call by setting step to 0. Should we do
> that?
>
> ~ will try to fix the patch later
>
attached the patch. Not checking if it overflows, but testing it with 9 *
10 ^ 131072 works (not resulting in an error). Other modifications:
- doc update
- regresssion tests
- while testing regression test, opr_sanity checks that the
generate_series_numeric function is used twice (once for 2 parameter and
once for the 3 parameter function), so i changed the name to
generate_series_step_numeric and created new function
generate_series_numeric that calls generate_series_step_numeric
--
Ali Akbar
Attachment | Content-Type | Size |
---|---|---|
20141005_generate_series_numeric.patch | text/x-diff | 13.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Ali Akbar | 2014-10-05 10:50:49 | Re: Add generate_series(numeric, numeric) |
Previous Message | Pavel Stehule | 2014-10-05 10:30:52 | RLS with check option - surprised design |