Eneboo - Documentación para desarrolladores
src/libpq/include/utils/nabstime.h
Ir a la documentación de este archivo.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * nabstime.h
00004  *        Definitions for the "new" abstime code.
00005  *
00006  *
00007  * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
00008  * Portions Copyright (c) 1994, Regents of the University of California
00009  *
00010  * $PostgreSQL: pgsql/src/include/utils/nabstime.h,v 1.48 2005/10/15 02:49:46 momjian Exp $
00011  *
00012  *-------------------------------------------------------------------------
00013  */
00014 #ifndef NABSTIME_H
00015 #define NABSTIME_H
00016 
00017 #include <limits.h>
00018 
00019 #include "fmgr.h"
00020 #include "utils/timestamp.h"
00021 #include "utils/datetime.h"
00022 
00023 
00024 /* ----------------------------------------------------------------
00025  *
00026  *                              time types + support macros
00027  *
00028  * ----------------------------------------------------------------
00029  */
00030 
00031 /*
00032  * Although time_t generally is a long int on 64 bit systems, these two
00033  * types must be 4 bytes, because that's what pg_type.h assumes. They
00034  * should be yanked (long) before 2038 and be replaced by timestamp and
00035  * interval.
00036  */
00037 typedef int32 AbsoluteTime;
00038 typedef int32 RelativeTime;
00039 
00040 typedef struct
00041 {
00042         int32           status;
00043         AbsoluteTime data[2];
00044 } TimeIntervalData;
00045 
00046 typedef TimeIntervalData *TimeInterval;
00047 
00048 /*
00049  * Macros for fmgr-callable functions.
00050  */
00051 #define DatumGetAbsoluteTime(X)  ((AbsoluteTime) DatumGetInt32(X))
00052 #define DatumGetRelativeTime(X)  ((RelativeTime) DatumGetInt32(X))
00053 #define DatumGetTimeInterval(X)  ((TimeInterval) DatumGetPointer(X))
00054 
00055 #define AbsoluteTimeGetDatum(X)  Int32GetDatum(X)
00056 #define RelativeTimeGetDatum(X)  Int32GetDatum(X)
00057 #define TimeIntervalGetDatum(X)  PointerGetDatum(X)
00058 
00059 #define PG_GETARG_ABSOLUTETIME(n)  DatumGetAbsoluteTime(PG_GETARG_DATUM(n))
00060 #define PG_GETARG_RELATIVETIME(n)  DatumGetRelativeTime(PG_GETARG_DATUM(n))
00061 #define PG_GETARG_TIMEINTERVAL(n)  DatumGetTimeInterval(PG_GETARG_DATUM(n))
00062 
00063 #define PG_RETURN_ABSOLUTETIME(x)  return AbsoluteTimeGetDatum(x)
00064 #define PG_RETURN_RELATIVETIME(x)  return RelativeTimeGetDatum(x)
00065 #define PG_RETURN_TIMEINTERVAL(x)  return TimeIntervalGetDatum(x)
00066 
00067 /*
00068  * Reserved values
00069  * Epoch is Unix system time zero, but needs to be kept as a reserved
00070  *      value rather than converting to time since timezone calculations
00071  *      might move it away from 1970-01-01 00:00:00Z - tgl 97/02/20
00072  *
00073  * Pre-v6.1 code had large decimal numbers for reserved values.
00074  * These were chosen as special 32-bit bit patterns,
00075  *      so redefine them explicitly using these bit patterns. - tgl 97/02/24
00076  */
00077 #define INVALID_ABSTIME ((AbsoluteTime) 0x7FFFFFFE)             /* 2147483647 (2^31 - 1) */
00078 #define NOEND_ABSTIME   ((AbsoluteTime) 0x7FFFFFFC)             /* 2147483645 (2^31 - 3) */
00079 #define NOSTART_ABSTIME ((AbsoluteTime) INT_MIN)                /* -2147483648 */
00080 
00081 #define INVALID_RELTIME ((RelativeTime) 0x7FFFFFFE)             /* 2147483647 (2^31 - 1) */
00082 
00083 #define AbsoluteTimeIsValid(time) \
00084         ((bool) ((time) != INVALID_ABSTIME))
00085 
00086 /*
00087  * Because NOSTART_ABSTIME is defined as INT_MIN, there can't be any
00088  * AbsoluteTime values less than it.  Therefore, we can code the test
00089  * "time > NOSTART_ABSTIME" as "time != NOSTART_ABSTIME", which avoids
00090  * compiler bugs on some platforms.  --- tgl & az, 11/2000
00091  */
00092 #define AbsoluteTimeIsReal(time) \
00093         ((bool) (((AbsoluteTime) (time)) < NOEND_ABSTIME && \
00094                           ((AbsoluteTime) (time)) != NOSTART_ABSTIME))
00095 
00096 #define RelativeTimeIsValid(time) \
00097         ((bool) (((RelativeTime) (time)) != INVALID_RELTIME))
00098 
00099 
00100 /*
00101  * nabstime.c prototypes
00102  */
00103 extern Datum abstimein(PG_FUNCTION_ARGS);
00104 extern Datum abstimeout(PG_FUNCTION_ARGS);
00105 extern Datum abstimerecv(PG_FUNCTION_ARGS);
00106 extern Datum abstimesend(PG_FUNCTION_ARGS);
00107 
00108 extern Datum abstimeeq(PG_FUNCTION_ARGS);
00109 extern Datum abstimene(PG_FUNCTION_ARGS);
00110 extern Datum abstimelt(PG_FUNCTION_ARGS);
00111 extern Datum abstimegt(PG_FUNCTION_ARGS);
00112 extern Datum abstimele(PG_FUNCTION_ARGS);
00113 extern Datum abstimege(PG_FUNCTION_ARGS);
00114 extern Datum abstime_finite(PG_FUNCTION_ARGS);
00115 
00116 extern Datum timestamp_abstime(PG_FUNCTION_ARGS);
00117 extern Datum abstime_timestamp(PG_FUNCTION_ARGS);
00118 extern Datum timestamptz_abstime(PG_FUNCTION_ARGS);
00119 extern Datum abstime_timestamptz(PG_FUNCTION_ARGS);
00120 
00121 extern Datum reltimein(PG_FUNCTION_ARGS);
00122 extern Datum reltimeout(PG_FUNCTION_ARGS);
00123 extern Datum reltimerecv(PG_FUNCTION_ARGS);
00124 extern Datum reltimesend(PG_FUNCTION_ARGS);
00125 extern Datum tintervalin(PG_FUNCTION_ARGS);
00126 extern Datum tintervalout(PG_FUNCTION_ARGS);
00127 extern Datum tintervalrecv(PG_FUNCTION_ARGS);
00128 extern Datum tintervalsend(PG_FUNCTION_ARGS);
00129 extern Datum interval_reltime(PG_FUNCTION_ARGS);
00130 extern Datum reltime_interval(PG_FUNCTION_ARGS);
00131 extern Datum mktinterval(PG_FUNCTION_ARGS);
00132 extern Datum timepl(PG_FUNCTION_ARGS);
00133 extern Datum timemi(PG_FUNCTION_ARGS);
00134 
00135 extern Datum intinterval(PG_FUNCTION_ARGS);
00136 extern Datum tintervalrel(PG_FUNCTION_ARGS);
00137 extern Datum timenow(PG_FUNCTION_ARGS);
00138 extern Datum reltimeeq(PG_FUNCTION_ARGS);
00139 extern Datum reltimene(PG_FUNCTION_ARGS);
00140 extern Datum reltimelt(PG_FUNCTION_ARGS);
00141 extern Datum reltimegt(PG_FUNCTION_ARGS);
00142 extern Datum reltimele(PG_FUNCTION_ARGS);
00143 extern Datum reltimege(PG_FUNCTION_ARGS);
00144 extern Datum tintervalsame(PG_FUNCTION_ARGS);
00145 extern Datum tintervaleq(PG_FUNCTION_ARGS);
00146 extern Datum tintervalne(PG_FUNCTION_ARGS);
00147 extern Datum tintervallt(PG_FUNCTION_ARGS);
00148 extern Datum tintervalgt(PG_FUNCTION_ARGS);
00149 extern Datum tintervalle(PG_FUNCTION_ARGS);
00150 extern Datum tintervalge(PG_FUNCTION_ARGS);
00151 extern Datum tintervalleneq(PG_FUNCTION_ARGS);
00152 extern Datum tintervallenne(PG_FUNCTION_ARGS);
00153 extern Datum tintervallenlt(PG_FUNCTION_ARGS);
00154 extern Datum tintervallengt(PG_FUNCTION_ARGS);
00155 extern Datum tintervallenle(PG_FUNCTION_ARGS);
00156 extern Datum tintervallenge(PG_FUNCTION_ARGS);
00157 extern Datum tintervalct(PG_FUNCTION_ARGS);
00158 extern Datum tintervalov(PG_FUNCTION_ARGS);
00159 extern Datum tintervalstart(PG_FUNCTION_ARGS);
00160 extern Datum tintervalend(PG_FUNCTION_ARGS);
00161 extern Datum timeofday(PG_FUNCTION_ARGS);
00162 
00163 /* non-fmgr-callable support routines */
00164 extern AbsoluteTime GetCurrentAbsoluteTime(void);
00165 extern void abstime2tm(AbsoluteTime time, int *tzp, struct pg_tm * tm, char **tzn);
00166 
00167 #endif   /* NABSTIME_H */
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'