Repair usage of the OVERLAPS operator.
Allow some operator-like tokens to be used as function names. Flesh out support for time, timetz, and interval operators and interactions. Regression tests pass, but non-reference-platform horology test results will need to be updated.
This commit is contained in:
parent
1131261270
commit
6969b8fa11
@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.210 2000/11/24 20:16:39 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.211 2000/12/03 14:50:54 thomas Exp $
|
||||
*
|
||||
* HISTORY
|
||||
* AUTHOR DATE MAJOR EVENT
|
||||
@ -198,8 +198,9 @@ static void doNegateFloat(Value *v);
|
||||
%type <jtype> join_type
|
||||
|
||||
%type <list> extract_list, position_list
|
||||
%type <list> substr_list, substr_from, substr_for, trim_list
|
||||
%type <list> substr_list, trim_list
|
||||
%type <list> opt_interval
|
||||
%type <node> substr_from, substr_for
|
||||
|
||||
%type <boolean> opt_inh_star, opt_binary, opt_using, opt_instead, opt_only
|
||||
opt_with_copy, index_opt_unique, opt_verbose, opt_analyze
|
||||
@ -330,7 +331,7 @@ static void doNegateFloat(Value *v);
|
||||
* when some sort of pg_privileges relation is introduced.
|
||||
* - Todd A. Brandys 1998-01-01?
|
||||
*/
|
||||
%token ABORT_TRANS, ACCESS, AFTER, AGGREGATE, ANALYZE, ANALYSE,
|
||||
%token ABORT_TRANS, ACCESS, AFTER, AGGREGATE, ANALYSE, ANALYZE,
|
||||
BACKWARD, BEFORE, BINARY, BIT,
|
||||
CACHE, CHECKPOINT, CLUSTER, COMMENT, COPY, CREATEDB, CREATEUSER, CYCLE,
|
||||
DATABASE, DELIMITERS, DO,
|
||||
@ -4873,7 +4874,8 @@ c_expr: attr
|
||||
| SUBSTRING '(' substr_list ')'
|
||||
{
|
||||
/* substring(A from B for C) is converted to
|
||||
* substring(A, B, C) */
|
||||
* substring(A, B, C) - thomas 2000-11-28
|
||||
*/
|
||||
FuncCall *n = makeNode(FuncCall);
|
||||
n->funcname = "substring";
|
||||
n->args = $3;
|
||||
@ -4881,9 +4883,11 @@ c_expr: attr
|
||||
n->agg_distinct = FALSE;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
/* various trim expressions are defined in SQL92 - thomas 1997-07-19 */
|
||||
| TRIM '(' BOTH trim_list ')'
|
||||
{
|
||||
/* various trim expressions are defined in SQL92
|
||||
* - thomas 1997-07-19
|
||||
*/
|
||||
FuncCall *n = makeNode(FuncCall);
|
||||
n->funcname = "btrim";
|
||||
n->args = $4;
|
||||
@ -4994,31 +4998,51 @@ position_list: b_expr IN b_expr
|
||||
{ $$ = NIL; }
|
||||
;
|
||||
|
||||
substr_list: expr_list substr_from substr_for
|
||||
/* SUBSTRING() arguments
|
||||
* SQL9x defines a specific syntax for arguments to SUBSTRING():
|
||||
* o substring(text from int for int)
|
||||
* o substring(text from int) get entire string from starting point "int"
|
||||
* o substring(text for int) get first "int" characters of string
|
||||
* We also want to implement generic substring functions which accept
|
||||
* the usual generic list of arguments. So we will accept both styles
|
||||
* here, and convert the SQL9x style to the generic list for further
|
||||
* processing. - thomas 2000-11-28
|
||||
*/
|
||||
substr_list: a_expr substr_from substr_for
|
||||
{
|
||||
$$ = nconc(nconc($1,$2),$3);
|
||||
$$ = makeList3($1, $2, $3);
|
||||
}
|
||||
| /*EMPTY*/
|
||||
{ $$ = NIL; }
|
||||
;
|
||||
|
||||
substr_from: FROM expr_list
|
||||
{ $$ = $2; }
|
||||
| /*EMPTY*/
|
||||
| a_expr substr_for substr_from
|
||||
{
|
||||
$$ = makeList3($1, $3, $2);
|
||||
}
|
||||
| a_expr substr_from
|
||||
{
|
||||
$$ = makeList2($1, $2);
|
||||
}
|
||||
| a_expr substr_for
|
||||
{
|
||||
A_Const *n = makeNode(A_Const);
|
||||
n->val.type = T_Integer;
|
||||
n->val.val.ival = 1;
|
||||
$$ = makeList1((Node *)n);
|
||||
$$ = makeList3($1, (Node *)n, $2);
|
||||
}
|
||||
| expr_list
|
||||
{
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
substr_for: FOR expr_list
|
||||
{ $$ = $2; }
|
||||
| /*EMPTY*/
|
||||
{ $$ = NIL; }
|
||||
;
|
||||
|
||||
substr_from: FROM a_expr
|
||||
{ $$ = $2; }
|
||||
;
|
||||
|
||||
substr_for: FOR a_expr
|
||||
{ $$ = $2; }
|
||||
;
|
||||
|
||||
trim_list: a_expr FROM expr_list
|
||||
{ $$ = lappend($3, $1); }
|
||||
| FROM expr_list
|
||||
@ -5241,6 +5265,7 @@ relation_name: SpecialRuleRelation
|
||||
}
|
||||
;
|
||||
|
||||
name: ColId { $$ = $1; };
|
||||
database_name: ColId { $$ = $1; };
|
||||
access_method: ColId { $$ = $1; };
|
||||
attr_name: ColId { $$ = $1; };
|
||||
@ -5250,9 +5275,27 @@ index_name: ColId { $$ = $1; };
|
||||
/* Functions
|
||||
* Include date/time keywords as SQL92 extension.
|
||||
* Include TYPE as a SQL92 unreserved keyword. - thomas 1997-10-05
|
||||
* Any tokens which show up as operators will screw up the parsing if
|
||||
* allowed as identifiers, but are acceptable as ColLabels:
|
||||
* BETWEEN, IN, IS, ISNULL, NOTNULL, OVERLAPS
|
||||
* Thanks to Tom Lane for pointing this out. - thomas 2000-03-29
|
||||
* We need OVERLAPS allowed as a function name to enable the implementation
|
||||
* of argument type variations on the underlying implementation. These
|
||||
* variations are done as SQL-language entries in the pg_proc catalog.
|
||||
* Do not include SUBSTRING here since it has explicit productions
|
||||
* in a_expr to support the goofy SQL9x argument syntax.
|
||||
* - thomas 2000-11-28
|
||||
*/
|
||||
name: ColId { $$ = $1; };
|
||||
func_name: ColId { $$ = xlateSqlFunc($1); };
|
||||
func_name: ColId { $$ = xlateSqlFunc($1); }
|
||||
| BETWEEN { $$ = xlateSqlFunc("between"); }
|
||||
| ILIKE { $$ = xlateSqlFunc("ilike"); }
|
||||
| IN { $$ = xlateSqlFunc("in"); }
|
||||
| IS { $$ = xlateSqlFunc("is"); }
|
||||
| ISNULL { $$ = xlateSqlFunc("isnull"); }
|
||||
| LIKE { $$ = xlateSqlFunc("like"); }
|
||||
| NOTNULL { $$ = xlateSqlFunc("notnull"); }
|
||||
| OVERLAPS { $$ = xlateSqlFunc("overlaps"); }
|
||||
;
|
||||
|
||||
file_name: Sconst { $$ = $1; };
|
||||
|
||||
@ -5358,14 +5401,6 @@ UserId: ColId { $$ = $1; };
|
||||
* some of these keywords will have to be removed from this
|
||||
* list due to shift/reduce conflicts in yacc. If so, move
|
||||
* down to the ColLabel entity. - thomas 1997-11-06
|
||||
* Any tokens which show up as operators will screw up the parsing if
|
||||
* allowed as identifiers, but are acceptable as ColLabels:
|
||||
* BETWEEN, IN, IS, ISNULL, NOTNULL, OVERLAPS
|
||||
* Thanks to Tom Lane for pointing this out. - thomas 2000-03-29
|
||||
* Allow LIKE and ILIKE as TokenId (and ColId) to make sure that they
|
||||
* are allowed in the func_name production. Otherwise, we can't define
|
||||
* more like() and ilike() functions for new data types.
|
||||
* - thomas 2000-08-07
|
||||
*/
|
||||
ColId: generic { $$ = $1; }
|
||||
| datetime { $$ = $1; }
|
||||
@ -5428,7 +5463,6 @@ TokenId: ABSOLUTE { $$ = "absolute"; }
|
||||
| FUNCTION { $$ = "function"; }
|
||||
| GRANT { $$ = "grant"; }
|
||||
| HANDLER { $$ = "handler"; }
|
||||
| ILIKE { $$ = "ilike"; }
|
||||
| IMMEDIATE { $$ = "immediate"; }
|
||||
| INCREMENT { $$ = "increment"; }
|
||||
| INDEX { $$ = "index"; }
|
||||
@ -5441,7 +5475,6 @@ TokenId: ABSOLUTE { $$ = "absolute"; }
|
||||
| LANGUAGE { $$ = "language"; }
|
||||
| LANCOMPILER { $$ = "lancompiler"; }
|
||||
| LEVEL { $$ = "level"; }
|
||||
| LIKE { $$ = "like"; }
|
||||
| LOCATION { $$ = "location"; }
|
||||
| MATCH { $$ = "match"; }
|
||||
| MAXVALUE { $$ = "maxvalue"; }
|
||||
@ -5571,6 +5604,7 @@ ColLabel: ColId { $$ = $1; }
|
||||
| GLOBAL { $$ = "global"; }
|
||||
| GROUP { $$ = "group"; }
|
||||
| HAVING { $$ = "having"; }
|
||||
| ILIKE { $$ = "ilike"; }
|
||||
| INITIALLY { $$ = "initially"; }
|
||||
| IN { $$ = "in"; }
|
||||
| INNER_P { $$ = "inner"; }
|
||||
@ -5582,6 +5616,8 @@ ColLabel: ColId { $$ = $1; }
|
||||
| JOIN { $$ = "join"; }
|
||||
| LEADING { $$ = "leading"; }
|
||||
| LEFT { $$ = "left"; }
|
||||
| LIKE { $$ = "like"; }
|
||||
| LIMIT { $$ = "limit"; }
|
||||
| LISTEN { $$ = "listen"; }
|
||||
| LOAD { $$ = "load"; }
|
||||
| LOCAL { $$ = "local"; }
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.52 2000/11/11 19:55:19 thomas Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.53 2000/12/03 14:51:01 thomas Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -594,7 +594,6 @@ timestamp_time(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_TIMEADT(result);
|
||||
}
|
||||
|
||||
|
||||
/* datetime_timestamp()
|
||||
* Convert date and time to timestamp data type.
|
||||
*/
|
||||
@ -612,7 +611,6 @@ datetime_timestamp(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_TIMESTAMP(result);
|
||||
}
|
||||
|
||||
|
||||
/* time_interval()
|
||||
* Convert time to interval data type.
|
||||
*/
|
||||
@ -630,6 +628,72 @@ time_interval(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INTERVAL_P(result);
|
||||
}
|
||||
|
||||
/* interval_time()
|
||||
* Convert interval to time data type.
|
||||
*/
|
||||
Datum
|
||||
interval_time(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Interval *span = PG_GETARG_INTERVAL_P(0);
|
||||
TimeADT result;
|
||||
Interval span1;
|
||||
|
||||
result = span->time;
|
||||
TMODULO(result, span1.time, 86400e0);
|
||||
|
||||
PG_RETURN_TIMEADT(result);
|
||||
}
|
||||
|
||||
/* time_pl_interval()
|
||||
* Add interval to time.
|
||||
*/
|
||||
Datum
|
||||
time_pl_interval(PG_FUNCTION_ARGS)
|
||||
{
|
||||
TimeADT time = PG_GETARG_TIMEADT(0);
|
||||
Interval *span = PG_GETARG_INTERVAL_P(1);
|
||||
TimeADT result;
|
||||
TimeADT time1;
|
||||
|
||||
result = (time + span->time);
|
||||
TMODULO(result, time1, 86400e0);
|
||||
if (result < 0)
|
||||
result += 86400;
|
||||
|
||||
PG_RETURN_TIMEADT(result);
|
||||
}
|
||||
|
||||
/* time_mi_interval()
|
||||
* Subtract interval from time.
|
||||
*/
|
||||
Datum
|
||||
time_mi_interval(PG_FUNCTION_ARGS)
|
||||
{
|
||||
TimeADT time = PG_GETARG_TIMEADT(0);
|
||||
Interval *span = PG_GETARG_INTERVAL_P(1);
|
||||
TimeADT result;
|
||||
TimeADT time1;
|
||||
|
||||
result = (time - span->time);
|
||||
TMODULO(result, time1, 86400e0);
|
||||
if (result < 0)
|
||||
result += 86400;
|
||||
|
||||
PG_RETURN_TIMEADT(result);
|
||||
}
|
||||
|
||||
/* interval_pl_time()
|
||||
* Add time to interval.
|
||||
*/
|
||||
Datum
|
||||
interval_pl_time(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Datum span = PG_GETARG_DATUM(0);
|
||||
Datum time = PG_GETARG_DATUM(1);
|
||||
|
||||
return DirectFunctionCall2(time_pl_interval, time, span);
|
||||
}
|
||||
|
||||
|
||||
/* time_text()
|
||||
* Convert time to text data type.
|
||||
@ -856,6 +920,50 @@ timetz_smaller(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_TIMETZADT_P(time2);
|
||||
}
|
||||
|
||||
/* timetz_pl_interval()
|
||||
* Add interval to timetz.
|
||||
*/
|
||||
Datum
|
||||
timetz_pl_interval(PG_FUNCTION_ARGS)
|
||||
{
|
||||
TimeTzADT *time = PG_GETARG_TIMETZADT_P(0);
|
||||
Interval *span = PG_GETARG_INTERVAL_P(1);
|
||||
TimeTzADT *result;
|
||||
TimeTzADT time1;
|
||||
|
||||
result = (TimeTzADT *) palloc(sizeof(TimeTzADT));
|
||||
|
||||
result->time = (time->time + span->time);
|
||||
TMODULO(result->time, time1.time, 86400e0);
|
||||
if (result->time < 0)
|
||||
result->time += 86400;
|
||||
result->zone = time->zone;
|
||||
|
||||
PG_RETURN_TIMETZADT_P(result);
|
||||
}
|
||||
|
||||
/* timetz_mi_interval()
|
||||
* Subtract interval from timetz.
|
||||
*/
|
||||
Datum
|
||||
timetz_mi_interval(PG_FUNCTION_ARGS)
|
||||
{
|
||||
TimeTzADT *time = PG_GETARG_TIMETZADT_P(0);
|
||||
Interval *span = PG_GETARG_INTERVAL_P(1);
|
||||
TimeTzADT *result;
|
||||
TimeTzADT time1;
|
||||
|
||||
result = (TimeTzADT *) palloc(sizeof(TimeTzADT));
|
||||
|
||||
result->time = (time->time - span->time);
|
||||
TMODULO(result->time, time1.time, 86400e0);
|
||||
if (result->time < 0)
|
||||
result->time += 86400;
|
||||
result->zone = time->zone;
|
||||
|
||||
PG_RETURN_TIMETZADT_P(result);
|
||||
}
|
||||
|
||||
/* overlaps_timetz()
|
||||
* Implements the SQL92 OVERLAPS operator.
|
||||
* Algorithm from Date and Darwen, 1997
|
||||
|
@ -37,7 +37,7 @@
|
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: catversion.h,v 1.65 2000/11/30 01:47:33 vadim Exp $
|
||||
* $Id: catversion.h,v 1.66 2000/12/03 14:51:09 thomas Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -53,6 +53,6 @@
|
||||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 200011291
|
||||
#define CATALOG_VERSION_NO 200012030
|
||||
|
||||
#endif
|
||||
|
@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: pg_operator.h,v 1.84 2000/11/21 03:23:19 tgl Exp $
|
||||
* $Id: pg_operator.h,v 1.85 2000/12/03 14:51:09 thomas Exp $
|
||||
*
|
||||
* NOTES
|
||||
* the genbki.sh script reads this file and generates .bki
|
||||
@ -745,6 +745,11 @@ DATA(insert OID = 1795 ( "<<" PGUID 0 b t f 1560 23 1560 0 0 0 0 bits
|
||||
DATA(insert OID = 1796 ( ">>" PGUID 0 b t f 1560 23 1560 0 0 0 0 bitshiftright - - ));
|
||||
DATA(insert OID = 1797 ( "||" PGUID 0 b t f 1560 1560 1560 0 0 0 0 bitcat - - ));
|
||||
|
||||
DATA(insert OID = 1800 ( "+" PGUID 0 b t f 1083 1186 1083 0 0 0 0 time_pl_interval - - ));
|
||||
DATA(insert OID = 1801 ( "-" PGUID 0 b t f 1083 1186 1083 0 0 0 0 time_mi_interval - - ));
|
||||
DATA(insert OID = 1802 ( "+" PGUID 0 b t f 1266 1186 1266 0 0 0 0 timetz_pl_interval - - ));
|
||||
DATA(insert OID = 1803 ( "-" PGUID 0 b t f 1266 1186 1266 0 0 0 0 timetz_mi_interval - - ));
|
||||
|
||||
DATA(insert OID = 1804 ( "=" PGUID 0 b t f 1562 1562 16 1804 1805 1806 1806 varbiteq eqsel eqjoinsel ));
|
||||
DATA(insert OID = 1805 ( "<>" PGUID 0 b t f 1562 1562 16 1805 1804 0 0 varbitne neqsel neqjoinsel ));
|
||||
DATA(insert OID = 1806 ( "<" PGUID 0 b t f 1562 1562 16 1807 1809 0 0 varbitlt scalarltsel scalarltjoinsel ));
|
||||
@ -752,6 +757,8 @@ DATA(insert OID = 1807 ( ">" PGUID 0 b t f 1562 1562 16 1806 1808 0 0 varbit
|
||||
DATA(insert OID = 1808 ( "<=" PGUID 0 b t f 1562 1562 16 1809 1807 0 0 varbitle scalarltsel scalarltjoinsel ));
|
||||
DATA(insert OID = 1809 ( ">=" PGUID 0 b t f 1562 1562 16 1808 1806 0 0 varbitge scalargtsel scalargtjoinsel ));
|
||||
|
||||
DATA(insert OID = 1849 ( "+" PGUID 0 b t f 1186 1083 1083 0 0 0 0 interval_pl_time - - ));
|
||||
|
||||
DATA(insert OID = 1862 ( "=" PGUID 0 b t f 21 20 16 1868 1863 95 412 int28eq eqsel eqjoinsel ));
|
||||
DATA(insert OID = 1863 ( "<>" PGUID 0 b t f 21 20 16 1869 1862 0 0 int28ne neqsel neqjoinsel ));
|
||||
DATA(insert OID = 1864 ( "<" PGUID 0 b t f 21 20 16 1871 1867 0 0 int28lt scalarltsel scalarltjoinsel ));
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: pg_proc.h,v 1.175 2000/11/21 03:23:19 tgl Exp $
|
||||
* $Id: pg_proc.h,v 1.176 2000/12/03 14:51:09 thomas Exp $
|
||||
*
|
||||
* NOTES
|
||||
* The script catalog/genbki.sh reads this file and generates .bki
|
||||
@ -1571,20 +1571,20 @@ DESCR("join selectivity for containment comparison operators");
|
||||
|
||||
DATA(insert OID = 1304 ( overlaps PGUID 12 f t t t 4 f 16 "1184 1184 1184 1184" 100 0 0 100 overlaps_timestamp - ));
|
||||
DESCR("SQL92 interval comparison");
|
||||
DATA(insert OID = 1305 ( overlaps PGUID 14 f t t t 4 f 16 "1184 1186 1184 1186" 100 0 0 100 "select overlaps($1, ($1 + $2), $3, ($3 + $4))" - ));
|
||||
DATA(insert OID = 1305 ( overlaps PGUID 14 f t t t 4 f 16 "1184 1186 1184 1186" 100 0 0 100 "select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))" - ));
|
||||
DESCR("SQL92 interval comparison");
|
||||
DATA(insert OID = 1306 ( overlaps PGUID 14 f t t t 4 f 16 "1184 1184 1184 1186" 100 0 0 100 "select overlaps($1, $2, $3, ($3 + $4))" - ));
|
||||
DATA(insert OID = 1306 ( overlaps PGUID 14 f t t t 4 f 16 "1184 1184 1184 1186" 100 0 0 100 "select ($1, $2) overlaps ($3, ($3 + $4))" - ));
|
||||
DESCR("SQL92 interval comparison");
|
||||
DATA(insert OID = 1307 ( overlaps PGUID 14 f t t t 4 f 16 "1184 1186 1184 1184" 100 0 0 100 "select overlaps($1, ($1 + $2), $3, $4)" - ));
|
||||
DATA(insert OID = 1307 ( overlaps PGUID 14 f t t t 4 f 16 "1184 1186 1184 1184" 100 0 0 100 "select ($1, ($1 + $2)) overlaps ($3, $4)" - ));
|
||||
DESCR("SQL92 interval comparison");
|
||||
|
||||
DATA(insert OID = 1308 ( overlaps PGUID 12 f t t t 4 f 16 "1083 1083 1083 1083" 100 0 0 100 overlaps_time - ));
|
||||
DESCR("SQL92 interval comparison");
|
||||
DATA(insert OID = 1309 ( overlaps PGUID 14 f t t t 4 f 16 "1083 1186 1083 1186" 100 0 0 100 "select overlaps($1, ($1 + $2), $3, ($3 + $4))" - ));
|
||||
DATA(insert OID = 1309 ( overlaps PGUID 14 f t t t 4 f 16 "1083 1186 1083 1186" 100 0 0 100 "select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))" - ));
|
||||
DESCR("SQL92 interval comparison");
|
||||
DATA(insert OID = 1310 ( overlaps PGUID 14 f t t t 4 f 16 "1083 1083 1083 1186" 100 0 0 100 "select overlaps($1, $2, $3, ($3 + $4))" - ));
|
||||
DATA(insert OID = 1310 ( overlaps PGUID 14 f t t t 4 f 16 "1083 1083 1083 1186" 100 0 0 100 "select ($1, $2) overlaps ($3, ($3 + $4))" - ));
|
||||
DESCR("SQL92 interval comparison");
|
||||
DATA(insert OID = 1311 ( overlaps PGUID 14 f t t t 4 f 16 "1083 1186 1083 1083" 100 0 0 100 "select overlaps($1, ($1 + $2), $3, $4)" - ));
|
||||
DATA(insert OID = 1311 ( overlaps PGUID 14 f t t t 4 f 16 "1083 1186 1083 1083" 100 0 0 100 "select ($1, ($1 + $2)) overlaps ($3, $4)" - ));
|
||||
DESCR("SQL92 interval comparison");
|
||||
|
||||
DATA(insert OID = 1314 ( timestamp_cmp PGUID 12 f t f t 2 f 23 "1184 1184" 100 0 0 100 timestamp_cmp - ));
|
||||
@ -1773,6 +1773,9 @@ DESCR("bool is not true (ie, false or unknown)");
|
||||
DATA(insert OID = 1418 ( isnotfalse PGUID 12 f t t f 1 f 16 "16" 100 0 0 100 isnotfalse - ));
|
||||
DESCR("bool is not false (ie, true or unknown)");
|
||||
|
||||
DATA(insert OID = 1419 ( time PGUID 12 f t f t 1 f 1083 "1186" 100 0 0 100 interval_time - ));
|
||||
DESCR("convert interval to time");
|
||||
|
||||
DATA(insert OID = 1421 ( box PGUID 12 f t t t 2 f 603 "600 600" 100 0 0 100 points_box - ));
|
||||
DESCR("convert points to box");
|
||||
DATA(insert OID = 1422 ( box_add PGUID 12 f t t t 2 f 603 "603 600" 100 0 0 100 box_add - ));
|
||||
@ -2115,7 +2118,7 @@ DESCR("trim both ends of string");
|
||||
|
||||
DATA(insert OID = 936 ( substring PGUID 12 f t t t 3 f 25 "25 23 23" 100 0 0 100 text_substr - ));
|
||||
DESCR("return portion of string");
|
||||
DATA(insert OID = 937 ( substring PGUID 14 f t t t 2 f 25 "25 23" 100 0 0 100 "select \042substring\042($1, $2, -1)" - ));
|
||||
DATA(insert OID = 937 ( substring PGUID 14 f t t t 2 f 25 "25 23" 100 0 0 100 "select substring($1, $2, -1)" - ));
|
||||
DESCR("return portion of string");
|
||||
|
||||
/* for multi-byte support */
|
||||
@ -2220,7 +2223,7 @@ DESCR("adjust varbit()[] to typmod length");
|
||||
|
||||
DATA(insert OID = 1698 ( position PGUID 12 f t t t 2 f 23 "1560 1560" 100 0 0 100 bitposition - ));
|
||||
DESCR("return position of sub-bitstring");
|
||||
DATA(insert OID = 1699 ( substring PGUID 14 f t t t 2 f 1560 "1560 23" 100 0 0 100 "select \042substring\042($1, $2, -1)" - ));
|
||||
DATA(insert OID = 1699 ( substring PGUID 14 f t t t 2 f 1560 "1560 23" 100 0 0 100 "select substring($1, $2, -1)" - ));
|
||||
DESCR("return portion of bitstring");
|
||||
|
||||
|
||||
@ -2398,6 +2401,16 @@ DATA(insert OID = 1745 ( float4 PGUID 12 f t t t 1 f 700 "1700" 100 0 0 100
|
||||
DESCR("(internal)");
|
||||
DATA(insert OID = 1746 ( float8 PGUID 12 f t t t 1 f 701 "1700" 100 0 0 100 numeric_float8 - ));
|
||||
DESCR("(internal)");
|
||||
|
||||
DATA(insert OID = 1747 ( time_pl_interval PGUID 12 f t t t 2 f 1083 "1083 1186" 100 0 0 100 time_pl_interval - ));
|
||||
DESCR("plus");
|
||||
DATA(insert OID = 1748 ( time_mi_interval PGUID 12 f t t t 2 f 1083 "1083 1186" 100 0 0 100 time_mi_interval - ));
|
||||
DESCR("minus");
|
||||
DATA(insert OID = 1749 ( timetz_pl_interval PGUID 12 f t t t 2 f 1266 "1266 1186" 100 0 0 100 timetz_pl_interval - ));
|
||||
DESCR("plus");
|
||||
DATA(insert OID = 1750 ( timetz_mi_interval PGUID 12 f t t t 2 f 1266 "1266 1186" 100 0 0 100 timetz_mi_interval - ));
|
||||
DESCR("minus");
|
||||
|
||||
DATA(insert OID = 1764 ( numeric_inc PGUID 12 f t t t 1 f 1700 "1700" 100 0 0 100 numeric_inc - ));
|
||||
DESCR("increment by one");
|
||||
DATA(insert OID = 1766 ( numeric_smaller PGUID 12 f t t t 2 f 1700 "1700 1700" 100 0 0 100 numeric_smaller - ));
|
||||
@ -2521,6 +2534,9 @@ DESCR("encode text from encoding to ASCII text");
|
||||
DATA(insert OID = 1847 ( to_ascii PGUID 12 f t t t 2 f 25 "25 19" 100 0 0 100 to_ascii_encname - ));
|
||||
DESCR("encode text from encoding to ASCII text");
|
||||
|
||||
DATA(insert OID = 1848 ( interval_pl_time PGUID 12 f t t t 2 f 1083 "1186 1083" 100 0 0 100 interval_pl_time - ));
|
||||
DESCR("plus");
|
||||
|
||||
DATA(insert OID = 1850 ( int28eq PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28eq - ));
|
||||
DESCR("equal");
|
||||
DATA(insert OID = 1851 ( int28ne PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28ne - ));
|
||||
|
@ -33,4 +33,9 @@ typedef unsigned int slock_t;
|
||||
|
||||
#define HAS_TEST_AND_SET
|
||||
|
||||
#elif defined(__s390__)
|
||||
typedef unsigned int slock_t;
|
||||
|
||||
#define HAS_TEST_AND_SET
|
||||
|
||||
#endif
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: date.h,v 1.6 2000/11/11 19:55:39 thomas Exp $
|
||||
* $Id: date.h,v 1.7 2000/12/03 14:51:11 thomas Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -87,8 +87,12 @@ extern Datum time_larger(PG_FUNCTION_ARGS);
|
||||
extern Datum time_smaller(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_time(PG_FUNCTION_ARGS);
|
||||
extern Datum time_interval(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_time(PG_FUNCTION_ARGS);
|
||||
extern Datum text_time(PG_FUNCTION_ARGS);
|
||||
extern Datum time_text(PG_FUNCTION_ARGS);
|
||||
extern Datum time_pl_interval(PG_FUNCTION_ARGS);
|
||||
extern Datum time_mi_interval(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_pl_time(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum timetz_in(PG_FUNCTION_ARGS);
|
||||
extern Datum timetz_out(PG_FUNCTION_ARGS);
|
||||
@ -107,5 +111,7 @@ extern Datum timestamp_timetz(PG_FUNCTION_ARGS);
|
||||
extern Datum datetimetz_timestamp(PG_FUNCTION_ARGS);
|
||||
extern Datum text_timetz(PG_FUNCTION_ARGS);
|
||||
extern Datum timetz_text(PG_FUNCTION_ARGS);
|
||||
extern Datum timetz_pl_interval(PG_FUNCTION_ARGS);
|
||||
extern Datum timetz_mi_interval(PG_FUNCTION_ARGS);
|
||||
|
||||
#endif /* DATE_H */
|
||||
|
@ -70,6 +70,712 @@ SELECT timestamp '1999-12-01' + interval '1 month - 1 second' AS "Dec 31";
|
||||
Fri Dec 31 23:59:59 1999 PST
|
||||
(1 row)
|
||||
|
||||
--
|
||||
-- time, interval arithmetic
|
||||
--
|
||||
SELECT CAST(time '01:02' AS interval) AS "+01:02";
|
||||
+01:02
|
||||
-----------------
|
||||
@ 1 hour 2 mins
|
||||
(1 row)
|
||||
|
||||
SELECT CAST(interval '02:03' AS time) AS "02:03:00";
|
||||
02:03:00
|
||||
----------
|
||||
02:03:00
|
||||
(1 row)
|
||||
|
||||
SELECT time '01:30' + interval '02:01' AS "03:31:00";
|
||||
03:31:00
|
||||
----------
|
||||
03:31:00
|
||||
(1 row)
|
||||
|
||||
SELECT time '01:30' - interval '02:01' AS "23:29:00";
|
||||
23:29:00
|
||||
----------
|
||||
23:29:00
|
||||
(1 row)
|
||||
|
||||
SELECT time '02:30' + interval '36:01' AS "14:31:00";
|
||||
14:31:00
|
||||
----------
|
||||
14:31:00
|
||||
(1 row)
|
||||
|
||||
SELECT time '03:30' + interval '1 month 04:01' AS "07:31:00";
|
||||
07:31:00
|
||||
----------
|
||||
07:31:00
|
||||
(1 row)
|
||||
|
||||
SELECT interval '04:30' - time '01:02' AS "+03:28";
|
||||
+03:28
|
||||
-------------------
|
||||
@ 3 hours 28 mins
|
||||
(1 row)
|
||||
|
||||
SELECT CAST(time with time zone '01:02-08' AS interval) AS "+00:01";
|
||||
ERROR: Cannot cast type 'timetz' to 'interval'
|
||||
SELECT CAST(interval '02:03' AS time with time zone) AS "02:03:00-08";
|
||||
ERROR: Cannot cast type 'interval' to 'timetz'
|
||||
SELECT time with time zone '01:30' + interval '02:01' AS "03:31:00-08";
|
||||
03:31:00-08
|
||||
-------------
|
||||
03:31:00-08
|
||||
(1 row)
|
||||
|
||||
SELECT time with time zone '01:30-08' - interval '02:01' AS "23:29:00-08";
|
||||
23:29:00-08
|
||||
-------------
|
||||
23:29:00-08
|
||||
(1 row)
|
||||
|
||||
SELECT time with time zone '02:30-08' + interval '36:01' AS "14:31:00-08";
|
||||
14:31:00-08
|
||||
-------------
|
||||
14:31:00-08
|
||||
(1 row)
|
||||
|
||||
SELECT time with time zone '03:30' + interval '1 month 04:01' AS "07:31:00-08";
|
||||
07:31:00-08
|
||||
-------------
|
||||
07:31:00-08
|
||||
(1 row)
|
||||
|
||||
SELECT interval '04:30' - time with time zone '01:02' AS "+03:28";
|
||||
ERROR: Unable to identify an operator '-' for types 'interval' and 'timetz'
|
||||
You will have to retype this query using an explicit cast
|
||||
-- We get 100 rows when run in GMT...
|
||||
SELECT t.d1 + i.f1 AS "102" FROM TIMESTAMP_TBL t, INTERVAL_TBL i
|
||||
WHERE t.d1 BETWEEN '1990-01-01' AND '2001-01-01'
|
||||
AND i.f1 BETWEEN '00:00' AND '23:00';
|
||||
102
|
||||
---------------------------------
|
||||
Mon Feb 10 17:33:01 1997 PST
|
||||
Mon Feb 10 22:32:01 1997 PST
|
||||
Mon Feb 10 17:33:01.00 1997 PST
|
||||
Mon Feb 10 22:32:01.00 1997 PST
|
||||
Mon Feb 10 17:33:02.00 1997 PST
|
||||
Mon Feb 10 22:32:02.00 1997 PST
|
||||
Mon Feb 10 17:33:01.40 1997 PST
|
||||
Mon Feb 10 22:32:01.40 1997 PST
|
||||
Mon Feb 10 17:33:01.50 1997 PST
|
||||
Mon Feb 10 22:32:01.50 1997 PST
|
||||
Mon Feb 10 17:33:01.60 1997 PST
|
||||
Mon Feb 10 22:32:01.60 1997 PST
|
||||
Thu Jan 02 00:01:00 1997 PST
|
||||
Thu Jan 02 05:00:00 1997 PST
|
||||
Thu Jan 02 03:05:05 1997 PST
|
||||
Thu Jan 02 08:04:05 1997 PST
|
||||
Mon Feb 10 17:33:01 1997 PST
|
||||
Mon Feb 10 22:32:01 1997 PST
|
||||
Mon Feb 10 17:33:01 1997 PST
|
||||
Mon Feb 10 22:32:01 1997 PST
|
||||
Mon Feb 10 17:33:01 1997 PST
|
||||
Mon Feb 10 22:32:01 1997 PST
|
||||
Mon Feb 10 17:33:01 1997 PST
|
||||
Mon Feb 10 22:32:01 1997 PST
|
||||
Tue Jun 10 17:33:01 1997 PDT
|
||||
Tue Jun 10 22:32:01 1997 PDT
|
||||
Wed Mar 15 08:15:01 2000 PST
|
||||
Wed Mar 15 13:14:01 2000 PST
|
||||
Wed Mar 15 04:15:02 2000 PST
|
||||
Wed Mar 15 09:14:02 2000 PST
|
||||
Wed Mar 15 02:15:03 2000 PST
|
||||
Wed Mar 15 07:14:03 2000 PST
|
||||
Wed Mar 15 03:15:04 2000 PST
|
||||
Wed Mar 15 08:14:04 2000 PST
|
||||
Wed Mar 15 01:15:05 2000 PST
|
||||
Wed Mar 15 06:14:05 2000 PST
|
||||
Mon Feb 10 17:33:01 1997 PST
|
||||
Mon Feb 10 22:32:01 1997 PST
|
||||
Mon Feb 10 17:33:01 1997 PST
|
||||
Mon Feb 10 22:32:01 1997 PST
|
||||
Mon Feb 10 17:33:00 1997 PST
|
||||
Mon Feb 10 22:32:00 1997 PST
|
||||
Mon Feb 10 17:33:01 1997 PST
|
||||
Mon Feb 10 22:32:01 1997 PST
|
||||
Mon Feb 10 17:33:01 1997 PST
|
||||
Mon Feb 10 22:32:01 1997 PST
|
||||
Mon Feb 10 17:33:01 1997 PST
|
||||
Mon Feb 10 22:32:01 1997 PST
|
||||
Mon Feb 10 17:33:01 1997 PST
|
||||
Mon Feb 10 22:32:01 1997 PST
|
||||
Mon Feb 10 17:33:01 1997 PST
|
||||
Mon Feb 10 22:32:01 1997 PST
|
||||
Mon Feb 10 09:33:01 1997 PST
|
||||
Mon Feb 10 14:32:01 1997 PST
|
||||
Mon Feb 10 09:33:01 1997 PST
|
||||
Mon Feb 10 14:32:01 1997 PST
|
||||
Mon Feb 10 09:33:01 1997 PST
|
||||
Mon Feb 10 14:32:01 1997 PST
|
||||
Tue Jun 10 18:33:01 1997 PDT
|
||||
Tue Jun 10 23:32:01 1997 PDT
|
||||
Mon Feb 10 17:33:01 1997 PST
|
||||
Mon Feb 10 22:32:01 1997 PST
|
||||
Tue Feb 11 17:33:01 1997 PST
|
||||
Tue Feb 11 22:32:01 1997 PST
|
||||
Wed Feb 12 17:33:01 1997 PST
|
||||
Wed Feb 12 22:32:01 1997 PST
|
||||
Thu Feb 13 17:33:01 1997 PST
|
||||
Thu Feb 13 22:32:01 1997 PST
|
||||
Fri Feb 14 17:33:01 1997 PST
|
||||
Fri Feb 14 22:32:01 1997 PST
|
||||
Sat Feb 15 17:33:01 1997 PST
|
||||
Sat Feb 15 22:32:01 1997 PST
|
||||
Sun Feb 16 17:33:01 1997 PST
|
||||
Sun Feb 16 22:32:01 1997 PST
|
||||
Sun Feb 16 17:33:01 1997 PST
|
||||
Sun Feb 16 22:32:01 1997 PST
|
||||
Wed Feb 28 17:33:01 1996 PST
|
||||
Wed Feb 28 22:32:01 1996 PST
|
||||
Thu Feb 29 17:33:01 1996 PST
|
||||
Thu Feb 29 22:32:01 1996 PST
|
||||
Fri Mar 01 17:33:01 1996 PST
|
||||
Fri Mar 01 22:32:01 1996 PST
|
||||
Mon Dec 30 17:33:01 1996 PST
|
||||
Mon Dec 30 22:32:01 1996 PST
|
||||
Tue Dec 31 17:33:01 1996 PST
|
||||
Tue Dec 31 22:32:01 1996 PST
|
||||
Wed Jan 01 17:33:01 1997 PST
|
||||
Wed Jan 01 22:32:01 1997 PST
|
||||
Fri Feb 28 17:33:01 1997 PST
|
||||
Fri Feb 28 22:32:01 1997 PST
|
||||
Sat Mar 01 17:33:01 1997 PST
|
||||
Sat Mar 01 22:32:01 1997 PST
|
||||
Tue Dec 30 17:33:01 1997 PST
|
||||
Tue Dec 30 22:32:01 1997 PST
|
||||
Wed Dec 31 17:33:01 1997 PST
|
||||
Wed Dec 31 22:32:01 1997 PST
|
||||
Fri Dec 31 17:33:01 1999 PST
|
||||
Fri Dec 31 22:32:01 1999 PST
|
||||
Sat Jan 01 17:33:01 2000 PST
|
||||
Sat Jan 01 22:32:01 2000 PST
|
||||
Sun Dec 31 17:33:01 2000 PST
|
||||
Sun Dec 31 22:32:01 2000 PST
|
||||
(102 rows)
|
||||
|
||||
SELECT t.d1 - i.f1 AS "102" FROM TIMESTAMP_TBL t, INTERVAL_TBL i
|
||||
WHERE t.d1 BETWEEN '1990-01-01' AND '2001-01-01'
|
||||
AND i.f1 BETWEEN '00:00' AND '23:00';
|
||||
102
|
||||
---------------------------------
|
||||
Mon Feb 10 17:31:01 1997 PST
|
||||
Mon Feb 10 12:32:01 1997 PST
|
||||
Mon Feb 10 17:31:01.00 1997 PST
|
||||
Mon Feb 10 12:32:01.00 1997 PST
|
||||
Mon Feb 10 17:31:02.00 1997 PST
|
||||
Mon Feb 10 12:32:02.00 1997 PST
|
||||
Mon Feb 10 17:31:01.40 1997 PST
|
||||
Mon Feb 10 12:32:01.40 1997 PST
|
||||
Mon Feb 10 17:31:01.50 1997 PST
|
||||
Mon Feb 10 12:32:01.50 1997 PST
|
||||
Mon Feb 10 17:31:01.60 1997 PST
|
||||
Mon Feb 10 12:32:01.60 1997 PST
|
||||
Wed Jan 01 23:59:00 1997 PST
|
||||
Wed Jan 01 19:00:00 1997 PST
|
||||
Thu Jan 02 03:03:05 1997 PST
|
||||
Wed Jan 01 22:04:05 1997 PST
|
||||
Mon Feb 10 17:31:01 1997 PST
|
||||
Mon Feb 10 12:32:01 1997 PST
|
||||
Mon Feb 10 17:31:01 1997 PST
|
||||
Mon Feb 10 12:32:01 1997 PST
|
||||
Mon Feb 10 17:31:01 1997 PST
|
||||
Mon Feb 10 12:32:01 1997 PST
|
||||
Mon Feb 10 17:31:01 1997 PST
|
||||
Mon Feb 10 12:32:01 1997 PST
|
||||
Tue Jun 10 17:31:01 1997 PDT
|
||||
Tue Jun 10 12:32:01 1997 PDT
|
||||
Wed Mar 15 08:13:01 2000 PST
|
||||
Wed Mar 15 03:14:01 2000 PST
|
||||
Wed Mar 15 04:13:02 2000 PST
|
||||
Tue Mar 14 23:14:02 2000 PST
|
||||
Wed Mar 15 02:13:03 2000 PST
|
||||
Tue Mar 14 21:14:03 2000 PST
|
||||
Wed Mar 15 03:13:04 2000 PST
|
||||
Tue Mar 14 22:14:04 2000 PST
|
||||
Wed Mar 15 01:13:05 2000 PST
|
||||
Tue Mar 14 20:14:05 2000 PST
|
||||
Mon Feb 10 17:31:01 1997 PST
|
||||
Mon Feb 10 12:32:01 1997 PST
|
||||
Mon Feb 10 17:31:01 1997 PST
|
||||
Mon Feb 10 12:32:01 1997 PST
|
||||
Mon Feb 10 17:31:00 1997 PST
|
||||
Mon Feb 10 12:32:00 1997 PST
|
||||
Mon Feb 10 17:31:01 1997 PST
|
||||
Mon Feb 10 12:32:01 1997 PST
|
||||
Mon Feb 10 17:31:01 1997 PST
|
||||
Mon Feb 10 12:32:01 1997 PST
|
||||
Mon Feb 10 17:31:01 1997 PST
|
||||
Mon Feb 10 12:32:01 1997 PST
|
||||
Mon Feb 10 17:31:01 1997 PST
|
||||
Mon Feb 10 12:32:01 1997 PST
|
||||
Mon Feb 10 17:31:01 1997 PST
|
||||
Mon Feb 10 12:32:01 1997 PST
|
||||
Mon Feb 10 09:31:01 1997 PST
|
||||
Mon Feb 10 04:32:01 1997 PST
|
||||
Mon Feb 10 09:31:01 1997 PST
|
||||
Mon Feb 10 04:32:01 1997 PST
|
||||
Mon Feb 10 09:31:01 1997 PST
|
||||
Mon Feb 10 04:32:01 1997 PST
|
||||
Tue Jun 10 18:31:01 1997 PDT
|
||||
Tue Jun 10 13:32:01 1997 PDT
|
||||
Mon Feb 10 17:31:01 1997 PST
|
||||
Mon Feb 10 12:32:01 1997 PST
|
||||
Tue Feb 11 17:31:01 1997 PST
|
||||
Tue Feb 11 12:32:01 1997 PST
|
||||
Wed Feb 12 17:31:01 1997 PST
|
||||
Wed Feb 12 12:32:01 1997 PST
|
||||
Thu Feb 13 17:31:01 1997 PST
|
||||
Thu Feb 13 12:32:01 1997 PST
|
||||
Fri Feb 14 17:31:01 1997 PST
|
||||
Fri Feb 14 12:32:01 1997 PST
|
||||
Sat Feb 15 17:31:01 1997 PST
|
||||
Sat Feb 15 12:32:01 1997 PST
|
||||
Sun Feb 16 17:31:01 1997 PST
|
||||
Sun Feb 16 12:32:01 1997 PST
|
||||
Sun Feb 16 17:31:01 1997 PST
|
||||
Sun Feb 16 12:32:01 1997 PST
|
||||
Wed Feb 28 17:31:01 1996 PST
|
||||
Wed Feb 28 12:32:01 1996 PST
|
||||
Thu Feb 29 17:31:01 1996 PST
|
||||
Thu Feb 29 12:32:01 1996 PST
|
||||
Fri Mar 01 17:31:01 1996 PST
|
||||
Fri Mar 01 12:32:01 1996 PST
|
||||
Mon Dec 30 17:31:01 1996 PST
|
||||
Mon Dec 30 12:32:01 1996 PST
|
||||
Tue Dec 31 17:31:01 1996 PST
|
||||
Tue Dec 31 12:32:01 1996 PST
|
||||
Wed Jan 01 17:31:01 1997 PST
|
||||
Wed Jan 01 12:32:01 1997 PST
|
||||
Fri Feb 28 17:31:01 1997 PST
|
||||
Fri Feb 28 12:32:01 1997 PST
|
||||
Sat Mar 01 17:31:01 1997 PST
|
||||
Sat Mar 01 12:32:01 1997 PST
|
||||
Tue Dec 30 17:31:01 1997 PST
|
||||
Tue Dec 30 12:32:01 1997 PST
|
||||
Wed Dec 31 17:31:01 1997 PST
|
||||
Wed Dec 31 12:32:01 1997 PST
|
||||
Fri Dec 31 17:31:01 1999 PST
|
||||
Fri Dec 31 12:32:01 1999 PST
|
||||
Sat Jan 01 17:31:01 2000 PST
|
||||
Sat Jan 01 12:32:01 2000 PST
|
||||
Sun Dec 31 17:31:01 2000 PST
|
||||
Sun Dec 31 12:32:01 2000 PST
|
||||
(102 rows)
|
||||
|
||||
SELECT t.f1 + i.f1 AS "80" FROM TIME_TBL t, INTERVAL_TBL i;
|
||||
80
|
||||
----------
|
||||
00:01:00
|
||||
05:00:00
|
||||
00:00:00
|
||||
00:00:00
|
||||
00:00:00
|
||||
23:59:46
|
||||
02:03:04
|
||||
00:00:00
|
||||
00:00:00
|
||||
12:00:00
|
||||
01:01:00
|
||||
06:00:00
|
||||
01:00:00
|
||||
01:00:00
|
||||
01:00:00
|
||||
00:59:46
|
||||
03:03:04
|
||||
01:00:00
|
||||
01:00:00
|
||||
13:00:00
|
||||
02:04:00
|
||||
07:03:00
|
||||
02:03:00
|
||||
02:03:00
|
||||
02:03:00
|
||||
02:02:46
|
||||
04:06:04
|
||||
02:03:00
|
||||
02:03:00
|
||||
14:03:00
|
||||
12:00:00
|
||||
16:59:00
|
||||
11:59:00
|
||||
11:59:00
|
||||
11:59:00
|
||||
11:58:46
|
||||
14:02:04
|
||||
11:59:00
|
||||
11:59:00
|
||||
23:59:00
|
||||
12:01:00
|
||||
17:00:00
|
||||
12:00:00
|
||||
12:00:00
|
||||
12:00:00
|
||||
11:59:46
|
||||
14:03:04
|
||||
12:00:00
|
||||
12:00:00
|
||||
00:00:00
|
||||
12:02:00
|
||||
17:01:00
|
||||
12:01:00
|
||||
12:01:00
|
||||
12:01:00
|
||||
12:00:46
|
||||
14:04:04
|
||||
12:01:00
|
||||
12:01:00
|
||||
00:01:00
|
||||
00:00:00
|
||||
04:59:00
|
||||
23:59:00
|
||||
23:59:00
|
||||
23:59:00
|
||||
23:58:46
|
||||
02:02:04
|
||||
23:59:00
|
||||
23:59:00
|
||||
11:59:00
|
||||
00:00:59
|
||||
04:59:59
|
||||
23:59:59
|
||||
23:59:59
|
||||
23:59:59
|
||||
23:59:45
|
||||
02:03:03
|
||||
23:59:59
|
||||
23:59:59
|
||||
11:59:59
|
||||
(80 rows)
|
||||
|
||||
SELECT t.f1 - i.f1 AS "80" FROM TIME_TBL t, INTERVAL_TBL i;
|
||||
80
|
||||
----------
|
||||
23:59:00
|
||||
19:00:00
|
||||
00:00:00
|
||||
00:00:00
|
||||
00:00:00
|
||||
00:00:14
|
||||
21:56:56
|
||||
00:00:00
|
||||
00:00:00
|
||||
12:00:00
|
||||
00:59:00
|
||||
20:00:00
|
||||
01:00:00
|
||||
01:00:00
|
||||
01:00:00
|
||||
01:00:14
|
||||
22:56:56
|
||||
01:00:00
|
||||
01:00:00
|
||||
13:00:00
|
||||
02:02:00
|
||||
21:03:00
|
||||
02:03:00
|
||||
02:03:00
|
||||
02:03:00
|
||||
02:03:14
|
||||
23:59:56
|
||||
02:03:00
|
||||
02:03:00
|
||||
14:03:00
|
||||
11:58:00
|
||||
06:59:00
|
||||
11:59:00
|
||||
11:59:00
|
||||
11:59:00
|
||||
11:59:14
|
||||
09:55:56
|
||||
11:59:00
|
||||
11:59:00
|
||||
23:59:00
|
||||
11:59:00
|
||||
07:00:00
|
||||
12:00:00
|
||||
12:00:00
|
||||
12:00:00
|
||||
12:00:14
|
||||
09:56:56
|
||||
12:00:00
|
||||
12:00:00
|
||||
00:00:00
|
||||
12:00:00
|
||||
07:01:00
|
||||
12:01:00
|
||||
12:01:00
|
||||
12:01:00
|
||||
12:01:14
|
||||
09:57:56
|
||||
12:01:00
|
||||
12:01:00
|
||||
00:01:00
|
||||
23:58:00
|
||||
18:59:00
|
||||
23:59:00
|
||||
23:59:00
|
||||
23:59:00
|
||||
23:59:14
|
||||
21:55:56
|
||||
23:59:00
|
||||
23:59:00
|
||||
11:59:00
|
||||
23:58:59
|
||||
18:59:59
|
||||
23:59:59
|
||||
23:59:59
|
||||
23:59:59
|
||||
00:00:13
|
||||
21:56:55
|
||||
23:59:59
|
||||
23:59:59
|
||||
11:59:59
|
||||
(80 rows)
|
||||
|
||||
SELECT t.f2 + i.f1 AS "80" FROM TIME_TBL t, INTERVAL_TBL i;
|
||||
80
|
||||
-------------
|
||||
00:01:00-07
|
||||
05:00:00-07
|
||||
00:00:00-07
|
||||
00:00:00-07
|
||||
00:00:00-07
|
||||
23:59:46-07
|
||||
02:03:04-07
|
||||
00:00:00-07
|
||||
00:00:00-07
|
||||
12:00:00-07
|
||||
01:01:00-07
|
||||
06:00:00-07
|
||||
01:00:00-07
|
||||
01:00:00-07
|
||||
01:00:00-07
|
||||
00:59:46-07
|
||||
03:03:04-07
|
||||
01:00:00-07
|
||||
01:00:00-07
|
||||
13:00:00-07
|
||||
02:04:00-07
|
||||
07:03:00-07
|
||||
02:03:00-07
|
||||
02:03:00-07
|
||||
02:03:00-07
|
||||
02:02:46-07
|
||||
04:06:04-07
|
||||
02:03:00-07
|
||||
02:03:00-07
|
||||
14:03:00-07
|
||||
12:00:00-07
|
||||
16:59:00-07
|
||||
11:59:00-07
|
||||
11:59:00-07
|
||||
11:59:00-07
|
||||
11:58:46-07
|
||||
14:02:04-07
|
||||
11:59:00-07
|
||||
11:59:00-07
|
||||
23:59:00-07
|
||||
12:01:00-07
|
||||
17:00:00-07
|
||||
12:00:00-07
|
||||
12:00:00-07
|
||||
12:00:00-07
|
||||
11:59:46-07
|
||||
14:03:04-07
|
||||
12:00:00-07
|
||||
12:00:00-07
|
||||
00:00:00-07
|
||||
12:02:00-07
|
||||
17:01:00-07
|
||||
12:01:00-07
|
||||
12:01:00-07
|
||||
12:01:00-07
|
||||
12:00:46-07
|
||||
14:04:04-07
|
||||
12:01:00-07
|
||||
12:01:00-07
|
||||
00:01:00-07
|
||||
00:00:00-07
|
||||
04:59:00-07
|
||||
23:59:00-07
|
||||
23:59:00-07
|
||||
23:59:00-07
|
||||
23:58:46-07
|
||||
02:02:04-07
|
||||
23:59:00-07
|
||||
23:59:00-07
|
||||
11:59:00-07
|
||||
00:00:59-07
|
||||
04:59:59-07
|
||||
23:59:59-07
|
||||
23:59:59-07
|
||||
23:59:59-07
|
||||
23:59:45-07
|
||||
02:03:03-07
|
||||
23:59:59-07
|
||||
23:59:59-07
|
||||
11:59:59-07
|
||||
(80 rows)
|
||||
|
||||
SELECT t.f2 - i.f1 AS "80" FROM TIME_TBL t, INTERVAL_TBL i;
|
||||
80
|
||||
-------------
|
||||
23:59:00-07
|
||||
19:00:00-07
|
||||
00:00:00-07
|
||||
00:00:00-07
|
||||
00:00:00-07
|
||||
00:00:14-07
|
||||
21:56:56-07
|
||||
00:00:00-07
|
||||
00:00:00-07
|
||||
12:00:00-07
|
||||
00:59:00-07
|
||||
20:00:00-07
|
||||
01:00:00-07
|
||||
01:00:00-07
|
||||
01:00:00-07
|
||||
01:00:14-07
|
||||
22:56:56-07
|
||||
01:00:00-07
|
||||
01:00:00-07
|
||||
13:00:00-07
|
||||
02:02:00-07
|
||||
21:03:00-07
|
||||
02:03:00-07
|
||||
02:03:00-07
|
||||
02:03:00-07
|
||||
02:03:14-07
|
||||
23:59:56-07
|
||||
02:03:00-07
|
||||
02:03:00-07
|
||||
14:03:00-07
|
||||
11:58:00-07
|
||||
06:59:00-07
|
||||
11:59:00-07
|
||||
11:59:00-07
|
||||
11:59:00-07
|
||||
11:59:14-07
|
||||
09:55:56-07
|
||||
11:59:00-07
|
||||
11:59:00-07
|
||||
23:59:00-07
|
||||
11:59:00-07
|
||||
07:00:00-07
|
||||
12:00:00-07
|
||||
12:00:00-07
|
||||
12:00:00-07
|
||||
12:00:14-07
|
||||
09:56:56-07
|
||||
12:00:00-07
|
||||
12:00:00-07
|
||||
00:00:00-07
|
||||
12:00:00-07
|
||||
07:01:00-07
|
||||
12:01:00-07
|
||||
12:01:00-07
|
||||
12:01:00-07
|
||||
12:01:14-07
|
||||
09:57:56-07
|
||||
12:01:00-07
|
||||
12:01:00-07
|
||||
00:01:00-07
|
||||
23:58:00-07
|
||||
18:59:00-07
|
||||
23:59:00-07
|
||||
23:59:00-07
|
||||
23:59:00-07
|
||||
23:59:14-07
|
||||
21:55:56-07
|
||||
23:59:00-07
|
||||
23:59:00-07
|
||||
11:59:00-07
|
||||
23:58:59-07
|
||||
18:59:59-07
|
||||
23:59:59-07
|
||||
23:59:59-07
|
||||
23:59:59-07
|
||||
00:00:13-07
|
||||
21:56:55-07
|
||||
23:59:59-07
|
||||
23:59:59-07
|
||||
11:59:59-07
|
||||
(80 rows)
|
||||
|
||||
-- SQL9x OVERLAPS operator
|
||||
SELECT (timestamp '2000-11-27', timestamp '2000-11-28')
|
||||
OVERLAPS (timestamp '2000-11-27 12:00', timestamp '2000-11-30') AS "True";
|
||||
True
|
||||
------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT (timestamp '2000-11-26', timestamp '2000-11-27')
|
||||
OVERLAPS (timestamp '2000-11-27 12:00', timestamp '2000-11-30') AS "False";
|
||||
False
|
||||
-------
|
||||
f
|
||||
(1 row)
|
||||
|
||||
SELECT (timestamp '2000-11-27', timestamp '2000-11-28')
|
||||
OVERLAPS (timestamp '2000-11-27 12:00', interval '1 day') AS "True";
|
||||
True
|
||||
------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT (timestamp '2000-11-27', interval '12 hours')
|
||||
OVERLAPS (timestamp '2000-11-27 12:00', timestamp '2000-11-30') AS "False";
|
||||
False
|
||||
-------
|
||||
f
|
||||
(1 row)
|
||||
|
||||
SELECT (timestamp '2000-11-27', interval '12 hours')
|
||||
OVERLAPS (timestamp '2000-11-27', interval '12 hours') AS "True";
|
||||
True
|
||||
------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT (timestamp '2000-11-27', interval '12 hours')
|
||||
OVERLAPS (timestamp '2000-11-27 12:00', interval '12 hours') AS "False";
|
||||
False
|
||||
-------
|
||||
f
|
||||
(1 row)
|
||||
|
||||
SELECT (time '00:00', time '01:00')
|
||||
OVERLAPS (time '00:30', time '01:30') AS "True";
|
||||
True
|
||||
------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT (time '00:00', interval '1 hour')
|
||||
OVERLAPS (time '00:30', interval '1 hour') AS "True";
|
||||
True
|
||||
------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT (time '00:00', interval '1 hour')
|
||||
OVERLAPS (time '01:30', interval '1 hour') AS "False";
|
||||
False
|
||||
-------
|
||||
f
|
||||
(1 row)
|
||||
|
||||
SELECT (time '00:00', interval '1 hour')
|
||||
OVERLAPS (time '01:30', interval '1 day') AS "True";
|
||||
True
|
||||
------
|
||||
f
|
||||
(1 row)
|
||||
|
||||
CREATE TABLE TEMP_TIMESTAMP (f1 timestamp);
|
||||
-- get some candidate input values
|
||||
INSERT INTO TEMP_TIMESTAMP (f1)
|
||||
|
@ -62,122 +62,14 @@ SELECT f1 AS "Eight" FROM TIME_TBL WHERE f1 >= '00:00';
|
||||
--
|
||||
-- TIME simple math
|
||||
--
|
||||
SELECT f1 + time '00:01' AS "Eight" FROM TIME_TBL;
|
||||
Eight
|
||||
--------------------
|
||||
@ 1 min
|
||||
@ 1 hour 1 min
|
||||
@ 2 hours 4 mins
|
||||
@ 12 hours
|
||||
@ 12 hours 1 min
|
||||
@ 12 hours 2 mins
|
||||
@ 1 day
|
||||
@ 1 day 59.99 secs
|
||||
(8 rows)
|
||||
|
||||
SELECT f1 + time '01:00' AS "Eight" FROM TIME_TBL;
|
||||
Eight
|
||||
----------------------------
|
||||
@ 1 hour
|
||||
@ 2 hours
|
||||
@ 3 hours 3 mins
|
||||
@ 12 hours 59 mins
|
||||
@ 13 hours
|
||||
@ 13 hours 1 min
|
||||
@ 1 day 59 mins
|
||||
@ 1 day 59 mins 59.99 secs
|
||||
(8 rows)
|
||||
|
||||
SELECT f1 + time '00:00:01.11' AS "Eight" FROM TIME_TBL;
|
||||
Eight
|
||||
------------------------------
|
||||
@ 1.11 secs
|
||||
@ 1 hour 1.11 secs
|
||||
@ 2 hours 3 mins 1.11 secs
|
||||
@ 11 hours 59 mins 1.11 secs
|
||||
@ 12 hours 1.11 secs
|
||||
@ 12 hours 1 min 1.11 secs
|
||||
@ 23 hours 59 mins 1.11 secs
|
||||
@ 1 day 1.10 secs
|
||||
(8 rows)
|
||||
|
||||
SELECT f1 + time '00:00:59.99' AS "Eight" FROM TIME_TBL;
|
||||
Eight
|
||||
-------------------------------
|
||||
@ 59.99 secs
|
||||
@ 1 hour 59.99 secs
|
||||
@ 2 hours 3 mins 59.99 secs
|
||||
@ 11 hours 59 mins 59.99 secs
|
||||
@ 12 hours 59.99 secs
|
||||
@ 12 hours 1 min 59.99 secs
|
||||
@ 23 hours 59 mins 59.99 secs
|
||||
@ 1 day 59.98 secs
|
||||
(8 rows)
|
||||
|
||||
SELECT f1 - '00:01' AS "Eight" FROM TIME_TBL;
|
||||
Eight
|
||||
-------------------------------
|
||||
@ 1 min ago
|
||||
@ 59 mins
|
||||
@ 2 hours 2 mins
|
||||
@ 11 hours 58 mins
|
||||
@ 11 hours 59 mins
|
||||
@ 12 hours
|
||||
@ 23 hours 58 mins
|
||||
@ 23 hours 58 mins 59.99 secs
|
||||
(8 rows)
|
||||
|
||||
SELECT f1 - '01:00' AS "Eight" FROM TIME_TBL;
|
||||
Eight
|
||||
-------------------------------
|
||||
@ 1 hour ago
|
||||
@ 0
|
||||
@ 1 hour 3 mins
|
||||
@ 10 hours 59 mins
|
||||
@ 11 hours
|
||||
@ 11 hours 1 min
|
||||
@ 22 hours 59 mins
|
||||
@ 22 hours 59 mins 59.99 secs
|
||||
(8 rows)
|
||||
|
||||
SELECT f1 - '00:00:01.11' AS "Eight" FROM TIME_TBL;
|
||||
Eight
|
||||
-------------------------------
|
||||
@ 1.11 secs ago
|
||||
@ 59 mins 58.89 secs
|
||||
@ 2 hours 2 mins 58.89 secs
|
||||
@ 11 hours 58 mins 58.89 secs
|
||||
@ 11 hours 59 mins 58.89 secs
|
||||
@ 12 hours 58.89 secs
|
||||
@ 23 hours 58 mins 58.89 secs
|
||||
@ 23 hours 59 mins 58.88 secs
|
||||
(8 rows)
|
||||
|
||||
SELECT f1 - '00:00:59.99' AS "Eight" FROM TIME_TBL;
|
||||
Eight
|
||||
------------------------------
|
||||
@ 59.99 secs ago
|
||||
@ 59 mins 0.01 secs
|
||||
@ 2 hours 2 mins 0.01 secs
|
||||
@ 11 hours 58 mins 0.01 secs
|
||||
@ 11 hours 59 mins 0.01 secs
|
||||
@ 12 hours 0.01 secs
|
||||
@ 23 hours 58 mins 0.01 secs
|
||||
@ 23 hours 59 mins
|
||||
(8 rows)
|
||||
|
||||
--
|
||||
-- TIME WITH TIME ZONE simple math
|
||||
--
|
||||
/*
|
||||
-- Not yet implemented
|
||||
-- Thomas 2000-09-09
|
||||
SELECT f2 + time '00:01' AS "" FROM TIME_TBL;
|
||||
SELECT f2 + time '01:00' AS "" FROM TIME_TBL;
|
||||
SELECT f2 + time '00:00:01.11' AS "" FROM TIME_TBL;
|
||||
SELECT f2 + '00:00:59.99' AS "" FROM TIME_TBL;
|
||||
SELECT f2 - '00:01' AS "" FROM TIME_TBL;
|
||||
SELECT f2 - '01:00' AS "" FROM TIME_TBL;
|
||||
SELECT f2 - '00:00:01.11' AS "" FROM TIME_TBL;
|
||||
SELECT f2 - '00:00:59.99' AS "" FROM TIME_TBL;
|
||||
*/
|
||||
-- We now make a distinction between time and intervals,
|
||||
-- and adding two times together makes no sense at all.
|
||||
-- Leave in one query to show that it is rejected,
|
||||
-- and do the rest of the testing in horology.sql
|
||||
-- where we do mixed-type arithmetic. - thomas 2000-12-02
|
||||
SELECT f1 + time '00:01' AS "Illegal" FROM TIME_TBL;
|
||||
ERROR: Unable to identify an operator '+' for types 'time' and 'time'
|
||||
You will have to retype this query using an explicit cast
|
||||
SELECT f2 + time with time zone '00:01' AS "Illegal" FROM TIME_TBL;
|
||||
ERROR: Unable to identify an operator '+' for types 'timetz' and 'timetz'
|
||||
You will have to retype this query using an explicit cast
|
||||
|
@ -25,10 +25,94 @@ SELECT date '1991-02-03' - time with time zone '04:05:06 UTC' AS "Subtract Time
|
||||
--
|
||||
|
||||
SELECT timestamp '1996-03-01' - interval '1 second' AS "Feb 29";
|
||||
|
||||
SELECT timestamp '1999-03-01' - interval '1 second' AS "Feb 28";
|
||||
|
||||
SELECT timestamp '2000-03-01' - interval '1 second' AS "Feb 29";
|
||||
|
||||
SELECT timestamp '1999-12-01' + interval '1 month - 1 second' AS "Dec 31";
|
||||
|
||||
--
|
||||
-- time, interval arithmetic
|
||||
--
|
||||
|
||||
SELECT CAST(time '01:02' AS interval) AS "+01:02";
|
||||
|
||||
SELECT CAST(interval '02:03' AS time) AS "02:03:00";
|
||||
|
||||
SELECT time '01:30' + interval '02:01' AS "03:31:00";
|
||||
|
||||
SELECT time '01:30' - interval '02:01' AS "23:29:00";
|
||||
|
||||
SELECT time '02:30' + interval '36:01' AS "14:31:00";
|
||||
|
||||
SELECT time '03:30' + interval '1 month 04:01' AS "07:31:00";
|
||||
|
||||
SELECT interval '04:30' - time '01:02' AS "+03:28";
|
||||
|
||||
SELECT CAST(time with time zone '01:02-08' AS interval) AS "+00:01";
|
||||
|
||||
SELECT CAST(interval '02:03' AS time with time zone) AS "02:03:00-08";
|
||||
|
||||
SELECT time with time zone '01:30' + interval '02:01' AS "03:31:00-08";
|
||||
|
||||
SELECT time with time zone '01:30-08' - interval '02:01' AS "23:29:00-08";
|
||||
|
||||
SELECT time with time zone '02:30-08' + interval '36:01' AS "14:31:00-08";
|
||||
|
||||
SELECT time with time zone '03:30' + interval '1 month 04:01' AS "07:31:00-08";
|
||||
|
||||
SELECT interval '04:30' - time with time zone '01:02' AS "+03:28";
|
||||
|
||||
-- We get 100 rows when run in GMT...
|
||||
SELECT t.d1 + i.f1 AS "102" FROM TIMESTAMP_TBL t, INTERVAL_TBL i
|
||||
WHERE t.d1 BETWEEN '1990-01-01' AND '2001-01-01'
|
||||
AND i.f1 BETWEEN '00:00' AND '23:00';
|
||||
|
||||
SELECT t.d1 - i.f1 AS "102" FROM TIMESTAMP_TBL t, INTERVAL_TBL i
|
||||
WHERE t.d1 BETWEEN '1990-01-01' AND '2001-01-01'
|
||||
AND i.f1 BETWEEN '00:00' AND '23:00';
|
||||
|
||||
SELECT t.f1 + i.f1 AS "80" FROM TIME_TBL t, INTERVAL_TBL i;
|
||||
|
||||
SELECT t.f1 - i.f1 AS "80" FROM TIME_TBL t, INTERVAL_TBL i;
|
||||
|
||||
SELECT t.f2 + i.f1 AS "80" FROM TIME_TBL t, INTERVAL_TBL i;
|
||||
|
||||
SELECT t.f2 - i.f1 AS "80" FROM TIME_TBL t, INTERVAL_TBL i;
|
||||
|
||||
-- SQL9x OVERLAPS operator
|
||||
|
||||
SELECT (timestamp '2000-11-27', timestamp '2000-11-28')
|
||||
OVERLAPS (timestamp '2000-11-27 12:00', timestamp '2000-11-30') AS "True";
|
||||
|
||||
SELECT (timestamp '2000-11-26', timestamp '2000-11-27')
|
||||
OVERLAPS (timestamp '2000-11-27 12:00', timestamp '2000-11-30') AS "False";
|
||||
|
||||
SELECT (timestamp '2000-11-27', timestamp '2000-11-28')
|
||||
OVERLAPS (timestamp '2000-11-27 12:00', interval '1 day') AS "True";
|
||||
|
||||
SELECT (timestamp '2000-11-27', interval '12 hours')
|
||||
OVERLAPS (timestamp '2000-11-27 12:00', timestamp '2000-11-30') AS "False";
|
||||
|
||||
SELECT (timestamp '2000-11-27', interval '12 hours')
|
||||
OVERLAPS (timestamp '2000-11-27', interval '12 hours') AS "True";
|
||||
|
||||
SELECT (timestamp '2000-11-27', interval '12 hours')
|
||||
OVERLAPS (timestamp '2000-11-27 12:00', interval '12 hours') AS "False";
|
||||
|
||||
SELECT (time '00:00', time '01:00')
|
||||
OVERLAPS (time '00:30', time '01:30') AS "True";
|
||||
|
||||
SELECT (time '00:00', interval '1 hour')
|
||||
OVERLAPS (time '00:30', interval '1 hour') AS "True";
|
||||
|
||||
SELECT (time '00:00', interval '1 hour')
|
||||
OVERLAPS (time '01:30', interval '1 hour') AS "False";
|
||||
|
||||
SELECT (time '00:00', interval '1 hour')
|
||||
OVERLAPS (time '01:30', interval '1 day') AS "True";
|
||||
|
||||
CREATE TABLE TEMP_TIMESTAMP (f1 timestamp);
|
||||
|
||||
-- get some candidate input values
|
||||
|
@ -26,43 +26,12 @@ SELECT f1 AS "Eight" FROM TIME_TBL WHERE f1 >= '00:00';
|
||||
--
|
||||
-- TIME simple math
|
||||
--
|
||||
-- We now make a distinction between time and intervals,
|
||||
-- and adding two times together makes no sense at all.
|
||||
-- Leave in one query to show that it is rejected,
|
||||
-- and do the rest of the testing in horology.sql
|
||||
-- where we do mixed-type arithmetic. - thomas 2000-12-02
|
||||
|
||||
SELECT f1 + time '00:01' AS "Eight" FROM TIME_TBL;
|
||||
SELECT f1 + time '00:01' AS "Illegal" FROM TIME_TBL;
|
||||
|
||||
SELECT f1 + time '01:00' AS "Eight" FROM TIME_TBL;
|
||||
|
||||
SELECT f1 + time '00:00:01.11' AS "Eight" FROM TIME_TBL;
|
||||
|
||||
SELECT f1 + time '00:00:59.99' AS "Eight" FROM TIME_TBL;
|
||||
|
||||
SELECT f1 - '00:01' AS "Eight" FROM TIME_TBL;
|
||||
|
||||
SELECT f1 - '01:00' AS "Eight" FROM TIME_TBL;
|
||||
|
||||
SELECT f1 - '00:00:01.11' AS "Eight" FROM TIME_TBL;
|
||||
|
||||
SELECT f1 - '00:00:59.99' AS "Eight" FROM TIME_TBL;
|
||||
|
||||
--
|
||||
-- TIME WITH TIME ZONE simple math
|
||||
--
|
||||
|
||||
/*
|
||||
-- Not yet implemented
|
||||
-- Thomas 2000-09-09
|
||||
SELECT f2 + time '00:01' AS "" FROM TIME_TBL;
|
||||
|
||||
SELECT f2 + time '01:00' AS "" FROM TIME_TBL;
|
||||
|
||||
SELECT f2 + time '00:00:01.11' AS "" FROM TIME_TBL;
|
||||
|
||||
SELECT f2 + '00:00:59.99' AS "" FROM TIME_TBL;
|
||||
|
||||
SELECT f2 - '00:01' AS "" FROM TIME_TBL;
|
||||
|
||||
SELECT f2 - '01:00' AS "" FROM TIME_TBL;
|
||||
|
||||
SELECT f2 - '00:00:01.11' AS "" FROM TIME_TBL;
|
||||
|
||||
SELECT f2 - '00:00:59.99' AS "" FROM TIME_TBL;
|
||||
*/
|
||||
SELECT f2 + time with time zone '00:01' AS "Illegal" FROM TIME_TBL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user