Lists: | pgsql-hackers |
---|
From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | make_interval ?? |
Date: | 2013-12-20 07:59:41 |
Message-ID: | CAFj8pRAfXSA86NFMHff5UCzLmbR_GTGMh0efNaem7oBdWpqcNw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hello
we have defined interface date, time, timestamp constructors.
There is a question if we would to have some similar for interval type?
As different from time, timestamp there we can use a zero as defaults.
So constructor should to look like:
CREATE OR REPLACE FUNCTION make_interval(years int DEFAULT 0, months int
DEFAULT 0, ...)
and usage:
SELECT make_interval(years := 2)
SELECT make_interval(days := 14)
Is there a interest for this (or similar) function?
Regards
Pavel
From: | Josh Berkus <josh(at)agliodbs(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: make_interval ?? |
Date: | 2013-12-20 17:29:11 |
Message-ID: | 52B47E67.1000205@agliodbs.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Pavel,
> So constructor should to look like:
>
> CREATE OR REPLACE FUNCTION make_interval(years int DEFAULT 0, months int
> DEFAULT 0, ...)
>
> and usage:
>
> SELECT make_interval(years := 2)
> SELECT make_interval(days := 14)
>
> Is there a interest for this (or similar) function?
It would certainly make our Python users happy.
And for that matter would get rid of this kind of stupid thing in stored
procedure code:
time_ahead := ( interval '1 minute' * var_skip );
So, +1 for the feature.
--
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com
From: | Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz> |
---|---|
To: | Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: make_interval ?? |
Date: | 2013-12-20 23:09:03 |
Message-ID: | 52B4CE0F.7010300@archidevsys.co.nz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 21/12/13 06:29, Josh Berkus wrote:
> Pavel,
>
>> So constructor should to look like:
>>
>> CREATE OR REPLACE FUNCTION make_interval(years int DEFAULT 0, months int
>> DEFAULT 0, ...)
>>
>> and usage:
>>
>> SELECT make_interval(years := 2)
>> SELECT make_interval(days := 14)
>>
>> Is there a interest for this (or similar) function?
> It would certainly make our Python users happy.
>
> And for that matter would get rid of this kind of stupid thing in stored
> procedure code:
>
> time_ahead := ( interval '1 minute' * var_skip );
>
> So, +1 for the feature.
>
What about leap years?
Cheers,
Gavin
From: | Josh Berkus <josh(at)agliodbs(dot)com> |
---|---|
To: | Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: make_interval ?? |
Date: | 2013-12-21 00:40:29 |
Message-ID: | 52B4E37D.3030406@agliodbs.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 12/20/2013 03:09 PM, Gavin Flower wrote:
> What about leap years?
What about them?
--
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com
From: | Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz> |
---|---|
To: | Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: make_interval ?? |
Date: | 2013-12-21 00:44:39 |
Message-ID: | 52B4E477.8020207@archidevsys.co.nz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 21/12/13 13:40, Josh Berkus wrote:
> On 12/20/2013 03:09 PM, Gavin Flower wrote:
>> What about leap years?
> What about them?
>
some years have 365 days others have 366, so how any days in an interval
of 2 years?, 4 years?
From: | Josh Berkus <josh(at)agliodbs(dot)com> |
---|---|
To: | Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: make_interval ?? |
Date: | 2013-12-21 01:03:22 |
Message-ID: | 52B4E8DA.4070506@agliodbs.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 12/20/2013 04:44 PM, Gavin Flower wrote:
> On 21/12/13 13:40, Josh Berkus wrote:
>> On 12/20/2013 03:09 PM, Gavin Flower wrote:
>>> What about leap years?
>> What about them?
>>
> some years have 365 days others have 366, so how any days in an interval
> of 2 years?, 4 years?
Your question isn't relevant to this patch. It's not defining the
interval type, just creating an alternate constructor for it.
(the answer is, it depends on what timestamp you're adding it to ...)
--
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com
From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Josh Berkus <josh(at)agliodbs(dot)com> |
Cc: | Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: make_interval ?? |
Date: | 2013-12-21 08:41:12 |
Message-ID: | CAFj8pRBT3jmiGNWQZrhBPA0cr4XfF5+OKHqiwSxBLyCoeo4AQg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hello
here is patch
postgres=# select make_interval(years := 1, months := 6);
make_interval
---------------
1 year 6 mons
(1 row)
postgres=# select make_interval(weeks := 3);
make_interval
---------------
21 days
(1 row)
postgres=# select make_interval(days := 10);
make_interval
---------------
10 days
(1 row)
postgres=# select make_interval(hours := 2, mins := 10, secs := 25.33);
make_interval
---------------
02:10:25.33
(1 row)
Regards
Pavel
2013/12/21 Josh Berkus <josh(at)agliodbs(dot)com>
> On 12/20/2013 04:44 PM, Gavin Flower wrote:
> > On 21/12/13 13:40, Josh Berkus wrote:
> >> On 12/20/2013 03:09 PM, Gavin Flower wrote:
> >>> What about leap years?
> >> What about them?
> >>
> > some years have 365 days others have 366, so how any days in an interval
> > of 2 years?, 4 years?
>
> Your question isn't relevant to this patch. It's not defining the
> interval type, just creating an alternate constructor for it.
>
> (the answer is, it depends on what timestamp you're adding it to ...)
>
> --
> Josh Berkus
> PostgreSQL Experts Inc.
> http://pgexperts.com
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>
Attachment | Content-Type | Size |
---|---|---|
make_timestamp-2013-12-21-01.patch | text/x-patch | 27.6 KB |