pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #12872: Inconsistent processing of interval values
3+ messages / 3 participants
[nested] [flat]

* BUG #12872: Inconsistent processing of interval values
@ 2015-03-16 23:03  jan.mate@inf-it.com
  0 siblings, 1 reply; 3+ messages in thread

From: jan.mate@inf-it.com @ 2015-03-16 23:03 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      12872
Logged by:          Jan Mate
Email address:      jan.mate@inf-it.com
PostgreSQL version: 9.4.1
Operating system:   Debian GNU/Linux 7
Description:        

Postgresql 9.4 documentation says:

Interval values can be written using the following verbose syntax:

[@] quantity unit [quantity unit...] [direction]

but it works ONLY if a unit is used exactly once, e.g.:

testdb=> SELECT (now()-' +5 days -12 hours -1 second +1 week'::interval) AS
tstz;
             tstz              
-------------------------------
 2015-03-05 11:36:08.646603+01
(1 row)

works, but:

testdb=> SELECT (now()-' +5 days -12 hours -1 second +1 day'::interval) AS
tstz;
ERROR:  invalid input syntax for type interval: " +5 days -12 hours -1
second +1 day"
LINE 1: SELECT (now()-' +5 days -12 hours -1 second +1 day'::interva...

generates an error. Yes, I understand that writing '+5 days +1 day' is
"stupid" but it conforms the syntax in the documentation.


JM


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #12872: Inconsistent processing of interval values
@ 2015-03-17 19:45  Bruce Momjian <bruce@momjian.us>
  parent: jan.mate@inf-it.com
  0 siblings, 1 reply; 3+ messages in thread

From: Bruce Momjian @ 2015-03-17 19:45 UTC (permalink / raw)
  To: jan.mate@inf-it.com; +Cc: pgsql-bugs

On Mon, Mar 16, 2015 at 11:03:52PM +0000, jan.mate@inf-it.com wrote:
> works, but:
> 
> testdb=> SELECT (now()-' +5 days -12 hours -1 second +1 day'::interval) AS
> tstz;
> ERROR:  invalid input syntax for type interval: " +5 days -12 hours -1
> second +1 day"
> LINE 1: SELECT (now()-' +5 days -12 hours -1 second +1 day'::interva...
> 
> generates an error. Yes, I understand that writing '+5 days +1 day' is
> "stupid" but it conforms the syntax in the documentation.

Well, I think we have always had that restriction, and you are the first
person to mention it.  Are you thinking we should document this
limitation?

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + Everyone has their own god. +


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #12872: Inconsistent processing of interval values
@ 2015-03-17 22:09  Ján Máté <jan.mate@inf-it.com>
  parent: Bruce Momjian <bruce@momjian.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Ján Máté @ 2015-03-17 22:09 UTC (permalink / raw)
  To: Bruce Momjian <bruce@momjian.us>; +Cc: pgsql-bugs

Hi Bruce,

> On 17 Mar 2015, at 20:45, Bruce Momjian <bruce@momjian.us> wrote:
> 
> On Mon, Mar 16, 2015 at 11:03:52PM +0000, jan.mate@inf-it.com wrote:
>> works, but:
>> 
>> testdb=> SELECT (now()-' +5 days -12 hours -1 second +1 day'::interval) AS
>> tstz;
>> ERROR:  invalid input syntax for type interval: " +5 days -12 hours -1
>> second +1 day"
>> LINE 1: SELECT (now()-' +5 days -12 hours -1 second +1 day'::interva...
>> 
>> generates an error. Yes, I understand that writing '+5 days +1 day' is
>> "stupid" but it conforms the syntax in the documentation.
> 
> Well, I think we have always had that restriction, and you are the first
> person to mention it.  Are you thinking we should document this
> limitation?

yes, document it or allow to use the same unit multiple times. The documentation
fix looks as the easier solution ...


JM

Attachments:

  smime.p7s (application/pkcs7-signature, 4.1K) download

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2015-03-17 22:09 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-03-16 23:03 BUG #12872: Inconsistent processing of interval values jan.mate@inf-it.com
2015-03-17 19:45 ` Bruce Momjian <bruce@momjian.us>
2015-03-17 22:09   ` Ján Máté <jan.mate@inf-it.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox