Implement precision support for timestamp and time, both with and without

time zones.
SQL99 spec requires a default of zero (round to seconds) which is set
 in gram.y as typmod is set in the parse tree. We *could* change to a
 default of either 6 (for internal compatibility with previous versions)
 or 2 (for external compatibility with previous versions).
Evaluate entries in pg_proc wrt the iscachable attribute for timestamp and
 other date/time types. Try to recognize cases where side effects like the
 current time zone setting may have an effect on results to decide whether
 something is cachable or not.
This commit is contained in:
Thomas G. Lockhart 2001-10-03 05:29:27 +00:00
parent a51de40fb6
commit 3e1beda2cd
22 changed files with 946 additions and 942 deletions

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.198 2001/09/07 21:57:53 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.199 2001/10/03 05:29:12 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -510,11 +510,10 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
* No user-supplied value, so add a targetentry with DEFAULT
* expr and correct data for the target column.
*/
te = makeTargetEntry(
makeResdom(attrno,
te = makeTargetEntry(makeResdom(attrno,
thisatt->atttypid,
thisatt->atttypmod,
pstrdup(NameStr(thisatt->attname)),
pstrdup(NameStr(thisatt->attname)),
false),
stringToNode(defval[ndef].adbin));
qry->targetList = lappend(qry->targetList, te);

View File

@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.256 2001/10/02 21:39:35 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.257 2001/10/03 05:29:12 thomas Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@ -4075,10 +4075,10 @@ opt_numeric: '(' Iconst ',' Iconst ')'
{
if ($2 < 1 || $2 > NUMERIC_MAX_PRECISION)
elog(ERROR,"NUMERIC precision %d must be beween 1 and %d",
$2, NUMERIC_MAX_PRECISION);
$2, NUMERIC_MAX_PRECISION);
if ($4 < 0 || $4 > $2)
elog(ERROR,"NUMERIC scale %d must be between 0 and precision %d",
$4,$2);
$4,$2);
$$ = (($2 << 16) | $4) + VARHDRSZ;
}
@ -4086,7 +4086,7 @@ opt_numeric: '(' Iconst ',' Iconst ')'
{
if ($2 < 1 || $2 > NUMERIC_MAX_PRECISION)
elog(ERROR,"NUMERIC precision %d must be beween 1 and %d",
$2, NUMERIC_MAX_PRECISION);
$2, NUMERIC_MAX_PRECISION);
$$ = ($2 << 16) + VARHDRSZ;
}
@ -4163,7 +4163,7 @@ bit: BIT opt_varying
* SQL92 character data types
* The following implements CHAR() and VARCHAR().
*/
Character: character '(' Iconst ')'
Character: character '(' Iconst ')' opt_charset
{
$$ = makeNode(TypeName);
$$->name = $1;
@ -4180,34 +4180,37 @@ Character: character '(' Iconst ')'
* truncate where necessary)
*/
$$->typmod = VARHDRSZ + $3;
if (($5 != NULL) && (strcmp($5, "sql_text") != 0)) {
char *type;
type = palloc(strlen($$->name) + 1 + strlen($5) + 1);
strcpy(type, $$->name);
strcat(type, "_");
strcat(type, $5);
$$->name = xlateSqlType(type);
};
}
| character
| character opt_charset
{
$$ = makeNode(TypeName);
$$->name = $1;
/* default length, if needed, will be inserted later */
$$->typmod = -1;
if (($2 != NULL) && (strcmp($2, "sql_text") != 0)) {
char *type;
type = palloc(strlen($$->name) + 1 + strlen($2) + 1);
strcpy(type, $$->name);
strcat(type, "_");
strcat(type, $2);
$$->name = xlateSqlType(type);
};
}
;
character: CHARACTER opt_varying opt_charset
{
char *type, *c;
if (($3 == NULL) || (strcmp($3, "sql_text") == 0)) {
if ($2) type = xlateSqlType("varchar");
else type = xlateSqlType("bpchar");
} else {
if ($2) {
c = palloc(strlen("var") + strlen($3) + 1);
strcpy(c, "var");
strcat(c, $3);
type = xlateSqlType(c);
} else {
type = xlateSqlType($3);
}
};
$$ = type;
}
character: CHARACTER opt_varying { $$ = xlateSqlType($2 ? "varchar": "bpchar"); }
| CHAR opt_varying { $$ = xlateSqlType($2 ? "varchar": "bpchar"); }
| VARCHAR { $$ = xlateSqlType("varchar"); }
| NATIONAL CHARACTER opt_varying { $$ = xlateSqlType($3 ? "varchar": "bpchar"); }
@ -4233,6 +4236,22 @@ ConstDatetime: datetime
$$->name = xlateSqlType($1);
$$->typmod = -1;
}
| TIMESTAMP '(' Iconst ')' opt_timezone_x
{
$$ = makeNode(TypeName);
if ($5)
$$->name = xlateSqlType("timestamptz");
else
$$->name = xlateSqlType("timestamp");
/* XXX the timezone field seems to be unused
* - thomas 2001-09-06
*/
$$->timezone = $5;
if (($3 < 0) || ($3 > 13))
elog(ERROR,"TIMESTAMP %s precision %d must be beween 0 and %d",
($5? " WITH TIME ZONE": ""), 0, 13);
$$->typmod = $3;
}
| TIMESTAMP opt_timezone_x
{
$$ = makeNode(TypeName);
@ -4244,7 +4263,19 @@ ConstDatetime: datetime
* - thomas 2001-09-06
*/
$$->timezone = $2;
$$->typmod = -1;
$$->typmod = 0;
}
| TIME '(' Iconst ')' opt_timezone
{
$$ = makeNode(TypeName);
if ($5)
$$->name = xlateSqlType("timetz");
else
$$->name = xlateSqlType("time");
if (($3 < 0) || ($3 > 13))
elog(ERROR,"TIME %s precision %d must be beween 0 and %d",
($5? " WITH TIME ZONE": ""), 0, 13);
$$->typmod = $3;
}
| TIME opt_timezone
{
@ -4253,7 +4284,10 @@ ConstDatetime: datetime
$$->name = xlateSqlType("timetz");
else
$$->name = xlateSqlType("time");
$$->typmod = -1;
/* SQL99 specified a default precision of zero.
* - thomas 2001-09-30
*/
$$->typmod = 0;
}
;
@ -5586,8 +5620,6 @@ ColId: IDENT { $$ = $1; }
| NATIONAL { $$ = "national"; }
| NONE { $$ = "none"; }
| PATH_P { $$ = "path"; }
| TIME { $$ = "time"; }
| TIMESTAMP { $$ = "timestamp"; }
;
/* Parser tokens to be used as identifiers.
@ -5839,6 +5871,8 @@ ColLabel: ColId { $$ = $1; }
| SUBSTRING { $$ = "substring"; }
| TABLE { $$ = "table"; }
| THEN { $$ = "then"; }
| TIME { $$ = "time"; }
| TIMESTAMP { $$ = "timestamp"; }
| TO { $$ = "to"; }
| TRAILING { $$ = "trailing"; }
| TRANSACTION { $$ = "transaction"; }

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.61 2001/09/28 08:09:09 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.62 2001/10/03 05:29:12 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -287,8 +287,7 @@ coerce_type_typmod(ParseState *pstate, Node *node,
* We assume that only typmod values greater than 0 indicate a forced
* conversion is necessary.
*/
if (atttypmod <= 0 ||
atttypmod == exprTypmod(node))
if ((atttypmod <= 0) || (atttypmod == exprTypmod(node)))
return node;
funcname = typeidTypeName(targetTypeId);
@ -376,9 +375,9 @@ select_common_type(List *typeids, const char *context)
Oid ntype = (Oid) lfirsti(l);
/* move on to next one if no new information... */
if (ntype && (ntype != UNKNOWNOID) && (ntype != ptype))
if ((ntype != InvalidOid) && (ntype != UNKNOWNOID) && (ntype != ptype))
{
if (!ptype || ptype == UNKNOWNOID)
if ((ptype == InvalidOid) || ptype == UNKNOWNOID)
{
/* so far, only nulls so take anything... */
ptype = ntype;
@ -456,6 +455,9 @@ coerce_to_common_type(ParseState *pstate, Node *node,
/* TypeCategory()
* Assign a category to the specified OID.
* XXX This should be moved to system catalog lookups
* to allow for better type extensibility.
* - thomas 2001-09-30
*/
CATEGORY
TypeCategory(Oid inType)
@ -538,16 +540,22 @@ TypeCategory(Oid inType)
/* IsPreferredType()
* Check if this type is a preferred type.
* XXX This should be moved to system catalog lookups
* to allow for better type extensibility.
* - thomas 2001-09-30
*/
bool
IsPreferredType(CATEGORY category, Oid type)
{
return type == PreferredType(category, type);
return (type == PreferredType(category, type));
} /* IsPreferredType() */
/* PreferredType()
* Return the preferred type OID for the specified category.
* XXX This should be moved to system catalog lookups
* to allow for better type extensibility.
* - thomas 2001-09-30
*/
static Oid
PreferredType(CATEGORY category, Oid type)
@ -603,210 +611,3 @@ PreferredType(CATEGORY category, Oid type)
}
return result;
} /* PreferredType() */
#ifdef NOT_USED
Oid
PromoteTypeToNext(Oid inType)
{
Oid result;
switch (inType)
{
case (CHAROID):
case (BPCHAROID):
result = VARCHAROID;
break;
case (VARCHAROID):
result = TEXTOID;
break;
case (INT2OID):
case (CASHOID):
result = INT4OID;
break;
case (INT4OID):
case (INT8OID):
case (FLOAT4OID):
result = FLOAT8OID;
break;
case (NUMERICOID):
result = NUMERICOID;
break;
case (DATEOID):
result = TIMESTAMPOID;
break;
case (ABSTIMEOID):
case (TIMESTAMPOID):
result = TIMESTAMPTZOID;
break;
case (TIMEOID):
case (RELTIMEOID):
result = INTERVALOID;
break;
case (BOOLOID):
case (TEXTOID):
case (FLOAT8OID):
case (TIMESTAMPTZOID):
case (INTERVALOID):
default:
result = inType;
break;
}
return result;
} /* PromoteTypeToNext() */
Oid
DemoteType(Oid inType)
{
Oid result;
switch (inType)
{
case (FLOAT4OID):
case (FLOAT8OID):
result = INT4OID;
break;
default:
result = inType;
break;
}
return result;
} /* DemoteType() */
Oid
PromoteLesserType(Oid inType1, Oid inType2, Oid *newType1, Oid *newType2)
{
Oid result;
if (inType1 == inType2)
{
result = PromoteTypeToNext(inType1);
inType1 = result;
*arg2 = result;
return result;
}
kind1 = ClassifyType(inType1);
kind2 = ClassifyType(*arg2);
if (kind1 != kind2)
{
*newType1 = inType1;
*newType2 = inType2;
result = InvalidOid;
}
isBuiltIn1 = IS_BUILTIN_TYPE(inType1);
isBuiltIn2 = IS_BUILTIN_TYPE(*arg2);
if (isBuiltIn1 && isBuiltIn2)
{
switch (*arg1)
{
case (CHAROID):
switch (*arg2)
{
case (BPCHAROID):
case (VARCHAROID):
case (TEXTOID):
case (INT2OID):
case (INT4OID):
case (FLOAT4OID):
case (FLOAT8OID):
case (CASHOID):
case (POINTOID):
case (LSEGOID):
case (LINEOID):
case (BOXOID):
case (PATHOID):
case (CIRCLEOID):
case (POLYGONOID):
case (InvalidOid):
case (UNKNOWNOID):
case (BOOLOID):
default:
*arg1 = InvalidOid;
*arg2 = InvalidOid;
result = InvalidOid;
}
}
}
else if (isBuiltIn1 && !isBuiltIn2)
{
if ((promotedType = PromoteBuiltInType(*arg1)) != *arg1)
{
*arg1 = promotedType;
return promotedType;
}
else if (CanCoerceType(*arg1, *arg2))
{
*arg1 = *arg2;
return *arg2;
}
}
else if (!isBuiltIn1 && isBuiltIn2)
{
if ((promotedType = PromoteBuiltInType(*arg2)) != *arg2)
{
*arg2 = promotedType;
return promotedType;
}
else if (CanCoerceType(*arg2, *arg1))
{
*arg2 = *arg1;
return *arg1;
}
}
if (*arg2 == InvalidOid)
return InvalidOid;
switch (*arg1)
{
case (CHAROID):
switch (*arg2)
{
case (BPCHAROID):
case (VARCHAROID):
case (TEXTOID):
case (INT2OID):
case (INT4OID):
case (FLOAT4OID):
case (FLOAT8OID):
case (CASHOID):
case (POINTOID):
case (LSEGOID):
case (LINEOID):
case (BOXOID):
case (PATHOID):
case (CIRCLEOID):
case (POLYGONOID):
case (InvalidOid):
case (UNKNOWNOID):
case (BOOLOID):
default:
*arg1 = InvalidOid;
*arg2 = InvalidOid;
result = InvalidOid;
}
}
}
#endif

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.58 2001/09/28 08:09:10 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.59 2001/10/03 05:29:24 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -28,6 +28,9 @@
#include "utils/timestamp.h"
static void
AdjustTimeForTypmod(TimeADT *time, int32 typmod);
/*****************************************************************************
* Date ADT
*****************************************************************************/
@ -425,7 +428,11 @@ Datum
time_in(PG_FUNCTION_ARGS)
{
char *str = PG_GETARG_CSTRING(0);
TimeADT time;
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
int32 typmod = PG_GETARG_INT32(2);
TimeADT result;
double fsec;
struct tm tt,
*tm = &tt;
@ -439,9 +446,11 @@ time_in(PG_FUNCTION_ARGS)
|| (DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec, NULL) != 0))
elog(ERROR, "Bad time external representation '%s'", str);
time = ((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec + fsec);
result = ((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec + fsec);
PG_RETURN_TIMEADT(time);
AdjustTimeForTypmod(&result, typmod);
PG_RETURN_TIMEADT(result);
}
Datum
@ -452,13 +461,14 @@ time_out(PG_FUNCTION_ARGS)
struct tm tt,
*tm = &tt;
double fsec;
double trem;
char buf[MAXDATELEN + 1];
tm->tm_hour = (time / (60 * 60));
tm->tm_min = (((int) (time / 60)) % 60);
tm->tm_sec = (((int) time) % 60);
fsec = 0;
trem = time;
TMODULO(trem, tm->tm_hour, 3600e0);
TMODULO(trem, tm->tm_min, 60e0);
TMODULO(trem, tm->tm_sec, 1e0);
fsec = trem;
EncodeTimeOnly(tm, fsec, NULL, DateStyle, buf);
@ -466,6 +476,43 @@ time_out(PG_FUNCTION_ARGS)
PG_RETURN_CSTRING(result);
}
/* time_scale()
* Adjust time type for specified scale factor.
* Used by PostgreSQL type system to stuff columns.
*/
Datum
time_scale(PG_FUNCTION_ARGS)
{
TimeADT time = PG_GETARG_TIMEADT(0);
int32 typmod = PG_GETARG_INT32(1);
TimeADT result;
result = time;
AdjustTimeForTypmod(&result, typmod);
PG_RETURN_TIMEADT(result);
}
static void
AdjustTimeForTypmod(TimeADT *time, int32 typmod)
{
if ((typmod >= 0) && (typmod <= 13))
{
static double TimeScale = 1;
static int32 TimeTypmod = 0;
if (typmod != TimeTypmod)
TimeScale = pow(10, typmod);
*time = (rint(((double) *time)*TimeScale)/TimeScale);
if (*time >= 86400)
*time -= 86400;
}
return;
}
Datum
time_eq(PG_FUNCTION_ARGS)
@ -882,12 +929,15 @@ text_time(PG_FUNCTION_ARGS)
* Time With Time Zone ADT
*****************************************************************************/
Datum
timetz_in(PG_FUNCTION_ARGS)
{
char *str = PG_GETARG_CSTRING(0);
TimeTzADT *time;
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
int32 typmod = PG_GETARG_INT32(2);
TimeTzADT *result;
double fsec;
struct tm tt,
*tm = &tt;
@ -902,12 +952,14 @@ timetz_in(PG_FUNCTION_ARGS)
|| (DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0))
elog(ERROR, "Bad time external representation '%s'", str);
time = (TimeTzADT *) palloc(sizeof(TimeTzADT));
result = (TimeTzADT *) palloc(sizeof(TimeTzADT));
time->time = ((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec + fsec);
time->zone = tz;
result->time = ((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec + fsec);
result->zone = tz;
PG_RETURN_TIMETZADT_P(time);
AdjustTimeForTypmod(&(result->time), typmod);
PG_RETURN_TIMETZADT_P(result);
}
Datum
@ -919,13 +971,15 @@ timetz_out(PG_FUNCTION_ARGS)
*tm = &tt;
double fsec;
int tz;
double trem;
char buf[MAXDATELEN + 1];
tm->tm_hour = (time->time / (60 * 60));
tm->tm_min = (((int) (time->time / 60)) % 60);
tm->tm_sec = (((int) time->time) % 60);
trem = time->time;
TMODULO(trem, tm->tm_hour, 3600e0);
TMODULO(trem, tm->tm_min, 60e0);
TMODULO(trem, tm->tm_sec, 1e0);
fsec = trem;
fsec = 0;
tz = time->zone;
EncodeTimeOnly(tm, fsec, &tz, DateStyle, buf);
@ -934,6 +988,27 @@ timetz_out(PG_FUNCTION_ARGS)
PG_RETURN_CSTRING(result);
}
/* timetz_scale()
* Adjust time type for specified scale factor.
* Used by PostgreSQL type system to stuff columns.
*/
Datum
timetz_scale(PG_FUNCTION_ARGS)
{
TimeTzADT *time = PG_GETARG_TIMETZADT_P(0);
int32 typmod = PG_GETARG_INT32(1);
TimeTzADT *result;
result = (TimeTzADT *) palloc(sizeof(TimeTzADT));
result->time = time->time;
result->zone = time->zone;
AdjustTimeForTypmod(&(result->time), typmod);
PG_RETURN_TIMETZADT_P(result);
}
static int
timetz_cmp_internal(TimeTzADT *time1, TimeTzADT *time2)

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.67 2001/09/28 08:09:10 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.68 2001/10/03 05:29:24 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -26,8 +26,6 @@
#include "utils/datetime.h"
#define ROUND_ALL 1
static int DecodeNumber(int flen, char *field,
int fmask, int *tmask,
struct tm * tm, double *fsec, int *is2digits);
@ -2173,8 +2171,27 @@ EncodeTimeOnly(struct tm * tm, double fsec, int *tzp, int style, char *str)
sec = (tm->tm_sec + fsec);
sprintf(str, "%02d:%02d:", tm->tm_hour, tm->tm_min);
sprintf((str + 6), ((fsec != 0) ? "%05.2f" : "%02.0f"), sec);
sprintf(str, "%02d:%02d", tm->tm_hour, tm->tm_min);
/* If we have fractional seconds, then include a decimal point
* We will do up to 6 fractional digits, and we have rounded any inputs
* to eliminate anything to the right of 6 digits anyway.
* If there are no fractional seconds, then do not bother printing
* a decimal point at all. - thomas 2001-09-29
*/
if (fsec != 0) {
sprintf((str + strlen(str)), ":%013.10f", sec);
/* chop off trailing pairs of zeros... */
while ((strcmp((str + strlen(str) - 2), "00") == 0)
&& (*(str + strlen(str) - 3) != '.'))
{
*(str + strlen(str) - 2) = '\0';
}
}
else
{
sprintf((str + strlen(str)), ":%02.0f", sec);
}
if (tzp != NULL)
{
@ -2221,9 +2238,28 @@ EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, cha
case USE_ISO_DATES:
if (tm->tm_year > 0)
{
sprintf(str, "%04d-%02d-%02d %02d:%02d:",
sprintf(str, "%04d-%02d-%02d %02d:%02d",
tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min);
sprintf((str + strlen(str)), ((fsec != 0) ? "%05.2f" : "%02.0f"), sec);
/* If we have fractional seconds, then include a decimal point
* We will do up to 6 fractional digits, and we have rounded any inputs
* to eliminate anything to the right of 6 digits anyway.
* If there are no fractional seconds, then do not bother printing
* a decimal point at all. - thomas 2001-09-29
*/
if (fsec != 0) {
sprintf((str + strlen(str)), ":%013.10f", sec);
/* chop off trailing pairs of zeros... */
while ((strcmp((str + strlen(str) - 2), "00") == 0)
&& (*(str + strlen(str) - 3) != '.'))
{
*(str + strlen(str) - 2) = '\0';
}
}
else
{
sprintf((str + strlen(str)), ":%02.0f", sec);
}
if ((*tzn != NULL) && (tm->tm_isdst >= 0))
{
@ -2261,8 +2297,28 @@ EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, cha
if (tm->tm_year > 0)
{
sprintf((str + 5), "/%04d %02d:%02d:%05.2f",
tm->tm_year, tm->tm_hour, tm->tm_min, sec);
sprintf((str + 5), "/%04d %02d:%02d",
tm->tm_year, tm->tm_hour, tm->tm_min);
/* If we have fractional seconds, then include a decimal point
* We will do up to 6 fractional digits, and we have rounded any inputs
* to eliminate anything to the right of 6 digits anyway.
* If there are no fractional seconds, then do not bother printing
* a decimal point at all. - thomas 2001-09-29
*/
if (fsec != 0) {
sprintf((str + strlen(str)), ":%013.10f", sec);
/* chop off trailing pairs of zeros... */
while ((strcmp((str + strlen(str) - 2), "00") == 0)
&& (*(str + strlen(str) - 3) != '.'))
{
*(str + strlen(str) - 2) = '\0';
}
}
else
{
sprintf((str + strlen(str)), ":%02.0f", sec);
}
if ((*tzn != NULL) && (tm->tm_isdst >= 0))
sprintf((str + strlen(str)), " %.*s", MAXTZLEN, *tzn);
@ -2277,8 +2333,28 @@ EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, cha
sprintf(str, "%02d.%02d", tm->tm_mday, tm->tm_mon);
if (tm->tm_year > 0)
{
sprintf((str + 5), ".%04d %02d:%02d:%05.2f",
tm->tm_year, tm->tm_hour, tm->tm_min, sec);
sprintf((str + 5), ".%04d %02d:%02d",
tm->tm_year, tm->tm_hour, tm->tm_min);
/* If we have fractional seconds, then include a decimal point
* We will do up to 6 fractional digits, and we have rounded any inputs
* to eliminate anything to the right of 6 digits anyway.
* If there are no fractional seconds, then do not bother printing
* a decimal point at all. - thomas 2001-09-29
*/
if (fsec != 0) {
sprintf((str + strlen(str)), ":%013.10f", sec);
/* chop off trailing pairs of zeros... */
while ((strcmp((str + strlen(str) - 2), "00") == 0)
&& (*(str + strlen(str) - 3) != '.'))
{
*(str + strlen(str) - 2) = '\0';
}
}
else
{
sprintf((str + strlen(str)), ":%02.0f", sec);
}
if ((*tzn != NULL) && (tm->tm_isdst >= 0))
sprintf((str + strlen(str)), " %.*s", MAXTZLEN, *tzn);
@ -2305,18 +2381,30 @@ EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, cha
if (tm->tm_year > 0)
{
sprintf((str + 10), " %02d:%02d", tm->tm_hour, tm->tm_min);
if (fsec != 0)
{
sprintf((str + 16), ":%05.2f %04d", sec, tm->tm_year);
if ((*tzn != NULL) && (tm->tm_isdst >= 0))
sprintf((str + strlen(str)), " %.*s", MAXTZLEN, *tzn);
/* If we have fractional seconds, then include a decimal point
* We will do up to 6 fractional digits, and we have rounded any inputs
* to eliminate anything to the right of 6 digits anyway.
* If there are no fractional seconds, then do not bother printing
* a decimal point at all. - thomas 2001-09-29
*/
if (fsec != 0) {
sprintf((str + strlen(str)), ":%013.10f", sec);
/* chop off trailing pairs of zeros... */
while ((strcmp((str + strlen(str) - 2), "00") == 0)
&& (*(str + strlen(str) - 3) != '.'))
{
*(str + strlen(str) - 2) = '\0';
}
}
else
{
sprintf((str + 16), ":%02.0f %04d", sec, tm->tm_year);
if ((*tzn != NULL) && (tm->tm_isdst >= 0))
sprintf((str + strlen(str)), " %.*s", MAXTZLEN, *tzn);
sprintf((str + strlen(str)), ":%02.0f", sec);
}
sprintf((str + strlen(str)), " %04d", tm->tm_year);
if ((*tzn != NULL) && (tm->tm_isdst >= 0))
sprintf((str + strlen(str)), " %.*s", MAXTZLEN, *tzn);
}
else
{

View File

@ -5,7 +5,7 @@
*
* 1998 Jan Wieck
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.43 2001/08/14 22:21:58 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.44 2001/10/03 05:29:24 thomas Exp $
*
* ----------
*/
@ -193,10 +193,8 @@ Datum
numeric_in(PG_FUNCTION_ARGS)
{
char *str = PG_GETARG_CSTRING(0);
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
int32 typmod = PG_GETARG_INT32(2);
NumericVar value;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.51 2001/09/28 08:09:11 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.52 2001/10/03 05:29:24 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -32,6 +32,8 @@
static double time2t(const int hour, const int min, const double sec);
static int EncodeSpecialTimestamp(Timestamp dt, char *str);
static Timestamp dt2local(Timestamp dt, int timezone);
static void
AdjustTimestampForTypmod(Timestamp *time, int32 typmod);
/*****************************************************************************
@ -45,6 +47,10 @@ Datum
timestamp_in(PG_FUNCTION_ARGS)
{
char *str = PG_GETARG_CSTRING(0);
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
int32 typmod = PG_GETARG_INT32(2);
Timestamp result;
double fsec;
struct tm tt,
@ -89,6 +95,8 @@ timestamp_in(PG_FUNCTION_ARGS)
TIMESTAMP_NOEND(result);
}
AdjustTimestampForTypmod(&result, typmod);
PG_RETURN_TIMESTAMP(result);
}
@ -98,7 +106,7 @@ timestamp_in(PG_FUNCTION_ARGS)
Datum
timestamp_out(PG_FUNCTION_ARGS)
{
Timestamp dt = PG_GETARG_TIMESTAMP(0);
Timestamp timestamp = PG_GETARG_TIMESTAMP(0);
char *result;
struct tm tt,
*tm = &tt;
@ -106,9 +114,9 @@ timestamp_out(PG_FUNCTION_ARGS)
char *tzn = NULL;
char buf[MAXDATELEN + 1];
if (TIMESTAMP_NOT_FINITE(dt))
EncodeSpecialTimestamp(dt, buf);
else if (timestamp2tm(dt, NULL, tm, &fsec, NULL) == 0)
if (TIMESTAMP_NOT_FINITE(timestamp))
EncodeSpecialTimestamp(timestamp, buf);
else if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL) == 0)
EncodeDateTime(tm, fsec, NULL, &tzn, DateStyle, buf);
else
elog(ERROR, "Unable to format timestamp; internal coding error");
@ -117,6 +125,42 @@ timestamp_out(PG_FUNCTION_ARGS)
PG_RETURN_CSTRING(result);
}
/* timestamp_scale()
* Adjust time type for specified scale factor.
* Used by PostgreSQL type system to stuff columns.
*/
Datum
timestamp_scale(PG_FUNCTION_ARGS)
{
Timestamp timestamp = PG_GETARG_TIMESTAMP(0);
int32 typmod = PG_GETARG_INT32(1);
Timestamp result;
result = timestamp;
if (! TIMESTAMP_NOT_FINITE(result))
AdjustTimestampForTypmod(&result, typmod);
PG_RETURN_TIMESTAMP(result);
}
static void
AdjustTimestampForTypmod(Timestamp *time, int32 typmod)
{
if ((typmod >= 0) && (typmod <= 13))
{
static double TimestampScale = 1;
static int32 TimestampTypmod = 0;
if (typmod != TimestampTypmod)
TimestampScale = pow(10, typmod);
*time = (rint(((double) *time)*TimestampScale)/TimestampScale);
}
return;
}
/* timestamptz_in()
* Convert a string to internal form.
@ -125,6 +169,10 @@ Datum
timestamptz_in(PG_FUNCTION_ARGS)
{
char *str = PG_GETARG_CSTRING(0);
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
int32 typmod = PG_GETARG_INT32(2);
TimestampTz result;
double fsec;
struct tm tt,
@ -169,6 +217,8 @@ timestamptz_in(PG_FUNCTION_ARGS)
TIMESTAMP_NOEND(result);
}
AdjustTimestampForTypmod(&result, typmod);
PG_RETURN_TIMESTAMPTZ(result);
}
@ -198,6 +248,25 @@ timestamptz_out(PG_FUNCTION_ARGS)
PG_RETURN_CSTRING(result);
}
/* timestamptz_scale()
* Adjust time type for specified scale factor.
* Used by PostgreSQL type system to stuff columns.
*/
Datum
timestamptz_scale(PG_FUNCTION_ARGS)
{
TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
int32 typmod = PG_GETARG_INT32(1);
TimestampTz result;
result = timestamp;
if (! TIMESTAMP_NOT_FINITE(result))
AdjustTimestampForTypmod(&result, typmod);
PG_RETURN_TIMESTAMPTZ(result);
}
/* interval_in()
* Convert a string to internal form.
@ -2119,16 +2188,13 @@ timestamp_part(PG_FUNCTION_ARGS)
text *units = PG_GETARG_TEXT_P(0);
Timestamp timestamp = PG_GETARG_TIMESTAMP(1);
float8 result;
int tz;
int type,
val;
int i;
char *up,
*lp,
lowunits[MAXDATELEN + 1];
double dummy;
double fsec;
char *tzn;
struct tm tt,
*tm = &tt;
@ -2152,24 +2218,10 @@ timestamp_part(PG_FUNCTION_ARGS)
PG_RETURN_FLOAT8(result);
}
if ((type == UNITS) && (timestamp2tm(timestamp, &tz, tm, &fsec, &tzn) == 0))
if ((type == UNITS) && (timestamp2tm(timestamp, NULL, tm, &fsec, NULL) == 0))
{
switch (val)
{
case DTK_TZ:
result = tz;
break;
case DTK_TZ_MINUTE:
result = tz / 60;
TMODULO(result, dummy, 60e0);
break;
case DTK_TZ_HOUR:
dummy = tz;
TMODULO(dummy, result, 3600e0);
break;
case DTK_MICROSEC:
result = (fsec * 1000000);
break;
@ -2222,11 +2274,13 @@ timestamp_part(PG_FUNCTION_ARGS)
result = (tm->tm_year / 1000);
break;
case DTK_TZ:
case DTK_TZ_MINUTE:
case DTK_TZ_HOUR:
default:
elog(ERROR, "Timestamp units '%s' not supported", lowunits);
result = 0;
}
}
else if (type == RESERV)
{
@ -2237,14 +2291,14 @@ timestamp_part(PG_FUNCTION_ARGS)
break;
case DTK_DOW:
if (timestamp2tm(timestamp, &tz, tm, &fsec, &tzn) != 0)
if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL) != 0)
elog(ERROR, "Unable to encode timestamp");
result = j2day(date2j(tm->tm_year, tm->tm_mon, tm->tm_mday));
break;
case DTK_DOY:
if (timestamp2tm(timestamp, &tz, tm, &fsec, &tzn) != 0)
if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL) != 0)
elog(ERROR, "Unable to encode timestamp");
result = (date2j(tm->tm_year, tm->tm_mon, tm->tm_mday)

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.82 2001/09/11 05:18:59 ishii Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.83 2001/10/03 05:29:24 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -33,7 +33,7 @@
* at CREATE TABLE time.
*
* It's hard to implement these types because we cannot figure out
* the length of the type from the type itself. I change (hopefully all) the
* the length of the type from the type itself. I changed (hopefully all) the
* fmgr calls that invoke input functions of a data type to supply the
* length also. (eg. in INSERTs, we have the tupleDescriptor which contains
* the length of the attributes and hence the exact length of the char() or

View File

@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: catversion.h,v 1.96 2001/09/28 08:09:13 thomas Exp $
* $Id: catversion.h,v 1.97 2001/10/03 05:29:24 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -53,6 +53,6 @@
*/
/* yyyymmddN */
#define CATALOG_VERSION_NO 200109261
#define CATALOG_VERSION_NO 200110011
#endif

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_proc.h,v 1.213 2001/10/02 21:39:36 tgl Exp $
* $Id: pg_proc.h,v 1.214 2001/10/03 05:29:24 thomas Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
@ -1256,7 +1256,7 @@ DESCR("horizontal?");
DATA(insert OID = 999 ( lseg_eq PGUID 12 f t t t 2 f 16 "601 601" 100 0 0 100 lseg_eq - ));
DESCR("equal");
DATA(insert OID = 748 ( date PGUID 12 f t t t 1 f 1082 "25" 100 0 0 100 text_date - ));
DATA(insert OID = 748 ( date PGUID 12 f t f t 1 f 1082 "25" 100 0 0 100 text_date - ));
DESCR("convert text to date");
DATA(insert OID = 749 ( text PGUID 12 f t t t 1 f 25 "1082" 100 0 0 100 date_text - ));
DESCR("convert date to text");
@ -1264,14 +1264,14 @@ DATA(insert OID = 837 ( time PGUID 12 f t t t 1 f 1083 "25" 100 0 0 100 t
DESCR("convert text to time");
DATA(insert OID = 948 ( text PGUID 12 f t t t 1 f 25 "1083" 100 0 0 100 time_text - ));
DESCR("convert time to text");
DATA(insert OID = 938 ( timetz PGUID 12 f t t t 1 f 1266 "25" 100 0 0 100 text_timetz - ));
DATA(insert OID = 938 ( timetz PGUID 12 f t f t 1 f 1266 "25" 100 0 0 100 text_timetz - ));
DESCR("convert text to timetz");
DATA(insert OID = 939 ( text PGUID 12 f t t t 1 f 25 "1266" 100 0 0 100 timetz_text - ));
DESCR("convert timetz to text");
/* OIDS 1000 - 1999 */
DATA(insert OID = 1026 ( timezone PGUID 12 f t t t 2 f 25 "1186 1184" 100 0 0 100 timestamptz_izone - ));
DATA(insert OID = 1026 ( timezone PGUID 12 f t f t 2 f 25 "1186 1184" 100 0 0 100 timestamptz_izone - ));
DESCR("time zone");
DATA(insert OID = 1029 ( nullvalue PGUID 12 f t t f 1 f 16 "0" 100 0 0 100 nullvalue - ));
@ -1430,7 +1430,7 @@ DATA(insert OID = 1169 ( interval_pl PGUID 12 f t t t 2 f 1186 "1186 1186" 1
DESCR("add");
DATA(insert OID = 1170 ( interval_mi PGUID 12 f t t t 2 f 1186 "1186 1186" 100 0 0 100 interval_mi - ));
DESCR("subtract");
DATA(insert OID = 1171 ( date_part PGUID 12 f t t t 2 f 701 "25 1184" 100 0 0 100 timestamptz_part - ));
DATA(insert OID = 1171 ( date_part PGUID 12 f t f t 2 f 701 "25 1184" 100 0 0 100 timestamptz_part - ));
DESCR("extract field from timestamp with time zone");
DATA(insert OID = 1172 ( date_part PGUID 12 f t t t 2 f 701 "25 1186" 100 0 0 100 interval_part - ));
DESCR("extract field from interval");
@ -1458,9 +1458,9 @@ DATA(insert OID = 1189 ( timestamptz_pl_span PGUID 12 f t t t 2 f 1184 "1184 11
DESCR("plus");
DATA(insert OID = 1190 ( timestamptz_mi_span PGUID 12 f t t t 2 f 1184 "1184 1186" 100 0 0 100 timestamp_mi_span - ));
DESCR("minus");
DATA(insert OID = 1191 ( timestamptz PGUID 12 f t t t 1 f 1184 "25" 100 0 0 100 text_timestamptz - ));
DATA(insert OID = 1191 ( timestamptz PGUID 12 f t f t 1 f 1184 "25" 100 0 0 100 text_timestamptz - ));
DESCR("convert text to timestamp with time zone");
DATA(insert OID = 1192 ( text PGUID 12 f t t t 1 f 25 "1184" 100 0 0 100 timestamptz_text - ));
DATA(insert OID = 1192 ( text PGUID 12 f t f t 1 f 25 "1184" 100 0 0 100 timestamptz_text - ));
DESCR("convert timestamp to text");
DATA(insert OID = 1193 ( text PGUID 12 f t t t 1 f 25 "1186" 100 0 0 100 interval_text - ));
DESCR("convert interval to text");
@ -1558,11 +1558,11 @@ DESCR("latest tid of a tuple");
DATA(insert OID = 1294 ( currtid2 PGUID 12 f t f t 2 f 27 "25 27" 100 0 0 100 currtid_byrelname - ));
DESCR("latest tid of a tuple");
DATA(insert OID = 1296 ( timedate_pl PGUID 14 f t t t 2 f 1114 "1083 1082" 100 0 0 100 "select datetime_pl($2, $1)" - ));
DATA(insert OID = 1296 ( timedate_pl PGUID 14 f t t t 2 f 1114 "1083 1082" 100 0 0 100 "select ($2 + $1)" - ));
DESCR("convert time and date to timestamp");
DATA(insert OID = 1297 ( datetimetz_pl PGUID 12 f t t t 2 f 1184 "1082 1266" 100 0 0 100 datetimetz_timestamptz - ));
DESCR("convert date and time with time zone to timestamp with time zone");
DATA(insert OID = 1298 ( timetzdate_pl PGUID 14 f t t t 2 f 1184 "1266 1082" 100 0 0 100 "select datetimetz_pl($2, $1)" - ));
DATA(insert OID = 1298 ( timetzdate_pl PGUID 14 f t t t 2 f 1184 "1266 1082" 100 0 0 100 "select ($2 + $1)" - ));
DESCR("convert time with time zone and date to timestamp");
DATA(insert OID = 1299 ( now PGUID 12 f t f t 0 f 1184 "0" 100 0 0 100 now - ));
DESCR("current transaction time");
@ -1669,7 +1669,7 @@ DESCR("convert date and time with time zone to timestamp with time zone");
DATA(insert OID = 1362 ( time PGUID 14 f t t t 1 f 1083 "1083" 100 0 0 100 "select $1" - ));
DESCR("convert (noop)");
DATA(insert OID = 1364 ( time PGUID 14 f t t t 1 f 1083 "702" 100 0 0 100 "select time(timestamp($1))" - ));
DATA(insert OID = 1364 ( time PGUID 14 f t t t 1 f 1083 "702" 100 0 0 100 "select time(cast($1 as timestamp without time zone))" - ));
DESCR("convert abstime to time");
DATA(insert OID = 1365 ( abstime PGUID 14 f t f t 1 f 702 "702" 100 0 0 100 "select $1" - ));
DESCR("convert (noop)");
@ -1711,7 +1711,7 @@ DATA(insert OID = 1382 ( date_part PGUID 14 f t f t 2 f 701 "25 702" 100 0
DESCR("extract field from abstime");
DATA(insert OID = 1383 ( date_part PGUID 14 f t f t 2 f 701 "25 703" 100 0 0 100 "select date_part($1, interval($2))" - ));
DESCR("extract field from reltime");
DATA(insert OID = 1384 ( date_part PGUID 14 f t t t 2 f 701 "25 1082" 100 0 0 100 "select date_part($1, timestamptz($2))" - ));
DATA(insert OID = 1384 ( date_part PGUID 14 f t t t 2 f 701 "25 1082" 100 0 0 100 "select date_part($1, cast($2 as timestamp without time zone))" - ));
DESCR("extract field from date");
DATA(insert OID = 1385 ( date_part PGUID 14 f t t t 2 f 701 "25 1083" 100 0 0 100 "select date_part($1, interval($2))" - ));
DESCR("extract field from time");
@ -1720,7 +1720,7 @@ DESCR("date difference from today preserving months and years");
DATA(insert OID = 1387 ( timetz PGUID 14 f t t t 1 f 1266 "1266" 100 0 0 100 "select $1" - ));
DESCR("noop conversion");
DATA(insert OID = 1388 ( timetz PGUID 12 f t t t 1 f 1266 "1184" 100 0 0 100 timestamptz_timetz - ));
DATA(insert OID = 1388 ( timetz PGUID 12 f t f t 1 f 1266 "1184" 100 0 0 100 timestamptz_timetz - ));
DESCR("convert timestamp to timetz");
DATA(insert OID = 1389 ( isfinite PGUID 12 f t t t 1 f 16 "1184" 100 0 0 100 timestamp_finite - ));
@ -2471,24 +2471,24 @@ DESCR("(internal)");
/* formatting */
DATA(insert OID = 1770 ( to_char PGUID 12 f t f t 2 f 25 "1184 25" 100 0 0 100 timestamptz_to_char - ));
DESCR("format timestamp to text");
DATA(insert OID = 1772 ( to_char PGUID 12 f t f t 2 f 25 "1700 25" 100 0 0 100 numeric_to_char - ));
DESCR("format timestamp with time zone to text");
DATA(insert OID = 1772 ( to_char PGUID 12 f t t t 2 f 25 "1700 25" 100 0 0 100 numeric_to_char - ));
DESCR("format numeric to text");
DATA(insert OID = 1773 ( to_char PGUID 12 f t f t 2 f 25 "23 25" 100 0 0 100 int4_to_char - ));
DATA(insert OID = 1773 ( to_char PGUID 12 f t t t 2 f 25 "23 25" 100 0 0 100 int4_to_char - ));
DESCR("format int4 to text");
DATA(insert OID = 1774 ( to_char PGUID 12 f t f t 2 f 25 "20 25" 100 0 0 100 int8_to_char - ));
DATA(insert OID = 1774 ( to_char PGUID 12 f t t t 2 f 25 "20 25" 100 0 0 100 int8_to_char - ));
DESCR("format int8 to text");
DATA(insert OID = 1775 ( to_char PGUID 12 f t f t 2 f 25 "700 25" 100 0 0 100 float4_to_char - ));
DATA(insert OID = 1775 ( to_char PGUID 12 f t t t 2 f 25 "700 25" 100 0 0 100 float4_to_char - ));
DESCR("format float4 to text");
DATA(insert OID = 1776 ( to_char PGUID 12 f t f t 2 f 25 "701 25" 100 0 0 100 float8_to_char - ));
DATA(insert OID = 1776 ( to_char PGUID 12 f t t t 2 f 25 "701 25" 100 0 0 100 float8_to_char - ));
DESCR("format float8 to text");
DATA(insert OID = 1777 ( to_number PGUID 12 f t f t 2 f 1700 "25 25" 100 0 0 100 numeric_to_number - ));
DATA(insert OID = 1777 ( to_number PGUID 12 f t t t 2 f 1700 "25 25" 100 0 0 100 numeric_to_number - ));
DESCR("convert text to numeric");
DATA(insert OID = 1778 ( to_timestamp PGUID 12 f t f t 2 f 1184 "25 25" 100 0 0 100 to_timestamp - ));
DESCR("convert text to timestamp");
DATA(insert OID = 1780 ( to_date PGUID 12 f t f t 2 f 1082 "25 25" 100 0 0 100 to_date - ));
DATA(insert OID = 1780 ( to_date PGUID 12 f t t t 2 f 1082 "25 25" 100 0 0 100 to_date - ));
DESCR("convert text to date");
DATA(insert OID = 1768 ( to_char PGUID 12 f t f t 2 f 25 "1186 25" 100 0 0 100 interval_to_char - ));
DATA(insert OID = 1768 ( to_char PGUID 12 f t t t 2 f 25 "1186 25" 100 0 0 100 interval_to_char - ));
DESCR("format interval to text");
DATA(insert OID = 1282 ( quote_ident PGUID 12 f t t t 1 f 25 "25" 100 0 0 100 quote_ident - ));
@ -2741,11 +2741,21 @@ DESCR("not equal");
DATA(insert OID = 1954 ( byteacmp PGUID 12 f t t t 2 f 23 "17 17" 100 0 0 100 byteacmp - ));
DESCR("less-equal-greater");
DATA(insert OID = 1961 ( timestamp PGUID 12 f t f t 2 f 1114 "1114 23" 100 0 0 100 timestamp_scale - ));
DESCR("adjust time precision");
DATA(insert OID = 1965 ( oidlarger PGUID 12 f t t t 2 f 26 "26 26" 100 0 0 100 oidlarger - ));
DESCR("larger of two");
DATA(insert OID = 1966 ( oidsmaller PGUID 12 f t t t 2 f 26 "26 26" 100 0 0 100 oidsmaller - ));
DESCR("smaller of two");
DATA(insert OID = 1967 ( timestamptz PGUID 12 f t t t 2 f 1184 "1184 23" 100 0 0 100 timestamptz_scale - ));
DESCR("adjust time precision");
DATA(insert OID = 1968 ( time PGUID 12 f t t t 2 f 1083 "1083 23" 100 0 0 100 time_scale - ));
DESCR("adjust time precision");
DATA(insert OID = 1969 ( timetz PGUID 12 f t t t 2 f 1266 "1266 23" 100 0 0 100 timetz_scale - ));
DESCR("adjust time with time zone precision");
DATA(insert OID = 2005 ( bytealike PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 bytealike - ));
DESCR("matches LIKE expression");
DATA(insert OID = 2006 ( byteanlike PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteanlike - ));
@ -2823,10 +2833,11 @@ DATA(insert OID = 2047 ( timetz PGUID 12 f t f t 1 f 1266 "1083" 100 0 0 100
DESCR("convert time to timetz");
DATA(insert OID = 2048 ( isfinite PGUID 12 f t t t 1 f 16 "1114" 100 0 0 100 timestamp_finite - ));
DESCR("boolean test");
DATA(insert OID = 2050 ( interval_mi_time PGUID 14 f t t t 2 f 1083 "1186 1083" 100 0 0 100 "select $2 - $1 + (interval \'24 hours\')" - ));
DATA(insert OID = 2049 ( to_char PGUID 12 f t f t 2 f 25 "1114 25" 100 0 0 100 timestamp_to_char - ));
DESCR("format timestamp to text");
DATA(insert OID = 2050 ( interval_mi_time PGUID 14 f t t t 2 f 1083 "1186 1083" 100 0 0 100 "select $2 - $1" - ));
DESCR("minus");
DATA(insert OID = 2051 ( interval_mi_timetz PGUID 14 f t t t 2 f 1266 "1186 1266" 100 0 0 100 "select $2 - $1 + (interval \'24 hours\')" - ));
DATA(insert OID = 2051 ( interval_mi_timetz PGUID 14 f t t t 2 f 1266 "1186 1266" 100 0 0 100 "select $2 - $1" - ));
DESCR("minus");
DATA(insert OID = 2052 ( timestamp_eq PGUID 12 f t t t 2 f 16 "1114 1114" 100 0 0 100 timestamp_eq - ));
DESCR("equal");
@ -2844,9 +2855,9 @@ DATA(insert OID = 2058 ( age PGUID 12 f t t t 2 f 1186 "1114 1114" 100 0 0 1
DESCR("date difference preserving months and years");
DATA(insert OID = 2059 ( age PGUID 14 f t t t 1 f 1186 "1114" 100 0 0 100 "select age(\'today\', $1)" - ));
DESCR("date difference from today preserving months and years");
DATA(insert OID = 2069 ( timezone PGUID 12 f t t t 2 f 1184 "25 1114" 100 0 0 100 timestamp_zone - ));
DATA(insert OID = 2069 ( timezone PGUID 12 f t f t 2 f 1184 "25 1114" 100 0 0 100 timestamp_zone - ));
DESCR("time zone");
DATA(insert OID = 2070 ( timezone PGUID 12 f t t t 2 f 1184 "1186 1114" 100 0 0 100 timestamp_izone - ));
DATA(insert OID = 2070 ( timezone PGUID 12 f t f t 2 f 1184 "1186 1114" 100 0 0 100 timestamp_izone - ));
DESCR("time zone");

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: date.h,v 1.12 2001/09/28 08:09:14 thomas Exp $
* $Id: date.h,v 1.13 2001/10/03 05:29:25 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -77,6 +77,7 @@ extern Datum date_text(PG_FUNCTION_ARGS);
extern Datum time_in(PG_FUNCTION_ARGS);
extern Datum time_out(PG_FUNCTION_ARGS);
extern Datum time_scale(PG_FUNCTION_ARGS);
extern Datum time_eq(PG_FUNCTION_ARGS);
extern Datum time_ne(PG_FUNCTION_ARGS);
extern Datum time_lt(PG_FUNCTION_ARGS);
@ -99,6 +100,7 @@ extern Datum interval_pl_time(PG_FUNCTION_ARGS);
extern Datum timetz_in(PG_FUNCTION_ARGS);
extern Datum timetz_out(PG_FUNCTION_ARGS);
extern Datum timetz_scale(PG_FUNCTION_ARGS);
extern Datum timetz_eq(PG_FUNCTION_ARGS);
extern Datum timetz_ne(PG_FUNCTION_ARGS);
extern Datum timetz_lt(PG_FUNCTION_ARGS);

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: timestamp.h,v 1.18 2001/09/28 08:09:14 thomas Exp $
* $Id: timestamp.h,v 1.19 2001/10/03 05:29:25 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -91,6 +91,7 @@ typedef struct
extern Datum timestamp_in(PG_FUNCTION_ARGS);
extern Datum timestamp_out(PG_FUNCTION_ARGS);
extern Datum timestamp_scale(PG_FUNCTION_ARGS);
extern Datum timestamp_eq(PG_FUNCTION_ARGS);
extern Datum timestamp_ne(PG_FUNCTION_ARGS);
extern Datum timestamp_lt(PG_FUNCTION_ARGS);
@ -130,6 +131,7 @@ extern Datum timestamp_timestamptz(PG_FUNCTION_ARGS);
extern Datum timestamptz_in(PG_FUNCTION_ARGS);
extern Datum timestamptz_out(PG_FUNCTION_ARGS);
extern Datum timestamptz_scale(PG_FUNCTION_ARGS);
extern Datum timestamptz_timestamp(PG_FUNCTION_ARGS);
extern Datum timestamptz_zone(PG_FUNCTION_ARGS);
extern Datum timestamptz_izone(PG_FUNCTION_ARGS);

View File

@ -101,21 +101,24 @@ SELECT (timestamp without time zone 'tomorrow' > 'now') as "True";
t
(1 row)
SELECT timestamp(date '1994-01-01', time '11:00') AS "Jan_01_1994_11am";
-- Convert from date and time to timestamp
-- This test used to be timestamp(date,time) but no longer allowed by grammar
-- to enable support for SQL99 timestamp type syntax.
SELECT date '1994-01-01' + time '11:00' AS "Jan_01_1994_11am";
Jan_01_1994_11am
--------------------------
Sat Jan 01 11:00:00 1994
(1 row)
SELECT timestamp(date '1994-01-01', time '10:00') AS "Jan_01_1994_10am";
SELECT date '1994-01-01' + time '10:00' AS "Jan_01_1994_10am";
Jan_01_1994_10am
--------------------------
Sat Jan 01 10:00:00 1994
(1 row)
SELECT timestamp(date '1994-01-01', time '11:00-5') AS "Jan_01_1994_8am";
SELECT date '1994-01-01' + time '11:00-5' AS "Jan_01_1994_8am";
ERROR: Bad time external representation '11:00-5'
SELECT timestamp(date '1994-01-01', time with time zone '11:00-5') AS "Jan_01_1994_11am";
SELECT "timestamp"(date '1994-01-01', time with time zone '11:00-5') AS "Jan_01_1994_11am";
Jan_01_1994_11am
--------------------------
Sat Jan 01 11:00:00 1994
@ -128,8 +131,8 @@ SELECT '' AS "64", d1 + interval '1 year' AS one_year FROM TIMESTAMP_TBL;
| infinity
| Fri Jan 01 00:00:00 1971
| Tue Feb 10 17:32:01 1998
| Tue Feb 10 17:32:01.00 1998
| Tue Feb 10 17:32:02.00 1998
| Tue Feb 10 17:32:01 1998
| Tue Feb 10 17:32:02 1998
| Tue Feb 10 17:32:01.40 1998
| Tue Feb 10 17:32:01.50 1998
| Tue Feb 10 17:32:01.60 1998
@ -197,8 +200,8 @@ SELECT '' AS "64", d1 - interval '1 year' AS one_year FROM TIMESTAMP_TBL;
| infinity
| Wed Jan 01 00:00:00 1969
| Sat Feb 10 17:32:01 1996
| Sat Feb 10 17:32:01.00 1996
| Sat Feb 10 17:32:02.00 1996
| Sat Feb 10 17:32:01 1996
| Sat Feb 10 17:32:02 1996
| Sat Feb 10 17:32:01.40 1996
| Sat Feb 10 17:32:01.50 1996
| Sat Feb 10 17:32:01.60 1996
@ -344,8 +347,8 @@ SELECT '' AS "64", d1 + interval '1 year' AS one_year FROM TIMESTAMPTZ_TBL;
| infinity
| Thu Dec 31 16:00:00 1970 PST
| Tue Feb 10 17:32:01 1998 PST
| Tue Feb 10 17:32:01.00 1998 PST
| Tue Feb 10 17:32:02.00 1998 PST
| Tue Feb 10 17:32:01 1998 PST
| Tue Feb 10 17:32:02 1998 PST
| Tue Feb 10 17:32:01.40 1998 PST
| Tue Feb 10 17:32:01.50 1998 PST
| Tue Feb 10 17:32:01.60 1998 PST
@ -413,8 +416,8 @@ SELECT '' AS "64", d1 - interval '1 year' AS one_year FROM TIMESTAMPTZ_TBL;
| infinity
| Tue Dec 31 16:00:00 1968 PST
| Sat Feb 10 17:32:01 1996 PST
| Sat Feb 10 17:32:01.00 1996 PST
| Sat Feb 10 17:32:02.00 1996 PST
| Sat Feb 10 17:32:01 1996 PST
| Sat Feb 10 17:32:02 1996 PST
| Sat Feb 10 17:32:01.40 1996 PST
| Sat Feb 10 17:32:01.50 1996 PST
| Sat Feb 10 17:32:01.60 1996 PST
@ -568,10 +571,10 @@ SELECT t.d1 + i.f1 AS "102" FROM TIMESTAMP_TBL t, INTERVAL_TBL i
-----------------------------
Mon Feb 10 17:33:01 1997
Mon Feb 10 22:32:01 1997
Mon Feb 10 17:33:01.00 1997
Mon Feb 10 22:32:01.00 1997
Mon Feb 10 17:33:02.00 1997
Mon Feb 10 22:32:02.00 1997
Mon Feb 10 17:33:01 1997
Mon Feb 10 22:32:01 1997
Mon Feb 10 17:33:02 1997
Mon Feb 10 22:32:02 1997
Mon Feb 10 17:33:01.40 1997
Mon Feb 10 22:32:01.40 1997
Mon Feb 10 17:33:01.50 1997
@ -677,10 +680,10 @@ SELECT t.d1 - i.f1 AS "102" FROM TIMESTAMP_TBL t, INTERVAL_TBL i
-----------------------------
Mon Feb 10 17:31:01 1997
Mon Feb 10 12:32:01 1997
Mon Feb 10 17:31:01.00 1997
Mon Feb 10 12:32:01.00 1997
Mon Feb 10 17:31:02.00 1997
Mon Feb 10 12:32:02.00 1997
Mon Feb 10 17:31:01 1997
Mon Feb 10 12:32:01 1997
Mon Feb 10 17:31:02 1997
Mon Feb 10 12:32:02 1997
Mon Feb 10 17:31:01.40 1997
Mon Feb 10 12:32:01.40 1997
Mon Feb 10 17:31:01.50 1997
@ -780,8 +783,8 @@ SELECT t.d1 - i.f1 AS "102" FROM TIMESTAMP_TBL t, INTERVAL_TBL i
(102 rows)
SELECT t.f1 + i.f1 AS "80" FROM TIME_TBL t, INTERVAL_TBL i;
80
----------
80
-------------
00:01:00
05:00:00
00:00:00
@ -852,21 +855,21 @@ SELECT t.f1 + i.f1 AS "80" FROM TIME_TBL t, INTERVAL_TBL i;
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
00:00:59.99
04:59:59.99
23:59:59.99
23:59:59.99
23:59:59.99
23:59:45.99
02:03:03.99
23:59:59.99
23:59:59.99
11:59:59.99
(80 rows)
SELECT t.f1 - i.f1 AS "80" FROM TIME_TBL t, INTERVAL_TBL i;
80
----------
80
-------------
23:59:00
19:00:00
00:00:00
@ -937,21 +940,21 @@ SELECT t.f1 - i.f1 AS "80" FROM TIME_TBL t, INTERVAL_TBL i;
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
23:58:59.99
18:59:59.99
23:59:59.99
23:59:59.99
23:59:59.99
00:00:13.99
21:56:55.99
23:59:59.99
23:59:59.99
11:59:59.99
(80 rows)
SELECT t.f1 + i.f1 AS "100" FROM TIMETZ_TBL t, INTERVAL_TBL i;
100
-------------
100
----------------
00:02:00-07
05:01:00-07
00:01:00-07
@ -1042,21 +1045,21 @@ SELECT t.f1 + i.f1 AS "100" FROM TIMETZ_TBL t, INTERVAL_TBL i;
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
00:00:59.99-07
04:59:59.99-07
23:59:59.99-07
23:59:59.99-07
23:59:59.99-07
23:59:45.99-07
02:03:03.99-07
23:59:59.99-07
23:59:59.99-07
11:59:59.99-07
(100 rows)
SELECT t.f1 - i.f1 AS "100" FROM TIMETZ_TBL t, INTERVAL_TBL i;
100
-------------
100
----------------
00:00:00-07
19:01:00-07
00:01:00-07
@ -1147,16 +1150,16 @@ SELECT t.f1 - i.f1 AS "100" FROM TIMETZ_TBL t, INTERVAL_TBL i;
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
23:58:59.99-07
18:59:59.99-07
23:59:59.99-07
23:59:59.99-07
23:59:59.99-07
00:00:13.99-07
21:56:55.99-07
23:59:59.99-07
23:59:59.99-07
11:59:59.99-07
(100 rows)
-- SQL9x OVERLAPS operator
@ -1284,9 +1287,9 @@ INSERT INTO TEMP_TIMESTAMP (f1)
SELECT d1 FROM TIMESTAMP_TBL
WHERE d1 BETWEEN '13-jun-1957' AND '1-jan-1997'
OR d1 BETWEEN '1-jan-1999' AND '1-jan-2010';
SELECT '' AS "16", f1 AS timestamp
SELECT '' AS "16", f1 AS "timestamp"
FROM TEMP_TIMESTAMP
ORDER BY timestamp;
ORDER BY "timestamp";
16 | timestamp
----+------------------------------
| Thu Jan 01 00:00:00 1970 PST
@ -1307,9 +1310,9 @@ SELECT '' AS "16", f1 AS timestamp
| Sat Sep 22 18:19:20 2001 PDT
(16 rows)
SELECT '' AS "160", d.f1 AS timestamp, t.f1 AS interval, d.f1 + t.f1 AS plus
SELECT '' AS "160", d.f1 AS "timestamp", t.f1 AS interval, d.f1 + t.f1 AS plus
FROM TEMP_TIMESTAMP d, INTERVAL_TBL t
ORDER BY plus, timestamp, interval;
ORDER BY plus, "timestamp", interval;
160 | timestamp | interval | plus
-----+------------------------------+-------------------------------+------------------------------
| Thu Jan 01 00:00:00 1970 PST | @ 14 secs ago | Wed Dec 31 23:59:46 1969 PST
@ -1474,10 +1477,10 @@ SELECT '' AS "160", d.f1 AS timestamp, t.f1 AS interval, d.f1 + t.f1 AS plus
| Sat Sep 22 18:19:20 2001 PDT | @ 34 years | Sat Sep 22 18:19:20 2035 PDT
(160 rows)
SELECT '' AS "160", d.f1 AS timestamp, t.f1 AS interval, d.f1 - t.f1 AS minus
SELECT '' AS "160", d.f1 AS "timestamp", t.f1 AS interval, d.f1 - t.f1 AS minus
FROM TEMP_TIMESTAMP d, INTERVAL_TBL t
WHERE isfinite(d.f1)
ORDER BY minus, timestamp, interval;
ORDER BY minus, "timestamp", interval;
160 | timestamp | interval | minus
-----+------------------------------+-------------------------------+------------------------------
| Thu Jan 01 00:00:00 1970 PST | @ 34 years | Wed Jan 01 00:00:00 1936 PST
@ -1642,7 +1645,7 @@ SELECT '' AS "160", d.f1 AS timestamp, t.f1 AS interval, d.f1 - t.f1 AS minus
| Sat Sep 22 18:19:20 2001 PDT | @ 14 secs ago | Sat Sep 22 18:19:34 2001 PDT
(160 rows)
SELECT '' AS "16", d.f1 AS timestamp, timestamp '1980-01-06 00:00 GMT' AS gpstime_zero,
SELECT '' AS "16", d.f1 AS "timestamp", timestamp '1980-01-06 00:00 GMT' AS gpstime_zero,
d.f1 - timestamp '1980-01-06 00:00 GMT' AS difference
FROM TEMP_TIMESTAMP d
ORDER BY difference;
@ -1929,72 +1932,6 @@ SELECT '' AS "226", d1.f1 AS timestamp1, d2.f1 AS timestamp2, d1.f1 - d2.f1 AS d
| Sat Sep 22 18:19:20 2001 PDT | Sat Sep 22 18:19:20 2001 PDT | @ 0
(256 rows)
SELECT '' as "55", d1 as timestamp,
date_part('year', d1) AS year, date_part('month', d1) AS month,
date_part('day',d1) AS day, date_part('hour', d1) AS hour,
date_part('minute', d1) AS minute, date_part('second', d1) AS second
FROM TIMESTAMP_TBL
WHERE isfinite(d1) and d1 >= '1-jan-1900 GMT'
ORDER BY timestamp;
55 | timestamp | year | month | day | hour | minute | second
----+-----------------------------+------+-------+-----+------+--------+----------
| Thu Jan 01 00:00:00 1970 | 1969 | 12 | 31 | 16 | 0 | 0
| Wed Feb 28 17:32:01 1996 | 1996 | 2 | 28 | 9 | 32 | 1
| Thu Feb 29 17:32:01 1996 | 1996 | 2 | 29 | 9 | 32 | 1
| Fri Mar 01 17:32:01 1996 | 1996 | 3 | 1 | 9 | 32 | 1
| Mon Dec 30 17:32:01 1996 | 1996 | 12 | 30 | 9 | 32 | 1
| Tue Dec 31 17:32:01 1996 | 1996 | 12 | 31 | 9 | 32 | 1
| Wed Jan 01 17:32:01 1997 | 1997 | 1 | 1 | 9 | 32 | 1
| Thu Jan 02 00:00:00 1997 | 1997 | 1 | 1 | 16 | 0 | 0
| Thu Jan 02 03:04:05 1997 | 1997 | 1 | 1 | 19 | 4 | 5
| Mon Feb 10 17:32:00 1997 | 1997 | 2 | 10 | 9 | 32 | 0
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 9 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 9 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 9 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 9 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 9 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 9 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 9 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 9 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 9 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 9 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 9 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 9 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 9 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 9 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 9 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 9 | 32 | 1
| Mon Feb 10 17:32:01.00 1997 | 1997 | 2 | 10 | 9 | 32 | 1.000001
| Mon Feb 10 17:32:01.40 1997 | 1997 | 2 | 10 | 9 | 32 | 1.4
| Mon Feb 10 17:32:01.50 1997 | 1997 | 2 | 10 | 9 | 32 | 1.5
| Mon Feb 10 17:32:01.60 1997 | 1997 | 2 | 10 | 9 | 32 | 1.6
| Mon Feb 10 17:32:02.00 1997 | 1997 | 2 | 10 | 9 | 32 | 1.999999
| Tue Feb 11 17:32:01 1997 | 1997 | 2 | 11 | 9 | 32 | 1
| Wed Feb 12 17:32:01 1997 | 1997 | 2 | 12 | 9 | 32 | 1
| Thu Feb 13 17:32:01 1997 | 1997 | 2 | 13 | 9 | 32 | 1
| Fri Feb 14 17:32:01 1997 | 1997 | 2 | 14 | 9 | 32 | 1
| Sat Feb 15 17:32:01 1997 | 1997 | 2 | 15 | 9 | 32 | 1
| Sun Feb 16 17:32:01 1997 | 1997 | 2 | 16 | 9 | 32 | 1
| Sun Feb 16 17:32:01 1997 | 1997 | 2 | 16 | 9 | 32 | 1
| Fri Feb 28 17:32:01 1997 | 1997 | 2 | 28 | 9 | 32 | 1
| Sat Mar 01 17:32:01 1997 | 1997 | 3 | 1 | 9 | 32 | 1
| Tue Jun 10 17:32:01 1997 | 1997 | 6 | 10 | 10 | 32 | 1
| Tue Jun 10 18:32:01 1997 | 1997 | 6 | 10 | 11 | 32 | 1
| Tue Dec 30 17:32:01 1997 | 1997 | 12 | 30 | 9 | 32 | 1
| Wed Dec 31 17:32:01 1997 | 1997 | 12 | 31 | 9 | 32 | 1
| Fri Dec 31 17:32:01 1999 | 1999 | 12 | 31 | 9 | 32 | 1
| Sat Jan 01 17:32:01 2000 | 2000 | 1 | 1 | 9 | 32 | 1
| Wed Mar 15 02:14:05 2000 | 2000 | 3 | 14 | 18 | 14 | 5
| Wed Mar 15 03:14:04 2000 | 2000 | 3 | 14 | 19 | 14 | 4
| Wed Mar 15 08:14:01 2000 | 2000 | 3 | 15 | 0 | 14 | 1
| Wed Mar 15 12:14:03 2000 | 2000 | 3 | 15 | 4 | 14 | 3
| Wed Mar 15 13:14:02 2000 | 2000 | 3 | 15 | 5 | 14 | 2
| Sun Dec 31 17:32:01 2000 | 2000 | 12 | 31 | 9 | 32 | 1
| Mon Jan 01 17:32:01 2001 | 2001 | 1 | 1 | 9 | 32 | 1
| Sat Sep 22 18:19:20 2001 | 2001 | 9 | 22 | 11 | 19 | 20
| Sat Feb 16 17:32:01 2097 | 2097 | 2 | 16 | 17 | 32 | 1
(55 rows)
--
-- abstime, reltime arithmetic
--
@ -2061,10 +1998,10 @@ SELECT '' AS three, ABSTIME_TBL.*
--
-- Conversions
--
SELECT '' AS "16", f1 AS timestamp, date(f1) AS date
SELECT '' AS "16", f1 AS "timestamp", date(f1) AS date
FROM TEMP_TIMESTAMP
WHERE f1 <> timestamp 'current'
ORDER BY date, timestamp;
ORDER BY date, "timestamp";
16 | timestamp | date
----+------------------------------+------------
| Thu Jan 01 00:00:00 1970 PST | 01-01-1970
@ -2085,7 +2022,7 @@ SELECT '' AS "16", f1 AS timestamp, date(f1) AS date
| Sat Sep 22 18:19:20 2001 PDT | 09-22-2001
(16 rows)
SELECT '' AS "16", f1 AS timestamp, abstime(f1) AS abstime
SELECT '' AS "16", f1 AS "timestamp", abstime(f1) AS abstime
FROM TEMP_TIMESTAMP
ORDER BY abstime;
16 | timestamp | abstime
@ -2120,7 +2057,7 @@ SELECT '' AS four, f1 AS abstime, date(f1) AS date
| Mon May 01 00:30:30 1995 PDT | 05-01-1995
(4 rows)
SELECT '' AS two, d1 AS timestamp, abstime(d1) AS abstime
SELECT '' AS two, d1 AS "timestamp", abstime(d1) AS abstime
FROM TIMESTAMP_TBL WHERE NOT isfinite(d1);
two | timestamp | abstime
-----+-----------+-----------
@ -2128,9 +2065,9 @@ SELECT '' AS two, d1 AS timestamp, abstime(d1) AS abstime
| infinity | infinity
(2 rows)
SELECT '' AS three, f1 as abstime, timestamp(f1) AS timestamp
SELECT '' AS three, f1 as abstime, cast(f1 as timestamp) AS "timestamp"
FROM ABSTIME_TBL WHERE NOT isfinite(f1);
ERROR: Unable to convert abstime 'invalid' to timestamp
ERROR: Unable to convert abstime 'invalid' to timestamptz
SELECT '' AS ten, f1 AS interval, reltime(f1) AS reltime
FROM INTERVAL_TBL;
ten | interval | reltime
@ -2173,8 +2110,8 @@ SELECT '' AS "64", d1 AS us_postgres FROM TIMESTAMP_TBL;
| infinity
| Thu Jan 01 00:00:00 1970
| Mon Feb 10 17:32:01 1997
| Mon Feb 10 17:32:01.00 1997
| Mon Feb 10 17:32:02.00 1997
| Mon Feb 10 17:32:01 1997
| Mon Feb 10 17:32:02 1997
| Mon Feb 10 17:32:01.40 1997
| Mon Feb 10 17:32:01.50 1997
| Mon Feb 10 17:32:01.60 1997
@ -2255,8 +2192,8 @@ SELECT '' AS "64", d1 AS us_iso FROM TIMESTAMP_TBL;
| infinity
| 1970-01-01 00:00:00
| 1997-02-10 17:32:01
| 1997-02-10 17:32:01.00
| 1997-02-10 17:32:02.00
| 1997-02-10 17:32:01
| 1997-02-10 17:32:02
| 1997-02-10 17:32:01.40
| 1997-02-10 17:32:01.50
| 1997-02-10 17:32:01.60
@ -2337,79 +2274,79 @@ SELECT '' AS "64", d1 AS us_sql FROM TIMESTAMP_TBL;
----+------------------------
| -infinity
| infinity
| 01/01/1970 00:00:00.00
| 02/10/1997 17:32:01.00
| 02/10/1997 17:32:01.00
| 02/10/1997 17:32:02.00
| 01/01/1970 00:00:00
| 02/10/1997 17:32:01
| 02/10/1997 17:32:01
| 02/10/1997 17:32:02
| 02/10/1997 17:32:01.40
| 02/10/1997 17:32:01.50
| 02/10/1997 17:32:01.60
| 01/02/1997 00:00:00.00
| 01/02/1997 03:04:05.00
| 02/10/1997 17:32:01.00
| 02/10/1997 17:32:01.00
| 02/10/1997 17:32:01.00
| 02/10/1997 17:32:01.00
| 06/10/1997 17:32:01.00
| 09/22/2001 18:19:20.00
| 03/15/2000 08:14:01.00
| 03/15/2000 13:14:02.00
| 03/15/2000 12:14:03.00
| 03/15/2000 03:14:04.00
| 03/15/2000 02:14:05.00
| 02/10/1997 17:32:01.00
| 02/10/1997 17:32:01.00
| 02/10/1997 17:32:00.00
| 02/10/1997 17:32:01.00
| 02/10/1997 17:32:01.00
| 02/10/1997 17:32:01.00
| 02/10/1997 17:32:01.00
| 02/10/1997 17:32:01.00
| 02/10/1997 17:32:01.00
| 02/10/1997 17:32:01.00
| 02/10/1997 17:32:01.00
| 06/10/1997 18:32:01.00
| 02/10/1997 17:32:01.00
| 02/11/1997 17:32:01.00
| 02/12/1997 17:32:01.00
| 02/13/1997 17:32:01.00
| 02/14/1997 17:32:01.00
| 02/15/1997 17:32:01.00
| 02/16/1997 17:32:01.00
| 01/02/1997 00:00:00
| 01/02/1997 03:04:05
| 02/10/1997 17:32:01
| 02/10/1997 17:32:01
| 02/10/1997 17:32:01
| 02/10/1997 17:32:01
| 06/10/1997 17:32:01
| 09/22/2001 18:19:20
| 03/15/2000 08:14:01
| 03/15/2000 13:14:02
| 03/15/2000 12:14:03
| 03/15/2000 03:14:04
| 03/15/2000 02:14:05
| 02/10/1997 17:32:01
| 02/10/1997 17:32:01
| 02/10/1997 17:32:00
| 02/10/1997 17:32:01
| 02/10/1997 17:32:01
| 02/10/1997 17:32:01
| 02/10/1997 17:32:01
| 02/10/1997 17:32:01
| 02/10/1997 17:32:01
| 02/10/1997 17:32:01
| 02/10/1997 17:32:01
| 06/10/1997 18:32:01
| 02/10/1997 17:32:01
| 02/11/1997 17:32:01
| 02/12/1997 17:32:01
| 02/13/1997 17:32:01
| 02/14/1997 17:32:01
| 02/15/1997 17:32:01
| 02/16/1997 17:32:01
| 02/16/0097 17:32 BC
| 02/16/0097 17:32:01.00
| 02/16/0597 17:32:01.00
| 02/16/1097 17:32:01.00
| 02/16/1697 17:32:01.00
| 02/16/1797 17:32:01.00
| 02/16/1897 17:32:01.00
| 02/16/1997 17:32:01.00
| 02/16/2097 17:32:01.00
| 02/28/1996 17:32:01.00
| 02/29/1996 17:32:01.00
| 03/01/1996 17:32:01.00
| 12/30/1996 17:32:01.00
| 12/31/1996 17:32:01.00
| 01/01/1997 17:32:01.00
| 02/28/1997 17:32:01.00
| 03/01/1997 17:32:01.00
| 12/30/1997 17:32:01.00
| 12/31/1997 17:32:01.00
| 12/31/1999 17:32:01.00
| 01/01/2000 17:32:01.00
| 12/31/2000 17:32:01.00
| 01/01/2001 17:32:01.00
| 02/16/0097 17:32:01
| 02/16/0597 17:32:01
| 02/16/1097 17:32:01
| 02/16/1697 17:32:01
| 02/16/1797 17:32:01
| 02/16/1897 17:32:01
| 02/16/1997 17:32:01
| 02/16/2097 17:32:01
| 02/28/1996 17:32:01
| 02/29/1996 17:32:01
| 03/01/1996 17:32:01
| 12/30/1996 17:32:01
| 12/31/1996 17:32:01
| 01/01/1997 17:32:01
| 02/28/1997 17:32:01
| 03/01/1997 17:32:01
| 12/30/1997 17:32:01
| 12/31/1997 17:32:01
| 12/31/1999 17:32:01
| 01/01/2000 17:32:01
| 12/31/2000 17:32:01
| 01/01/2001 17:32:01
(64 rows)
SELECT '' AS seven, f1 AS us_sql FROM ABSTIME_TBL;
seven | us_sql
-------+----------------------------
| 01/14/1973 03:14:21.00 PST
| 05/01/1995 00:30:30.00 PDT
| 12/31/1969 16:00:00.00 PST
seven | us_sql
-------+-------------------------
| 01/14/1973 03:14:21 PST
| 05/01/1995 00:30:30 PDT
| 12/31/1969 16:00:00 PST
| infinity
| -infinity
| 05/10/1947 23:59:12.00 PST
| 05/10/1947 23:59:12 PST
| invalid
(7 rows)
@ -2430,8 +2367,8 @@ SELECT '' AS "65", d1 AS european_postgres FROM TIMESTAMP_TBL;
| infinity
| Thu 01 Jan 00:00:00 1970
| Mon 10 Feb 17:32:01 1997
| Mon 10 Feb 17:32:01.00 1997
| Mon 10 Feb 17:32:02.00 1997
| Mon 10 Feb 17:32:01 1997
| Mon 10 Feb 17:32:02 1997
| Mon 10 Feb 17:32:01.40 1997
| Mon 10 Feb 17:32:01.50 1997
| Mon 10 Feb 17:32:01.60 1997
@ -2515,8 +2452,8 @@ SELECT '' AS "65", d1 AS european_iso FROM TIMESTAMP_TBL;
| infinity
| 1970-01-01 00:00:00
| 1997-02-10 17:32:01
| 1997-02-10 17:32:01.00
| 1997-02-10 17:32:02.00
| 1997-02-10 17:32:01
| 1997-02-10 17:32:02
| 1997-02-10 17:32:01.40
| 1997-02-10 17:32:01.50
| 1997-02-10 17:32:01.60
@ -2598,80 +2535,80 @@ SELECT '' AS "65", d1 AS european_sql FROM TIMESTAMP_TBL;
----+------------------------
| -infinity
| infinity
| 01/01/1970 00:00:00.00
| 10/02/1997 17:32:01.00
| 10/02/1997 17:32:01.00
| 10/02/1997 17:32:02.00
| 01/01/1970 00:00:00
| 10/02/1997 17:32:01
| 10/02/1997 17:32:01
| 10/02/1997 17:32:02
| 10/02/1997 17:32:01.40
| 10/02/1997 17:32:01.50
| 10/02/1997 17:32:01.60
| 02/01/1997 00:00:00.00
| 02/01/1997 03:04:05.00
| 10/02/1997 17:32:01.00
| 10/02/1997 17:32:01.00
| 10/02/1997 17:32:01.00
| 10/02/1997 17:32:01.00
| 10/06/1997 17:32:01.00
| 22/09/2001 18:19:20.00
| 15/03/2000 08:14:01.00
| 15/03/2000 13:14:02.00
| 15/03/2000 12:14:03.00
| 15/03/2000 03:14:04.00
| 15/03/2000 02:14:05.00
| 10/02/1997 17:32:01.00
| 10/02/1997 17:32:01.00
| 10/02/1997 17:32:00.00
| 10/02/1997 17:32:01.00
| 10/02/1997 17:32:01.00
| 10/02/1997 17:32:01.00
| 10/02/1997 17:32:01.00
| 10/02/1997 17:32:01.00
| 10/02/1997 17:32:01.00
| 10/02/1997 17:32:01.00
| 10/02/1997 17:32:01.00
| 10/06/1997 18:32:01.00
| 10/02/1997 17:32:01.00
| 11/02/1997 17:32:01.00
| 12/02/1997 17:32:01.00
| 13/02/1997 17:32:01.00
| 14/02/1997 17:32:01.00
| 15/02/1997 17:32:01.00
| 16/02/1997 17:32:01.00
| 02/01/1997 00:00:00
| 02/01/1997 03:04:05
| 10/02/1997 17:32:01
| 10/02/1997 17:32:01
| 10/02/1997 17:32:01
| 10/02/1997 17:32:01
| 10/06/1997 17:32:01
| 22/09/2001 18:19:20
| 15/03/2000 08:14:01
| 15/03/2000 13:14:02
| 15/03/2000 12:14:03
| 15/03/2000 03:14:04
| 15/03/2000 02:14:05
| 10/02/1997 17:32:01
| 10/02/1997 17:32:01
| 10/02/1997 17:32:00
| 10/02/1997 17:32:01
| 10/02/1997 17:32:01
| 10/02/1997 17:32:01
| 10/02/1997 17:32:01
| 10/02/1997 17:32:01
| 10/02/1997 17:32:01
| 10/02/1997 17:32:01
| 10/02/1997 17:32:01
| 10/06/1997 18:32:01
| 10/02/1997 17:32:01
| 11/02/1997 17:32:01
| 12/02/1997 17:32:01
| 13/02/1997 17:32:01
| 14/02/1997 17:32:01
| 15/02/1997 17:32:01
| 16/02/1997 17:32:01
| 16/02/0097 17:32 BC
| 16/02/0097 17:32:01.00
| 16/02/0597 17:32:01.00
| 16/02/1097 17:32:01.00
| 16/02/1697 17:32:01.00
| 16/02/1797 17:32:01.00
| 16/02/1897 17:32:01.00
| 16/02/1997 17:32:01.00
| 16/02/2097 17:32:01.00
| 28/02/1996 17:32:01.00
| 29/02/1996 17:32:01.00
| 01/03/1996 17:32:01.00
| 30/12/1996 17:32:01.00
| 31/12/1996 17:32:01.00
| 01/01/1997 17:32:01.00
| 28/02/1997 17:32:01.00
| 01/03/1997 17:32:01.00
| 30/12/1997 17:32:01.00
| 31/12/1997 17:32:01.00
| 31/12/1999 17:32:01.00
| 01/01/2000 17:32:01.00
| 31/12/2000 17:32:01.00
| 01/01/2001 17:32:01.00
| 13/06/1957 00:00:00.00
| 16/02/0097 17:32:01
| 16/02/0597 17:32:01
| 16/02/1097 17:32:01
| 16/02/1697 17:32:01
| 16/02/1797 17:32:01
| 16/02/1897 17:32:01
| 16/02/1997 17:32:01
| 16/02/2097 17:32:01
| 28/02/1996 17:32:01
| 29/02/1996 17:32:01
| 01/03/1996 17:32:01
| 30/12/1996 17:32:01
| 31/12/1996 17:32:01
| 01/01/1997 17:32:01
| 28/02/1997 17:32:01
| 01/03/1997 17:32:01
| 30/12/1997 17:32:01
| 31/12/1997 17:32:01
| 31/12/1999 17:32:01
| 01/01/2000 17:32:01
| 31/12/2000 17:32:01
| 01/01/2001 17:32:01
| 13/06/1957 00:00:00
(65 rows)
SELECT '' AS seven, f1 AS european_sql FROM ABSTIME_TBL;
seven | european_sql
-------+----------------------------
| 14/01/1973 03:14:21.00 PST
| 01/05/1995 00:30:30.00 PDT
| 31/12/1969 16:00:00.00 PST
seven | european_sql
-------+-------------------------
| 14/01/1973 03:14:21 PST
| 01/05/1995 00:30:30 PDT
| 31/12/1969 16:00:00 PST
| infinity
| -infinity
| 10/05/1947 23:59:12.00 PST
| 10/05/1947 23:59:12 PST
| invalid
(7 rows)

View File

@ -1,7 +1,7 @@
--
-- TIME
--
CREATE TABLE TIME_TBL (f1 time);
CREATE TABLE TIME_TBL (f1 time(2));
INSERT INTO TIME_TBL VALUES ('00:00');
INSERT INTO TIME_TBL VALUES ('01:00');
INSERT INTO TIME_TBL VALUES ('02:03');
@ -15,8 +15,8 @@ INSERT INTO TIME_TBL VALUES ('12:01');
INSERT INTO TIME_TBL VALUES ('23:59');
INSERT INTO TIME_TBL VALUES ('11:59:59.99 PM');
SELECT f1 AS "Time" FROM TIME_TBL;
Time
----------
Time
-------------
00:00:00
01:00:00
02:03:00
@ -24,7 +24,7 @@ SELECT f1 AS "Time" FROM TIME_TBL;
12:00:00
12:01:00
23:59:00
23:59:59
23:59:59.99
(8 rows)
SELECT f1 AS "Three" FROM TIME_TBL WHERE f1 < '05:06:07';
@ -36,13 +36,13 @@ SELECT f1 AS "Three" FROM TIME_TBL WHERE f1 < '05:06:07';
(3 rows)
SELECT f1 AS "Five" FROM TIME_TBL WHERE f1 > '05:06:07';
Five
----------
Five
-------------
11:59:00
12:00:00
12:01:00
23:59:00
23:59:59
23:59:59.99
(5 rows)
SELECT f1 AS "None" FROM TIME_TBL WHERE f1 < '00:00';
@ -51,8 +51,8 @@ SELECT f1 AS "None" FROM TIME_TBL WHERE f1 < '00:00';
(0 rows)
SELECT f1 AS "Eight" FROM TIME_TBL WHERE f1 >= '00:00';
Eight
----------
Eight
-------------
00:00:00
01:00:00
02:03:00
@ -60,7 +60,7 @@ SELECT f1 AS "Eight" FROM TIME_TBL WHERE f1 >= '00:00';
12:00:00
12:01:00
23:59:00
23:59:59
23:59:59.99
(8 rows)
--

View File

@ -3,7 +3,7 @@
--
-- needed so tests pass even in Australia
SET australian_timezones = 'off';
CREATE TABLE TIMESTAMP_TBL ( d1 timestamp without time zone);
CREATE TABLE TIMESTAMP_TBL ( d1 timestamp(2) without time zone);
-- Shorthand values
-- Not directly usable for regression testing since these are not constants.
-- So, just try to test parser and hope for the best - thomas 97/04/26
@ -143,8 +143,8 @@ SELECT '' AS "64", d1 FROM TIMESTAMP_TBL;
| infinity
| Thu Jan 01 00:00:00 1970
| Mon Feb 10 17:32:01 1997
| Mon Feb 10 17:32:01.00 1997
| Mon Feb 10 17:32:02.00 1997
| Mon Feb 10 17:32:01 1997
| Mon Feb 10 17:32:02 1997
| Mon Feb 10 17:32:01.40 1997
| Mon Feb 10 17:32:01.50 1997
| Mon Feb 10 17:32:01.60 1997
@ -212,8 +212,8 @@ SELECT '' AS "48", d1 FROM TIMESTAMP_TBL
----+-----------------------------
| infinity
| Mon Feb 10 17:32:01 1997
| Mon Feb 10 17:32:01.00 1997
| Mon Feb 10 17:32:02.00 1997
| Mon Feb 10 17:32:01 1997
| Mon Feb 10 17:32:02 1997
| Mon Feb 10 17:32:01.40 1997
| Mon Feb 10 17:32:01.50 1997
| Mon Feb 10 17:32:01.60 1997
@ -296,8 +296,8 @@ SELECT '' AS "63", d1 FROM TIMESTAMP_TBL
| infinity
| Thu Jan 01 00:00:00 1970
| Mon Feb 10 17:32:01 1997
| Mon Feb 10 17:32:01.00 1997
| Mon Feb 10 17:32:02.00 1997
| Mon Feb 10 17:32:01 1997
| Mon Feb 10 17:32:02 1997
| Mon Feb 10 17:32:01.40 1997
| Mon Feb 10 17:32:01.50 1997
| Mon Feb 10 17:32:01.60 1997
@ -385,8 +385,8 @@ SELECT '' AS "49", d1 FROM TIMESTAMP_TBL
----+-----------------------------
| infinity
| Mon Feb 10 17:32:01 1997
| Mon Feb 10 17:32:01.00 1997
| Mon Feb 10 17:32:02.00 1997
| Mon Feb 10 17:32:01 1997
| Mon Feb 10 17:32:02 1997
| Mon Feb 10 17:32:01.40 1997
| Mon Feb 10 17:32:01.50 1997
| Mon Feb 10 17:32:01.60 1997
@ -440,8 +440,8 @@ SELECT '' AS "54", d1 - timestamp without time zone '1997-01-02' AS diff
----+----------------------------------------
| @ 9863 days ago
| @ 39 days 17 hours 32 mins 1 sec
| @ 39 days 17 hours 32 mins 1.00 secs
| @ 39 days 17 hours 32 mins 2.00 secs
| @ 39 days 17 hours 32 mins 1 sec
| @ 39 days 17 hours 32 mins 2 secs
| @ 39 days 17 hours 32 mins 1.40 secs
| @ 39 days 17 hours 32 mins 1.50 secs
| @ 39 days 17 hours 32 mins 1.60 secs
@ -503,8 +503,8 @@ SELECT '' AS "54", d1 - timestamp without time zone '1997-01-02' AS diff
----+----------------------------------------
| @ 9863 days ago
| @ 39 days 17 hours 32 mins 1 sec
| @ 39 days 17 hours 32 mins 1.00 secs
| @ 39 days 17 hours 32 mins 2.00 secs
| @ 39 days 17 hours 32 mins 1 sec
| @ 39 days 17 hours 32 mins 2 secs
| @ 39 days 17 hours 32 mins 1.40 secs
| @ 39 days 17 hours 32 mins 1.50 secs
| @ 39 days 17 hours 32 mins 1.60 secs
@ -557,127 +557,129 @@ SELECT '' AS "54", d1 - timestamp without time zone '1997-01-02' AS diff
| @ 1460 days 17 hours 32 mins 1 sec
(54 rows)
SELECT '' AS "54", date_part( 'year', d1) AS year, date_part( 'month', d1) AS month,
SELECT '' AS "54", d1 as "timestamp",
date_part( 'year', d1) AS year, date_part( 'month', d1) AS month,
date_part( 'day', d1) AS day, date_part( 'hour', d1) AS hour,
date_part( 'minute', d1) AS minute, date_part( 'second', d1) AS second
FROM TIMESTAMP_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';
54 | year | month | day | hour | minute | second
----+------+-------+-----+------+--------+----------
| 1969 | 12 | 31 | 16 | 0 | 0
| 1997 | 2 | 10 | 9 | 32 | 1
| 1997 | 2 | 10 | 9 | 32 | 1.000001
| 1997 | 2 | 10 | 9 | 32 | 1.999999
| 1997 | 2 | 10 | 9 | 32 | 1.4
| 1997 | 2 | 10 | 9 | 32 | 1.5
| 1997 | 2 | 10 | 9 | 32 | 1.6
| 1997 | 1 | 1 | 16 | 0 | 0
| 1997 | 1 | 1 | 19 | 4 | 5
| 1997 | 2 | 10 | 9 | 32 | 1
| 1997 | 2 | 10 | 9 | 32 | 1
| 1997 | 2 | 10 | 9 | 32 | 1
| 1997 | 2 | 10 | 9 | 32 | 1
| 1997 | 6 | 10 | 10 | 32 | 1
| 2001 | 9 | 22 | 11 | 19 | 20
| 2000 | 3 | 15 | 0 | 14 | 1
| 2000 | 3 | 15 | 5 | 14 | 2
| 2000 | 3 | 15 | 4 | 14 | 3
| 2000 | 3 | 14 | 19 | 14 | 4
| 2000 | 3 | 14 | 18 | 14 | 5
| 1997 | 2 | 10 | 9 | 32 | 1
| 1997 | 2 | 10 | 9 | 32 | 1
| 1997 | 2 | 10 | 9 | 32 | 0
| 1997 | 2 | 10 | 9 | 32 | 1
| 1997 | 2 | 10 | 9 | 32 | 1
| 1997 | 2 | 10 | 9 | 32 | 1
| 1997 | 2 | 10 | 9 | 32 | 1
| 1997 | 2 | 10 | 9 | 32 | 1
| 1997 | 2 | 10 | 9 | 32 | 1
| 1997 | 2 | 10 | 9 | 32 | 1
| 1997 | 2 | 10 | 9 | 32 | 1
| 1997 | 6 | 10 | 11 | 32 | 1
| 1997 | 2 | 10 | 9 | 32 | 1
| 1997 | 2 | 11 | 9 | 32 | 1
| 1997 | 2 | 12 | 9 | 32 | 1
| 1997 | 2 | 13 | 9 | 32 | 1
| 1997 | 2 | 14 | 9 | 32 | 1
| 1997 | 2 | 15 | 9 | 32 | 1
| 1997 | 2 | 16 | 9 | 32 | 1
| 1997 | 2 | 16 | 9 | 32 | 1
| 1996 | 2 | 28 | 9 | 32 | 1
| 1996 | 2 | 29 | 9 | 32 | 1
| 1996 | 3 | 1 | 9 | 32 | 1
| 1996 | 12 | 30 | 9 | 32 | 1
| 1996 | 12 | 31 | 9 | 32 | 1
| 1997 | 1 | 1 | 9 | 32 | 1
| 1997 | 2 | 28 | 9 | 32 | 1
| 1997 | 3 | 1 | 9 | 32 | 1
| 1997 | 12 | 30 | 9 | 32 | 1
| 1997 | 12 | 31 | 9 | 32 | 1
| 1999 | 12 | 31 | 9 | 32 | 1
| 2000 | 1 | 1 | 9 | 32 | 1
| 2000 | 12 | 31 | 9 | 32 | 1
| 2001 | 1 | 1 | 9 | 32 | 1
54 | timestamp | year | month | day | hour | minute | second
----+-----------------------------+------+-------+-----+------+--------+--------
| Thu Jan 01 00:00:00 1970 | 1970 | 1 | 1 | 0 | 0 | 0
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:02 1997 | 1997 | 2 | 10 | 17 | 32 | 2
| Mon Feb 10 17:32:01.40 1997 | 1997 | 2 | 10 | 17 | 32 | 1.4
| Mon Feb 10 17:32:01.50 1997 | 1997 | 2 | 10 | 17 | 32 | 1.5
| Mon Feb 10 17:32:01.60 1997 | 1997 | 2 | 10 | 17 | 32 | 1.6
| Thu Jan 02 00:00:00 1997 | 1997 | 1 | 2 | 0 | 0 | 0
| Thu Jan 02 03:04:05 1997 | 1997 | 1 | 2 | 3 | 4 | 5
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1
| Tue Jun 10 17:32:01 1997 | 1997 | 6 | 10 | 17 | 32 | 1
| Sat Sep 22 18:19:20 2001 | 2001 | 9 | 22 | 18 | 19 | 20
| Wed Mar 15 08:14:01 2000 | 2000 | 3 | 15 | 8 | 14 | 1
| Wed Mar 15 13:14:02 2000 | 2000 | 3 | 15 | 13 | 14 | 2
| Wed Mar 15 12:14:03 2000 | 2000 | 3 | 15 | 12 | 14 | 3
| Wed Mar 15 03:14:04 2000 | 2000 | 3 | 15 | 3 | 14 | 4
| Wed Mar 15 02:14:05 2000 | 2000 | 3 | 15 | 2 | 14 | 5
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:00 1997 | 1997 | 2 | 10 | 17 | 32 | 0
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1
| Tue Jun 10 18:32:01 1997 | 1997 | 6 | 10 | 18 | 32 | 1
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1
| Tue Feb 11 17:32:01 1997 | 1997 | 2 | 11 | 17 | 32 | 1
| Wed Feb 12 17:32:01 1997 | 1997 | 2 | 12 | 17 | 32 | 1
| Thu Feb 13 17:32:01 1997 | 1997 | 2 | 13 | 17 | 32 | 1
| Fri Feb 14 17:32:01 1997 | 1997 | 2 | 14 | 17 | 32 | 1
| Sat Feb 15 17:32:01 1997 | 1997 | 2 | 15 | 17 | 32 | 1
| Sun Feb 16 17:32:01 1997 | 1997 | 2 | 16 | 17 | 32 | 1
| Sun Feb 16 17:32:01 1997 | 1997 | 2 | 16 | 17 | 32 | 1
| Wed Feb 28 17:32:01 1996 | 1996 | 2 | 28 | 17 | 32 | 1
| Thu Feb 29 17:32:01 1996 | 1996 | 2 | 29 | 17 | 32 | 1
| Fri Mar 01 17:32:01 1996 | 1996 | 3 | 1 | 17 | 32 | 1
| Mon Dec 30 17:32:01 1996 | 1996 | 12 | 30 | 17 | 32 | 1
| Tue Dec 31 17:32:01 1996 | 1996 | 12 | 31 | 17 | 32 | 1
| Wed Jan 01 17:32:01 1997 | 1997 | 1 | 1 | 17 | 32 | 1
| Fri Feb 28 17:32:01 1997 | 1997 | 2 | 28 | 17 | 32 | 1
| Sat Mar 01 17:32:01 1997 | 1997 | 3 | 1 | 17 | 32 | 1
| Tue Dec 30 17:32:01 1997 | 1997 | 12 | 30 | 17 | 32 | 1
| Wed Dec 31 17:32:01 1997 | 1997 | 12 | 31 | 17 | 32 | 1
| Fri Dec 31 17:32:01 1999 | 1999 | 12 | 31 | 17 | 32 | 1
| Sat Jan 01 17:32:01 2000 | 2000 | 1 | 1 | 17 | 32 | 1
| Sun Dec 31 17:32:01 2000 | 2000 | 12 | 31 | 17 | 32 | 1
| Mon Jan 01 17:32:01 2001 | 2001 | 1 | 1 | 17 | 32 | 1
(54 rows)
SELECT '' AS "54", date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec,
SELECT '' AS "54", d1 as "timestamp",
date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec,
date_part( 'usec', d1) AS usec
FROM TIMESTAMP_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';
54 | quarter | msec | usec
----+---------+----------------------+-------------------
| 4 | 0 | 0
| 1 | 0 | 0
| 1 | 0.000999999999917733 | 0.999999999917733
| 1 | 999.999 | 999999
| 1 | 400 | 400000
| 1 | 500 | 500000
| 1 | 600 | 600000
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 2 | 0 | 0
| 3 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 2 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 4 | 0 | 0
| 4 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 4 | 0 | 0
| 4 | 0 | 0
| 4 | 0 | 0
| 1 | 0 | 0
| 4 | 0 | 0
| 1 | 0 | 0
54 | timestamp | quarter | msec | usec
----+-----------------------------+---------+------+--------
| Thu Jan 01 00:00:00 1970 | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
| Mon Feb 10 17:32:02 1997 | 1 | 0 | 0
| Mon Feb 10 17:32:01.40 1997 | 1 | 400 | 400000
| Mon Feb 10 17:32:01.50 1997 | 1 | 500 | 500000
| Mon Feb 10 17:32:01.60 1997 | 1 | 600 | 600000
| Thu Jan 02 00:00:00 1997 | 1 | 0 | 0
| Thu Jan 02 03:04:05 1997 | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
| Tue Jun 10 17:32:01 1997 | 2 | 0 | 0
| Sat Sep 22 18:19:20 2001 | 3 | 0 | 0
| Wed Mar 15 08:14:01 2000 | 1 | 0 | 0
| Wed Mar 15 13:14:02 2000 | 1 | 0 | 0
| Wed Mar 15 12:14:03 2000 | 1 | 0 | 0
| Wed Mar 15 03:14:04 2000 | 1 | 0 | 0
| Wed Mar 15 02:14:05 2000 | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
| Mon Feb 10 17:32:00 1997 | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
| Tue Jun 10 18:32:01 1997 | 2 | 0 | 0
| Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
| Tue Feb 11 17:32:01 1997 | 1 | 0 | 0
| Wed Feb 12 17:32:01 1997 | 1 | 0 | 0
| Thu Feb 13 17:32:01 1997 | 1 | 0 | 0
| Fri Feb 14 17:32:01 1997 | 1 | 0 | 0
| Sat Feb 15 17:32:01 1997 | 1 | 0 | 0
| Sun Feb 16 17:32:01 1997 | 1 | 0 | 0
| Sun Feb 16 17:32:01 1997 | 1 | 0 | 0
| Wed Feb 28 17:32:01 1996 | 1 | 0 | 0
| Thu Feb 29 17:32:01 1996 | 1 | 0 | 0
| Fri Mar 01 17:32:01 1996 | 1 | 0 | 0
| Mon Dec 30 17:32:01 1996 | 4 | 0 | 0
| Tue Dec 31 17:32:01 1996 | 4 | 0 | 0
| Wed Jan 01 17:32:01 1997 | 1 | 0 | 0
| Fri Feb 28 17:32:01 1997 | 1 | 0 | 0
| Sat Mar 01 17:32:01 1997 | 1 | 0 | 0
| Tue Dec 30 17:32:01 1997 | 4 | 0 | 0
| Wed Dec 31 17:32:01 1997 | 4 | 0 | 0
| Fri Dec 31 17:32:01 1999 | 4 | 0 | 0
| Sat Jan 01 17:32:01 2000 | 1 | 0 | 0
| Sun Dec 31 17:32:01 2000 | 4 | 0 | 0
| Mon Jan 01 17:32:01 2001 | 1 | 0 | 0
(54 rows)
-- TO_CHAR()
@ -970,7 +972,7 @@ SELECT '' AS to_char_5, to_char(d1, 'HH HH12 HH24 MI SS SSSS')
| 12 12 00 00 00 0
| 05 05 17 32 01 63121
| 05 05 17 32 01 63121
| 05 05 17 32 01 63121
| 05 05 17 32 02 63122
| 05 05 17 32 01 63121
| 05 05 17 32 01 63121
| 05 05 17 32 01 63121
@ -1040,7 +1042,7 @@ SELECT '' AS to_char_6, to_char(d1, '"HH:MI:SS is" HH:MI:SS "\\"text between quo
| HH:MI:SS is 12:00:00 "text between quote marks"
| HH:MI:SS is 05:32:01 "text between quote marks"
| HH:MI:SS is 05:32:01 "text between quote marks"
| HH:MI:SS is 05:32:01 "text between quote marks"
| HH:MI:SS is 05:32:02 "text between quote marks"
| HH:MI:SS is 05:32:01 "text between quote marks"
| HH:MI:SS is 05:32:01 "text between quote marks"
| HH:MI:SS is 05:32:01 "text between quote marks"
@ -1110,7 +1112,7 @@ SELECT '' AS to_char_7, to_char(d1, 'HH24--text--MI--text--SS')
| 00--text--00--text--00
| 17--text--32--text--01
| 17--text--32--text--01
| 17--text--32--text--01
| 17--text--32--text--02
| 17--text--32--text--01
| 17--text--32--text--01
| 17--text--32--text--01
@ -1251,7 +1253,7 @@ SELECT '' AS to_char_9, to_char(d1, 'YYYY A.D. YYYY a.d. YYYY bc HH:MI:SS P.M. H
| 1970 A.D. 1970 a.d. 1970 ad 12:00:00 A.M. 12:00:00 a.m. 12:00:00 am
| 1997 A.D. 1997 a.d. 1997 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm
| 1997 A.D. 1997 a.d. 1997 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm
| 1997 A.D. 1997 a.d. 1997 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm
| 1997 A.D. 1997 a.d. 1997 ad 05:32:02 P.M. 05:32:02 p.m. 05:32:02 pm
| 1997 A.D. 1997 a.d. 1997 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm
| 1997 A.D. 1997 a.d. 1997 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm
| 1997 A.D. 1997 a.d. 1997 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm

View File

@ -3,7 +3,7 @@
--
-- needed so tests pass even in Australia
SET australian_timezones = 'off';
CREATE TABLE TIMESTAMPTZ_TBL ( d1 timestamp with time zone);
CREATE TABLE TIMESTAMPTZ_TBL ( d1 timestamp(2) with time zone);
INSERT INTO TIMESTAMPTZ_TBL VALUES ('now');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('current');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('today');
@ -140,8 +140,8 @@ SELECT '' AS "64", d1 FROM TIMESTAMPTZ_TBL;
| infinity
| Wed Dec 31 16:00:00 1969 PST
| Mon Feb 10 17:32:01 1997 PST
| Mon Feb 10 17:32:01.00 1997 PST
| Mon Feb 10 17:32:02.00 1997 PST
| Mon Feb 10 17:32:01 1997 PST
| Mon Feb 10 17:32:02 1997 PST
| Mon Feb 10 17:32:01.40 1997 PST
| Mon Feb 10 17:32:01.50 1997 PST
| Mon Feb 10 17:32:01.60 1997 PST
@ -209,8 +209,8 @@ SELECT '' AS "48", d1 FROM TIMESTAMPTZ_TBL
----+---------------------------------
| infinity
| Mon Feb 10 17:32:01 1997 PST
| Mon Feb 10 17:32:01.00 1997 PST
| Mon Feb 10 17:32:02.00 1997 PST
| Mon Feb 10 17:32:01 1997 PST
| Mon Feb 10 17:32:02 1997 PST
| Mon Feb 10 17:32:01.40 1997 PST
| Mon Feb 10 17:32:01.50 1997 PST
| Mon Feb 10 17:32:01.60 1997 PST
@ -293,8 +293,8 @@ SELECT '' AS "63", d1 FROM TIMESTAMPTZ_TBL
| infinity
| Wed Dec 31 16:00:00 1969 PST
| Mon Feb 10 17:32:01 1997 PST
| Mon Feb 10 17:32:01.00 1997 PST
| Mon Feb 10 17:32:02.00 1997 PST
| Mon Feb 10 17:32:01 1997 PST
| Mon Feb 10 17:32:02 1997 PST
| Mon Feb 10 17:32:01.40 1997 PST
| Mon Feb 10 17:32:01.50 1997 PST
| Mon Feb 10 17:32:01.60 1997 PST
@ -382,8 +382,8 @@ SELECT '' AS "49", d1 FROM TIMESTAMPTZ_TBL
----+---------------------------------
| infinity
| Mon Feb 10 17:32:01 1997 PST
| Mon Feb 10 17:32:01.00 1997 PST
| Mon Feb 10 17:32:02.00 1997 PST
| Mon Feb 10 17:32:01 1997 PST
| Mon Feb 10 17:32:02 1997 PST
| Mon Feb 10 17:32:01.40 1997 PST
| Mon Feb 10 17:32:01.50 1997 PST
| Mon Feb 10 17:32:01.60 1997 PST
@ -437,8 +437,8 @@ SELECT '' AS "54", d1 - timestamp with time zone '1997-01-02' AS diff
----+----------------------------------------
| @ 9863 days 8 hours ago
| @ 39 days 17 hours 32 mins 1 sec
| @ 39 days 17 hours 32 mins 1.00 secs
| @ 39 days 17 hours 32 mins 2.00 secs
| @ 39 days 17 hours 32 mins 1 sec
| @ 39 days 17 hours 32 mins 2 secs
| @ 39 days 17 hours 32 mins 1.40 secs
| @ 39 days 17 hours 32 mins 1.50 secs
| @ 39 days 17 hours 32 mins 1.60 secs
@ -499,8 +499,8 @@ SELECT '' AS "54", d1 - timestamp with time zone '1997-01-02' AS diff
----+----------------------------------------
| @ 9863 days 8 hours ago
| @ 39 days 17 hours 32 mins 1 sec
| @ 39 days 17 hours 32 mins 1.00 secs
| @ 39 days 17 hours 32 mins 2.00 secs
| @ 39 days 17 hours 32 mins 1 sec
| @ 39 days 17 hours 32 mins 2 secs
| @ 39 days 17 hours 32 mins 1.40 secs
| @ 39 days 17 hours 32 mins 1.50 secs
| @ 39 days 17 hours 32 mins 1.60 secs
@ -553,127 +553,129 @@ SELECT '' AS "54", d1 - timestamp with time zone '1997-01-02' AS diff
| @ 1460 days 17 hours 32 mins 1 sec
(54 rows)
SELECT '' AS "54", date_part( 'year', d1) AS year, date_part( 'month', d1) AS month,
SELECT '' AS "54", d1 as timestamptz,
date_part( 'year', d1) AS year, date_part( 'month', d1) AS month,
date_part( 'day', d1) AS day, date_part( 'hour', d1) AS hour,
date_part( 'minute', d1) AS minute, date_part( 'second', d1) AS second
FROM TIMESTAMPTZ_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';
54 | year | month | day | hour | minute | second
----+------+-------+-----+------+--------+----------
| 1969 | 12 | 31 | 16 | 0 | 0
| 1997 | 2 | 10 | 17 | 32 | 1
| 1997 | 2 | 10 | 17 | 32 | 1.000001
| 1997 | 2 | 10 | 17 | 32 | 1.999999
| 1997 | 2 | 10 | 17 | 32 | 1.4
| 1997 | 2 | 10 | 17 | 32 | 1.5
| 1997 | 2 | 10 | 17 | 32 | 1.6
| 1997 | 1 | 2 | 0 | 0 | 0
| 1997 | 1 | 2 | 3 | 4 | 5
| 1997 | 2 | 10 | 17 | 32 | 1
| 1997 | 2 | 10 | 17 | 32 | 1
| 1997 | 2 | 10 | 17 | 32 | 1
| 1997 | 2 | 10 | 17 | 32 | 1
| 1997 | 6 | 10 | 17 | 32 | 1
| 2001 | 9 | 22 | 11 | 19 | 20
| 2000 | 3 | 15 | 8 | 14 | 1
| 2000 | 3 | 15 | 4 | 14 | 2
| 2000 | 3 | 15 | 2 | 14 | 3
| 2000 | 3 | 15 | 3 | 14 | 4
| 2000 | 3 | 15 | 1 | 14 | 5
| 1997 | 2 | 10 | 17 | 32 | 1
| 1997 | 2 | 10 | 17 | 32 | 1
| 1997 | 2 | 10 | 17 | 32 | 0
| 1997 | 2 | 10 | 17 | 32 | 1
| 1997 | 2 | 10 | 17 | 32 | 1
| 1997 | 2 | 10 | 17 | 32 | 1
| 1997 | 2 | 10 | 17 | 32 | 1
| 1997 | 2 | 10 | 17 | 32 | 1
| 1997 | 2 | 10 | 9 | 32 | 1
| 1997 | 2 | 10 | 9 | 32 | 1
| 1997 | 2 | 10 | 9 | 32 | 1
| 1997 | 6 | 10 | 18 | 32 | 1
| 1997 | 2 | 10 | 17 | 32 | 1
| 1997 | 2 | 11 | 17 | 32 | 1
| 1997 | 2 | 12 | 17 | 32 | 1
| 1997 | 2 | 13 | 17 | 32 | 1
| 1997 | 2 | 14 | 17 | 32 | 1
| 1997 | 2 | 15 | 17 | 32 | 1
| 1997 | 2 | 16 | 17 | 32 | 1
| 1997 | 2 | 16 | 17 | 32 | 1
| 1996 | 2 | 28 | 17 | 32 | 1
| 1996 | 2 | 29 | 17 | 32 | 1
| 1996 | 3 | 1 | 17 | 32 | 1
| 1996 | 12 | 30 | 17 | 32 | 1
| 1996 | 12 | 31 | 17 | 32 | 1
| 1997 | 1 | 1 | 17 | 32 | 1
| 1997 | 2 | 28 | 17 | 32 | 1
| 1997 | 3 | 1 | 17 | 32 | 1
| 1997 | 12 | 30 | 17 | 32 | 1
| 1997 | 12 | 31 | 17 | 32 | 1
| 1999 | 12 | 31 | 17 | 32 | 1
| 2000 | 1 | 1 | 17 | 32 | 1
| 2000 | 12 | 31 | 17 | 32 | 1
| 2001 | 1 | 1 | 17 | 32 | 1
54 | timestamptz | year | month | day | hour | minute | second
----+---------------------------------+------+-------+-----+------+--------+--------
| Wed Dec 31 16:00:00 1969 PST | 1969 | 12 | 31 | 16 | 0 | 0
| Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:02 1997 PST | 1997 | 2 | 10 | 17 | 32 | 2
| Mon Feb 10 17:32:01.40 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1.4
| Mon Feb 10 17:32:01.50 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1.5
| Mon Feb 10 17:32:01.60 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1.6
| Thu Jan 02 00:00:00 1997 PST | 1997 | 1 | 2 | 0 | 0 | 0
| Thu Jan 02 03:04:05 1997 PST | 1997 | 1 | 2 | 3 | 4 | 5
| Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1
| Tue Jun 10 17:32:01 1997 PDT | 1997 | 6 | 10 | 17 | 32 | 1
| Sat Sep 22 11:19:20 2001 PDT | 2001 | 9 | 22 | 11 | 19 | 20
| Wed Mar 15 08:14:01 2000 PST | 2000 | 3 | 15 | 8 | 14 | 1
| Wed Mar 15 04:14:02 2000 PST | 2000 | 3 | 15 | 4 | 14 | 2
| Wed Mar 15 02:14:03 2000 PST | 2000 | 3 | 15 | 2 | 14 | 3
| Wed Mar 15 03:14:04 2000 PST | 2000 | 3 | 15 | 3 | 14 | 4
| Wed Mar 15 01:14:05 2000 PST | 2000 | 3 | 15 | 1 | 14 | 5
| Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:00 1997 PST | 1997 | 2 | 10 | 17 | 32 | 0
| Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1
| Mon Feb 10 09:32:01 1997 PST | 1997 | 2 | 10 | 9 | 32 | 1
| Mon Feb 10 09:32:01 1997 PST | 1997 | 2 | 10 | 9 | 32 | 1
| Mon Feb 10 09:32:01 1997 PST | 1997 | 2 | 10 | 9 | 32 | 1
| Tue Jun 10 18:32:01 1997 PDT | 1997 | 6 | 10 | 18 | 32 | 1
| Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1
| Tue Feb 11 17:32:01 1997 PST | 1997 | 2 | 11 | 17 | 32 | 1
| Wed Feb 12 17:32:01 1997 PST | 1997 | 2 | 12 | 17 | 32 | 1
| Thu Feb 13 17:32:01 1997 PST | 1997 | 2 | 13 | 17 | 32 | 1
| Fri Feb 14 17:32:01 1997 PST | 1997 | 2 | 14 | 17 | 32 | 1
| Sat Feb 15 17:32:01 1997 PST | 1997 | 2 | 15 | 17 | 32 | 1
| Sun Feb 16 17:32:01 1997 PST | 1997 | 2 | 16 | 17 | 32 | 1
| Sun Feb 16 17:32:01 1997 PST | 1997 | 2 | 16 | 17 | 32 | 1
| Wed Feb 28 17:32:01 1996 PST | 1996 | 2 | 28 | 17 | 32 | 1
| Thu Feb 29 17:32:01 1996 PST | 1996 | 2 | 29 | 17 | 32 | 1
| Fri Mar 01 17:32:01 1996 PST | 1996 | 3 | 1 | 17 | 32 | 1
| Mon Dec 30 17:32:01 1996 PST | 1996 | 12 | 30 | 17 | 32 | 1
| Tue Dec 31 17:32:01 1996 PST | 1996 | 12 | 31 | 17 | 32 | 1
| Wed Jan 01 17:32:01 1997 PST | 1997 | 1 | 1 | 17 | 32 | 1
| Fri Feb 28 17:32:01 1997 PST | 1997 | 2 | 28 | 17 | 32 | 1
| Sat Mar 01 17:32:01 1997 PST | 1997 | 3 | 1 | 17 | 32 | 1
| Tue Dec 30 17:32:01 1997 PST | 1997 | 12 | 30 | 17 | 32 | 1
| Wed Dec 31 17:32:01 1997 PST | 1997 | 12 | 31 | 17 | 32 | 1
| Fri Dec 31 17:32:01 1999 PST | 1999 | 12 | 31 | 17 | 32 | 1
| Sat Jan 01 17:32:01 2000 PST | 2000 | 1 | 1 | 17 | 32 | 1
| Sun Dec 31 17:32:01 2000 PST | 2000 | 12 | 31 | 17 | 32 | 1
| Mon Jan 01 17:32:01 2001 PST | 2001 | 1 | 1 | 17 | 32 | 1
(54 rows)
SELECT '' AS "54", date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec,
SELECT '' AS "54", d1 as timestamptz,
date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec,
date_part( 'usec', d1) AS usec
FROM TIMESTAMPTZ_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';
54 | quarter | msec | usec
----+---------+----------------------+-------------------
| 4 | 0 | 0
| 1 | 0 | 0
| 1 | 0.000999999999917733 | 0.999999999917733
| 1 | 999.999 | 999999
| 1 | 400 | 400000
| 1 | 500 | 500000
| 1 | 600 | 600000
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 2 | 0 | 0
| 3 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 2 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 4 | 0 | 0
| 4 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 1 | 0 | 0
| 4 | 0 | 0
| 4 | 0 | 0
| 4 | 0 | 0
| 1 | 0 | 0
| 4 | 0 | 0
| 1 | 0 | 0
54 | timestamptz | quarter | msec | usec
----+---------------------------------+---------+------+--------
| Wed Dec 31 16:00:00 1969 PST | 4 | 0 | 0
| Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
| Mon Feb 10 17:32:02 1997 PST | 1 | 0 | 0
| Mon Feb 10 17:32:01.40 1997 PST | 1 | 400 | 400000
| Mon Feb 10 17:32:01.50 1997 PST | 1 | 500 | 500000
| Mon Feb 10 17:32:01.60 1997 PST | 1 | 600 | 600000
| Thu Jan 02 00:00:00 1997 PST | 1 | 0 | 0
| Thu Jan 02 03:04:05 1997 PST | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
| Tue Jun 10 17:32:01 1997 PDT | 2 | 0 | 0
| Sat Sep 22 11:19:20 2001 PDT | 3 | 0 | 0
| Wed Mar 15 08:14:01 2000 PST | 1 | 0 | 0
| Wed Mar 15 04:14:02 2000 PST | 1 | 0 | 0
| Wed Mar 15 02:14:03 2000 PST | 1 | 0 | 0
| Wed Mar 15 03:14:04 2000 PST | 1 | 0 | 0
| Wed Mar 15 01:14:05 2000 PST | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
| Mon Feb 10 17:32:00 1997 PST | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
| Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
| Mon Feb 10 09:32:01 1997 PST | 1 | 0 | 0
| Mon Feb 10 09:32:01 1997 PST | 1 | 0 | 0
| Mon Feb 10 09:32:01 1997 PST | 1 | 0 | 0
| Tue Jun 10 18:32:01 1997 PDT | 2 | 0 | 0
| Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
| Tue Feb 11 17:32:01 1997 PST | 1 | 0 | 0
| Wed Feb 12 17:32:01 1997 PST | 1 | 0 | 0
| Thu Feb 13 17:32:01 1997 PST | 1 | 0 | 0
| Fri Feb 14 17:32:01 1997 PST | 1 | 0 | 0
| Sat Feb 15 17:32:01 1997 PST | 1 | 0 | 0
| Sun Feb 16 17:32:01 1997 PST | 1 | 0 | 0
| Sun Feb 16 17:32:01 1997 PST | 1 | 0 | 0
| Wed Feb 28 17:32:01 1996 PST | 1 | 0 | 0
| Thu Feb 29 17:32:01 1996 PST | 1 | 0 | 0
| Fri Mar 01 17:32:01 1996 PST | 1 | 0 | 0
| Mon Dec 30 17:32:01 1996 PST | 4 | 0 | 0
| Tue Dec 31 17:32:01 1996 PST | 4 | 0 | 0
| Wed Jan 01 17:32:01 1997 PST | 1 | 0 | 0
| Fri Feb 28 17:32:01 1997 PST | 1 | 0 | 0
| Sat Mar 01 17:32:01 1997 PST | 1 | 0 | 0
| Tue Dec 30 17:32:01 1997 PST | 4 | 0 | 0
| Wed Dec 31 17:32:01 1997 PST | 4 | 0 | 0
| Fri Dec 31 17:32:01 1999 PST | 4 | 0 | 0
| Sat Jan 01 17:32:01 2000 PST | 1 | 0 | 0
| Sun Dec 31 17:32:01 2000 PST | 4 | 0 | 0
| Mon Jan 01 17:32:01 2001 PST | 1 | 0 | 0
(54 rows)
-- TO_CHAR()
@ -969,7 +971,7 @@ SELECT '' AS to_char_5, to_char(d1, 'HH HH12 HH24 MI SS SSSS')
| 04 04 16 00 00 57600
| 05 05 17 32 01 63121
| 05 05 17 32 01 63121
| 05 05 17 32 01 63121
| 05 05 17 32 02 63122
| 05 05 17 32 01 63121
| 05 05 17 32 01 63121
| 05 05 17 32 01 63121
@ -1039,7 +1041,7 @@ SELECT '' AS to_char_6, to_char(d1, '"HH:MI:SS is" HH:MI:SS "\\"text between quo
| HH:MI:SS is 04:00:00 "text between quote marks"
| HH:MI:SS is 05:32:01 "text between quote marks"
| HH:MI:SS is 05:32:01 "text between quote marks"
| HH:MI:SS is 05:32:01 "text between quote marks"
| HH:MI:SS is 05:32:02 "text between quote marks"
| HH:MI:SS is 05:32:01 "text between quote marks"
| HH:MI:SS is 05:32:01 "text between quote marks"
| HH:MI:SS is 05:32:01 "text between quote marks"
@ -1110,7 +1112,7 @@ SELECT '' AS to_char_7, to_char(d1, 'HH24--text--MI--text--SS')
| 16--text--00--text--00
| 17--text--32--text--01
| 17--text--32--text--01
| 17--text--32--text--01
| 17--text--32--text--02
| 17--text--32--text--01
| 17--text--32--text--01
| 17--text--32--text--01
@ -1251,7 +1253,7 @@ SELECT '' AS to_char_9, to_char(d1, 'YYYY A.D. YYYY a.d. YYYY bc HH:MI:SS P.M. H
| 1969 A.D. 1969 a.d. 1969 ad 04:00:00 P.M. 04:00:00 p.m. 04:00:00 pm
| 1997 A.D. 1997 a.d. 1997 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm
| 1997 A.D. 1997 a.d. 1997 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm
| 1997 A.D. 1997 a.d. 1997 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm
| 1997 A.D. 1997 a.d. 1997 ad 05:32:02 P.M. 05:32:02 p.m. 05:32:02 pm
| 1997 A.D. 1997 a.d. 1997 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm
| 1997 A.D. 1997 a.d. 1997 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm
| 1997 A.D. 1997 a.d. 1997 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm

View File

@ -1,7 +1,7 @@
--
-- TIMETZ
--
CREATE TABLE TIMETZ_TBL (f1 time with time zone);
CREATE TABLE TIMETZ_TBL (f1 time(2) with time zone);
INSERT INTO TIMETZ_TBL VALUES ('00:01 PDT');
INSERT INTO TIMETZ_TBL VALUES ('01:00 PDT');
INSERT INTO TIMETZ_TBL VALUES ('02:03 PDT');
@ -13,8 +13,8 @@ INSERT INTO TIMETZ_TBL VALUES ('12:01 PDT');
INSERT INTO TIMETZ_TBL VALUES ('23:59 PDT');
INSERT INTO TIMETZ_TBL VALUES ('11:59:59.99 PM PDT');
SELECT f1 AS "Time TZ" FROM TIMETZ_TBL;
Time TZ
-------------
Time TZ
----------------
00:01:00-07
01:00:00-07
02:03:00-07
@ -24,7 +24,7 @@ SELECT f1 AS "Time TZ" FROM TIMETZ_TBL;
12:00:00-07
12:01:00-07
23:59:00-07
23:59:59-07
23:59:59.99-07
(10 rows)
SELECT f1 AS "Three" FROM TIMETZ_TBL WHERE f1 < '05:06:07';
@ -36,15 +36,15 @@ SELECT f1 AS "Three" FROM TIMETZ_TBL WHERE f1 < '05:06:07';
(3 rows)
SELECT f1 AS "Seven" FROM TIMETZ_TBL WHERE f1 > '05:06:07';
Seven
-------------
Seven
----------------
07:07:00-08
08:08:00-04
11:59:00-07
12:00:00-07
12:01:00-07
23:59:00-07
23:59:59-07
23:59:59.99-07
(7 rows)
SELECT f1 AS "None" FROM TIMETZ_TBL WHERE f1 < '00:00';
@ -53,8 +53,8 @@ SELECT f1 AS "None" FROM TIMETZ_TBL WHERE f1 < '00:00';
(0 rows)
SELECT f1 AS "Ten" FROM TIMETZ_TBL WHERE f1 >= '00:00';
Ten
-------------
Ten
----------------
00:01:00-07
01:00:00-07
02:03:00-07
@ -64,7 +64,7 @@ SELECT f1 AS "Ten" FROM TIMETZ_TBL WHERE f1 >= '00:00';
12:00:00-07
12:01:00-07
23:59:00-07
23:59:59-07
23:59:59.99-07
(10 rows)
--

View File

@ -35,10 +35,13 @@ SELECT (timestamp without time zone 'today' = (timestamp without time zone 'tomo
SELECT (timestamp without time zone 'tomorrow' = (timestamp without time zone 'yesterday' + interval '2 days')) as "True";
SELECT (timestamp without time zone 'tomorrow' > 'now') as "True";
SELECT timestamp(date '1994-01-01', time '11:00') AS "Jan_01_1994_11am";
SELECT timestamp(date '1994-01-01', time '10:00') AS "Jan_01_1994_10am";
SELECT timestamp(date '1994-01-01', time '11:00-5') AS "Jan_01_1994_8am";
SELECT timestamp(date '1994-01-01', time with time zone '11:00-5') AS "Jan_01_1994_11am";
-- Convert from date and time to timestamp
-- This test used to be timestamp(date,time) but no longer allowed by grammar
-- to enable support for SQL99 timestamp type syntax.
SELECT date '1994-01-01' + time '11:00' AS "Jan_01_1994_11am";
SELECT date '1994-01-01' + time '10:00' AS "Jan_01_1994_10am";
SELECT date '1994-01-01' + time '11:00-5' AS "Jan_01_1994_8am";
SELECT "timestamp"(date '1994-01-01', time with time zone '11:00-5') AS "Jan_01_1994_11am";
SELECT '' AS "64", d1 + interval '1 year' AS one_year FROM TIMESTAMP_TBL;
SELECT '' AS "64", d1 - interval '1 year' AS one_year FROM TIMESTAMP_TBL;
@ -170,20 +173,20 @@ INSERT INTO TEMP_TIMESTAMP (f1)
WHERE d1 BETWEEN '13-jun-1957' AND '1-jan-1997'
OR d1 BETWEEN '1-jan-1999' AND '1-jan-2010';
SELECT '' AS "16", f1 AS timestamp
SELECT '' AS "16", f1 AS "timestamp"
FROM TEMP_TIMESTAMP
ORDER BY timestamp;
ORDER BY "timestamp";
SELECT '' AS "160", d.f1 AS timestamp, t.f1 AS interval, d.f1 + t.f1 AS plus
SELECT '' AS "160", d.f1 AS "timestamp", t.f1 AS interval, d.f1 + t.f1 AS plus
FROM TEMP_TIMESTAMP d, INTERVAL_TBL t
ORDER BY plus, timestamp, interval;
ORDER BY plus, "timestamp", interval;
SELECT '' AS "160", d.f1 AS timestamp, t.f1 AS interval, d.f1 - t.f1 AS minus
SELECT '' AS "160", d.f1 AS "timestamp", t.f1 AS interval, d.f1 - t.f1 AS minus
FROM TEMP_TIMESTAMP d, INTERVAL_TBL t
WHERE isfinite(d.f1)
ORDER BY minus, timestamp, interval;
ORDER BY minus, "timestamp", interval;
SELECT '' AS "16", d.f1 AS timestamp, timestamp '1980-01-06 00:00 GMT' AS gpstime_zero,
SELECT '' AS "16", d.f1 AS "timestamp", timestamp '1980-01-06 00:00 GMT' AS gpstime_zero,
d.f1 - timestamp '1980-01-06 00:00 GMT' AS difference
FROM TEMP_TIMESTAMP d
ORDER BY difference;
@ -192,14 +195,6 @@ SELECT '' AS "226", d1.f1 AS timestamp1, d2.f1 AS timestamp2, d1.f1 - d2.f1 AS d
FROM TEMP_TIMESTAMP d1, TEMP_TIMESTAMP d2
ORDER BY timestamp1, timestamp2, difference;
SELECT '' as "55", d1 as timestamp,
date_part('year', d1) AS year, date_part('month', d1) AS month,
date_part('day',d1) AS day, date_part('hour', d1) AS hour,
date_part('minute', d1) AS minute, date_part('second', d1) AS second
FROM TIMESTAMP_TBL
WHERE isfinite(d1) and d1 >= '1-jan-1900 GMT'
ORDER BY timestamp;
--
-- abstime, reltime arithmetic
--
@ -232,12 +227,12 @@ SELECT '' AS three, ABSTIME_TBL.*
-- Conversions
--
SELECT '' AS "16", f1 AS timestamp, date(f1) AS date
SELECT '' AS "16", f1 AS "timestamp", date(f1) AS date
FROM TEMP_TIMESTAMP
WHERE f1 <> timestamp 'current'
ORDER BY date, timestamp;
ORDER BY date, "timestamp";
SELECT '' AS "16", f1 AS timestamp, abstime(f1) AS abstime
SELECT '' AS "16", f1 AS "timestamp", abstime(f1) AS abstime
FROM TEMP_TIMESTAMP
ORDER BY abstime;
@ -246,10 +241,10 @@ SELECT '' AS four, f1 AS abstime, date(f1) AS date
WHERE isfinite(f1) AND f1 <> abstime 'current'
ORDER BY date, abstime;
SELECT '' AS two, d1 AS timestamp, abstime(d1) AS abstime
SELECT '' AS two, d1 AS "timestamp", abstime(d1) AS abstime
FROM TIMESTAMP_TBL WHERE NOT isfinite(d1);
SELECT '' AS three, f1 as abstime, timestamp(f1) AS timestamp
SELECT '' AS three, f1 as abstime, cast(f1 as timestamp) AS "timestamp"
FROM ABSTIME_TBL WHERE NOT isfinite(f1);
SELECT '' AS ten, f1 AS interval, reltime(f1) AS reltime

View File

@ -2,7 +2,7 @@
-- TIME
--
CREATE TABLE TIME_TBL (f1 time);
CREATE TABLE TIME_TBL (f1 time(2));
INSERT INTO TIME_TBL VALUES ('00:00');
INSERT INTO TIME_TBL VALUES ('01:00');

View File

@ -4,7 +4,7 @@
-- needed so tests pass even in Australia
SET australian_timezones = 'off';
CREATE TABLE TIMESTAMP_TBL ( d1 timestamp without time zone);
CREATE TABLE TIMESTAMP_TBL ( d1 timestamp(2) without time zone);
-- Shorthand values
-- Not directly usable for regression testing since these are not constants.
@ -153,12 +153,14 @@ SELECT '' AS "54", d1 - timestamp without time zone '1997-01-02' AS diff
WHERE d1 BETWEEN timestamp without time zone '1902-01-01'
AND timestamp without time zone '2038-01-01';
SELECT '' AS "54", date_part( 'year', d1) AS year, date_part( 'month', d1) AS month,
SELECT '' AS "54", d1 as "timestamp",
date_part( 'year', d1) AS year, date_part( 'month', d1) AS month,
date_part( 'day', d1) AS day, date_part( 'hour', d1) AS hour,
date_part( 'minute', d1) AS minute, date_part( 'second', d1) AS second
FROM TIMESTAMP_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';
SELECT '' AS "54", date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec,
SELECT '' AS "54", d1 as "timestamp",
date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec,
date_part( 'usec', d1) AS usec
FROM TIMESTAMP_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';

View File

@ -4,7 +4,7 @@
-- needed so tests pass even in Australia
SET australian_timezones = 'off';
CREATE TABLE TIMESTAMPTZ_TBL ( d1 timestamp with time zone);
CREATE TABLE TIMESTAMPTZ_TBL ( d1 timestamp(2) with time zone);
INSERT INTO TIMESTAMPTZ_TBL VALUES ('now');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('current');
@ -148,12 +148,14 @@ SELECT '' AS "54", d1 - timestamp with time zone '1997-01-02' AS diff
FROM TIMESTAMPTZ_TBL
WHERE d1 BETWEEN timestamp with time zone '1902-01-01' AND timestamp with time zone '2038-01-01';
SELECT '' AS "54", date_part( 'year', d1) AS year, date_part( 'month', d1) AS month,
SELECT '' AS "54", d1 as timestamptz,
date_part( 'year', d1) AS year, date_part( 'month', d1) AS month,
date_part( 'day', d1) AS day, date_part( 'hour', d1) AS hour,
date_part( 'minute', d1) AS minute, date_part( 'second', d1) AS second
FROM TIMESTAMPTZ_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';
SELECT '' AS "54", date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec,
SELECT '' AS "54", d1 as timestamptz,
date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec,
date_part( 'usec', d1) AS usec
FROM TIMESTAMPTZ_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';

View File

@ -2,7 +2,7 @@
-- TIMETZ
--
CREATE TABLE TIMETZ_TBL (f1 time with time zone);
CREATE TABLE TIMETZ_TBL (f1 time(2) with time zone);
INSERT INTO TIMETZ_TBL VALUES ('00:01 PDT');
INSERT INTO TIMETZ_TBL VALUES ('01:00 PDT');