Eneboo - Documentación para desarrolladores
|
00001 /*------------------------------------------------------------------------- 00002 * 00003 * date.h 00004 * Definitions for the SQL92 "date" and "time" types. 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/date.h,v 1.32 2005/10/15 02:49:46 momjian Exp $ 00011 * 00012 *------------------------------------------------------------------------- 00013 */ 00014 #ifndef DATE_H 00015 #define DATE_H 00016 00017 #include "fmgr.h" 00018 00019 00020 typedef int32 DateADT; 00021 00022 #ifdef HAVE_INT64_TIMESTAMP 00023 typedef int64 TimeADT; 00024 #else 00025 typedef float8 TimeADT; 00026 #endif 00027 00028 typedef struct 00029 { 00030 #ifdef HAVE_INT64_TIMESTAMP 00031 int64 time; /* all time units other than months and years */ 00032 #else 00033 double time; /* all time units other than months and years */ 00034 #endif 00035 int32 zone; /* numeric time zone, in seconds */ 00036 } TimeTzADT; 00037 00038 /* 00039 * Macros for fmgr-callable functions. 00040 * 00041 * For TimeADT, we make use of the same support routines as for float8 or int64. 00042 * Therefore TimeADT is pass-by-reference if and only if float8 or int64 is! 00043 */ 00044 #ifdef HAVE_INT64_TIMESTAMP 00045 00046 #define MAX_TIME_PRECISION 6 00047 00048 #define DatumGetDateADT(X) ((DateADT) DatumGetInt32(X)) 00049 #define DatumGetTimeADT(X) ((TimeADT) DatumGetInt64(X)) 00050 #define DatumGetTimeTzADTP(X) ((TimeTzADT *) DatumGetPointer(X)) 00051 00052 #define DateADTGetDatum(X) Int32GetDatum(X) 00053 #define TimeADTGetDatum(X) Int64GetDatum(X) 00054 #define TimeTzADTPGetDatum(X) PointerGetDatum(X) 00055 #else 00056 00057 #define MAX_TIME_PRECISION 10 00058 00059 /* round off to MAX_TIME_PRECISION decimal places */ 00060 #define TIME_PREC_INV 10000000000.0 00061 #define TIMEROUND(j) (rint(((double) (j)) * TIME_PREC_INV) / TIME_PREC_INV) 00062 00063 #define DatumGetDateADT(X) ((DateADT) DatumGetInt32(X)) 00064 #define DatumGetTimeADT(X) ((TimeADT) DatumGetFloat8(X)) 00065 #define DatumGetTimeTzADTP(X) ((TimeTzADT *) DatumGetPointer(X)) 00066 00067 #define DateADTGetDatum(X) Int32GetDatum(X) 00068 #define TimeADTGetDatum(X) Float8GetDatum(X) 00069 #define TimeTzADTPGetDatum(X) PointerGetDatum(X) 00070 #endif /* HAVE_INT64_TIMESTAMP */ 00071 00072 #define PG_GETARG_DATEADT(n) DatumGetDateADT(PG_GETARG_DATUM(n)) 00073 #define PG_GETARG_TIMEADT(n) DatumGetTimeADT(PG_GETARG_DATUM(n)) 00074 #define PG_GETARG_TIMETZADT_P(n) DatumGetTimeTzADTP(PG_GETARG_DATUM(n)) 00075 00076 #define PG_RETURN_DATEADT(x) return DateADTGetDatum(x) 00077 #define PG_RETURN_TIMEADT(x) return TimeADTGetDatum(x) 00078 #define PG_RETURN_TIMETZADT_P(x) return TimeTzADTPGetDatum(x) 00079 00080 00081 /* date.c */ 00082 extern Datum date_in(PG_FUNCTION_ARGS); 00083 extern Datum date_out(PG_FUNCTION_ARGS); 00084 extern Datum date_recv(PG_FUNCTION_ARGS); 00085 extern Datum date_send(PG_FUNCTION_ARGS); 00086 extern Datum date_eq(PG_FUNCTION_ARGS); 00087 extern Datum date_ne(PG_FUNCTION_ARGS); 00088 extern Datum date_lt(PG_FUNCTION_ARGS); 00089 extern Datum date_le(PG_FUNCTION_ARGS); 00090 extern Datum date_gt(PG_FUNCTION_ARGS); 00091 extern Datum date_ge(PG_FUNCTION_ARGS); 00092 extern Datum date_cmp(PG_FUNCTION_ARGS); 00093 extern Datum date_larger(PG_FUNCTION_ARGS); 00094 extern Datum date_smaller(PG_FUNCTION_ARGS); 00095 extern Datum date_mi(PG_FUNCTION_ARGS); 00096 extern Datum date_pli(PG_FUNCTION_ARGS); 00097 extern Datum date_mii(PG_FUNCTION_ARGS); 00098 extern Datum date_eq_timestamp(PG_FUNCTION_ARGS); 00099 extern Datum date_ne_timestamp(PG_FUNCTION_ARGS); 00100 extern Datum date_lt_timestamp(PG_FUNCTION_ARGS); 00101 extern Datum date_le_timestamp(PG_FUNCTION_ARGS); 00102 extern Datum date_gt_timestamp(PG_FUNCTION_ARGS); 00103 extern Datum date_ge_timestamp(PG_FUNCTION_ARGS); 00104 extern Datum date_cmp_timestamp(PG_FUNCTION_ARGS); 00105 extern Datum date_eq_timestamptz(PG_FUNCTION_ARGS); 00106 extern Datum date_ne_timestamptz(PG_FUNCTION_ARGS); 00107 extern Datum date_lt_timestamptz(PG_FUNCTION_ARGS); 00108 extern Datum date_le_timestamptz(PG_FUNCTION_ARGS); 00109 extern Datum date_gt_timestamptz(PG_FUNCTION_ARGS); 00110 extern Datum date_ge_timestamptz(PG_FUNCTION_ARGS); 00111 extern Datum date_cmp_timestamptz(PG_FUNCTION_ARGS); 00112 extern Datum timestamp_eq_date(PG_FUNCTION_ARGS); 00113 extern Datum timestamp_ne_date(PG_FUNCTION_ARGS); 00114 extern Datum timestamp_lt_date(PG_FUNCTION_ARGS); 00115 extern Datum timestamp_le_date(PG_FUNCTION_ARGS); 00116 extern Datum timestamp_gt_date(PG_FUNCTION_ARGS); 00117 extern Datum timestamp_ge_date(PG_FUNCTION_ARGS); 00118 extern Datum timestamp_cmp_date(PG_FUNCTION_ARGS); 00119 extern Datum timestamptz_eq_date(PG_FUNCTION_ARGS); 00120 extern Datum timestamptz_ne_date(PG_FUNCTION_ARGS); 00121 extern Datum timestamptz_lt_date(PG_FUNCTION_ARGS); 00122 extern Datum timestamptz_le_date(PG_FUNCTION_ARGS); 00123 extern Datum timestamptz_gt_date(PG_FUNCTION_ARGS); 00124 extern Datum timestamptz_ge_date(PG_FUNCTION_ARGS); 00125 extern Datum timestamptz_cmp_date(PG_FUNCTION_ARGS); 00126 extern Datum date_pl_interval(PG_FUNCTION_ARGS); 00127 extern Datum date_mi_interval(PG_FUNCTION_ARGS); 00128 extern Datum date_timestamp(PG_FUNCTION_ARGS); 00129 extern Datum timestamp_date(PG_FUNCTION_ARGS); 00130 extern Datum date_timestamptz(PG_FUNCTION_ARGS); 00131 extern Datum timestamptz_date(PG_FUNCTION_ARGS); 00132 extern Datum datetime_timestamp(PG_FUNCTION_ARGS); 00133 extern Datum abstime_date(PG_FUNCTION_ARGS); 00134 extern Datum text_date(PG_FUNCTION_ARGS); 00135 extern Datum date_text(PG_FUNCTION_ARGS); 00136 00137 extern Datum time_in(PG_FUNCTION_ARGS); 00138 extern Datum time_out(PG_FUNCTION_ARGS); 00139 extern Datum time_recv(PG_FUNCTION_ARGS); 00140 extern Datum time_send(PG_FUNCTION_ARGS); 00141 extern Datum time_scale(PG_FUNCTION_ARGS); 00142 extern Datum time_eq(PG_FUNCTION_ARGS); 00143 extern Datum time_ne(PG_FUNCTION_ARGS); 00144 extern Datum time_lt(PG_FUNCTION_ARGS); 00145 extern Datum time_le(PG_FUNCTION_ARGS); 00146 extern Datum time_gt(PG_FUNCTION_ARGS); 00147 extern Datum time_ge(PG_FUNCTION_ARGS); 00148 extern Datum time_cmp(PG_FUNCTION_ARGS); 00149 extern Datum overlaps_time(PG_FUNCTION_ARGS); 00150 extern Datum time_larger(PG_FUNCTION_ARGS); 00151 extern Datum time_smaller(PG_FUNCTION_ARGS); 00152 extern Datum time_mi_time(PG_FUNCTION_ARGS); 00153 extern Datum timestamp_time(PG_FUNCTION_ARGS); 00154 extern Datum timestamptz_time(PG_FUNCTION_ARGS); 00155 extern Datum time_interval(PG_FUNCTION_ARGS); 00156 extern Datum interval_time(PG_FUNCTION_ARGS); 00157 extern Datum text_time(PG_FUNCTION_ARGS); 00158 extern Datum time_text(PG_FUNCTION_ARGS); 00159 extern Datum time_pl_interval(PG_FUNCTION_ARGS); 00160 extern Datum time_mi_interval(PG_FUNCTION_ARGS); 00161 extern Datum time_part(PG_FUNCTION_ARGS); 00162 00163 extern Datum timetz_in(PG_FUNCTION_ARGS); 00164 extern Datum timetz_out(PG_FUNCTION_ARGS); 00165 extern Datum timetz_recv(PG_FUNCTION_ARGS); 00166 extern Datum timetz_send(PG_FUNCTION_ARGS); 00167 extern Datum timetz_scale(PG_FUNCTION_ARGS); 00168 extern Datum timetz_eq(PG_FUNCTION_ARGS); 00169 extern Datum timetz_ne(PG_FUNCTION_ARGS); 00170 extern Datum timetz_lt(PG_FUNCTION_ARGS); 00171 extern Datum timetz_le(PG_FUNCTION_ARGS); 00172 extern Datum timetz_gt(PG_FUNCTION_ARGS); 00173 extern Datum timetz_ge(PG_FUNCTION_ARGS); 00174 extern Datum timetz_cmp(PG_FUNCTION_ARGS); 00175 extern Datum timetz_hash(PG_FUNCTION_ARGS); 00176 extern Datum overlaps_timetz(PG_FUNCTION_ARGS); 00177 extern Datum timetz_larger(PG_FUNCTION_ARGS); 00178 extern Datum timetz_smaller(PG_FUNCTION_ARGS); 00179 extern Datum timetz_time(PG_FUNCTION_ARGS); 00180 extern Datum time_timetz(PG_FUNCTION_ARGS); 00181 extern Datum timestamptz_timetz(PG_FUNCTION_ARGS); 00182 extern Datum datetimetz_timestamptz(PG_FUNCTION_ARGS); 00183 extern Datum text_timetz(PG_FUNCTION_ARGS); 00184 extern Datum timetz_text(PG_FUNCTION_ARGS); 00185 extern Datum timetz_part(PG_FUNCTION_ARGS); 00186 extern Datum timetz_zone(PG_FUNCTION_ARGS); 00187 extern Datum timetz_izone(PG_FUNCTION_ARGS); 00188 extern Datum timetz_pl_interval(PG_FUNCTION_ARGS); 00189 extern Datum timetz_mi_interval(PG_FUNCTION_ARGS); 00190 00191 #endif /* DATE_H */