OSDN Git Service

From: Thomas Lockhart <Thomas.G.Lockhart@jpl.nasa.gov>
authorMarc G. Fournier <scrappy@hub.org>
Tue, 25 Mar 1997 08:11:24 +0000 (08:11 +0000)
committerMarc G. Fournier <scrappy@hub.org>
Tue, 25 Mar 1997 08:11:24 +0000 (08:11 +0000)
Subject: [HACKERS] More patches for date/time

I have accumulated several patches to add functionality to the datetime
and timespan data types as well as to fix reported porting bugs on non-BSD
machines. These patches are:

dt.c.patch              - add datetime_part(), fix bugs
dt.h.patch              - add quarter and timezone support, add prototypes
globals.c.patch         - add time and timezone variables
miscadmin.h.patch       - add time and timezone variables
nabstime.c.patch        - add datetime conversion routine
nabstime.h.patch        - add prototypes
pg_operator.h.patch     - add datetime operators, clean up formatting
pg_proc.h.patch         - add datetime functions, reassign conflicting date OIDs
pg_type.h.patch         - add datetime and timespan data types

The dt.c and pg_proc.h patches are fairly large; the latter mostly because I tried
to get some columns for existing entries to line up.

src/backend/utils/adt/dt.c
src/backend/utils/adt/nabstime.c
src/backend/utils/init/globals.c
src/include/catalog/pg_operator.h
src/include/catalog/pg_proc.h
src/include/catalog/pg_type.h
src/include/miscadmin.h
src/include/utils/dt.h
src/include/utils/nabstime.h

index 8439de5..95589e6 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.7 1997/03/18 16:35:17 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.8 1997/03/25 08:09:32 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 #define USE_DATE_CACHE 1
 
-#define JTIME_INVALID          (NAN)
-#define DATETIME_INVALID(j)    {*j = JTIME_INVALID;}
-#define DATETIME_IS_INVALID(j) (isnan(*j))
+#if FALSE
+#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)
+#else
+#define DT_NOBEGIN             (-DBL_MAX)
+#define DT_NOEND               (DBL_MAX)
+#endif
+#define DT_CURRENT             (DBL_MIN)
+#define DT_EPOCH               (-DBL_MIN)
+
+#define DATETIME_INVALID(j)    {j = DT_INVALID;}
+#ifdef NAN
+#define DATETIME_IS_INVALID(j) (isnan(j))
+#else
+#define DATETIME_IS_INVALID(j) (j == DT_INVALID)
+#endif
 
-#define JTIME_NOBEGIN          (-HUGE_VAL)
-#define DATETIME_NOBEGIN(j)    {*j = JTIME_NOBEGIN;}
-#define DATETIME_IS_NOBEGIN(j) (*j == JTIME_NOBEGIN)
+#define DATETIME_NOBEGIN(j)    {j = DT_NOBEGIN;}
+#define DATETIME_IS_NOBEGIN(j) (j == DT_NOBEGIN)
 
-#define JTIME_NOEND            (HUGE_VAL)
-#define DATETIME_NOEND(j)      {*j = JTIME_NOEND;}
-#define DATETIME_IS_NOEND(j)   (*j == JTIME_NOEND)
+#define DATETIME_NOEND(j)      {j = DT_NOEND;}
+#define DATETIME_IS_NOEND(j)   (j == DT_NOEND)
 
-#define JTIME_CURRENT          (MINDOUBLE)
-#define DATETIME_CURRENT(j)    {*j = JTIME_CURRENT;}
-#define DATETIME_IS_CURRENT(j) (*j == MINDOUBLE)
+#define DATETIME_CURRENT(j)    {j = DT_CURRENT;}
+#define DATETIME_IS_CURRENT(j) (j == DT_CURRENT)
 
-#define JTIME_EPOCH            (-MINDOUBLE)
-#define DATETIME_EPOCH(j)      {*j = JTIME_EPOCH;}
-#define DATETIME_IS_EPOCH(j)   (*j == JTIME_EPOCH)
+#define DATETIME_EPOCH(j)      {j = DT_EPOCH;}
+#define DATETIME_IS_EPOCH(j)   (j == DT_EPOCH)
 
-#define DATETIME_IS_RESERVED(j) (*j < 0)
-#undef DATETIME_IS_RESERVED
-#define DATETIME_IS_RESERVED(j)        (DATETIME_IS_INVALID(j) \
-                                || DATETIME_IS_NOBEGIN(j) || DATETIME_IS_NOEND(j) \
-                                || DATETIME_IS_CURRENT(j) || DATETIME_IS_EPOCH(j))
+#define DATETIME_IS_RELATIVE(j)        (DATETIME_IS_CURRENT(j) || DATETIME_IS_EPOCH(j))
+#define DATETIME_NOT_FINITE(j) (DATETIME_IS_INVALID(j) \
+                                || DATETIME_IS_NOBEGIN(j) || DATETIME_IS_NOEND(j))
+#define DATETIME_IS_RESERVED(j)        (DATETIME_IS_RELATIVE(j) || DATETIME_NOT_FINITE(j))
+
+
+#define TIMESPAN_INVALID(j)    {j->time = DT_INVALID;}
+#ifdef NAN
+#define TIMESPAN_IS_INVALID(j) (isnan((j).time))
+#else
+#define TIMESPAN_IS_INVALID(j) ((j).time == DT_INVALID)
+#endif
 
 #define TIME_PREC 1e-6
 #define JROUND(j) (rint(((double) j)/TIME_PREC)*TIME_PREC)
+#endif
 
 
 /***************************************************************************** 
  *   USER I/O ROUTINES                                                       *
  *****************************************************************************/
 
-
 /* datetime_in()
  * Convert a string to internal form.
  */
