pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robert Lichtenberger <r.lichtenberger@synedra.com>
To: pgsql-bugs@lists.postgresql.org
Subject: Restricted interval data type
Date: Wed, 18 Sep 2019 08:10:50 +0200
Message-ID: <40dd257c-91f5-8119-64ee-bc20bc7fbb6c@synedra.com> (raw)

The documentation at
https://www.postgresql.org/docs/11/datatype-datetime.html says:

"The |interval| type has an additional option, which is to restrict the
set of stored fields by writing one of these phrases:"

I have tried this:

aimdevelprocess=# CREATE TABLE rli_foo (x interval hour to second (3));
CREATE TABLE
aimdevelprocess=# \d rli_foo
                             Tabelle »public.rli_foo«
 Spalte |            Typ             | Sortierfolge | NULL erlaubt? |
Vorgabewert
--------+----------------------------+--------------+---------------+-------------
 x      | interval hour to second(3) |              |               |

aimdevelprocess=# INSERT INTO rli_foo(x) VALUES('1 year 2 days
12:13:14.1516');
INSERT 0 1
aimdevelprocess=# SELECT * FROM rli_foo ;
             x             
----------------------------
 1 year 2 days 12:13:14.152
(1 Zeile)

This is surprising to me. I had expected postgres to reject the '1 year
2 days 12:13:14.1516' literal as it does not comply with the restriction
"hour to second".

On the other hand precision seems to work (.1516 gets rounded to .152).

There's not much information on restricted intervals to be found so it
seems I've stumbled across some exotic part of postgresql (or SQL in
general?).

Best regards,

Robert

view thread (2+ messages)  latest in thread

Message-ID: <40dd257c-91f5-8119-64ee-bc20bc7fbb6c@synedra.com>
Permalink:  ../40dd257c-91f5-8119-64ee-bc20bc7fbb6c@synedra.com/
Also on:    postgresql.org/message-id/40dd257c-91f5-8119-64ee-bc20bc7fbb6c@synedra.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: r.lichtenberger@synedra.com
  Subject: Re: Restricted interval data type
  In-Reply-To: <40dd257c-91f5-8119-64ee-bc20bc7fbb6c@synedra.com>
  References: <40dd257c-91f5-8119-64ee-bc20bc7fbb6c@synedra.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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