</row>
</thead>
<tbody>
- <row>
- <entry><literal>abstime_minmax_ops</literal></entry>
- <entry><type>abstime</type></entry>
- <entry>
- <literal><</literal>
- <literal><=</literal>
- <literal>=</literal>
- <literal>>=</literal>
- <literal>></literal>
- </entry>
- </row>
<row>
<entry><literal>int8_minmax_ops</literal></entry>
<entry><type>bigint</type></entry>
<literal>></literal>
</entry>
</row>
- <row>
- <entry><literal>reltime_minmax_ops</literal></entry>
- <entry><type>reltime</type></entry>
- <entry>
- <literal><</literal>
- <literal><=</literal>
- <literal>=</literal>
- <literal>>=</literal>
- <literal>></literal>
- </entry>
- </row>
<row>
<entry><literal>int2_minmax_ops</literal></entry>
<entry><type>smallint</type></entry>
<row>
<entry><structfield>valuntil</structfield></entry>
- <entry><type>abstime</type></entry>
+ <entry><type>timestamptz</type></entry>
<entry></entry>
<entry>Password expiry time (only used for password authentication)</entry>
</row>
<row>
<entry><structfield>valuntil</structfield></entry>
- <entry><type>abstime</type></entry>
+ <entry><type>timestamptz</type></entry>
<entry>Password expiry time (only used for password authentication)</entry>
</row>
any application.
</para>
- <para>
- The types <type>abstime</type>
- and <type>reltime</type> are lower precision types which are used internally.
- You are discouraged from using these types in
- applications; these internal types
- might disappear in a future release.
- </para>
-
<sect2 id="datatype-datetime-input">
<title>Date/Time Input</title>
</row>
</thead>
<tbody>
- <row>
- <entry><type>abstime</type></entry>
- <entry><type>AbsoluteTime</type></entry>
- <entry><filename>utils/nabstime.h</filename></entry>
- </row>
- <row>
- <entry><type>bigint</type> (<type>int8</type>)</entry>
- <entry><type>int64</type></entry>
- <entry><filename>postgres.h</filename></entry>
- </row>
<row>
<entry><type>boolean</type></entry>
<entry><type>bool</type></entry>
<entry><type>regproc</type></entry>
<entry><filename>postgres.h</filename></entry>
</row>
- <row>
- <entry><type>reltime</type></entry>
- <entry><type>RelativeTime</type></entry>
- <entry><filename>utils/nabstime.h</filename></entry>
- </row>
<row>
<entry><type>text</type></entry>
<entry><type>text*</type></entry>
<entry><type>Timestamp*</type></entry>
<entry><filename>datatype/timestamp.h</filename></entry>
</row>
- <row>
- <entry><type>tinterval</type></entry>
- <entry><type>TimeInterval</type></entry>
- <entry><filename>utils/nabstime.h</filename></entry>
- </row>
<row>
<entry><type>varchar</type></entry>
<entry><type>VarChar*</type></entry>
*/
if ((funcid == F_HASHINT4 || funcid == F_HASHINT4EXTENDED) &&
(argtype == DATEOID ||
- argtype == ABSTIMEOID || argtype == RELTIMEOID ||
argtype == XIDOID || argtype == CIDOID))
/* okay, allowed use of hashint4() */ ;
else if ((funcid == F_TIMESTAMP_HASH ||
rolreplication AS userepl,
rolbypassrls AS usebypassrls,
rolpassword AS passwd,
- rolvaliduntil::abstime AS valuntil,
+ rolvaliduntil AS valuntil,
setconfig AS useconfig
FROM pg_authid LEFT JOIN pg_db_role_setting s
ON (pg_authid.oid = setrole AND setdatabase = 0)
float.o format_type.o formatting.o genfile.o \
geo_ops.o geo_selfuncs.o geo_spgist.o inet_cidr_ntop.o inet_net_pton.o \
int.o int8.o json.o jsonb.o jsonb_gin.o jsonb_op.o jsonb_util.o \
- jsonfuncs.o like.o lockfuncs.o mac.o mac8.o misc.o nabstime.o name.o \
+ jsonfuncs.o like.o lockfuncs.o mac.o mac8.o misc.o name.o \
network.o network_gist.o network_selfuncs.o network_spgist.o \
numeric.o numutils.o oid.o oracle_compat.o \
orderedsetaggs.o pg_locale.o pg_lsn.o pg_upgrade_support.o \
#include "utils/builtins.h"
#include "utils/date.h"
#include "utils/datetime.h"
-#include "utils/nabstime.h"
#include "utils/sortsupport.h"
/*
}
-/* abstime_date()
- * Convert abstime to date data type.
- */
-Datum
-abstime_date(PG_FUNCTION_ARGS)
-{
- AbsoluteTime abstime = PG_GETARG_ABSOLUTETIME(0);
- DateADT result;
- struct pg_tm tt,
- *tm = &tt;
- int tz;
-
- switch (abstime)
- {
- case INVALID_ABSTIME:
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("cannot convert reserved abstime value to date")));
- result = 0; /* keep compiler quiet */
- break;
-
- case NOSTART_ABSTIME:
- DATE_NOBEGIN(result);
- break;
-
- case NOEND_ABSTIME:
- DATE_NOEND(result);
- break;
-
- default:
- abstime2tm(abstime, &tz, tm, NULL);
- /* Prevent overflow in Julian-day routines */
- if (!IS_VALID_JULIAN(tm->tm_year, tm->tm_mon, tm->tm_mday))
- ereport(ERROR,
- (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
- errmsg("abstime out of range for date")));
- result = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - POSTGRES_EPOCH_JDATE;
- /* Now check for just-out-of-range dates */
- if (!IS_VALID_DATE(result))
- ereport(ERROR,
- (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
- errmsg("abstime out of range for date")));
- break;
- }
-
- PG_RETURN_DATEADT(result);
-}
-
-
/*****************************************************************************
* Time ADT
*****************************************************************************/
* - better number building (formatting) / parsing, now it isn't
* ideal code
* - use Assert()
- * - add support for abstime
* - add support for roman number to standard number conversion
* - add support for number spelling
* - add support for string to string formatting (we must be better
+++ /dev/null
-/*-------------------------------------------------------------------------
- *
- * nabstime.c
- * Utilities for the built-in type "AbsoluteTime".
- * Functions for the built-in type "RelativeTime".
- * Functions for the built-in type "TimeInterval".
- *
- * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- *
- * IDENTIFICATION
- * src/backend/utils/adt/nabstime.c
- *
- *-------------------------------------------------------------------------
- */
-#include "postgres.h"
-
-#include <ctype.h>
-#include <limits.h>
-#include <math.h>
-#include <time.h>
-#include <sys/time.h>
-
-#include "libpq/pqformat.h"
-#include "miscadmin.h"
-#include "utils/builtins.h"
-#include "utils/datetime.h"
-#include "utils/nabstime.h"
-
-#define MIN_DAYNUM (-24856) /* December 13, 1901 */
-#define MAX_DAYNUM 24854 /* January 18, 2038 */
-
-/*
- * Unix epoch is Jan 1 00:00:00 1970.
- * Postgres knows about times sixty-eight years on either side of that
- * for these 4-byte types.
- *
- * "tinterval" is two 4-byte fields.
- * Definitions for parsing tinterval.
- */
-
-#define IsSpace(C) ((C) == ' ')
-
-#define T_INTERVAL_INVAL 0 /* data represents no valid tinterval */
-#define T_INTERVAL_VALID 1 /* data represents a valid tinterval */
-/*
- * ['Mon May 10 23:59:12 1943 PST' 'Sun Jan 14 03:14:21 1973 PST']
- * 0 1 2 3 4 5 6
- * 1234567890123456789012345678901234567890123456789012345678901234
- *
- * we allocate some extra -- timezones are usually 3 characters but
- * this is not in the POSIX standard...
- */
-#define T_INTERVAL_LEN 80
-#define INVALID_INTERVAL_STR "Undefined Range"
-#define INVALID_INTERVAL_STR_LEN (sizeof(INVALID_INTERVAL_STR)-1)
-
-#define ABSTIMEMIN(t1, t2) \
- (DatumGetBool(DirectFunctionCall2(abstimele, \
- AbsoluteTimeGetDatum(t1), \
- AbsoluteTimeGetDatum(t2))) ? (t1) : (t2))
-#define ABSTIMEMAX(t1, t2) \
- (DatumGetBool(DirectFunctionCall2(abstimelt, \
- AbsoluteTimeGetDatum(t1), \
- AbsoluteTimeGetDatum(t2))) ? (t2) : (t1))
-
-
-/*
- * Function prototypes -- internal to this file only
- */
-
-static AbsoluteTime tm2abstime(struct pg_tm *tm, int tz);
-static void reltime2tm(RelativeTime time, struct pg_tm *tm);
-static void parsetinterval(char *i_string,
- AbsoluteTime *i_start,
- AbsoluteTime *i_end);
-
-
-/*
- * GetCurrentAbsoluteTime()
- *
- * Get the current system time (relative to Unix epoch).
- *
- * NB: this will overflow in 2038; it should be gone long before that.
- */
-AbsoluteTime
-GetCurrentAbsoluteTime(void)
-{
- time_t now;
-
- now = time(NULL);
- return (AbsoluteTime) now;
-}
-
-
-void
-abstime2tm(AbsoluteTime _time, int *tzp, struct pg_tm *tm, char **tzn)
-{
- pg_time_t time = (pg_time_t) _time;
- struct pg_tm *tx;
-
- if (tzp != NULL)
- tx = pg_localtime(&time, session_timezone);
- else
- tx = pg_gmtime(&time);
-
- tm->tm_year = tx->tm_year + 1900;
- tm->tm_mon = tx->tm_mon + 1;
- tm->tm_mday = tx->tm_mday;
- tm->tm_hour = tx->tm_hour;
- tm->tm_min = tx->tm_min;
- tm->tm_sec = tx->tm_sec;
- tm->tm_isdst = tx->tm_isdst;
-
- tm->tm_gmtoff = tx->tm_gmtoff;
- tm->tm_zone = tx->tm_zone;
-
- if (tzp != NULL)
- {
- *tzp = -tm->tm_gmtoff; /* tm_gmtoff is Sun/DEC-ism */
-
- /*
- * XXX FreeBSD man pages indicate that this should work - tgl 97/04/23
- */
- if (tzn != NULL)
- {
- /*
- * Copy no more than MAXTZLEN bytes of timezone to tzn, in case it
- * contains an error message, which doesn't fit in the buffer
- */
- StrNCpy(*tzn, tm->tm_zone, MAXTZLEN + 1);
- if (strlen(tm->tm_zone) > MAXTZLEN)
- ereport(WARNING,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("invalid time zone name: \"%s\"",
- tm->tm_zone)));
- }
- }
- else
- tm->tm_isdst = -1;
-}
-
-
-/* tm2abstime()
- * Convert a tm structure to abstime.
- * Note that tm has full year (not 1900-based) and 1-based month.
- */
-static AbsoluteTime
-tm2abstime(struct pg_tm *tm, int tz)
-{
- int day;
- AbsoluteTime 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 > MONTHS_PER_YEAR ||
- tm->tm_mday < 1 || tm->tm_mday > 31 ||
- tm->tm_hour < 0 ||
- tm->tm_hour > HOURS_PER_DAY || /* test for > 24:00:00 */
- (tm->tm_hour == HOURS_PER_DAY && (tm->tm_min > 0 || tm->tm_sec > 0)) ||
- tm->tm_min < 0 || tm->tm_min > MINS_PER_HOUR - 1 ||
- tm->tm_sec < 0 || tm->tm_sec > SECS_PER_MINUTE)
- return INVALID_ABSTIME;
-
- day = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - UNIX_EPOCH_JDATE;
-
- /* 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 * HOURS_PER_DAY + tm->tm_hour) * MINS_PER_HOUR) * SECS_PER_MINUTE;
-
- /*
- * check for overflow. We need a little slop here because the H/M/S plus
- * TZ offset could add up to more than 1 day.
- */
- if ((day >= MAX_DAYNUM - 10 && sec < 0) ||
- (day <= MIN_DAYNUM + 10 && sec > 0))
- return INVALID_ABSTIME;
-
- /* check for reserved values (e.g. "current" on edge of usual range */
- if (!AbsoluteTimeIsReal(sec))
- return INVALID_ABSTIME;
-
- return sec;
-}
-
-
-/* abstimein()
- * Decode date/time string and return abstime.
- */
-Datum
-abstimein(PG_FUNCTION_ARGS)
-{
- char *str = PG_GETARG_CSTRING(0);
- AbsoluteTime result;
- fsec_t fsec;
- int tz = 0;
- struct pg_tm date,
- *tm = &date;
- int dterr;
- char *field[MAXDATEFIELDS];
- char workbuf[MAXDATELEN + 1];
- int dtype;
- int nf,
- ftype[MAXDATEFIELDS];
-
- dterr = ParseDateTime(str, workbuf, sizeof(workbuf),
- field, ftype, MAXDATEFIELDS, &nf);
- if (dterr == 0)
- dterr = DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz);
- if (dterr != 0)
- DateTimeParseError(dterr, str, "abstime");
-
- switch (dtype)
- {
- case DTK_DATE:
- result = tm2abstime(tm, tz);
- break;
-
- case DTK_EPOCH:
-
- /*
- * Don't bother retaining this as a reserved value, but instead
- * just set to the actual epoch time (1970-01-01)
- */
- result = 0;
- break;
-
- case DTK_LATE:
- result = NOEND_ABSTIME;
- break;
-
- case DTK_EARLY:
- result = NOSTART_ABSTIME;
- break;
-
- case DTK_INVALID:
- result = INVALID_ABSTIME;
- break;
-
- default:
- elog(ERROR, "unexpected dtype %d while parsing abstime \"%s\"",
- dtype, str);
- result = INVALID_ABSTIME;
- break;
- };
-
- PG_RETURN_ABSOLUTETIME(result);
-}
-
-
-/* abstimeout()
- * Given an AbsoluteTime return the English text version of the date
- */
-Datum
-abstimeout(PG_FUNCTION_ARGS)
-{
- AbsoluteTime time = PG_GETARG_ABSOLUTETIME(0);
- char *result;
- int tz;
- double fsec = 0;
- struct pg_tm tt,
- *tm = &tt;
- char buf[MAXDATELEN + 1];
- char zone[MAXDATELEN + 1],
- *tzn = zone;
-
- switch (time)
- {
- /*
- * Note that timestamp no longer supports 'invalid'. Retain
- * 'invalid' for abstime for now, but dump it someday.
- */
- case INVALID_ABSTIME:
- strcpy(buf, INVALID);
- break;
- case NOEND_ABSTIME:
- strcpy(buf, LATE);
- break;
- case NOSTART_ABSTIME:
- strcpy(buf, EARLY);
- break;
- default:
- abstime2tm(time, &tz, tm, &tzn);
- EncodeDateTime(tm, fsec, true, tz, tzn, DateStyle, buf);
- break;
- }
-
- result = pstrdup(buf);
- PG_RETURN_CSTRING(result);
-}
-
-/*
- * abstimerecv - converts external binary format to abstime
- */
-Datum
-abstimerecv(PG_FUNCTION_ARGS)
-{
- StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
-
- PG_RETURN_ABSOLUTETIME((AbsoluteTime) pq_getmsgint(buf, sizeof(AbsoluteTime)));
-}
-
-/*
- * abstimesend - converts abstime to binary format
- */
-Datum
-abstimesend(PG_FUNCTION_ARGS)
-{
- AbsoluteTime time = PG_GETARG_ABSOLUTETIME(0);
- StringInfoData buf;
-
- pq_begintypsend(&buf);
- pq_sendint32(&buf, time);
- PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
-}
-
-
-/* abstime_finite()
- */
-Datum
-abstime_finite(PG_FUNCTION_ARGS)
-{
- AbsoluteTime abstime = PG_GETARG_ABSOLUTETIME(0);
-
- PG_RETURN_BOOL(abstime != INVALID_ABSTIME &&
- abstime != NOSTART_ABSTIME &&
- abstime != NOEND_ABSTIME);
-}
-
-
-/*
- * abstime comparison routines
- */
-static int
-abstime_cmp_internal(AbsoluteTime a, AbsoluteTime b)
-{
- /*
- * We consider all INVALIDs to be equal and larger than any non-INVALID.
- * This is somewhat arbitrary; the important thing is to have a consistent
- * sort order.
- */
- if (a == INVALID_ABSTIME)
- {
- if (b == INVALID_ABSTIME)
- return 0; /* INVALID = INVALID */
- else
- return 1; /* INVALID > non-INVALID */
- }
-
- if (b == INVALID_ABSTIME)
- return -1; /* non-INVALID < INVALID */
-
- if (a > b)
- return 1;
- else if (a == b)
- return 0;
- else
- return -1;
-}
-
-Datum
-abstimeeq(PG_FUNCTION_ARGS)
-{
- AbsoluteTime t1 = PG_GETARG_ABSOLUTETIME(0);
- AbsoluteTime t2 = PG_GETARG_ABSOLUTETIME(1);
-
- PG_RETURN_BOOL(abstime_cmp_internal(t1, t2) == 0);
-}
-
-Datum
-abstimene(PG_FUNCTION_ARGS)
-{
- AbsoluteTime t1 = PG_GETARG_ABSOLUTETIME(0);
- AbsoluteTime t2 = PG_GETARG_ABSOLUTETIME(1);
-
- PG_RETURN_BOOL(abstime_cmp_internal(t1, t2) != 0);
-}
-
-Datum
-abstimelt(PG_FUNCTION_ARGS)
-{
- AbsoluteTime t1 = PG_GETARG_ABSOLUTETIME(0);
- AbsoluteTime t2 = PG_GETARG_ABSOLUTETIME(1);
-
- PG_RETURN_BOOL(abstime_cmp_internal(t1, t2) < 0);
-}
-
-Datum
-abstimegt(PG_FUNCTION_ARGS)
-{
- AbsoluteTime t1 = PG_GETARG_ABSOLUTETIME(0);
- AbsoluteTime t2 = PG_GETARG_ABSOLUTETIME(1);
-
- PG_RETURN_BOOL(abstime_cmp_internal(t1, t2) > 0);
-}
-
-Datum
-abstimele(PG_FUNCTION_ARGS)
-{
- AbsoluteTime t1 = PG_GETARG_ABSOLUTETIME(0);
- AbsoluteTime t2 = PG_GETARG_ABSOLUTETIME(1);
-
- PG_RETURN_BOOL(abstime_cmp_internal(t1, t2) <= 0);
-}
-
-Datum
-abstimege(PG_FUNCTION_ARGS)
-{
- AbsoluteTime t1 = PG_GETARG_ABSOLUTETIME(0);
- AbsoluteTime t2 = PG_GETARG_ABSOLUTETIME(1);
-
- PG_RETURN_BOOL(abstime_cmp_internal(t1, t2) >= 0);
-}
-
-Datum
-btabstimecmp(PG_FUNCTION_ARGS)
-{
- AbsoluteTime t1 = PG_GETARG_ABSOLUTETIME(0);
- AbsoluteTime t2 = PG_GETARG_ABSOLUTETIME(1);
-
- PG_RETURN_INT32(abstime_cmp_internal(t1, t2));
-}
-
-
-/* timestamp_abstime()
- * Convert timestamp to abstime.
- */
-Datum
-timestamp_abstime(PG_FUNCTION_ARGS)
-{
- Timestamp timestamp = PG_GETARG_TIMESTAMP(0);
- AbsoluteTime result;
- fsec_t fsec;
- int tz;
- struct pg_tm tt,
- *tm = &tt;
-
- if (TIMESTAMP_IS_NOBEGIN(timestamp))
- result = NOSTART_ABSTIME;
- else if (TIMESTAMP_IS_NOEND(timestamp))
- result = NOEND_ABSTIME;
- else if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL, NULL) == 0)
- {
- tz = DetermineTimeZoneOffset(tm, session_timezone);
- result = tm2abstime(tm, tz);
- }
- else
- {
- ereport(ERROR,
- (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
- errmsg("timestamp out of range")));
- result = INVALID_ABSTIME;
- }
-
- PG_RETURN_ABSOLUTETIME(result);
-}
-
-/* abstime_timestamp()
- * Convert abstime to timestamp.
- */
-Datum
-abstime_timestamp(PG_FUNCTION_ARGS)
-{
- AbsoluteTime abstime = PG_GETARG_ABSOLUTETIME(0);
- Timestamp result;
- struct pg_tm tt,
- *tm = &tt;
- int tz;
- char zone[MAXDATELEN + 1],
- *tzn = zone;
-
- switch (abstime)
- {
- case INVALID_ABSTIME:
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("cannot convert abstime \"invalid\" to timestamp")));
- TIMESTAMP_NOBEGIN(result);
- break;
-
- case NOSTART_ABSTIME:
- TIMESTAMP_NOBEGIN(result);
- break;
-
- case NOEND_ABSTIME:
- TIMESTAMP_NOEND(result);
- break;
-
- default:
- abstime2tm(abstime, &tz, tm, &tzn);
- if (tm2timestamp(tm, 0, NULL, &result) != 0)
- ereport(ERROR,
- (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
- errmsg("timestamp out of range")));
- break;
- };
-
- PG_RETURN_TIMESTAMP(result);
-}
-
-
-/* timestamptz_abstime()
- * Convert timestamp with time zone to abstime.
- */
-Datum
-timestamptz_abstime(PG_FUNCTION_ARGS)
-{
- TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
- AbsoluteTime result;
- fsec_t fsec;
- struct pg_tm tt,
- *tm = &tt;
-
- if (TIMESTAMP_IS_NOBEGIN(timestamp))
- result = NOSTART_ABSTIME;
- else if (TIMESTAMP_IS_NOEND(timestamp))
- result = NOEND_ABSTIME;
- else if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL, NULL) == 0)
- result = tm2abstime(tm, 0);
- else
- {
- ereport(ERROR,
- (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
- errmsg("timestamp out of range")));
- result = INVALID_ABSTIME;
- }
-
- PG_RETURN_ABSOLUTETIME(result);
-}
-
-/* abstime_timestamptz()
- * Convert abstime to timestamp with time zone.
- */
-Datum
-abstime_timestamptz(PG_FUNCTION_ARGS)
-{
- AbsoluteTime abstime = PG_GETARG_ABSOLUTETIME(0);
- TimestampTz result;
- struct pg_tm tt,
- *tm = &tt;
- int tz;
- char zone[MAXDATELEN + 1],
- *tzn = zone;
-
- switch (abstime)
- {
- case INVALID_ABSTIME:
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("cannot convert abstime \"invalid\" to timestamp")));
- TIMESTAMP_NOBEGIN(result);
- break;
-
- case NOSTART_ABSTIME:
- TIMESTAMP_NOBEGIN(result);
- break;
-
- case NOEND_ABSTIME:
- TIMESTAMP_NOEND(result);
- break;
-
- default:
- abstime2tm(abstime, &tz, tm, &tzn);
- if (tm2timestamp(tm, 0, &tz, &result) != 0)
- ereport(ERROR,
- (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
- errmsg("timestamp out of range")));
- break;
- };
-
- PG_RETURN_TIMESTAMP(result);
-}
-
-
-/*****************************************************************************
- * USER I/O ROUTINES *
- *****************************************************************************/
-
-/*
- * reltimein - converts a reltime string in an internal format
- */
-Datum
-reltimein(PG_FUNCTION_ARGS)
-{
- char *str = PG_GETARG_CSTRING(0);
- RelativeTime result;
- struct pg_tm tt,
- *tm = &tt;
- fsec_t fsec;
- int dtype;
- int dterr;
- char *field[MAXDATEFIELDS];
- int nf,
- ftype[MAXDATEFIELDS];
- char workbuf[MAXDATELEN + 1];
-
- dterr = ParseDateTime(str, workbuf, sizeof(workbuf),
- field, ftype, MAXDATEFIELDS, &nf);
- if (dterr == 0)
- dterr = DecodeInterval(field, ftype, nf, INTERVAL_FULL_RANGE,
- &dtype, tm, &fsec);
-
- /* if those functions think it's a bad format, try ISO8601 style */
- if (dterr == DTERR_BAD_FORMAT)
- dterr = DecodeISO8601Interval(str,
- &dtype, tm, &fsec);
-
- if (dterr != 0)
- {
- if (dterr == DTERR_FIELD_OVERFLOW)
- dterr = DTERR_INTERVAL_OVERFLOW;
- DateTimeParseError(dterr, str, "reltime");
- }
-
- switch (dtype)
- {
- case DTK_DELTA:
- result = ((tm->tm_hour * MINS_PER_HOUR + tm->tm_min) * SECS_PER_MINUTE) + tm->tm_sec;
- result += tm->tm_year * SECS_PER_YEAR + ((tm->tm_mon * DAYS_PER_MONTH) + tm->tm_mday) * SECS_PER_DAY;
- break;
-
- default:
- elog(ERROR, "unexpected dtype %d while parsing reltime \"%s\"",
- dtype, str);
- result = INVALID_RELTIME;
- break;
- }
-
- PG_RETURN_RELATIVETIME(result);
-}
-
-/*
- * reltimeout - converts the internal format to a reltime string
- */
-Datum
-reltimeout(PG_FUNCTION_ARGS)
-{
- RelativeTime time = PG_GETARG_RELATIVETIME(0);
- char *result;
- struct pg_tm tt,
- *tm = &tt;
- char buf[MAXDATELEN + 1];
-
- reltime2tm(time, tm);
- EncodeInterval(tm, 0, IntervalStyle, buf);
-
- result = pstrdup(buf);
- PG_RETURN_CSTRING(result);
-}
-
-/*
- * reltimerecv - converts external binary format to reltime
- */
-Datum
-reltimerecv(PG_FUNCTION_ARGS)
-{
- StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
-
- PG_RETURN_RELATIVETIME((RelativeTime) pq_getmsgint(buf, sizeof(RelativeTime)));
-}
-
-/*
- * reltimesend - converts reltime to binary format
- */
-Datum
-reltimesend(PG_FUNCTION_ARGS)
-{
- RelativeTime time = PG_GETARG_RELATIVETIME(0);
- StringInfoData buf;
-
- pq_begintypsend(&buf);
- pq_sendint32(&buf, time);
- PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
-}
-
-
-static void
-reltime2tm(RelativeTime time, struct pg_tm *tm)
-{
- double dtime = time;
-
- FMODULO(dtime, tm->tm_year, 31557600);
- FMODULO(dtime, tm->tm_mon, 2592000);
- FMODULO(dtime, tm->tm_mday, SECS_PER_DAY);
- FMODULO(dtime, tm->tm_hour, SECS_PER_HOUR);
- FMODULO(dtime, tm->tm_min, SECS_PER_MINUTE);
- FMODULO(dtime, tm->tm_sec, 1);
-}
-
-
-/*
- * tintervalin - converts a tinterval string to internal format
- */
-Datum
-tintervalin(PG_FUNCTION_ARGS)
-{
- char *tintervalstr = PG_GETARG_CSTRING(0);
- TimeInterval tinterval;
- AbsoluteTime i_start,
- i_end,
- t1,
- t2;
-
- parsetinterval(tintervalstr, &t1, &t2);
-
- tinterval = (TimeInterval) palloc(sizeof(TimeIntervalData));
-
- if (t1 == INVALID_ABSTIME || t2 == INVALID_ABSTIME)
- tinterval->status = T_INTERVAL_INVAL; /* undefined */
- else
- tinterval->status = T_INTERVAL_VALID;
-
- i_start = ABSTIMEMIN(t1, t2);
- i_end = ABSTIMEMAX(t1, t2);
- tinterval->data[0] = i_start;
- tinterval->data[1] = i_end;
-
- PG_RETURN_TIMEINTERVAL(tinterval);
-}
-
-
-/*
- * tintervalout - converts an internal tinterval format to a string
- */
-Datum
-tintervalout(PG_FUNCTION_ARGS)
-{
- TimeInterval tinterval = PG_GETARG_TIMEINTERVAL(0);
- char *i_str,
- *p;
-
- i_str = (char *) palloc(T_INTERVAL_LEN); /* ["..." "..."] */
- strcpy(i_str, "[\"");
- if (tinterval->status == T_INTERVAL_INVAL)
- strcat(i_str, INVALID_INTERVAL_STR);
- else
- {
- p = DatumGetCString(DirectFunctionCall1(abstimeout,
- AbsoluteTimeGetDatum(tinterval->data[0])));
- strcat(i_str, p);
- pfree(p);
- strcat(i_str, "\" \"");
- p = DatumGetCString(DirectFunctionCall1(abstimeout,
- AbsoluteTimeGetDatum(tinterval->data[1])));
- strcat(i_str, p);
- pfree(p);
- }
- strcat(i_str, "\"]");
- PG_RETURN_CSTRING(i_str);
-}
-
-/*
- * tintervalrecv - converts external binary format to tinterval
- */
-Datum
-tintervalrecv(PG_FUNCTION_ARGS)
-{
- StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
- TimeInterval tinterval;
- int32 status;
-
- tinterval = (TimeInterval) palloc(sizeof(TimeIntervalData));
-
- tinterval->status = pq_getmsgint(buf, sizeof(tinterval->status));
- tinterval->data[0] = pq_getmsgint(buf, sizeof(tinterval->data[0]));
- tinterval->data[1] = pq_getmsgint(buf, sizeof(tinterval->data[1]));
-
- if (tinterval->data[0] == INVALID_ABSTIME ||
- tinterval->data[1] == INVALID_ABSTIME)
- status = T_INTERVAL_INVAL; /* undefined */
- else
- status = T_INTERVAL_VALID;
-
- if (status != tinterval->status)
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
- errmsg("invalid status in external \"tinterval\" value")));
-
- PG_RETURN_TIMEINTERVAL(tinterval);
-}
-
-/*
- * tintervalsend - converts tinterval to binary format
- */
-Datum
-tintervalsend(PG_FUNCTION_ARGS)
-{
- TimeInterval tinterval = PG_GETARG_TIMEINTERVAL(0);
- StringInfoData buf;
-
- pq_begintypsend(&buf);
- pq_sendint32(&buf, tinterval->status);
- pq_sendint32(&buf, tinterval->data[0]);
- pq_sendint32(&buf, tinterval->data[1]);
- PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
-}
-
-
-/*****************************************************************************
- * PUBLIC ROUTINES *
- *****************************************************************************/
-
-Datum
-interval_reltime(PG_FUNCTION_ARGS)
-{
- Interval *interval = PG_GETARG_INTERVAL_P(0);
- RelativeTime time;
- int year,
- month,
- day;
- TimeOffset span;
-
- year = interval->month / MONTHS_PER_YEAR;
- month = interval->month % MONTHS_PER_YEAR;
- day = interval->day;
-
- span = ((INT64CONST(365250000) * year + INT64CONST(30000000) * month +
- INT64CONST(1000000) * day) * INT64CONST(86400)) +
- interval->time;
- span /= USECS_PER_SEC;
-
- if (span < INT_MIN || span > INT_MAX)
- time = INVALID_RELTIME;
- else
- time = span;
-
- PG_RETURN_RELATIVETIME(time);
-}
-
-
-Datum
-reltime_interval(PG_FUNCTION_ARGS)
-{
- RelativeTime reltime = PG_GETARG_RELATIVETIME(0);
- Interval *result;
- int year,
- month,
- day;
-
- result = (Interval *) palloc(sizeof(Interval));
-
- switch (reltime)
- {
- case INVALID_RELTIME:
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("cannot convert reltime \"invalid\" to interval")));
- result->time = 0;
- result->day = 0;
- result->month = 0;
- break;
-
- default:
- year = reltime / SECS_PER_YEAR;
- reltime -= year * SECS_PER_YEAR;
- month = reltime / (DAYS_PER_MONTH * SECS_PER_DAY);
- reltime -= month * (DAYS_PER_MONTH * SECS_PER_DAY);
- day = reltime / SECS_PER_DAY;
- reltime -= day * SECS_PER_DAY;
-
- result->time = (reltime * USECS_PER_SEC);
- result->month = MONTHS_PER_YEAR * year + month;
- result->day = day;
- break;
- }
-
- PG_RETURN_INTERVAL_P(result);
-}
-
-
-/*
- * mktinterval - creates a time interval with endpoints t1 and t2
- */
-Datum
-mktinterval(PG_FUNCTION_ARGS)
-{
- AbsoluteTime t1 = PG_GETARG_ABSOLUTETIME(0);
- AbsoluteTime t2 = PG_GETARG_ABSOLUTETIME(1);
- AbsoluteTime tstart = ABSTIMEMIN(t1, t2);
- AbsoluteTime tend = ABSTIMEMAX(t1, t2);
- TimeInterval tinterval;
-
- tinterval = (TimeInterval) palloc(sizeof(TimeIntervalData));
-
- if (t1 == INVALID_ABSTIME || t2 == INVALID_ABSTIME)
- tinterval->status = T_INTERVAL_INVAL;
-
- else
- {
- tinterval->status = T_INTERVAL_VALID;
- tinterval->data[0] = tstart;
- tinterval->data[1] = tend;
- }
-
- PG_RETURN_TIMEINTERVAL(tinterval);
-}
-
-/*
- * timepl, timemi and abstimemi use the formula
- * abstime + reltime = abstime
- * so abstime - reltime = abstime
- * and abstime - abstime = reltime
- */
-
-/*
- * timepl - returns the value of (abstime t1 + reltime t2)
- */
-Datum
-timepl(PG_FUNCTION_ARGS)
-{
- AbsoluteTime t1 = PG_GETARG_ABSOLUTETIME(0);
- RelativeTime t2 = PG_GETARG_RELATIVETIME(1);
-
- if (AbsoluteTimeIsReal(t1) &&
- RelativeTimeIsValid(t2) &&
- ((t2 > 0 && t1 < NOEND_ABSTIME - t2) ||
- (t2 <= 0 && t1 > NOSTART_ABSTIME - t2))) /* prevent overflow */
- PG_RETURN_ABSOLUTETIME(t1 + t2);
-
- PG_RETURN_ABSOLUTETIME(INVALID_ABSTIME);
-}
-
-
-/*
- * timemi - returns the value of (abstime t1 - reltime t2)
- */
-Datum
-timemi(PG_FUNCTION_ARGS)
-{
- AbsoluteTime t1 = PG_GETARG_ABSOLUTETIME(0);
- RelativeTime t2 = PG_GETARG_RELATIVETIME(1);
-
- if (AbsoluteTimeIsReal(t1) &&
- RelativeTimeIsValid(t2) &&
- ((t2 > 0 && t1 > NOSTART_ABSTIME + t2) ||
- (t2 <= 0 && t1 < NOEND_ABSTIME + t2))) /* prevent overflow */
- PG_RETURN_ABSOLUTETIME(t1 - t2);
-
- PG_RETURN_ABSOLUTETIME(INVALID_ABSTIME);
-}
-
-
-/*
- * intinterval - returns true iff absolute date is in the tinterval
- */
-Datum
-intinterval(PG_FUNCTION_ARGS)
-{
- AbsoluteTime t = PG_GETARG_ABSOLUTETIME(0);
- TimeInterval tinterval = PG_GETARG_TIMEINTERVAL(1);
-
- if (tinterval->status == T_INTERVAL_VALID && t != INVALID_ABSTIME)
- {
- if (DatumGetBool(DirectFunctionCall2(abstimege,
- AbsoluteTimeGetDatum(t),
- AbsoluteTimeGetDatum(tinterval->data[0]))) &&
- DatumGetBool(DirectFunctionCall2(abstimele,
- AbsoluteTimeGetDatum(t),
- AbsoluteTimeGetDatum(tinterval->data[1]))))
- PG_RETURN_BOOL(true);
- }
- PG_RETURN_BOOL(false);
-}
-
-/*
- * tintervalrel - returns relative time corresponding to tinterval
- */
-Datum
-tintervalrel(PG_FUNCTION_ARGS)
-{
- TimeInterval tinterval = PG_GETARG_TIMEINTERVAL(0);
- AbsoluteTime t1 = tinterval->data[0];
- AbsoluteTime t2 = tinterval->data[1];
-
- if (tinterval->status != T_INTERVAL_VALID)
- PG_RETURN_RELATIVETIME(INVALID_RELTIME);
-
- if (AbsoluteTimeIsReal(t1) &&
- AbsoluteTimeIsReal(t2))
- PG_RETURN_RELATIVETIME(t2 - t1);
-
- PG_RETURN_RELATIVETIME(INVALID_RELTIME);
-}
-
-
-/*
- * timenow - returns time "now", internal format
- *
- * Now AbsoluteTime is time since Jan 1 1970 -mer 7 Feb 1992
- */
-Datum
-timenow(PG_FUNCTION_ARGS)
-{
- PG_RETURN_ABSOLUTETIME(GetCurrentAbsoluteTime());
-}
-
-/*
- * reltime comparison routines
- */
-static int
-reltime_cmp_internal(RelativeTime a, RelativeTime b)
-{
- /*
- * We consider all INVALIDs to be equal and larger than any non-INVALID.
- * This is somewhat arbitrary; the important thing is to have a consistent
- * sort order.
- */
- if (a == INVALID_RELTIME)
- {
- if (b == INVALID_RELTIME)
- return 0; /* INVALID = INVALID */
- else
- return 1; /* INVALID > non-INVALID */
- }
-
- if (b == INVALID_RELTIME)
- return -1; /* non-INVALID < INVALID */
-
- if (a > b)
- return 1;
- else if (a == b)
- return 0;
- else
- return -1;
-}
-
-Datum
-reltimeeq(PG_FUNCTION_ARGS)
-{
- RelativeTime t1 = PG_GETARG_RELATIVETIME(0);
- RelativeTime t2 = PG_GETARG_RELATIVETIME(1);
-
- PG_RETURN_BOOL(reltime_cmp_internal(t1, t2) == 0);
-}
-
-Datum
-reltimene(PG_FUNCTION_ARGS)
-{
- RelativeTime t1 = PG_GETARG_RELATIVETIME(0);
- RelativeTime t2 = PG_GETARG_RELATIVETIME(1);
-
- PG_RETURN_BOOL(reltime_cmp_internal(t1, t2) != 0);
-}
-
-Datum
-reltimelt(PG_FUNCTION_ARGS)
-{
- RelativeTime t1 = PG_GETARG_RELATIVETIME(0);
- RelativeTime t2 = PG_GETARG_RELATIVETIME(1);
-
- PG_RETURN_BOOL(reltime_cmp_internal(t1, t2) < 0);
-}
-
-Datum
-reltimegt(PG_FUNCTION_ARGS)
-{
- RelativeTime t1 = PG_GETARG_RELATIVETIME(0);
- RelativeTime t2 = PG_GETARG_RELATIVETIME(1);
-
- PG_RETURN_BOOL(reltime_cmp_internal(t1, t2) > 0);
-}
-
-Datum
-reltimele(PG_FUNCTION_ARGS)
-{
- RelativeTime t1 = PG_GETARG_RELATIVETIME(0);
- RelativeTime t2 = PG_GETARG_RELATIVETIME(1);
-
- PG_RETURN_BOOL(reltime_cmp_internal(t1, t2) <= 0);
-}
-
-Datum
-reltimege(PG_FUNCTION_ARGS)
-{
- RelativeTime t1 = PG_GETARG_RELATIVETIME(0);
- RelativeTime t2 = PG_GETARG_RELATIVETIME(1);
-
- PG_RETURN_BOOL(reltime_cmp_internal(t1, t2) >= 0);
-}
-
-Datum
-btreltimecmp(PG_FUNCTION_ARGS)
-{
- RelativeTime t1 = PG_GETARG_RELATIVETIME(0);
- RelativeTime t2 = PG_GETARG_RELATIVETIME(1);
-
- PG_RETURN_INT32(reltime_cmp_internal(t1, t2));
-}
-
-
-/*
- * tintervalsame - returns true iff tinterval i1 is same as tinterval i2
- * Check begin and end time.
- */
-Datum
-tintervalsame(PG_FUNCTION_ARGS)
-{
- TimeInterval i1 = PG_GETARG_TIMEINTERVAL(0);
- TimeInterval i2 = PG_GETARG_TIMEINTERVAL(1);
-
- if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL)
- PG_RETURN_BOOL(false);
-
- if (DatumGetBool(DirectFunctionCall2(abstimeeq,
- AbsoluteTimeGetDatum(i1->data[0]),
- AbsoluteTimeGetDatum(i2->data[0]))) &&
- DatumGetBool(DirectFunctionCall2(abstimeeq,
- AbsoluteTimeGetDatum(i1->data[1]),
- AbsoluteTimeGetDatum(i2->data[1]))))
- PG_RETURN_BOOL(true);
- PG_RETURN_BOOL(false);
-}
-
-/*
- * tinterval comparison routines
- *
- * Note: comparison is based only on the lengths of the tintervals, not on
- * endpoint values (as long as they're not INVALID). This is pretty bogus,
- * but since it's only a legacy datatype, we're not going to change it.
- *
- * Some other bogus things that won't be changed for compatibility reasons:
- * 1. The interval length computations overflow at 2^31 seconds, causing
- * intervals longer than that to sort oddly compared to those shorter.
- * 2. infinity and minus infinity (NOEND_ABSTIME and NOSTART_ABSTIME) are
- * just ordinary integers. Since this code doesn't handle them specially,
- * it's possible for [a b] to be considered longer than [c infinity] for
- * finite abstimes a, b, c. In combination with the previous point, the
- * interval [-infinity infinity] is treated as being shorter than many finite
- * intervals :-(
- *
- * If tinterval is ever reimplemented atop timestamp, it'd be good to give
- * some consideration to avoiding these problems.
- */
-static int
-tinterval_cmp_internal(TimeInterval a, TimeInterval b)
-{
- bool a_invalid;
- bool b_invalid;
- AbsoluteTime a_len;
- AbsoluteTime b_len;
-
- /*
- * We consider all INVALIDs to be equal and larger than any non-INVALID.
- * This is somewhat arbitrary; the important thing is to have a consistent
- * sort order.
- */
- a_invalid = a->status == T_INTERVAL_INVAL ||
- a->data[0] == INVALID_ABSTIME ||
- a->data[1] == INVALID_ABSTIME;
- b_invalid = b->status == T_INTERVAL_INVAL ||
- b->data[0] == INVALID_ABSTIME ||
- b->data[1] == INVALID_ABSTIME;
-
- if (a_invalid)
- {
- if (b_invalid)
- return 0; /* INVALID = INVALID */
- else
- return 1; /* INVALID > non-INVALID */
- }
-
- if (b_invalid)
- return -1; /* non-INVALID < INVALID */
-
- a_len = a->data[1] - a->data[0];
- b_len = b->data[1] - b->data[0];
-
- if (a_len > b_len)
- return 1;
- else if (a_len == b_len)
- return 0;
- else
- return -1;
-}
-
-Datum
-tintervaleq(PG_FUNCTION_ARGS)
-{
- TimeInterval i1 = PG_GETARG_TIMEINTERVAL(0);
- TimeInterval i2 = PG_GETARG_TIMEINTERVAL(1);
-
- PG_RETURN_BOOL(tinterval_cmp_internal(i1, i2) == 0);
-}
-
-Datum
-tintervalne(PG_FUNCTION_ARGS)
-{
- TimeInterval i1 = PG_GETARG_TIMEINTERVAL(0);
- TimeInterval i2 = PG_GETARG_TIMEINTERVAL(1);
-
- PG_RETURN_BOOL(tinterval_cmp_internal(i1, i2) != 0);
-}
-
-Datum
-tintervallt(PG_FUNCTION_ARGS)
-{
- TimeInterval i1 = PG_GETARG_TIMEINTERVAL(0);
- TimeInterval i2 = PG_GETARG_TIMEINTERVAL(1);
-
- PG_RETURN_BOOL(tinterval_cmp_internal(i1, i2) < 0);
-}
-
-Datum
-tintervalle(PG_FUNCTION_ARGS)
-{
- TimeInterval i1 = PG_GETARG_TIMEINTERVAL(0);
- TimeInterval i2 = PG_GETARG_TIMEINTERVAL(1);
-
- PG_RETURN_BOOL(tinterval_cmp_internal(i1, i2) <= 0);
-}
-
-Datum
-tintervalgt(PG_FUNCTION_ARGS)
-{
- TimeInterval i1 = PG_GETARG_TIMEINTERVAL(0);
- TimeInterval i2 = PG_GETARG_TIMEINTERVAL(1);
-
- PG_RETURN_BOOL(tinterval_cmp_internal(i1, i2) > 0);
-}
-
-Datum
-tintervalge(PG_FUNCTION_ARGS)
-{
- TimeInterval i1 = PG_GETARG_TIMEINTERVAL(0);
- TimeInterval i2 = PG_GETARG_TIMEINTERVAL(1);
-
- PG_RETURN_BOOL(tinterval_cmp_internal(i1, i2) >= 0);
-}
-
-Datum
-bttintervalcmp(PG_FUNCTION_ARGS)
-{
- TimeInterval i1 = PG_GETARG_TIMEINTERVAL(0);
- TimeInterval i2 = PG_GETARG_TIMEINTERVAL(1);
-
- PG_RETURN_INT32(tinterval_cmp_internal(i1, i2));
-}
-
-
-/*
- * tintervalleneq - returns true iff length of tinterval i is equal to
- * reltime t
- * tintervallenne - returns true iff length of tinterval i is not equal
- * to reltime t
- * tintervallenlt - returns true iff length of tinterval i is less than
- * reltime t
- * tintervallengt - returns true iff length of tinterval i is greater
- * than reltime t
- * tintervallenle - returns true iff length of tinterval i is less or
- * equal than reltime t
- * tintervallenge - returns true iff length of tinterval i is greater or
- * equal than reltime t
- */
-Datum
-tintervalleneq(PG_FUNCTION_ARGS)
-{
- TimeInterval i = PG_GETARG_TIMEINTERVAL(0);
- RelativeTime t = PG_GETARG_RELATIVETIME(1);
- RelativeTime rt;
-
- if (i->status == T_INTERVAL_INVAL || t == INVALID_RELTIME)
- PG_RETURN_BOOL(false);
- rt = DatumGetRelativeTime(DirectFunctionCall1(tintervalrel,
- TimeIntervalGetDatum(i)));
- PG_RETURN_BOOL(rt != INVALID_RELTIME && rt == t);
-}
-
-Datum
-tintervallenne(PG_FUNCTION_ARGS)
-{
- TimeInterval i = PG_GETARG_TIMEINTERVAL(0);
- RelativeTime t = PG_GETARG_RELATIVETIME(1);
- RelativeTime rt;
-
- if (i->status == T_INTERVAL_INVAL || t == INVALID_RELTIME)
- PG_RETURN_BOOL(false);
- rt = DatumGetRelativeTime(DirectFunctionCall1(tintervalrel,
- TimeIntervalGetDatum(i)));
- PG_RETURN_BOOL(rt != INVALID_RELTIME && rt != t);
-}
-
-Datum
-tintervallenlt(PG_FUNCTION_ARGS)
-{
- TimeInterval i = PG_GETARG_TIMEINTERVAL(0);
- RelativeTime t = PG_GETARG_RELATIVETIME(1);
- RelativeTime rt;
-
- if (i->status == T_INTERVAL_INVAL || t == INVALID_RELTIME)
- PG_RETURN_BOOL(false);
- rt = DatumGetRelativeTime(DirectFunctionCall1(tintervalrel,
- TimeIntervalGetDatum(i)));
- PG_RETURN_BOOL(rt != INVALID_RELTIME && rt < t);
-}
-
-Datum
-tintervallengt(PG_FUNCTION_ARGS)
-{
- TimeInterval i = PG_GETARG_TIMEINTERVAL(0);
- RelativeTime t = PG_GETARG_RELATIVETIME(1);
- RelativeTime rt;
-
- if (i->status == T_INTERVAL_INVAL || t == INVALID_RELTIME)
- PG_RETURN_BOOL(false);
- rt = DatumGetRelativeTime(DirectFunctionCall1(tintervalrel,
- TimeIntervalGetDatum(i)));
- PG_RETURN_BOOL(rt != INVALID_RELTIME && rt > t);
-}
-
-Datum
-tintervallenle(PG_FUNCTION_ARGS)
-{
- TimeInterval i = PG_GETARG_TIMEINTERVAL(0);
- RelativeTime t = PG_GETARG_RELATIVETIME(1);
- RelativeTime rt;
-
- if (i->status == T_INTERVAL_INVAL || t == INVALID_RELTIME)
- PG_RETURN_BOOL(false);
- rt = DatumGetRelativeTime(DirectFunctionCall1(tintervalrel,
- TimeIntervalGetDatum(i)));
- PG_RETURN_BOOL(rt != INVALID_RELTIME && rt <= t);
-}
-
-Datum
-tintervallenge(PG_FUNCTION_ARGS)
-{
- TimeInterval i = PG_GETARG_TIMEINTERVAL(0);
- RelativeTime t = PG_GETARG_RELATIVETIME(1);
- RelativeTime rt;
-
- if (i->status == T_INTERVAL_INVAL || t == INVALID_RELTIME)
- PG_RETURN_BOOL(false);
- rt = DatumGetRelativeTime(DirectFunctionCall1(tintervalrel,
- TimeIntervalGetDatum(i)));
- PG_RETURN_BOOL(rt != INVALID_RELTIME && rt >= t);
-}
-
-/*
- * tintervalct - returns true iff tinterval i1 contains tinterval i2
- */
-Datum
-tintervalct(PG_FUNCTION_ARGS)
-{
- TimeInterval i1 = PG_GETARG_TIMEINTERVAL(0);
- TimeInterval i2 = PG_GETARG_TIMEINTERVAL(1);
-
- if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL)
- PG_RETURN_BOOL(false);
- if (DatumGetBool(DirectFunctionCall2(abstimele,
- AbsoluteTimeGetDatum(i1->data[0]),
- AbsoluteTimeGetDatum(i2->data[0]))) &&
- DatumGetBool(DirectFunctionCall2(abstimege,
- AbsoluteTimeGetDatum(i1->data[1]),
- AbsoluteTimeGetDatum(i2->data[1]))))
- PG_RETURN_BOOL(true);
- PG_RETURN_BOOL(false);
-}
-
-/*
- * tintervalov - returns true iff tinterval i1 (partially) overlaps i2
- */
-Datum
-tintervalov(PG_FUNCTION_ARGS)
-{
- TimeInterval i1 = PG_GETARG_TIMEINTERVAL(0);
- TimeInterval i2 = PG_GETARG_TIMEINTERVAL(1);
-
- if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL)
- PG_RETURN_BOOL(false);
- if (DatumGetBool(DirectFunctionCall2(abstimelt,
- AbsoluteTimeGetDatum(i1->data[1]),
- AbsoluteTimeGetDatum(i2->data[0]))) ||
- DatumGetBool(DirectFunctionCall2(abstimegt,
- AbsoluteTimeGetDatum(i1->data[0]),
- AbsoluteTimeGetDatum(i2->data[1]))))
- PG_RETURN_BOOL(false);
- PG_RETURN_BOOL(true);
-}
-
-/*
- * tintervalstart - returns the start of tinterval i
- */
-Datum
-tintervalstart(PG_FUNCTION_ARGS)
-{
- TimeInterval i = PG_GETARG_TIMEINTERVAL(0);
-
- if (i->status == T_INTERVAL_INVAL)
- PG_RETURN_ABSOLUTETIME(INVALID_ABSTIME);
- PG_RETURN_ABSOLUTETIME(i->data[0]);
-}
-
-/*
- * tintervalend - returns the end of tinterval i
- */
-Datum
-tintervalend(PG_FUNCTION_ARGS)
-{
- TimeInterval i = PG_GETARG_TIMEINTERVAL(0);
-
- if (i->status == T_INTERVAL_INVAL)
- PG_RETURN_ABSOLUTETIME(INVALID_ABSTIME);
- PG_RETURN_ABSOLUTETIME(i->data[1]);
-}
-
-
-/*****************************************************************************
- * PRIVATE ROUTINES *
- *****************************************************************************/
-
-/*
- * parsetinterval -- parse a tinterval string
- *
- * output parameters:
- * i_start, i_end: tinterval margins
- *
- * Time interval:
- * `[' {` '} `'' <AbsTime> `'' {` '} `'' <AbsTime> `'' {` '} `]'
- *
- * OR `Undefined Range' (see also INVALID_INTERVAL_STR)
- *
- * where <AbsTime> satisfies the syntax of absolute time.
- *
- * e.g. [ ' Jan 18 1902' 'Jan 1 00:00:00 1970']
- */
-static void
-parsetinterval(char *i_string,
- AbsoluteTime *i_start,
- AbsoluteTime *i_end)
-{
- char *p,
- *p1;
- char c;
-
- p = i_string;
- /* skip leading blanks up to '[' */
- while ((c = *p) != '\0')
- {
- if (IsSpace(c))
- p++;
- else if (c != '[')
- goto bogus; /* syntax error */
- else
- break;
- }
- if (c == '\0')
- goto bogus; /* syntax error */
- p++;
- /* skip leading blanks up to '"' */
- while ((c = *p) != '\0')
- {
- if (IsSpace(c))
- p++;
- else if (c != '"')
- goto bogus; /* syntax error */
- else
- break;
- }
- if (c == '\0')
- goto bogus; /* syntax error */
- p++;
- if (strncmp(INVALID_INTERVAL_STR, p, strlen(INVALID_INTERVAL_STR)) == 0)
- goto bogus; /* undefined range, handled like a syntax err. */
- /* search for the end of the first date and change it to a \0 */
- p1 = p;
- while ((c = *p1) != '\0')
- {
- if (c == '"')
- break;
- p1++;
- }
- if (c == '\0')
- goto bogus; /* syntax error */
- *p1 = '\0';
- /* get the first date */
- *i_start = DatumGetAbsoluteTime(DirectFunctionCall1(abstimein,
- CStringGetDatum(p)));
- /* undo change to \0 */
- *p1 = c;
- p = ++p1;
- /* skip blanks up to '"', beginning of second date */
- while ((c = *p) != '\0')
- {
- if (IsSpace(c))
- p++;
- else if (c != '"')
- goto bogus; /* syntax error */
- else
- break;
- }
- if (c == '\0')
- goto bogus; /* syntax error */
- p++;
- /* search for the end of the second date and change it to a \0 */
- p1 = p;
- while ((c = *p1) != '\0')
- {
- if (c == '"')
- break;
- p1++;
- }
- if (c == '\0')
- goto bogus; /* syntax error */
- *p1 = '\0';
- /* get the second date */
- *i_end = DatumGetAbsoluteTime(DirectFunctionCall1(abstimein,
- CStringGetDatum(p)));
- /* undo change to \0 */
- *p1 = c;
- p = ++p1;
- /* skip blanks up to ']' */
- while ((c = *p) != '\0')
- {
- if (IsSpace(c))
- p++;
- else if (c != ']')
- goto bogus; /* syntax error */
- else
- break;
- }
- if (c == '\0')
- goto bogus; /* syntax error */
- p++;
- c = *p;
- if (c != '\0')
- goto bogus; /* syntax error */
-
- /* it seems to be a valid tinterval */
- return;
-
-bogus:
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_DATETIME_FORMAT),
- errmsg("invalid input syntax for type %s: \"%s\"",
- "tinterval", i_string)));
- *i_start = *i_end = INVALID_ABSTIME; /* keep compiler quiet */
-}
#include "utils/fmgroids.h"
#include "utils/index_selfuncs.h"
#include "utils/lsyscache.h"
-#include "utils/nabstime.h"
#include "utils/pg_locale.h"
#include "utils/rel.h"
#include "utils/selfuncs.h"
*/
case TIMESTAMPOID:
case TIMESTAMPTZOID:
- case ABSTIMEOID:
case DATEOID:
case INTERVALOID:
- case RELTIMEOID:
- case TINTERVALOID:
case TIMEOID:
case TIMETZOID:
*scaledvalue = convert_timevalue_to_scalar(value, valuetypid,
return DatumGetTimestamp(value);
case TIMESTAMPTZOID:
return DatumGetTimestampTz(value);
- case ABSTIMEOID:
- return DatumGetTimestamp(DirectFunctionCall1(abstime_timestamp,
- value));
case DATEOID:
return date2timestamp_no_overflow(DatumGetDateADT(value));
case INTERVALOID:
return interval->time + interval->day * (double) USECS_PER_DAY +
interval->month * ((DAYS_PER_YEAR / (double) MONTHS_PER_YEAR) * USECS_PER_DAY);
}
- case RELTIMEOID:
- return (DatumGetRelativeTime(value) * 1000000.0);
- case TINTERVALOID:
- {
- TimeInterval tinterval = DatumGetTimeInterval(value);
-
- if (tinterval->status != 0)
- return ((tinterval->data[1] - tinterval->data[0]) * 1000000.0);
- return 0; /* for lack of a better idea */
- }
case TIMEOID:
return DatumGetTimeADT(value);
case TIMETZOID:
"false as rolcanlogin, "
"-1 as rolconnlimit, "
"null::text as rolpassword, "
- "null::abstime as rolvaliduntil, "
+ "null::timestamptz as rolvaliduntil, "
"false as rolreplication, "
"false as rolbypassrls, "
"null as rolcomment, "
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 201810091
+#define CATALOG_VERSION_NO 201810111
#endif
{ aggfnoid => 'max(float8)', aggtransfn => 'float8larger',
aggcombinefn => 'float8larger', aggsortop => '>(float8,float8)',
aggtranstype => 'float8' },
-{ aggfnoid => 'max(abstime)', aggtransfn => 'int4larger',
- aggcombinefn => 'int4larger', aggsortop => '>(abstime,abstime)',
- aggtranstype => 'abstime' },
{ aggfnoid => 'max(date)', aggtransfn => 'date_larger',
aggcombinefn => 'date_larger', aggsortop => '>(date,date)',
aggtranstype => 'date' },
{ aggfnoid => 'min(float8)', aggtransfn => 'float8smaller',
aggcombinefn => 'float8smaller', aggsortop => '<(float8,float8)',
aggtranstype => 'float8' },
-{ aggfnoid => 'min(abstime)', aggtransfn => 'int4smaller',
- aggcombinefn => 'int4smaller', aggsortop => '<(abstime,abstime)',
- aggtranstype => 'abstime' },
{ aggfnoid => 'min(date)', aggtransfn => 'date_smaller',
aggcombinefn => 'date_smaller', aggsortop => '<(date,date)',
aggtranstype => 'date' },
amoprighttype => 'bytea', amopstrategy => '5', amopopr => '>(bytea,bytea)',
amopmethod => 'btree' },
-# btree abstime_ops
-
-{ amopfamily => 'btree/abstime_ops', amoplefttype => 'abstime',
- amoprighttype => 'abstime', amopstrategy => '1',
- amopopr => '<(abstime,abstime)', amopmethod => 'btree' },
-{ amopfamily => 'btree/abstime_ops', amoplefttype => 'abstime',
- amoprighttype => 'abstime', amopstrategy => '2',
- amopopr => '<=(abstime,abstime)', amopmethod => 'btree' },
-{ amopfamily => 'btree/abstime_ops', amoplefttype => 'abstime',
- amoprighttype => 'abstime', amopstrategy => '3',
- amopopr => '=(abstime,abstime)', amopmethod => 'btree' },
-{ amopfamily => 'btree/abstime_ops', amoplefttype => 'abstime',
- amoprighttype => 'abstime', amopstrategy => '4',
- amopopr => '>=(abstime,abstime)', amopmethod => 'btree' },
-{ amopfamily => 'btree/abstime_ops', amoplefttype => 'abstime',
- amoprighttype => 'abstime', amopstrategy => '5',
- amopopr => '>(abstime,abstime)', amopmethod => 'btree' },
-
# btree datetime_ops
# default operators date
amoprighttype => 'money', amopstrategy => '5', amopopr => '>(money,money)',
amopmethod => 'btree' },
-# btree reltime_ops
-
-{ amopfamily => 'btree/reltime_ops', amoplefttype => 'reltime',
- amoprighttype => 'reltime', amopstrategy => '1',
- amopopr => '<(reltime,reltime)', amopmethod => 'btree' },
-{ amopfamily => 'btree/reltime_ops', amoplefttype => 'reltime',
- amoprighttype => 'reltime', amopstrategy => '2',
- amopopr => '<=(reltime,reltime)', amopmethod => 'btree' },
-{ amopfamily => 'btree/reltime_ops', amoplefttype => 'reltime',
- amoprighttype => 'reltime', amopstrategy => '3',
- amopopr => '=(reltime,reltime)', amopmethod => 'btree' },
-{ amopfamily => 'btree/reltime_ops', amoplefttype => 'reltime',
- amoprighttype => 'reltime', amopstrategy => '4',
- amopopr => '>=(reltime,reltime)', amopmethod => 'btree' },
-{ amopfamily => 'btree/reltime_ops', amoplefttype => 'reltime',
- amoprighttype => 'reltime', amopstrategy => '5',
- amopopr => '>(reltime,reltime)', amopmethod => 'btree' },
-
-# btree tinterval_ops
-
-{ amopfamily => 'btree/tinterval_ops', amoplefttype => 'tinterval',
- amoprighttype => 'tinterval', amopstrategy => '1',
- amopopr => '<(tinterval,tinterval)', amopmethod => 'btree' },
-{ amopfamily => 'btree/tinterval_ops', amoplefttype => 'tinterval',
- amoprighttype => 'tinterval', amopstrategy => '2',
- amopopr => '<=(tinterval,tinterval)', amopmethod => 'btree' },
-{ amopfamily => 'btree/tinterval_ops', amoplefttype => 'tinterval',
- amoprighttype => 'tinterval', amopstrategy => '3',
- amopopr => '=(tinterval,tinterval)', amopmethod => 'btree' },
-{ amopfamily => 'btree/tinterval_ops', amoplefttype => 'tinterval',
- amoprighttype => 'tinterval', amopstrategy => '4',
- amopopr => '>=(tinterval,tinterval)', amopmethod => 'btree' },
-{ amopfamily => 'btree/tinterval_ops', amoplefttype => 'tinterval',
- amoprighttype => 'tinterval', amopstrategy => '5',
- amopopr => '>(tinterval,tinterval)', amopmethod => 'btree' },
-
# btree array_ops
{ amopfamily => 'btree/array_ops', amoplefttype => 'anyarray',
{ amopfamily => 'hash/cid_ops', amoplefttype => 'cid', amoprighttype => 'cid',
amopstrategy => '1', amopopr => '=(cid,cid)', amopmethod => 'hash' },
-# abstime_ops
-{ amopfamily => 'hash/abstime_ops', amoplefttype => 'abstime',
- amoprighttype => 'abstime', amopstrategy => '1',
- amopopr => '=(abstime,abstime)', amopmethod => 'hash' },
-
-# reltime_ops
-{ amopfamily => 'hash/reltime_ops', amoplefttype => 'reltime',
- amoprighttype => 'reltime', amopstrategy => '1',
- amopopr => '=(reltime,reltime)', amopmethod => 'hash' },
-
# text_pattern_ops
{ amopfamily => 'hash/text_pattern_ops', amoplefttype => 'text',
amoprighttype => 'text', amopstrategy => '1', amopopr => '=(text,text)',
amoprighttype => 'float8', amopstrategy => '5', amopopr => '>(float8,float8)',
amopmethod => 'brin' },
-# minmax abstime
-{ amopfamily => 'brin/abstime_minmax_ops', amoplefttype => 'abstime',
- amoprighttype => 'abstime', amopstrategy => '1',
- amopopr => '<(abstime,abstime)', amopmethod => 'brin' },
-{ amopfamily => 'brin/abstime_minmax_ops', amoplefttype => 'abstime',
- amoprighttype => 'abstime', amopstrategy => '2',
- amopopr => '<=(abstime,abstime)', amopmethod => 'brin' },
-{ amopfamily => 'brin/abstime_minmax_ops', amoplefttype => 'abstime',
- amoprighttype => 'abstime', amopstrategy => '3',
- amopopr => '=(abstime,abstime)', amopmethod => 'brin' },
-{ amopfamily => 'brin/abstime_minmax_ops', amoplefttype => 'abstime',
- amoprighttype => 'abstime', amopstrategy => '4',
- amopopr => '>=(abstime,abstime)', amopmethod => 'brin' },
-{ amopfamily => 'brin/abstime_minmax_ops', amoplefttype => 'abstime',
- amoprighttype => 'abstime', amopstrategy => '5',
- amopopr => '>(abstime,abstime)', amopmethod => 'brin' },
-
-# minmax reltime
-{ amopfamily => 'brin/reltime_minmax_ops', amoplefttype => 'reltime',
- amoprighttype => 'reltime', amopstrategy => '1',
- amopopr => '<(reltime,reltime)', amopmethod => 'brin' },
-{ amopfamily => 'brin/reltime_minmax_ops', amoplefttype => 'reltime',
- amoprighttype => 'reltime', amopstrategy => '2',
- amopopr => '<=(reltime,reltime)', amopmethod => 'brin' },
-{ amopfamily => 'brin/reltime_minmax_ops', amoplefttype => 'reltime',
- amoprighttype => 'reltime', amopstrategy => '3',
- amopopr => '=(reltime,reltime)', amopmethod => 'brin' },
-{ amopfamily => 'brin/reltime_minmax_ops', amoplefttype => 'reltime',
- amoprighttype => 'reltime', amopstrategy => '4',
- amopopr => '>=(reltime,reltime)', amopmethod => 'brin' },
-{ amopfamily => 'brin/reltime_minmax_ops', amoplefttype => 'reltime',
- amoprighttype => 'reltime', amopstrategy => '5',
- amopopr => '>(reltime,reltime)', amopmethod => 'brin' },
-
# minmax macaddr
{ amopfamily => 'brin/macaddr_minmax_ops', amoplefttype => 'macaddr',
amoprighttype => 'macaddr', amopstrategy => '1',
# btree
{ amprocfamily => 'btree/array_ops', amproclefttype => 'anyarray',
amprocrighttype => 'anyarray', amprocnum => '1', amproc => 'btarraycmp' },
-{ amprocfamily => 'btree/abstime_ops', amproclefttype => 'abstime',
- amprocrighttype => 'abstime', amprocnum => '1', amproc => 'btabstimecmp' },
{ amprocfamily => 'btree/bit_ops', amproclefttype => 'bit',
amprocrighttype => 'bit', amprocnum => '1', amproc => 'bitcmp' },
{ amprocfamily => 'btree/bool_ops', amproclefttype => 'bool',
amproc => 'btbpchar_pattern_sortsupport' },
{ amprocfamily => 'btree/money_ops', amproclefttype => 'money',
amprocrighttype => 'money', amprocnum => '1', amproc => 'cash_cmp' },
-{ amprocfamily => 'btree/reltime_ops', amproclefttype => 'reltime',
- amprocrighttype => 'reltime', amprocnum => '1', amproc => 'btreltimecmp' },
-{ amprocfamily => 'btree/tinterval_ops', amproclefttype => 'tinterval',
- amprocrighttype => 'tinterval', amprocnum => '1',
- amproc => 'bttintervalcmp' },
{ amprocfamily => 'btree/tid_ops', amproclefttype => 'tid',
amprocrighttype => 'tid', amprocnum => '1', amproc => 'bttidcmp' },
{ amprocfamily => 'btree/uuid_ops', amproclefttype => 'uuid',
amprocrighttype => 'cid', amprocnum => '1', amproc => 'hashint4' },
{ amprocfamily => 'hash/cid_ops', amproclefttype => 'cid',
amprocrighttype => 'cid', amprocnum => '2', amproc => 'hashint4extended' },
-{ amprocfamily => 'hash/abstime_ops', amproclefttype => 'abstime',
- amprocrighttype => 'abstime', amprocnum => '1', amproc => 'hashint4' },
-{ amprocfamily => 'hash/abstime_ops', amproclefttype => 'abstime',
- amprocrighttype => 'abstime', amprocnum => '2',
- amproc => 'hashint4extended' },
-{ amprocfamily => 'hash/reltime_ops', amproclefttype => 'reltime',
- amprocrighttype => 'reltime', amprocnum => '1', amproc => 'hashint4' },
-{ amprocfamily => 'hash/reltime_ops', amproclefttype => 'reltime',
- amprocrighttype => 'reltime', amprocnum => '2',
- amproc => 'hashint4extended' },
{ amprocfamily => 'hash/text_pattern_ops', amproclefttype => 'text',
amprocrighttype => 'text', amprocnum => '1', amproc => 'hashtext' },
{ amprocfamily => 'hash/text_pattern_ops', amproclefttype => 'text',
amprocrighttype => 'float4', amprocnum => '4',
amproc => 'brin_minmax_union' },
-# minmax abstime
-{ amprocfamily => 'brin/abstime_minmax_ops', amproclefttype => 'abstime',
- amprocrighttype => 'abstime', amprocnum => '1',
- amproc => 'brin_minmax_opcinfo' },
-{ amprocfamily => 'brin/abstime_minmax_ops', amproclefttype => 'abstime',
- amprocrighttype => 'abstime', amprocnum => '2',
- amproc => 'brin_minmax_add_value' },
-{ amprocfamily => 'brin/abstime_minmax_ops', amproclefttype => 'abstime',
- amprocrighttype => 'abstime', amprocnum => '3',
- amproc => 'brin_minmax_consistent' },
-{ amprocfamily => 'brin/abstime_minmax_ops', amproclefttype => 'abstime',
- amprocrighttype => 'abstime', amprocnum => '4',
- amproc => 'brin_minmax_union' },
-
-# minmax reltime
-{ amprocfamily => 'brin/reltime_minmax_ops', amproclefttype => 'reltime',
- amprocrighttype => 'reltime', amprocnum => '1',
- amproc => 'brin_minmax_opcinfo' },
-{ amprocfamily => 'brin/reltime_minmax_ops', amproclefttype => 'reltime',
- amprocrighttype => 'reltime', amprocnum => '2',
- amproc => 'brin_minmax_add_value' },
-{ amprocfamily => 'brin/reltime_minmax_ops', amproclefttype => 'reltime',
- amprocrighttype => 'reltime', amprocnum => '3',
- amproc => 'brin_minmax_consistent' },
-{ amprocfamily => 'brin/reltime_minmax_ops', amproclefttype => 'reltime',
- amprocrighttype => 'reltime', amprocnum => '4',
- amproc => 'brin_minmax_union' },
-
# minmax macaddr
{ amprocfamily => 'brin/macaddr_minmax_ops', amproclefttype => 'macaddr',
amprocrighttype => 'macaddr', amprocnum => '1',
castcontext => 'i', castmethod => 'i' },
# Datetime category
-{ castsource => 'abstime', casttarget => 'date', castfunc => 'date(abstime)',
- castcontext => 'a', castmethod => 'f' },
-{ castsource => 'abstime', casttarget => 'time', castfunc => 'time(abstime)',
- castcontext => 'a', castmethod => 'f' },
-{ castsource => 'abstime', casttarget => 'timestamp',
- castfunc => 'timestamp(abstime)', castcontext => 'i', castmethod => 'f' },
-{ castsource => 'abstime', casttarget => 'timestamptz',
- castfunc => 'timestamptz(abstime)', castcontext => 'i', castmethod => 'f' },
-{ castsource => 'reltime', casttarget => 'interval',
- castfunc => 'interval(reltime)', castcontext => 'i', castmethod => 'f' },
{ castsource => 'date', casttarget => 'timestamp',
castfunc => 'timestamp(date)', castcontext => 'i', castmethod => 'f' },
{ castsource => 'date', casttarget => 'timestamptz',
castcontext => 'i', castmethod => 'f' },
{ castsource => 'time', casttarget => 'timetz', castfunc => 'timetz(time)',
castcontext => 'i', castmethod => 'f' },
-{ castsource => 'timestamp', casttarget => 'abstime',
- castfunc => 'abstime(timestamp)', castcontext => 'a', castmethod => 'f' },
{ castsource => 'timestamp', casttarget => 'date',
castfunc => 'date(timestamp)', castcontext => 'a', castmethod => 'f' },
{ castsource => 'timestamp', casttarget => 'time',
castfunc => 'time(timestamp)', castcontext => 'a', castmethod => 'f' },
{ castsource => 'timestamp', casttarget => 'timestamptz',
castfunc => 'timestamptz(timestamp)', castcontext => 'i', castmethod => 'f' },
-{ castsource => 'timestamptz', casttarget => 'abstime',
- castfunc => 'abstime(timestamptz)', castcontext => 'a', castmethod => 'f' },
{ castsource => 'timestamptz', casttarget => 'date',
castfunc => 'date(timestamptz)', castcontext => 'a', castmethod => 'f' },
{ castsource => 'timestamptz', casttarget => 'time',
castfunc => 'timestamp(timestamptz)', castcontext => 'a', castmethod => 'f' },
{ castsource => 'timestamptz', casttarget => 'timetz',
castfunc => 'timetz(timestamptz)', castcontext => 'a', castmethod => 'f' },
-{ castsource => 'interval', casttarget => 'reltime', castfunc => 'reltime',
- castcontext => 'a', castmethod => 'f' },
{ castsource => 'interval', casttarget => 'time', castfunc => 'time(interval)',
castcontext => 'a', castmethod => 'f' },
{ castsource => 'timetz', casttarget => 'time', castfunc => 'time(timetz)',
castcontext => 'a', castmethod => 'f' },
-# Cross-category casts between int4 and abstime, reltime
-{ castsource => 'int4', casttarget => 'abstime', castfunc => '0',
- castcontext => 'e', castmethod => 'b' },
-{ castsource => 'abstime', casttarget => 'int4', castfunc => '0',
- castcontext => 'e', castmethod => 'b' },
-{ castsource => 'int4', casttarget => 'reltime', castfunc => '0',
- castcontext => 'e', castmethod => 'b' },
-{ castsource => 'reltime', casttarget => 'int4', castfunc => '0',
- castcontext => 'e', castmethod => 'b' },
-
# Geometric category
{ castsource => 'point', casttarget => 'box', castfunc => 'box(point)',
castcontext => 'a', castmethod => 'f' },
# referenced in the C code or in built-in catalog entries. The rest get OIDs
# assigned on-the-fly during initdb.
-{ opcmethod => 'btree', opcname => 'abstime_ops',
- opcfamily => 'btree/abstime_ops', opcintype => 'abstime' },
{ opcmethod => 'btree', opcname => 'array_ops', opcfamily => 'btree/array_ops',
opcintype => 'anyarray' },
{ opcmethod => 'hash', opcname => 'array_ops', opcfamily => 'hash/array_ops',
opcintype => 'xid' },
{ opcmethod => 'hash', opcname => 'cid_ops', opcfamily => 'hash/cid_ops',
opcintype => 'cid' },
-{ opcmethod => 'hash', opcname => 'abstime_ops',
- opcfamily => 'hash/abstime_ops', opcintype => 'abstime' },
-{ opcmethod => 'hash', opcname => 'reltime_ops',
- opcfamily => 'hash/reltime_ops', opcintype => 'reltime' },
{ opcmethod => 'hash', opcname => 'text_pattern_ops',
opcfamily => 'hash/text_pattern_ops', opcintype => 'text',
opcdefault => 'f' },
{ opcmethod => 'hash', opcname => 'bpchar_pattern_ops',
opcfamily => 'hash/bpchar_pattern_ops', opcintype => 'bpchar',
opcdefault => 'f' },
-{ opcmethod => 'btree', opcname => 'reltime_ops',
- opcfamily => 'btree/reltime_ops', opcintype => 'reltime' },
-{ opcmethod => 'btree', opcname => 'tinterval_ops',
- opcfamily => 'btree/tinterval_ops', opcintype => 'tinterval' },
{ opcmethod => 'hash', opcname => 'aclitem_ops',
opcfamily => 'hash/aclitem_ops', opcintype => 'aclitem' },
{ opcmethod => 'gist', opcname => 'box_ops', opcfamily => 'gist/box_ops',
{ opcmethod => 'brin', opcname => 'float8_minmax_ops',
opcfamily => 'brin/float_minmax_ops', opcintype => 'float8',
opckeytype => 'float8' },
-{ opcmethod => 'brin', opcname => 'abstime_minmax_ops',
- opcfamily => 'brin/abstime_minmax_ops', opcintype => 'abstime',
- opckeytype => 'abstime' },
-{ opcmethod => 'brin', opcname => 'reltime_minmax_ops',
- opcfamily => 'brin/reltime_minmax_ops', opcintype => 'reltime',
- opckeytype => 'reltime' },
{ opcmethod => 'brin', opcname => 'macaddr_minmax_ops',
opcfamily => 'brin/macaddr_minmax_ops', opcintype => 'macaddr',
opckeytype => 'macaddr' },
{ oid => '559', descr => 'negate',
oprname => '-', oprkind => 'l', oprleft => '0', oprright => 'int2',
oprresult => 'int2', oprcode => 'int2um' },
-{ oid => '560', descr => 'equal',
- oprname => '=', oprcanmerge => 't', oprcanhash => 't', oprleft => 'abstime',
- oprright => 'abstime', oprresult => 'bool', oprcom => '=(abstime,abstime)',
- oprnegate => '<>(abstime,abstime)', oprcode => 'abstimeeq',
- oprrest => 'eqsel', oprjoin => 'eqjoinsel' },
-{ oid => '561', descr => 'not equal',
- oprname => '<>', oprleft => 'abstime', oprright => 'abstime',
- oprresult => 'bool', oprcom => '<>(abstime,abstime)',
- oprnegate => '=(abstime,abstime)', oprcode => 'abstimene',
- oprrest => 'neqsel', oprjoin => 'neqjoinsel' },
-{ oid => '562', descr => 'less than',
- oprname => '<', oprleft => 'abstime', oprright => 'abstime',
- oprresult => 'bool', oprcom => '>(abstime,abstime)',
- oprnegate => '>=(abstime,abstime)', oprcode => 'abstimelt',
- oprrest => 'scalarltsel', oprjoin => 'scalarltjoinsel' },
-{ oid => '563', descr => 'greater than',
- oprname => '>', oprleft => 'abstime', oprright => 'abstime',
- oprresult => 'bool', oprcom => '<(abstime,abstime)',
- oprnegate => '<=(abstime,abstime)', oprcode => 'abstimegt',
- oprrest => 'scalargtsel', oprjoin => 'scalargtjoinsel' },
-{ oid => '564', descr => 'less than or equal',
- oprname => '<=', oprleft => 'abstime', oprright => 'abstime',
- oprresult => 'bool', oprcom => '>=(abstime,abstime)',
- oprnegate => '>(abstime,abstime)', oprcode => 'abstimele',
- oprrest => 'scalarlesel', oprjoin => 'scalarlejoinsel' },
-{ oid => '565', descr => 'greater than or equal',
- oprname => '>=', oprleft => 'abstime', oprright => 'abstime',
- oprresult => 'bool', oprcom => '<=(abstime,abstime)',
- oprnegate => '<(abstime,abstime)', oprcode => 'abstimege',
- oprrest => 'scalargesel', oprjoin => 'scalargejoinsel' },
-{ oid => '566', descr => 'equal',
- oprname => '=', oprcanmerge => 't', oprcanhash => 't', oprleft => 'reltime',
- oprright => 'reltime', oprresult => 'bool', oprcom => '=(reltime,reltime)',
- oprnegate => '<>(reltime,reltime)', oprcode => 'reltimeeq',
- oprrest => 'eqsel', oprjoin => 'eqjoinsel' },
-{ oid => '567', descr => 'not equal',
- oprname => '<>', oprleft => 'reltime', oprright => 'reltime',
- oprresult => 'bool', oprcom => '<>(reltime,reltime)',
- oprnegate => '=(reltime,reltime)', oprcode => 'reltimene',
- oprrest => 'neqsel', oprjoin => 'neqjoinsel' },
-{ oid => '568', descr => 'less than',
- oprname => '<', oprleft => 'reltime', oprright => 'reltime',
- oprresult => 'bool', oprcom => '>(reltime,reltime)',
- oprnegate => '>=(reltime,reltime)', oprcode => 'reltimelt',
- oprrest => 'scalarltsel', oprjoin => 'scalarltjoinsel' },
-{ oid => '569', descr => 'greater than',
- oprname => '>', oprleft => 'reltime', oprright => 'reltime',
- oprresult => 'bool', oprcom => '<(reltime,reltime)',
- oprnegate => '<=(reltime,reltime)', oprcode => 'reltimegt',
- oprrest => 'scalargtsel', oprjoin => 'scalargtjoinsel' },
-{ oid => '570', descr => 'less than or equal',
- oprname => '<=', oprleft => 'reltime', oprright => 'reltime',
- oprresult => 'bool', oprcom => '>=(reltime,reltime)',
- oprnegate => '>(reltime,reltime)', oprcode => 'reltimele',
- oprrest => 'scalarlesel', oprjoin => 'scalarlejoinsel' },
-{ oid => '571', descr => 'greater than or equal',
- oprname => '>=', oprleft => 'reltime', oprright => 'reltime',
- oprresult => 'bool', oprcom => '<=(reltime,reltime)',
- oprnegate => '<(reltime,reltime)', oprcode => 'reltimege',
- oprrest => 'scalargesel', oprjoin => 'scalargejoinsel' },
-{ oid => '572', descr => 'same as',
- oprname => '~=', oprleft => 'tinterval', oprright => 'tinterval',
- oprresult => 'bool', oprcom => '~=(tinterval,tinterval)',
- oprcode => 'tintervalsame', oprrest => 'eqsel', oprjoin => 'eqjoinsel' },
-{ oid => '573', descr => 'contains',
- oprname => '<<', oprleft => 'tinterval', oprright => 'tinterval',
- oprresult => 'bool', oprcode => 'tintervalct' },
-{ oid => '574', descr => 'overlaps',
- oprname => '&&', oprleft => 'tinterval', oprright => 'tinterval',
- oprresult => 'bool', oprcom => '&&(tinterval,tinterval)',
- oprcode => 'tintervalov' },
-{ oid => '575', descr => 'equal by length',
- oprname => '#=', oprleft => 'tinterval', oprright => 'reltime',
- oprresult => 'bool', oprnegate => '#<>(tinterval,reltime)',
- oprcode => 'tintervalleneq' },
-{ oid => '576', descr => 'not equal by length',
- oprname => '#<>', oprleft => 'tinterval', oprright => 'reltime',
- oprresult => 'bool', oprnegate => '#=(tinterval,reltime)',
- oprcode => 'tintervallenne' },
-{ oid => '577', descr => 'less than by length',
- oprname => '#<', oprleft => 'tinterval', oprright => 'reltime',
- oprresult => 'bool', oprnegate => '#>=(tinterval,reltime)',
- oprcode => 'tintervallenlt' },
-{ oid => '578', descr => 'greater than by length',
- oprname => '#>', oprleft => 'tinterval', oprright => 'reltime',
- oprresult => 'bool', oprnegate => '#<=(tinterval,reltime)',
- oprcode => 'tintervallengt' },
-{ oid => '579', descr => 'less than or equal by length',
- oprname => '#<=', oprleft => 'tinterval', oprright => 'reltime',
- oprresult => 'bool', oprnegate => '#>(tinterval,reltime)',
- oprcode => 'tintervallenle' },
-{ oid => '580', descr => 'greater than or equal by length',
- oprname => '#>=', oprleft => 'tinterval', oprright => 'reltime',
- oprresult => 'bool', oprnegate => '#<(tinterval,reltime)',
- oprcode => 'tintervallenge' },
-{ oid => '581', descr => 'add',
- oprname => '+', oprleft => 'abstime', oprright => 'reltime',
- oprresult => 'abstime', oprcode => 'timepl' },
-{ oid => '582', descr => 'subtract',
- oprname => '-', oprleft => 'abstime', oprright => 'reltime',
- oprresult => 'abstime', oprcode => 'timemi' },
-{ oid => '583', descr => 'is contained by',
- oprname => '<?>', oprleft => 'abstime', oprright => 'tinterval',
- oprresult => 'bool', oprcode => 'intinterval' },
{ oid => '584', descr => 'negate',
oprname => '-', oprkind => 'l', oprleft => '0', oprright => 'float4',
oprresult => 'float4', oprcode => 'float4um' },
{ oid => '597', descr => 'cube root',
oprname => '||/', oprkind => 'l', oprleft => '0', oprright => 'float8',
oprresult => 'float8', oprcode => 'dcbrt' },
-{ oid => '1284', descr => 'start of interval',
- oprname => '|', oprkind => 'l', oprleft => '0', oprright => 'tinterval',
- oprresult => 'abstime', oprcode => 'tintervalstart' },
-{ oid => '606', descr => 'convert to tinterval',
- oprname => '<#>', oprleft => 'abstime', oprright => 'abstime',
- oprresult => 'tinterval', oprcode => 'mktinterval' },
{ oid => '607', descr => 'equal',
oprname => '=', oprcanmerge => 't', oprcanhash => 't', oprleft => 'oid',
oprname => '?|', oprleft => 'point', oprright => 'point', oprresult => 'bool',
oprcom => '?|(point,point)', oprcode => 'point_vert' },
-{ oid => '811', descr => 'equal',
- oprname => '=', oprcanmerge => 't', oprleft => 'tinterval',
- oprright => 'tinterval', oprresult => 'bool',
- oprcom => '=(tinterval,tinterval)', oprnegate => '<>(tinterval,tinterval)',
- oprcode => 'tintervaleq', oprrest => 'eqsel', oprjoin => 'eqjoinsel' },
-{ oid => '812', descr => 'not equal',
- oprname => '<>', oprleft => 'tinterval', oprright => 'tinterval',
- oprresult => 'bool', oprcom => '<>(tinterval,tinterval)',
- oprnegate => '=(tinterval,tinterval)', oprcode => 'tintervalne',
- oprrest => 'neqsel', oprjoin => 'neqjoinsel' },
-{ oid => '813', descr => 'less than',
- oprname => '<', oprleft => 'tinterval', oprright => 'tinterval',
- oprresult => 'bool', oprcom => '>(tinterval,tinterval)',
- oprnegate => '>=(tinterval,tinterval)', oprcode => 'tintervallt',
- oprrest => 'scalarltsel', oprjoin => 'scalarltjoinsel' },
-{ oid => '814', descr => 'greater than',
- oprname => '>', oprleft => 'tinterval', oprright => 'tinterval',
- oprresult => 'bool', oprcom => '<(tinterval,tinterval)',
- oprnegate => '<=(tinterval,tinterval)', oprcode => 'tintervalgt',
- oprrest => 'scalargtsel', oprjoin => 'scalargtjoinsel' },
-{ oid => '815', descr => 'less than or equal',
- oprname => '<=', oprleft => 'tinterval', oprright => 'tinterval',
- oprresult => 'bool', oprcom => '>=(tinterval,tinterval)',
- oprnegate => '>(tinterval,tinterval)', oprcode => 'tintervalle',
- oprrest => 'scalarlesel', oprjoin => 'scalarlejoinsel' },
-{ oid => '816', descr => 'greater than or equal',
- oprname => '>=', oprleft => 'tinterval', oprright => 'tinterval',
- oprresult => 'bool', oprcom => '<=(tinterval,tinterval)',
- oprnegate => '<(tinterval,tinterval)', oprcode => 'tintervalge',
- oprrest => 'scalargesel', oprjoin => 'scalargejoinsel' },
-
{ oid => '843', descr => 'multiply',
oprname => '*', oprleft => 'money', oprright => 'float4',
oprresult => 'money', oprcom => '*(float4,money)',
[
-{ oid => '421',
- opfmethod => 'btree', opfname => 'abstime_ops' },
{ oid => '397',
opfmethod => 'btree', opfname => 'array_ops' },
{ oid => '627',
opfmethod => 'hash', opfname => 'xid_ops' },
{ oid => '2226',
opfmethod => 'hash', opfname => 'cid_ops' },
-{ oid => '2227',
- opfmethod => 'hash', opfname => 'abstime_ops' },
-{ oid => '2228',
- opfmethod => 'hash', opfname => 'reltime_ops' },
{ oid => '2229',
opfmethod => 'hash', opfname => 'text_pattern_ops' },
{ oid => '2231',
opfmethod => 'hash', opfname => 'bpchar_pattern_ops' },
-{ oid => '2233',
- opfmethod => 'btree', opfname => 'reltime_ops' },
-{ oid => '2234',
- opfmethod => 'btree', opfname => 'tinterval_ops' },
{ oid => '2235',
opfmethod => 'hash', opfname => 'aclitem_ops' },
{ oid => '2593',
opfmethod => 'brin', opfname => 'tid_minmax_ops' },
{ oid => '4070',
opfmethod => 'brin', opfname => 'float_minmax_ops' },
-{ oid => '4072',
- opfmethod => 'brin', opfname => 'abstime_minmax_ops' },
-{ oid => '4073',
- opfmethod => 'brin', opfname => 'reltime_minmax_ops' },
{ oid => '4074',
opfmethod => 'brin', opfname => 'macaddr_minmax_ops' },
{ oid => '4109',
proname => 'line_distance', prorettype => 'float8',
proargtypes => 'line line', prosrc => 'line_distance' },
-{ oid => '240', descr => 'I/O',
- proname => 'abstimein', provolatile => 's', prorettype => 'abstime',
- proargtypes => 'cstring', prosrc => 'abstimein' },
-{ oid => '241', descr => 'I/O',
- proname => 'abstimeout', provolatile => 's', prorettype => 'cstring',
- proargtypes => 'abstime', prosrc => 'abstimeout' },
-{ oid => '242', descr => 'I/O',
- proname => 'reltimein', provolatile => 's', prorettype => 'reltime',
- proargtypes => 'cstring', prosrc => 'reltimein' },
-{ oid => '243', descr => 'I/O',
- proname => 'reltimeout', provolatile => 's', prorettype => 'cstring',
- proargtypes => 'reltime', prosrc => 'reltimeout' },
-{ oid => '244',
- proname => 'timepl', prorettype => 'abstime',
- proargtypes => 'abstime reltime', prosrc => 'timepl' },
-{ oid => '245',
- proname => 'timemi', prorettype => 'abstime',
- proargtypes => 'abstime reltime', prosrc => 'timemi' },
-{ oid => '246', descr => 'I/O',
- proname => 'tintervalin', provolatile => 's', prorettype => 'tinterval',
- proargtypes => 'cstring', prosrc => 'tintervalin' },
-{ oid => '247', descr => 'I/O',
- proname => 'tintervalout', provolatile => 's', prorettype => 'cstring',
- proargtypes => 'tinterval', prosrc => 'tintervalout' },
-{ oid => '248',
- proname => 'intinterval', prorettype => 'bool',
- proargtypes => 'abstime tinterval', prosrc => 'intinterval' },
-{ oid => '249', descr => 'tinterval to reltime',
- proname => 'tintervalrel', prorettype => 'reltime',
- proargtypes => 'tinterval', prosrc => 'tintervalrel' },
-{ oid => '250', descr => 'current date and time (abstime)',
- proname => 'timenow', provolatile => 's', prorettype => 'abstime',
- proargtypes => '', prosrc => 'timenow' },
-{ oid => '251',
- proname => 'abstimeeq', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'abstime abstime', prosrc => 'abstimeeq' },
-{ oid => '252',
- proname => 'abstimene', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'abstime abstime', prosrc => 'abstimene' },
-{ oid => '253',
- proname => 'abstimelt', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'abstime abstime', prosrc => 'abstimelt' },
-{ oid => '254',
- proname => 'abstimegt', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'abstime abstime', prosrc => 'abstimegt' },
-{ oid => '255',
- proname => 'abstimele', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'abstime abstime', prosrc => 'abstimele' },
-{ oid => '256',
- proname => 'abstimege', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'abstime abstime', prosrc => 'abstimege' },
-{ oid => '257',
- proname => 'reltimeeq', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'reltime reltime', prosrc => 'reltimeeq' },
-{ oid => '258',
- proname => 'reltimene', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'reltime reltime', prosrc => 'reltimene' },
-{ oid => '259',
- proname => 'reltimelt', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'reltime reltime', prosrc => 'reltimelt' },
-{ oid => '260',
- proname => 'reltimegt', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'reltime reltime', prosrc => 'reltimegt' },
-{ oid => '261',
- proname => 'reltimele', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'reltime reltime', prosrc => 'reltimele' },
-{ oid => '262',
- proname => 'reltimege', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'reltime reltime', prosrc => 'reltimege' },
-{ oid => '263',
- proname => 'tintervalsame', prorettype => 'bool',
- proargtypes => 'tinterval tinterval', prosrc => 'tintervalsame' },
-{ oid => '264',
- proname => 'tintervalct', prorettype => 'bool',
- proargtypes => 'tinterval tinterval', prosrc => 'tintervalct' },
-{ oid => '265',
- proname => 'tintervalov', prorettype => 'bool',
- proargtypes => 'tinterval tinterval', prosrc => 'tintervalov' },
-{ oid => '266',
- proname => 'tintervalleneq', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'tinterval reltime', prosrc => 'tintervalleneq' },
-{ oid => '267',
- proname => 'tintervallenne', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'tinterval reltime', prosrc => 'tintervallenne' },
-{ oid => '268',
- proname => 'tintervallenlt', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'tinterval reltime', prosrc => 'tintervallenlt' },
-{ oid => '269',
- proname => 'tintervallengt', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'tinterval reltime', prosrc => 'tintervallengt' },
-{ oid => '270',
- proname => 'tintervallenle', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'tinterval reltime', prosrc => 'tintervallenle' },
-{ oid => '271',
- proname => 'tintervallenge', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'tinterval reltime', prosrc => 'tintervallenge' },
-{ oid => '272',
- proname => 'tintervalstart', prorettype => 'abstime',
- proargtypes => 'tinterval', prosrc => 'tintervalstart' },
-{ oid => '273', descr => 'end of interval',
- proname => 'tintervalend', prorettype => 'abstime',
- proargtypes => 'tinterval', prosrc => 'tintervalend' },
{ oid => '274',
descr => 'current date and time - increments during transactions',
proname => 'timeofday', provolatile => 'v', prorettype => 'text',
proargtypes => '', prosrc => 'timeofday' },
-{ oid => '275', descr => 'finite abstime?',
- proname => 'isfinite', prorettype => 'bool', proargtypes => 'abstime',
- prosrc => 'abstime_finite' },
{ oid => '277',
proname => 'inter_sl', prorettype => 'bool', proargtypes => 'lseg line',
{ oid => '404', descr => 'less-equal-greater',
proname => 'btoidvectorcmp', prorettype => 'int4',
proargtypes => 'oidvector oidvector', prosrc => 'btoidvectorcmp' },
-{ oid => '357', descr => 'less-equal-greater',
- proname => 'btabstimecmp', proleakproof => 't', prorettype => 'int4',
- proargtypes => 'abstime abstime', prosrc => 'btabstimecmp' },
{ oid => '358', descr => 'less-equal-greater',
proname => 'btcharcmp', proleakproof => 't', prorettype => 'int4',
proargtypes => 'char char', prosrc => 'btcharcmp' },
{ oid => '377', descr => 'less-equal-greater',
proname => 'cash_cmp', proleakproof => 't', prorettype => 'int4',
proargtypes => 'money money', prosrc => 'cash_cmp' },
-{ oid => '380', descr => 'less-equal-greater',
- proname => 'btreltimecmp', proleakproof => 't', prorettype => 'int4',
- proargtypes => 'reltime reltime', prosrc => 'btreltimecmp' },
-{ oid => '381', descr => 'less-equal-greater',
- proname => 'bttintervalcmp', proleakproof => 't', prorettype => 'int4',
- proargtypes => 'tinterval tinterval', prosrc => 'bttintervalcmp' },
{ oid => '382', descr => 'less-equal-greater',
proname => 'btarraycmp', prorettype => 'int4',
proargtypes => 'anyarray anyarray', prosrc => 'btarraycmp' },
prorettype => 'varchar', proargtypes => 'varchar int4 bool',
prosrc => 'varchar' },
-{ oid => '676',
- proname => 'mktinterval', prorettype => 'tinterval',
- proargtypes => 'abstime abstime', prosrc => 'mktinterval' },
-
{ oid => '619',
proname => 'oidvectorne', prorettype => 'bool',
proargtypes => 'oidvector oidvector', prosrc => 'oidvectorne' },
proname => 'int2smaller', prorettype => 'int2', proargtypes => 'int2 int2',
prosrc => 'int2smaller' },
-{ oid => '784',
- proname => 'tintervaleq', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'tinterval tinterval', prosrc => 'tintervaleq' },
-{ oid => '785',
- proname => 'tintervalne', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'tinterval tinterval', prosrc => 'tintervalne' },
-{ oid => '786',
- proname => 'tintervallt', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'tinterval tinterval', prosrc => 'tintervallt' },
-{ oid => '787',
- proname => 'tintervalgt', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'tinterval tinterval', prosrc => 'tintervalgt' },
-{ oid => '788',
- proname => 'tintervalle', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'tinterval tinterval', prosrc => 'tintervalle' },
-{ oid => '789',
- proname => 'tintervalge', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'tinterval tinterval', prosrc => 'tintervalge' },
-
# OIDS 800 - 899
{ oid => '846',
{ oid => '1172', descr => 'extract field from interval',
proname => 'date_part', prorettype => 'float8',
proargtypes => 'text interval', prosrc => 'interval_part' },
-{ oid => '1173', descr => 'convert abstime to timestamp with time zone',
- proname => 'timestamptz', prorettype => 'timestamptz',
- proargtypes => 'abstime', prosrc => 'abstime_timestamptz' },
{ oid => '1174', descr => 'convert date to timestamp with time zone',
proname => 'timestamptz', provolatile => 's', prorettype => 'timestamptz',
proargtypes => 'date', prosrc => 'date_timestamptz' },
proname => 'timestamptz', prolang => '14', provolatile => 's',
prorettype => 'timestamptz', proargtypes => 'date time',
prosrc => 'select cast(($1 + $2) as timestamp with time zone)' },
-{ oid => '1177', descr => 'convert reltime to interval',
- proname => 'interval', prorettype => 'interval', proargtypes => 'reltime',
- prosrc => 'reltime_interval' },
{ oid => '1178', descr => 'convert timestamp with time zone to date',
proname => 'date', provolatile => 's', prorettype => 'date',
proargtypes => 'timestamptz', prosrc => 'timestamptz_date' },
-{ oid => '1179', descr => 'convert abstime to date',
- proname => 'date', provolatile => 's', prorettype => 'date',
- proargtypes => 'abstime', prosrc => 'abstime_date' },
-{ oid => '1180', descr => 'convert timestamp with time zone to abstime',
- proname => 'abstime', prorettype => 'abstime', proargtypes => 'timestamptz',
- prosrc => 'timestamptz_abstime' },
{ oid => '1181',
descr => 'age of a transaction ID, in transactions before current transaction',
proname => 'age', provolatile => 's', proparallel => 'r',
proname => 'timestamptz_mi_interval', provolatile => 's',
prorettype => 'timestamptz', proargtypes => 'timestamptz interval',
prosrc => 'timestamptz_mi_interval' },
-{ oid => '1194', descr => 'convert interval to reltime',
- proname => 'reltime', prorettype => 'reltime', proargtypes => 'interval',
- prosrc => 'interval_reltime' },
{ oid => '1195', descr => 'smaller of two',
proname => 'timestamptz_smaller', prorettype => 'timestamptz',
proargtypes => 'timestamptz timestamptz', prosrc => 'timestamp_smaller' },
proname => 'timestamptz', prorettype => 'timestamptz',
proargtypes => 'date timetz', prosrc => 'datetimetz_timestamptz' },
-{ oid => '1364', descr => 'convert abstime to time',
- proname => 'time', prolang => '14', provolatile => 's', prorettype => 'time',
- proargtypes => 'abstime',
- prosrc => 'select cast(cast($1 as timestamp without time zone) as pg_catalog.time)' },
-
{ oid => '1367', descr => 'character length',
proname => 'character_length', prorettype => 'int4', proargtypes => 'bpchar',
prosrc => 'bpcharlen' },
proname => 'char_length', prorettype => 'int4', proargtypes => 'text',
prosrc => 'textlen' },
-{ oid => '1382', descr => 'extract field from abstime',
- proname => 'date_part', prolang => '14', provolatile => 's',
- prorettype => 'float8', proargtypes => 'text abstime',
- prosrc => 'select pg_catalog.date_part($1, cast($2 as timestamp with time zone))' },
-{ oid => '1383', descr => 'extract field from reltime',
- proname => 'date_part', prolang => '14', provolatile => 's',
- prorettype => 'float8', proargtypes => 'text reltime',
- prosrc => 'select pg_catalog.date_part($1, cast($2 as pg_catalog.interval))' },
{ oid => '1384', descr => 'extract field from date',
proname => 'date_part', prolang => '14', prorettype => 'float8',
proargtypes => 'text date',
{ oid => '1480', descr => 'convert circle to box',
proname => 'box', prorettype => 'box', proargtypes => 'circle',
prosrc => 'circle_box' },
-{ oid => '1481', descr => 'convert to tinterval',
- proname => 'tinterval', prorettype => 'tinterval',
- proargtypes => 'abstime abstime', prosrc => 'mktinterval' },
{ oid => '1482',
proname => 'lseg_ne', proleakproof => 't', prorettype => 'bool',
{ oid => '2021', descr => 'extract field from timestamp',
proname => 'date_part', prorettype => 'float8',
proargtypes => 'text timestamp', prosrc => 'timestamp_part' },
-{ oid => '2023', descr => 'convert abstime to timestamp',
- proname => 'timestamp', provolatile => 's', prorettype => 'timestamp',
- proargtypes => 'abstime', prosrc => 'abstime_timestamp' },
{ oid => '2024', descr => 'convert date to timestamp',
proname => 'timestamp', prorettype => 'timestamp', proargtypes => 'date',
prosrc => 'date_timestamp' },
{ oid => '2029', descr => 'convert timestamp to date',
proname => 'date', prorettype => 'date', proargtypes => 'timestamp',
prosrc => 'timestamp_date' },
-{ oid => '2030', descr => 'convert timestamp to abstime',
- proname => 'abstime', provolatile => 's', prorettype => 'abstime',
- proargtypes => 'timestamp', prosrc => 'timestamp_abstime' },
{ oid => '2031',
proname => 'timestamp_mi', prorettype => 'interval',
proargtypes => 'timestamp timestamp', prosrc => 'timestamp_mi' },
{ oid => '2120', descr => 'maximum value of all float8 input values',
proname => 'max', prokind => 'a', proisstrict => 'f', prorettype => 'float8',
proargtypes => 'float8', prosrc => 'aggregate_dummy' },
-{ oid => '2121', descr => 'maximum value of all abstime input values',
- proname => 'max', prokind => 'a', proisstrict => 'f', prorettype => 'abstime',
- proargtypes => 'abstime', prosrc => 'aggregate_dummy' },
{ oid => '2122', descr => 'maximum value of all date input values',
proname => 'max', prokind => 'a', proisstrict => 'f', prorettype => 'date',
proargtypes => 'date', prosrc => 'aggregate_dummy' },
{ oid => '2136', descr => 'minimum value of all float8 input values',
proname => 'min', prokind => 'a', proisstrict => 'f', prorettype => 'float8',
proargtypes => 'float8', prosrc => 'aggregate_dummy' },
-{ oid => '2137', descr => 'minimum value of all abstime input values',
- proname => 'min', prokind => 'a', proisstrict => 'f', prorettype => 'abstime',
- proargtypes => 'abstime', prosrc => 'aggregate_dummy' },
{ oid => '2138', descr => 'minimum value of all date input values',
proname => 'min', prokind => 'a', proisstrict => 'f', prorettype => 'date',
proargtypes => 'date', prosrc => 'aggregate_dummy' },
{ oid => '2461', descr => 'I/O',
proname => 'numeric_send', prorettype => 'bytea', proargtypes => 'numeric',
prosrc => 'numeric_send' },
-{ oid => '2462', descr => 'I/O',
- proname => 'abstimerecv', prorettype => 'abstime', proargtypes => 'internal',
- prosrc => 'abstimerecv' },
-{ oid => '2463', descr => 'I/O',
- proname => 'abstimesend', prorettype => 'bytea', proargtypes => 'abstime',
- prosrc => 'abstimesend' },
-{ oid => '2464', descr => 'I/O',
- proname => 'reltimerecv', prorettype => 'reltime', proargtypes => 'internal',
- prosrc => 'reltimerecv' },
-{ oid => '2465', descr => 'I/O',
- proname => 'reltimesend', prorettype => 'bytea', proargtypes => 'reltime',
- prosrc => 'reltimesend' },
-{ oid => '2466', descr => 'I/O',
- proname => 'tintervalrecv', prorettype => 'tinterval',
- proargtypes => 'internal', prosrc => 'tintervalrecv' },
-{ oid => '2467', descr => 'I/O',
- proname => 'tintervalsend', prorettype => 'bytea', proargtypes => 'tinterval',
- prosrc => 'tintervalsend' },
{ oid => '2468', descr => 'I/O',
proname => 'date_recv', prorettype => 'date', proargtypes => 'internal',
prosrc => 'date_recv' },
typcategory => 'N', typispreferred => 't', typinput => 'float8in',
typoutput => 'float8out', typreceive => 'float8recv', typsend => 'float8send',
typalign => 'd' },
-{ oid => '702', array_type_oid => '1023',
- descr => 'absolute, limited-range date and time (Unix system time)',
- typname => 'abstime', typlen => '4', typbyval => 't', typcategory => 'D',
- typinput => 'abstimein', typoutput => 'abstimeout',
- typreceive => 'abstimerecv', typsend => 'abstimesend', typalign => 'i' },
-{ oid => '703', array_type_oid => '1024',
- descr => 'relative, limited-range time interval (Unix delta time)',
- typname => 'reltime', typlen => '4', typbyval => 't', typcategory => 'T',
- typinput => 'reltimein', typoutput => 'reltimeout',
- typreceive => 'reltimerecv', typsend => 'reltimesend', typalign => 'i' },
-{ oid => '704', array_type_oid => '1025',
- descr => '(abstime,abstime), time interval',
- typname => 'tinterval', typlen => '12', typbyval => 'f', typcategory => 'T',
- typinput => 'tintervalin', typoutput => 'tintervalout',
- typreceive => 'tintervalrecv', typsend => 'tintervalsend', typalign => 'i' },
{ oid => '705', descr => 'pseudo-type representing an undetermined type',
typname => 'unknown', typlen => '-2', typbyval => 'f', typtype => 'p',
typcategory => 'X', typinput => 'unknownin', typoutput => 'unknownout',
* datetime.h
* Definitions for date/time support code.
* The support code is shared with other date data types,
- * including abstime, reltime, date, and time.
+ * including date, and time.
*
*
* Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
+++ /dev/null
-/*-------------------------------------------------------------------------
- *
- * nabstime.h
- * Definitions for the "new" abstime code.
- *
- *
- * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- * src/include/utils/nabstime.h
- *
- *-------------------------------------------------------------------------
- */
-#ifndef NABSTIME_H
-#define NABSTIME_H
-
-#include <limits.h>
-
-#include "fmgr.h"
-#include "pgtime.h"
-
-
-/* ----------------------------------------------------------------
- *
- * time types + support macros
- *
- * ----------------------------------------------------------------
- */
-
-/*
- * Although time_t generally is a long int on 64 bit systems, these two
- * types must be 4 bytes, because that's what pg_type.h assumes. They
- * should be yanked (long) before 2038 and be replaced by timestamp and
- * interval.
- */
-typedef int32 AbsoluteTime;
-typedef int32 RelativeTime;
-
-typedef struct
-{
- int32 status;
- AbsoluteTime data[2];
-} TimeIntervalData;
-
-typedef TimeIntervalData *TimeInterval;
-
-/*
- * Macros for fmgr-callable functions.
- */
-#define DatumGetAbsoluteTime(X) ((AbsoluteTime) DatumGetInt32(X))
-#define DatumGetRelativeTime(X) ((RelativeTime) DatumGetInt32(X))
-#define DatumGetTimeInterval(X) ((TimeInterval) DatumGetPointer(X))
-
-#define AbsoluteTimeGetDatum(X) Int32GetDatum(X)
-#define RelativeTimeGetDatum(X) Int32GetDatum(X)
-#define TimeIntervalGetDatum(X) PointerGetDatum(X)
-
-#define PG_GETARG_ABSOLUTETIME(n) DatumGetAbsoluteTime(PG_GETARG_DATUM(n))
-#define PG_GETARG_RELATIVETIME(n) DatumGetRelativeTime(PG_GETARG_DATUM(n))
-#define PG_GETARG_TIMEINTERVAL(n) DatumGetTimeInterval(PG_GETARG_DATUM(n))
-
-#define PG_RETURN_ABSOLUTETIME(x) return AbsoluteTimeGetDatum(x)
-#define PG_RETURN_RELATIVETIME(x) return RelativeTimeGetDatum(x)
-#define PG_RETURN_TIMEINTERVAL(x) return TimeIntervalGetDatum(x)
-
-/*
- * Reserved values
- * Epoch is Unix system time zero, but needs to be kept as a reserved
- * value rather than converting to time since timezone calculations
- * might move it away from 1970-01-01 00:00:00Z - tgl 97/02/20
- *
- * Pre-v6.1 code had large decimal numbers for reserved values.
- * These were chosen as special 32-bit bit patterns,
- * so redefine them explicitly using these bit patterns. - tgl 97/02/24
- */
-#define INVALID_ABSTIME ((AbsoluteTime) 0x7FFFFFFE) /* 2147483647 (2^31 - 1) */
-#define NOEND_ABSTIME ((AbsoluteTime) 0x7FFFFFFC) /* 2147483645 (2^31 - 3) */
-#define NOSTART_ABSTIME ((AbsoluteTime) INT_MIN) /* -2147483648 */
-
-#define INVALID_RELTIME ((RelativeTime) 0x7FFFFFFE) /* 2147483647 (2^31 - 1) */
-
-#define AbsoluteTimeIsValid(time) \
- ((bool) ((time) != INVALID_ABSTIME))
-
-/*
- * Because NOSTART_ABSTIME is defined as INT_MIN, there can't be any
- * AbsoluteTime values less than it. Therefore, we can code the test
- * "time > NOSTART_ABSTIME" as "time != NOSTART_ABSTIME", which avoids
- * compiler bugs on some platforms. --- tgl & az, 11/2000
- */
-#define AbsoluteTimeIsReal(time) \
- ((bool) (((AbsoluteTime) (time)) < NOEND_ABSTIME && \
- ((AbsoluteTime) (time)) != NOSTART_ABSTIME))
-
-#define RelativeTimeIsValid(time) \
- ((bool) (((RelativeTime) (time)) != INVALID_RELTIME))
-
-
-/* non-fmgr-callable support routines */
-extern AbsoluteTime GetCurrentAbsoluteTime(void);
-extern void abstime2tm(AbsoluteTime time, int *tzp, struct pg_tm *tm, char **tzn);
-
-#endif /* NABSTIME_H */
return ECPG_ARRAY_ERROR;
if (!ecpg_type_infocache_push(&(stmt->connection->cache_head), FLOAT8OID, ECPG_ARRAY_NONE, stmt->lineno))
return ECPG_ARRAY_ERROR;
- if (!ecpg_type_infocache_push(&(stmt->connection->cache_head), ABSTIMEOID, ECPG_ARRAY_NONE, stmt->lineno))
- return ECPG_ARRAY_ERROR;
- if (!ecpg_type_infocache_push(&(stmt->connection->cache_head), RELTIMEOID, ECPG_ARRAY_NONE, stmt->lineno))
- return ECPG_ARRAY_ERROR;
- if (!ecpg_type_infocache_push(&(stmt->connection->cache_head), TINTERVALOID, ECPG_ARRAY_NONE, stmt->lineno))
- return ECPG_ARRAY_ERROR;
if (!ecpg_type_infocache_push(&(stmt->connection->cache_head), UNKNOWNOID, ECPG_ARRAY_NONE, stmt->lineno))
return ECPG_ARRAY_ERROR;
if (!ecpg_type_infocache_push(&(stmt->connection->cache_head), CIRCLEOID, ECPG_ARRAY_NONE, stmt->lineno))
+++ /dev/null
---
--- ABSTIME
--- testing built-in time type abstime
--- uses reltime and tinterval
---
---
--- timezones may vary based not only on location but the operating
--- system. the main correctness issue is that the OS may not get
--- daylight savings time right for times prior to Unix epoch (jan 1 1970).
---
-CREATE TABLE ABSTIME_TBL (f1 abstime);
-BEGIN;
-INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'now');
-INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'now');
-SELECT count(*) AS two FROM ABSTIME_TBL WHERE f1 = 'now' ;
- two
------
- 2
-(1 row)
-
-END;
-DELETE FROM ABSTIME_TBL;
-INSERT INTO ABSTIME_TBL (f1) VALUES ('Jan 14, 1973 03:14:21');
-INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'Mon May 1 00:30:30 1995');
-INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'epoch');
-INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'infinity');
-INSERT INTO ABSTIME_TBL (f1) VALUES (abstime '-infinity');
-INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'May 10, 1947 23:59:12');
--- what happens if we specify slightly misformatted abstime?
-INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 35, 1946 10:00:00');
-ERROR: date/time field value out of range: "Feb 35, 1946 10:00:00"
-LINE 1: INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 35, 1946 10:00:00'...
- ^
-HINT: Perhaps you need a different "datestyle" setting.
-INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 28, 1984 25:08:10');
-ERROR: date/time field value out of range: "Feb 28, 1984 25:08:10"
-LINE 1: INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 28, 1984 25:08:10'...
- ^
--- badly formatted abstimes: these should result in invalid abstimes
-INSERT INTO ABSTIME_TBL (f1) VALUES ('bad date format');
-ERROR: invalid input syntax for type abstime: "bad date format"
-LINE 1: INSERT INTO ABSTIME_TBL (f1) VALUES ('bad date format');
- ^
-INSERT INTO ABSTIME_TBL (f1) VALUES ('Jun 10, 1843');
--- test abstime operators
-SELECT '' AS eight, * FROM ABSTIME_TBL;
- eight | f1
--------+------------------------------
- | Sun Jan 14 03:14:21 1973 PST
- | Mon May 01 00:30:30 1995 PDT
- | Wed Dec 31 16:00:00 1969 PST
- | infinity
- | -infinity
- | Sat May 10 23:59:12 1947 PST
- | invalid
-(7 rows)
-
-SELECT '' AS six, * FROM ABSTIME_TBL
- WHERE ABSTIME_TBL.f1 < abstime 'Jun 30, 2001';
- six | f1
------+------------------------------
- | Sun Jan 14 03:14:21 1973 PST
- | Mon May 01 00:30:30 1995 PDT
- | Wed Dec 31 16:00:00 1969 PST
- | -infinity
- | Sat May 10 23:59:12 1947 PST
-(5 rows)
-
-SELECT '' AS six, * FROM ABSTIME_TBL
- WHERE ABSTIME_TBL.f1 > abstime '-infinity';
- six | f1
------+------------------------------
- | Sun Jan 14 03:14:21 1973 PST
- | Mon May 01 00:30:30 1995 PDT
- | Wed Dec 31 16:00:00 1969 PST
- | infinity
- | Sat May 10 23:59:12 1947 PST
- | invalid
-(6 rows)
-
-SELECT '' AS six, * FROM ABSTIME_TBL
- WHERE abstime 'May 10, 1947 23:59:12' <> ABSTIME_TBL.f1;
- six | f1
------+------------------------------
- | Sun Jan 14 03:14:21 1973 PST
- | Mon May 01 00:30:30 1995 PDT
- | Wed Dec 31 16:00:00 1969 PST
- | infinity
- | -infinity
- | invalid
-(6 rows)
-
-SELECT '' AS three, * FROM ABSTIME_TBL
- WHERE abstime 'epoch' >= ABSTIME_TBL.f1;
- three | f1
--------+------------------------------
- | Wed Dec 31 16:00:00 1969 PST
- | -infinity
- | Sat May 10 23:59:12 1947 PST
-(3 rows)
-
-SELECT '' AS four, * FROM ABSTIME_TBL
- WHERE ABSTIME_TBL.f1 <= abstime 'Jan 14, 1973 03:14:21';
- four | f1
-------+------------------------------
- | Sun Jan 14 03:14:21 1973 PST
- | Wed Dec 31 16:00:00 1969 PST
- | -infinity
- | Sat May 10 23:59:12 1947 PST
-(4 rows)
-
-SELECT '' AS four, * FROM ABSTIME_TBL
- WHERE ABSTIME_TBL.f1 <?>
- tinterval '["Apr 1 1950 00:00:00" "Dec 30 1999 23:00:00"]';
- four | f1
-------+------------------------------
- | Sun Jan 14 03:14:21 1973 PST
- | Mon May 01 00:30:30 1995 PDT
- | Wed Dec 31 16:00:00 1969 PST
-(3 rows)
-
-SELECT '' AS four, f1 AS abstime,
- date_part('year', f1) AS year, date_part('month', f1) AS month,
- date_part('day',f1) AS day, date_part('hour', f1) AS hour,
- date_part('minute', f1) AS minute, date_part('second', f1) AS second
- FROM ABSTIME_TBL
- WHERE isfinite(f1)
- ORDER BY abstime;
- four | abstime | year | month | day | hour | minute | second
-------+------------------------------+------+-------+-----+------+--------+--------
- | Sat May 10 23:59:12 1947 PST | 1947 | 5 | 10 | 23 | 59 | 12
- | Wed Dec 31 16:00:00 1969 PST | 1969 | 12 | 31 | 16 | 0 | 0
- | Sun Jan 14 03:14:21 1973 PST | 1973 | 1 | 14 | 3 | 14 | 21
- | Mon May 01 00:30:30 1995 PDT | 1995 | 5 | 1 | 0 | 30 | 30
-(4 rows)
-
ALTER TABLE attmp ADD COLUMN e float4;
ALTER TABLE attmp ADD COLUMN f int2;
ALTER TABLE attmp ADD COLUMN g polygon;
-ALTER TABLE attmp ADD COLUMN h abstime;
ALTER TABLE attmp ADD COLUMN i char;
-ALTER TABLE attmp ADD COLUMN j abstime[];
ALTER TABLE attmp ADD COLUMN k int4;
ALTER TABLE attmp ADD COLUMN l tid;
ALTER TABLE attmp ADD COLUMN m xid;
ALTER TABLE attmp ADD COLUMN r lseg;
ALTER TABLE attmp ADD COLUMN s path;
ALTER TABLE attmp ADD COLUMN t box;
-ALTER TABLE attmp ADD COLUMN u tinterval;
ALTER TABLE attmp ADD COLUMN v timestamp;
ALTER TABLE attmp ADD COLUMN w interval;
ALTER TABLE attmp ADD COLUMN x float8[];
ALTER TABLE attmp ADD COLUMN y float4[];
ALTER TABLE attmp ADD COLUMN z int2[];
-INSERT INTO attmp (a, b, c, d, e, f, g, h, i, j, k, l, m, n, p, q, r, s, t, u,
+INSERT INTO attmp (a, b, c, d, e, f, g, i, k, l, m, n, p, q, r, s, t,
v, w, x, y, z)
VALUES (4, 'name', 'text', 4.1, 4.1, 2, '(4.1,4.1,3.1,3.1)',
- 'Mon May 1 00:30:30 1995', 'c', '{Mon May 1 00:30:30 1995, Monday Aug 24 14:43:07 1992, epoch}',
+ 'c',
314159, '(1,1)', '512',
'1 2 3 4 5 6 7 8', 'magnetic disk', '(1.1,1.1)', '(4.1,4.1,3.1,3.1)',
- '(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)', '["epoch" "infinity"]',
+ '(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)',
'epoch', '01:00:10', '{1.0,2.0,3.0,4.0}', '{1.0,2.0,3.0,4.0}', '{1,2,3,4}');
SELECT * FROM attmp;
- initial | a | b | c | d | e | f | g | h | i | j | k | l | m | n | p | q | r | s | t | u | v | w | x | y | z
----------+---+------+------+-----+-----+---+-----------------------+------------------------------+---+------------------------------------------------------------------------------------------------+--------+-------+-----+-----------------+---------------+-----------+-----------------------+-----------------------------+---------------------+---------------------------------------------+--------------------------+------------------+-----------+-----------+-----------
- | 4 | name | text | 4.1 | 4.1 | 2 | ((4.1,4.1),(3.1,3.1)) | Mon May 01 00:30:30 1995 PDT | c | {"Mon May 01 00:30:30 1995 PDT","Mon Aug 24 14:43:07 1992 PDT","Wed Dec 31 16:00:00 1969 PST"} | 314159 | (1,1) | 512 | 1 2 3 4 5 6 7 8 | magnetic disk | (1.1,1.1) | [(4.1,4.1),(3.1,3.1)] | ((0,2),(4.1,4.1),(3.1,3.1)) | (4.1,4.1),(3.1,3.1) | ["Wed Dec 31 16:00:00 1969 PST" "infinity"] | Thu Jan 01 00:00:00 1970 | @ 1 hour 10 secs | {1,2,3,4} | {1,2,3,4} | {1,2,3,4}
+ initial | a | b | c | d | e | f | g | i | k | l | m | n | p | q | r | s | t | v | w | x | y | z
+---------+---+------+------+-----+-----+---+-----------------------+---+--------+-------+-----+-----------------+---------------+-----------+-----------------------+-----------------------------+---------------------+--------------------------+------------------+-----------+-----------+-----------
+ | 4 | name | text | 4.1 | 4.1 | 2 | ((4.1,4.1),(3.1,3.1)) | c | 314159 | (1,1) | 512 | 1 2 3 4 5 6 7 8 | magnetic disk | (1.1,1.1) | [(4.1,4.1),(3.1,3.1)] | ((0,2),(4.1,4.1),(3.1,3.1)) | (4.1,4.1),(3.1,3.1) | Thu Jan 01 00:00:00 1970 | @ 1 hour 10 secs | {1,2,3,4} | {1,2,3,4} | {1,2,3,4}
(1 row)
DROP TABLE attmp;
ALTER TABLE attmp ADD COLUMN e float4;
ALTER TABLE attmp ADD COLUMN f int2;
ALTER TABLE attmp ADD COLUMN g polygon;
-ALTER TABLE attmp ADD COLUMN h abstime;
ALTER TABLE attmp ADD COLUMN i char;
-ALTER TABLE attmp ADD COLUMN j abstime[];
ALTER TABLE attmp ADD COLUMN k int4;
ALTER TABLE attmp ADD COLUMN l tid;
ALTER TABLE attmp ADD COLUMN m xid;
ALTER TABLE attmp ADD COLUMN r lseg;
ALTER TABLE attmp ADD COLUMN s path;
ALTER TABLE attmp ADD COLUMN t box;
-ALTER TABLE attmp ADD COLUMN u tinterval;
ALTER TABLE attmp ADD COLUMN v timestamp;
ALTER TABLE attmp ADD COLUMN w interval;
ALTER TABLE attmp ADD COLUMN x float8[];
ALTER TABLE attmp ADD COLUMN y float4[];
ALTER TABLE attmp ADD COLUMN z int2[];
-INSERT INTO attmp (a, b, c, d, e, f, g, h, i, j, k, l, m, n, p, q, r, s, t, u,
+INSERT INTO attmp (a, b, c, d, e, f, g, i, k, l, m, n, p, q, r, s, t,
v, w, x, y, z)
VALUES (4, 'name', 'text', 4.1, 4.1, 2, '(4.1,4.1,3.1,3.1)',
- 'Mon May 1 00:30:30 1995', 'c', '{Mon May 1 00:30:30 1995, Monday Aug 24 14:43:07 1992, epoch}',
+ 'c',
314159, '(1,1)', '512',
'1 2 3 4 5 6 7 8', 'magnetic disk', '(1.1,1.1)', '(4.1,4.1,3.1,3.1)',
- '(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)', '["epoch" "infinity"]',
+ '(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)',
'epoch', '01:00:10', '{1.0,2.0,3.0,4.0}', '{1.0,2.0,3.0,4.0}', '{1,2,3,4}');
SELECT * FROM attmp;
- initial | a | b | c | d | e | f | g | h | i | j | k | l | m | n | p | q | r | s | t | u | v | w | x | y | z
----------+---+------+------+-----+-----+---+-----------------------+------------------------------+---+------------------------------------------------------------------------------------------------+--------+-------+-----+-----------------+---------------+-----------+-----------------------+-----------------------------+---------------------+---------------------------------------------+--------------------------+------------------+-----------+-----------+-----------
- | 4 | name | text | 4.1 | 4.1 | 2 | ((4.1,4.1),(3.1,3.1)) | Mon May 01 00:30:30 1995 PDT | c | {"Mon May 01 00:30:30 1995 PDT","Mon Aug 24 14:43:07 1992 PDT","Wed Dec 31 16:00:00 1969 PST"} | 314159 | (1,1) | 512 | 1 2 3 4 5 6 7 8 | magnetic disk | (1.1,1.1) | [(4.1,4.1),(3.1,3.1)] | ((0,2),(4.1,4.1),(3.1,3.1)) | (4.1,4.1),(3.1,3.1) | ["Wed Dec 31 16:00:00 1969 PST" "infinity"] | Thu Jan 01 00:00:00 1970 | @ 1 hour 10 secs | {1,2,3,4} | {1,2,3,4} | {1,2,3,4}
+ initial | a | b | c | d | e | f | g | i | k | l | m | n | p | q | r | s | t | v | w | x | y | z
+---------+---+------+------+-----+-----+---+-----------------------+---+--------+-------+-----+-----------------+---------------+-----------+-----------------------+-----------------------------+---------------------+--------------------------+------------------+-----------+-----------+-----------
+ | 4 | name | text | 4.1 | 4.1 | 2 | ((4.1,4.1),(3.1,3.1)) | c | 314159 | (1,1) | 512 | 1 2 3 4 5 6 7 8 | magnetic disk | (1.1,1.1) | [(4.1,4.1),(3.1,3.1)] | ((0,2),(4.1,4.1),(3.1,3.1)) | (4.1,4.1),(3.1,3.1) | Thu Jan 01 00:00:00 1970 | @ 1 hour 10 secs | {1,2,3,4} | {1,2,3,4} | {1,2,3,4}
(1 row)
CREATE INDEX attmp_idx ON attmp (a, (d + e), b);
| Sat Sep 22 18:19:20 2001 PDT | Sat Sep 22 18:19:20 2001 PDT | @ 0
(256 rows)
---
--- abstime, reltime arithmetic
---
-SELECT '' AS ten, ABSTIME_TBL.f1 AS abstime, RELTIME_TBL.f1 AS reltime
- FROM ABSTIME_TBL, RELTIME_TBL
- WHERE (ABSTIME_TBL.f1 + RELTIME_TBL.f1) < abstime 'Jan 14 14:00:00 1971'
- ORDER BY abstime, reltime;
- ten | abstime | reltime
------+------------------------------+---------------
- | Sat May 10 23:59:12 1947 PST | @ 14 secs ago
- | Sat May 10 23:59:12 1947 PST | @ 1 min
- | Sat May 10 23:59:12 1947 PST | @ 5 hours
- | Sat May 10 23:59:12 1947 PST | @ 10 days
- | Sat May 10 23:59:12 1947 PST | @ 3 mons
- | Wed Dec 31 16:00:00 1969 PST | @ 14 secs ago
- | Wed Dec 31 16:00:00 1969 PST | @ 1 min
- | Wed Dec 31 16:00:00 1969 PST | @ 5 hours
- | Wed Dec 31 16:00:00 1969 PST | @ 10 days
- | Wed Dec 31 16:00:00 1969 PST | @ 3 mons
-(10 rows)
-
--- these four queries should return the same answer
--- the "infinity" and "-infinity" tuples in ABSTIME_TBL cannot be added and
--- therefore, should not show up in the results.
-SELECT '' AS three, * FROM ABSTIME_TBL
- WHERE (ABSTIME_TBL.f1 + reltime '@ 3 year') -- +3 years
- < abstime 'Jan 14 14:00:00 1977';
- three | f1
--------+------------------------------
- | Sun Jan 14 03:14:21 1973 PST
- | Wed Dec 31 16:00:00 1969 PST
- | Sat May 10 23:59:12 1947 PST
-(3 rows)
-
-SELECT '' AS three, * FROM ABSTIME_TBL
- WHERE (ABSTIME_TBL.f1 + reltime '@ 3 year ago') -- -3 years
- < abstime 'Jan 14 14:00:00 1971';
- three | f1
--------+------------------------------
- | Sun Jan 14 03:14:21 1973 PST
- | Wed Dec 31 16:00:00 1969 PST
- | Sat May 10 23:59:12 1947 PST
-(3 rows)
-
-SELECT '' AS three, * FROM ABSTIME_TBL
- WHERE (ABSTIME_TBL.f1 - reltime '@ 3 year') -- -(+3) years
- < abstime 'Jan 14 14:00:00 1971';
- three | f1
--------+------------------------------
- | Sun Jan 14 03:14:21 1973 PST
- | Wed Dec 31 16:00:00 1969 PST
- | Sat May 10 23:59:12 1947 PST
-(3 rows)
-
-SELECT '' AS three, * FROM ABSTIME_TBL
- WHERE (ABSTIME_TBL.f1 - reltime '@ 3 year ago') -- -(-3) years
- < abstime 'Jan 14 14:00:00 1977';
- three | f1
--------+------------------------------
- | Sun Jan 14 03:14:21 1973 PST
- | Wed Dec 31 16:00:00 1969 PST
- | Sat May 10 23:59:12 1947 PST
-(3 rows)
-
--
-- Conversions
--
| Sat Sep 22 18:19:20 2001 PDT | 09-22-2001
(16 rows)
-SELECT '' AS "16", f1 AS "timestamp", abstime(f1) AS abstime
- FROM TEMP_TIMESTAMP
- ORDER BY abstime;
- 16 | timestamp | abstime
-----+------------------------------+------------------------------
- | Thu Jan 01 00:00:00 1970 PST | Thu Jan 01 00:00:00 1970 PST
- | Wed Feb 28 17:32:01 1996 PST | Wed Feb 28 17:32:01 1996 PST
- | Thu Feb 29 17:32:01 1996 PST | Thu Feb 29 17:32:01 1996 PST
- | Fri Mar 01 17:32:01 1996 PST | Fri Mar 01 17:32:01 1996 PST
- | Mon Dec 30 17:32:01 1996 PST | Mon Dec 30 17:32:01 1996 PST
- | Tue Dec 31 17:32:01 1996 PST | Tue Dec 31 17:32:01 1996 PST
- | Fri Dec 31 17:32:01 1999 PST | Fri Dec 31 17:32:01 1999 PST
- | Sat Jan 01 17:32:01 2000 PST | Sat Jan 01 17:32:01 2000 PST
- | Wed Mar 15 02:14:05 2000 PST | Wed Mar 15 02:14:05 2000 PST
- | Wed Mar 15 03:14:04 2000 PST | Wed Mar 15 03:14:04 2000 PST
- | Wed Mar 15 08:14:01 2000 PST | Wed Mar 15 08:14:01 2000 PST
- | Wed Mar 15 12:14:03 2000 PST | Wed Mar 15 12:14:03 2000 PST
- | Wed Mar 15 13:14:02 2000 PST | Wed Mar 15 13:14:02 2000 PST
- | Sun Dec 31 17:32:01 2000 PST | Sun Dec 31 17:32:01 2000 PST
- | Mon Jan 01 17:32:01 2001 PST | Mon Jan 01 17:32:01 2001 PST
- | Sat Sep 22 18:19:20 2001 PDT | Sat Sep 22 18:19:20 2001 PDT
-(16 rows)
-
-SELECT '' AS four, f1 AS abstime, date(f1) AS date
- FROM ABSTIME_TBL
- WHERE isfinite(f1) AND f1 <> abstime 'now'
- ORDER BY date, abstime;
- four | abstime | date
-------+------------------------------+------------
- | Sat May 10 23:59:12 1947 PST | 05-10-1947
- | Wed Dec 31 16:00:00 1969 PST | 12-31-1969
- | Sun Jan 14 03:14:21 1973 PST | 01-14-1973
- | Mon May 01 00:30:30 1995 PDT | 05-01-1995
-(4 rows)
-
-SELECT '' AS two, d1 AS "timestamp", abstime(d1) AS abstime
- FROM TIMESTAMP_TBL WHERE NOT isfinite(d1);
- two | timestamp | abstime
------+-----------+-----------
- | -infinity | -infinity
- | infinity | infinity
-(2 rows)
-
-SELECT '' AS three, f1 as abstime, cast(f1 as timestamp) AS "timestamp"
- FROM ABSTIME_TBL WHERE NOT isfinite(f1);
-ERROR: cannot convert abstime "invalid" to timestamp
-SELECT '' AS ten, f1 AS interval, reltime(f1) AS reltime
- FROM INTERVAL_TBL;
- ten | interval | reltime
------+-------------------------------+-------------------------------
- | @ 1 min | @ 1 min
- | @ 5 hours | @ 5 hours
- | @ 10 days | @ 10 days
- | @ 34 years | @ 34 years
- | @ 3 mons | @ 3 mons
- | @ 14 secs ago | @ 14 secs ago
- | @ 1 day 2 hours 3 mins 4 secs | @ 1 day 2 hours 3 mins 4 secs
- | @ 6 years | @ 6 years
- | @ 5 mons | @ 5 mons
- | @ 5 mons 12 hours | @ 5 mons 12 hours
-(10 rows)
-
-SELECT '' AS six, f1 as reltime, CAST(f1 AS interval) AS interval
- FROM RELTIME_TBL;
- six | reltime | interval
------+---------------+---------------
- | @ 1 min | @ 1 min
- | @ 5 hours | @ 5 hours
- | @ 10 days | @ 10 days
- | @ 34 years | @ 34 years
- | @ 3 mons | @ 3 mons
- | @ 14 secs ago | @ 14 secs ago
-(6 rows)
-
DROP TABLE TEMP_TIMESTAMP;
--
-- Formats
| Mon Jan 01 17:32:01 2001
(65 rows)
-SELECT '' AS seven, f1 AS us_postgres FROM ABSTIME_TBL;
- seven | us_postgres
--------+------------------------------
- | Sun Jan 14 03:14:21 1973 PST
- | Mon May 01 00:30:30 1995 PDT
- | Wed Dec 31 16:00:00 1969 PST
- | infinity
- | -infinity
- | Sat May 10 23:59:12 1947 PST
- | invalid
-(7 rows)
-
SET DateStyle TO 'US,ISO';
SELECT '' AS "64", d1 AS us_iso FROM TIMESTAMP_TBL;
64 | us_iso
| 2001-01-01 17:32:01
(65 rows)
-SELECT '' AS seven, f1 AS us_iso FROM ABSTIME_TBL;
- seven | us_iso
--------+------------------------
- | 1973-01-14 03:14:21-08
- | 1995-05-01 00:30:30-07
- | 1969-12-31 16:00:00-08
- | infinity
- | -infinity
- | 1947-05-10 23:59:12-08
- | invalid
-(7 rows)
-
SET DateStyle TO 'US,SQL';
SHOW DateStyle;
DateStyle
| 01/01/2001 17:32:01
(65 rows)
-SELECT '' AS seven, f1 AS us_sql FROM ABSTIME_TBL;
- seven | us_sql
--------+-------------------------
- | 01/14/1973 03:14:21 PST
- | 05/01/1995 00:30:30 PDT
- | 12/31/1969 16:00:00 PST
- | infinity
- | -infinity
- | 05/10/1947 23:59:12 PST
- | invalid
-(7 rows)
-
SET DateStyle TO 'European,Postgres';
SHOW DateStyle;
DateStyle
| Thu 13 Jun 00:00:00 1957
(66 rows)
-SELECT '' AS seven, f1 AS european_postgres FROM ABSTIME_TBL;
- seven | european_postgres
--------+------------------------------
- | Sun 14 Jan 03:14:21 1973 PST
- | Mon 01 May 00:30:30 1995 PDT
- | Wed 31 Dec 16:00:00 1969 PST
- | infinity
- | -infinity
- | Sat 10 May 23:59:12 1947 PST
- | invalid
-(7 rows)
-
SET DateStyle TO 'European,ISO';
SHOW DateStyle;
DateStyle
| 1957-06-13 00:00:00
(66 rows)
-SELECT '' AS seven, f1 AS european_iso FROM ABSTIME_TBL;
- seven | european_iso
--------+------------------------
- | 1973-01-14 03:14:21-08
- | 1995-05-01 00:30:30-07
- | 1969-12-31 16:00:00-08
- | infinity
- | -infinity
- | 1947-05-10 23:59:12-08
- | invalid
-(7 rows)
-
SET DateStyle TO 'European,SQL';
SHOW DateStyle;
DateStyle
| 13/06/1957 00:00:00
(66 rows)
-SELECT '' AS seven, f1 AS european_sql FROM ABSTIME_TBL;
- seven | european_sql
--------+-------------------------
- | 14/01/1973 03:14:21 PST
- | 01/05/1995 00:30:30 PDT
- | 31/12/1969 16:00:00 PST
- | infinity
- | -infinity
- | 10/05/1947 23:59:12 PST
- | invalid
-(7 rows)
-
RESET DateStyle;
--
-- to_timestamp()
int42ge(integer,smallint)
oideq(oid,oid)
oidne(oid,oid)
-abstimeeq(abstime,abstime)
-abstimene(abstime,abstime)
-abstimelt(abstime,abstime)
-abstimegt(abstime,abstime)
-abstimele(abstime,abstime)
-abstimege(abstime,abstime)
-reltimeeq(reltime,reltime)
-reltimene(reltime,reltime)
-reltimelt(reltime,reltime)
-reltimegt(reltime,reltime)
-reltimele(reltime,reltime)
-reltimege(reltime,reltime)
-tintervalleneq(tinterval,reltime)
-tintervallenne(tinterval,reltime)
-tintervallenlt(tinterval,reltime)
-tintervallengt(tinterval,reltime)
-tintervallenle(tinterval,reltime)
-tintervallenge(tinterval,reltime)
float4eq(real,real)
float4ne(real,real)
float4lt(real,real)
btfloat4cmp(real,real)
btfloat8cmp(double precision,double precision)
btoidcmp(oid,oid)
-btabstimecmp(abstime,abstime)
btcharcmp("char","char")
btnamecmp(name,name)
cash_cmp(money,money)
-btreltimecmp(reltime,reltime)
-bttintervalcmp(tinterval,tinterval)
int8eq(bigint,bigint)
int8ne(bigint,bigint)
int8lt(bigint,bigint)
namene(name,name)
oidlt(oid,oid)
oidle(oid,oid)
-tintervaleq(tinterval,tinterval)
-tintervalne(tinterval,tinterval)
-tintervallt(tinterval,tinterval)
-tintervalgt(tinterval,tinterval)
-tintervalle(tinterval,tinterval)
-tintervalge(tinterval,tinterval)
macaddr_eq(macaddr,macaddr)
macaddr_lt(macaddr,macaddr)
macaddr_le(macaddr,macaddr)
!~* | ~*
!~~ | ~~
!~~* | ~~*
- #< | #>=
- #<= | #>
- #<> | #=
*< | *>=
*<= | *>
*<> | *=
<> | ~=
~<=~ | ~>~
~<~ | ~>=~
-(16 rows)
+(13 rows)
-- A mergejoinable or hashjoinable operator must be binary, must return
-- boolean, and must have a commutator (itself, unless it's a cross-type
-- Cross-check transfn against its entry in pg_proc.
-- NOTE: use physically_coercible here, not binary_coercible, because
--- max and min on abstime are implemented using int4larger/int4smaller.
SELECT a.aggfnoid::oid, p.proname, ptr.oid, ptr.proname
FROM pg_aggregate AS a, pg_proc AS p, pg_proc AS ptr
WHERE a.aggfnoid = p.oid AND
-- Check that all combine functions have signature
-- combine(transtype, transtype) returns transtype
-- NOTE: use physically_coercible here, not binary_coercible, because
--- max and min on abstime are implemented using int4larger/int4smaller.
SELECT a.aggfnoid, p.proname
FROM pg_aggregate as a, pg_proc as p
WHERE a.aggcombinefn = p.oid AND
+++ /dev/null
---
--- RELTIME
---
-CREATE TABLE RELTIME_TBL (f1 reltime);
-INSERT INTO RELTIME_TBL (f1) VALUES ('@ 1 minute');
-INSERT INTO RELTIME_TBL (f1) VALUES ('@ 5 hour');
-INSERT INTO RELTIME_TBL (f1) VALUES ('@ 10 day');
-INSERT INTO RELTIME_TBL (f1) VALUES ('@ 34 year');
-INSERT INTO RELTIME_TBL (f1) VALUES ('@ 3 months');
-INSERT INTO RELTIME_TBL (f1) VALUES ('@ 14 seconds ago');
--- badly formatted reltimes
-INSERT INTO RELTIME_TBL (f1) VALUES ('badly formatted reltime');
-ERROR: invalid input syntax for type reltime: "badly formatted reltime"
-LINE 1: INSERT INTO RELTIME_TBL (f1) VALUES ('badly formatted reltim...
- ^
-INSERT INTO RELTIME_TBL (f1) VALUES ('@ 30 eons ago');
-ERROR: invalid input syntax for type reltime: "@ 30 eons ago"
-LINE 1: INSERT INTO RELTIME_TBL (f1) VALUES ('@ 30 eons ago');
- ^
--- test reltime operators
-SELECT '' AS six, * FROM RELTIME_TBL;
- six | f1
------+---------------
- | @ 1 min
- | @ 5 hours
- | @ 10 days
- | @ 34 years
- | @ 3 mons
- | @ 14 secs ago
-(6 rows)
-
-SELECT '' AS five, * FROM RELTIME_TBL
- WHERE RELTIME_TBL.f1 <> reltime '@ 10 days';
- five | f1
-------+---------------
- | @ 1 min
- | @ 5 hours
- | @ 34 years
- | @ 3 mons
- | @ 14 secs ago
-(5 rows)
-
-SELECT '' AS three, * FROM RELTIME_TBL
- WHERE RELTIME_TBL.f1 <= reltime '@ 5 hours';
- three | f1
--------+---------------
- | @ 1 min
- | @ 5 hours
- | @ 14 secs ago
-(3 rows)
-
-SELECT '' AS three, * FROM RELTIME_TBL
- WHERE RELTIME_TBL.f1 < reltime '@ 1 day';
- three | f1
--------+---------------
- | @ 1 min
- | @ 5 hours
- | @ 14 secs ago
-(3 rows)
-
-SELECT '' AS one, * FROM RELTIME_TBL
- WHERE RELTIME_TBL.f1 = reltime '@ 34 years';
- one | f1
------+------------
- | @ 34 years
-(1 row)
-
-SELECT '' AS two, * FROM RELTIME_TBL
- WHERE RELTIME_TBL.f1 >= reltime '@ 1 month';
- two | f1
------+------------
- | @ 34 years
- | @ 3 mons
-(2 rows)
-
-SELECT '' AS five, * FROM RELTIME_TBL
- WHERE RELTIME_TBL.f1 > reltime '@ 3 seconds ago';
- five | f1
-------+------------
- | @ 1 min
- | @ 5 hours
- | @ 10 days
- | @ 34 years
- | @ 3 mons
-(5 rows)
-
-SELECT '' AS fifteen, r1.*, r2.*
- FROM RELTIME_TBL r1, RELTIME_TBL r2
- WHERE r1.f1 > r2.f1
- ORDER BY r1.f1, r2.f1;
- fifteen | f1 | f1
----------+------------+---------------
- | @ 1 min | @ 14 secs ago
- | @ 5 hours | @ 14 secs ago
- | @ 5 hours | @ 1 min
- | @ 10 days | @ 14 secs ago
- | @ 10 days | @ 1 min
- | @ 10 days | @ 5 hours
- | @ 3 mons | @ 14 secs ago
- | @ 3 mons | @ 1 min
- | @ 3 mons | @ 5 hours
- | @ 3 mons | @ 10 days
- | @ 34 years | @ 14 secs ago
- | @ 34 years | @ 1 min
- | @ 34 years | @ 5 hours
- | @ 34 years | @ 10 days
- | @ 34 years | @ 3 mons
-(15 rows)
-
pg_authid.rolreplication AS userepl,
pg_authid.rolbypassrls AS usebypassrls,
pg_authid.rolpassword AS passwd,
- (pg_authid.rolvaliduntil)::abstime AS valuntil,
+ pg_authid.rolvaliduntil AS valuntil,
s.setconfig AS useconfig
FROM (pg_authid
LEFT JOIN pg_db_role_setting s ON (((pg_authid.oid = s.setrole) AND (s.setdatabase = (0)::oid))))
ORDER BY relname;
a|f
a_star|f
-abstime_tbl|f
aggtest|f
array_index_op_test|t
array_op_test|f
radix_text_tbl|t
ramp|f
real_city|f
-reltime_tbl|f
road|t
shighway|t
slow_emp4000|f
timestamp_tbl|f
timestamptz_tbl|f
timetz_tbl|f
-tinterval_tbl|f
varchar_tbl|f
-- restore normal output mode
\a\t
+++ /dev/null
---
--- TINTERVAL
---
-CREATE TABLE TINTERVAL_TBL (f1 tinterval);
--- Should accept any abstime,
--- so do not bother with extensive testing of values
-INSERT INTO TINTERVAL_TBL (f1)
- VALUES ('["-infinity" "infinity"]');
-INSERT INTO TINTERVAL_TBL (f1)
- VALUES ('["May 10, 1947 23:59:12" "Jan 14, 1973 03:14:21"]');
-INSERT INTO TINTERVAL_TBL (f1)
- VALUES ('["Sep 4, 1983 23:59:12" "Oct 4, 1983 23:59:12"]');
-INSERT INTO TINTERVAL_TBL (f1)
- VALUES ('["epoch" "Mon May 1 00:30:30 1995"]');
-INSERT INTO TINTERVAL_TBL (f1)
- VALUES ('["Feb 15 1990 12:15:03" "2001-09-23 11:12:13"]');
--- badly formatted tintervals
-INSERT INTO TINTERVAL_TBL (f1)
- VALUES ('["bad time specifications" ""]');
-ERROR: invalid input syntax for type abstime: "bad time specifications"
-LINE 2: VALUES ('["bad time specifications" ""]');
- ^
-INSERT INTO TINTERVAL_TBL (f1)
- VALUES ('["" "infinity"]');
-ERROR: invalid input syntax for type abstime: ""
-LINE 2: VALUES ('["" "infinity"]');
- ^
--- test tinterval operators
-SELECT '' AS five, * FROM TINTERVAL_TBL;
- five | f1
-------+-----------------------------------------------------------------
- | ["-infinity" "infinity"]
- | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"]
- | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"]
- | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"]
- | ["Thu Feb 15 12:15:03 1990 PST" "Sun Sep 23 11:12:13 2001 PDT"]
-(5 rows)
-
--- length ==
-SELECT '' AS one, t.*
- FROM TINTERVAL_TBL t
- WHERE t.f1 #= '@ 1 months';
- one | f1
------+-----------------------------------------------------------------
- | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"]
-(1 row)
-
--- length <>
-SELECT '' AS three, t.*
- FROM TINTERVAL_TBL t
- WHERE t.f1 #<> '@ 1 months';
- three | f1
--------+-----------------------------------------------------------------
- | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"]
- | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"]
- | ["Thu Feb 15 12:15:03 1990 PST" "Sun Sep 23 11:12:13 2001 PDT"]
-(3 rows)
-
--- length <
-SELECT '' AS zero, t.*
- FROM TINTERVAL_TBL t
- WHERE t.f1 #< '@ 1 month';
- zero | f1
-------+----
-(0 rows)
-
--- length <=
-SELECT '' AS one, t.*
- FROM TINTERVAL_TBL t
- WHERE t.f1 #<= '@ 1 month';
- one | f1
------+-----------------------------------------------------------------
- | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"]
-(1 row)
-
--- length >
-SELECT '' AS three, t.*
- FROM TINTERVAL_TBL t
- WHERE t.f1 #> '@ 1 year';
- three | f1
--------+-----------------------------------------------------------------
- | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"]
- | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"]
- | ["Thu Feb 15 12:15:03 1990 PST" "Sun Sep 23 11:12:13 2001 PDT"]
-(3 rows)
-
--- length >=
-SELECT '' AS three, t.*
- FROM TINTERVAL_TBL t
- WHERE t.f1 #>= '@ 3 years';
- three | f1
--------+-----------------------------------------------------------------
- | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"]
- | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"]
- | ["Thu Feb 15 12:15:03 1990 PST" "Sun Sep 23 11:12:13 2001 PDT"]
-(3 rows)
-
--- overlaps
-SELECT '' AS three, t1.*
- FROM TINTERVAL_TBL t1
- WHERE t1.f1 &&
- tinterval '["Aug 15 14:23:19 1983" "Sep 16 14:23:19 1983"]';
- three | f1
--------+-----------------------------------------------------------------
- | ["-infinity" "infinity"]
- | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"]
- | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"]
-(3 rows)
-
-SELECT '' AS five, t1.f1, t2.f1
- FROM TINTERVAL_TBL t1, TINTERVAL_TBL t2
- WHERE t1.f1 && t2.f1 and
- t1.f1 = t2.f1
- ORDER BY t1.f1, t2.f1;
- five | f1 | f1
-------+-----------------------------------------------------------------+-----------------------------------------------------------------
- | ["-infinity" "infinity"] | ["-infinity" "infinity"]
- | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"] | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"]
- | ["Thu Feb 15 12:15:03 1990 PST" "Sun Sep 23 11:12:13 2001 PDT"] | ["Thu Feb 15 12:15:03 1990 PST" "Sun Sep 23 11:12:13 2001 PDT"]
- | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"] | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"]
- | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"] | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"]
-(5 rows)
-
-SELECT '' AS fourteen, t1.f1 AS interval1, t2.f1 AS interval2
- FROM TINTERVAL_TBL t1, TINTERVAL_TBL t2
- WHERE t1.f1 && t2.f1 and not t1.f1 = t2.f1
- ORDER BY interval1, interval2;
- fourteen | interval1 | interval2
-----------+-----------------------------------------------------------------+-----------------------------------------------------------------
- | ["-infinity" "infinity"] | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"]
- | ["-infinity" "infinity"] | ["Thu Feb 15 12:15:03 1990 PST" "Sun Sep 23 11:12:13 2001 PDT"]
- | ["-infinity" "infinity"] | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"]
- | ["-infinity" "infinity"] | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"]
- | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"] | ["-infinity" "infinity"]
- | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"] | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"]
- | ["Thu Feb 15 12:15:03 1990 PST" "Sun Sep 23 11:12:13 2001 PDT"] | ["-infinity" "infinity"]
- | ["Thu Feb 15 12:15:03 1990 PST" "Sun Sep 23 11:12:13 2001 PDT"] | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"]
- | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"] | ["-infinity" "infinity"]
- | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"] | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"]
- | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"] | ["Thu Feb 15 12:15:03 1990 PST" "Sun Sep 23 11:12:13 2001 PDT"]
- | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"] | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"]
- | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"] | ["-infinity" "infinity"]
- | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"] | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"]
-(14 rows)
-
--- contains
-SELECT '' AS five, t1.f1
- FROM TINTERVAL_TBL t1
- WHERE not t1.f1 <<
- tinterval '["Aug 15 14:23:19 1980" "Sep 16 14:23:19 1990"]'
- ORDER BY t1.f1;
- five | f1
-------+-----------------------------------------------------------------
- | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"]
- | ["Thu Feb 15 12:15:03 1990 PST" "Sun Sep 23 11:12:13 2001 PDT"]
- | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"]
-(3 rows)
-
--- make time interval
-SELECT '' AS three, t1.f1
- FROM TINTERVAL_TBL t1
- WHERE t1.f1 &&
- (abstime 'Aug 15 14:23:19 1983' <#>
- abstime 'Sep 16 14:23:19 1983')
- ORDER BY t1.f1;
- three | f1
--------+-----------------------------------------------------------------
- | ["-infinity" "infinity"]
- | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"]
- | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"]
-(3 rows)
-
# ----------
# The second group of parallel tests
# ----------
-test: point lseg line box path polygon circle date time timetz timestamp timestamptz interval abstime reltime tinterval inet macaddr macaddr8 tstypes
+test: point lseg line box path polygon circle date time timetz timestamp timestamptz interval inet macaddr macaddr8 tstypes
# ----------
# Another group of parallel tests
# geometry depends on point, lseg, box, path, polygon and circle
-# horology depends on interval, timetz, timestamp, timestamptz, reltime and abstime
+# horology depends on interval, timetz, timestamp, timestamptz
# ----------
test: geometry horology regex oidjoins type_sanity opr_sanity misc_sanity comments expressions
test: timestamp
test: timestamptz
test: interval
-test: abstime
-test: reltime
-test: tinterval
test: inet
test: macaddr
test: macaddr8
+++ /dev/null
---
--- ABSTIME
--- testing built-in time type abstime
--- uses reltime and tinterval
---
-
---
--- timezones may vary based not only on location but the operating
--- system. the main correctness issue is that the OS may not get
--- daylight savings time right for times prior to Unix epoch (jan 1 1970).
---
-
-CREATE TABLE ABSTIME_TBL (f1 abstime);
-
-BEGIN;
-INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'now');
-INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'now');
-SELECT count(*) AS two FROM ABSTIME_TBL WHERE f1 = 'now' ;
-END;
-
-DELETE FROM ABSTIME_TBL;
-
-INSERT INTO ABSTIME_TBL (f1) VALUES ('Jan 14, 1973 03:14:21');
-INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'Mon May 1 00:30:30 1995');
-INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'epoch');
-INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'infinity');
-INSERT INTO ABSTIME_TBL (f1) VALUES (abstime '-infinity');
-INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'May 10, 1947 23:59:12');
-
--- what happens if we specify slightly misformatted abstime?
-INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 35, 1946 10:00:00');
-INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 28, 1984 25:08:10');
-
--- badly formatted abstimes: these should result in invalid abstimes
-INSERT INTO ABSTIME_TBL (f1) VALUES ('bad date format');
-INSERT INTO ABSTIME_TBL (f1) VALUES ('Jun 10, 1843');
-
--- test abstime operators
-
-SELECT '' AS eight, * FROM ABSTIME_TBL;
-
-SELECT '' AS six, * FROM ABSTIME_TBL
- WHERE ABSTIME_TBL.f1 < abstime 'Jun 30, 2001';
-
-SELECT '' AS six, * FROM ABSTIME_TBL
- WHERE ABSTIME_TBL.f1 > abstime '-infinity';
-
-SELECT '' AS six, * FROM ABSTIME_TBL
- WHERE abstime 'May 10, 1947 23:59:12' <> ABSTIME_TBL.f1;
-
-SELECT '' AS three, * FROM ABSTIME_TBL
- WHERE abstime 'epoch' >= ABSTIME_TBL.f1;
-
-SELECT '' AS four, * FROM ABSTIME_TBL
- WHERE ABSTIME_TBL.f1 <= abstime 'Jan 14, 1973 03:14:21';
-
-SELECT '' AS four, * FROM ABSTIME_TBL
- WHERE ABSTIME_TBL.f1 <?>
- tinterval '["Apr 1 1950 00:00:00" "Dec 30 1999 23:00:00"]';
-
-SELECT '' AS four, f1 AS abstime,
- date_part('year', f1) AS year, date_part('month', f1) AS month,
- date_part('day',f1) AS day, date_part('hour', f1) AS hour,
- date_part('minute', f1) AS minute, date_part('second', f1) AS second
- FROM ABSTIME_TBL
- WHERE isfinite(f1)
- ORDER BY abstime;
ALTER TABLE attmp ADD COLUMN g polygon;
-ALTER TABLE attmp ADD COLUMN h abstime;
-
ALTER TABLE attmp ADD COLUMN i char;
-ALTER TABLE attmp ADD COLUMN j abstime[];
-
ALTER TABLE attmp ADD COLUMN k int4;
ALTER TABLE attmp ADD COLUMN l tid;
ALTER TABLE attmp ADD COLUMN t box;
-ALTER TABLE attmp ADD COLUMN u tinterval;
-
ALTER TABLE attmp ADD COLUMN v timestamp;
ALTER TABLE attmp ADD COLUMN w interval;
ALTER TABLE attmp ADD COLUMN z int2[];
-INSERT INTO attmp (a, b, c, d, e, f, g, h, i, j, k, l, m, n, p, q, r, s, t, u,
+INSERT INTO attmp (a, b, c, d, e, f, g, i, k, l, m, n, p, q, r, s, t,
v, w, x, y, z)
VALUES (4, 'name', 'text', 4.1, 4.1, 2, '(4.1,4.1,3.1,3.1)',
- 'Mon May 1 00:30:30 1995', 'c', '{Mon May 1 00:30:30 1995, Monday Aug 24 14:43:07 1992, epoch}',
+ 'c',
314159, '(1,1)', '512',
'1 2 3 4 5 6 7 8', 'magnetic disk', '(1.1,1.1)', '(4.1,4.1,3.1,3.1)',
- '(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)', '["epoch" "infinity"]',
+ '(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)',
'epoch', '01:00:10', '{1.0,2.0,3.0,4.0}', '{1.0,2.0,3.0,4.0}', '{1,2,3,4}');
SELECT * FROM attmp;
ALTER TABLE attmp ADD COLUMN g polygon;
-ALTER TABLE attmp ADD COLUMN h abstime;
-
ALTER TABLE attmp ADD COLUMN i char;
-ALTER TABLE attmp ADD COLUMN j abstime[];
-
ALTER TABLE attmp ADD COLUMN k int4;
ALTER TABLE attmp ADD COLUMN l tid;
ALTER TABLE attmp ADD COLUMN t box;
-ALTER TABLE attmp ADD COLUMN u tinterval;
-
ALTER TABLE attmp ADD COLUMN v timestamp;
ALTER TABLE attmp ADD COLUMN w interval;
ALTER TABLE attmp ADD COLUMN z int2[];
-INSERT INTO attmp (a, b, c, d, e, f, g, h, i, j, k, l, m, n, p, q, r, s, t, u,
+INSERT INTO attmp (a, b, c, d, e, f, g, i, k, l, m, n, p, q, r, s, t,
v, w, x, y, z)
VALUES (4, 'name', 'text', 4.1, 4.1, 2, '(4.1,4.1,3.1,3.1)',
- 'Mon May 1 00:30:30 1995', 'c', '{Mon May 1 00:30:30 1995, Monday Aug 24 14:43:07 1992, epoch}',
+ 'c',
314159, '(1,1)', '512',
'1 2 3 4 5 6 7 8', 'magnetic disk', '(1.1,1.1)', '(4.1,4.1,3.1,3.1)',
- '(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)', '["epoch" "infinity"]',
+ '(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)',
'epoch', '01:00:10', '{1.0,2.0,3.0,4.0}', '{1.0,2.0,3.0,4.0}', '{1,2,3,4}');
SELECT * FROM attmp;
FROM TEMP_TIMESTAMP d1, TEMP_TIMESTAMP d2
ORDER BY timestamp1, timestamp2, difference;
---
--- abstime, reltime arithmetic
---
-
-SELECT '' AS ten, ABSTIME_TBL.f1 AS abstime, RELTIME_TBL.f1 AS reltime
- FROM ABSTIME_TBL, RELTIME_TBL
- WHERE (ABSTIME_TBL.f1 + RELTIME_TBL.f1) < abstime 'Jan 14 14:00:00 1971'
- ORDER BY abstime, reltime;
-
--- these four queries should return the same answer
--- the "infinity" and "-infinity" tuples in ABSTIME_TBL cannot be added and
--- therefore, should not show up in the results.
-
-SELECT '' AS three, * FROM ABSTIME_TBL
- WHERE (ABSTIME_TBL.f1 + reltime '@ 3 year') -- +3 years
- < abstime 'Jan 14 14:00:00 1977';
-
-SELECT '' AS three, * FROM ABSTIME_TBL
- WHERE (ABSTIME_TBL.f1 + reltime '@ 3 year ago') -- -3 years
- < abstime 'Jan 14 14:00:00 1971';
-
-SELECT '' AS three, * FROM ABSTIME_TBL
- WHERE (ABSTIME_TBL.f1 - reltime '@ 3 year') -- -(+3) years
- < abstime 'Jan 14 14:00:00 1971';
-
-SELECT '' AS three, * FROM ABSTIME_TBL
- WHERE (ABSTIME_TBL.f1 - reltime '@ 3 year ago') -- -(-3) years
- < abstime 'Jan 14 14:00:00 1977';
-
--
-- Conversions
--
WHERE f1 <> timestamp 'now'
ORDER BY date, "timestamp";
-SELECT '' AS "16", f1 AS "timestamp", abstime(f1) AS abstime
- FROM TEMP_TIMESTAMP
- ORDER BY abstime;
-
-SELECT '' AS four, f1 AS abstime, date(f1) AS date
- FROM ABSTIME_TBL
- WHERE isfinite(f1) AND f1 <> abstime 'now'
- ORDER BY date, abstime;
-
-SELECT '' AS two, d1 AS "timestamp", abstime(d1) AS abstime
- FROM TIMESTAMP_TBL WHERE NOT isfinite(d1);
-
-SELECT '' AS three, f1 as abstime, cast(f1 as timestamp) AS "timestamp"
- FROM ABSTIME_TBL WHERE NOT isfinite(f1);
-
-SELECT '' AS ten, f1 AS interval, reltime(f1) AS reltime
- FROM INTERVAL_TBL;
-
-SELECT '' AS six, f1 as reltime, CAST(f1 AS interval) AS interval
- FROM RELTIME_TBL;
-
DROP TABLE TEMP_TIMESTAMP;
--
SELECT '' AS "64", d1 AS us_postgres FROM TIMESTAMP_TBL;
-SELECT '' AS seven, f1 AS us_postgres FROM ABSTIME_TBL;
-
SET DateStyle TO 'US,ISO';
SELECT '' AS "64", d1 AS us_iso FROM TIMESTAMP_TBL;
-SELECT '' AS seven, f1 AS us_iso FROM ABSTIME_TBL;
-
SET DateStyle TO 'US,SQL';
SHOW DateStyle;
SELECT '' AS "64", d1 AS us_sql FROM TIMESTAMP_TBL;
-SELECT '' AS seven, f1 AS us_sql FROM ABSTIME_TBL;
-
SET DateStyle TO 'European,Postgres';
SHOW DateStyle;
SELECT '' AS "65", d1 AS european_postgres FROM TIMESTAMP_TBL;
-SELECT '' AS seven, f1 AS european_postgres FROM ABSTIME_TBL;
-
SET DateStyle TO 'European,ISO';
SHOW DateStyle;
SELECT '' AS "65", d1 AS european_iso FROM TIMESTAMP_TBL;
-SELECT '' AS seven, f1 AS european_iso FROM ABSTIME_TBL;
-
SET DateStyle TO 'European,SQL';
SHOW DateStyle;
SELECT '' AS "65", d1 AS european_sql FROM TIMESTAMP_TBL;
-SELECT '' AS seven, f1 AS european_sql FROM ABSTIME_TBL;
-
RESET DateStyle;
--
-- Cross-check transfn against its entry in pg_proc.
-- NOTE: use physically_coercible here, not binary_coercible, because
--- max and min on abstime are implemented using int4larger/int4smaller.
SELECT a.aggfnoid::oid, p.proname, ptr.oid, ptr.proname
FROM pg_aggregate AS a, pg_proc AS p, pg_proc AS ptr
WHERE a.aggfnoid = p.oid AND
-- Check that all combine functions have signature
-- combine(transtype, transtype) returns transtype
-- NOTE: use physically_coercible here, not binary_coercible, because
--- max and min on abstime are implemented using int4larger/int4smaller.
SELECT a.aggfnoid, p.proname
FROM pg_aggregate as a, pg_proc as p
+++ /dev/null
---
--- RELTIME
---
-
-CREATE TABLE RELTIME_TBL (f1 reltime);
-
-INSERT INTO RELTIME_TBL (f1) VALUES ('@ 1 minute');
-
-INSERT INTO RELTIME_TBL (f1) VALUES ('@ 5 hour');
-
-INSERT INTO RELTIME_TBL (f1) VALUES ('@ 10 day');
-
-INSERT INTO RELTIME_TBL (f1) VALUES ('@ 34 year');
-
-INSERT INTO RELTIME_TBL (f1) VALUES ('@ 3 months');
-
-INSERT INTO RELTIME_TBL (f1) VALUES ('@ 14 seconds ago');
-
-
--- badly formatted reltimes
-INSERT INTO RELTIME_TBL (f1) VALUES ('badly formatted reltime');
-
-INSERT INTO RELTIME_TBL (f1) VALUES ('@ 30 eons ago');
-
--- test reltime operators
-
-SELECT '' AS six, * FROM RELTIME_TBL;
-
-SELECT '' AS five, * FROM RELTIME_TBL
- WHERE RELTIME_TBL.f1 <> reltime '@ 10 days';
-
-SELECT '' AS three, * FROM RELTIME_TBL
- WHERE RELTIME_TBL.f1 <= reltime '@ 5 hours';
-
-SELECT '' AS three, * FROM RELTIME_TBL
- WHERE RELTIME_TBL.f1 < reltime '@ 1 day';
-
-SELECT '' AS one, * FROM RELTIME_TBL
- WHERE RELTIME_TBL.f1 = reltime '@ 34 years';
-
-SELECT '' AS two, * FROM RELTIME_TBL
- WHERE RELTIME_TBL.f1 >= reltime '@ 1 month';
-
-SELECT '' AS five, * FROM RELTIME_TBL
- WHERE RELTIME_TBL.f1 > reltime '@ 3 seconds ago';
-
-SELECT '' AS fifteen, r1.*, r2.*
- FROM RELTIME_TBL r1, RELTIME_TBL r2
- WHERE r1.f1 > r2.f1
- ORDER BY r1.f1, r2.f1;
+++ /dev/null
---
--- TINTERVAL
---
-
-CREATE TABLE TINTERVAL_TBL (f1 tinterval);
-
--- Should accept any abstime,
--- so do not bother with extensive testing of values
-
-INSERT INTO TINTERVAL_TBL (f1)
- VALUES ('["-infinity" "infinity"]');
-
-INSERT INTO TINTERVAL_TBL (f1)
- VALUES ('["May 10, 1947 23:59:12" "Jan 14, 1973 03:14:21"]');
-
-INSERT INTO TINTERVAL_TBL (f1)
- VALUES ('["Sep 4, 1983 23:59:12" "Oct 4, 1983 23:59:12"]');
-
-INSERT INTO TINTERVAL_TBL (f1)
- VALUES ('["epoch" "Mon May 1 00:30:30 1995"]');
-
-INSERT INTO TINTERVAL_TBL (f1)
- VALUES ('["Feb 15 1990 12:15:03" "2001-09-23 11:12:13"]');
-
-
--- badly formatted tintervals
-INSERT INTO TINTERVAL_TBL (f1)
- VALUES ('["bad time specifications" ""]');
-
-INSERT INTO TINTERVAL_TBL (f1)
- VALUES ('["" "infinity"]');
-
--- test tinterval operators
-
-SELECT '' AS five, * FROM TINTERVAL_TBL;
-
--- length ==
-SELECT '' AS one, t.*
- FROM TINTERVAL_TBL t
- WHERE t.f1 #= '@ 1 months';
-
--- length <>
-SELECT '' AS three, t.*
- FROM TINTERVAL_TBL t
- WHERE t.f1 #<> '@ 1 months';
-
--- length <
-SELECT '' AS zero, t.*
- FROM TINTERVAL_TBL t
- WHERE t.f1 #< '@ 1 month';
-
--- length <=
-SELECT '' AS one, t.*
- FROM TINTERVAL_TBL t
- WHERE t.f1 #<= '@ 1 month';
-
--- length >
-SELECT '' AS three, t.*
- FROM TINTERVAL_TBL t
- WHERE t.f1 #> '@ 1 year';
-
--- length >=
-SELECT '' AS three, t.*
- FROM TINTERVAL_TBL t
- WHERE t.f1 #>= '@ 3 years';
-
--- overlaps
-SELECT '' AS three, t1.*
- FROM TINTERVAL_TBL t1
- WHERE t1.f1 &&
- tinterval '["Aug 15 14:23:19 1983" "Sep 16 14:23:19 1983"]';
-
-SELECT '' AS five, t1.f1, t2.f1
- FROM TINTERVAL_TBL t1, TINTERVAL_TBL t2
- WHERE t1.f1 && t2.f1 and
- t1.f1 = t2.f1
- ORDER BY t1.f1, t2.f1;
-
-SELECT '' AS fourteen, t1.f1 AS interval1, t2.f1 AS interval2
- FROM TINTERVAL_TBL t1, TINTERVAL_TBL t2
- WHERE t1.f1 && t2.f1 and not t1.f1 = t2.f1
- ORDER BY interval1, interval2;
-
--- contains
-SELECT '' AS five, t1.f1
- FROM TINTERVAL_TBL t1
- WHERE not t1.f1 <<
- tinterval '["Aug 15 14:23:19 1980" "Sep 16 14:23:19 1990"]'
- ORDER BY t1.f1;
-
--- make time interval
-SELECT '' AS three, t1.f1
- FROM TINTERVAL_TBL t1
- WHERE t1.f1 &&
- (abstime 'Aug 15 14:23:19 1983' <#>
- abstime 'Sep 16 14:23:19 1983')
- ORDER BY t1.f1;