Measure the current transaction time to milliseconds.

Define a new function, GetCurrentTransactionStartTimeUsec() to get the time
 to this precision.
Allow now() and timestamp 'now' to use this higher precision result so
 we now have fractional seconds in this "constant".
Add timestamp without time zone type.
Move previous timestamp type to timestamp with time zone.
Accept another ISO variant for date/time values: yyyy-mm-ddThh:mm:ss
 (note the "T" separating the day from hours information).
Remove 'current' from date/time types; convert to 'now' in input.
Separate time and timetz regression tests.
Separate timestamp and timestamptz regression test.
This commit is contained in:
Thomas G. Lockhart 2001-09-28 08:09:14 +00:00
parent 1f075a32ee
commit 6f58115ddd
27 changed files with 2778 additions and 1873 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.109 2001/08/25 18:52:41 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.110 2001/09/28 08:08:57 thomas Exp $
*
* NOTES
* Transaction aborts can now occur two ways:
@ -369,6 +369,21 @@ GetCurrentTransactionStartTime(void)
}
/* --------------------------------
* GetCurrentTransactionStartTimeUsec
* --------------------------------
*/
AbsoluteTime
GetCurrentTransactionStartTimeUsec(int *msec)
{
TransactionState s = CurrentTransactionState;
*msec = s->startTimeMsec;
return s->startTime;
}
/* --------------------------------
* TransactionIdIsCurrentTransactionId
* --------------------------------
@ -859,7 +874,10 @@ StartTransaction(void)
*/
s->commandId = FirstCommandId;
s->scanCommandId = FirstCommandId;
#if NOT_USED
s->startTime = GetCurrentAbsoluteTime();
#endif
s->startTime = GetCurrentAbsoluteTimeUsec(&(s->startTimeMsec));
/*
* initialize the various transaction subsystems

View File

@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.253 2001/09/23 03:39:01 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.254 2001/09/28 08:09:09 thomas Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@ -259,7 +259,7 @@ static void doNegateFloat(Value *v);
%type <str> opt_charset, opt_collate
%type <str> opt_float
%type <ival> opt_numeric, opt_decimal
%type <boolean> opt_varying, opt_timezone
%type <boolean> opt_varying, opt_timezone, opt_timezone_x
%type <ival> Iconst
%type <str> Sconst, comment_text
@ -4229,10 +4229,16 @@ ConstDatetime: datetime
$$->name = xlateSqlType($1);
$$->typmod = -1;
}
| TIMESTAMP opt_timezone
| TIMESTAMP opt_timezone_x
{
$$ = makeNode(TypeName);
$$->name = xlateSqlType("timestamp");
if ($2)
$$->name = xlateSqlType("timestamptz");
else
$$->name = xlateSqlType("timestamp");
/* XXX the timezone field seems to be unused
* - thomas 2001-09-06
*/
$$->timezone = $2;
$$->typmod = -1;
}
@ -4263,6 +4269,16 @@ datetime: YEAR_P { $$ = "year"; }
| SECOND_P { $$ = "second"; }
;
/* XXX Make the default be WITH TIME ZONE for 7.2 to help with database upgrades
* but revert this back to WITHOUT TIME ZONE for 7.3.
* Do this by simply reverting opt_timezone_x to opt_timezone - thomas 2001-09-06
*/
opt_timezone_x: WITH TIME ZONE { $$ = TRUE; }
| WITHOUT TIME ZONE { $$ = FALSE; }
| /*EMPTY*/ { $$ = TRUE; }
;
opt_timezone: WITH TIME ZONE { $$ = TRUE; }
| WITHOUT TIME ZONE { $$ = FALSE; }
| /*EMPTY*/ { $$ = FALSE; }

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.60 2001/06/24 02:41:21 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.61 2001/09/28 08:09:09 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -240,7 +240,7 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids)
oid_array[0] = inputTypeId;
ftup = SearchSysCache(PROCNAME,
PointerGetDatum(typeidTypeName(targetTypeId)),
PointerGetDatum(typeidTypeName(targetTypeId)),
Int32GetDatum(1),
PointerGetDatum(oid_array),
0);
@ -498,6 +498,7 @@ TypeCategory(Oid inType)
case (TIMETZOID):
case (ABSTIMEOID):
case (TIMESTAMPOID):
case (TIMESTAMPTZOID):
result = DATETIME_TYPE;
break;
@ -577,7 +578,10 @@ PreferredType(CATEGORY category, Oid type)
break;
case (DATETIME_TYPE):
result = TIMESTAMPOID;
if (type == DATEOID)
result = TIMESTAMPOID;
else
result = TIMESTAMPTZOID;
break;
case (TIMESPAN_TYPE):
@ -634,10 +638,14 @@ PromoteTypeToNext(Oid inType)
break;
case (DATEOID):
case (ABSTIMEOID):
result = TIMESTAMPOID;
break;
case (ABSTIMEOID):
case (TIMESTAMPOID):
result = TIMESTAMPTZOID;
break;
case (TIMEOID):
case (RELTIMEOID):
result = INTERVALOID;
@ -646,7 +654,7 @@ PromoteTypeToNext(Oid inType)
case (BOOLOID):
case (TEXTOID):
case (FLOAT8OID):
case (TIMESTAMPOID):
case (TIMESTAMPTZOID):
case (INTERVALOID):
default:
result = inType;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.101 2001/09/20 23:31:08 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.102 2001/09/28 08:09:09 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -40,11 +40,11 @@ bool Transform_null_equals = false;
static Node *parser_typecast_constant(Value *expr, TypeName *typename);
static Node *parser_typecast_expression(ParseState *pstate,
Node *expr, TypeName *typename);
Node *expr, TypeName *typename);
static Node *transformAttr(ParseState *pstate, Attr *att, int precedence);
static Node *transformIdent(ParseState *pstate, Ident *ident, int precedence);
static Node *transformIndirection(ParseState *pstate, Node *basenode,
List *indirection);
List *indirection);
/*

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.72 2001/09/17 01:06:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.73 2001/09/28 08:09:09 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -462,10 +462,13 @@ FigureColname(Node *node)
{
if (node == NULL)
return "?column?";
switch (nodeTag(node))
{
case T_Ident:
return ((Ident *) node)->name;
case T_A_Const:
return (FigureColname((Node *)((A_Const *) node)->typename));
case T_Attr:
{
List *attrs = ((Attr *) node)->attrs;
@ -481,7 +484,15 @@ FigureColname(Node *node)
case T_FuncCall:
return ((FuncCall *) node)->funcname;
case T_TypeCast:
return FigureColname(((TypeCast *) node)->arg);
{
char *name;
name = FigureColname(((TypeCast *) node)->arg);
if (strcmp(name, "?column?") == 0)
name = FigureColname((Node *)((TypeCast *) node)->typename);
return name;
}
break;
case T_CaseExpr:
{
char *name;
@ -492,6 +503,8 @@ FigureColname(Node *node)
return name;
}
break;
case T_TypeName:
return ((TypeName *) node)->name;
default:
break;
}

View File

@ -8,21 +8,24 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.57 2001/05/03 19:00:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.58 2001/09/28 08:09:10 thomas Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include <ctype.h>
#include <limits.h>
#include <time.h>
#include <float.h>
#include "access/hash.h"
#include "miscadmin.h"
#include "utils/builtins.h"
#include "utils/date.h"
#include "utils/nabstime.h"
#include "utils/timestamp.h"
/*****************************************************************************
@ -58,13 +61,13 @@ date_in(PG_FUNCTION_ARGS)
break;
case DTK_CURRENT:
elog(ERROR, "Date CURRENT no longer supported"
"\n\tdate_in() internal coding error");
GetCurrentTime(tm);
break;
case DTK_EPOCH:
tm->tm_year = 1970;
tm->tm_mon = 1;
tm->tm_mday = 1;
GetEpochTime(tm);
break;
default:
@ -224,6 +227,46 @@ date_timestamp(PG_FUNCTION_ARGS)
{
DateADT dateVal = PG_GETARG_DATEADT(0);
Timestamp result;
/* date is days since 2000, timestamp is seconds since same... */
result = dateVal * 86400.0;
PG_RETURN_TIMESTAMP(result);
}
/* timestamp_date()
* Convert timestamp to date data type.
*/
Datum
timestamp_date(PG_FUNCTION_ARGS)
{
Timestamp timestamp = PG_GETARG_TIMESTAMP(0);
DateADT result;
struct tm tt,
*tm = &tt;
double fsec;
if (TIMESTAMP_NOT_FINITE(timestamp))
PG_RETURN_NULL();
if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL) != 0)
elog(ERROR, "Unable to convert timestamp to date");
result = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - date2j(2000, 1, 1);
PG_RETURN_DATEADT(result);
}
/* date_timestamptz()
* Convert date to timestamp with time zone data type.
*/
Datum
date_timestamptz(PG_FUNCTION_ARGS)
{
DateADT dateVal = PG_GETARG_DATEADT(0);
TimestampTz result;
struct tm tt,
*tm = &tt;
time_t utime;
@ -259,32 +302,25 @@ date_timestamp(PG_FUNCTION_ARGS)
}
/* timestamp_date()
* Convert timestamp to date data type.
/* timestamptz_date()
* Convert timestamp with time zone to date data type.
*/
Datum
timestamp_date(PG_FUNCTION_ARGS)
timestamptz_date(PG_FUNCTION_ARGS)
{
Timestamp timestamp = PG_GETARG_TIMESTAMP(0);
TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
DateADT result;
struct tm tt,
*tm = &tt;
int tz;
double fsec;
int tz;
char *tzn;
if (TIMESTAMP_NOT_FINITE(timestamp))
elog(ERROR, "Unable to convert timestamp to date");
PG_RETURN_NULL();
if (TIMESTAMP_IS_EPOCH(timestamp))
timestamp2tm(SetTimestamp(timestamp), NULL, tm, &fsec, NULL);
else if (TIMESTAMP_IS_CURRENT(timestamp))
timestamp2tm(SetTimestamp(timestamp), &tz, tm, &fsec, &tzn);
else
{
if (timestamp2tm(timestamp, &tz, tm, &fsec, &tzn) != 0)
elog(ERROR, "Unable to convert timestamp to date");
}
if (timestamp2tm(timestamp, &tz, tm, &fsec, &tzn) != 0)
elog(ERROR, "Unable to convert timestamp to date");
result = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - date2j(2000, 1, 1);
@ -316,15 +352,6 @@ abstime_date(PG_FUNCTION_ARGS)
* will be set
*/
case EPOCH_ABSTIME:
result = date2j(1970, 1, 1) - date2j(2000, 1, 1);
break;
case CURRENT_ABSTIME:
GetCurrentTime(tm);
result = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - date2j(2000, 1, 1);
break;
default:
abstime2tm(abstime, &tz, tm, NULL);
result = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - date2j(2000, 1, 1);
@ -664,22 +691,13 @@ timestamp_time(PG_FUNCTION_ARGS)
TimeADT result;
struct tm tt,
*tm = &tt;
int tz;
double fsec;
char *tzn;
if (TIMESTAMP_NOT_FINITE(timestamp))
elog(ERROR, "Unable to convert timestamp to date");
PG_RETURN_NULL();
if (TIMESTAMP_IS_EPOCH(timestamp))
timestamp2tm(SetTimestamp(timestamp), NULL, tm, &fsec, NULL);
else if (TIMESTAMP_IS_CURRENT(timestamp))
timestamp2tm(SetTimestamp(timestamp), &tz, tm, &fsec, &tzn);
else
{
if (timestamp2tm(timestamp, &tz, tm, &fsec, &tzn) != 0)
elog(ERROR, "Unable to convert timestamp to date");
}
if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL) != 0)
elog(ERROR, "Unable to convert timestamp to date");
result = ((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec + fsec);
@ -736,6 +754,24 @@ interval_time(PG_FUNCTION_ARGS)
PG_RETURN_TIMEADT(result);
}
/* time_mi_time()
* Subtract two times to produce an interval.
*/
Datum
time_mi_time(PG_FUNCTION_ARGS)
{
TimeADT time1 = PG_GETARG_TIMEADT(0);
TimeADT time2 = PG_GETARG_TIMEADT(1);
Interval *result;
result = (Interval *) palloc(sizeof(Interval));
result->time = time2 - time1;
result->month = 0;
PG_RETURN_INTERVAL_P(result);
}
/* time_pl_interval()
* Add interval to time.
*/
@ -918,7 +954,12 @@ timetz_cmp_internal(TimeTzADT *time1, TimeTzADT *time2)
* If same GMT time, sort by timezone; we only want to say that two
* timetz's are equal if both the time and zone parts are equal.
*/
return time1->zone - time2->zone;
if (time1->zone > time2->zone)
return 1;
if (time1->zone < time2->zone)
return -1;
return 0;
}
Datum
@ -1199,13 +1240,48 @@ overlaps_timetz(PG_FUNCTION_ARGS)
#undef TIMETZ_LT
}
/* timestamp_timetz()
Datum
timetz_time(PG_FUNCTION_ARGS)
{
TimeTzADT *timetz = PG_GETARG_TIMETZADT_P(0);
TimeADT result;
/* swallow the time zone and just return the time */
result = timetz->time;
PG_RETURN_TIMEADT(result);
}
Datum
time_timetz(PG_FUNCTION_ARGS)
{
TimeADT time = PG_GETARG_TIMEADT(0);
TimeTzADT *result;
struct tm tt,
*tm = &tt;
int tz;
GetCurrentTime(tm);
tz = DetermineLocalTimeZone(tm);
result = (TimeTzADT *) palloc(sizeof(TimeTzADT));
result->time = time;
result->zone = tz;
PG_RETURN_TIMETZADT_P(result);
}
/* timestamptz_timetz()
* Convert timestamp to timetz data type.
*/
Datum
timestamp_timetz(PG_FUNCTION_ARGS)
timestamptz_timetz(PG_FUNCTION_ARGS)
{
Timestamp timestamp = PG_GETARG_TIMESTAMP(0);
TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
TimeTzADT *result;
struct tm tt,
*tm = &tt;
@ -1214,20 +1290,10 @@ timestamp_timetz(PG_FUNCTION_ARGS)
char *tzn;
if (TIMESTAMP_NOT_FINITE(timestamp))
elog(ERROR, "Unable to convert timestamp to date");
PG_RETURN_NULL();
if (TIMESTAMP_IS_EPOCH(timestamp))
{
timestamp2tm(SetTimestamp(timestamp), NULL, tm, &fsec, NULL);
tz = 0;
}
else if (TIMESTAMP_IS_CURRENT(timestamp))
timestamp2tm(SetTimestamp(timestamp), &tz, tm, &fsec, &tzn);
else
{
if (timestamp2tm(timestamp, &tz, tm, &fsec, &tzn) != 0)
elog(ERROR, "Unable to convert timestamp to date");
}
if (timestamp2tm(timestamp, &tz, tm, &fsec, &tzn) != 0)
elog(ERROR, "Unable to convert timestamp to date");
result = (TimeTzADT *) palloc(sizeof(TimeTzADT));
@ -1238,18 +1304,18 @@ timestamp_timetz(PG_FUNCTION_ARGS)
}
/* datetimetz_timestamp()
* Convert date and timetz to timestamp data type.
/* datetimetz_timestamptz()
* Convert date and timetz to timestamp with time zone data type.
* Timestamp is stored in GMT, so add the time zone
* stored with the timetz to the result.
* - thomas 2000-03-10
*/
Datum
datetimetz_timestamp(PG_FUNCTION_ARGS)
datetimetz_timestamptz(PG_FUNCTION_ARGS)
{
DateADT date = PG_GETARG_DATEADT(0);
TimeTzADT *time = PG_GETARG_TIMETZADT_P(1);
Timestamp result;
TimestampTz result;
result = date * 86400.0 + time->time + time->zone;
@ -1310,3 +1376,83 @@ text_timetz(PG_FUNCTION_ARGS)
return DirectFunctionCall1(timetz_in,
CStringGetDatum(dstr));
}
/* timetz_zone()
* Encode time with time zone type with specified time zone.
*/
Datum
timetz_zone(PG_FUNCTION_ARGS)
{
text *zone = PG_GETARG_TEXT_P(0);
TimeTzADT *time = PG_GETARG_TIMETZADT_P(1);
TimeTzADT *result;
TimeADT time1;
int tz;
int type,
val;
int i;
char *up,
*lp,
lowzone[MAXDATELEN + 1];
if (VARSIZE(zone) - VARHDRSZ > MAXDATELEN)
elog(ERROR, "Time zone '%s' not recognized",
DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(zone))));
up = VARDATA(zone);
lp = lowzone;
for (i = 0; i < (VARSIZE(zone) - VARHDRSZ); i++)
*lp++ = tolower((unsigned char) *up++);
*lp = '\0';
type = DecodeSpecial(0, lowzone, &val);
result = (TimeTzADT *) palloc(sizeof(TimeTzADT));
if ((type == TZ) || (type == DTZ))
{
tz = val * 60;
time1 = time->time - time->zone + tz;
TMODULO(result->time, time1, 86400e0);
if (result->time < 0)
result->time += 86400;
result->zone = tz;
}
else
{
elog(ERROR, "Time zone '%s' not recognized", lowzone);
PG_RETURN_NULL();
}
PG_RETURN_TIMETZADT_P(result);
} /* timetz_zone() */
/* timetz_izone()
* Encode time with time zone type with specified time interval as time zone.
*/
Datum
timetz_izone(PG_FUNCTION_ARGS)
{
Interval *zone = PG_GETARG_INTERVAL_P(0);
TimeTzADT *time = PG_GETARG_TIMETZADT_P(1);
TimeTzADT *result;
TimeADT time1;
int tz;
if (zone->month != 0)
elog(ERROR, "INTERVAL time zone '%s' not legal (month specified)",
DatumGetCString(DirectFunctionCall1(interval_out,
PointerGetDatum(zone))));
tz = -(zone->time);
result = (TimeTzADT *) palloc(sizeof(TimeTzADT));
time1 = time->time - time->zone + tz;
TMODULO(result->time, time1, 86400e0);
if (result->time < 0)
result->time += 86400;
result->zone = tz;
PG_RETURN_TIMETZADT_P(result);
} /* timetz_izone() */

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.66 2001/07/10 01:41:47 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.67 2001/09/28 08:09:10 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -29,13 +29,13 @@
#define ROUND_ALL 1
static int DecodeNumber(int flen, char *field,
int fmask, int *tmask,
struct tm * tm, double *fsec, int *is2digits);
int fmask, int *tmask,
struct tm * tm, double *fsec, int *is2digits);
static int DecodeNumberField(int len, char *str,
int fmask, int *tmask,
struct tm * tm, double *fsec, int *is2digits);
int fmask, int *tmask,
struct tm * tm, double *fsec, int *is2digits);
static int DecodeTime(char *str, int fmask, int *tmask,
struct tm * tm, double *fsec);
struct tm * tm, double *fsec);
static int DecodeTimezone(char *str, int *tzp);
static datetkn *datebsearch(char *key, datetkn *base, unsigned int nel);
static int DecodeDate(char *str, int fmask, int *tmask, struct tm * tm);
@ -47,10 +47,10 @@ int day_tab[2][13] = {
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}};
char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL};
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL};
char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday", NULL};
"Thursday", "Friday", "Saturday", NULL};
/*****************************************************************************
@ -71,7 +71,7 @@ char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday",
* the text field is not guaranteed to be NULL-terminated.
*/
static datetkn datetktbl[] = {
/* text token lexval */
/* text, token, lexval */
{EARLY, RESERV, DTK_EARLY}, /* "-infinity" reserved for "early time" */
{"acsst", DTZ, 63}, /* Cent. Australia */
{"acst", TZ, 57}, /* Cent. Australia */
@ -104,6 +104,7 @@ static datetkn datetktbl[] = {
{"cetdst", DTZ, 12}, /* Central European Dayl.Time */
{"cst", TZ, NEG(36)}, /* Central Standard Time */
{DCURRENT, RESERV, DTK_CURRENT}, /* "current" is always now */
{"d", UNITS, DAY}, /* "day of month" for ISO input */
{"dec", MONTH, 12},
{"december", MONTH, 12},
{"dnt", TZ, 6}, /* Dansk Normal Tid */
@ -124,6 +125,7 @@ static datetkn datetktbl[] = {
{"fwt", DTZ, 12}, /* French Winter Time */
{"gmt", TZ, 0}, /* Greenwish Mean Time */
{"gst", TZ, 60}, /* Guam Std Time, USSR Zone 9 */
{"h", UNITS, HOUR}, /* "hour" */
{"hdt", DTZ, NEG(54)}, /* Hawaii/Alaska */
{"hmt", DTZ, 18}, /* Hellas ? ? */
{"hst", TZ, NEG(60)}, /* Hawaii Std Time */
@ -134,16 +136,19 @@ static datetkn datetktbl[] = {
/* "invalid" reserved for invalid time */
{"ist", TZ, 12}, /* Israel */
{"it", TZ, 21}, /* Iran Time */
{"j", UNITS, JULIAN},
{"jan", MONTH, 1},
{"january", MONTH, 1},
{"jd", UNITS, JULIAN},
{"jst", TZ, 54}, /* Japan Std Time,USSR Zone 8 */
{"jt", TZ, 45}, /* Java Time */
{"jul", MONTH, 7},
{"july", MONTH, 7},
{"julian", UNITS, JULIAN},
{"jun", MONTH, 6},
{"june", MONTH, 6},
{"kst", TZ, 54}, /* Korea Standard Time */
{"ligt", TZ, 60}, /* From Melbourne, Australia */
{"m", UNITS, MONTH}, /* "month" for ISO input */
{"mar", MONTH, 3},
{"march", MONTH, 3},
{"may", MONTH, 5},
@ -153,6 +158,7 @@ static datetkn datetktbl[] = {
{"metdst", DTZ, 12}, /* Middle Europe Daylight Time */
{"mewt", TZ, 6}, /* Middle Europe Winter Time */
{"mez", TZ, 6}, /* Middle Europe Zone */
{"mm", UNITS, MINUTE}, /* "minute" for ISO input */
{"mon", DOW, 1},
{"monday", DOW, 1},
{"mst", TZ, NEG(42)}, /* Mountain Standard Time */
@ -174,6 +180,7 @@ static datetkn datetktbl[] = {
{"pdt", DTZ, NEG(42)}, /* Pacific Daylight Time */
{"pm", AMPM, PM},
{"pst", TZ, NEG(48)}, /* Pacific Standard Time */
{"s", UNITS, SECOND}, /* "seconds" for ISO input */
{"sadt", DTZ, 63}, /* S. Australian Dayl. Time */
{"sast", TZ, 57}, /* South Australian Std Time */
{"sat", DOW, 6},
@ -186,6 +193,7 @@ static datetkn datetktbl[] = {
{"sun", DOW, 0},
{"sunday", DOW, 0},
{"swt", TZ, 6}, /* Swedish Winter Time */
{"t", DTK_ISO_TIME, 0}, /* Filler for ISO time fields */
{"thu", DOW, 4},
{"thur", DOW, 4},
{"thurs", DOW, 4},
@ -208,6 +216,7 @@ static datetkn datetktbl[] = {
{"wet", TZ, 0}, /* Western Europe */
{"wetdst", DTZ, 6}, /* Western Europe */
{"wst", TZ, 48}, /* West Australian Std Time */
{"y", UNITS, YEAR}, /* "year" for ISO input */
{"ydt", DTZ, NEG(48)}, /* Yukon Daylight Time */
{YESTERDAY, RESERV, DTK_YESTERDAY}, /* yesterday midnight */
{"yst", TZ, NEG(54)}, /* Yukon Standard Time */
@ -222,7 +231,7 @@ static unsigned int szdatetktbl = sizeof datetktbl / sizeof datetktbl[0];
/* Used for SET australian_timezones to override North American ones */
static datetkn australian_datetktbl[] = {
{"cst", TZ, 63}, /* Australia Eastern Std Time */
{"cst", TZ, 63}, /* Australia Central Std Time */
{"est", TZ, 60}, /* Australia Eastern Std Time */
{"sat", TZ, 57},
};
@ -231,7 +240,7 @@ static unsigned int australian_szdatetktbl = sizeof australian_datetktbl /
sizeof australian_datetktbl[0];
static datetkn deltatktbl[] = {
/* text token lexval */
/* text, token, lexval */
{"@", IGNORE, 0}, /* postgres relative time prefix */
{DAGO, AGO, 0}, /* "ago" indicates negative time offset */
{"c", UNITS, DTK_CENTURY}, /* "century" relative time units */
@ -329,7 +338,8 @@ datetkn *deltacache[MAXDATEFIELDS] = {NULL};
* Use the algorithm by Henry Fliegel, a former NASA/JPL colleague
* now at Aerospace Corp. (hi, Henry!)
*
* These routines will be used by other date/time packages - tgl 97/02/25
* These routines will be used by other date/time packages
* - thomas 97/02/25
*/
int
@ -413,6 +423,7 @@ ParseDateTime(char *timestr, char *lowstr,
if (*cp == ':')
{
ftype[nf] = DTK_TIME;
*lp++ = *cp++;
while (isdigit((unsigned char) *cp) ||
(*cp == ':') || (*cp == '.'))
*lp++ = *cp++;
@ -422,10 +433,20 @@ ParseDateTime(char *timestr, char *lowstr,
else if ((*cp == '-') || (*cp == '/') || (*cp == '.'))
{
ftype[nf] = DTK_DATE;
while (isalnum((unsigned char) *cp) || (*cp == '-') ||
(*cp == '/') || (*cp == '.'))
*lp++ = tolower((unsigned char) *cp++);
*lp++ = *cp++;
/* second field is all digits? then no embedded text month */
if (isdigit((unsigned char) *cp))
{
while (isdigit((unsigned char) *cp) || (*cp == '-') ||
(*cp == '/') || (*cp == '.'))
*lp++ = *cp++;
}
else
{
while (isalnum((unsigned char) *cp) || (*cp == '-') ||
(*cp == '/') || (*cp == '.'))
*lp++ = tolower((unsigned char) *cp++);
}
}
/*
@ -539,7 +560,7 @@ ParseDateTime(char *timestr, char *lowstr,
* Use the system-provided functions to get the current time zone
* if not specified in the input string.
* If the date is outside the time_t system-supported time range,
* then assume GMT time zone. - tgl 97/05/27
* then assume GMT time zone. - thomas 1997/05/27
*/
int
DecodeDateTime(char **field, int *ftype, int nf,
@ -548,6 +569,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
int fmask = 0,
tmask,
type;
int ptype = 0; /* "prefix type" for ISO y2001m02d04 format */
int i;
int flen,
val;
@ -556,13 +578,16 @@ DecodeDateTime(char **field, int *ftype, int nf,
int is2digits = FALSE;
int bc = FALSE;
/* We'll insist on at least all of the date fields,
* but initialize the remaining fields in case they are not
* set later...
*/
*dtype = DTK_DATE;
tm->tm_hour = 0;
tm->tm_min = 0;
tm->tm_sec = 0;
*fsec = 0;
tm->tm_isdst = -1; /* don't know daylight savings time status
* apriori */
tm->tm_isdst = -1; /* don't know daylight savings time status apriori */
if (tzp != NULL)
*tzp = 0;
@ -571,13 +596,32 @@ DecodeDateTime(char **field, int *ftype, int nf,
switch (ftype[i])
{
case DTK_DATE:
/*
* Already have a date? Then this might be a POSIX time
* zone with an embedded dash (e.g. "PST-3" == "EST") -
* thomas 2000-03-15
/* Previous field was a label for "julian date"?
* then this should be a julian date with fractional day...
*/
if ((fmask & DTK_DATE_M) == DTK_DATE_M)
if (ptype == JULIAN)
{
char *cp;
double dt, date, time;
dt = strtod(field[i], &cp);
if (*cp != '\0')
return -1;
time = dt * 86400;
TMODULO(time, date, 86400e0);
j2date((int) date, &tm->tm_year, &tm->tm_mon, &tm->tm_mday);
dt2time(time, &tm->tm_hour, &tm->tm_min, fsec);
tmask = DTK_DATE_M | DTK_TIME_M;
*dtype = DTK_DATE;
}
/* Already have a date? Then this might be a POSIX time
* zone with an embedded dash (e.g. "PST-3" == "EST")
* - thomas 2000-03-15
*/
else if ((fmask & DTK_DATE_M) == DTK_DATE_M)
{
if ((tzp == NULL)
|| (DecodePosixTimezone(field[i], tzp) != 0))
@ -587,15 +631,16 @@ DecodeDateTime(char **field, int *ftype, int nf,
tmask = DTK_M(TZ);
}
else if (DecodeDate(field[i], fmask, &tmask, tm) != 0)
{
return -1;
}
break;
case DTK_TIME:
if (DecodeTime(field[i], fmask, &tmask, tm, fsec) != 0)
return -1;
/*
* check upper limit on hours; other limits checked in
/* Check upper limit on hours; other limits checked in
* DecodeTime()
*/
if (tm->tm_hour > 23)
@ -618,7 +663,8 @@ DecodeDateTime(char **field, int *ftype, int nf,
* PST)
*/
if ((i > 0) && ((fmask & DTK_M(TZ)) != 0)
&& (ftype[i - 1] == DTK_TZ) && (isalpha((unsigned char) *field[i - 1])))
&& (ftype[i - 1] == DTK_TZ)
&& (isalpha((unsigned char) *field[i - 1])))
{
*tzp -= tz;
tmask = 0;
@ -634,21 +680,81 @@ DecodeDateTime(char **field, int *ftype, int nf,
case DTK_NUMBER:
flen = strlen(field[i]);
/* Was this an "ISO date" with embedded field labels?
* An example is "y2001m02d04" - thomas 2001-02-04
*/
if (ptype != 0)
{
char *cp;
int val;
val = strtol(field[i], &cp, 10);
if (*cp != '\0')
return -1;
switch (ptype) {
case YEAR:
tm->tm_year = val;
tmask = DTK_M(ptype);
break;
case MONTH:
tm->tm_mon = val;
tmask = DTK_M(ptype);
break;
case DAY:
tm->tm_mday = val;
tmask = DTK_M(ptype);
break;
case HOUR:
tm->tm_hour = val;
tmask = DTK_M(ptype);
break;
case MINUTE:
tm->tm_min = val;
tmask = DTK_M(ptype);
break;
case SECOND:
tm->tm_sec = val;
tmask = DTK_M(ptype);
break;
case JULIAN:
/* previous field was a label for "julian date"?
* then this is a julian day with no fractional part
* (see DTK_DATE for cases involving fractional parts)
*/
j2date(val, &tm->tm_year, &tm->tm_mon, &tm->tm_mday);
tmask = DTK_DATE_M;
break;
default:
return -1;
break;
}
ptype = 0;
*dtype = DTK_DATE;
}
/*
* long numeric string and either no date or no time read
* yet? then interpret as a concatenated date or time...
*/
if ((flen > 4) && !((fmask & DTK_DATE_M) && (fmask & DTK_TIME_M)))
else if ((flen > 4) && !((fmask & DTK_DATE_M) && (fmask & DTK_TIME_M)))
{
if (DecodeNumberField(flen, field[i], fmask, &tmask, tm, fsec, &is2digits) != 0)
return -1;
}
/* otherwise it is a single date/time field... */
else
else if (DecodeNumber(flen, field[i], fmask, &tmask, tm, fsec, &is2digits) != 0)
{
if (DecodeNumber(flen, field[i], fmask, &tmask, tm, fsec, &is2digits) != 0)
return -1;
return -1;
}
break;
@ -664,10 +770,15 @@ DecodeDateTime(char **field, int *ftype, int nf,
case RESERV:
switch (val)
{
case DTK_CURRENT:
case DTK_NOW:
tmask = (DTK_DATE_M | DTK_TIME_M | DTK_M(TZ));
*dtype = DTK_DATE;
#if NOT_USED
GetCurrentTime(tm);
#else
GetCurrentTimeUsec(tm, fsec);
#endif
if (tzp != NULL)
*tzp = CTimeZone;
break;
@ -786,6 +897,18 @@ DecodeDateTime(char **field, int *ftype, int nf,
tm->tm_wday = val;
break;
case UNITS:
ptype = val;
tmask = 0;
break;
case DTK_ISO_TIME:
if ((i < 1) || (i >= (nf-1))
|| (ftype[i-1] != DTK_DATE)
|| (ftype[i+1] != DTK_TIME))
return -1;
break;
default:
return -1;
}
@ -1182,6 +1305,7 @@ DecodeDate(char *str, int fmask, int *tmask, struct tm * tm)
str++;
}
/* Just get rid of any non-digit, non-alpha characters... */
if (*str != '\0')
*str++ = '\0';
nf++;
@ -1362,8 +1486,9 @@ DecodeNumber(int flen, char *str, int fmask,
/*
* Enough digits to be unequivocal year? Used to test for 4 digits or
* more, but we now test first for a three-digit doy so anything
* bigger than two digits had better be an explicit year. - thomas
* 1999-01-09 Back to requiring a 4 digit year. We accept a two digit
* bigger than two digits had better be an explicit year.
* - thomas 1999-01-09
* Back to requiring a 4 digit year. We accept a two digit
* year farther down. - thomas 2000-03-28
*/
else if (flen >= 4)
@ -1613,7 +1738,7 @@ DecodeSpecial(int field, char *lowtoken, int *val)
datecache[field] = tp;
if (tp == NULL)
{
type = IGNORE;
type = UNKNOWN_FIELD;
*val = 0;
}
else
@ -1747,10 +1872,11 @@ DecodeDateDelta(char **field, int *ftype, int nf, int *dtype, struct tm * tm, do
case DTK_NUMBER:
val = strtol(field[i], &cp, 10);
if (type == IGNORE)
type = DTK_SECOND;
if (*cp == '.')
{
if (type == IGNORE)
type = DTK_SECOND;
fval = strtod(cp, &cp);
if (*cp != '\0')
return -1;
@ -1928,7 +2054,7 @@ DecodeUnits(int field, char *lowtoken, int *val)
deltacache[field] = tp;
if (tp == NULL)
{
type = IGNORE;
type = UNKNOWN_FIELD;
*val = 0;
}
else
@ -1985,8 +2111,8 @@ EncodeDateOnly(struct tm * tm, int style, char *str)
switch (style)
{
/* compatible with ISO date formats */
case USE_ISO_DATES:
/* compatible with ISO date formats */
if (tm->tm_year > 0)
sprintf(str, "%04d-%02d-%02d",
tm->tm_year, tm->tm_mon, tm->tm_mday);
@ -1995,8 +2121,8 @@ EncodeDateOnly(struct tm * tm, int style, char *str)
-(tm->tm_year - 1), tm->tm_mon, tm->tm_mday, "BC");
break;
/* compatible with Oracle/Ingres date formats */
case USE_SQL_DATES:
/* compatible with Oracle/Ingres date formats */
if (EuroDates)
sprintf(str, "%02d/%02d", tm->tm_mday, tm->tm_mon);
else
@ -2007,8 +2133,8 @@ EncodeDateOnly(struct tm * tm, int style, char *str)
sprintf((str + 5), "/%04d %s", -(tm->tm_year - 1), "BC");
break;
/* German-style date format */
case USE_GERMAN_DATES:
/* German-style date format */
sprintf(str, "%02d.%02d", tm->tm_mday, tm->tm_mon);
if (tm->tm_year > 0)
sprintf((str + 5), ".%04d", tm->tm_year);
@ -2016,9 +2142,9 @@ EncodeDateOnly(struct tm * tm, int style, char *str)
sprintf((str + 5), ".%04d %s", -(tm->tm_year - 1), "BC");
break;
/* traditional date-only style for Postgres */
case USE_POSTGRES_DATES:
default:
/* traditional date-only style for Postgres */
if (EuroDates)
sprintf(str, "%02d-%02d", tm->tm_mday, tm->tm_mon);
else

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.15 2001/09/21 15:27:38 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.16 2001/09/28 08:09:10 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -205,6 +205,10 @@ format_type_internal(Oid type_oid, int32 typemod, bool allow_invalid)
break;
case TIMESTAMPOID:
buf = pstrdup("timestamp without time zone");
break;
case TIMESTAMPTZOID:
buf = pstrdup("timestamp with time zone");
break;

View File

@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------
* formatting.c
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.40 2001/09/12 04:01:57 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.41 2001/09/28 08:09:11 thomas Exp $
*
*
* Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group
@ -2753,6 +2753,30 @@ timestamp_to_char(PG_FUNCTION_ARGS)
Timestamp dt = PG_GETARG_TIMESTAMP(0);
text *fmt = PG_GETARG_TEXT_P(1), *res;
TmToChar tmtc;
int r = 0;
if ((VARSIZE(fmt) - VARHDRSZ) <=0 || TIMESTAMP_NOT_FINITE(dt))
PG_RETURN_NULL();
ZERO_tmtc(&tmtc);
r = timestamp2tm(dt, NULL, tmtcTm(&tmtc), &tmtcFsec(&tmtc), NULL);
if (r != 0)
elog(ERROR, "to_char(): Unable to convert timestamp to tm");
if (!(res=datetime_to_char_body(&tmtc, fmt)))
PG_RETURN_NULL();
PG_RETURN_TEXT_P(res);
}
Datum
timestamptz_to_char(PG_FUNCTION_ARGS)
{
TimestampTz dt = PG_GETARG_TIMESTAMP(0);
text *fmt = PG_GETARG_TEXT_P(1), *res;
TmToChar tmtc;
int tz, r = 0;
if ((VARSIZE(fmt) - VARHDRSZ) <=0 || TIMESTAMP_NOT_FINITE(dt))
@ -2760,12 +2784,7 @@ timestamp_to_char(PG_FUNCTION_ARGS)
ZERO_tmtc(&tmtc);
if (TIMESTAMP_IS_EPOCH(dt))
r = timestamp2tm(SetTimestamp(dt), NULL, tmtcTm(&tmtc), &tmtcFsec(&tmtc), NULL);
else if (TIMESTAMP_IS_CURRENT(dt))
r = timestamp2tm(SetTimestamp(dt), &tz, tmtcTm(&tmtc), &tmtcFsec(&tmtc), &tmtcTzn(&tmtc));
else
r = timestamp2tm(dt, &tz, tmtcTm(&tmtc), &tmtcFsec(&tmtc), &tmtcTzn(&tmtc));
r = timestamp2tm(dt, &tz, tmtcTm(&tmtc), &tmtcFsec(&tmtc), &tmtcTzn(&tmtc));
if (r != 0)
elog(ERROR, "to_char(): Unable to convert timestamp to tm");
@ -2805,7 +2824,7 @@ interval_to_char(PG_FUNCTION_ARGS)
/* ---------------------
* TO_TIMESTAMP()
*
* Make Timestamp from date_str which is formated at argument 'fmt'
* Make Timestamp from date_str which is formatted at argument 'fmt'
* ( to_timestamp is reverse to_char() )
* ---------------------
*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

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: xact.h,v 1.36 2001/08/26 16:56:00 tgl Exp $
* $Id: xact.h,v 1.37 2001/09/28 08:09:12 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -17,6 +17,7 @@
#include "access/transam.h"
#include "access/xlog.h"
#include "utils/nabstime.h"
#include "utils/timestamp.h"
/*
* Xact isolation levels
@ -39,6 +40,7 @@ typedef struct TransactionStateData
CommandId commandId;
CommandId scanCommandId;
AbsoluteTime startTime;
int startTimeMsec;
int state;
int blockState;
} TransactionStateData;
@ -104,6 +106,7 @@ extern CommandId GetCurrentCommandId(void);
extern CommandId GetScanCommandId(void);
extern void SetScanCommandId(CommandId);
extern AbsoluteTime GetCurrentTransactionStartTime(void);
extern AbsoluteTime GetCurrentTransactionStartTimeUsec(int *usec);
extern bool TransactionIdIsCurrentTransactionId(TransactionId xid);
extern bool CommandIdIsCurrentCommandId(CommandId cid);
extern bool CommandIdGEScanCommandId(CommandId cid);

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.95 2001/09/14 17:46:40 momjian Exp $
* $Id: catversion.h,v 1.96 2001/09/28 08:09:13 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -53,6 +53,6 @@
*/
/* yyyymmddN */
#define CATALOG_VERSION_NO 200109101
#define CATALOG_VERSION_NO 200109261
#endif

View File

@ -8,10 +8,21 @@
# no multibytes files
FILES=`ls pg_*.h |grep -v '_mb.h'`
#
# The previous version did not use the -d option on uniq
# so check here that it is supported.
# Otherwise, use the old algorithm
#
if [ `uniq -d < /dev/null > /dev/null 2>&1` ]; then
echo "uniq -d is not supported on your platform."
echo "Please report this to pgsql-hackers@postgresql.org"
egrep '^DATA' $FILES | \
sed -e 's/^.*OID[^=]*=[^0-9]*//' -e 's/[^0-9].*$//' | \
sort -n >/tmp/alloids.$$
uniq /tmp/alloids.$$ >/tmp/uniqoids.$$
diff -u /tmp/alloids.$$ /tmp/uniqoids.$$ | \
grep -v '/tmp/' | \
grep '^-' | \
@ -21,3 +32,16 @@ diff -u /tmp/alloids.$$ /tmp/uniqoids.$$ | \
rm /tmp/alloids.$$
rm /tmp/uniqoids.$$
else
# echo "uniq -d is supported on this platform."
# echo "Will omit the use of temporary files."
egrep '^DATA' $FILES | \
sed -e 's/^.*OID[^=]*=[^0-9]*//' -e 's/[^0-9].*$//' | \
sort -n | uniq -d | \
egrep -v '^[0]*$'
fi
exit

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_aggregate.h,v 1.31 2001/08/14 22:21:58 tgl Exp $
* $Id: pg_aggregate.h,v 1.32 2001/09/28 08:09:13 thomas Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@ -109,7 +109,8 @@ DATA(insert OID = 0 ( max PGUID date_larger - 1082 1082 1082 _null_ ));
DATA(insert OID = 0 ( max PGUID time_larger - 1083 1083 1083 _null_ ));
DATA(insert OID = 0 ( max PGUID timetz_larger - 1266 1266 1266 _null_ ));
DATA(insert OID = 0 ( max PGUID cashlarger - 790 790 790 _null_ ));
DATA(insert OID = 0 ( max PGUID timestamp_larger - 1184 1184 1184 _null_ ));
DATA(insert OID = 0 ( max PGUID timestamp_larger - 1114 1114 1114 _null_ ));
DATA(insert OID = 0 ( max PGUID timestamptz_larger - 1184 1184 1184 _null_ ));
DATA(insert OID = 0 ( max PGUID interval_larger - 1186 1186 1186 _null_ ));
DATA(insert OID = 0 ( max PGUID text_larger - 25 25 25 _null_ ));
DATA(insert OID = 0 ( max PGUID numeric_larger - 1700 1700 1700 _null_ ));
@ -125,7 +126,8 @@ DATA(insert OID = 0 ( min PGUID date_smaller - 1082 1082 1082 _null_ ));
DATA(insert OID = 0 ( min PGUID time_smaller - 1083 1083 1083 _null_ ));
DATA(insert OID = 0 ( min PGUID timetz_smaller - 1266 1266 1266 _null_ ));
DATA(insert OID = 0 ( min PGUID cashsmaller - 790 790 790 _null_ ));
DATA(insert OID = 0 ( min PGUID timestamp_smaller - 1184 1184 1184 _null_ ));
DATA(insert OID = 0 ( min PGUID timestamp_smaller - 1114 1114 1114 _null_ ));
DATA(insert OID = 0 ( min PGUID timestamptz_smaller - 1184 1184 1184 _null_ ));
DATA(insert OID = 0 ( min PGUID interval_smaller - 1186 1186 1186 _null_ ));
DATA(insert OID = 0 ( min PGUID text_smaller - 25 25 25 _null_ ));
DATA(insert OID = 0 ( min PGUID numeric_smaller - 1700 1700 1700 _null_ ));

View File

@ -16,7 +16,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_amop.h,v 1.41 2001/08/21 16:36:05 tgl Exp $
* $Id: pg_amop.h,v 1.42 2001/09/28 08:09:13 thomas Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@ -282,6 +282,16 @@ DATA(insert ( 2000 5 f 1554 ));
* btree timestamp_ops
*/
DATA(insert ( 2039 1 f 2062 ));
DATA(insert ( 2039 2 f 2063 ));
DATA(insert ( 2039 3 f 2060 ));
DATA(insert ( 2039 4 f 2065 ));
DATA(insert ( 2039 5 f 2064 ));
/*
* btree timestamptz_ops
*/
DATA(insert ( 1998 1 f 1322 ));
DATA(insert ( 1998 2 f 1323 ));
DATA(insert ( 1998 3 f 1320 ));
@ -407,11 +417,13 @@ DATA(insert ( 1992 1 f 649 ));
DATA(insert ( 1995 1 f 98 ));
/* time_ops */
DATA(insert ( 1997 1 f 1108 ));
/* timestamp_ops */
/* timestamptz_ops */
DATA(insert ( 1999 1 f 1320 ));
/* timetz_ops */
DATA(insert ( 2001 1 f 1550 ));
/* varchar_ops */
DATA(insert ( 2004 1 f 1062 ));
/* timestamp_ops */
DATA(insert ( 2040 1 f 2060 ));
#endif /* PG_AMOP_H */

View File

@ -14,7 +14,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_amproc.h,v 1.30 2001/08/21 16:36:05 tgl Exp $
* $Id: pg_amproc.h,v 1.31 2001/09/28 08:09:13 thomas Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@ -104,6 +104,7 @@ DATA(insert ( 1998 1 1314 ));
DATA(insert ( 2000 1 1358 ));
DATA(insert ( 2002 1 1672 ));
DATA(insert ( 2003 1 1079 ));
DATA(insert ( 2039 1 1314 ));
/* hash */
@ -127,5 +128,6 @@ DATA(insert ( 1997 1 452 ));
DATA(insert ( 1999 1 452 ));
DATA(insert ( 2001 1 1696 ));
DATA(insert ( 2004 1 456 ));
DATA(insert ( 2040 1 452 ));
#endif /* PG_AMPROC_H */

View File

@ -26,7 +26,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_opclass.h,v 1.39 2001/08/21 16:36:05 tgl Exp $
* $Id: pg_opclass.h,v 1.40 2001/09/28 08:09:13 thomas Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@ -127,12 +127,14 @@ DATA(insert OID = 1994 ( 403 text_ops 25 t 0 ));
DATA(insert OID = 1995 ( 405 text_ops 25 t 0 ));
DATA(insert OID = 1996 ( 403 time_ops 1083 t 0 ));
DATA(insert OID = 1997 ( 405 time_ops 1083 t 0 ));
DATA(insert OID = 1998 ( 403 timestamp_ops 1184 t 0 ));
DATA(insert OID = 1999 ( 405 timestamp_ops 1184 t 0 ));
DATA(insert OID = 1998 ( 403 timestamptz_ops 1184 t 0 ));
DATA(insert OID = 1999 ( 405 timestamptz_ops 1184 t 0 ));
DATA(insert OID = 2000 ( 403 timetz_ops 1266 t 0 ));
DATA(insert OID = 2001 ( 405 timetz_ops 1266 t 0 ));
DATA(insert OID = 2002 ( 403 varbit_ops 1562 t 0 ));
DATA(insert OID = 2003 ( 403 varchar_ops 1043 t 0 ));
DATA(insert OID = 2004 ( 405 varchar_ops 1043 t 0 ));
DATA(insert OID = 2039 ( 403 timestamp_ops 1114 t 0 ));
DATA(insert OID = 2040 ( 405 timestamp_ops 1114 t 0 ));
#endif /* PG_OPCLASS_H */

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_operator.h,v 1.93 2001/09/14 17:46:40 momjian Exp $
* $Id: pg_operator.h,v 1.94 2001/09/28 08:09:13 thomas Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@ -483,14 +483,16 @@ DATA(insert OID = 1110 ( "<" PGUID 0 b t f 1083 1083 16 1112 1113 0 0 time_
DATA(insert OID = 1111 ( "<=" PGUID 0 b t f 1083 1083 16 1113 1112 0 0 time_le scalarltsel scalarltjoinsel ));
DATA(insert OID = 1112 ( ">" PGUID 0 b t f 1083 1083 16 1110 1111 0 0 time_gt scalargtsel scalargtjoinsel ));
DATA(insert OID = 1113 ( ">=" PGUID 0 b t f 1083 1083 16 1111 1110 0 0 time_ge scalargtsel scalargtjoinsel ));
DATA(insert OID = 1269 ( "-" PGUID 0 b t f 1186 1083 1083 0 0 0 0 interval_mi_time - - ));
/* timetz operators */
DATA(insert OID = 1550 ( "=" PGUID 0 b t f 1266 1266 16 1550 1551 1552 1552 timetz_eq eqsel eqjoinsel ));
DATA(insert OID = 1551 ( "<>" PGUID 0 b t f 1266 1266 16 1551 1550 0 0 timetz_ne neqsel neqjoinsel ));
DATA(insert OID = 1552 ( "<" PGUID 0 b t f 1266 1266 16 1554 1555 0 0 timetz_lt scalarltsel scalarltjoinsel ));
DATA(insert OID = 1553 ( "<=" PGUID 0 b t f 1266 1266 16 1555 1554 0 0 timetz_le scalarltsel scalarltjoinsel ));
DATA(insert OID = 1554 ( ">" PGUID 0 b t f 1266 1266 16 1552 1553 0 0 timetz_gt scalargtsel scalargtjoinsel ));
DATA(insert OID = 1555 ( ">=" PGUID 0 b t f 1266 1266 16 1553 1552 0 0 timetz_ge scalargtsel scalargtjoinsel ));
DATA(insert OID = 1295 ( "-" PGUID 0 b t f 1186 1266 1266 0 0 0 0 interval_mi_timetz - - ));
DATA(insert OID = 1550 ( "=" PGUID 0 b t f 1266 1266 16 1550 1551 1552 1552 timetz_eq eqsel eqjoinsel ));
DATA(insert OID = 1551 ( "<>" PGUID 0 b t f 1266 1266 16 1551 1550 0 0 timetz_ne neqsel neqjoinsel ));
DATA(insert OID = 1552 ( "<" PGUID 0 b t f 1266 1266 16 1554 1555 0 0 timetz_lt scalarltsel scalarltjoinsel ));
DATA(insert OID = 1553 ( "<=" PGUID 0 b t f 1266 1266 16 1555 1554 0 0 timetz_le scalarltsel scalarltjoinsel ));
DATA(insert OID = 1554 ( ">" PGUID 0 b t f 1266 1266 16 1552 1553 0 0 timetz_gt scalargtsel scalargtjoinsel ));
DATA(insert OID = 1555 ( ">=" PGUID 0 b t f 1266 1266 16 1553 1552 0 0 timetz_ge scalargtsel scalargtjoinsel ));
/* float48 operators */
DATA(insert OID = 1116 ( "+" PGUID 0 b t f 700 701 701 1126 0 0 0 float48pl - - ));
@ -551,7 +553,7 @@ DATA(insert OID = 1234 ( "~*" PGUID 0 b t f 1042 25 16 0 1235 0 0 texticreg
#define OID_BPCHAR_ICREGEXEQ_OP 1234
DATA(insert OID = 1235 ( "!~*" PGUID 0 b t f 1042 25 16 0 1234 0 0 texticregexne icregexnesel icregexnejoinsel ));
/* timestamp operators */
/* timestamptz operators */
/* name, owner, prec, kind, isleft, canhash, left, right, result, com, negate, lsortop, rsortop, oprcode, operrest, oprjoin */
DATA(insert OID = 1320 ( "=" PGUID 0 b t f 1184 1184 16 1320 1321 1322 1322 timestamp_eq eqsel eqjoinsel ));
DATA(insert OID = 1321 ( "<>" PGUID 0 b t f 1184 1184 16 1321 1320 0 0 timestamp_ne neqsel neqjoinsel ));
@ -559,9 +561,9 @@ DATA(insert OID = 1322 ( "<" PGUID 0 b t f 1184 1184 16 1324 1325 0 0 times
DATA(insert OID = 1323 ( "<=" PGUID 0 b t f 1184 1184 16 1325 1324 0 0 timestamp_le scalarltsel scalarltjoinsel ));
DATA(insert OID = 1324 ( ">" PGUID 0 b t f 1184 1184 16 1322 1323 0 0 timestamp_gt scalargtsel scalargtjoinsel ));
DATA(insert OID = 1325 ( ">=" PGUID 0 b t f 1184 1184 16 1323 1322 0 0 timestamp_ge scalargtsel scalargtjoinsel ));
DATA(insert OID = 1327 ( "+" PGUID 0 b t f 1184 1186 1184 0 0 0 0 timestamp_pl_span - - ));
DATA(insert OID = 1328 ( "-" PGUID 0 b t f 1184 1184 1186 0 0 0 0 timestamp_mi - - ));
DATA(insert OID = 1329 ( "-" PGUID 0 b t f 1184 1186 1184 0 0 0 0 timestamp_mi_span - - ));
DATA(insert OID = 1327 ( "+" PGUID 0 b t f 1184 1186 1184 0 0 0 0 timestamptz_pl_span - - ));
DATA(insert OID = 1328 ( "-" PGUID 0 b t f 1184 1184 1186 0 0 0 0 timestamptz_mi - - ));
DATA(insert OID = 1329 ( "-" PGUID 0 b t f 1184 1186 1184 0 0 0 0 timestamptz_mi_span - - ));
/* interval operators */
DATA(insert OID = 1330 ( "=" PGUID 0 b t f 1186 1186 16 1330 1331 1332 1332 interval_eq eqsel eqjoinsel ));
@ -575,11 +577,13 @@ DATA(insert OID = 1336 ( "-" PGUID 0 l t f 0 1186 1186 0 0 0 0 interval_u
DATA(insert OID = 1337 ( "+" PGUID 0 b t f 1186 1186 1186 1337 0 0 0 interval_pl - - ));
DATA(insert OID = 1338 ( "-" PGUID 0 b t f 1186 1186 1186 0 0 0 0 interval_mi - - ));
DATA(insert OID = 1360 ( "+" PGUID 0 b t f 1082 1083 1184 0 0 0 0 datetime_pl - - ));
DATA(insert OID = 1360 ( "+" PGUID 0 b t f 1082 1083 1114 0 0 0 0 datetime_pl - - ));
DATA(insert OID = 1361 ( "+" PGUID 0 b t f 1082 1266 1184 0 0 0 0 datetimetz_pl - - ));
DATA(insert OID = 1363 ( "+" PGUID 0 b t f 1083 1082 1184 0 0 0 0 timedate_pl - - ));
DATA(insert OID = 1363 ( "+" PGUID 0 b t f 1083 1082 1114 0 0 0 0 timedate_pl - - ));
DATA(insert OID = 1366 ( "+" PGUID 0 b t f 1266 1082 1184 0 0 0 0 timetzdate_pl - - ));
DATA(insert OID = 1399 ( "-" PGUID 0 b t f 1083 1083 1186 0 0 0 0 time_mi_time - - ));
/* additional geometric operators - thomas 97/04/18 */
DATA(insert OID = 1420 ( "@@" PGUID 0 l t f 0 718 600 0 0 0 0 circle_center - - ));
DATA(insert OID = 1500 ( "=" PGUID 0 b t f 718 718 16 1500 1501 1502 1502 circle_eq eqsel eqjoinsel ));
@ -821,6 +825,19 @@ DATA(insert OID = 2016 ( "~~" PGUID 0 b t f 17 17 16 0 2017 0 0 bytea
DATA(insert OID = 2017 ( "!~~" PGUID 0 b t f 17 17 16 0 2016 0 0 byteanlike nlikesel nlikejoinsel ));
DATA(insert OID = 2018 ( "||" PGUID 0 b t f 17 17 17 0 0 0 0 byteacat - - ));
/* timestamp operators */
/* name, owner, prec, kind, isleft, canhash, left, right, result, com, negate, lsortop, rsortop, oprcode, operrest, oprjoin */
DATA(insert OID = 2060 ( "=" PGUID 0 b t f 1114 1114 16 2060 2061 2062 2062 timestamp_eq eqsel eqjoinsel ));
DATA(insert OID = 2061 ( "<>" PGUID 0 b t f 1114 1114 16 2061 2060 0 0 timestamp_ne neqsel neqjoinsel ));
DATA(insert OID = 2062 ( "<" PGUID 0 b t f 1114 1114 16 2064 2065 0 0 timestamp_lt scalarltsel scalarltjoinsel ));
DATA(insert OID = 2063 ( "<=" PGUID 0 b t f 1114 1114 16 2065 2064 0 0 timestamp_le scalarltsel scalarltjoinsel ));
DATA(insert OID = 2064 ( ">" PGUID 0 b t f 1114 1114 16 2062 2063 0 0 timestamp_gt scalargtsel scalargtjoinsel ));
DATA(insert OID = 2065 ( ">=" PGUID 0 b t f 1114 1114 16 2063 2062 0 0 timestamp_ge scalargtsel scalargtjoinsel ));
DATA(insert OID = 2066 ( "+" PGUID 0 b t f 1114 1186 1114 0 0 0 0 timestamp_pl_span - - ));
DATA(insert OID = 2067 ( "-" PGUID 0 b t f 1114 1114 1186 0 0 0 0 timestamp_mi - - ));
DATA(insert OID = 2068 ( "-" PGUID 0 b t f 1114 1186 1114 0 0 0 0 timestamp_mi_span - - ));
/*
* function prototypes
*/

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_type.h,v 1.111 2001/09/06 02:07:42 tgl Exp $
* $Id: pg_type.h,v 1.112 2001/09/28 08:09:14 thomas Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@ -395,12 +395,16 @@ DESCR("hh:mm:ss, ANSI SQL time");
#define TIMEOID 1083
/* OIDS 1100 - 1199 */
DATA(insert OID = 1114 ( timestamp PGUID 8 47 f b t \054 0 0 timestamp_in timestamp_out timestamp_in timestamp_out d p _null_ ));
DESCR("date and time");
#define TIMESTAMPOID 1114
DATA(insert OID = 1115 ( _timestamp PGUID -1 -1 f b t \054 0 1184 array_in array_out array_in array_out d x _null_ ));
DATA(insert OID = 1182 ( _date PGUID -1 -1 f b t \054 0 1082 array_in array_out array_in array_out i x _null_ ));
DATA(insert OID = 1183 ( _time PGUID -1 -1 f b t \054 0 1083 array_in array_out array_in array_out d x _null_ ));
DATA(insert OID = 1184 ( timestamp PGUID 8 47 f b t \054 0 0 timestamp_in timestamp_out timestamp_in timestamp_out d p _null_ ));
DESCR("date and time");
#define TIMESTAMPOID 1184
DATA(insert OID = 1185 ( _timestamp PGUID -1 -1 f b t \054 0 1184 array_in array_out array_in array_out d x _null_ ));
DATA(insert OID = 1184 ( timestamptz PGUID 8 47 f b t \054 0 0 timestamptz_in timestamptz_out timestamptz_in timestamptz_out d p _null_ ));
DESCR("date and time with time zone");
#define TIMESTAMPTZOID 1184
DATA(insert OID = 1185 ( _timestamptz PGUID -1 -1 f b t \054 0 1184 array_in array_out array_in array_out d x _null_ ));
DATA(insert OID = 1186 ( interval PGUID 12 47 f b t \054 0 0 interval_in interval_out interval_in interval_out d p _null_ ));
DESCR("@ <number> <units>, time interval");
#define INTERVALOID 1186

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: builtins.h,v 1.164 2001/09/14 17:46:40 momjian Exp $
* $Id: builtins.h,v 1.165 2001/09/28 08:09:14 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -16,7 +16,7 @@
#include "fmgr.h"
#include "nodes/primnodes.h"
#include "storage/itemptr.h" /* for setLastTid() */
/*
* Defined in adt/
@ -345,6 +345,7 @@ extern char *deparse_expression(Node *expr, List *dpcontext,
extern List *deparse_context_for(char *relname, Oid relid);
/* tid.c */
extern void setLastTid(const ItemPointer tid);
extern Datum tidin(PG_FUNCTION_ARGS);
extern Datum tidout(PG_FUNCTION_ARGS);
extern Datum tideq(PG_FUNCTION_ARGS);

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.11 2001/03/22 04:01:11 momjian Exp $
* $Id: date.h,v 1.12 2001/09/28 08:09:14 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -68,6 +68,8 @@ extern Datum date_pli(PG_FUNCTION_ARGS);
extern Datum date_mii(PG_FUNCTION_ARGS);
extern Datum date_timestamp(PG_FUNCTION_ARGS);
extern Datum timestamp_date(PG_FUNCTION_ARGS);
extern Datum date_timestamptz(PG_FUNCTION_ARGS);
extern Datum timestamptz_date(PG_FUNCTION_ARGS);
extern Datum datetime_timestamp(PG_FUNCTION_ARGS);
extern Datum abstime_date(PG_FUNCTION_ARGS);
extern Datum text_date(PG_FUNCTION_ARGS);
@ -85,6 +87,7 @@ extern Datum time_cmp(PG_FUNCTION_ARGS);
extern Datum overlaps_time(PG_FUNCTION_ARGS);
extern Datum time_larger(PG_FUNCTION_ARGS);
extern Datum time_smaller(PG_FUNCTION_ARGS);
extern Datum time_mi_time(PG_FUNCTION_ARGS);
extern Datum timestamp_time(PG_FUNCTION_ARGS);
extern Datum time_interval(PG_FUNCTION_ARGS);
extern Datum interval_time(PG_FUNCTION_ARGS);
@ -107,10 +110,14 @@ extern Datum timetz_hash(PG_FUNCTION_ARGS);
extern Datum overlaps_timetz(PG_FUNCTION_ARGS);
extern Datum timetz_larger(PG_FUNCTION_ARGS);
extern Datum timetz_smaller(PG_FUNCTION_ARGS);
extern Datum timestamp_timetz(PG_FUNCTION_ARGS);
extern Datum datetimetz_timestamp(PG_FUNCTION_ARGS);
extern Datum timetz_time(PG_FUNCTION_ARGS);
extern Datum time_timetz(PG_FUNCTION_ARGS);
extern Datum timestamptz_timetz(PG_FUNCTION_ARGS);
extern Datum datetimetz_timestamptz(PG_FUNCTION_ARGS);
extern Datum text_timetz(PG_FUNCTION_ARGS);
extern Datum timetz_text(PG_FUNCTION_ARGS);
extern Datum timetz_zone(PG_FUNCTION_ARGS);
extern Datum timetz_izone(PG_FUNCTION_ARGS);
extern Datum timetz_pl_interval(PG_FUNCTION_ARGS);
extern Datum timetz_mi_interval(PG_FUNCTION_ARGS);

View File

@ -9,7 +9,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: datetime.h,v 1.21 2001/08/27 20:02:10 tgl Exp $
* $Id: datetime.h,v 1.22 2001/09/28 08:09:14 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -86,7 +86,7 @@
#define MONTH 1
#define YEAR 2
#define DAY 3
#define TIMES 4 /* not used - thomas 1997-07-14 */
#define JULIAN 4
#define TZ 5
#define DTZ 6
#define DTZMOD 7
@ -103,6 +103,8 @@
#define AGO 17
#define ABS_BEFORE 18
#define ABS_AFTER 19
/* reserved for unrecognized string values */
#define UNKNOWN_FIELD 31
/*
* Token field definitions for time parsing and decoding.
@ -149,12 +151,17 @@
#define DTK_MILLENNIUM 28
#define DTK_MILLISEC 29
#define DTK_MICROSEC 30
#define DTK_JULIAN 31
#define DTK_DOW 32
#define DTK_DOY 33
#define DTK_TZ_HOUR 34
#define DTK_TZ_MINUTE 35
#define DTK_ISO_DATE 36
#define DTK_ISO_TIME 37
/*
* Bit mask definitions for time parsing.
*/
@ -238,6 +245,7 @@ extern int day_tab[2][13];
extern void GetCurrentTime(struct tm * tm);
extern void GetCurrentTimeUsec(struct tm * tm, double *fsec);
extern void j2date(int jd, int *year, int *month, int *day);
extern int date2j(int year, int month, int day);

View File

@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------
* formatting.h
*
* $Id: formatting.h,v 1.8 2001/09/06 03:22:42 momjian Exp $
* $Id: formatting.h,v 1.9 2001/09/28 08:09:14 thomas Exp $
*
*
* Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group
@ -22,6 +22,7 @@
extern Datum timestamp_to_char(PG_FUNCTION_ARGS);
extern Datum timestamptz_to_char(PG_FUNCTION_ARGS);
extern Datum interval_to_char(PG_FUNCTION_ARGS);
extern Datum to_timestamp(PG_FUNCTION_ARGS);
extern Datum to_date(PG_FUNCTION_ARGS);

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: nabstime.h,v 1.30 2001/05/03 19:00:37 tgl Exp $
* $Id: nabstime.h,v 1.31 2001/09/28 08:09:14 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -74,11 +74,8 @@ typedef TimeIntervalData *TimeInterval;
* These were chosen as special 32-bit bit patterns,
* so redefine them explicitly using these bit patterns. - tgl 97/02/24
*/
#define EPOCH_ABSTIME ((AbsoluteTime) 0)
#define INVALID_ABSTIME ((AbsoluteTime) 0x7FFFFFFE) /* 2147483647 (2^31 - 1) */
#define CURRENT_ABSTIME ((AbsoluteTime) 0x7FFFFFFD) /* 2147483646 (2^31 - 2) */
#define NOEND_ABSTIME ((AbsoluteTime) 0x7FFFFFFC) /* 2147483645 (2^31 - 3) */
#define BIG_ABSTIME ((AbsoluteTime) 0x7FFFFFFB) /* 2147483644 (2^31 - 4) */
#define NOSTART_ABSTIME ((AbsoluteTime) INT_MIN) /* -2147483648 */
#define INVALID_RELTIME ((RelativeTime) 0x7FFFFFFE) /* 2147483647 (2^31 - 1) */
@ -116,6 +113,8 @@ extern Datum abstime_finite(PG_FUNCTION_ARGS);
extern Datum timestamp_abstime(PG_FUNCTION_ARGS);
extern Datum abstime_timestamp(PG_FUNCTION_ARGS);
extern Datum timestamptz_abstime(PG_FUNCTION_ARGS);
extern Datum abstime_timestamptz(PG_FUNCTION_ARGS);
extern Datum reltimein(PG_FUNCTION_ARGS);
extern Datum reltimeout(PG_FUNCTION_ARGS);
@ -158,6 +157,7 @@ extern Datum timeofday(PG_FUNCTION_ARGS);
/* non-fmgr-callable support routines */
extern AbsoluteTime GetCurrentAbsoluteTime(void);
extern AbsoluteTime GetCurrentAbsoluteTimeUsec(int *usec);
extern void abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char *tzn);
#endif /* NABSTIME_H */

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.17 2001/09/06 03:22:42 momjian Exp $
* $Id: timestamp.h,v 1.18 2001/09/28 08:09:14 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -33,12 +33,12 @@
typedef double Timestamp;
typedef double TimestampTz;
typedef struct
{
double time; /* all time units other than months and
* years */
int32 month; /* months and years, after time for
* alignment */
double time; /* all time units other than months and years */
int32 month; /* months and years, after time for alignment */
} Interval;
@ -49,23 +49,22 @@ typedef struct
* Therefore Timestamp is pass-by-reference if and only if float8 is!
*/
#define DatumGetTimestamp(X) ((Timestamp) DatumGetFloat8(X))
#define DatumGetTimestampTz(X) ((Timestamp) DatumGetFloat8(X))
#define DatumGetIntervalP(X) ((Interval *) DatumGetPointer(X))
#define TimestampGetDatum(X) Float8GetDatum(X)
#define IntervalPGetDatum(X) PointerGetDatum(X)
#define TimestampGetDatum(X) Float8GetDatum(X)
#define TimestampTzGetDatum(X) Float8GetDatum(X)
#define IntervalPGetDatum(X) PointerGetDatum(X)
#define PG_GETARG_TIMESTAMP(n) DatumGetTimestamp(PG_GETARG_DATUM(n))
#define PG_GETARG_TIMESTAMP(n) DatumGetTimestamp(PG_GETARG_DATUM(n))
#define PG_GETARG_TIMESTAMPTZ(n) DatumGetTimestampTz(PG_GETARG_DATUM(n))
#define PG_GETARG_INTERVAL_P(n) DatumGetIntervalP(PG_GETARG_DATUM(n))
#define PG_RETURN_TIMESTAMP(x) return TimestampGetDatum(x)
#define PG_RETURN_TIMESTAMP(x) return TimestampGetDatum(x)
#define PG_RETURN_TIMESTAMPTZ(x) return TimestampTzGetDatum(x)
#define PG_RETURN_INTERVAL_P(x) return IntervalPGetDatum(x)
#ifdef NAN
#define DT_INVALID (NAN)
#else
#define DT_INVALID (DBL_MIN+DBL_MIN)
#endif
#ifdef HUGE_VAL
#define DT_NOBEGIN (-HUGE_VAL)
#define DT_NOEND (HUGE_VAL)
@ -73,15 +72,6 @@ typedef struct
#define DT_NOBEGIN (-DBL_MAX)
#define DT_NOEND (DBL_MAX)
#endif
#define DT_CURRENT (DBL_MIN)
#define DT_EPOCH (-DBL_MIN)
#define TIMESTAMP_INVALID(j) do {j = DT_INVALID;} while (0)
#ifdef NAN
#define TIMESTAMP_IS_INVALID(j) (isnan(j))
#else
#define TIMESTAMP_IS_INVALID(j) ((j) == DT_INVALID)
#endif
#define TIMESTAMP_NOBEGIN(j) do {j = DT_NOBEGIN;} while (0)
#define TIMESTAMP_IS_NOBEGIN(j) ((j) == DT_NOBEGIN)
@ -89,24 +79,7 @@ typedef struct
#define TIMESTAMP_NOEND(j) do {j = DT_NOEND;} while (0)
#define TIMESTAMP_IS_NOEND(j) ((j) == DT_NOEND)
#define TIMESTAMP_CURRENT(j) do {j = DT_CURRENT;} while (0)
#define TIMESTAMP_IS_CURRENT(j) ((j) == DT_CURRENT)
#define TIMESTAMP_EPOCH(j) do {j = DT_EPOCH;} while (0)
#define TIMESTAMP_IS_EPOCH(j) ((j) == DT_EPOCH)
#define TIMESTAMP_IS_RELATIVE(j) (TIMESTAMP_IS_CURRENT(j) || TIMESTAMP_IS_EPOCH(j))
#define TIMESTAMP_NOT_FINITE(j) (TIMESTAMP_IS_INVALID(j) \
|| TIMESTAMP_IS_NOBEGIN(j) || TIMESTAMP_IS_NOEND(j))
#define TIMESTAMP_IS_RESERVED(j) (TIMESTAMP_IS_RELATIVE(j) || TIMESTAMP_NOT_FINITE(j))
#define INTERVAL_INVALID(j) do {(j).time = DT_INVALID;} while (0)
#ifdef NAN
#define INTERVAL_IS_INVALID(j) (isnan((j).time))
#else
#define INTERVAL_IS_INVALID(j) ((j).time == DT_INVALID)
#endif
#define INTERVAL_NOT_FINITE(j) INTERVAL_IS_INVALID(j)
#define TIMESTAMP_NOT_FINITE(j) (TIMESTAMP_IS_NOBEGIN(j) || TIMESTAMP_IS_NOEND(j))
#define TIME_PREC_INV 1000000.0
#define JROUND(j) (rint(((double) (j))*TIME_PREC_INV)/TIME_PREC_INV)
@ -153,6 +126,14 @@ extern Datum timestamp_part(PG_FUNCTION_ARGS);
extern Datum interval_part(PG_FUNCTION_ARGS);
extern Datum timestamp_zone(PG_FUNCTION_ARGS);
extern Datum timestamp_izone(PG_FUNCTION_ARGS);
extern Datum timestamp_timestamptz(PG_FUNCTION_ARGS);
extern Datum timestamptz_in(PG_FUNCTION_ARGS);
extern Datum timestamptz_out(PG_FUNCTION_ARGS);
extern Datum timestamptz_timestamp(PG_FUNCTION_ARGS);
extern Datum timestamptz_zone(PG_FUNCTION_ARGS);
extern Datum timestamptz_izone(PG_FUNCTION_ARGS);
extern Datum timestamptz_timestamptz(PG_FUNCTION_ARGS);
extern Datum interval_um(PG_FUNCTION_ARGS);
extern Datum interval_pl(PG_FUNCTION_ARGS);
@ -169,18 +150,28 @@ extern Datum timestamp_mi_span(PG_FUNCTION_ARGS);
extern Datum timestamp_age(PG_FUNCTION_ARGS);
extern Datum overlaps_timestamp(PG_FUNCTION_ARGS);
extern Datum timestamptz_text(PG_FUNCTION_ARGS);
extern Datum text_timestamptz(PG_FUNCTION_ARGS);
extern Datum timestamptz_pl_span(PG_FUNCTION_ARGS);
extern Datum timestamptz_mi_span(PG_FUNCTION_ARGS);
extern Datum timestamptz_age(PG_FUNCTION_ARGS);
extern Datum timestamptz_trunc(PG_FUNCTION_ARGS);
extern Datum timestamptz_part(PG_FUNCTION_ARGS);
extern Datum now(PG_FUNCTION_ARGS);
/* Internal routines (not fmgr-callable) */
extern int tm2timestamp(struct tm * tm, double fsec, int *tzp, Timestamp *dt);
extern int timestamp2tm(Timestamp dt, int *tzp, struct tm * tm,
double *fsec, char **tzn);
extern int timestamp2tm(Timestamp dt, int *tzp, struct tm * tm,
double *fsec, char **tzn);
extern void dt2time(Timestamp dt, int *hour, int *min, double *sec);
extern int interval2tm(Interval span, struct tm * tm, float8 *fsec);
extern int tm2interval(struct tm * tm, double fsec, Interval *span);
extern Timestamp SetTimestamp(Timestamp timestamp);
extern Timestamp SetEpochTimestamp(void);
extern void GetEpochTime(struct tm * tm);
extern void isoweek2date(int woy, int *year, int *mon, int *mday);
extern int date2isoweek(int year, int mon, int mday);