Re: Add generate_series(numeric, numeric)

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Платон Малюгин <malugin(dot)p(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add generate_series(numeric, numeric)
Date: 2014-09-30 01:00:40
Message-ID: CAB7nPqSjBFVbUJSeaxQrfdSy6ve3dvkwmfEp5Jrg-O=qGEZ+hA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Sep 29, 2014 at 4:19 PM, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
wrote:

>
> Michael
> Btw, while looking at your patch, I actually hacked it a bit and finished
> with the attached:
> - changed process to use NumericVar instead of Numeric
> - addition of custom step values with a function
> generate_series(numeric,numeric,numeric)
> - some cleanup and some comments here and there
> That's still WIP, but feel free to use it for future work. If you are able
> to add documentation and regression tests to this patch, I would recommend
> that you register it to the next commit fest, where it would get more
> review, and hopefully it will get committed.
>
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 initialization of step variable with const_one
- 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.
Platon (am I writing your name correctly??), feel free to pick up the
attached version, it works for me:
=# SELECT * FROM generate_series(0.8, -4, -0.7);
generate_series
-----------------
0.8
0.1
-0.6
-1.3
-2.0
-2.7
-3.4
(7 rows)
=# SELECT * FROM generate_series(0.8, 5, 1.2);
generate_series
-----------------
0.8
2.0
3.2
4.4
(4 rows)
=# SELECT * FROM generate_series(0.8, 5);
generate_series
-----------------
0.8
1.8
2.8
3.8
4.8
(5 rows)
=# SELECT * FROM generate_series(0.8, 5, 0);
ERROR: 22023: step size cannot equal zero
LOCATION: generate_series_numeric, numeric.c:1271

This could be polished more, but I'm sure you'll deal with that well. If
you are able to have a more accompished version for the next commit fest
I'll have a look at it.
Regards,
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2014-09-30 01:01:22 Re: Add generate_series(numeric, numeric)
Previous Message Bruce Momjian 2014-09-30 00:28:45 Re: jsonb format is pessimal for toast compression