--- /dev/null
+-- **** testing built-in time types: abstime, reltime, and tinterval ****
+
+--
+-- timezones may vary based not only on location but the operating
+-- system. the main correctness issue is that the OS may not get
+-- DST right for times prior to unix epoch (jan 1 1970).
+--
+
+CREATE TABLE ABSTIME_TBL (f1 abstime);
+
+INSERT INTO ABSTIME_TBL (f1) VALUES ('Jan 14, 1973 03:14:21');
+
+-- was INSERT INTO ABSTIME_TBL (f1) VALUES ('now'::abstime):
+INSERT INTO ABSTIME_TBL (f1) VALUES ('Mon May 1 00:30:30 1995'::abstime);
+
+INSERT INTO ABSTIME_TBL (f1) VALUES ('epoch'::abstime);
+
+INSERT INTO ABSTIME_TBL (f1) VALUES ('current'::abstime);
+
+INSERT INTO ABSTIME_TBL (f1) VALUES ('infinity'::abstime);
+
+INSERT INTO ABSTIME_TBL (f1) VALUES ('-infinity'::abstime);
+
+INSERT INTO ABSTIME_TBL (f1) VALUES ('May 10, 1943 23:59:12');
+
+
+-- what happens if we specify slightly misformatted abstime?
+INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 35, 1946 10:00:00');
+
+INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 28, 1984 25:08:10');
+
+
+-- badly formatted abstimes: these should result in invalid abstimes
+INSERT INTO ABSTIME_TBL (f1) VALUES ('bad date format');
+
+INSERT INTO ABSTIME_TBL (f1) VALUES ('Jun 10, 1843');
+
+-- test abstime operators
+
+SELECT '' AS eleven, ABSTIME_TBL.*;
+
+SELECT '' AS eight, ABSTIME_TBL.*
+ WHERE ABSTIME_TBL.f1 < 'Jun 30, 2001'::abstime;
+
+SELECT '' AS eight, ABSTIME_TBL.*
+ WHERE ABSTIME_TBL.f1 > '-infinity'::abstime;
+
+SELECT '' AS eight, ABSTIME_TBL.*
+ WHERE 'May 10, 1943 23:59:12'::abstime <> ABSTIME_TBL.f1;
+
+SELECT '' AS one, ABSTIME_TBL.*
+ WHERE 'current'::abstime = ABSTIME_TBL.f1;
+
+SELECT '' AS five, ABSTIME_TBL.*
+ WHERE 'epoch'::abstime >= ABSTIME_TBL.f1;
+
+SELECT '' AS six, ABSTIME_TBL.*
+ WHERE ABSTIME_TBL.f1 <= 'Jan 14, 1973 03:14:21'::abstime;
+
+SELECT '' AS six, ABSTIME_TBL.*
+ WHERE ABSTIME_TBL.f1 <?>
+ '["Apr 1 1945 00:00:00" "Dec 30 1999 23:00:00"]'::tinterval;
+
+-- these four queries should return the same answer
+-- the "infinity" and "-infinity" tuples in ABSTIME_TBL cannot be added and
+-- therefore, should not show up in the results.
+SELECT '' AS five, ABSTIME_TBL.*
+ WHERE (ABSTIME_TBL.f1 + '@ 3 year'::reltime) -- +3 years
+ < 'Jan 14 14:00:00 1977'::abstime;
+
+SELECT '' AS five, ABSTIME_TBL.*
+ WHERE (ABSTIME_TBL.f1 + '@ 3 year ago'::reltime) -- -3 years
+ < 'Jan 14 14:00:00 1971'::abstime;
+
+SELECT '' AS five, ABSTIME_TBL.*
+ WHERE (ABSTIME_TBL.f1 - '@ 3 year'::reltime) -- -(+3) years
+ < 'Jan 14 14:00:00 1971'::abstime;
+
+SELECT '' AS five, ABSTIME_TBL.*
+ WHERE (ABSTIME_TBL.f1 - '@ 3 year ago'::reltime) -- -(-3) years
+ < 'Jan 14 14:00:00 1977'::abstime;
+
+
+SELECT '' AS twenty, ABSTIME_TBL.*, RELTIME_TBL.*
+ WHERE (ABSTIME_TBL.f1 + RELTIME_TBL.f1)
+ < 'Jan 14 14:00:00 1971'::abstime;
+
--- /dev/null
+--
+-- boolean.source
+--
+-- $Header: /cvsroot/pgsql/src/test/regress/sql/boolean.sql,v 1.1 1997/04/05 11:08:15 scrappy Exp $
+--
+
+--
+-- sanity check - if this fails go insane!
+--
+SELECT 1 AS one;
+
+
+-- ******************testing built-in type bool********************
+
+-- check bool type-casting as well as and, or, not in qualifications--
+
+SELECT 't'::bool AS true;
+
+SELECT 'f'::bool AS false;
+
+SELECT 't'::bool or 'f'::bool AS true;
+
+SELECT 't'::bool and 'f'::bool AS false;
+
+SELECT not 'f'::bool AS true;
+
+SELECT 't'::bool = 'f'::bool AS false;
+
+SELECT 't'::bool <> 'f'::bool AS true;
+
+
+CREATE TABLE BOOLTBL1 (f1 bool);
+
+INSERT INTO BOOLTBL1 (f1) VALUES ('t'::bool);
+
+INSERT INTO BOOLTBL1 (f1) VALUES ('True'::bool);
+
+INSERT INTO BOOLTBL1 (f1) VALUES ('true'::bool);
+
+
+-- BOOLTBL1 should be full of true's at this point
+SELECT '' AS t_3, BOOLTBL1.*;
+
+
+SELECT '' AS t_3, BOOLTBL1.*
+ FROM BOOLTBL1
+ WHERE f1 = 'true'::bool;
+
+
+SELECT '' AS t_3, BOOLTBL1.*
+ FROM BOOLTBL1
+ WHERE f1 <> 'false'::bool;
+
+SELECT '' AS zero, BOOLTBL1.*
+ FROM BOOLTBL1
+ WHERE booleq('false'::bool, f1);
+
+INSERT INTO BOOLTBL1 (f1) VALUES ('f'::bool);
+
+SELECT '' AS f_1, BOOLTBL1.*
+ FROM BOOLTBL1
+ WHERE f1 = 'false'::bool;
+
+
+CREATE TABLE BOOLTBL2 (f1 bool);
+
+INSERT INTO BOOLTBL2 (f1) VALUES ('f'::bool);
+
+INSERT INTO BOOLTBL2 (f1) VALUES ('false'::bool);
+
+INSERT INTO BOOLTBL2 (f1) VALUES ('False'::bool);
+
+-- this evaluates to a false value
+INSERT INTO BOOLTBL2 (f1)
+ VALUES ('XXX'::bool);
+
+
+-- BOOLTBL2 should be full of false's at this point
+SELECT '' AS f_4, BOOLTBL2.*;
+
+
+SELECT '' AS tf_12, BOOLTBL1.*, BOOLTBL2.*
+ WHERE BOOLTBL2.f1 <> BOOLTBL1.f1;
+
+
+SELECT '' AS tf_12, BOOLTBL1.*, BOOLTBL2.*
+ WHERE boolne(BOOLTBL2.f1,BOOLTBL1.f1);
+
+
+SELECT '' AS ff_4, BOOLTBL1.*, BOOLTBL2.*
+ WHERE BOOLTBL2.f1 = BOOLTBL1.f1 and BOOLTBL1.f1 = 'false'::bool;
+
+
+SELECT '' AS tf_12_ff_4, BOOLTBL1.*, BOOLTBL2.*
+ WHERE BOOLTBL2.f1 = BOOLTBL1.f1 or BOOLTBL1.f1 = 'true'::bool;
--- /dev/null
+-- ****************** test built-in type box ********************
+
+--
+-- box logic
+-- o
+-- 3 o--|X
+-- | o|
+-- 2 +-+-+ |
+-- | | | |
+-- 1 | o-+-o
+-- | |
+-- 0 +---+
+--
+-- 0 1 2 3
+--
+
+-- boxes are specified by two points, given by four floats x1,y1,x2,y2
+
+
+CREATE TABLE BOX_TBL (f1 box);
+
+INSERT INTO BOX_TBL (f1) VALUES ('(2.0,2.0,0.0,0.0)');
+
+INSERT INTO BOX_TBL (f1) VALUES ('(1.0,1.0,3.0,3.0)');
+
+-- degenerate cases where the box is a line or a point
+-- note that lines and points boxes all have zero area
+INSERT INTO BOX_TBL (f1) VALUES ('(2.5, 2.5, 2.5,3.5)');
+
+INSERT INTO BOX_TBL (f1) VALUES ('(3.0, 3.0,3.0,3.0)');
+
+-- badly formatted box inputs
+INSERT INTO BOX_TBL (f1) VALUES ('(2.3, 4.5)');
+
+INSERT INTO BOX_TBL (f1) VALUES ('asdfasdf(ad');
+
+
+SELECT '' AS four, BOX_TBL.*;
+
+SELECT '' AS four, b.*, box_area(b.f1) as barea
+ FROM BOX_TBL b;
+
+-- overlap
+SELECT '' AS three, b.f1
+ FROM BOX_TBL b
+ WHERE b.f1 && '(2.5,2.5,1.0,1.0)'::box;
+
+-- left-or-overlap (x only)
+SELECT '' AS two, b1.*
+ FROM BOX_TBL b1
+ WHERE b1.f1 &< '(2.0,2.0,2.5,2.5)'::box;
+
+-- right-or-overlap (x only)
+SELECT '' AS two, b1.*
+ FROM BOX_TBL b1
+ WHERE b1.f1 &> '(2.0,2.0,2.5,2.5)'::box;
+
+-- left of
+SELECT '' AS two, b.f1
+ FROM BOX_TBL b
+ WHERE b.f1 << '(3.0,3.0,5.0,5.0)'::box;
+
+-- area <=
+SELECT '' AS four, b.f1
+ FROM BOX_TBL b
+ WHERE b.f1 <= '(3.0,3.0,5.0,5.0)'::box;
+
+-- area <
+SELECT '' AS two, b.f1
+ FROM BOX_TBL b
+ WHERE b.f1 < '(3.0,3.0,5.0,5.0)'::box;
+
+-- area =
+SELECT '' AS two, b.f1
+ FROM BOX_TBL b
+ WHERE b.f1 = '(3.0,3.0,5.0,5.0)'::box;
+
+-- area >
+SELECT '' AS two, b.f1
+ FROM BOX_TBL b -- zero area
+ WHERE b.f1 > '(3.5,3.0,4.5,3.0)'::box;
+
+-- area >=
+SELECT '' AS four, b.f1
+ FROM BOX_TBL b -- zero area
+ WHERE b.f1 >= '(3.5,3.0,4.5,3.0)'::box;
+
+-- right of
+SELECT '' AS two, b.f1
+ FROM BOX_TBL b
+ WHERE '(3.0,3.0,5.0,5.0)'::box >> b.f1;
+
+-- contained in
+SELECT '' AS three, b.f1
+ FROM BOX_TBL b
+ WHERE b.f1 @ '(0,0,3,3)'::box;
+
+-- contains
+SELECT '' AS three, b.f1
+ FROM BOX_TBL b
+ WHERE '(0,0,3,3)'::box ~ b.f1;
+
+-- box equality
+SELECT '' AS one, b.f1
+ FROM BOX_TBL b
+ WHERE '(1,1,3,3)'::box ~= b.f1;
+
+-- center of box, left unary operator
+SELECT '' AS four, @@(b1.f1) AS p
+ FROM BOX_TBL b1;
+
+-- wholly-contained
+SELECT '' AS one, b1.*, b2.*
+ FROM BOX_TBL b1, BOX_TBL b2
+ WHERE b1.f1 ~ b2.f1 and not b1.f1 ~= b2.f1;
+
+
--- /dev/null
+-- ****************** test built-in type char **************
+--
+-- all inputs are SILENTLY truncated at 1 character
+--
+
+CREATE TABLE CHAR_TBL(f1 char);
+
+INSERT INTO CHAR_TBL (f1) VALUES ('a');
+
+INSERT INTO CHAR_TBL (f1) VALUES ('A');
+
+-- any of the following three input formats are acceptable
+INSERT INTO CHAR_TBL (f1) VALUES ('1');
+
+INSERT INTO CHAR_TBL (f1) VALUES (2);
+
+INSERT INTO CHAR_TBL (f1) VALUES ('3');
+
+-- zero-length char
+INSERT INTO CHAR_TBL (f1) VALUES ('');
+
+-- try char's of greater than 1 length
+INSERT INTO CHAR_TBL (f1) VALUES ('cd');
+
+
+SELECT '' AS seven, CHAR_TBL.*;
+
+SELECT '' AS six, c.*
+ FROM CHAR_TBL c
+ WHERE c.f1 <> 'a';
+
+SELECT '' AS one, c.*
+ FROM CHAR_TBL c
+ WHERE c.f1 = 'a';
+
+SELECT '' AS five, c.*
+ FROM CHAR_TBL c
+ WHERE c.f1 < 'a';
+
+SELECT '' AS six, c.*
+ FROM CHAR_TBL c
+ WHERE c.f1 <= 'a';
+
+SELECT '' AS one, c.*
+ FROM CHAR_TBL c
+ WHERE c.f1 > 'a';
+
+SELECT '' AS two, c.*
+ FROM CHAR_TBL c
+ WHERE c.f1 >= 'a';
+
+
--- /dev/null
+-- **************** testing built-in type char2 **************
+--
+-- all inputs are silently truncated at 2 characters
+--
+
+CREATE TABLE CHAR2_TBL(f1 char2);
+
+INSERT INTO CHAR2_TBL (f1) VALUES ('AB');
+
+INSERT INTO CHAR2_TBL (f1) VALUES ('ab');
+
+INSERT INTO CHAR2_TBL (f1) VALUES ('ZY');
+
+INSERT INTO CHAR2_TBL (f1) VALUES ('34');
+
+INSERT INTO CHAR2_TBL (f1) VALUES ('d');
+
+INSERT INTO CHAR2_TBL (f1) VALUES ('');
+
+INSERT INTO CHAR2_TBL (f1) VALUES ('12345');
+
+
+SELECT '' AS seven, CHAR2_TBL.*;
+
+SELECT '' AS six, c.f1 FROM CHAR2_TBL c WHERE c.f1 <> 'AB';
+
+SELECT '' AS one, c.f1 FROM CHAR2_TBL c WHERE c.f1 = 'AB';
+
+SELECT '' AS three, c.f1 FROM CHAR2_TBL c WHERE c.f1 < 'AB';
+
+SELECT '' AS four, c.f1 FROM CHAR2_TBL c WHERE c.f1 <= 'AB';
+
+SELECT '' AS three, c.f1 FROM CHAR2_TBL c WHERE c.f1 > 'AB';
+
+SELECT '' AS four, c.f1 FROM CHAR2_TBL c WHERE c.f1 >= 'AB';
+
+SELECT '' AS seven, c.f1 FROM CHAR2_TBL c WHERE c.f1 ~ '.*';
+
+SELECT '' AS zero, c.f1 FROM CHAR2_TBL c WHERE c.f1 !~ '.*';
+
+SELECT '' AS one, c.f1 FROM CHAR2_TBL c WHERE c.f1 ~ '34';
+
+SELECT '' AS one, c.f1 FROM CHAR2_TBL c WHERE c.f1 ~ '3.*';
+
+
+
--- /dev/null
+--**************** testing built-in type char4 **************
+--
+-- all inputs are silently truncated at 4 characters
+--
+
+CREATE TABLE CHAR4_TBL (f1 char4);
+
+INSERT INTO CHAR4_TBL(f1) VALUES ('ABCD');
+
+INSERT INTO CHAR4_TBL(f1) VALUES ('abcd');
+
+INSERT INTO CHAR4_TBL(f1) VALUES ('ZYWZ');
+
+INSERT INTO CHAR4_TBL(f1) VALUES ('343f');
+
+INSERT INTO CHAR4_TBL(f1) VALUES ('d34a');
+
+INSERT INTO CHAR4_TBL(f1) VALUES ('');
+
+INSERT INTO CHAR4_TBL(f1) VALUES ('12345678');
+
+
+SELECT '' AS seven, CHAR4_TBL.*;
+
+SELECT '' AS six, c.f1 FROM CHAR4_TBL c WHERE c.f1 <> 'ABCD';
+
+SELECT '' AS one, c.f1 FROM CHAR4_TBL c WHERE c.f1 = 'ABCD';
+
+SELECT '' AS three, c.f1 FROM CHAR4_TBL c WHERE c.f1 < 'ABCD';
+
+SELECT '' AS four, c.f1 FROM CHAR4_TBL c WHERE c.f1 <= 'ABCD';
+
+SELECT '' AS three, c.f1 FROM CHAR4_TBL c WHERE c.f1 > 'ABCD';
+
+SELECT '' AS four, c.f1 FROM CHAR4_TBL c WHERE c.f1 >= 'ABCD';
+
+SELECT '' AS seven, c.f1 FROM CHAR4_TBL c WHERE c.f1 ~ '.*';
+
+SELECT '' AS zero, c.f1 FROM CHAR4_TBL c WHERE c.f1 !~ '.*';
+
+SELECT '' AS three, c.f1 FROM CHAR4_TBL c WHERE c.f1 ~ '.*34.*';
+
+
--- /dev/null
+CREATE TABLE RELTIME_TBL (f1 reltime);
+
+INSERT INTO RELTIME_TBL (f1) VALUES ('@ 1 minute');
+
+INSERT INTO RELTIME_TBL (f1) VALUES ('@ 5 hour');
+
+INSERT INTO RELTIME_TBL (f1) VALUES ('@ 10 day');
+
+INSERT INTO RELTIME_TBL (f1) VALUES ('@ 34 year');
+
+INSERT INTO RELTIME_TBL (f1) VALUES ('@ 3 months');
+
+INSERT INTO RELTIME_TBL (f1) VALUES ('@ 14 seconds ago');
+
+
+-- badly formatted reltimes:
+INSERT INTO RELTIME_TBL (f1) VALUES ('badly formatted reltime');
+
+INSERT INTO RELTIME_TBL (f1) VALUES ('@ 30 eons ago');
+
+-- test reltime operators
+
+SELECT '' AS eight, RELTIME_TBL.*;
+
+SELECT '' AS five, RELTIME_TBL.*
+ WHERE RELTIME_TBL.f1 <> '@ 10 days'::reltime;
+
+SELECT '' AS three, RELTIME_TBL.*
+ WHERE RELTIME_TBL.f1 <= '@ 5 hours'::reltime;
+
+SELECT '' AS three, RELTIME_TBL.*
+ WHERE RELTIME_TBL.f1 < '@ 1 day'::reltime;
+
+SELECT '' AS one, RELTIME_TBL.*
+ WHERE RELTIME_TBL.f1 = '@ 34 years'::reltime;
+
+SELECT '' AS two, RELTIME_TBL.*
+ WHERE RELTIME_TBL.f1 >= '@ 1 month'::reltime;
+
+SELECT '' AS five, RELTIME_TBL.*
+ WHERE RELTIME_TBL.f1 > '@ 3 seconds ago'::reltime;
+
+SELECT '' AS fifteen, r1.*, r2.*
+ FROM RELTIME_TBL r1, RELTIME_TBL r2
+ WHERE r1.f1 > r2.f1;
+
--- /dev/null
+boolean
+reltime
+abstime
+tinterval
+box
+char
+char2
+char4
--- /dev/null
+CREATE TABLE TINTERVAL_TBL (f1 tinterval);
+
+INSERT INTO TINTERVAL_TBL (f1)
+ VALUES ('["-infinity" "infinity"]');
+
+INSERT INTO TINTERVAL_TBL (f1)
+ VALUES ('["May 10, 1943 23:59:12" "Jan 14, 1973 03:14:21"]');
+
+INSERT INTO TINTERVAL_TBL (f1)
+ VALUES ('["Sep 4, 1983 23:59:12" "Oct 4, 1983 23:59:12"]');
+
+INSERT INTO TINTERVAL_TBL (f1)
+ VALUES ('["epoch" "Mon May 1 00:30:30 1995"]');
+
+INSERT INTO TINTERVAL_TBL (f1)
+ VALUES ('["Feb 15 1990 12:15:03" "current"]');
+
+
+-- badly formatted tintervals
+INSERT INTO TINTERVAL_TBL (f1)
+ VALUES ('["bad time specifications" ""]');
+
+INSERT INTO TINTERVAL_TBL (f1)
+ VALUES ('["" "infinity"]');
+
+-- test tinterval operators
+
+SELECT '' AS seven, TINTERVAL_TBL.*;
+
+-- length ==
+SELECT '' AS one, t.*
+ FROM TINTERVAL_TBL t
+ WHERE t.f1 #= '@ 1 months';
+
+-- length <>
+SELECT '' AS three, t.*
+ FROM TINTERVAL_TBL t
+ WHERE t.f1 #<> '@ 1 months';
+
+-- length <
+SELECT '' AS zero, t.*
+ FROM TINTERVAL_TBL t
+ WHERE t.f1 #< '@ 1 month';
+
+-- length <=
+SELECT '' AS one, t.*
+ FROM TINTERVAL_TBL t
+ WHERE t.f1 #<= '@ 1 month';
+
+-- length >
+SELECT '' AS three, t.*
+ FROM TINTERVAL_TBL t
+ WHERE t.f1 #> '@ 1 year';
+
+-- length >=
+SELECT '' AS three, t.*
+ FROM TINTERVAL_TBL t
+ WHERE t.f1 #>= '@ 3 years';
+
+-- overlaps
+SELECT '' AS three, t1.*
+ FROM TINTERVAL_TBL t1
+ WHERE t1.f1 &&
+ '["Aug 15 14:23:19 1983" "Sep 16 14:23:19 1983"]'::tinterval;
+
+SELECT '' AS five, t1.*, t2.*
+ FROM TINTERVAL_TBL t1, TINTERVAL_TBL t2
+ WHERE t1.f1 && t2.f1 and
+ t1.f1 = t2.f1;
+
+SELECT '' AS fourteen, t1.*, t2.*
+ FROM TINTERVAL_TBL t1, TINTERVAL_TBL t2
+ WHERE t1.f1 && t2.f1 and
+ not t1.f1 = t2.f1;
+
+-- contains
+SELECT '' AS five, t1.*
+ FROM TINTERVAL_TBL t1
+ WHERE not t1.f1 <<
+ '["Aug 15 14:23:19 1980" "Sep 16 14:23:19 1990"]'::tinterval;
+
+-- make time interval
+SELECT '' AS three, t1.*
+ FROM TINTERVAL_TBL t1
+ WHERE t1.f1 &&
+ ('Aug 15 14:23:19 1983'::abstime <#>
+ 'Sep 16 14:23:19 1983'::abstime);
+