Re: Add generate_series(numeric, numeric)

Поиск
Список
Период
Сортировка
От Ali Akbar
Тема Re: Add generate_series(numeric, numeric)
Дата
Msg-id CACQjQLraP1njx=T_LY4jLimRwQGGuT3W9JG7G1N-P5JpUwh8LA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Add generate_series(numeric, numeric)  (Michael Paquier <michael.paquier@gmail.com>)
Ответы Re: Add generate_series(numeric, numeric)
Список 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
Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Marti Raudsepp
Дата:
Сообщение: Re: CREATE IF NOT EXISTS INDEX
Следующее
От: Emre Hasegeli
Дата:
Сообщение: Re: KNN-GiST with recheck