Return-Path: owner-postman
Received: from localhost (localhost [127.0.0.1]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with SMTP id PAA02130 for postgres-dist; Mon, 20 Dec 1993 15:23:50 -0800
Resent-From: POSTGRES mailing list <postman@postgres.Berkeley.EDU>
Resent-Message-Id: <199312202323.PAA02130@nobozo.CS.Berkeley.EDU>
Sender: owner-postman@postgres.Berkeley.EDU
X-Return-Path: owner-postman
Received: from arcadia.CS.Berkeley.EDU (arcadia.CS.Berkeley.EDU [128.32.149.40]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with ESMTP id PAA02121 for <postgres@nobozo.CS.Berkeley.EDU>; Mon, 20 Dec 1993 15:23:50 -0800
Received: from localhost (localhost [127.0.0.1]) by arcadia.CS.Berkeley.EDU (8.6.4/8.6.3) with SMTP id PAA16517; Mon, 20 Dec 1993 15:23:45 -0800
Message-Id: <199312202323.PAA16517@arcadia.CS.Berkeley.EDU>
X-Authentication-Warning: arcadia.CS.Berkeley.EDU: Host localhost didn't use HELO protocol
To: vivek@tsg.com (vivek Shipuri)
cc: postgres@postgres.Berkeley.EDU
Subject: Re: Appending to tinterval type in 4.1 
In-reply-to: Your message of "Mon, 20 Dec 93 11:37:05 EST."
             <9312201637.AA03388@tsg.com> 
Date: Mon, 20 Dec 93 15:23:44 -0800
From: Jolly Chen <jolly@postgres.Berkeley.EDU>
Resent-To: postgres-dist@postgres.Berkeley.EDU
X-Mts: smtp
Resent-Date: Mon, 20 Dec 93 15:23:50 -0800
Resent-XMts: smtp



>  I create a class as follows :-
> 
>  create tt(a=tinterval)
> 
>  How do I append an time interval to it?
>  Whatever is in the manual does not work......and I have tried virtually
>  all different combinations I can think of. 
> 
>  So let me know if this is a known bug in Postgres and that I should not
>  bother with it or if you know how to append to such a relation, I would
>  appreciate a reply.
> 
>  Thanks
> 
>  Vivek
>  vivek@tsg.com
> 

The manual is incorrect.  (I don't think anybody in the postgres group
has looked at tinterval's for a while)  

The actual syntax for tinterval is 

[ '<abstime>' '<abstime>' ]

Note the square brackets, single quotes and the lack of commas.
<abstime> is any legal abstime specification.   Also, ignore what the
manual says about using pairs of double-quotes to designate least or
greatest time available. Use 'infinity' or '-infinity' instead. 

Below are some examples of how to use tinterval:

* create TINTERVAL_TBL(f1 = tinterval)
\g

Query sent to backend is "create TINTERVAL_TBL(f1 = tinterval) "
CREATE
Go 
* append TINTERVAL_TBL(f1 = "['-infinity' 'infinity']")
append TINTERVAL_TBL(f1 = "['May 10, 1943 23:59:12' 'Jan 14, 1973 03:14:21']")
append TINTERVAL_TBL(f1 = "['epoch' 'now']")
append TINTERVAL_TBL(f1 = "['Feb 15 1990 12:15:03' 'current']")
\g

Query sent to backend is "append TINTERVAL_TBL(f1 = "['-infinity' 'infinity']") append TINTERVAL_TBL(f1 = "['May 10, 1943 23:59:12' 'Jan 14, 1973 03:14:21']") append TINTERVAL_TBL(f1 = "['epoch' 'now']") append TINTERVAL_TBL(f1 = "['Feb 15 1990 12:15:03' 'current']")  "
APPEND 579572APPEND 579573APPEND 579574APPEND 579575
Go 
* retrieve (TINTERVAL_TBL.all)
\g

Query sent to backend is "retrieve (TINTERVAL_TBL.all) "
---------------
| f1          |
---------------
| ['-infinity' 'infinity']|
---------------
| ['Mon May 10 23:59:12 1943 PDT' 'Sun Jan 14 03:14:21 1973 PDT']|
---------------
| ['epoch' 'Mon Dec 20 15:16:24 1993 PDT']|
---------------
| ['Thurs Feb 15 12:15:03 1990 PDT' 'current']|
---------------

Go 
* 

- Jolly Chen

