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-06 08:44:55 |
Message-ID: | CACQjQLraP1njx=T_LY4jLimRwQGGuT3W9JG7G1N-P5JpUwh8LA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Thanks for the review. Attached the formatted patch according to your
suggestion.
- 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?
>>
> Yes we should.
>
how can we check the overflow after add_var?
(in int.c, the code checks for integer calculation overflow, that wraps the
result to negative value)
in numeric.sql regression test, i've added this query:
select (i / (10::numeric ^ 131071))::numeric(1,0)
from generate_series(-9*(10::numeric ^ 131071),
9*(10::numeric ^ 131071),
(10::numeric ^ 131071))
as a(i);
Because the doc notes that the maximum numeric digit before decimal point
is 131072, i hope this query covers the overflow case (in the last value it
will generate, if we add 9 x 10^13071 with 10^13071, add_var will
overflows). But in my tests, that isn't the case. The code works without
any error and returns the correct rows:
numeric
---------
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
(19 rows)
Regards,
--
Ali Akbar
Attachment | Content-Type | Size |
---|---|---|
20141006_generate_series_numeric.patch | text/x-diff | 13.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Emre Hasegeli | 2014-10-06 09:36:09 | Re: KNN-GiST with recheck |
Previous Message | Marti Raudsepp | 2014-10-06 07:49:35 | Re: CREATE IF NOT EXISTS INDEX |