@@ -70,7 +92,9 @@ datetime_in(char *str)
 {
     DateTime *result;
 
+#if FALSE
     double date, time;
+#endif
     double fsec;
     struct tm tt, *tm = &tt;
     int tzp;
@@ -81,29 +105,26 @@ datetime_in(char *str)
     char lowstr[MAXDATELEN];
 
     if (!PointerIsValid(str))
-       elog (WARN, "Bad (null) datetime external representation", NULL);
+       elog(WARN, "Bad (null) datetime external representation", NULL);
 
     if ((ParseDateTime( str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
       || (DecodeDateTime( field, ftype, nf, &dtype, tm, &fsec, &tzp) != 0))
-       elog (WARN,"Bad datetime external representation %s",str);
+       elog(WARN,"Bad datetime external representation %s",str);
 
     if (!PointerIsValid(result = PALLOCTYPE(DateTime)))
        elog(WARN, "Memory allocation failed, can't input datetime '%s'",str);
 
     switch (dtype) {
     case DTK_DATE:
-       date = (date2j(tm->tm_year,tm->tm_mon,tm->tm_mday)-date2j(2000,1,1));
-       time = time2t(tm->tm_hour,tm->tm_min,(tm->tm_sec + fsec));
-       *result = (date*86400+time);
-#ifdef DATEDEBUG
-printf( "datetime_in- date is %f (%f %f %d)\n", *result, date, time, (((tm->tm_hour*60)+tm->tm_min)*60+tm->tm_sec));
-printf( "datetime_in- time is %f %02d:%02d:%02d %f\n", time, tm->tm_hour, tm->tm_min, tm->tm_sec, fsec);
-#endif
+#if FALSE
        if (tzp != 0) {
-           *result = dt2local(*result, -tzp);
+           *result = tm2datetime( tm, fsec, tzp);
        } else {
-           *result = dt2local(*result, -CTimeZone);
+           *result = tm2datetime( tm, fsec, CTimeZone);
        };
+#endif
+       *result = tm2datetime( tm, fsec, tzp);
+
 #ifdef DATEDEBUG
 printf( "datetime_in- date is %f\n", *result);
 #endif
@@ -111,23 +132,23 @@ printf( "datetime_in- date is %f\n", *result);
        break;
 
     case DTK_EPOCH:
-       DATETIME_EPOCH(result);
+       DATETIME_EPOCH(*result);
        break;
 
     case DTK_CURRENT:
-       DATETIME_CURRENT(result);
+       DATETIME_CURRENT(*result);
        break;
 
     case DTK_LATE:
-       DATETIME_NOEND(result);
+       DATETIME_NOEND(*result);
        break;
 
     case DTK_EARLY:
-       DATETIME_NOBEGIN(result);
+       DATETIME_NOBEGIN(*result);
        break;
 
     case DTK_INVALID:
-       DATETIME_INVALID(result);
+       DATETIME_INVALID(*result);
        break;
 
     default:
@@ -145,52 +166,20 @@ datetime_out(DateTime *dt)
 {
     char *result;
     struct tm tt, *tm = &tt;
-    double date, time, sec, fsec;
+    double fsec;
     char buf[MAXDATELEN];
 
     if (!PointerIsValid(dt))
        return(NULL);
 
-    if (DATETIME_IS_RESERVED(dt)) {
-       EncodeSpecialDateTime(dt, buf);
-
-    } else {
-
-       time = (modf( dt2local( *dt, CTimeZone)/86400, &date)*86400);
-       date += date2j(2000,1,1);
-       if (time < 0) {
-           time += 86400;
-           date -= 1;
-       };
-
-#ifdef DATEDEBUG
-printf( "datetime_out- date is %f (%f %f)\n", *dt, date, time);
-#endif
-
-       j2date((int) date, &tm->tm_year, &tm->tm_mon, &tm->tm_mday);
-       dt2time( time, &tm->tm_hour, &tm->tm_min, &sec);
-
-#ifdef DATEDEBUG
-printf( "datetime_out- date is %d.%02d.%02d\n", tm->tm_year, tm->tm_mon, tm->tm_mday);
-printf( "datetime_out- time is %02d:%02d:%2.2f\n", tm->tm_hour, tm->tm_min, sec);
-#endif
-
-       fsec = modf(JROUND(sec),&sec);
-       tm->tm_sec = sec;
-
-#ifdef DATEDEBUG
-printf( "datetime_out- time is %02d:%02d:%02d %.7f\n", tm->tm_hour, tm->tm_min, tm->tm_sec, fsec);
-#endif
-
-       tm->tm_isdst = -1;
-
-#ifdef DATEDEBUG
-printf( "datetime_out- timezone is %s; offset is %ld; daylight is %d\n",
- CTZName, CTimeZone, CDayLight);
-#endif
+    if (DATETIME_IS_RESERVED(*dt)) {
+       EncodeSpecialDateTime(*dt, buf);
 
+    } else if (datetime2tm( *dt, tm, &fsec) == 0) {
        EncodePostgresDate(tm, fsec, buf);
 
+    } else {
+       EncodeSpecialDateTime(DT_INVALID, buf);
     };
 
     if (!PointerIsValid(result = PALLOC(strlen(buf)+1)))
@@ -230,27 +219,22 @@ timespan_in(char *str)
     fsec = 0;
 
     if (!PointerIsValid(str))
-       elog (WARN, "Bad (null) timespan external representation", NULL);
+       elog(WARN, "Bad (null) timespan external representation", NULL);
 
     if ((ParseDateTime( str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
       || (DecodeDateDelta( field, ftype, nf, &dtype, tm, &fsec) != 0))
-       elog (WARN,"Bad timespan external representation %s",str);
+       elog(WARN,"Bad timespan external representation %s",str);
 
     if (!PointerIsValid(span = PALLOCTYPE(TimeSpan)))
        elog(WARN, "Memory allocation failed, can't input timespan '%s'",str);
 
     switch (dtype) {
     case DTK_DELTA:
-
-       span->month = ((tm->tm_year*12)+tm->tm_mon);
-       span->time = ((((((tm->tm_mday*24)+tm->tm_hour)*60)+tm->tm_min)*60)+tm->tm_sec);
-       span->time = JROUND(span->time + fsec);
-
-#ifdef DATEDEBUG
-printf( "timespan_in- %d %f = %04d-%02d-%02d %02d:%02d:%02d %.2f\n", span->month, span->time,
- tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, fsec);
+       if (tm2timespan(tm, fsec, span) != 0) {
+#if FALSE
+           TIMESPAN_INVALID(span);
 #endif
-
+       };
        break;
 
     default:
@@ -269,61 +253,701 @@ timespan_out(TimeSpan *span)
     char *result;
 
     struct tm tt, *tm = &tt;
-    double time, iunit, funit, fsec = 0;
+    double fsec;
     char buf[MAXDATELEN];
 
     if (!PointerIsValid(span))
        return(NULL);
 
-    if (span->month != 0) {
-       tm->tm_year = span->month / 12;
-       tm->tm_mon = span->month % 12;
+    if (timespan2tm(*span, tm, &fsec) != 0)
+       return(NULL);
+
+    if (EncodePostgresSpan(tm, fsec, buf) != 0)
+         elog(WARN,"Unable to format timespan",NULL);
+
+    if (!PointerIsValid(result = PALLOC(strlen(buf)+1)))
+       elog(WARN,"Memory allocation failed, can't output timespan",NULL);
+
+    strcpy( result, buf);
+    return( result);
+} /* timespan_out() */
+
+
+/***************************************************************************** 
+ *   PUBLIC ROUTINES                                                         *
+ *****************************************************************************/
+
+
+/*----------------------------------------------------------
+ *  Relational operators for datetime.
+ *---------------------------------------------------------*/
+
+void GetEpochTime( struct tm *tm);
+
+void
+GetEpochTime( struct tm *tm)
+{
+    struct tm *t0;
+    time_t epoch = 0;
+
+    t0 = gmtime( &epoch);
+
+    tm->tm_year = t0->tm_year;
+    tm->tm_mon = t0->tm_mon;
+    tm->tm_mday = t0->tm_mday;
+    tm->tm_hour = t0->tm_hour;
+    tm->tm_min = t0->tm_min;
+    tm->tm_sec = t0->tm_sec;
+
+    if (tm->tm_year < 1900) tm->tm_year += 1900;
+
+#ifdef DATEDEBUG
+printf( "GetEpochTime- %04d-%02d-%02d %02d:%02d:%02d\n",
+ tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
+#endif
+
+    return;
+} /* GetEpochTime() */
+
+DateTime
+SetDateTime( DateTime dt) {
+    struct tm tt;
+
+    if (DATETIME_IS_CURRENT(dt)) {
+       GetCurrentTime(&tt);
+       dt = tm2datetime( &tt, 0, 0);
+
+#ifdef DATEDEBUG
+printf( "SetDateTime- current time is %f\n", dt);
+#endif
+    } else { /* if (DATETIME_IS_EPOCH(dt1)) */
+       GetEpochTime(&tt);
+       dt = tm2datetime( &tt, 0, 0);
+#ifdef DATEDEBUG
+printf( "SetDateTime- epoch time is %f\n", dt);
+#endif
+    };
+
+    return(dt);
+} /* SetDateTime() */
+
+/*     datetime_relop  - is datetime1 relop datetime2
+ */
+bool
+datetime_eq(DateTime *datetime1, DateTime *datetime2)
+{
+    DateTime dt1, dt2;
+
+    if (!PointerIsValid(datetime1) || !PointerIsValid(datetime2))
+       return FALSE;
+
+    dt1 = *datetime1;
+    dt2 = *datetime2;
+
+#if FALSE
+    if (DATETIME_NOT_FINITE(dt1) || DATETIME_NOT_FINITE(dt2))
+       return FALSE;
+#endif
+    if (DATETIME_IS_INVALID(dt1) || DATETIME_IS_INVALID(dt2))
+       return FALSE;
+
+    if (DATETIME_IS_RELATIVE(dt1)) dt1 = SetDateTime(dt1);
+    if (DATETIME_IS_RELATIVE(dt2)) dt2 = SetDateTime(dt2);
+
+    return( dt1 == dt2);
+} /* datetime_eq() */
+
+bool
+datetime_ne(DateTime *datetime1, DateTime *datetime2)
+{
+    DateTime dt1, dt2;
+
+    if (!PointerIsValid(datetime1) || !PointerIsValid(datetime2))
+       return FALSE;
+
+    dt1 = *datetime1;
+    dt2 = *datetime2;
+
+#if FALSE
+    if (DATETIME_NOT_FINITE(dt1) || DATETIME_NOT_FINITE(dt2))
+       return FALSE;
+#endif
+    if (DATETIME_IS_INVALID(dt1) || DATETIME_IS_INVALID(dt2))
+       return FALSE;
+
+    if (DATETIME_IS_RELATIVE(dt1)) dt1 = SetDateTime(dt1);
+    if (DATETIME_IS_RELATIVE(dt2)) dt2 = SetDateTime(dt2);
+
+    return( dt1 != dt2);
+} /* datetime_ne() */
+
+bool
+datetime_lt(DateTime *datetime1, DateTime *datetime2)
+{
+    DateTime dt1, dt2;
+
+    if (!PointerIsValid(datetime1) || !PointerIsValid(datetime2))
+       return FALSE;
+
+    dt1 = *datetime1;
+    dt2 = *datetime2;
+
+#if FALSE
+    if (DATETIME_NOT_FINITE(dt1) || DATETIME_NOT_FINITE(dt2))
+       return FALSE;
+#endif
+    if (DATETIME_IS_INVALID(dt1) || DATETIME_IS_INVALID(dt2))
+       return FALSE;
+
+    if (DATETIME_IS_RELATIVE(dt1)) dt1 = SetDateTime(dt1);
+    if (DATETIME_IS_RELATIVE(dt2)) dt2 = SetDateTime(dt2);
+
+    return( dt1 < dt2);
+} /* datetime_lt() */
+
+bool
+datetime_gt(DateTime *datetime1, DateTime *datetime2)
+{
+    DateTime dt1, dt2;
+
+    if (!PointerIsValid(datetime1) || !PointerIsValid(datetime2))
+       return FALSE;
+
+    dt1 = *datetime1;
+    dt2 = *datetime2;
+
+#if FALSE
+    if (DATETIME_NOT_FINITE(dt1) || DATETIME_NOT_FINITE(dt2))
+       return FALSE;
+#endif
+    if (DATETIME_IS_INVALID(dt1) || DATETIME_IS_INVALID(dt2))
+       return FALSE;
+
+    if (DATETIME_IS_RELATIVE(dt1)) dt1 = SetDateTime(dt1);
+    if (DATETIME_IS_RELATIVE(dt2)) dt2 = SetDateTime(dt2);
+
+#ifdef DATEDEBUG
+printf( "datetime_gt- %f %s greater than %f\n", dt1, ((dt1 > dt2)? "is": "is not"), dt2);
+#endif
+    return( dt1 > dt2);
+} /* datetime_gt() */
+
+bool
+datetime_le(DateTime *datetime1, DateTime *datetime2)
+{
+    DateTime dt1, dt2;
+
+    if (!PointerIsValid(datetime1) || !PointerIsValid(datetime2))
+       return FALSE;
+
+    dt1 = *datetime1;
+    dt2 = *datetime2;
+
+#if FALSE
+    if (DATETIME_NOT_FINITE(dt1) || DATETIME_NOT_FINITE(dt2))
+       return FALSE;
+#endif
+    if (DATETIME_IS_INVALID(dt1) || DATETIME_IS_INVALID(dt2))
+       return FALSE;
+
+    if (DATETIME_IS_RELATIVE(dt1)) dt1 = SetDateTime(dt1);
+    if (DATETIME_IS_RELATIVE(dt2)) dt2 = SetDateTime(dt2);
+
+    return( dt1 <= dt2);
+} /* datetime_le() */
+
+bool
+datetime_ge(DateTime *datetime1, DateTime *datetime2)
+{
+    DateTime dt1, dt2;
+
+    if (!PointerIsValid(datetime1) || !PointerIsValid(datetime2))
+       return FALSE;
+
+    dt1 = *datetime1;
+    dt2 = *datetime2;
+
+#if FALSE
+    if (DATETIME_NOT_FINITE(dt1) || DATETIME_NOT_FINITE(dt2))
+       return FALSE;
+#endif
+    if (DATETIME_IS_INVALID(dt1) || DATETIME_IS_INVALID(dt2))
+       return FALSE;
+
+    if (DATETIME_IS_RELATIVE(dt1)) dt1 = SetDateTime(dt1);
+    if (DATETIME_IS_RELATIVE(dt2)) dt2 = SetDateTime(dt2);
+
+    return( dt1 >= dt2);
+} /* datetime_ge() */
+
+
+/*     timespan_relop  - is timespan1 relop timespan2
+ */
+bool
+timespan_eq(TimeSpan *timespan1, TimeSpan *timespan2)
+{
+    if (!PointerIsValid(timespan1) || !PointerIsValid(timespan2))
+       return FALSE;
+
+    if (TIMESPAN_IS_INVALID(*timespan1) || TIMESPAN_IS_INVALID(*timespan2))
+       return FALSE;
+
+    return( (timespan1->time == timespan2->time)
+         && (timespan1->month == timespan2->month));
+} /* timespan_eq() */
+
+bool
+timespan_ne(TimeSpan *timespan1, TimeSpan *timespan2)
+{
+    if (!PointerIsValid(timespan1) || !PointerIsValid(timespan2))
+       return FALSE;
+
+    return( (timespan1->time != timespan2->time)
+         || (timespan1->month != timespan2->month));
+} /* timespan_ne() */
+
+bool
+timespan_lt(TimeSpan *timespan1, TimeSpan *timespan2)
+{
+    double span1, span2;
+
+    if (!PointerIsValid(timespan1) || !PointerIsValid(timespan2))
+       return FALSE;
+
+    span1 = timespan1->time;
+    if (timespan1->month != 0) span1 += (timespan1->month * 30);
+    span2 = timespan2->time;
+    if (timespan2->month != 0) span2 += (timespan2->month * 30);
+
+    return( span1 < span2);
+} /* timespan_lt() */
+
+bool
+timespan_gt(TimeSpan *timespan1, TimeSpan *timespan2)
+{
+    double span1, span2;
+
+    if (!PointerIsValid(timespan1) || !PointerIsValid(timespan2))
+       return FALSE;
+
+    span1 = timespan1->time;
+    if (timespan1->month != 0) span1 += (timespan1->month * 30);
+    span2 = timespan2->time;
+    if (timespan2->month != 0) span2 += (timespan2->month * 30);
+
+    return( span1 > span2);
+} /* timespan_gt() */
+
+bool
+timespan_le(TimeSpan *timespan1, TimeSpan *timespan2)
+{
+    double span1, span2;
+
+    if (!PointerIsValid(timespan1) || !PointerIsValid(timespan2))
+       return FALSE;
+
+    span1 = timespan1->time;
+    if (timespan1->month != 0) span1 += (timespan1->month * 30);
+    span2 = timespan2->time;
+    if (timespan2->month != 0) span2 += (timespan2->month * 30);
+
+    return( span1 <= span2);
+} /* timespan_le() */
+
+bool
+timespan_ge(TimeSpan *timespan1, TimeSpan *timespan2)
+{
+    double span1, span2;
+
+    if (!PointerIsValid(timespan1) || !PointerIsValid(timespan2))
+       return FALSE;
+
+    span1 = timespan1->time;
+    if (timespan1->month != 0) span1 += (timespan1->month * 30);
+    span2 = timespan2->time;
+    if (timespan2->month != 0) span2 += (timespan2->month * 30);
+
+    return( span1 >= span2);
+} /* timespan_ge() */
+
+
+/*----------------------------------------------------------
+ *  "Arithmetic" operators on date/times.
+ *     datetime_foo    returns foo as an object (pointer) that
+ *                      can be passed between languages.
+ *     datetime_xx     is an internal routine which returns the
+ *                     actual value.
+ *---------------------------------------------------------*/
+
+TimeSpan *datetime_sub(DateTime *datetime1, DateTime *datetime2)
+{
+    TimeSpan *result;
+
+    DateTime dt1, dt2;
+
+    if (!PointerIsValid(datetime1) || !PointerIsValid(datetime2))
+       return NULL;
+
+    dt1 = *datetime1;
+    dt2 = *datetime2;
+
+    if (!PointerIsValid(result = PALLOCTYPE(TimeSpan)))
+       elog(WARN, "Memory allocation failed, can't subtract dates",NULL);
+
+    if (DATETIME_IS_RELATIVE(dt1)) dt1 = SetDateTime(dt1);
+    if (DATETIME_IS_RELATIVE(dt2)) dt2 = SetDateTime(dt2);
+
+    if (DATETIME_IS_INVALID(dt1)
+     || DATETIME_IS_INVALID(dt2)) {
+       DATETIME_INVALID( result->time);
 
     } else {
-       tm->tm_year = 0;
-       tm->tm_mon = 0;
+#if FALSE
+       result->time = JROUND(dt1 - dt2);
+#endif
+       result->time = (dt1 - dt2);
     };
+    result->month = 0;
+
+    return(result);
+} /* datetime_sub() */
+
+
+DateTime *datetime_add_span(DateTime *datetime, TimeSpan *span)
+{
+    DateTime *result;
+
+    double date, time;
+    int year, mon, mday;
+
+    if ((!PointerIsValid(datetime)) || (!PointerIsValid(span)))
+       return NULL;
+
+    if (!PointerIsValid(result = PALLOCTYPE(DateTime)))
+       elog(WARN, "Memory allocation failed, can't add dates",NULL);
+
+#ifdef DATEDEBUG
+printf( "date_add- add %f to %d %f\n", *datetime, span->month, span->time);
+#endif
+
+    *result = *datetime;
+    if (DATETIME_IS_RELATIVE(*result)) *result = SetDateTime(*result);
+
+    if (span->month != 0) {
+       time = JROUND(modf( (*result/86400), &date)*86400);
+       date += date2j(2000,1,1);
+
+       j2date( ((int) date), &year, &mon, &mday);
+       mon += span->month;
+       if (mon > 12) {
+           year += mon / 12;
+           mon %= 12;
+       } else if (mon < 0) {
+           year += mon / 12;
+           mon %= 12;
+           year -= 1;
+           mon += 12;
+       };
+       *result += ((date2j( year, mon, mday)-date2j(2000,1,1))*86400);
+       *result += time;
+    };
+
+    *result = JROUND(*result + span->time);
+
+    return(result);
+} /* datetime_add_span() */
+
+DateTime *datetime_sub_span(DateTime *datetime, TimeSpan *span)
+{
+    DateTime *result;
+    TimeSpan tspan;
+
+    if (!PointerIsValid(datetime) || !PointerIsValid(span))
+       return NULL;
+
+    tspan.month = -span->month;
+    tspan.time = -span->time;
+
+    result = datetime_add_span( datetime, &tspan);
+
+    return(result);
+} /* datetime_sub_span() */
+
+
+TimeSpan *timespan_um(TimeSpan *timespan)
+{
+    TimeSpan *result;
+
+    if (!PointerIsValid(timespan))
+       return NULL;
+
+    if (!PointerIsValid(result = PALLOCTYPE(TimeSpan)))
+       elog(WARN, "Memory allocation failed, can't subtract dates",NULL);
+
+    result->time = -(timespan->time);
+    result->month = -(timespan->month);
+
+    return(result);
+} /* datetime_sub() */
+
+
+TimeSpan *timespan_add(TimeSpan *span1, TimeSpan *span2)
+{
+    TimeSpan *result;
+
+    if ((!PointerIsValid(span1)) || (!PointerIsValid(span2)))
+       return NULL;
+
+    if (!PointerIsValid(result = PALLOCTYPE(TimeSpan)))
+       elog(WARN, "Memory allocation failed, can't add timespans",NULL);
+
+    result->month = (span1->month + span2->month);
+    result->time = JROUND(span1->time + span2->time);
 
+    return(result);
+} /* timespan_add() */
+
+TimeSpan *timespan_sub(TimeSpan *span1, TimeSpan *span2)
+{
+    TimeSpan *result;
+
+    if ((!PointerIsValid(span1)) || (!PointerIsValid(span2)))
+       return NULL;
+
+    if (!PointerIsValid(result = PALLOCTYPE(TimeSpan)))
+       elog(WARN, "Memory allocation failed, can't subtract timespans",NULL);
+
+    result->month = (span1->month - span2->month);
+    result->time = JROUND(span1->time - span2->time);
+
+    return(result);
+} /* timespan_sub() */
+
+
+/*----------------------------------------------------------
+ *  Conversion operators.
+ *---------------------------------------------------------*/
+
+
+float64
+datetime_part(text *units, DateTime *datetime)
+{
+    float64 result;
+
+    DateTime dt;
+    int type, val;
+    int i;
+    char *up, *lp, lowunits[MAXDATELEN];
+    double fsec;
+    struct tm tt, *tm = &tt;
+
+    if ((!PointerIsValid(units)) || (!PointerIsValid(datetime)))
+       return NULL;
+
+    if (!PointerIsValid(result = PALLOCTYPE(float64data)))
+       elog(WARN, "Memory allocation failed, can't get date part",NULL);
+
+    up = VARDATA(units);
+    lp = lowunits;
+    for (i = 0; i < (VARSIZE(units)-VARHDRSZ); i++) *lp++ = tolower( *up++);
+    *lp = '\0';
+
+    type = DecodeUnits( 0, lowunits, &val);
+
+#ifdef DATEDEBUG
+if (type == IGNORE) strcpy(lowunits, "(unknown)");
+printf( "datetime_part- units %s type=%d value=%d\n", lowunits, type, val); 
+#endif
+
+    if (DATETIME_NOT_FINITE(*datetime)) {
 #if FALSE
-    time = JROUND(span->time);
+       elog(WARN,"Datetime is not finite",NULL);
 #endif
-    time = span->time;
+       *result = 0;
 
-    funit = modf( (time / 86400), &iunit);
-    tm->tm_mday = iunit;
-    if (tm->tm_mday != 0) time -= rint(tm->tm_mday * 86400);
+    } else if (type == UNITS) {
+
+       dt = (DATETIME_IS_RELATIVE(*datetime)? SetDateTime(*datetime): *datetime); 
+
+       if (datetime2tm( dt, tm, &fsec) == 0) {
+           switch (val) {
+           case DTK_TZ:
+               *result = CTimeZone;
+               break;
+
+           case DTK_MICROSEC:
+               *result = (fsec*1000000);
+               break;
+
+           case DTK_MILLISEC:
+               *result = (fsec*1000);
+               break;
+
+           case DTK_SECOND:
+               *result = (tm->tm_sec + fsec);
+               break;
+
+           case DTK_MINUTE:
+               *result = tm->tm_min;
+               break;
+
+           case DTK_HOUR:
+               *result = tm->tm_hour;
+               break;
+
+           case DTK_DAY:
+               *result = tm->tm_mday;
+               break;
+
+           case DTK_MONTH:
+               *result = tm->tm_mon;
+               break;
+
+           case DTK_QUARTER:
+               *result = (tm->tm_mon/4)+1;
+               break;
+
+           case DTK_YEAR:
+               *result = tm->tm_year;
+               break;
+
+           case DTK_DECADE:
+               *result = (tm->tm_year/10)+1;
+               break;
+
+           case DTK_CENTURY:
+               *result = (tm->tm_year/100)+1;
+               break;
+
+           case DTK_MILLENIUM:
+               *result = (tm->tm_year/1000)+1;
+               break;
+
+           default:
+               elog(WARN,"Datetime units %s not yet supported",units);
+               *result = 0;
+           };
+
+       } else {
+           elog(NOTICE,"Datetime out of range",NULL);
+           *result = 0;
+       };
 
-    funit = modf( (time / 3600), &iunit);
-    tm->tm_hour = iunit;
-    if (tm->tm_hour != 0) time -= rint(tm->tm_hour * 3600e0);
-    funit = modf( (time / 60), &iunit);
-    tm->tm_min = iunit;
-    if (tm->tm_min != 0) time -= rint(tm->tm_min * 60e0);
-    funit = modf( time, &iunit);
-    tm->tm_sec = iunit;
-    if (tm->tm_sec != 0) time -= tm->tm_sec;
-    fsec = time;
+
+    } else {
+       elog(WARN,"Datetime units %s not recognized",units);
+       *result = 0;
+    };
+
+    return(result);
+} /* datetime_part() */
+
+
+float64
+timespan_part(text *units, TimeSpan *timespan)
+{
+    float64 result;
+
+    int type, val;
+    int i;
+    char *up, *lp, lowunits[MAXDATELEN];
+    double fsec;
+    struct tm tt, *tm = &tt;
+
+    if ((!PointerIsValid(units)) || (!PointerIsValid(timespan)))
+       return NULL;
+
+    if (!PointerIsValid(result = PALLOCTYPE(float64data)))
+       elog(WARN, "Memory allocation failed, can't get date part",NULL);
+
+    up = VARDATA(units);
+    lp = lowunits;
+    for (i = 0; i < (VARSIZE(units)-VARHDRSZ); i++) *lp++ = tolower( *up++);
+    *lp = '\0';
+
+    type = DecodeUnits( 0, lowunits, &val);
 
 #ifdef DATEDEBUG
-printf( "timespan_out- %d %f = %04d-%02d-%02d %02d:%02d:%02d %.2f\n", span->month, span->time,
- tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, fsec);
+if (type == IGNORE) strcpy(lowunits, "(unknown)");
+printf( "timespan_part- units %s type=%d value=%d\n", lowunits, type, val); 
 #endif
 
-    if (EncodePostgresSpan(tm, fsec, buf) != 0)
-         elog(WARN,"Unable to format timespan",NULL);
+    if (TIMESPAN_IS_INVALID(*timespan)) {
+#if FALSE
+       elog(WARN,"Timespan is not finite",NULL);
+#endif
+       *result = 0;
 
-    if (!PointerIsValid(result = PALLOC(strlen(buf)+1)))
-       elog(WARN,"Memory allocation failed, can't output timespan",NULL);
+    } else if (type == UNITS) {
 
-    strcpy( result, buf);
-    return( result);
-} /* timespan_out() */
+       if (timespan2tm(*timespan, tm, &fsec) == 0) {
+           switch (val) {
+           case DTK_MICROSEC:
+               *result = (fsec*1000000);
+               break;
 
+           case DTK_MILLISEC:
+               *result = (fsec*1000);
+               break;
 
-/***************************************************************************** 
- *   PUBLIC ROUTINES                                                         *
- *****************************************************************************/
-/* (see int.c for comparison/operation routines) */
+           case DTK_SECOND:
+               *result = (tm->tm_sec + fsec);
+               break;
+
+           case DTK_MINUTE:
+               *result = tm->tm_min;
+               break;
+
+           case DTK_HOUR:
+               *result = tm->tm_hour;
+               break;
+
+           case DTK_DAY:
+               *result = tm->tm_mday;
+               break;
+
+           case DTK_MONTH:
+               *result = tm->tm_mon;
+               break;
+
+           case DTK_QUARTER:
+               *result = (tm->tm_mon/4)+1;
+               break;
+
+           case DTK_YEAR:
+               *result = tm->tm_year;
+               break;
+
+           case DTK_DECADE:
+               *result = (tm->tm_year/10)+1;
+               break;
+
+           case DTK_CENTURY:
+               *result = (tm->tm_year/100)+1;
+               break;
+
+           case DTK_MILLENIUM:
+               *result = (tm->tm_year/1000)+1;
+               break;
+
+           default:
+               elog(WARN,"Timespan units %s not yet supported",units);
+               result = NULL;
+           };
+
+       } else {
+           elog(NOTICE,"Timespan out of range",NULL);
+           *result = 0;
+       };
+
+
+    } else {
+       elog(WARN,"Timespan units %s not recognized",units);
+       *result = 0;
+    };
+
+    return(result);
+} /* timespan_part() */
 
 
 /***************************************************************************** 
@@ -519,7 +1143,7 @@ static datetkn deltatktbl[] = {
 {      "mils",         UNITS,  DTK_MILLENIUM}, /* "millenia" relative time units */
 {      "millenia",     UNITS,  DTK_MILLENIUM}, /* "millenia" relative time units */
 {      DMILLENIUM,     UNITS,  DTK_MILLENIUM}, /* "millenium" relative time units */
-{      "milliseco",    UNITS,  DTK_MILLISEC},  /* "millisecond" relative time units */
+{      "millisecon",   UNITS,  DTK_MILLISEC},  /* "millisecond" relative time units */
 {      "min",          UNITS,  DTK_MINUTE},    /* "minute" relative time units */
 {      "mins",         UNITS,  DTK_MINUTE},    /* "minutes" relative time units */
 {      "mins",         UNITS,  DTK_MINUTE},    /* "minutes" relative time units */
@@ -534,12 +1158,16 @@ static datetkn deltatktbl[] = {
 {      DMILLISEC,      UNITS,  DTK_MILLISEC},  /* "millisecond" relative time units */
 {      "mseconds",     UNITS,  DTK_MILLISEC},  /* "milliseconds" relative time units */
 {      "msecs",        UNITS,  DTK_MILLISEC},  /* "milliseconds" relative time units */
+{      "qtr",          UNITS,  DTK_QUARTER},   /* "quarter" relative time units */
+{      DQUARTER,       UNITS,  DTK_QUARTER},   /* "quarter" relative time units */
 {      "reltime",      IGNORE, 0},             /* "reltime" for pre-v6.1 "Undefined Reltime" */
 {      "s",            UNITS,  DTK_SECOND},    /* "second" relative time units */
 {      "sec",          UNITS,  DTK_SECOND},    /* "second" relative time units */
 {      DSECOND,        UNITS,  DTK_SECOND},    /* "second" relative time units */
 {      "seconds",      UNITS,  DTK_SECOND},    /* "seconds" relative time units */
 {      "secs",         UNITS,  DTK_SECOND},    /* "seconds" relative time units */
+{      DTIMEZONE,      UNITS,  DTK_TZ},        /* "timezone" time offset */
+{      "tz",           UNITS,  DTK_TZ},        /* "timezone" time offset */
 {      "undefined",    RESERV, DTK_INVALID},   /* "undefined" pre-v6.1 invalid time */
 {      "us",           UNITS,  DTK_MICROSEC},  /* "microsecond" relative time units */
 {      "usec",         UNITS,  DTK_MICROSEC},  /* "microsecond" relative time units */
@@ -638,25 +1266,152 @@ void j2date( int jd, int *year, int *month, int *day)
     if (m < 10) {
        m += 3;
     } else {
-       m -= 9;
-       y++;
+       m -= 9;
+       y++;
+    };
+#endif
+
+    *year = y;
+    *month = m;
+    *day = d;
+    return;
+} /* j2date() */
+
+int j2day( int date)
+{
+    int day;
+
+    day = (date+1) % 7;
+
+    return(day);
+} /* j2day() */
+
+int
+datetime2tm( DateTime dt, struct tm *tm, double *fsec)
+{
+    double date, time, sec;
+
+    time = (modf( dt2local( dt, CTimeZone)/86400, &date)*86400);
+    date += date2j(2000,1,1);
+    if (time < 0) {
+           time += 86400;
+           date -= 1;
+    };
+
+    /* Julian day routine does not work for negative Julian days */
+    if (date < 0) return -1;
+
+#ifdef DATEDEBUG
+printf( "datetime2tm- date is %f (%f %f)\n", dt, date, time);
+#endif
+
+    j2date((int) date, &tm->tm_year, &tm->tm_mon, &tm->tm_mday);
+    dt2time( time, &tm->tm_hour, &tm->tm_min, &sec);
+
+#ifdef DATEDEBUG
+printf( "datetime2tm- date is %d.%02d.%02d\n", tm->tm_year, tm->tm_mon, tm->tm_mday);
+printf( "datetime2tm- time is %02d:%02d:%2.2f\n", tm->tm_hour, tm->tm_min, sec);
+#endif
+
+    *fsec = modf(JROUND(sec),&sec);
+    tm->tm_sec = sec;
+
+#ifdef DATEDEBUG
+printf( "datetime2tm- time is %02d:%02d:%02d %.7f\n", tm->tm_hour, tm->tm_min, tm->tm_sec, *fsec);
+#endif
+
+    tm->tm_isdst = -1;
+
+#ifdef DATEDEBUG
+printf( "datetime2tm- timezone is %s; offset is %d; daylight is %d\n",
+ CTZName, CTimeZone, CDayLight);
+#endif
+
+    return 0;
+} /* datetime2tm() */
+
+/* tm2datetime()
+ * Convert a tm structure to a datetime data type.
+ */
+DateTime
+tm2datetime( struct tm *tm, double fsec, int tzp) {
+
+    DateTime result;
+    double date, time;
+
+    /* Julian day routines are not correct for negative Julian days */
+    if ((date = date2j(tm->tm_year,tm->tm_mon,tm->tm_mday)) < 0)
+       return(DT_INVALID);
+
+    date -= date2j(2000,1,1);
+    time = time2t(tm->tm_hour,tm->tm_min,(tm->tm_sec + fsec));
+    result = (date*86400+time);
+#ifdef DATEDEBUG
+printf( "tm2datetime- date is %f (%f %f %d)\n", result, date, time, (((tm->tm_hour*60)+tm->tm_min)*60+tm->tm_sec));
+printf( "tm2datetime- time is %f %02d:%02d:%02d %f\n", time, tm->tm_hour, tm->tm_min, tm->tm_sec, fsec);
+#endif
+    if (tzp != 0) result = dt2local(result, -tzp);
+
+    return(result);
+} /* tm2datetime() */
+
+
+int
+timespan2tm(TimeSpan span, struct tm *tm, float8 *fsec)
+{
+    double time, iunit, funit;
+
+    if (span.month != 0) {
+       tm->tm_year = span.month / 12;
+       tm->tm_mon = span.month % 12;
+
+    } else {
+       tm->tm_year = 0;
+       tm->tm_mon = 0;
     };
+
+#if FALSE
+    time = JROUND(span.time);
 #endif
+    time = span.time;
 
-    *year = y;
-    *month = m;
-    *day = d;
-    return;
-} /* j2date() */
+    funit = modf( (time / 86400), &iunit);
+    tm->tm_mday = iunit;
+    if (tm->tm_mday != 0) time -= rint(tm->tm_mday * 86400);
 
-int j2day( int date)
+    funit = modf( (time / 3600), &iunit);
+    tm->tm_hour = iunit;
+    if (tm->tm_hour != 0) time -= rint(tm->tm_hour * 3600e0);
+    funit = modf( (time / 60), &iunit);
+    tm->tm_min = iunit;
+    if (tm->tm_min != 0) time -= rint(tm->tm_min * 60e0);
+    funit = modf( time, &iunit);
+    tm->tm_sec = iunit;
+    if (tm->tm_sec != 0) time -= tm->tm_sec;
+    *fsec = time;
+
+#ifdef DATEDEBUG
+printf( "timespan2tm- %d %f = %04d-%02d-%02d %02d:%02d:%02d %.2f\n", span.month, span.time,
+ tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, *fsec);
+#endif
+
+    return 0;
+} /* timespan2tm() */
+
+int
+tm2timespan( struct tm *tm, double fsec, TimeSpan *span)
 {
-    int day;
+    span->month = ((tm->tm_year*12)+tm->tm_mon);
+    span->time = ((((((tm->tm_mday*24)+tm->tm_hour)*60)+tm->tm_min)*60)+tm->tm_sec);
+    span->time = JROUND(span->time + fsec);
 
-    day = (date+1) % 7;
+#ifdef DATEDEBUG
+printf( "tm2timespan- %d %f = %04d-%02d-%02d %02d:%02d:%02d %.2f\n", span->month, span->time,
+ tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, fsec);
+#endif
 
-    return(day);
-} /* j2day() */
+    return 1;
+} /* tm2timespan() */
 
 
 DateTime dt2local(DateTime dt, int timezone)
@@ -826,6 +1581,7 @@ DecodeDateTime( char *field[], int ftype[], int nf,
     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 */
     if (tzp != NULL) *tzp = CTimeZone;
 
@@ -1376,7 +2132,7 @@ printf( "DecodeNumberField- %s is date field fmask=%08x tmask=%08x\n", str, fmas
            tm->tm_year = atoi(str+0);
        };
 
-    } else if (index(str,'.') != NULL) {
+    } else if (strchr(str,'.') != NULL) {
 #ifdef DATEDEBUG
 printf( "DecodeNumberField- %s is time field fmask=%08x tmask=%08x\n", str, fmask, *tmask);
 #endif
@@ -1741,12 +2497,6 @@ datebsearch(char *key, datetkn *base, unsigned int nel)
 /***************************************************************************/
 /***************************************************************************/
 
-#if FALSE
-#ifndef PALLOCTYPE
-#define PALLOCTYPE(p) palloc(sizeof(p))
-#endif
-#endif
-
 char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL};
 
@@ -1767,7 +2517,7 @@ int EncodeMonth(int mon, char *str)
 #define EncodeMonth(m,s)       strcpy(s,months[m-1])
 
 
-int EncodeSpecialDateTime(DateTime *dt, char *str)
+int EncodeSpecialDateTime(DateTime dt, char *str)
 {
     if (DATETIME_IS_RESERVED(dt)) {
        if (DATETIME_IS_INVALID(dt)) {
@@ -1810,7 +2560,7 @@ int EncodePostgresDate(struct tm *tm, double fsec, char *str)
     tm->tm_isdst = -1;
 
 #ifdef DATEDEBUG
-printf( "EncodePostgresDate- timezone is %s; offset is %ld; daylight is %d\n",
+printf( "EncodePostgresDate- timezone is %s; offset is %d; daylight is %d\n",
  CTZName, CTimeZone, CDayLight);
 #endif
 
@@ -1828,37 +2578,62 @@ printf( "EncodePostgresDate- day is %d\n", day);
 
     strcpy( mabbrev, months[tm->tm_mon-1]);
 
-    if (EuroDates) {
-       sprintf( str, "%3s %02d/%02d/%04d %02d:%02d:%02d %s", dabbrev,
-         tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_hour, tm->tm_min, (int) rint(sec), CTZName);
+    if (DateStyle == USE_ISO_DATES) {
+       if (tm->tm_year > 0) {
+           sprintf( str, "%04d-%02d-%02d %02d:%02d:%5.2f %s",
+             tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, sec, CTZName);
+           /* XXX brute-force fill in leading zero on seconds */
+           if (*(str+17) == ' ') *(str+17) = '0';
 
-    } else if (tm->tm_year > 0) {
-#if FALSE
-       sprintf( str, "%3s %3s %02d %02d:%02d:%02d %04d %s", dabbrev,
-         mabbrev, tm->tm_mday, tm->tm_hour, tm->tm_min, (int) rint(sec), tm->tm_year, CTZName);
-#endif
-       sprintf( str, "%3s %3s %02d %02d:%02d:%5.2f %04d %s", dabbrev,
-         mabbrev, tm->tm_mday, tm->tm_hour, tm->tm_min, sec, tm->tm_year, CTZName);
-       /* XXX brute-force fill in leading zero on seconds */
-       if (*(str+17) == ' ') *(str+17) = '0';
+       } else {
+           sprintf( str, "%04d-%02d-%02d %02d:%02d %s",
+             -(tm->tm_year-1), tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, "BC");
+       };
 
-    } else {
-       sprintf( str, "%3s %3s %02d %02d:%02d:%02d %04d %s", dabbrev,
-         mabbrev, tm->tm_mday, tm->tm_hour, tm->tm_min, (int) rint(sec), -(tm->tm_year-1), "BC");
+    } else if (DateStyle == USE_SQL_DATES) {
+       if (EuroDates) {
+           sprintf( str, "%02d/%02d", tm->tm_mday, tm->tm_mon);
+       } else {
+           sprintf( str, "%02d/%02d", tm->tm_mon, tm->tm_mday);
+       };
+       if (tm->tm_year > 0) {
+           sprintf( (str+5), "/%04d %02d:%02d:%5.2f %s",
+             tm->tm_year, tm->tm_hour, tm->tm_min, sec, CTZName);
+           /* XXX brute-force fill in leading zero on seconds */
+           if (*(str+17) == ' ') *(str+17) = '0';
+
+       } else {
+           sprintf( (str+5), "/%04d %02d:%02d %s",
+             -(tm->tm_year-1), tm->tm_hour, tm->tm_min, "BC");
+       };
+
+    } else { /* if (DateStyle == USE_POSTGRES_DATES) */
+       sprintf( str, "%3s ", dabbrev);
+       if (EuroDates) {
+           sprintf( (str+4), "%02d %3s", tm->tm_mday, mabbrev);
+       } else {
+           sprintf( (str+4), "%3s %02d", mabbrev, tm->tm_mday);
+       };
+       if (tm->tm_year > 0) {
+           sprintf( (str+10), " %02d:%02d:%5.2f %04d %s",
+             tm->tm_hour, tm->tm_min, sec, tm->tm_year, CTZName);
+           /* XXX brute-force fill in leading zero on seconds */
+           if (*(str+17) == ' ') *(str+17) = '0';
+
+       } else {
+           sprintf( (str+10), " %02d:%02d %04d %s",
+             tm->tm_hour, tm->tm_min, -(tm->tm_year-1), "BC");
+       };
     };
+
 #ifdef DATEDEBUG
 printf( "EncodePostgresDate- date result is %s\n", str);
 #endif
 
+#ifdef DATEDEBUG
     if (tm->tm_year >= 1000) tm->tm_year -= 1900;
     tm->tm_mon -= 1;
     strftime( buf, sizeof(buf), "%y.%m.%d %H:%M:%S %Z", tm);
-#if FALSE
-    time = mktime( tm);
-    strftime( buf, sizeof(buf), "%y.%m.%d %H:%M:%S %Z", localtime(&time));
-    strcpy( str, buf);
-#endif
-#ifdef DATEDEBUG
 printf( "EncodePostgresDate- strftime result is %s\n", buf);
 #endif
 
@@ -1927,260 +2702,3 @@ printf( "EncodePostgresSpan- result is %s\n", str);
 
     return 0;
 } /* EncodePostgresSpan() */
-
-
-#if FALSE
-/*----------------------------------------------------------
- *  Relational operators for JDATEs.
- *---------------------------------------------------------*/
-
-#define JDATElt(a,b) (((a).date < (b).date) || (((a).date == (b).date) && ((a).time < (b).time)))
-#define JDATEle(a,b) (((a).date < (b).date) || (((a).date == (b).date) && ((a).time <= (b).time)))
-#define JDATEeq(a,b) (((a).date == (b).date) && ((a).time == (b).time))
-#define JDATEge(a,b) (((a).date > (b).date) || (((a).date == (b).date) && ((a).time >= (b).time)))
-#define JDATEgt(a,b) (((a).date > (b).date) || (((a).date == (b).date) && ((a).time > (b).time)))
-
-/*     jintervals identical?
- */
-bool jinterval_same(JINTERVAL *jinterval1, JINTERVAL *jinterval2)
-{
-    return( JDATEeq(jinterval1->bdate,jinterval2->bdate)
-      && JDATEeq(jinterval1->edate,jinterval2->edate));
-}
-
-/*     jinterval_overlap       -       does jinterval1 overlap jinterval2?
- */
-bool jinterval_overlap(JINTERVAL *jinterval1, JINTERVAL *jinterval2)
-{
-    return( JDATEle(jinterval1->bdate,jinterval2->edate)
-      && JDATEge(jinterval1->edate,jinterval2->bdate));
-}
-
-/*     jinterval_overleft      -       is the right edge of jinterval1 to the left of
- *                             the right edge of jinterval2?
- */
-bool jinterval_overleft(JINTERVAL *jinterval1, JINTERVAL *jinterval2)
-{
-    return( JDATEle(jinterval1->edate,jinterval2->edate));
-}
-
-/*     jinterval_left  -       is jinterval1 strictly left of jinterval2?
- */
-bool jinterval_left(JINTERVAL *jinterval1, JINTERVAL *jinterval2)
-{
-    return( JDATEle(jinterval1->edate,jinterval2->bdate));
-}
-
-/*     jinterval_right -       is jinterval1 strictly right of jinterval2?
- */
-bool jinterval_right(JINTERVAL *jinterval1, JINTERVAL *jinterval2)
-{
-    return( JDATEge(jinterval1->edate,jinterval2->bdate));
-}
-
-/*     jinterval_overright     -       is the left edge of jinterval1 to the right of
- *                             the left edge of jinterval2?
- */
-bool jinterval_overright(JINTERVAL *jinterval1, JINTERVAL *jinterval2)
-{
-    return( JDATEge(jinterval1->bdate,jinterval2->bdate));
-}
-
-/*     jinterval_contained     -       is jinterval1 contained by jinterval2?
- */
-bool jinterval_contained(JINTERVAL *jinterval1, JINTERVAL *jinterval2)
-{
-    return( JDATEge(jinterval1->bdate,jinterval2->bdate)
-      && JDATEle(jinterval1->edate,jinterval2->edate));
-}
-
-/*     jinterval_contain       - does jinterval1 contain jinterval2?
- */
-bool jinterval_contain(JINTERVAL *jinterval1, JINTERVAL *jinterval2)
-{
-    return( JDATEle(jinterval1->bdate,jinterval2->bdate)
-      && JDATEge(jinterval1->edate,jinterval2->edate));
-}
-
-
-/*     jdate_relop     - is jdate1 relop jdate2
- */
-bool jdate_lt(JDATE *jdate1, JDATE *jdate2)
-{
-    return( JDATElt(*jdate1,*jdate2));
-}
-
-bool jdate_gt(JDATE *jdate1, JDATE *jdate2)
-{
-    return( JDATEgt(*jdate1,*jdate2));
-}
-
-bool jdate_eq(JDATE *jdate1, JDATE *jdate2)
-{
-    return( JDATEeq(*jdate1,*jdate2));
-}
-
-bool jdate_le(JDATE *jdate1, JDATE *jdate2)
-{
-    return( JDATEle(*jdate1,*jdate2));
-}
-
-bool jdate_ge(JDATE *jdate1, JDATE *jdate2)
-{
-    return( JDATEge(*jdate1,*jdate2));
-}
-#endif
-
-
-/*----------------------------------------------------------
- *  "Arithmetic" operators on date/times.
- *     datetime_foo    returns foo as an object (pointer) that
- can be passed between languages.
- *     datetime_xx     is an internal routine which returns the
- *                     actual value.
- *---------------------------------------------------------*/
-
-/*----------------------------------------------------------
- *  Conversion operators.
- *---------------------------------------------------------*/
-
-TimeSpan *datetime_sub(DateTime *dt1, DateTime *dt2)
-{
-    TimeSpan *result;
-
-    if ((!PointerIsValid(dt1)) || (!PointerIsValid(dt2)))
-       return NULL;
-
-    if (!PointerIsValid(result = PALLOCTYPE(TimeSpan)))
-       elog(WARN, "Memory allocation failed, can't subtract dates",NULL);
-
-#if USE_JULIAN_DAY
-    result->time = ((*dt1 - *dt2)*86400);
-    result->month = 0;
-#else
-    result->time = JROUND(*dt1 - *dt2);
-    result->month = 0;
-#endif
-
-    return(result);
-} /* datetime_sub() */
-
-
-DateTime *datetime_add_span(DateTime *dt, TimeSpan *span)
-{
-    DateTime *result;
-    double date, time;
-    int year, mon, mday;
-
-    if ((!PointerIsValid(dt)) || (!PointerIsValid(span)))
-       return NULL;
-
-    if (!PointerIsValid(result = PALLOCTYPE(DateTime)))
-       elog(WARN, "Memory allocation failed, can't add dates",NULL);
-
-#ifdef DATEDEBUG
-printf( "date_add- add %f to %d %f\n", *dt, span->month, span->time);
-#endif
-
-    if (span->month != 0) {
-#if USE_JULIAN_DAY
-       time = modf( *dt, &date);
-#else
-       time = JROUND(modf( (*dt/86400), &date)*86400);
-       date += date2j(2000,1,1);
-#endif
-       j2date( ((int) date), &year, &mon, &mday);
-       mon += span->month;
-       if (mon > 12) {
-           year += mon / 12;
-           mon %= 12;
-       };
-#if USE_JULIAN_DAY
-       *result = date2j( year, mon, mday);
-#else
-       *result = ((date2j( year, mon, mday)-date2j(2000,1,1))*86400);
-#endif
-       *result += time;
-    } else {
-       *result = *dt;
-    };
-
-#if USE_JULIAN_DAY
-    *result += (span->time/86400);
-#else
-    *result = JROUND(*result + span->time);
-#endif
-
-    return(result);
-} /* datetime_add_span() */
-
-DateTime *datetime_sub_span(DateTime *dt, TimeSpan *span)
-{
-    DateTime *result;
-    TimeSpan tspan;
-
-    if ((!PointerIsValid(dt)) || (!PointerIsValid(span)))
-       return NULL;
-
-    tspan.month = -span->month;
-    tspan.time = -span->time;
-
-    result = datetime_add_span( dt, &tspan);
-
-    return(result);
-} /* datetime_sub_span() */
-
-
-/***********************************************************************
- **
- **    Routines for time spans.
- **
- ***********************************************************************/
-
-/*----------------------------------------------------------
- * Formatting and conversion routines.
- *---------------------------------------------------------*/
-
-/*----------------------------------------------------------
- *  "Arithmetic" operators on date/times.
- *     datetime_foo    returns foo as an object (pointer) that
- can be passed between languages.
- *     datetime_xx     is an internal routine which returns the
- *                     actual value.
- *---------------------------------------------------------*/
-
-/*----------------------------------------------------------
- *  Conversion operators.
- *---------------------------------------------------------*/
-
-TimeSpan *timespan_add(TimeSpan *span1, TimeSpan *span2)
-{
-    TimeSpan *result;
-
-    if ((!PointerIsValid(span1)) || (!PointerIsValid(span2)))
-       return NULL;
-
-    if (!PointerIsValid(result = PALLOCTYPE(TimeSpan)))
-       elog(WARN, "Memory allocation failed, can't add timespans",NULL);
-
-    result->month = (span1->month + span2->month);
-    result->time = JROUND(span1->time + span2->time);
-
-    return(result);
-} /* timespan_add() */
-
-TimeSpan *timespan_sub(TimeSpan *span1, TimeSpan *span2)
-{
-    TimeSpan *result;
-
-    if ((!PointerIsValid(span1)) || (!PointerIsValid(span2)))
-       return NULL;
-
-    if (!PointerIsValid(result = PALLOCTYPE(TimeSpan)))
-       elog(WARN, "Memory allocation failed, can't subtract timespans",NULL);
-
-    result->month = (span1->month - span2->month);
-    result->time = JROUND(span1->time - span2->time);
-
-    return(result);
-} /* timespan_sub() */
index 11811c9..1119b31 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.16 1997/03/21 18:53:28 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.17 1997/03/25 08:09:35 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -62,13 +62,13 @@ GetCurrentAbsoluteTime(void)
        CTimeZone = - tmnow->tm_gmtoff; /* tm_gmtoff is Sun/DEC-ism */
        CDayLight = (tmnow->tm_isdst > 0);
        /* XXX is there a better way to get local timezone string in V7? - tgl 97/03/18 */
-       strftime( CTZName, 8, "%Z", localtime(&now));
+       strftime( CTZName, MAXTZLEN, "%Z", localtime(&now));
 #endif
 #else /* ! USE_POSIX_TIME */
        CTimeZone = tbnow.timezone * 60;
        CDayLight = (tbnow.dstflag != 0);
        /* XXX does this work to get the local timezone string in V7? - tgl 97/03/18 */
-       strftime( CTZName, 8, "%Z", localtime(&now));
+       strftime( CTZName, MAXTZLEN, "%Z", localtime(&now));
 #endif 
     };
 
@@ -102,15 +102,61 @@ GetCurrentTime(struct tm *tm)
 } /* GetCurrentTime() */
 
 
+AbsoluteTime tm2abstime( struct tm *tm, int tz);
+
+AbsoluteTime
+tm2abstime( struct tm *tm, int tz)
+{
+    int day, sec;
+
+    /* validate, before going out of range on some members */
+    if (tm->tm_year < 1901 || tm->tm_year > 2038
+      || tm->tm_mon < 1 || tm->tm_mon > 12
+      || tm->tm_mday < 1 || tm->tm_mday > 31
+      || tm->tm_hour < 0 || tm->tm_hour >= 24
+      || tm->tm_min < 0 || tm->tm_min > 59
+      || tm->tm_sec < 0 || tm->tm_sec > 59)
+       return INVALID_ABSTIME;
+
+    day = (date2j( tm->tm_year, tm->tm_mon, tm->tm_mday) - date2j( 1970, 1, 1));
+
+    /* check for time out of range */
+    if ((day < MIN_DAYNUM) || (day > MAX_DAYNUM))
+       return INVALID_ABSTIME;
+
+    /* convert to seconds */
+    sec = tm->tm_sec + tz + (tm->tm_min +(day*24 + tm->tm_hour)*60)*60;
+
+    /* check for overflow */
+    if ((day == MAX_DAYNUM && sec < 0) ||
+      (day == MIN_DAYNUM && sec > 0))
+       return INVALID_ABSTIME;
+
+    /* daylight correction */
+    if (tm->tm_isdst < 0) {            /* unknown; find out */
+       tm->tm_isdst = (CDayLight > 0);
+    };
+    if (tm->tm_isdst > 0)
+       sec -= 60*60;
+
+    /* check for reserved values (e.g. "current" on edge of usual range */
+    if (!AbsoluteTimeIsReal(sec))
+       return INVALID_ABSTIME;
+
+    return sec;
+} /* tm2abstime() */
+
+
 /* nabstimein()
  * Decode date/time string and return abstime.
  */
 AbsoluteTime
 nabstimein(char* str)
 {
-    int sec;
+    AbsoluteTime result;
+
     double fsec;
-    int day, tz = 0;
+    int tz = 0;
     struct tm date, *tm = &date;
 
     char *field[MAXDATEFIELDS];
@@ -134,65 +180,35 @@ printf( "nabstimein- %d fields are type %d (DTK_DATE=%d)\n", nf, dtype, DTK_DATE
 
     switch (dtype) {
     case DTK_DATE:
-#if FALSE
-       return(dateconv( &date, tz));
-#endif
-       /* validate, before going out of range on some members */
-       if (tm->tm_year < 1901 || tm->tm_year > 2038
-        || tm->tm_mon < 1 || tm->tm_mon > 12
-        || tm->tm_mday < 1 || tm->tm_mday > 31
-        || tm->tm_hour < 0 || tm->tm_hour >= 24
-        || tm->tm_min < 0 || tm->tm_min > 59
-        || tm->tm_sec < 0 || tm->tm_sec > 59)
-           return INVALID_ABSTIME;
-
-       day = (date2j( tm->tm_year, tm->tm_mon, tm->tm_mday) - date2j( 1970, 1, 1));
-
-       /* check for time out of range */
-       if ((day < MIN_DAYNUM) || (day > MAX_DAYNUM))
-       return INVALID_ABSTIME;
-
-       /* convert to seconds */
-       sec = tm->tm_sec + tz + (tm->tm_min +(day*24 + tm->tm_hour)*60)*60;
-
-       /* check for overflow */
-       if ((day == MAX_DAYNUM && sec < 0) ||
-        (day == MIN_DAYNUM && sec > 0))
-           return INVALID_ABSTIME;
-
-       /* daylight correction */
-       if (tm->tm_isdst < 0) {         /* unknown; find out */
-           tm->tm_isdst = (CDayLight > 0);
-       };
-       if (tm->tm_isdst > 0)
-           sec -= 60*60;
-
-       /* check for reserved values (e.g. "current" on edge of usual range */
-       if (!AbsoluteTimeIsReal(sec))
-           return INVALID_ABSTIME;
-
-       return sec;
+       result = tm2abstime(tm, tz);
+       break;
 
     case DTK_EPOCH:
-       return EPOCH_ABSTIME;
+       result = EPOCH_ABSTIME;
+       break;
 
     case DTK_CURRENT:
-       return CURRENT_ABSTIME;
+       result = CURRENT_ABSTIME;
+       break;
 
     case DTK_LATE:
-       return NOEND_ABSTIME;
+       result = NOEND_ABSTIME;
+       break;
 
     case DTK_EARLY:
-       return NOSTART_ABSTIME;
+       result = NOSTART_ABSTIME;
+       break;
 
     case DTK_INVALID:
-       return INVALID_ABSTIME;
+       result = INVALID_ABSTIME;
+       break;
 
     default:
+       elog(WARN,"Bad abstime (internal coding error) '%s'",str);
+       result = INVALID_ABSTIME;
     };
 
-    elog(WARN,"Bad abstime (internal coding error) '%s'",str);
-    return INVALID_ABSTIME;
+    return result;
 } /* nabstimein() */
 
 
@@ -432,3 +448,42 @@ abstimege(AbsoluteTime t1, AbsoluteTime t2)
 
     return(t1 >= t2);
 }
+
+/* datetime_abstime()
+ * Convert datetime to abstime.
+ */
+AbsoluteTime
+datetime_abstime(DateTime *datetime)
+{
+    AbsoluteTime result;
+
+    double fsec;
+    struct tm tt, *tm = &tt;
+
+    if (!PointerIsValid(datetime)) {
+       result = INVALID_ABSTIME;
+
+    } else if (DATETIME_IS_INVALID(*datetime)) {
+       result = INVALID_ABSTIME;
+
+    } else if (DATETIME_IS_NOBEGIN(*datetime)) {
+       result = NOSTART_ABSTIME;
+
+    } else if (DATETIME_IS_NOEND(*datetime)) {
+       result = NOEND_ABSTIME;
+
+    } else {
+       if (DATETIME_IS_RELATIVE(*datetime)) {
+           datetime2tm( SetDateTime(*datetime), tm, &fsec);
+           result = tm2abstime( tm, 0);
+
+       } else if (datetime2tm( *datetime, tm, &fsec) == 0) {
+           result = tm2abstime( tm, 0);
+
+       } else {
+           result = INVALID_ABSTIME;
+       };
+    };
+
+    return(result);
+} /* datetime_abstime() */
index d5fa060..1fa7cf7 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.7 1997/03/18 20:14:46 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.8 1997/03/25 08:09:43 scrappy Exp $
  *
  * NOTES
  *    Globals used all over the place should be declared here and not
@@ -65,11 +65,12 @@ bool                IsPostmaster = false;
 
 short          DebugLvl = 0;
 
+int            DateStyle = USE_ISO_DATES;
 bool           EuroDates = false;
 bool           HasCTZSet = false;
 bool           CDayLight = false;
 int            CTimeZone = 0;
-char           CTZName[8] = "";
+char           CTZName[MAXTZLEN+1] = "";
 
 char DateFormat[20]    = "%d-%m-%Y";   /* mjl: sizes! or better malloc? XXX */
 char FloatFormat[20] = "%f";
index 647e6a9..681c9b5 100644 (file)
@@ -7,7 +7,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_operator.h,v 1.5 1997/03/12 21:27:18 scrappy Exp $
+ * $Id: pg_operator.h,v 1.6 1997/03/25 08:10:37 scrappy Exp $
  *
  * NOTES
  *    the genbki.sh script reads this file and generates .bki
@@ -185,7 +185,7 @@ DATA(insert OID = 513 (  "@@"      PGUID 0 l t f   0 603 600   0   0   0   0 box
 DATA(insert OID = 514 (  "*"       PGUID 0 b t f  23  23  23 514   0   0   0 int4mul intltsel intltjoinsel ));
 DATA(insert OID = 515 (  "!"       PGUID 0 r t f  23   0  23   0   0   0   0 int4fac intltsel intltjoinsel ));
 DATA(insert OID = 516 (  "!!"      PGUID 0 l t f   0  23  23   0   0   0   0 int4fac intltsel intltjoinsel ));
-DATA(insert OID = 517 (  "<===>"   PGUID 0 b t f 600 600  23   0   0   0   0 pointdist intltsel intltjoinsel ));
+DATA(insert OID = 517 (  "<===>"   PGUID 0 b t f 600 600 701   0   0   0   0 point_distance intltsel intltjoinsel ));
 DATA(insert OID = 518 (  "<>"      PGUID 0 b t f  23  23  16 518  96  0  0 int4ne neqsel neqjoinsel ));
 DATA(insert OID = 519 (  "<>"      PGUID 0 b t f  21  21  16 519  94  0  0 int2ne neqsel neqjoinsel ));
 DATA(insert OID = 520 (  ">"       PGUID 0 b t f  21  21  16  95   0  0  0 int2gt intgtsel intgtjoinsel ));
@@ -226,8 +226,8 @@ DATA(insert OID = 554 (  "-"       PGUID 0 b t f  21  21  21   0   0   0   0 int
 DATA(insert OID = 555 (  "-"       PGUID 0 b t f  23  23  23   0   0   0   0 int4mi intltsel intltjoinsel ));
 DATA(insert OID = 556 (  "-"       PGUID 0 b t f  21  23  23   0   0   0   0 int24mi intltsel intltjoinsel ));
 DATA(insert OID = 557 (  "-"       PGUID 0 b t f  23  21  23   0   0   0   0 int42mi intltsel intltjoinsel ));
-DATA(insert OID = 558   (  "-"       PGUID 0 l t f   0  23  23  0   0   0   0 int4um intltsel intltjoinsel ));
-DATA(insert OID = 559   (  "-"       PGUID 0 l t f   0  21  21  0   0   0   0 int2um intltsel intltjoinsel ));
+DATA(insert OID = 558 (  "-"       PGUID 0 l t f   0  23  23   0   0   0   0 int4um intltsel intltjoinsel ));
+DATA(insert OID = 559 (  "-"       PGUID 0 l t f   0  21  21   0   0   0   0 int2um intltsel intltjoinsel ));
 DATA(insert OID = 560 (  "="       PGUID 0 b t t 702 702  16 560 561 562 562 abstimeeq eqsel eqjoinsel ));
 DATA(insert OID = 561 (  "<>"      PGUID 0 b t f 702 702  16 561 560 0 0 abstimene neqsel neqjoinsel ));
 DATA(insert OID = 562 (  "<"       PGUID 0 b t f 702 702  16 563 565 0 0 abstimelt intltsel intltjoinsel ));
@@ -362,8 +362,8 @@ DATA(insert OID = 935 (  "<>"      PGUID 0 b t f  910  910  16 935 932  0 0 oidi
 
 DATA(insert OID = 965 (  "^"       PGUID 0 b t f 701 701 701   0   0   0   0 dpow - - ));
 DATA(insert OID = 966 (  "+"       PGUID 0 b t f 1034 1033 1034 0 0 0 0 aclinsert   intltsel intltjoinsel ));
-DATA(insert OID =  967 (  "-"       PGUID 0 b t f 1034 1033 1034 0 0 0 0 aclremove   intltsel intltjoinsel ));
-DATA(insert OID =   968 (  "~"       PGUID 0 b t f 1034 1033   16 0 0 0 0 aclcontains intltsel intltjoinsel ));
+DATA(insert OID = 967 (  "-"       PGUID 0 b t f 1034 1033 1034 0 0 0 0 aclremove   intltsel intltjoinsel ));
+DATA(insert OID = 968 (  "~"       PGUID 0 b t f 1034 1033   16 0 0 0 0 aclcontains intltsel intltjoinsel ));
 
 DATA(insert OID = 1054 ( "="       PGUID 0 b t t  1042  1042  16  1054 1057 1058 1058 bpchareq eqsel eqjoinsel ));
 DATA(insert OID = 1055 (  "~"      PGUID 0 b t f  1042  25  16 0 1056  0 0 textregexeq eqsel eqjoinsel ));
@@ -383,16 +383,18 @@ DATA(insert OID = 1067 ( "<="      PGUID 0 b t f  1043  1043  16 1069 1068  0 0
 DATA(insert OID = 1068 ( ">"       PGUID 0 b t f  1043  1043  16 1066 1067  0 0 varchargt intltsel intltjoinsel ));
 DATA(insert OID = 1069 ( ">="      PGUID 0 b t f  1043  1043  16 1067 1066  0 0 varcharge intltsel intltjoinsel ));
 
-DATA(insert OID = 1093 ( "="       PGUID 0 b t t  1082  1082  16 1093 1094 1095 1095 date_eq eqsel eqjoinsel ));
-DATA(insert OID = 1094 ( "<>"      PGUID 0 b t f  1082  1082  16 1094 1093  0 0 date_ne neqsel neqjoinsel ));
-DATA(insert OID = 1095 ( "<"       PGUID 0 b t f  1082  1082  16 1097 1098  0 0 date_lt intltsel intltjoinsel ));
-DATA(insert OID = 1096 ( "<="      PGUID 0 b t f  1082  1082  16 1098 1097  0 0 date_le intltsel intltjoinsel ));
-DATA(insert OID = 1097 ( ">"       PGUID 0 b t f  1082  1082  16 1095 1096  0 0 date_gt intltsel intltjoinsel ));
-DATA(insert OID = 1098 ( ">="      PGUID 0 b t f  1082  1082  16 1096 1065  0 0 date_ge intltsel intltjoinsel ));
-DATA(insert OID = 1099 ( "-"       PGUID 0 b t f  1082  1082  23 0 0 0 0 date_mi - - ));
-DATA(insert OID = 1100 ( "+"       PGUID 0 b t f  1082  23  1082 0 0 0 0 date_pli - - ));
-DATA(insert OID = 1101 ( "-"       PGUID 0 b t f    1082 23 1082 0 0 0 0 date_mii - - ));
-
+/* date operators */
+DATA(insert OID = 1093 ( "="       PGUID 0 b t t  1082  1082   16 1093 1094 1095 1095 date_eq eqsel eqjoinsel ));
+DATA(insert OID = 1094 ( "<>"      PGUID 0 b t f  1082  1082   16 1094 1093  0 0 date_ne neqsel neqjoinsel ));
+DATA(insert OID = 1095 ( "<"       PGUID 0 b t f  1082  1082   16 1097 1098  0 0 date_lt intltsel intltjoinsel ));
+DATA(insert OID = 1096 ( "<="      PGUID 0 b t f  1082  1082   16 1098 1097  0 0 date_le intltsel intltjoinsel ));
+DATA(insert OID = 1097 ( ">"       PGUID 0 b t f  1082  1082   16 1095 1096  0 0 date_gt intltsel intltjoinsel ));
+DATA(insert OID = 1098 ( ">="      PGUID 0 b t f  1082  1082   16 1096 1065  0 0 date_ge intltsel intltjoinsel ));
+DATA(insert OID = 1099 ( "-"       PGUID 0 b t f  1082  1082   23 0 0 0 0 date_mi - - ));
+DATA(insert OID = 1100 ( "+"       PGUID 0 b t f  1082    23 1082 0 0 0 0 date_pli - - ));
+DATA(insert OID = 1101 ( "-"       PGUID 0 b t f  1082    23 1082 0 0 0 0 date_mii - - ));
+
+/* time operators */
 DATA(insert OID = 1108 ( "="       PGUID 0 b t t  1083  1083  16 1108 1109 1110 1110 time_eq eqsel eqjoinsel ));
 DATA(insert OID = 1109 ( "<>"      PGUID 0 b t f  1083  1083  16 1109 1108  0 0 time_ne neqsel neqjoinsel ));
 DATA(insert OID = 1110 ( "<"       PGUID 0 b t f  1083  1083  16 1112 1113  0 0 time_lt intltsel intltjoinsel ));
@@ -400,10 +402,34 @@ DATA(insert OID = 1111 ( "<="      PGUID 0 b t f  1083  1083  16 1113 1112  0 0
 DATA(insert OID = 1112 ( ">"       PGUID 0 b t f  1083  1083  16 1110 1111  0 0 time_gt intltsel intltjoinsel ));
 DATA(insert OID = 1113 ( ">="      PGUID 0 b t f  1083  1083  16 1111 1065  0 0 time_ge intltsel intltjoinsel ));
 
+/* datetime 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 datetime_eq eqsel eqjoinsel ));
+DATA(insert OID = 1321 (  "<>"     PGUID 0 b t f 1184 1184   16 1321 1320 0 0 datetime_ne neqsel neqjoinsel ));
+DATA(insert OID = 1322 (  "<"      PGUID 0 b t f 1184 1184   16 1325 1325 0 0 datetime_lt intltsel intltjoinsel ));
+DATA(insert OID = 1323 (  "<="     PGUID 0 b t f 1184 1184   16 1324 1324 0 0 datetime_le intltsel intltjoinsel ));
+DATA(insert OID = 1324 (  ">"      PGUID 0 b t f 1184 1184   16 1323 1323 0 0 datetime_gt intltsel intltjoinsel ));
+DATA(insert OID = 1325 (  ">="     PGUID 0 b t f 1184 1184   16 1322 1322 0 0 datetime_ge intltsel intltjoinsel ));
+
+DATA(insert OID = 1327 (  "+"      PGUID 0 b t f 1184 1186 1184 1327    0 0 0 datetime_add_span - - ));
+DATA(insert OID = 1328 (  "-"      PGUID 0 b t f 1184 1184 1186    0    0 0 0 datetime_sub - - ));
+
+/* timespan operators */
+DATA(insert OID = 1330 (  "="      PGUID 0 b t f 1186 1186   16 1330 1331 1332 1332 timespan_eq eqsel eqjoinsel ));
+DATA(insert OID = 1331 (  "<>"     PGUID 0 b t f 1186 1186   16 1331 1330 0 0 timespan_ne neqsel neqjoinsel ));
+DATA(insert OID = 1332 (  "<"      PGUID 0 b t f 1186 1186   16 1335 1335 0 0 timespan_lt intltsel intltjoinsel ));
+DATA(insert OID = 1333 (  "<="     PGUID 0 b t f 1186 1186   16 1334 1334 0 0 timespan_le intltsel intltjoinsel ));
+DATA(insert OID = 1334 (  ">"      PGUID 0 b t f 1186 1186   16 1333 1333 0 0 timespan_gt intltsel intltjoinsel ));
+DATA(insert OID = 1335 (  ">="     PGUID 0 b t f 1186 1186   16 1332 1332 0 0 timespan_ge intltsel intltjoinsel ));
+
+DATA(insert OID = 1336 (  "-"      PGUID 0 b t f    0 1186 1186    0    0 0 0 timespan_um 0 0 ));
+DATA(insert OID = 1337 (  "+"      PGUID 0 b t f 1186 1186 1186 1337    0 0 0 timespan_add - - ));
+DATA(insert OID = 1338 (  "-"      PGUID 0 b t f 1186 1186 1186    0    0 0 0 timespan_sub - - ));
+
 /* float48 operators */
 DATA(insert OID = 1116 (  "+"       PGUID 0 b t f 700 701 701 1116   0   0   0 float48pl - - ));
-DATA(insert OID = 1117 (  "-"       PGUID 0 b t f 700 701 701   0   0   0   0 float48mi - - ));
-DATA(insert OID = 1118 (  "/"       PGUID 0 b t f 700 701 701   0   0   0   0 float48div - - ));
+DATA(insert OID = 1117 (  "-"       PGUID 0 b t f 700 701 701    0   0   0   0 float48mi - - ));
+DATA(insert OID = 1118 (  "/"       PGUID 0 b t f 700 701 701    0   0   0   0 float48div - - ));
 DATA(insert OID = 1119 (  "*"       PGUID 0 b t f 700 701 701 1119   0   0   0 float48mul - - ));
 DATA(insert OID = 1120 (  "="       PGUID 0 b t t  700  701  16 1120 1121  1122 1122 float48eq eqsel eqjoinsel ));
 DATA(insert OID = 1121 (  "<>"      PGUID 0 b t f  700  701  16 1121 1120  0 0 float48ne neqsel neqjoinsel ));
@@ -414,8 +440,8 @@ DATA(insert OID = 1125 (  ">="      PGUID 0 b t f  700  701  16 1124 1122  0 0 f
 
 /* float84 operators */
 DATA(insert OID = 1126 (  "+"       PGUID 0 b t f 701 700 701 1126   0   0   0 float84pl - - ));
-DATA(insert OID = 1127 (  "-"       PGUID 0 b t f 701 700 701   0   0   0   0 float84mi - - ));
-DATA(insert OID = 1128 (  "/"       PGUID 0 b t f 701 700 701   0   0   0   0 float84div - - ));
+DATA(insert OID = 1127 (  "-"       PGUID 0 b t f 701 700 701    0   0   0   0 float84mi - - ));
+DATA(insert OID = 1128 (  "/"       PGUID 0 b t f 701 700 701    0   0   0   0 float84div - - ));
 DATA(insert OID = 1129 (  "*"       PGUID 0 b t f 701 700 701 1129   0   0   0 float84mul - - ));
 DATA(insert OID = 1130 (  "="       PGUID 0 b t t  701  700  16 1130 1131  1132 1132 float84eq eqsel eqjoinsel ));
 DATA(insert OID = 1131 (  "<>"      PGUID 0 b t f  701  700  16 1131 1130  0 0 float84ne neqsel neqjoinsel ));
@@ -463,6 +489,7 @@ DATA(insert OID = 1232 (  "~*"      PGUID 0 b t f  1043  25  16 0 1233  0 0 text
 DATA(insert OID = 1233 ( "!~*"      PGUID 0 b t f  1043  25  16 0 1232  0 0 texticregexne neqsel neqjoinsel ));
 DATA(insert OID = 1234 (  "~*"      PGUID 0 b t f  1042  25  16 0 1235  0 0 texticregexeq eqsel eqjoinsel ));
 DATA(insert OID = 1235 ( "!~*"      PGUID 0 b t f  1042  25  16 0 1234  0 0 texticregexne neqsel neqjoinsel ));
+
 DATA(insert OID = 1300 (  "="       PGUID 0 b t t  1296 1296 16 1300 1301 1302 1302 timestampeq eqsel eqjoinsel ));
 DATA(insert OID = 1301 (  "<>"      PGUID 0 b t f  1296 1296 16 1301 1300 0 0 timestampne neqsel neqjoinsel ));
 DATA(insert OID = 1302 (  "<"       PGUID 0 b t f  1296 1296 16 1303 1305 0 0 timestamplt intltsel intltjoinsel ));
index 12a82ee..11ed9c3 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_proc.h,v 1.13 1997/03/24 07:32:38 vadim Exp $
+ * $Id: pg_proc.h,v 1.14 1997/03/25 08:10:50 scrappy Exp $
  *
  * NOTES
  *    The script catalog/genbki.sh reads this file and generates .bki
@@ -92,14 +92,14 @@ typedef FormData_pg_proc    *Form_pg_proc;
 /* keep the following ordered by OID so that later changes can be made easier*/
 
 /* OIDS 1 - 99 */
-DATA(insert OID = 1242 (  boolin            PGUID 11 f t f 1 f 16 "0" 100 0 0  100  foo bar ));
-DATA(insert OID = 1243 (  boolout           PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 1244 (  byteain           PGUID 11 f t f 1 f 17 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 1242 (  boolin           PGUID 11 f t f 1 f 16 "0" 100 0 0  100  foo bar ));
+DATA(insert OID = 1243 (  boolout          PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 1244 (  byteain          PGUID 11 f t f 1 f 17 "0" 100 0 0 100  foo bar ));
 DATA(insert OID =  31 (  byteaout          PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 1245 (  charin            PGUID 11 f t f 1 f 18 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 1245 (  charin           PGUID 11 f t f 1 f 18 "0" 100 0 0 100  foo bar ));
 DATA(insert OID =  33 (  charout           PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID =  34 (  namein          PGUID 11 f t f 1 f 19 "0" 100 0 0 100  foo bar ));
-DATA(insert OID =  35 (  nameout         PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID =  34 (  namein            PGUID 11 f t f 1 f 19 "0" 100 0 0 100  foo bar ));
+DATA(insert OID =  35 (  nameout           PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
 DATA(insert OID =  36 (  char16in          PGUID 11 f t f 1 f 19 "0" 100 0 0 100  foo bar ));
 DATA(insert OID =  37 (  char16out         PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
 DATA(insert OID =  38 (  int2in            PGUID 11 f t f 1 f 21 "0" 100 0 0 100  foo bar ));
@@ -126,7 +126,7 @@ DATA(insert OID =  60 (  booleq            PGUID 11 f t f 2 f 16 "16 16" 100 0 0
 DATA(insert OID =  61 (  chareq            PGUID 11 f t f 2 f 16 "18 18" 100 0 0 100  foo bar ));
 #define       CharacterEqualRegProcedure      61
 
-DATA(insert OID =  62 (  nameeq          PGUID 11 f t f 2 f 16 "19 19" 100 0 0 100  foo bar ));
+DATA(insert OID =  62 (  nameeq            PGUID 11 f t f 2 f 16 "19 19" 100 0 0 100  foo bar ));
 #define NameEqualRegProcedure          62
     
 DATA(insert OID =  63 (  int2eq            PGUID 11 f t f 2 f 16 "21 21" 100 0 0 100  foo bar ));
@@ -143,30 +143,30 @@ DATA(insert OID =  67 (  texteq            PGUID 11 f t f 2 f 16 "25 25" 100 0 0
 DATA(insert OID =  68 (  xideq             PGUID 11 f t f 2 f 16 "28 28" 100 0 0 100  foo bar ));
 DATA(insert OID =  69 (  cideq             PGUID 11 f t f 2 f 16 "29 29" 100 0 0 100  foo bar ));
 DATA(insert OID =  70 (  charne            PGUID 11 f t f 2 f 16 "18 18" 100 0 0 100  foo bar ));
-DATA(insert OID = 1246 (  charlt            PGUID 11 f t f 2 f 16 "18 18" 100 0 0 100  foo bar ));
+DATA(insert OID = 1246 (  charlt           PGUID 11 f t f 2 f 16 "18 18" 100 0 0 100  foo bar ));
 DATA(insert OID =  72 (  charle            PGUID 11 f t f 2 f 16 "18 18" 100 0 0 100  foo bar ));
 DATA(insert OID =  73 (  chargt            PGUID 11 f t f 2 f 16 "18 18" 100 0 0 100  foo bar ));
 DATA(insert OID =  74 (  charge            PGUID 11 f t f 2 f 16 "18 18" 100 0 0 100  foo bar ));
-DATA(insert OID = 1248 (  charpl            PGUID 11 f t f 2 f 18 "18 18" 100 0 0 100  foo bar ));
-DATA(insert OID = 1250 (  charmi            PGUID 11 f t f 2 f 18 "18 18" 100 0 0 100  foo bar ));
+DATA(insert OID = 1248 (  charpl           PGUID 11 f t f 2 f 18 "18 18" 100 0 0 100  foo bar ));
+DATA(insert OID = 1250 (  charmi           PGUID 11 f t f 2 f 18 "18 18" 100 0 0 100  foo bar ));
 DATA(insert OID =  77 (  charmul           PGUID 11 f t f 2 f 18 "18 18" 100 0 0 100  foo bar ));
 DATA(insert OID =  78 (  chardiv           PGUID 11 f t f 2 f 18 "18 18" 100 0 0 100  foo bar ));
 
-DATA(insert OID =  79 (  nameregexeq     PGUID 11 f t f 2 f 16 "19 25" 100 0 0 100  foo bar ));
-DATA(insert OID = 1252 (  nameregexne     PGUID 11 f t f 2 f 16 "19 25" 100 0 0 100  foo bar ));
-DATA(insert OID = 1254 (  textregexeq       PGUID 11 f t f 2 f 16 "25 25" 100 0 1 0  foo bar ));
-DATA(insert OID = 1256 (  textregexne       PGUID 11 f t f 2 f 16 "25 25" 100 0 1 0  foo bar ));
-DATA(insert OID = 1258 (  textcat           PGUID 11 f t f 2 f 25 "25 25" 100 0 1 0  foo bar ));
+DATA(insert OID =  79 (  nameregexeq       PGUID 11 f t f 2 f 16 "19 25" 100 0 0 100  foo bar ));
+DATA(insert OID = 1252 (  nameregexne      PGUID 11 f t f 2 f 16 "19 25" 100 0 0 100  foo bar ));
+DATA(insert OID = 1254 (  textregexeq      PGUID 11 f t f 2 f 16 "25 25" 100 0 1 0  foo bar ));
+DATA(insert OID = 1256 (  textregexne      PGUID 11 f t f 2 f 16 "25 25" 100 0 1 0  foo bar ));
+DATA(insert OID = 1258 (  textcat          PGUID 11 f t f 2 f 25 "25 25" 100 0 1 0  foo bar ));
 DATA(insert OID =  84 (  boolne            PGUID 11 f t f 2 f 16 "16 16" 100 0 0 100  foo bar ));
 
-DATA(insert OID = 1265 (  rtsel             PGUID 11 f t f 7 f 701 "26 26 21 0 23 23 26" 100 0 0 100  foo bar ));
-DATA(insert OID = 1266 (  rtnpage           PGUID 11 f t f 7 f 701 "26 26 21 0 23 23 26" 100 0 0 100  foo bar ));
-DATA(insert OID = 1268 (  btreesel          PGUID 11 f t f 7 f 701 "26 26 21 0 23 23 26" 100 0 0 100  foo bar ));
+DATA(insert OID = 1265 (  rtsel            PGUID 11 f t f 7 f 701 "26 26 21 0 23 23 26" 100 0 0 100  foo bar ));
+DATA(insert OID = 1266 (  rtnpage          PGUID 11 f t f 7 f 701 "26 26 21 0 23 23 26" 100 0 0 100  foo bar ));
+DATA(insert OID = 1268 (  btreesel         PGUID 11 f t f 7 f 701 "26 26 21 0 23 23 26" 100 0 0 100  foo bar ));
 
 /* OIDS 100 - 199 */
 
-DATA(insert OID = 1270 (  btreenpage        PGUID 11 f t f 7 f 701 "26 26 21 0 23 23 26" 100 0 0 100  foo bar ));
-DATA(insert OID = 1272 (  eqsel             PGUID 11 f t f 5 f 701 "26 26 21 0 23" 100 0 0 100  foo bar ));
+DATA(insert OID = 1270 (  btreenpage       PGUID 11 f t f 7 f 701 "26 26 21 0 23 23 26" 100 0 0 100  foo bar ));
+DATA(insert OID = 1272 (  eqsel            PGUID 11 f t f 5 f 701 "26 26 21 0 23" 100 0 0 100  foo bar ));
 #define EqualSelectivityProcedure 1272
 
 DATA(insert OID = 102 (  neqsel            PGUID 11 f t f 5 f 701 "26 26 21 0 23" 100 0 0 100  foo bar ));
@@ -423,7 +423,7 @@ DATA(insert OID = 355 (  btfloat8cmp       PGUID 11 f t f 2 f 23 "701 701" 100 0
 DATA(insert OID = 356 (  btoidcmp          PGUID 11 f t f 2 f 23 "26 26" 100 0 0 100  foo bar ));
 DATA(insert OID = 357 (  btabstimecmp      PGUID 11 f t f 2 f 23 "702 702" 100 0 0 100  foo bar ));
 DATA(insert OID = 358 (  btcharcmp         PGUID 11 f t f 2 f 23 "18 18" 100 0 0 100  foo bar ));
-DATA(insert OID = 359 (  btnamecmp       PGUID 11 f t f 2 f 23 "19 19" 100 0 0 100  foo bar ));
+DATA(insert OID = 359 (  btnamecmp         PGUID 11 f t f 2 f 23 "19 19" 100 0 0 100  foo bar ));
 DATA(insert OID = 360 (  bttextcmp         PGUID 11 f t f 2 f 23 "25 25" 100 0 0 100  foo bar ));
 
 DATA(insert OID = 361 (  lseg_distance     PGUID 11 f t f 2 f 701 "601 601" 100 0 0 100  foo bar ));
@@ -439,56 +439,56 @@ DATA(insert OID = 370 (  path_distance     PGUID 11 f t f 2 f 701 "602 602" 100
 DATA(insert OID = 371 (  dist_ppth         PGUID 11 f t f 2 f 701 "600 602" 100 0 1 0 foo bar ));
 DATA(insert OID = 372 (  on_sb             PGUID 11 f t f 2 f 16 "601 603" 100 0 0 100  foo bar ));
 DATA(insert OID = 373 (  inter_sb          PGUID 11 f t f 2 f 16 "601 603" 100 0 0 100  foo bar ));
-DATA(insert OID = 1274 (  btchar16cmp       PGUID 11 f t f 2 f 23 "19 19" 100 0 0 100  foo bar ));
+DATA(insert OID = 1274 (  btchar16cmp      PGUID 11 f t f 2 f 23 "19 19" 100 0 0 100  foo bar ));
 
 /* OIDS 400 - 499 */
 
 DATA(insert OID =  438 (  hashsel          PGUID 11 f t t 7 f 701 "26 26 21 0 23 23 26" 100 0 0 100  foo bar ));
 DATA(insert OID =  439 (  hashnpage        PGUID 11 f t t 7 f 701 "26 26 21 0 23 23 26" 100 0 0 100  foo bar ));
 
-DATA(insert OID = 440 (  hashgettuple     PGUID 11 f t f 2 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 441 (  hashinsert       PGUID 11 f t f 5 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 442 (  hashdelete       PGUID 11 f t f 2 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 443 (  hashbeginscan    PGUID 11 f t f 4 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 444 (  hashrescan       PGUID 11 f t f 3 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 445 (  hashendscan      PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 446 (  hashmarkpos      PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 447 (  hashrestrpos     PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 448 (  hashbuild        PGUID 11 f t f 9 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 449 (  hashint2         PGUID 11 f t f 2 f 23 "21 21" 100 0 0 100  foo bar ));
-DATA(insert OID = 450 (  hashint4         PGUID 11 f t f 2 f 23 "23 23" 100 0 0 100  foo bar ));
-DATA(insert OID = 451 (  hashfloat4       PGUID 11 f t f 2 f 23 "700 700" 100 0 0 100  foo bar ));
-DATA(insert OID = 452 (  hashfloat8       PGUID 11 f t f 2 f 23 "701 701" 100 0 0 100  foo bar ));
-DATA(insert OID = 453 (  hashoid          PGUID 11 f t f 2 f 23 "26 26" 100 0 0 100  foo bar ));
-DATA(insert OID = 454 (  hashchar         PGUID 11 f t f 2 f 23 "18 18" 100 0 0 100  foo bar ));
-DATA(insert OID = 455 (  hashname       PGUID 11 f t f 2 f 23 "19 19" 100 0 0 100  foo bar ));
-DATA(insert OID = 456 (  hashtext         PGUID 11 f t f 2 f 23 "25 25" 100 0 0 100  foo bar ));
-DATA(insert OID = 466 (  char2in          PGUID 11 f t f 1 f 409 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 467 (  char4in          PGUID 11 f t f 1 f 410 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 468 (  char8in          PGUID 11 f t f 1 f 411 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 469 (  char2out         PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 470 (  char4out         PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 471 (  char8out         PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 472 (  char2eq          PGUID 11 f t f 2 f 16 "409 409" 100 0 0 100  foo bar ));
-DATA(insert OID = 473 (  char4eq          PGUID 11 f t f 2 f 16 "410 410" 100 0 0 100  foo bar ));
-DATA(insert OID = 474 (  char8eq          PGUID 11 f t f 2 f 16 "411 411" 100 0 0 100  foo bar ));
-DATA(insert OID = 475 (  char2lt          PGUID 11 f t f 2 f 16 "409 409" 100 0 0 100  foo bar ));
-DATA(insert OID = 476 (  char4lt          PGUID 11 f t f 2 f 16 "410 410" 100 0 0 100  foo bar ));
-DATA(insert OID = 477 (  char8lt          PGUID 11 f t f 2 f 16 "411 411" 100 0 0 100  foo bar ));
-DATA(insert OID = 478 (  char2le          PGUID 11 f t f 2 f 16 "409 409" 100 0 0 100  foo bar ));
-DATA(insert OID = 479 (  char4le          PGUID 11 f t f 2 f 16 "410 410" 100 0 0 100  foo bar ));
-DATA(insert OID = 480 (  char8le          PGUID 11 f t f 2 f 16 "411 411" 100 0 0 100  foo bar ));
-DATA(insert OID = 481 (  char2gt          PGUID 11 f t f 2 f 16 "409 409" 100 0 0 100  foo bar ));
-DATA(insert OID = 482 (  char4gt          PGUID 11 f t f 2 f 16 "410 410" 100 0 0 100  foo bar ));
-DATA(insert OID = 483 (  char8gt          PGUID 11 f t f 2 f 16 "411 411" 100 0 0 100  foo bar ));
-DATA(insert OID = 484 (  char2ge          PGUID 11 f t f 2 f 16 "409 409" 100 0 0 100  foo bar ));
-DATA(insert OID = 1275 (  char16eq          PGUID 11 f t f 2 f 16 "19 19" 100 0 0 100  foo bar ));
+DATA(insert OID = 440 (  hashgettuple      PGUID 11 f t f 2 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 441 (  hashinsert        PGUID 11 f t f 5 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 442 (  hashdelete        PGUID 11 f t f 2 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 443 (  hashbeginscan     PGUID 11 f t f 4 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 444 (  hashrescan        PGUID 11 f t f 3 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 445 (  hashendscan       PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 446 (  hashmarkpos       PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 447 (  hashrestrpos      PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 448 (  hashbuild         PGUID 11 f t f 9 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 449 (  hashint2          PGUID 11 f t f 2 f 23 "21 21" 100 0 0 100  foo bar ));
+DATA(insert OID = 450 (  hashint4          PGUID 11 f t f 2 f 23 "23 23" 100 0 0 100  foo bar ));
+DATA(insert OID = 451 (  hashfloat4        PGUID 11 f t f 2 f 23 "700 700" 100 0 0 100  foo bar ));
+DATA(insert OID = 452 (  hashfloat8        PGUID 11 f t f 2 f 23 "701 701" 100 0 0 100  foo bar ));
+DATA(insert OID = 453 (  hashoid           PGUID 11 f t f 2 f 23 "26 26" 100 0 0 100  foo bar ));
+DATA(insert OID = 454 (  hashchar          PGUID 11 f t f 2 f 23 "18 18" 100 0 0 100  foo bar ));
+DATA(insert OID = 455 (  hashname          PGUID 11 f t f 2 f 23 "19 19" 100 0 0 100  foo bar ));
+DATA(insert OID = 456 (  hashtext          PGUID 11 f t f 2 f 23 "25 25" 100 0 0 100  foo bar ));
+DATA(insert OID = 466 (  char2in           PGUID 11 f t f 1 f 409 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 467 (  char4in           PGUID 11 f t f 1 f 410 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 468 (  char8in           PGUID 11 f t f 1 f 411 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 469 (  char2out          PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 470 (  char4out          PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 471 (  char8out          PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 472 (  char2eq           PGUID 11 f t f 2 f 16 "409 409" 100 0 0 100  foo bar ));
+DATA(insert OID = 473 (  char4eq           PGUID 11 f t f 2 f 16 "410 410" 100 0 0 100  foo bar ));
+DATA(insert OID = 474 (  char8eq           PGUID 11 f t f 2 f 16 "411 411" 100 0 0 100  foo bar ));
+DATA(insert OID = 475 (  char2lt           PGUID 11 f t f 2 f 16 "409 409" 100 0 0 100  foo bar ));
+DATA(insert OID = 476 (  char4lt           PGUID 11 f t f 2 f 16 "410 410" 100 0 0 100  foo bar ));
+DATA(insert OID = 477 (  char8lt           PGUID 11 f t f 2 f 16 "411 411" 100 0 0 100  foo bar ));
+DATA(insert OID = 478 (  char2le           PGUID 11 f t f 2 f 16 "409 409" 100 0 0 100  foo bar ));
+DATA(insert OID = 479 (  char4le           PGUID 11 f t f 2 f 16 "410 410" 100 0 0 100  foo bar ));
+DATA(insert OID = 480 (  char8le           PGUID 11 f t f 2 f 16 "411 411" 100 0 0 100  foo bar ));
+DATA(insert OID = 481 (  char2gt           PGUID 11 f t f 2 f 16 "409 409" 100 0 0 100  foo bar ));
+DATA(insert OID = 482 (  char4gt           PGUID 11 f t f 2 f 16 "410 410" 100 0 0 100  foo bar ));
+DATA(insert OID = 483 (  char8gt           PGUID 11 f t f 2 f 16 "411 411" 100 0 0 100  foo bar ));
+DATA(insert OID = 484 (  char2ge           PGUID 11 f t f 2 f 16 "409 409" 100 0 0 100  foo bar ));
+DATA(insert OID = 1275 (  char16eq         PGUID 11 f t f 2 f 16 "19 19" 100 0 0 100  foo bar ));
 #define Character16EqualRegProcedure   1275
-DATA(insert OID = 1276 (  char16lt          PGUID 11 f t f 2 f 16 "19 19" 100 0 0 100  foo bar ));
-DATA(insert OID = 1277 (  char16le          PGUID 11 f t f 2 f 16 "19 19" 100 0 0 100  foo bar ));
-DATA(insert OID = 1278 (  char16gt          PGUID 11 f t f 2 f 16 "19 19" 100 0 0 100  foo bar ));
-DATA(insert OID = 1279 (  char16ge          PGUID 11 f t f 2 f 16 "19 19" 100 0 0 100  foo bar ));
-DATA(insert OID = 1280 (  char16ne          PGUID 11 f t f 2 f 16 "19 19" 100 0 0 100  foo bar ));
+DATA(insert OID = 1276 (  char16lt         PGUID 11 f t f 2 f 16 "19 19" 100 0 0 100  foo bar ));
+DATA(insert OID = 1277 (  char16le         PGUID 11 f t f 2 f 16 "19 19" 100 0 0 100  foo bar ));
+DATA(insert OID = 1278 (  char16gt         PGUID 11 f t f 2 f 16 "19 19" 100 0 0 100  foo bar ));
+DATA(insert OID = 1279 (  char16ge         PGUID 11 f t f 2 f 16 "19 19" 100 0 0 100  foo bar ));
+DATA(insert OID = 1280 (  char16ne         PGUID 11 f t f 2 f 16 "19 19" 100 0 0 100  foo bar ));
 
 DATA(insert OID = 1281 (  hashchar16       PGUID 11 f t f 2 f 23 "19 19" 100 0 0 100  foo bar ));
 
@@ -496,42 +496,42 @@ DATA(insert OID = 1281 (  hashchar16       PGUID 11 f t f 2 f 23 "19 19" 100 0 0
 
 /* OIDS 600 - 699 */
 
-DATA(insert OID = 1285 (  int4notin         PGUID 11 f t f 2 f 16 "21 0" 100 0 0 100  foo bar ));
-DATA(insert OID = 1286 (  oidnotin          PGUID 11 f t f 2 f 16 "26 0" 100 0 0 100  foo bar ));
-DATA(insert OID = 1287 (  int44in           PGUID 11 f t f 1 f 22 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 1285 (  int4notin        PGUID 11 f t f 2 f 16 "21 0" 100 0 0 100  foo bar ));
+DATA(insert OID = 1286 (  oidnotin         PGUID 11 f t f 2 f 16 "26 0" 100 0 0 100  foo bar ));
+DATA(insert OID = 1287 (  int44in          PGUID 11 f t f 1 f 22 "0" 100 0 0 100  foo bar ));
 DATA(insert OID = 653 (  int44out          PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 655 (  namelt          PGUID 11 f t f 2 f 16 "19 19" 100 0 0 100  foo bar ));
-DATA(insert OID = 656 (  namele          PGUID 11 f t f 2 f 16 "19 19" 100 0 0 100  foo bar ));
-DATA(insert OID = 657 (  namegt          PGUID 11 f t f 2 f 16 "19 19" 100 0 0 100  foo bar ));
-DATA(insert OID = 658 (  namege          PGUID 11 f t f 2 f 16 "19 19" 100 0 0 100  foo bar ));
-DATA(insert OID = 659 (  namene          PGUID 11 f t f 2 f 16 "19 19" 100 0 0 100  foo bar ));
+DATA(insert OID = 655 (  namelt            PGUID 11 f t f 2 f 16 "19 19" 100 0 0 100  foo bar ));
+DATA(insert OID = 656 (  namele            PGUID 11 f t f 2 f 16 "19 19" 100 0 0 100  foo bar ));
+DATA(insert OID = 657 (  namegt            PGUID 11 f t f 2 f 16 "19 19" 100 0 0 100  foo bar ));
+DATA(insert OID = 658 (  namege            PGUID 11 f t f 2 f 16 "19 19" 100 0 0 100  foo bar ));
+DATA(insert OID = 659 (  namene            PGUID 11 f t f 2 f 16 "19 19" 100 0 0 100  foo bar ));
 DATA(insert OID = 682 (  mktinterval       PGUID 11 f t f 2 f 704 "702 702" 100 0 0 100 foo bar ));
 DATA(insert OID = 683 (  oid8eq                   PGUID 11 f t f 2 f 16 "30 30" 100 0 0 100  foo bar ));
-DATA(insert OID = 684 (  char4ge          PGUID 11 f t f 2 f 16 "410 410" 100 0 0 100  foo bar ));
-DATA(insert OID = 685 (  char8ge          PGUID 11 f t f 2 f 16 "411 411" 100 0 0 100  foo bar ));
-DATA(insert OID = 686 (  char2ne          PGUID 11 f t f 2 f 16 "409 409" 100 0 0 100  foo bar ));
-DATA(insert OID = 687 (  char4ne          PGUID 11 f t f 2 f 16 "410 410" 100 0 0 100  foo bar ));
-DATA(insert OID = 688 (  char8ne          PGUID 11 f t f 2 f 16 "411 411" 100 0 0 100  foo bar ));
-DATA(insert OID = 689 (  btchar2cmp       PGUID 11 f t f 2 f 23 "409 409" 100 0 0 100  foo bar ));
-DATA(insert OID = 690 (  btchar4cmp       PGUID 11 f t f 2 f 23 "410 410" 100 0 0 100  foo bar ));
-DATA(insert OID = 691 (  btchar8cmp       PGUID 11 f t f 2 f 23 "411 411" 100 0 0 100  foo bar ));
-DATA(insert OID = 692 (  hashchar2       PGUID 11 f t f 2 f 23 "409 409" 100 0 0 100  foo bar ));
-DATA(insert OID = 693 (  hashchar4       PGUID 11 f t f 2 f 23 "410 410" 100 0 0 100  foo bar ));
-DATA(insert OID = 694 (  hashchar8       PGUID 11 f t f 2 f 23 "411 411" 100 0 0 100  foo bar ));
-DATA(insert OID =  695 (  char8regexeq     PGUID 11 f t f 2 f 16 "411 25" 100 0 0 100  foo bar ));
-DATA(insert OID =  696 (  char8regexne     PGUID 11 f t f 2 f 16 "411 25" 100 0 0 100  foo bar ));
-DATA(insert OID =  699 (  char2regexeq     PGUID 11 f t f 2 f 16 "409 25" 100 0 0 100  foo bar ));
+DATA(insert OID = 684 (  char4ge           PGUID 11 f t f 2 f 16 "410 410" 100 0 0 100  foo bar ));
+DATA(insert OID = 685 (  char8ge           PGUID 11 f t f 2 f 16 "411 411" 100 0 0 100  foo bar ));
+DATA(insert OID = 686 (  char2ne           PGUID 11 f t f 2 f 16 "409 409" 100 0 0 100  foo bar ));
+DATA(insert OID = 687 (  char4ne           PGUID 11 f t f 2 f 16 "410 410" 100 0 0 100  foo bar ));
+DATA(insert OID = 688 (  char8ne           PGUID 11 f t f 2 f 16 "411 411" 100 0 0 100  foo bar ));
+DATA(insert OID = 689 (  btchar2cmp        PGUID 11 f t f 2 f 23 "409 409" 100 0 0 100  foo bar ));
+DATA(insert OID = 690 (  btchar4cmp        PGUID 11 f t f 2 f 23 "410 410" 100 0 0 100  foo bar ));
+DATA(insert OID = 691 (  btchar8cmp        PGUID 11 f t f 2 f 23 "411 411" 100 0 0 100  foo bar ));
+DATA(insert OID = 692 (  hashchar2         PGUID 11 f t f 2 f 23 "409 409" 100 0 0 100  foo bar ));
+DATA(insert OID = 693 (  hashchar4         PGUID 11 f t f 2 f 23 "410 410" 100 0 0 100  foo bar ));
+DATA(insert OID = 694 (  hashchar8         PGUID 11 f t f 2 f 23 "411 411" 100 0 0 100  foo bar ));
+DATA(insert OID = 695 (  char8regexeq      PGUID 11 f t f 2 f 16 "411 25" 100 0 0 100  foo bar ));
+DATA(insert OID = 696 (  char8regexne      PGUID 11 f t f 2 f 16 "411 25" 100 0 0 100  foo bar ));
+DATA(insert OID = 699 (  char2regexeq      PGUID 11 f t f 2 f 16 "409 25" 100 0 0 100  foo bar ));
 
 /* OIDS 700 - 799 */
-DATA(insert OID = 1288 (  char16regexeq     PGUID 11 f t f 2 f 16 "19 25" 100 0 0 100  foo bar ));
-DATA(insert OID = 1289 (  char16regexne     PGUID 11 f t f 2 f 16 "19 25" 100 0 0 100  foo bar ));
+DATA(insert OID = 1288 (  char16regexeq    PGUID 11 f t f 2 f 16 "19 25" 100 0 0 100  foo bar ));
+DATA(insert OID = 1289 (  char16regexne    PGUID 11 f t f 2 f 16 "19 25" 100 0 0 100  foo bar ));
 
-DATA(insert OID = 710 (  GetPgUserName       PGUID 11 f t f 0 f 19 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 710 (  GetPgUserName     PGUID 11 f t f 0 f 19 "0" 100 0 0 100  foo bar ));
 DATA(insert OID = 711 (  userfntest        PGUID 11 f t f 1 f 23 "23" 100 0 0 100  foo bar ));
-DATA(insert OID = 713 (  oidrand          PGUID 11 f t f 2 f 16 "26 23" 100 0 0 100  foo bar ));
-DATA(insert OID = 715 (  oidsrand         PGUID 11 f t f 1 f 16 "23" 100 0 0 100  foo bar ));
-DATA(insert OID = 716 (  oideqint4        PGUID 11 f t f 2 f 16 "26 23" 100 0 0 100  foo bar ));
-DATA(insert OID = 717 (  int4eqoid        PGUID 11 f t f 2 f 16 "23 26" 100 0 0 100  foo bar ));
+DATA(insert OID = 713 (  oidrand           PGUID 11 f t f 2 f 16 "26 23" 100 0 0 100  foo bar ));
+DATA(insert OID = 715 (  oidsrand          PGUID 11 f t f 1 f 16 "23" 100 0 0 100  foo bar ));
+DATA(insert OID = 716 (  oideqint4         PGUID 11 f t f 2 f 16 "26 23" 100 0 0 100  foo bar ));
+DATA(insert OID = 717 (  int4eqoid         PGUID 11 f t f 2 f 16 "23 26" 100 0 0 100  foo bar ));
 
 
 DATA(insert OID = 720 (  byteaGetSize     PGUID 11 f t f 1 f 23 "17" 100 0 0 100  foo bar ));
@@ -547,8 +547,8 @@ DATA(insert OID = 741 (  text_le           PGUID 11 f t f 2 f 16 "25 25" 100 0 0
 DATA(insert OID = 742 (  text_gt           PGUID 11 f t f 2 f 16 "25 25" 100 0 0 0  foo bar ));
 DATA(insert OID = 743 (  text_ge           PGUID 11 f t f 2 f 16 "25 25" 100 0 0 0  foo bar ));
 
-DATA(insert OID = 744 (  array_eq         PGUID 11 f t f 2 f 16 "0 0" 100 0 0 100 foo bar));
-DATA(insert OID = 745 (  array_assgn      PGUID 11 f t f 8 f 23 "0 23 0 0 0 23 23 0" 100 0 0 100 foo bar));
+DATA(insert OID = 744 (  array_eq          PGUID 11 f t f 2 f 16 "0 0" 100 0 0 100 foo bar));
+DATA(insert OID = 745 (  array_assgn       PGUID 11 f t f 8 f 23 "0 23 0 0 0 23 23 0" 100 0 0 100 foo bar));
 DATA(insert OID = 746 (  array_clip        PGUID 11 f t f 7 f 23 "0 23 0 0 23 23 0" 100 0 0 100 foo bar));
 DATA(insert OID = 747 (  array_dims        PGUID 11 f t f 1 f 25 "0" 100 0 0 100 foo bar));
 DATA(insert OID = 748 (  array_set         PGUID 11 f t f 8 f 23 "0 23 0 0 23 23 23 0" 100 0 0 100 foo bar));
@@ -573,17 +573,17 @@ DATA(insert OID = 768 (  int4larger        PGUID 11 f t f 2 f 23 "23 23" 100 0 0
 DATA(insert OID = 769 (  int4smaller       PGUID 11 f t f 2 f 23 "23 23" 100 0 0 100  foo bar ));
 DATA(insert OID = 770 (  int2larger        PGUID 11 f t f 2 f 21 "21 21" 100 0 0 100  foo bar ));
 DATA(insert OID = 771 (  int2smaller       PGUID 11 f t f 2 f 21 "21 21" 100 0 0 100  foo bar ));
-DATA(insert OID =  772 (  gistsel          PGUID 11 f t t 7 f 701 "26 26 21 0 23 23 26" 100 0 0 100  foo bar ));
-DATA(insert OID =  773 (  gistnpage        PGUID 11 f t t 7 f 701 "26 26 21 0 23 23 26" 100 0 0 100  foo bar ));
-DATA(insert OID = 774 (  gistgettuple     PGUID 11 f t f 2 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 775 (  gistinsert       PGUID 11 f t f 5 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 776 (  gistdelete       PGUID 11 f t f 2 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 777 (  gistbeginscan    PGUID 11 f t f 4 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 778 (  gistrescan       PGUID 11 f t f 3 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 779 (  gistendscan      PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 780 (  gistmarkpos      PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 781 (  gistrestrpos     PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 782 (  gistbuild        PGUID 11 f t f 9 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 772 (  gistsel           PGUID 11 f t t 7 f 701 "26 26 21 0 23 23 26" 100 0 0 100  foo bar ));
+DATA(insert OID = 773 (  gistnpage         PGUID 11 f t t 7 f 701 "26 26 21 0 23 23 26" 100 0 0 100  foo bar ));
+DATA(insert OID = 774 (  gistgettuple      PGUID 11 f t f 2 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 775 (  gistinsert        PGUID 11 f t f 5 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 776 (  gistdelete        PGUID 11 f t f 2 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 777 (  gistbeginscan     PGUID 11 f t f 4 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 778 (  gistrescan        PGUID 11 f t f 3 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 779 (  gistendscan       PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 780 (  gistmarkpos       PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 781 (  gistrestrpos      PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 782 (  gistbuild         PGUID 11 f t f 9 f 23 "0" 100 0 0 100  foo bar ));
 
 /* OIDS 800 - 899 */
 DATA(insert OID = 820 (  oidint2in        PGUID 11 f t f 1 f 810 "0" 100 0 0 100  foo bar));
@@ -604,18 +604,18 @@ DATA(insert OID =  837 (  char2regexne     PGUID 11 f t f 2 f 16 "409 25" 100 0
 DATA(insert OID =  836 (  char4regexeq     PGUID 11 f t f 2 f 16 "410 25" 100 0 0 100  foo bar ));
 DATA(insert OID =  838 (  char4regexne     PGUID 11 f t f 2 f 16 "410 25" 100 0 0 100  foo bar ));
 
-DATA(insert OID =  850 (  textlike     PGUID 11 f t f 2 f 16 "25 25" 100 0 1 0 foo bar ));
-DATA(insert OID =  851 (  textnlike    PGUID 11 f t f 2 f 16 "25 25" 100 0 1 0 foo bar ));
-DATA(insert OID =  852 (  char2like    PGUID 11 f t f 2 f 16 "409 25" 100 0 0 100  foo bar ));
-DATA(insert OID =  853 (  char2nlike   PGUID 11 f t f 2 f 16 "409 25" 100 0 0 100  foo bar ));
-DATA(insert OID =  854 (  char4like    PGUID 11 f t f 2 f 16 "410 25" 100 0 0 100  foo bar ));
-DATA(insert OID =  855 (  char4nlike   PGUID 11 f t f 2 f 16 "410 25" 100 0 0 100  foo bar ));
-DATA(insert OID =  856 (  char8like    PGUID 11 f t f 2 f 16 "411 25" 100 0 0 100  foo bar ));
-DATA(insert OID =  857 (  char8nlike   PGUID 11 f t f 2 f 16 "411 25" 100 0 0 100  foo bar ));
-DATA(insert OID =  858 (  namelike   PGUID 11 f t f 2 f 16 "19 25" 100 0 0 100  foo bar ));
-DATA(insert OID =  859 (  namenlike  PGUID 11 f t f 2 f 16 "19 25" 100 0 0 100  foo bar ));
-DATA(insert OID =  860 (  char16like   PGUID 11 f t f 2 f 16 "20 25" 100 0 0 100  foo bar ));
-DATA(insert OID =  861 (  char16nlike  PGUID 11 f t f 2 f 16 "20 25" 100 0 0 100  foo bar ));
+DATA(insert OID =  850 (  textlike         PGUID 11 f t f 2 f 16 "25 25" 100 0 1 0 foo bar ));
+DATA(insert OID =  851 (  textnlike        PGUID 11 f t f 2 f 16 "25 25" 100 0 1 0 foo bar ));
+DATA(insert OID =  852 (  char2like        PGUID 11 f t f 2 f 16 "409 25" 100 0 0 100  foo bar ));
+DATA(insert OID =  853 (  char2nlike       PGUID 11 f t f 2 f 16 "409 25" 100 0 0 100  foo bar ));
+DATA(insert OID =  854 (  char4like        PGUID 11 f t f 2 f 16 "410 25" 100 0 0 100  foo bar ));
+DATA(insert OID =  855 (  char4nlike       PGUID 11 f t f 2 f 16 "410 25" 100 0 0 100  foo bar ));
+DATA(insert OID =  856 (  char8like        PGUID 11 f t f 2 f 16 "411 25" 100 0 0 100  foo bar ));
+DATA(insert OID =  857 (  char8nlike       PGUID 11 f t f 2 f 16 "411 25" 100 0 0 100  foo bar ));
+DATA(insert OID =  858 (  namelike         PGUID 11 f t f 2 f 16 "19 25" 100 0 0 100  foo bar ));
+DATA(insert OID =  859 (  namenlike        PGUID 11 f t f 2 f 16 "19 25" 100 0 0 100  foo bar ));
+DATA(insert OID =  860 (  char16like       PGUID 11 f t f 2 f 16 "20 25" 100 0 0 100  foo bar ));
+DATA(insert OID =  861 (  char16nlike      PGUID 11 f t f 2 f 16 "20 25" 100 0 0 100  foo bar ));
  
 /* OIDS 900 - 999 */
 
@@ -729,45 +729,74 @@ DATA(insert OID = 1089 (  date_gt          PGUID 11 f t f 2 f 16 "1082 1082" 100
 DATA(insert OID = 1090 (  date_ge          PGUID 11 f t f 2 f 16 "1082 1082" 100 0 0 100  foo bar ));
 DATA(insert OID = 1091 (  date_ne          PGUID 11 f t f 2 f 16 "1082 1082" 100 0 0 100  foo bar ));
 DATA(insert OID = 1092 (  date_cmp         PGUID 11 f t f 2 f 23 "1082 1082" 100 0 0 100  foo bar ));
-DATA(insert OID = 1093 (  date_larger      PGUID 11 f t f 2 f 1082 "1082 1082" 100 0 0 100  foo bar ));
-DATA(insert OID = 1094 (  date_smaller     PGUID 11 f t f 2 f 1082 "1082 1082" 100 0 0 100  foo bar ));
-DATA(insert OID = 1095 (  date_mi          PGUID 11 f t f 2 f 23 "1082 1082" 100 0 0 100  foo bar ));
-DATA(insert OID = 1096 (  date_pli         PGUID 11 f t f 2 f 1082 "1082 23" 100 0 0 100  foo bar ));
-DATA(insert OID = 1097 (  date_mii         PGUID 11 f t f 2 f 1082 "1082 23" 100 0 0 100  foo bar ));
-DATA(insert OID = 1099 (  time_in          PGUID 11 f t f 1 f 1083 "0" 100 0 0 100  foo bar ));
 
 /* OIDS 1100 - 1199 */
-DATA(insert OID = 1100 (  time_out         PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID = 1101 (  time_eq          PGUID 11 f t f 2 f 16 "1083 1083" 100 0 0 100  foo bar ));
 DATA(insert OID = 1102 (  time_lt          PGUID 11 f t f 2 f 16 "1083 1083" 100 0 0 100  foo bar ));
 DATA(insert OID = 1103 (  time_le          PGUID 11 f t f 2 f 16 "1083 1083" 100 0 0 100  foo bar ));
 DATA(insert OID = 1104 (  time_gt          PGUID 11 f t f 2 f 16 "1083 1083" 100 0 0 100  foo bar ));
 DATA(insert OID = 1105 (  time_ge          PGUID 11 f t f 2 f 16 "1083 1083" 100 0 0 100  foo bar ));
 DATA(insert OID = 1106 (  time_ne          PGUID 11 f t f 2 f 16 "1083 1083" 100 0 0 100  foo bar ));
 DATA(insert OID = 1107 (  time_cmp         PGUID 11 f t f 2 f 23 "1083 1083" 100 0 0 100  foo bar ));
-DATA(insert OID = 1200 (  int42reltime      PGUID 11 f t f 1 f 703 "21" 100 0 0 100  foo bar ));
-
-DATA(insert OID =  1290 (  char2icregexeq     PGUID 11 f t f 2 f 16 "409 25" 100 0 0 100  foo bar ));
-DATA(insert OID =  1291 (  char2icregexne     PGUID 11 f t f 2 f 16 "409 25" 100 0 0 100  foo bar ));
-DATA(insert OID =  1292 (  char4icregexeq     PGUID 11 f t f 2 f 16 "410 25" 100 0 0 100  foo bar ));
-DATA(insert OID =  1293 (  char4icregexne     PGUID 11 f t f 2 f 16 "410 25" 100 0 0 100  foo bar ));
-DATA(insert OID =  1294 (  char8icregexeq     PGUID 11 f t f 2 f 16 "411 25" 100 0 0 100  foo bar ));
-DATA(insert OID =  1295 (  char8icregexne     PGUID 11 f t f 2 f 16 "411 25" 100 0 0 100  foo bar ));
-DATA(insert OID =  1236 (  char16icregexeq     PGUID 11 f t f 2 f 16 "20 25" 100 0 0 100  foo bar ));
-DATA(insert OID =  1237 (  char16icregexne     PGUID 11 f t f 2 f 16 "20 25" 100 0 0 100  foo bar ));
-DATA(insert OID =  1238 (  texticregexeq       PGUID 11 f t f 2 f 16 "25 25" 100 0 1 0  foo bar ));
-DATA(insert OID =  1239 (  texticregexne       PGUID 11 f t f 2 f 16 "25 25" 100 0 1 0  foo bar ));
-DATA(insert OID =  1240 (  nameicregexeq     PGUID 11 f t f 2 f 16 "19 25" 100 0 0 100  foo bar ));
-DATA(insert OID =  1241 (  nameicregexne     PGUID 11 f t f 2 f 16 "19 25" 100 0 0 100  foo bar ));
-DATA(insert OID =  1297 (  timestamp_in      PGUID 11 f t f 1 f 1296 "0" 100 0 0 100  foo bar ));
-DATA(insert OID =  1298 (  timestamp_out     PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
-DATA(insert OID =  1299 (  now               PGUID 11 f t f 0 f 1296 "0" 100 0 0 100  foo bar ));
-DATA(insert OID =  1306 (  timestampeq      PGUID 11 f t f 2 f 16 "1296 1296" 100 0 0 100  foo bar ));
-DATA(insert OID =  1307 (  timestampne      PGUID 11 f t f 2 f 16 "1296 1296" 100 0 0 100  foo bar ));
-DATA(insert OID =  1308 (  timestamplt      PGUID 11 f t f 2 f 16 "1296 1296" 100 0 0 100  foo bar ));
-DATA(insert OID =  1309 (  timestampgt      PGUID 11 f t f 2 f 16 "1296 1296" 100 0 0 100  foo bar ));
-DATA(insert OID =  1310 (  timestample      PGUID 11 f t f 2 f 16 "1296 1296" 100 0 0 100  foo bar ));
-DATA(insert OID =  1311 (  timestampge      PGUID 11 f t f 2 f 16 "1296 1296" 100 0 0 100  foo bar ));
+DATA(insert OID = 1138 (  date_larger      PGUID 11 f t f 2 f 1082 "1082 1082" 100 0 0 100  foo bar ));
+DATA(insert OID = 1139 (  date_smaller     PGUID 11 f t f 2 f 1082 "1082 1082" 100 0 0 100  foo bar ));
+DATA(insert OID = 1140 (  date_mi          PGUID 11 f t f 2 f 23 "1082 1082" 100 0 0 100  foo bar ));
+DATA(insert OID = 1141 (  date_pli         PGUID 11 f t f 2 f 1082 "1082 23" 100 0 0 100  foo bar ));
+DATA(insert OID = 1142 (  date_mii         PGUID 11 f t f 2 f 1082 "1082 23" 100 0 0 100  foo bar ));
+DATA(insert OID = 1143 (  time_in          PGUID 11 f t f 1 f 1083 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 1144 (  time_out         PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 1145 (  time_eq          PGUID 11 f t f 2 f 16 "1083 1083" 100 0 0 100  foo bar ));
+
+DATA(insert OID = 1150 (  datetime_in      PGUID 11 f t f 1 f 1184 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 1151 (  datetime_out     PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 1152 (  datetime_eq      PGUID 11 f t f 2 f 16 "1184 1184" 100 0 0 100  foo bar ));
+DATA(insert OID = 1153 (  datetime_ne      PGUID 11 f t f 2 f 16 "1184 1184" 100 0 0 100  foo bar ));
+DATA(insert OID = 1154 (  datetime_lt      PGUID 11 f t f 2 f 16 "1184 1184" 100 0 0 100  foo bar ));
+DATA(insert OID = 1155 (  datetime_le      PGUID 11 f t f 2 f 16 "1184 1184" 100 0 0 100  foo bar ));
+DATA(insert OID = 1156 (  datetime_ge      PGUID 11 f t f 2 f 16 "1184 1184" 100 0 0 100  foo bar ));
+DATA(insert OID = 1157 (  datetime_gt      PGUID 11 f t f 2 f 16 "1184 1184" 100 0 0 100  foo bar ));
+/* reserve OIDs 1158-1159 for additional date/time conversion routines! tgl 97/03/19 */
+DATA(insert OID = 1160 (  timespan_in      PGUID 11 f t f 1 f 1186 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 1161 (  timespan_out     PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 1162 (  timespan_eq      PGUID 11 f t f 2 f 16 "1186 1186" 100 0 0 100  foo bar ));
+DATA(insert OID = 1163 (  timespan_ne      PGUID 11 f t f 2 f 16 "1186 1186" 100 0 0 100  foo bar ));
+DATA(insert OID = 1164 (  timespan_lt      PGUID 11 f t f 2 f 16 "1186 1186" 100 0 0 100  foo bar ));
+DATA(insert OID = 1165 (  timespan_le      PGUID 11 f t f 2 f 16 "1186 1186" 100 0 0 100  foo bar ));
+DATA(insert OID = 1166 (  timespan_ge      PGUID 11 f t f 2 f 16 "1186 1186" 100 0 0 100  foo bar ));
+DATA(insert OID = 1167 (  timespan_gt      PGUID 11 f t f 2 f 16 "1186 1186" 100 0 0 100  foo bar ));
+DATA(insert OID = 1168 (  timespan_um      PGUID 11 f t f 1 f 1186 "1186" 100 0 0 100  foo bar ));
+DATA(insert OID = 1169 (  timespan_add     PGUID 11 f t f 2 f 1186 "1186 1186" 100 0 0 100  foo bar ));
+DATA(insert OID = 1170 (  timespan_sub     PGUID 11 f t f 2 f 1186 "1186 1186" 100 0 0 100  foo bar ));
+DATA(insert OID = 1171 (  datetime_part    PGUID 11 f t f 2 f  701 "25 1184" 100 0 0 100  foo bar ));
+DATA(insert OID = 1172 (  timespan_part    PGUID 11 f t f 2 f  701 "25 1186" 100 0 0 100  foo bar ));
+/* reserve OIDs 1173-1180 for additional date/time conversion routines! tgl 97/03/19 */
+DATA(insert OID = 1188 (  datetime_sub      PGUID 11 f t f 2 f 1186 "1184 1184" 100 0 0 100  foo bar ));
+DATA(insert OID = 1189 (  datetime_add_span PGUID 11 f t f 2 f 1184 "1184 1186" 100 0 0 100  foo bar ));
+DATA(insert OID = 1190 (  datetime_sub_span PGUID 11 f t f 2 f 1184 "1184 1186" 100 0 0 100  foo bar ));
+/* reserve OIDs 1191-1199 for additional date/time conversion routines! tgl 97/03/19 */
+
+DATA(insert OID = 1200 (  int42reltime     PGUID 11 f t f 1 f 703 "21" 100 0 0 100  foo bar ));
+
+DATA(insert OID = 1290 (  char2icregexeq   PGUID 11 f t f 2 f 16 "409 25" 100 0 0 100  foo bar ));
+DATA(insert OID = 1291 (  char2icregexne   PGUID 11 f t f 2 f 16 "409 25" 100 0 0 100  foo bar ));
+DATA(insert OID = 1292 (  char4icregexeq   PGUID 11 f t f 2 f 16 "410 25" 100 0 0 100  foo bar ));
+DATA(insert OID = 1293 (  char4icregexne   PGUID 11 f t f 2 f 16 "410 25" 100 0 0 100  foo bar ));
+DATA(insert OID = 1294 (  char8icregexeq   PGUID 11 f t f 2 f 16 "411 25" 100 0 0 100  foo bar ));
+DATA(insert OID = 1295 (  char8icregexne   PGUID 11 f t f 2 f 16 "411 25" 100 0 0 100  foo bar ));
+DATA(insert OID = 1236 (  char16icregexeq  PGUID 11 f t f 2 f 16 "20 25" 100 0 0 100  foo bar ));
+DATA(insert OID = 1237 (  char16icregexne  PGUID 11 f t f 2 f 16 "20 25" 100 0 0 100  foo bar ));
+DATA(insert OID = 1238 (  texticregexeq    PGUID 11 f t f 2 f 16 "25 25" 100 0 1 0  foo bar ));
+DATA(insert OID = 1239 (  texticregexne    PGUID 11 f t f 2 f 16 "25 25" 100 0 1 0  foo bar ));
+DATA(insert OID = 1240 (  nameicregexeq    PGUID 11 f t f 2 f 16 "19 25" 100 0 0 100  foo bar ));
+DATA(insert OID = 1241 (  nameicregexne    PGUID 11 f t f 2 f 16 "19 25" 100 0 0 100  foo bar ));
+DATA(insert OID = 1297 (  timestamp_in     PGUID 11 f t f 1 f 1296 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 1298 (  timestamp_out    PGUID 11 f t f 1 f 23 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 1299 (  now              PGUID 11 f t f 0 f 1296 "0" 100 0 0 100  foo bar ));
+DATA(insert OID = 1306 (  timestampeq      PGUID 11 f t f 2 f 16 "1296 1296" 100 0 0 100  foo bar ));
+DATA(insert OID = 1307 (  timestampne      PGUID 11 f t f 2 f 16 "1296 1296" 100 0 0 100  foo bar ));
+DATA(insert OID = 1308 (  timestamplt      PGUID 11 f t f 2 f 16 "1296 1296" 100 0 0 100  foo bar ));
+DATA(insert OID = 1309 (  timestampgt      PGUID 11 f t f 2 f 16 "1296 1296" 100 0 0 100  foo bar ));
+DATA(insert OID = 1310 (  timestample      PGUID 11 f t f 2 f 16 "1296 1296" 100 0 0 100  foo bar ));
+DATA(insert OID = 1311 (  timestampge      PGUID 11 f t f 2 f 16 "1296 1296" 100 0 0 100  foo bar ));
 
 /* Oracle Compatibility Related Functions - By Edmund Mergl <E.Mergl@bawue.de> */
 DATA(insert OID =  870 (  lower             PGUID 11 f t f 1 f 25 "25" 100 0 0 100  foo bar ));
index 2246fb8..ad400ed 100644 (file)
@@ -7,7 +7,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_type.h,v 1.8 1997/03/12 21:27:41 scrappy Exp $
+ * $Id: pg_type.h,v 1.9 1997/03/25 08:11:01 scrappy Exp $
  *
  * NOTES
  *    the genbki.sh script reads this file and generates .bki
@@ -32,7 +32,7 @@
  *     typedef struct FormData_pg_type
  *
  *      Some of the values in a pg_type instance are copied into 
- *      pg_attribute intances.  Some parts of Postgres use the pg_type copy,
+ *      pg_attribute instances.  Some parts of Postgres use the pg_type copy,
  *      while others use the pg_attribute copy, so they must match.
  *      See struct FormData_pg_attribute for details.
  * ----------------
@@ -57,6 +57,12 @@ CATALOG(pg_type) BOOTSTRAP {
          may be an oversimplification.  Also, there appear to be bugs in which
          Postgres doesn't ignore typbyval when it should, but I'm 
          afraid to change them until I see proof of damage. -BRYANH 96.08).
+
+         (Postgres crashes if typbyval is true, the declared length is 8,
+         and the I/O routines are written to expect pass by reference.
+         Note that float4 is written for pass by reference and has a declared length
+         of 4 bytes, so it looks like pass by reference must be consistant
+         with the declared length, and typbyval is used somewhere. - tgl 97/03/20)
          */
     char       typtype;
     bool       typisdefined;
@@ -66,6 +72,9 @@ CATALOG(pg_type) BOOTSTRAP {
       /* typelem is NULL if this is not an array type.  If this is an array
          type, typelem is the OID of the type of the elements of the array
          (it identifies another row in Table pg_type).
+
+         (Note that zero ("0") rather than _null_ is used
+         in the declarations. - tgl 97/03/20)
       */
     regproc    typinput;
     regproc    typoutput;
@@ -181,28 +190,28 @@ DATA(insert OID = 29 (  cid        PGUID  2   3 t b t \054 0   0 cidin cidout ci
 DATA(insert OID = 30 (  oid8       PGUID 32  89 f b t \054 0  26 oid8in oid8out oid8in oid8out i _null_ ));
 DATA(insert OID = 32 (  SET        PGUID -1  -1 f r t \054 0  -1 textin textout textin textout i _null_ ));
 
-DATA(insert OID = 71 ( pg_type PGUID 1 1 t b t \054 1247 0 foo bar foo bar c _null_));
-DATA(insert OID = 75 ( pg_attribute PGUID 1 1 t b t \054 1249 0 foo bar foo bar c _null_));
-DATA(insert OID = 76 ( pg_demon PGUID 1 1 t b t \054 1251 0 foo bar foo bar c _null_));
-DATA(insert OID = 80 ( pg_magic PGUID 1 1 t b t \054 1253 0 foo bar foo bar c _null_));
-DATA(insert OID = 81 ( pg_proc PGUID 1 1 t b t \054 1255 0 foo bar foo bar c _null_));
-DATA(insert OID = 82 ( pg_server PGUID 1 1 t b t \054 1257 0 foo bar foo bar c _null_));
-DATA(insert OID = 83 ( pg_class PGUID 1 1 t b t \054 1259 0 foo bar foo bar c _null_));
-DATA(insert OID = 86 ( pg_user PGUID 1 1 t b t \054 1260 0 foo bar foo bar c _null_));
-DATA(insert OID = 87 ( pg_group PGUID 1 1 t b t \054 1261 0 foo bar foo bar c _null_));
-DATA(insert OID = 88 ( pg_database PGUID 1 1 t b t \054 1262 0 foo bar foo bar c _null_));
-DATA(insert OID = 89 ( pg_defaults PGUID 1 1 t b t \054 1263 0 foo bar foo bar c _null_));
-DATA(insert OID = 90 ( pg_variable PGUID 1 1 t b t \054 1264 0 foo bar foo bar c _null_));
-DATA(insert OID = 99 ( pg_log PGUID 1 1 t b t \054 1269 0 foo bar foo bar c _null_));
+DATA(insert OID = 71 (  pg_type      PGUID 1 1 t b t \054 1247 0 foo bar foo bar c _null_));
+DATA(insert OID = 75 (  pg_attribute PGUID 1 1 t b t \054 1249 0 foo bar foo bar c _null_));
+DATA(insert OID = 76 (  pg_demon     PGUID 1 1 t b t \054 1251 0 foo bar foo bar c _null_));
+DATA(insert OID = 80 (  pg_magic     PGUID 1 1 t b t \054 1253 0 foo bar foo bar c _null_));
+DATA(insert OID = 81 (  pg_proc      PGUID 1 1 t b t \054 1255 0 foo bar foo bar c _null_));
+DATA(insert OID = 82 (  pg_server    PGUID 1 1 t b t \054 1257 0 foo bar foo bar c _null_));
+DATA(insert OID = 83 (  pg_class     PGUID 1 1 t b t \054 1259 0 foo bar foo bar c _null_));
+DATA(insert OID = 86 (  pg_user      PGUID 1 1 t b t \054 1260 0 foo bar foo bar c _null_));
+DATA(insert OID = 87 (  pg_group     PGUID 1 1 t b t \054 1261 0 foo bar foo bar c _null_));
+DATA(insert OID = 88 (  pg_database  PGUID 1 1 t b t \054 1262 0 foo bar foo bar c _null_));
+DATA(insert OID = 89 (  pg_defaults  PGUID 1 1 t b t \054 1263 0 foo bar foo bar c _null_));
+DATA(insert OID = 90 (  pg_variable  PGUID 1 1 t b t \054 1264 0 foo bar foo bar c _null_));
+DATA(insert OID = 99 (  pg_log       PGUID 1 1 t b t \054 1269 0 foo bar foo bar c _null_));
 
 /* OIDS 100 - 199 */
 
-DATA(insert OID = 100 ( pg_time PGUID 1 1 t b t \054 1271 0 foo bar foo bar c _null_));
-DATA(insert OID = 101 ( pg_hosts PGUID 1 1 t b t \054 1273 0 foo bar foo bar c _null_));
+DATA(insert OID = 100 (  pg_time   PGUID 1 1 t b t \054 1271 0 foo bar foo bar c _null_));
+DATA(insert OID = 101 (  pg_hosts  PGUID 1 1 t b t \054 1273 0 foo bar foo bar c _null_));
 
 /* OIDS 200 - 299 */
 
-DATA(insert OID = 210 (  smgr       PGUID 2  12 t b t \054 0  -1 smgrin smgrout smgrin smgrout s _null_ ));
+DATA(insert OID = 210 (  smgr      PGUID 2  12 t b t \054 0  -1 smgrin smgrout smgrin smgrout s _null_ ));
 
 /* OIDS 300 - 399 */
 
@@ -234,22 +243,22 @@ DATA(insert OID = 701 (  float8    PGUID  8  24 f b t \054 0   0 float8in float8
 DATA(insert OID = 702 (  abstime   PGUID  4  20 t b t \054 0   0 nabstimein nabstimeout nabstimein nabstimeout i _null_ ));
 DATA(insert OID = 703 (  reltime   PGUID  4  20 t b t \054 0   0 reltimein reltimeout reltimein reltimeout i _null_ ));
 DATA(insert OID = 704 (  tinterval PGUID 12  47 f b t \054 0   0 tintervalin tintervalout tintervalin tintervalout i _null_ ));
-DATA(insert OID = 705 (  unknown PGUID -1  -1 f b t \054 0   18 textin textout textin textout i _null_ ));
+DATA(insert OID = 705 (  unknown   PGUID -1  -1 f b t \054 0   18 textin textout textin textout i _null_ ));
 
 #define UNKNOWNOID     705
 
 /* OIDS 800 - 899 */
-DATA(insert OID = 810 (  oidint2    PGUID  6  20 f b t \054 0   0 oidint2in oidint2out oidint2in oidint2out i _null_ ));
+DATA(insert OID = 810 (  oidint2   PGUID  6  20 f b t \054 0   0 oidint2in oidint2out oidint2in oidint2out i _null_ ));
 
 /* OIDS 900 - 999 */
-DATA(insert OID = 910 (  oidint4    PGUID  8  20 f b t \054 0   0 oidint4in oidint4out oidint4in oidint4out i _null_ ));
-DATA(insert OID = 911 (  oidname  PGUID  OIDNAMELEN OIDNAMELEN f b t \054 0   0 oidnamein oidnameout oidnamein oidnameout i _null_ ));
+DATA(insert OID = 910 (  oidint4   PGUID  8  20 f b t \054 0   0 oidint4in oidint4out oidint4in oidint4out i _null_ ));
+DATA(insert OID = 911 (  oidname   PGUID  OIDNAMELEN OIDNAMELEN f b t \054 0   0 oidnamein oidnameout oidnamein oidnameout i _null_ ));
 
 /* OIDS 1000 - 1099 */
 DATA(insert OID = 1000 (  _bool      PGUID -1  -1 f b t \054 0  16 array_in array_out array_in array_out i _null_ ));
 DATA(insert OID = 1001 (  _bytea     PGUID -1  -1 f b t \054 0  17 array_in array_out array_in array_out i _null_ ));
 DATA(insert OID = 1002 (  _char      PGUID -1  -1 f b t \054 0  18 array_in array_out array_in array_out i _null_ ));
-DATA(insert OID = 1003 (  _name    PGUID -1  -1 f b t \054 0  19 array_in array_out array_in array_out i _null_ ));
+DATA(insert OID = 1003 (  _name      PGUID -1  -1 f b t \054 0  19 array_in array_out array_in array_out i _null_ ));
 DATA(insert OID = 1004 (  _char16    PGUID -1  -1 f b t \054 0  20 array_in array_out array_in array_out i _null_ ));
 DATA(insert OID = 1005 (  _int2      PGUID -1  -1 f b t \054 0  21 array_in array_out array_in array_out i _null_ ));
 DATA(insert OID = 1006 (  _int28     PGUID -1  -1 f b t \054 0  22 array_in array_out array_in array_out i _null_ )); 
@@ -273,26 +282,39 @@ DATA(insert OID = 1022 (  _float8    PGUID -1  -1 f b t \054 0 701 array_in arra
 DATA(insert OID = 1023 (  _abstime   PGUID -1  -1 f b t \054 0 702 array_in array_out array_in array_out i _null_ ));
 DATA(insert OID = 1024 (  _reltime   PGUID -1  -1 f b t \054 0 703 array_in array_out array_in array_out i _null_ ));
 DATA(insert OID = 1025 (  _tinterval PGUID -1  -1 f b t \054 0 704 array_in array_out array_in array_out i _null_ ));
-DATA(insert OID = 1026 (  _filename PGUID -1  -1 f b t \054 0 605 array_in array_out array_in array_out i _null_ ));
-DATA(insert OID = 1027 (  _polygon PGUID -1  -1 f b t \054 0 604 array_in array_out array_in array_out d _null_ ));
+DATA(insert OID = 1026 (  _filename  PGUID -1  -1 f b t \054 0 605 array_in array_out array_in array_out i _null_ ));
+DATA(insert OID = 1027 (  _polygon   PGUID -1  -1 f b t \054 0 604 array_in array_out array_in array_out d _null_ ));
 /* Note: the size of an aclitem needs to match sizeof(AclItem) in acl.h */
-DATA(insert OID = 1033 (  aclitem PGUID 8  -1 f b t \054 0 0 aclitemin aclitemout aclitemin aclitemout i _null_ ));
-DATA(insert OID = 1034 (  _aclitem PGUID -1  -1 f b t \054 0 1033 array_in array_out array_in array_out i _null_ ));
+DATA(insert OID = 1033 (  aclitem    PGUID 8   -1 f b t \054 0 0 aclitemin aclitemout aclitemin aclitemout i _null_ ));
+DATA(insert OID = 1034 (  _aclitem   PGUID -1  -1 f b t \054 0 1033 array_in array_out array_in array_out i _null_ ));
 
-DATA(insert OID = 1039 (  _char2    PGUID -1  -1 f b t \054 0  409 array_in array_out array_in array_out i _null_ ));
-DATA(insert OID = 1040 (  _char4    PGUID -1  -1 f b t \054 0  410 array_in array_out array_in array_out i _null_ ));
-DATA(insert OID = 1041 (  _char8    PGUID -1  -1 f b t \054 0  411 array_in array_out array_in array_out i _null_ ));
+DATA(insert OID = 1039 (  _char2     PGUID -1  -1 f b t \054 0  409 array_in array_out array_in array_out i _null_ ));
+DATA(insert OID = 1040 (  _char4     PGUID -1  -1 f b t \054 0  410 array_in array_out array_in array_out i _null_ ));
+DATA(insert OID = 1041 (  _char8     PGUID -1  -1 f b t \054 0  411 array_in array_out array_in array_out i _null_ ));
 
 #define        BPCHAROID       1042
-DATA(insert OID = 1042 ( bpchar  PGUID -1  -1 f b t \054 0  18 bpcharin bpcharout bpcharin bpcharout i _null_ ));
+DATA(insert OID = 1042 ( bpchar      PGUID -1  -1 f b t \054 0  18 bpcharin bpcharout bpcharin bpcharout i _null_ ));
 #define        VARCHAROID      1043
-DATA(insert OID = 1043 ( varchar PGUID -1  -1 f b t \054 0  18 varcharin varcharout varcharin varcharout i _null_ ));
-
-DATA(insert OID = 1082 ( date      PGUID  4  10 t b t \054 0  0 date_in date_out date_in date_out i _null_ ));
-DATA(insert OID = 1083 ( time      PGUID  8  16 f b t \054 0  0 time_in time_out time_in time_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 = 1296 ( timestamp PGUID  4  19 t b t \054 0  0 timestamp_in timestamp_out timestamp_in timestamp_out i _null_ ));
+DATA(insert OID = 1043 ( varchar     PGUID -1  -1 f b t \054 0  18 varcharin varcharout varcharin varcharout i _null_ ));
+
+DATA(insert OID = 1082 ( date        PGUID  4  10 t b t \054 0  0 date_in date_out date_in date_out i _null_ ));
+#define DATEOID                1082
+DATA(insert OID = 1083 ( time        PGUID  8  16 f b t \054 0  0 time_in time_out time_in time_out i _null_ ));
+#define TIMEOID                1083
+
+/* 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 = 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_ ));
+#define DATETIMEOID    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 = 1186 ( timespan    PGUID 12  47 f b t \054 0  0 timespan_in timespan_out timespan_in timespan_out d _null_ ));
+#define TIMESPANOID    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_ ));
+
+/* OIDS 1200 - 1299 */
+DATA(insert OID = 1296 ( timestamp   PGUID  4  19 t b t \054 0  0 timestamp_in timestamp_out timestamp_in timestamp_out i _null_ ));
+#define TIMESTAMPOID   1296
 
 /*
  * prototypes for functions in pg_type.c 
index a7648fe..9e3473a 100644 (file)
@@ -11,7 +11,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: miscadmin.h,v 1.7 1997/03/18 20:15:19 scrappy Exp $
+ * $Id: miscadmin.h,v 1.8 1997/03/25 08:09:59 scrappy Exp $
  *
  * NOTES
  *    some of the information in this file will be moved to
@@ -58,12 +58,28 @@ extern bool     IsPostmaster;
 extern short       DebugLvl;
 
 /* Date/Time Configuration
- * HasCTZSet if client timezone is specified by client.
+ *
+ * Constants to pass info from runtime environment:
+ *  USE_POSTGRES_DATES specifies traditional postgres format for output.
+ *  USE_ISO_DATES specifies ISO-compliant format for output.
+ *  USE_SQL_DATES specified Oracle/Ingres-compliant format for output.
+ *
+ * DateStyle specifies preference for date formatting for output.
  * EuroDates if client prefers dates interpreted and written w/European conventions.
+ *
+ * HasCTZSet if client timezone is specified by client.
+ * CDayLight is the apparent daylight savings time status.
  * CTimeZone is the timezone offset in seconds.
  * CTZName is the timezone label.
  */
 
+#define MAXTZLEN       7
+
+#define USE_POSTGRES_DATES     0
+#define USE_ISO_DATES          1
+#define USE_SQL_DATES          2
+
+extern int         DateStyle;
 extern bool        EuroDates;
 extern bool        HasCTZSet;
 extern bool        CDayLight;
index b9f20b0..fbc8d06 100644 (file)
@@ -8,7 +8,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: dt.h,v 1.2 1997/03/18 16:36:50 scrappy Exp $
+ * $Id: dt.h,v 1.3 1997/03/25 08:11:18 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
 #define DT_H
 
 #include <time.h>
+#include <math.h>
 
 /*
  * DateTime represents absolute time.
- * TimeSpan represents delta time.
+ * TimeSpan represents delta time. Keep track of months (and years)
+ *  separately since the elapsed time spanned is unknown until instantiated
+ *  relative to an absolute time.
+ *
  * Note that Postgres uses "time interval" to mean a bounded interval,
- *  consisting of a beginning and ending time, not a time span.
+ *  consisting of a beginning and ending time, not a time span - tgl 97/03/20
  */
 
 typedef double DateTime;
 
 typedef struct {
     double      time;   /* all time units other than months and years */
-    int4        month;  /* months and years */
+    int4        month;  /* months and years, after time for alignment */
 } TimeSpan;
 
 
@@ -45,6 +49,7 @@ typedef struct {
  * Other alternate forms are hardcoded into token tables in dt.c.
  * ----------------------------------------------------------------
  */
+
 #define DAGO           "ago"
 #define DCURRENT       "current"
 #define EPOCH          "epoch"
@@ -65,12 +70,14 @@ typedef struct {
 #define DDAY           "day"
 #define DWEEK          "week"
 #define DMONTH         "month"
+#define DQUARTER       "quarter"
 #define DYEAR          "year"
 #define DDECADE                "decade"
 #define DCENTURY       "century"
 #define DMILLENIUM     "millenium"
 #define DA_D           "ad"
 #define DB_C           "bc"
+#define DTIMEZONE      "timezone"
 
 /*
  * Fundamental time field definitions for parsing.
@@ -78,6 +85,7 @@ typedef struct {
  *  Meridian:  am, pm, or 24-hour style.
  *  Millenium: ad, bc
  */
+
 #define AM     0
 #define PM     1
 #define HR24   2
@@ -90,6 +98,7 @@ typedef struct {
  * Can't have more of these than there are bits in an unsigned int
  *  since these are turned into bit masks during parsing and decoding.
  */
+
 #define RESERV 0
 #define MONTH  1
 #define YEAR   2
@@ -116,6 +125,7 @@ typedef struct {
  * These need to fit into the datetkn table type.
  * At the moment, that means keep them within [-127,127].
  */
+
 #define DTK_NUMBER     0
 #define DTK_STRING     1
 
@@ -143,17 +153,19 @@ typedef struct {
 #define DTK_DAY                36
 #define DTK_WEEK       37
 #define DTK_MONTH      38
-#define DTK_YEAR       39
-#define DTK_DECADE     40
-#define DTK_CENTURY    41
-#define DTK_MILLENIUM  42
-#define DTK_MILLISEC   43
-#define DTK_MICROSEC   44
-#define DTK_AGO                45
+#define DTK_QUARTER    39
+#define DTK_YEAR       40
+#define DTK_DECADE     41
+#define DTK_CENTURY    42
+#define DTK_MILLENIUM  43
+#define DTK_MILLISEC   44
+#define DTK_MICROSEC   45
+#define DTK_AGO                46
 
 /*
  * Bit mask definitions for time parsing.
  */
+
 #define DTK_M(t)       (0x01 << t)
 
 #define DTK_DATE_M     (DTK_M(YEAR) | DTK_M(MONTH) | DTK_M(DAY))
@@ -174,21 +186,95 @@ typedef struct {
     char value;                /* this may be unsigned, alas */
 } datetkn;
 
-extern void GetCurrentTime(struct tm *tm);
+#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)
+#else
+#define DT_NOBEGIN     (-DBL_MAX)
+#define DT_NOEND       (DBL_MAX)
+#endif
+#define DT_CURRENT     (DBL_MIN)
+#define DT_EPOCH       (-DBL_MIN)
+
+#define DATETIME_INVALID(j)    {j = DT_INVALID;}
+#ifdef NAN
+#define DATETIME_IS_INVALID(j) (isnan(j))
+#else
+#define DATETIME_IS_INVALID(j) (j == DT_INVALID)
+#endif
+
+#define DATETIME_NOBEGIN(j)    {j = DT_NOBEGIN;}
+#define DATETIME_IS_NOBEGIN(j) (j == DT_NOBEGIN)
+
+#define DATETIME_NOEND(j)      {j = DT_NOEND;}
+#define DATETIME_IS_NOEND(j)   (j == DT_NOEND)
+
+#define DATETIME_CURRENT(j)    {j = DT_CURRENT;}
+#define DATETIME_IS_CURRENT(j) (j == DT_CURRENT)
+
+#define DATETIME_EPOCH(j)      {j = DT_EPOCH;}
+#define DATETIME_IS_EPOCH(j)   (j == DT_EPOCH)
+
+#define DATETIME_IS_RELATIVE(j)        (DATETIME_IS_CURRENT(j) || DATETIME_IS_EPOCH(j))
+#define DATETIME_NOT_FINITE(j) (DATETIME_IS_INVALID(j) \
+                               || DATETIME_IS_NOBEGIN(j) || DATETIME_IS_NOEND(j))
+#define DATETIME_IS_RESERVED(j) (DATETIME_IS_RELATIVE(j) || DATETIME_NOT_FINITE(j))
+
+#define TIMESPAN_INVALID(j)    {j->time = DT_INVALID;}
+#ifdef NAN
+#define TIMESPAN_IS_INVALID(j) (isnan((j).time))
+#else
+#define TIMESPAN_IS_INVALID(j) ((j).time == DT_INVALID)
+#endif
+
+#define TIME_PREC 1e-6
+#define JROUND(j) (rint(((double) j)/TIME_PREC)*TIME_PREC)
 
 /*
  * dt.c prototypes 
  */
+
 extern DateTime *datetime_in( char *str);
 extern char *datetime_out( DateTime *dt);
+extern bool datetime_eq(DateTime *dt1, DateTime *dt2);
+extern bool datetime_ne(DateTime *dt1, DateTime *dt2);
+extern bool datetime_lt(DateTime *dt1, DateTime *dt2);
+extern bool datetime_le(DateTime *dt1, DateTime *dt2);
+extern bool datetime_ge(DateTime *dt1, DateTime *dt2);
+extern bool datetime_gt(DateTime *dt1, DateTime *dt2);
+
 extern TimeSpan *timespan_in(char *str);
 extern char *timespan_out(TimeSpan *span);
+extern bool timespan_eq(TimeSpan *span1, TimeSpan *span2);
+extern bool timespan_ne(TimeSpan *span1, TimeSpan *span2);
+extern bool timespan_lt(TimeSpan *span1, TimeSpan *span2);
+extern bool timespan_le(TimeSpan *span1, TimeSpan *span2);
+extern bool timespan_ge(TimeSpan *span1, TimeSpan *span2);
+extern bool timespan_gt(TimeSpan *span1, TimeSpan *span2);
+
+float64 datetime_part(text *units, DateTime *datetime);
+float64 timespan_part(text *units, TimeSpan *timespan);
+
+extern TimeSpan *timespan_um(TimeSpan *span);
+extern TimeSpan *timespan_add(TimeSpan *span1, TimeSpan *span2);
+extern TimeSpan *timespan_sub(TimeSpan *span1, TimeSpan *span2);
 
 extern TimeSpan *datetime_sub(DateTime *dt1, DateTime *dt2);
 extern DateTime *datetime_add_span(DateTime *dt, TimeSpan *span);
 extern DateTime *datetime_sub_span(DateTime *dt, TimeSpan *span);
-extern TimeSpan *timespan_add(TimeSpan *span1, TimeSpan *span2);
-extern TimeSpan *timespan_sub(TimeSpan *span1, TimeSpan *span2);
+
+extern void GetCurrentTime(struct tm *tm);
+DateTime SetDateTime(DateTime datetime);
+DateTime tm2datetime(struct tm *tm, double fsec, int tzp);
+int datetime2tm( DateTime dt, struct tm *tm, double *fsec);
+
+int timespan2tm(TimeSpan span, struct tm *tm, float8 *fsec);
+int tm2timespan(struct tm *tm, double fsec, TimeSpan *span);
 
 extern DateTime dt2local( DateTime dt, int timezone);
 
@@ -199,12 +285,8 @@ extern int j2day( int jd);
 extern double time2t(const int hour, const int min, const double sec);
 extern void dt2time(DateTime dt, int *hour, int *min, double *sec);
 
-/*
-extern void GetCurrentTime(struct tm *tm);
-*/
 extern int ParseDateTime( char *timestr, char *lowstr,
   char *field[], int ftype[], int maxfields, int *numfields);
-
 extern int DecodeDateTime( char *field[], int ftype[],
  int nf, int *dtype, struct tm *tm, double *fsec, int *tzp);
 extern int DecodeDate(char *str, int fmask, int *tmask, struct tm *tm);
@@ -223,11 +305,10 @@ extern int DecodeDateDelta( char *field[], int ftype[],
  int nf, int *dtype, struct tm *tm, double *fsec);
 extern int DecodeUnits(int field, char *lowtoken, int *val);
 
-extern int EncodeSpecialDateTime(DateTime *dt, char *str);
+extern int EncodeSpecialDateTime(DateTime dt, char *str);
 extern int EncodePostgresDate(struct tm *tm, double fsec, char *str);
 extern int EncodePostgresSpan(struct tm *tm, double fsec, char *str);
 
-
 extern datetkn *datebsearch(char *key, datetkn *base, unsigned int nel);
 
 #endif /* DT_H */
index 8a0c92b..e8691f7 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: nabstime.h,v 1.5 1997/03/14 23:33:29 scrappy Exp $
+ * $Id: nabstime.h,v 1.6 1997/03/25 08:11:24 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -115,8 +115,6 @@ extern AbsoluteTime GetCurrentAbsoluteTime(void);
 extern AbsoluteTime nabstimein(char *timestr);
 extern char *nabstimeout(AbsoluteTime time);
 
-extern bool AbsoluteTimeIsBefore(AbsoluteTime time1, AbsoluteTime time2);
-extern bool AbsoluteTimeIsAfter(AbsoluteTime time1, AbsoluteTime time2);
 extern bool abstimeeq(AbsoluteTime t1, AbsoluteTime t2);
 extern bool abstimene(AbsoluteTime t1, AbsoluteTime t2);
 extern bool abstimelt(AbsoluteTime t1, AbsoluteTime t2);
@@ -124,6 +122,10 @@ extern bool abstimegt(AbsoluteTime t1, AbsoluteTime t2);
 extern bool abstimele(AbsoluteTime t1, AbsoluteTime t2);
 extern bool abstimege(AbsoluteTime t1, AbsoluteTime t2);
 
+extern AbsoluteTime datetime_abstime(DateTime *datetime);
+
+extern bool AbsoluteTimeIsBefore(AbsoluteTime time1, AbsoluteTime time2);
+extern bool AbsoluteTimeIsAfter(AbsoluteTime time1, AbsoluteTime time2);
 extern AbsoluteTime dateconv(struct tm *tm, int zone);
 extern time_t qmktime(struct tm *tp);