Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iATB6-0002Fh-Rc for pgsql-bugs@arkaria.postgresql.org; Wed, 18 Sep 2019 06:11:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iATB4-0003md-90 for pgsql-bugs@arkaria.postgresql.org; Wed, 18 Sep 2019 06:10:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iATB3-0003mO-Pc for pgsql-bugs@lists.postgresql.org; Wed, 18 Sep 2019 06:10:57 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iATB0-0006SG-Lc for pgsql-bugs@lists.postgresql.org; Wed, 18 Sep 2019 06:10:56 +0000 Received: by mail-wr1-x42b.google.com with SMTP id a11so5535964wrx.1 for ; Tue, 17 Sep 2019 23:10:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=synedra.com; s=google; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=Jtt4JaUsoVMBmRs2GIXWJISKenNgM6GaHYaRNnE+04c=; b=aMpPxmnRXWnIDCBuIlYURbuOWNeWu5kND/p9OnKqe9YjPOlZbfA34NeRCJbNa/5kJW flJ6yPBUCkBjDK5ZdttZkcE2XJGeJ6ccP3VZ7xSNPcGbfRvsK5WUU1xeX7ef+tGLKwm8 bYkozb7mPWbwlMrVWxksHcWZfjH4uqoMBWg9vcgVThZp8MJdV99PkxAYfejQsEkjrm6L sQ3+PP8BXrcKDFWxKDzEf3KioW3fJqmJ0GxG4l3+/YN7wqlMD6i2VURaX1ukZTUdlH2f m8D/wY0/iPbfO0a/iAAtn/8DEUDuBoClOxC2XAN/tc5xIqaGL3plYY6iLx/ELdhdpOPp PuFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=Jtt4JaUsoVMBmRs2GIXWJISKenNgM6GaHYaRNnE+04c=; b=KETWmvPDWcnyXAzby8ecdN4QBUivtQ5bZRtTEnMtd+IGbAWFkSXnEhtGRUkjsCrE0c oKeRrW/MrAu8SutthfjS8r1RNyPEJsPAyqFg2ArMAjrSY2z6UygOYTwmKPGBlSgFNzw2 5Ijxjjgy5Ex7c6/b/6lLDmFGO/lHqJ8XbyHZltWP6XhkTgd+lr77mOOXGE2U1Ky/GorU v0pG4G/5U1Eux6hwX+CVXnldUoqQa5kJoA3emrsrkxUgCek99EEQLWjmme8PSi99XpSe JlnnvMUtrrP5++dC9aSSJeqhxeOscLLNvVFjSN+WeuKevGm4QHr7OnDyOiurWNjT8b07 u97w== X-Gm-Message-State: APjAAAXKmGPp8itR/oQkUtZj4mWRMmHd3gtnryUqh75tOWLcbyalc6a4 pjsueaAupsHbGydRP+OHTjOYBlOKvkkVuVEc8pFQavptM9DtjFK83YZ5ktyLCrFVb0ElriNXCuV jJNORr1OeqoIAHJQYqukCM2LgrU3TwlJJrBbkgEaeb3Iv1kAL01IMLYm/HyaKjaYhvObEaFqnSj ifuIuOsz8kPR09Jjk= X-Google-Smtp-Source: APXvYqw5bMDj5JFn1hRd5iHf0jQuIa1/8H3XtU/TFlvO54vsRlPBFqxBko2U+ZTPd9psqJEf5xmeww== X-Received: by 2002:adf:ef49:: with SMTP id c9mr1567126wrp.122.1568787052581; Tue, 17 Sep 2019 23:10:52 -0700 (PDT) Received: from [172.26.67.7] (clnet-b06-235.ikbnet.co.at. [83.175.121.235]) by smtp.gmail.com with ESMTPSA id w12sm7009560wrg.47.2019.09.17.23.10.51 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Sep 2019 23:10:52 -0700 (PDT) To: pgsql-bugs@lists.postgresql.org From: Robert Lichtenberger Subject: Restricted interval data type Message-ID: <40dd257c-91f5-8119-64ee-bc20bc7fbb6c@synedra.com> Date: Wed, 18 Sep 2019 08:10:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------69C8535D74BA8E808DD62670" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------69C8535D74BA8E808DD62670 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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 --------------69C8535D74BA8E808DD62670 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

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

--------------69C8535D74BA8E808DD62670--