Commit 41f1f5b7 authored by Thomas G. Lockhart's avatar Thomas G. Lockhart

Implement "date/time grand unification".

 Transform datetime and timespan into timestamp and interval.
 Deprecate datetime and timespan, though translate to new types in gram.y.
 Transform all datetime and timespan catalog entries into new types.
 Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
 Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
  routines for all date/time types.
 date.{h,c} now deals with date, time types.
 timestamp.{h,c} now deals with timestamp, interval types.
 nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
parent c97672b0
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.142 2000/02/15 03:26:38 thomas Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.143 2000/02/16 17:24:36 thomas Exp $
* *
* HISTORY * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
...@@ -5180,6 +5180,7 @@ ColId: IDENT { $$ = $1; } ...@@ -5180,6 +5180,7 @@ ColId: IDENT { $$ = $1; }
| INITIALLY { $$ = "initially"; } | INITIALLY { $$ = "initially"; }
| INSENSITIVE { $$ = "insensitive"; } | INSENSITIVE { $$ = "insensitive"; }
| INSTEAD { $$ = "instead"; } | INSTEAD { $$ = "instead"; }
| INTERVAL { $$ = "interval"; }
| ISNULL { $$ = "isnull"; } | ISNULL { $$ = "isnull"; }
| ISOLATION { $$ = "isolation"; } | ISOLATION { $$ = "isolation"; }
| KEY { $$ = "key"; } | KEY { $$ = "key"; }
...@@ -5456,8 +5457,10 @@ xlateSqlType(char *name) ...@@ -5456,8 +5457,10 @@ xlateSqlType(char *name)
return "numeric"; return "numeric";
else if (!strcasecmp(name, "char")) else if (!strcasecmp(name, "char"))
return "bpchar"; return "bpchar";
else if (!strcasecmp(name, "interval")) else if (!strcasecmp(name, "datetime"))
return "timespan"; return "timestamp";
else if (!strcasecmp(name, "timespan"))
return "interval";
else if (!strcasecmp(name, "boolean")) else if (!strcasecmp(name, "boolean"))
return "bool"; return "bool";
else else
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.29 2000/01/26 05:56:42 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.30 2000/02/16 17:24:37 thomas Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -293,18 +293,18 @@ TypeCategory(Oid inType) ...@@ -293,18 +293,18 @@ TypeCategory(Oid inType)
case (INT8OID): case (INT8OID):
case (FLOAT4OID): case (FLOAT4OID):
case (FLOAT8OID): case (FLOAT8OID):
case (NUMERICOID):
case (CASHOID): case (CASHOID):
result = NUMERIC_TYPE; result = NUMERIC_TYPE;
break; break;
case (ABSTIMEOID): case (ABSTIMEOID):
case (TIMESTAMPOID): case (TIMESTAMPOID):
case (DATETIMEOID):
result = DATETIME_TYPE; result = DATETIME_TYPE;
break; break;
case (RELTIMEOID): case (RELTIMEOID):
case (TIMESPANOID): case (INTERVALOID):
result = TIMESPAN_TYPE; result = TIMESPAN_TYPE;
break; break;
...@@ -362,16 +362,18 @@ PreferredType(CATEGORY category, Oid type) ...@@ -362,16 +362,18 @@ PreferredType(CATEGORY category, Oid type)
case (NUMERIC_TYPE): case (NUMERIC_TYPE):
if (type == OIDOID) if (type == OIDOID)
result = OIDOID; result = OIDOID;
else if (type == NUMERICOID)
result = NUMERICOID;
else else
result = FLOAT8OID; result = FLOAT8OID;
break; break;
case (DATETIME_TYPE): case (DATETIME_TYPE):
result = DATETIMEOID; result = TIMESTAMPOID;
break; break;
case (TIMESPAN_TYPE): case (TIMESPAN_TYPE):
result = TIMESPANOID; result = INTERVALOID;
break; break;
case (NETWORK_TYPE): case (NETWORK_TYPE):
...@@ -419,22 +421,25 @@ PromoteTypeToNext(Oid inType) ...@@ -419,22 +421,25 @@ PromoteTypeToNext(Oid inType)
result = FLOAT8OID; result = FLOAT8OID;
break; break;
case (NUMERICOID):
result = NUMERICOID;
break;
case (DATEOID): case (DATEOID):
case (ABSTIMEOID): case (ABSTIMEOID):
case (TIMESTAMPOID): result = TIMESTAMPOID;
result = DATETIMEOID;
break; break;
case (TIMEOID): case (TIMEOID):
case (RELTIMEOID): case (RELTIMEOID):
result = TIMESPANOID; result = INTERVALOID;
break; break;
case (BOOLOID): case (BOOLOID):
case (TEXTOID): case (TEXTOID):
case (FLOAT8OID): case (FLOAT8OID):
case (DATETIMEOID): case (TIMESTAMPOID):
case (TIMESPANOID): case (INTERVALOID):
default: default:
result = inType; result = inType;
break; break;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# Makefile for utils/adt # Makefile for utils/adt
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.33 2000/01/25 23:53:51 momjian Exp $ # $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.34 2000/02/16 17:24:46 thomas Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -24,7 +24,7 @@ endif ...@@ -24,7 +24,7 @@ endif
endif endif
OBJS = acl.o arrayfuncs.o arrayutils.o bool.o cash.o char.o chunk.o \ OBJS = acl.o arrayfuncs.o arrayutils.o bool.o cash.o char.o chunk.o \
date.o datetime.o datum.o dt.o filename.o float.o \ date.o datetime.o datum.o filename.o float.o \
geo_ops.o geo_selfuncs.o int.o int8.o like.o \ geo_ops.o geo_selfuncs.o int.o int8.o like.o \
misc.o nabstime.o name.o not_in.o numeric.o numutils.o \ misc.o nabstime.o name.o not_in.o numeric.o numutils.o \
oid.o oracle_compat.o \ oid.o oracle_compat.o \
......
This diff is collapsed.
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
* formatting.c * formatting.c
* *
* $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.3 2000/02/08 15:56:55 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.4 2000/02/16 17:24:48 thomas Exp $
* *
* *
* Portions Copyright (c) 1999-2000, PostgreSQL, Inc * Portions Copyright (c) 1999-2000, PostgreSQL, Inc
* *
* *
* TO_CHAR(); TO_DATETIME(); TO_DATE(); TO_NUMBER(); * TO_CHAR(); TO_TIMESTAMP(); TO_DATE(); TO_NUMBER();
* *
* The PostgreSQL routines for a DateTime/int/float/numeric formatting, * The PostgreSQL routines for a timestamp/int/float/numeric formatting,
* inspire with Oracle TO_CHAR() / TO_DATE() / TO_NUMBER() routines. * inspire with Oracle TO_CHAR() / TO_DATE() / TO_NUMBER() routines.
* *
* *
* Cache & Memory: * Cache & Memory:
* Routines use (itself) internal cache for format pictures. If * Routines use (itself) internal cache for format pictures. If
* new format arg is same as a last format string, routines not * new format arg is same as a last format string, routines do not
* call the format-parser. * call the format-parser.
* *
* The cache use static buffer and is persistent across transactions. If * The cache uses a static buffer and is persistent across transactions.
* format-picture is bigger than cache buffer, parser is called always. * If format-picture is bigger than cache buffer, parser is called always.
* *
* NOTE for Number version: * NOTE for Number version:
* All in this version is implemented as keywords ( => not used * All in this version is implemented as keywords ( => not used
* suffixes), because a format picture is for *one* item (number) * suffixes), because a format picture is for *one* item (number)
* only. It not is as a datetime version, where each keyword (can) * only. It not is as a timestamp version, where each keyword (can)
* has suffix. * has suffix.
* *
* NOTE for DateTime version: * NOTE for Timestamp routines:
* In this modul is *not* used POSIX 'struct tm' type, but * In this module the POSIX 'struct tm' type is *not* used, but rather
* PgSQL type, which has tm_mon based on one (*non* zero) and * PgSQL type, which has tm_mon based on one (*non* zero) and
* year *not* based on 1900, but is used full year number. * year *not* based on 1900, but is used full year number.
* Modul support AC / BC years. * Module supports AC / BC years.
* *
* Supported types for to_char(): * Supported types for to_char():
* *
* Timestamp, DateTime, Numeric, int4, int8, float4, float8 * Timestamp, Numeric, int4, int8, float4, float8
* *
* Supported types for reverse conversion: * Supported types for reverse conversion:
* *
* Datetime - to_datetime() * Timestamp - to_timestamp()
* Date - to_date() * Date - to_date()
* Numeric - to_number() * Numeric - to_number()
* *
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
#define MAXDOUBLEWIDTH 128 #define MAXDOUBLEWIDTH 128
/* ---------- /* ----------
* External (defined in PgSQL dt.c (datetime utils)) * External (defined in PgSQL dt.c (timestamp utils))
* ---------- * ----------
*/ */
extern char *months[], /* month abbreviation */ extern char *months[], /* month abbreviation */
...@@ -1377,14 +1377,14 @@ dch_time(int arg, char *inout, int suf, int flag, FormatNode *node) ...@@ -1377,14 +1377,14 @@ dch_time(int arg, char *inout, int suf, int flag, FormatNode *node)
str_numth(p_inout, inout, S_TH_TYPE(suf)); str_numth(p_inout, inout, S_TH_TYPE(suf));
return strlen(p_inout)-1; return strlen(p_inout)-1;
} else if (flag == FROM_CHAR) } else if (flag == FROM_CHAR)
elog(ERROR, "to_datatime()/to_timestamp(): SSSS is not supported"); elog(ERROR, "to_datatime(): SSSS is not supported");
} }
return -1; return -1;
} }
#define CHECK_SEQ_SEARCH(_l, _s) { \ #define CHECK_SEQ_SEARCH(_l, _s) { \
if (_l <= 0) { \ if (_l <= 0) { \
elog(ERROR, "to_datatime()/to_timestamp(): bad value for %s", _s); \ elog(ERROR, "to_datatime(): bad value for %s", _s); \
} \ } \
} }
...@@ -1600,7 +1600,7 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node) ...@@ -1600,7 +1600,7 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node)
return 1; return 1;
} else if (flag == FROM_CHAR) } else if (flag == FROM_CHAR)
elog(ERROR, "to_datatime()/to_timestamp(): WW is not supported"); elog(ERROR, "to_datatime(): WW is not supported");
case DCH_Q: case DCH_Q:
if (flag == TO_CHAR) { if (flag == TO_CHAR) {
sprintf(inout, "%d", (tm->tm_mon-1)/3+1); sprintf(inout, "%d", (tm->tm_mon-1)/3+1);
...@@ -1611,7 +1611,7 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node) ...@@ -1611,7 +1611,7 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node)
return 0; return 0;
} else if (flag == FROM_CHAR) } else if (flag == FROM_CHAR)
elog(ERROR, "to_datatime()/to_timestamp(): Q is not supported"); elog(ERROR, "to_datatime(): Q is not supported");
case DCH_CC: case DCH_CC:
if (flag == TO_CHAR) { if (flag == TO_CHAR) {
...@@ -1625,7 +1625,7 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node) ...@@ -1625,7 +1625,7 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node)
return strlen(p_inout)-1; return strlen(p_inout)-1;
} else if (flag == FROM_CHAR) } else if (flag == FROM_CHAR)
elog(ERROR, "to_datatime()/to_timestamp(): CC is not supported"); elog(ERROR, "to_datatime(): CC is not supported");
case DCH_Y_YYY: case DCH_Y_YYY:
if (flag == TO_CHAR) { if (flag == TO_CHAR) {
i= YEAR_ABS(tm->tm_year) / 1000; i= YEAR_ABS(tm->tm_year) / 1000;
...@@ -1764,7 +1764,7 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node) ...@@ -1764,7 +1764,7 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node)
return 0; return 0;
} else if (flag == FROM_CHAR) } else if (flag == FROM_CHAR)
elog(ERROR, "to_datatime()/to_timestamp(): W is not supported"); elog(ERROR, "to_datatime(): W is not supported");
case DCH_J: case DCH_J:
if (flag == TO_CHAR) { if (flag == TO_CHAR) {
...@@ -1773,7 +1773,7 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node) ...@@ -1773,7 +1773,7 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node)
str_numth(p_inout, inout, S_TH_TYPE(suf)); str_numth(p_inout, inout, S_TH_TYPE(suf));
return strlen(p_inout)-1; return strlen(p_inout)-1;
} else if (flag == FROM_CHAR) } else if (flag == FROM_CHAR)
elog(ERROR, "to_datatime()/to_timestamp(): J is not supported"); elog(ERROR, "to_datatime(): J is not supported");
} }
return -1; return -1;
} }
...@@ -1783,11 +1783,11 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node) ...@@ -1783,11 +1783,11 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node)
***************************************************************************/ ***************************************************************************/
/* ------------------- /* -------------------
* DATETIME to_char() * TIMESTAMP to_char()
* ------------------- * -------------------
*/ */
text * text *
datetime_to_char(DateTime *dt, text *fmt) timestamp_to_char(Timestamp *dt, text *fmt)
{ {
static FormatNode CacheFormat[ DCH_CACHE_SIZE +1]; static FormatNode CacheFormat[ DCH_CACHE_SIZE +1];
static char CacheStr[ DCH_CACHE_SIZE +1]; static char CacheStr[ DCH_CACHE_SIZE +1];
...@@ -1814,14 +1814,14 @@ datetime_to_char(DateTime *dt, text *fmt) ...@@ -1814,14 +1814,14 @@ datetime_to_char(DateTime *dt, text *fmt)
tm->tm_mday =1; tm->tm_isdst =0; tm->tm_mday =1; tm->tm_isdst =0;
tm->tm_mon =1; tm->tm_mon =1;
if (DATETIME_IS_EPOCH(*dt)) if (TIMESTAMP_IS_EPOCH(*dt))
{ {
datetime2tm(SetDateTime(*dt), NULL, tm, &fsec, NULL); timestamp2tm(SetTimestamp(*dt), NULL, tm, &fsec, NULL);
} else if (DATETIME_IS_CURRENT(*dt)) { } else if (TIMESTAMP_IS_CURRENT(*dt)) {
datetime2tm(SetDateTime(*dt), &tz, tm, &fsec, &tzn); timestamp2tm(SetTimestamp(*dt), &tz, tm, &fsec, &tzn);
} else { } else {
if (datetime2tm(*dt, &tz, tm, &fsec, &tzn) != 0) if (timestamp2tm(*dt, &tz, tm, &fsec, &tzn) != 0)
elog(ERROR, "to_char(): Unable to convert datetime to tm"); elog(ERROR, "to_char(): Unable to convert timestamp to tm");
} }
tm->tm_wday = (date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) + 1) % 7; tm->tm_wday = (date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) + 1) % 7;
...@@ -1902,32 +1902,22 @@ datetime_to_char(DateTime *dt, text *fmt) ...@@ -1902,32 +1902,22 @@ datetime_to_char(DateTime *dt, text *fmt)
} }
/* -------------------
* TIMESTAMP to_char()
* -------------------
*/
text *
timestamp_to_char(time_t dt, text *fmt)
{
return datetime_to_char( timestamp_datetime(dt), fmt);
}
/* --------------------- /* ---------------------
* TO_DATETIME() * TO_TIMESTAMP()
* *
* Make DateTime from date_str which is formated at argument 'fmt' * Make Timestamp from date_str which is formated at argument 'fmt'
* ( to_datetime is reverse to_char() ) * ( to_timestamp is reverse to_char() )
* --------------------- * ---------------------
*/ */
DateTime * Timestamp *
to_datetime(text *date_str, text *fmt) to_timestamp(text *date_str, text *fmt)
{ {
static FormatNode CacheFormat[ DCH_CACHE_SIZE +1]; static FormatNode CacheFormat[ DCH_CACHE_SIZE +1];
static char CacheStr[ DCH_CACHE_SIZE +1]; static char CacheStr[ DCH_CACHE_SIZE +1];
FormatNode *format; FormatNode *format;
int flag=0; int flag=0;
DateTime *result; Timestamp *result;
char *str; char *str;
int len=0, int len=0,
fsec=0, fsec=0,
...@@ -1942,7 +1932,7 @@ to_datetime(text *date_str, text *fmt) ...@@ -1942,7 +1932,7 @@ to_datetime(text *date_str, text *fmt)
tm->tm_mday =1; tm->tm_isdst =0; tm->tm_mday =1; tm->tm_isdst =0;
tm->tm_mon =1; tm->tm_mon =1;
result = palloc(sizeof(DateTime)); result = palloc(sizeof(Timestamp));
len = VARSIZE(fmt) - VARHDRSZ; len = VARSIZE(fmt) - VARHDRSZ;
...@@ -2060,8 +2050,8 @@ to_datetime(text *date_str, text *fmt) ...@@ -2060,8 +2050,8 @@ to_datetime(text *date_str, text *fmt)
#ifdef DEBUG_TO_FROM_CHAR #ifdef DEBUG_TO_FROM_CHAR
NOTICE_TM; NOTICE_TM;
#endif #endif
if (tm2datetime(tm, fsec, &tz, result) != 0) if (tm2timestamp(tm, fsec, &tz, result) != 0)
elog(ERROR, "to_datatime()/to_timestamp(): can't convert 'tm' to datetime."); elog(ERROR, "to_datatime(): can't convert 'tm' to timestamp.");
return result; return result;
} }
...@@ -2074,18 +2064,7 @@ to_datetime(text *date_str, text *fmt) ...@@ -2074,18 +2064,7 @@ to_datetime(text *date_str, text *fmt)
DateADT DateADT
to_date(text *date_str, text *fmt) to_date(text *date_str, text *fmt)
{ {
return datetime_date( to_datetime(date_str, fmt) ); return timestamp_date( to_timestamp(date_str, fmt) );
}
/* ----------
* TO_TIMESTAMP
* Make timestamp from date_str which is formated at argument 'fmt'
* ----------
*/
time_t
to_timestamp(text *date_str, text *fmt)
{
return datetime_timestamp( to_datetime(date_str, fmt) );
} }
/********************************************************************** /**********************************************************************
......
This diff is collapsed.
This diff is collapsed.
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: catversion.h,v 1.14 2000/02/15 20:49:23 tgl Exp $ * $Id: catversion.h,v 1.15 2000/02/16 17:26:06 thomas Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -53,6 +53,6 @@ ...@@ -53,6 +53,6 @@
*/ */
/* yyyymmddN */ /* yyyymmddN */
#define CATALOG_VERSION_NO 200002151 #define CATALOG_VERSION_NO 200002161
#endif #endif
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_aggregate.h,v 1.22 2000/01/26 05:57:56 momjian Exp $ * $Id: pg_aggregate.h,v 1.23 2000/02/16 17:26:06 thomas Exp $
* *
* NOTES * NOTES
* the genbki.sh script reads this file and generates .bki * the genbki.sh script reads this file and generates .bki
...@@ -95,7 +95,7 @@ DATA(insert OID = 0 ( avg PGUID int2pl int2inc int2div 21 21 21 21 _nul ...@@ -95,7 +95,7 @@ DATA(insert OID = 0 ( avg PGUID int2pl int2inc int2div 21 21 21 21 _nul
DATA(insert OID = 0 ( avg PGUID float4pl float4inc float4div 700 700 700 700 _null_ 0.0 )); DATA(insert OID = 0 ( avg PGUID float4pl float4inc float4div 700 700 700 700 _null_ 0.0 ));
DATA(insert OID = 0 ( avg PGUID float8pl float8inc float8div 701 701 701 701 _null_ 0.0 )); DATA(insert OID = 0 ( avg PGUID float8pl float8inc float8div 701 701 701 701 _null_ 0.0 ));
DATA(insert OID = 0 ( avg PGUID cash_pl float8inc cash_div_flt8 790 790 701 790 _null_ 0.0 )); DATA(insert OID = 0 ( avg PGUID cash_pl float8inc cash_div_flt8 790 790 701 790 _null_ 0.0 ));
DATA(insert OID = 0 ( avg PGUID timespan_pl float8inc timespan_div 1186 1186 701 1186 _null_ 0.0 )); DATA(insert OID = 0 ( avg PGUID interval_pl float8inc interval_div 1186 1186 701 1186 _null_ 0.0 ));
DATA(insert OID = 0 ( avg PGUID numeric_add numeric_inc numeric_div 1700 1700 1700 1700 _null_ 0 )); DATA(insert OID = 0 ( avg PGUID numeric_add numeric_inc numeric_div 1700 1700 1700 1700 _null_ 0 ));
DATA(insert OID = 0 ( sum PGUID int8pl - - 20 20 0 20 _null_ _null_ )); DATA(insert OID = 0 ( sum PGUID int8pl - - 20 20 0 20 _null_ _null_ ));
...@@ -104,7 +104,7 @@ DATA(insert OID = 0 ( sum PGUID int2pl - - 21 21 0 21 _null_ _null_ )); ...@@ -104,7 +104,7 @@ DATA(insert OID = 0 ( sum PGUID int2pl - - 21 21 0 21 _null_ _null_ ));
DATA(insert OID = 0 ( sum PGUID float4pl - - 700 700 0 700 _null_ _null_ )); DATA(insert OID = 0 ( sum PGUID float4pl - - 700 700 0 700 _null_ _null_ ));
DATA(insert OID = 0 ( sum PGUID float8pl - - 701 701 0 701 _null_ _null_ )); DATA(insert OID = 0 ( sum PGUID float8pl - - 701 701 0 701 _null_ _null_ ));
DATA(insert OID = 0 ( sum PGUID cash_pl - - 790 790 0 790 _null_ _null_ )); DATA(insert OID = 0 ( sum PGUID cash_pl - - 790 790 0 790 _null_ _null_ ));
DATA(insert OID = 0 ( sum PGUID timespan_pl - - 1186 1186 0 1186 _null_ _null_ )); DATA(insert OID = 0 ( sum PGUID interval_pl - - 1186 1186 0 1186 _null_ _null_ ));
DATA(insert OID = 0 ( sum PGUID numeric_add - - 1700 1700 0 1700 _null_ _null_ )); DATA(insert OID = 0 ( sum PGUID numeric_add - - 1700 1700 0 1700 _null_ _null_ ));
DATA(insert OID = 0 ( max PGUID int8larger - - 20 20 0 20 _null_ _null_ )); DATA(insert OID = 0 ( max PGUID int8larger - - 20 20 0 20 _null_ _null_ ));
...@@ -115,8 +115,8 @@ DATA(insert OID = 0 ( max PGUID float8larger - - 701 701 0 701 _null_ _null_ ...@@ -115,8 +115,8 @@ DATA(insert OID = 0 ( max PGUID float8larger - - 701 701 0 701 _null_ _null_
DATA(insert OID = 0 ( max PGUID int4larger - - 702 702 0 702 _null_ _null_ )); DATA(insert OID = 0 ( max PGUID int4larger - - 702 702 0 702 _null_ _null_ ));
DATA(insert OID = 0 ( max PGUID date_larger - - 1082 1082 0 1082 _null_ _null_ )); DATA(insert OID = 0 ( max PGUID date_larger - - 1082 1082 0 1082 _null_ _null_ ));
DATA(insert OID = 0 ( max PGUID cashlarger - - 790 790 0 790 _null_ _null_ )); DATA(insert OID = 0 ( max PGUID cashlarger - - 790 790 0 790 _null_ _null_ ));
DATA(insert OID = 0 ( max PGUID datetime_larger - - 1184 1184 0 1184 _null_ _null_ )); DATA(insert OID = 0 ( max PGUID timestamp_larger - - 1184 1184 0 1184 _null_ _null_ ));
DATA(insert OID = 0 ( max PGUID timespan_larger - - 1186 1186 0 1186 _null_ _null_ )); DATA(insert OID = 0 ( max PGUID interval_larger - - 1186 1186 0 1186 _null_ _null_ ));
DATA(insert OID = 0 ( max PGUID text_larger - - 25 25 0 25 _null_ _null_ )); DATA(insert OID = 0 ( max PGUID text_larger - - 25 25 0 25 _null_ _null_ ));
DATA(insert OID = 0 ( max PGUID numeric_larger - - 1700 1700 0 1700 _null_ _null_ )); DATA(insert OID = 0 ( max PGUID numeric_larger - - 1700 1700 0 1700 _null_ _null_ ));
...@@ -128,8 +128,8 @@ DATA(insert OID = 0 ( min PGUID float8smaller - - 701 701 0 701 _null_ _null ...@@ -128,8 +128,8 @@ DATA(insert OID = 0 ( min PGUID float8smaller - - 701 701 0 701 _null_ _null
DATA(insert OID = 0 ( min PGUID int4smaller - - 702 702 0 702 _null_ _null_ )); DATA(insert OID = 0 ( min PGUID int4smaller - - 702 702 0 702 _null_ _null_ ));
DATA(insert OID = 0 ( min PGUID date_smaller - - 1082 1082 0 1082 _null_ _null_ )); DATA(insert OID = 0 ( min PGUID date_smaller - - 1082 1082 0 1082 _null_ _null_ ));
DATA(insert OID = 0 ( min PGUID cashsmaller - - 790 790 0 790 _null_ _null_ )); DATA(insert OID = 0 ( min PGUID cashsmaller - - 790 790 0 790 _null_ _null_ ));
DATA(insert OID = 0 ( min PGUID datetime_smaller - - 1184 1184 0 1184 _null_ _null_ )); DATA(insert OID = 0 ( min PGUID timestamp_smaller - - 1184 1184 0 1184 _null_ _null_ ));
DATA(insert OID = 0 ( min PGUID timespan_smaller - - 1186 1186 0 1186 _null_ _null_ )); DATA(insert OID = 0 ( min PGUID interval_smaller - - 1186 1186 0 1186 _null_ _null_ ));
DATA(insert OID = 0 ( min PGUID text_smaller - - 25 25 0 25 _null_ _null_ )); DATA(insert OID = 0 ( min PGUID text_smaller - - 25 25 0 25 _null_ _null_ ));
DATA(insert OID = 0 ( min PGUID numeric_smaller - - 1700 1700 0 1700 _null_ _null_ )); DATA(insert OID = 0 ( min PGUID numeric_smaller - - 1700 1700 0 1700 _null_ _null_ ));
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_opclass.h,v 1.28 2000/02/10 19:51:45 momjian Exp $ * $Id: pg_opclass.h,v 1.29 2000/02/16 17:26:07 thomas Exp $
* *
* NOTES * NOTES
* the genbki.sh script reads this file and generates .bki * the genbki.sh script reads this file and generates .bki
...@@ -106,9 +106,9 @@ DATA(insert OID = 1115 ( time_ops 1083 )); ...@@ -106,9 +106,9 @@ DATA(insert OID = 1115 ( time_ops 1083 ));
DESCR(""); DESCR("");
DATA(insert OID = 1181 ( name_ops 19 )); DATA(insert OID = 1181 ( name_ops 19 ));
DESCR(""); DESCR("");
DATA(insert OID = 1312 ( datetime_ops 1184 )); DATA(insert OID = 1312 ( timestamp_ops 1184 ));
DESCR(""); DESCR("");
DATA(insert OID = 1313 ( timespan_ops 1186 )); DATA(insert OID = 1313 ( interval_ops 1186 ));
DESCR(""); DESCR("");
DATA(insert OID = 810 ( macaddr_ops 829 )); DATA(insert OID = 810 ( macaddr_ops 829 ));
DESCR(""); DESCR("");
......
This diff is collapsed.
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_type.h,v 1.80 2000/02/15 03:28:31 thomas Exp $ * $Id: pg_type.h,v 1.81 2000/02/16 17:26:07 thomas Exp $
* *
* NOTES * NOTES
* the genbki.sh script reads this file and generates .bki * the genbki.sh script reads this file and generates .bki
...@@ -370,20 +370,17 @@ DESCR("hh:mm:ss, ANSI SQL time"); ...@@ -370,20 +370,17 @@ DESCR("hh:mm:ss, ANSI SQL time");
/* OIDS 1100 - 1199 */ /* OIDS 1100 - 1199 */
DATA(insert OID = 1182 ( _date PGUID -1 -1 f b t \054 0 1082 array_in array_out array_in array_out i _null_ )); DATA(insert OID = 1182 ( _date PGUID -1 -1 f b t \054 0 1082 array_in array_out array_in array_out i _null_ ));
DATA(insert OID = 1183 ( _time PGUID -1 -1 f b t \054 0 1083 array_in array_out array_in array_out d _null_ )); DATA(insert OID = 1183 ( _time PGUID -1 -1 f b t \054 0 1083 array_in array_out array_in array_out d _null_ ));
DATA(insert OID = 1184 ( datetime PGUID 8 47 f b t \054 0 0 datetime_in datetime_out datetime_in datetime_out d _null_ )); DATA(insert OID = 1184 ( timestamp PGUID 8 47 f b t \054 0 0 timestamp_in timestamp_out timestamp_in timestamp_out d _null_ ));
DESCR("date and time"); DESCR("date and time");
#define DATETIMEOID 1184 #define TIMESTAMPOID 1184
DATA(insert OID = 1185 ( _datetime PGUID -1 -1 f b t \054 0 1184 array_in array_out array_in array_out d _null_ )); DATA(insert OID = 1185 ( _timestamp PGUID -1 -1 f b t \054 0 1184 array_in array_out array_in array_out d _null_ ));
DATA(insert OID = 1186 ( timespan PGUID 12 47 f b t \054 0 0 timespan_in timespan_out timespan_in timespan_out d _null_ )); DATA(insert OID = 1186 ( interval PGUID 12 47 f b t \054 0 0 interval_in interval_out interval_in interval_out d _null_ ));
DESCR("@ <number> <units>, time interval"); DESCR("@ <number> <units>, time interval");
#define TIMESPANOID 1186 #define INTERVALOID 1186
DATA(insert OID = 1187 ( _timespan PGUID -1 -1 f b t \054 0 1186 array_in array_out array_in array_out d _null_ )); DATA(insert OID = 1187 ( _interval PGUID -1 -1 f b t \054 0 1186 array_in array_out array_in array_out d _null_ ));
/* OIDS 1200 - 1299 */ /* OIDS 1200 - 1299 */
DATA(insert OID = 1231 ( _numeric PGUID -1 -1 f b t \054 0 1700 array_in array_out array_in array_out i _null_ )); DATA(insert OID = 1231 ( _numeric PGUID -1 -1 f b t \054 0 1700 array_in array_out array_in array_out i _null_ ));
DATA(insert OID = 1296 ( timestamp PGUID 4 19 t b t \054 0 0 timestamp_in timestamp_out timestamp_in timestamp_out i _null_ ));
DESCR("date time timezone, limited-range ISO-formated date and time");
#define TIMESTAMPOID 1296
/* OIDS 1700 - 1799 */ /* OIDS 1700 - 1799 */
DATA(insert OID = 1700 ( numeric PGUID -1 -1 f b t \054 0 0 numeric_in numeric_out numeric_in numeric_out i _null_ )); DATA(insert OID = 1700 ( numeric PGUID -1 -1 f b t \054 0 0 numeric_in numeric_out numeric_in numeric_out i _null_ ));
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: parse_coerce.h,v 1.17 2000/01/26 05:58:27 momjian Exp $ * $Id: parse_coerce.h,v 1.18 2000/02/16 17:26:16 thomas Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -48,8 +48,9 @@ typedef enum CATEGORY ...@@ -48,8 +48,9 @@ typedef enum CATEGORY
|| ((t) == INT4OID) \ || ((t) == INT4OID) \
|| ((t) == INT8OID) \ || ((t) == INT8OID) \
|| ((t) == FLOAT8OID) \ || ((t) == FLOAT8OID) \
|| ((t) == DATETIMEOID) \ || ((t) == NUMERICOID) \
|| ((t) == TIMESTAMPOID) \ || ((t) == TIMESTAMPOID) \
|| ((t) == INTERVALOID) \
|| ((t) == ABSTIMEOID) \ || ((t) == ABSTIMEOID) \
|| ((t) == RELTIMEOID) \ || ((t) == RELTIMEOID) \
|| ((t) == CHAROID) \ || ((t) == CHAROID) \
...@@ -70,8 +71,8 @@ typedef enum CATEGORY ...@@ -70,8 +71,8 @@ typedef enum CATEGORY
* Check for types with the same underlying binary representation. * Check for types with the same underlying binary representation.
* This allows us to cheat and directly exchange values without * This allows us to cheat and directly exchange values without
* going through the trouble of calling a conversion function. * going through the trouble of calling a conversion function.
* Remove equivalencing of FLOAT8 and DATETIME. They really are not * Remove equivalencing of FLOAT8 and TIMESTAMP. They really are not
* close enough in behavior, with the DATETIME reserved values * close enough in behavior, with the TIMESTAMP reserved values
* and special formatting. - thomas 1999-01-24 * and special formatting. - thomas 1999-01-24
*/ */
#define IS_BINARY_COMPATIBLE(a,b) \ #define IS_BINARY_COMPATIBLE(a,b) \
...@@ -87,12 +88,8 @@ typedef enum CATEGORY ...@@ -87,12 +88,8 @@ typedef enum CATEGORY
|| ((a) == INT4OID && (b) == REGPROCOID) \ || ((a) == INT4OID && (b) == REGPROCOID) \
|| ((a) == REGPROCOID && (b) == OIDOID) \ || ((a) == REGPROCOID && (b) == OIDOID) \
|| ((a) == REGPROCOID && (b) == INT4OID) \ || ((a) == REGPROCOID && (b) == INT4OID) \
|| ((a) == ABSTIMEOID && (b) == TIMESTAMPOID) \
|| ((a) == ABSTIMEOID && (b) == INT4OID) \ || ((a) == ABSTIMEOID && (b) == INT4OID) \
|| ((a) == TIMESTAMPOID && (b) == ABSTIMEOID) \
|| ((a) == TIMESTAMPOID && (b) == INT4OID) \
|| ((a) == INT4OID && (b) == ABSTIMEOID) \ || ((a) == INT4OID && (b) == ABSTIMEOID) \
|| ((a) == INT4OID && (b) == TIMESTAMPOID) \
|| ((a) == RELTIMEOID && (b) == INT4OID) \ || ((a) == RELTIMEOID && (b) == INT4OID) \
|| ((a) == INT4OID && (b) == RELTIMEOID) \ || ((a) == INT4OID && (b) == RELTIMEOID) \
|| ((a) == INETOID && (b) == CIDROID) \ || ((a) == INETOID && (b) == CIDROID) \
...@@ -104,21 +101,21 @@ typedef enum CATEGORY ...@@ -104,21 +101,21 @@ typedef enum CATEGORY
#define IS_HIGHER_TYPE(t) \ #define IS_HIGHER_TYPE(t) \
(((t) == TEXTOID) \ (((t) == TEXTOID) \
|| ((t) == FLOAT8OID) \ || ((t) == FLOAT8OID) \
|| ((t) == TIMESPANOID) \ || ((t) == INTERVALOID) \
|| ((t) == DATETIMEOID) \ || ((t) == TIMESTAMPOID) \
|| ((t) == POLYGONOID) \ || ((t) == POLYGONOID) \
|| ((t) == INETOID) ) || ((t) == INETOID) )
/* IS_HIGHEST_TYPE() /* IS_HIGHEST_TYPE()
* These types are the most general in each of the type categories. * These types are the most general in each of the type categories.
* Since timespan and datetime overload so many functions, let's * Since interval and timestamp overload so many functions, let's
* give datetime the preference. * give timestamp the preference.
* Since text is a generic string type let's leave it out too. * Since text is a generic string type let's leave it out too.
*/ */
#define IS_HIGHEST_TYPE(t) \ #define IS_HIGHEST_TYPE(t) \
(((t) == FLOAT8OID) \ (((t) == FLOAT8OID) \
|| ((t) == DATETIMEOID) \ || ((t) == TIMESTAMPOID) \
|| ((t) == TIMESPANOID)) || ((t) == INTERVALOID))
extern bool IsPreferredType(CATEGORY category, Oid type); extern bool IsPreferredType(CATEGORY category, Oid type);
......
This diff is collapsed.
/*-------------------------------------------------------------------------
*
* date.h
* Definitions for the SQL92 "date" and "time" types.
*
*
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: date.h,v 1.1 2000/02/16 17:26:26 thomas Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef DATE_H
#define DATE_H
typedef int32 DateADT;
typedef float8 TimeADT;
/* date.c */
extern DateADT date_in(char *datestr);
extern char *date_out(DateADT dateVal);
extern bool date_eq(DateADT dateVal1, DateADT dateVal2);
extern bool date_ne(DateADT dateVal1, DateADT dateVal2);
extern bool date_lt(DateADT dateVal1, DateADT dateVal2);
extern bool date_le(DateADT dateVal1, DateADT dateVal2);
extern bool date_gt(DateADT dateVal1, DateADT dateVal2);
extern bool date_ge(DateADT dateVal1, DateADT dateVal2);
extern int date_cmp(DateADT dateVal1, DateADT dateVal2);
extern DateADT date_larger(DateADT dateVal1, DateADT dateVal2);
extern DateADT date_smaller(DateADT dateVal1, DateADT dateVal2);
extern int32 date_mi(DateADT dateVal1, DateADT dateVal2);
extern DateADT date_pli(DateADT dateVal, int32 days);
extern DateADT date_mii(DateADT dateVal, int32 days);
extern Timestamp *date_timestamp(DateADT date);
extern DateADT timestamp_date(Timestamp *timestamp);
extern Timestamp *datetime_timestamp(DateADT date, TimeADT *time);
extern DateADT abstime_date(AbsoluteTime abstime);
extern TimeADT *time_in(char *timestr);
extern char *time_out(TimeADT *time);
extern bool time_eq(TimeADT *time1, TimeADT *time2);
extern bool time_ne(TimeADT *time1, TimeADT *time2);
extern bool time_lt(TimeADT *time1, TimeADT *time2);
extern bool time_le(TimeADT *time1, TimeADT *time2);
extern bool time_gt(TimeADT *time1, TimeADT *time2);
extern bool time_ge(TimeADT *time1, TimeADT *time2);
extern int time_cmp(TimeADT *time1, TimeADT *time2);
extern TimeADT *timestamp_time(Timestamp *timestamp);
#endif /* DATE_H */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment