#include #include #include #include #include "access/xact.h" #include "catalog/pg_type.h" #include "common/hashfn.h" #include "common/int.h" #include "libpq/pqformat.h" #include "miscadmin.h" #include "nodes/supportnodes.h" #include "parser/scansup.h" #include "utils/array.h" #include "utils/builtins.h" #include "utils/date.h" #include "utils/datetime.h" #include "utils/numeric.h" #include "utils/skipsupport.h" #include "utils/sortsupport.h"">

PostgreSQL Source Code: src/backend/utils/adt/date.c File Reference (original) (raw)

#include "[postgres.h](postgres%5F8h%5Fsource.html)"
#include <ctype.h>
#include <limits.h>
#include <[float.h](float%5F8h%5Fsource.html)>
#include <math.h>
#include <[time.h](time%5F8h%5Fsource.html)>
#include "[access/xact.h](xact%5F8h%5Fsource.html)"
#include "[catalog/pg_type.h](pg%5F%5Ftype%5F8h%5Fsource.html)"
#include "[common/hashfn.h](hashfn%5F8h%5Fsource.html)"
#include "[common/int.h](int%5F8h%5Fsource.html)"
#include "[libpq/pqformat.h](pqformat%5F8h%5Fsource.html)"
#include "[miscadmin.h](miscadmin%5F8h%5Fsource.html)"
#include "[nodes/supportnodes.h](supportnodes%5F8h%5Fsource.html)"
#include "[parser/scansup.h](scansup%5F8h%5Fsource.html)"
#include "[utils/array.h](array%5F8h%5Fsource.html)"
#include "[utils/builtins.h](builtins%5F8h%5Fsource.html)"
#include "[utils/date.h](date%5F8h%5Fsource.html)"
#include "[utils/datetime.h](include%5F2utils%5F2datetime%5F8h%5Fsource.html)"
#include "[utils/numeric.h](numeric%5F8h%5Fsource.html)"
#include "[utils/skipsupport.h](skipsupport%5F8h%5Fsource.html)"
#include "[utils/sortsupport.h](sortsupport%5F8h%5Fsource.html)"

Go to the source code of this file.

Macros
#define TIMEADT_GT(t1, t2) (DatumGetTimeADT(t1) > DatumGetTimeADT(t2))
#define TIMEADT_LT(t1, t2) (DatumGetTimeADT(t1) < DatumGetTimeADT(t2))
#define TIMETZ_GT(t1, t2) DatumGetBool(DirectFunctionCall2(timetz_gt,t1,t2))
#define TIMETZ_LT(t1, t2) DatumGetBool(DirectFunctionCall2(timetz_lt,t1,t2))
Functions
static int32 anytime_typmodin (bool istz, ArrayType *ta)
int32 anytime_typmod_check (bool istz, int32 typmod)
static char * anytime_typmodout (bool istz, int32 typmod)
Datum date_in (PG_FUNCTION_ARGS)
Datum date_out (PG_FUNCTION_ARGS)
Datum date_recv (PG_FUNCTION_ARGS)
Datum date_send (PG_FUNCTION_ARGS)
Datum make_date (PG_FUNCTION_ARGS)
void EncodeSpecialDate (DateADT dt, char *str)
DateADT GetSQLCurrentDate (void)
TimeTzADT * GetSQLCurrentTime (int32 typmod)
TimeADT GetSQLLocalTime (int32 typmod)
Datum date_eq (PG_FUNCTION_ARGS)
Datum date_ne (PG_FUNCTION_ARGS)
Datum date_lt (PG_FUNCTION_ARGS)
Datum date_le (PG_FUNCTION_ARGS)
Datum date_gt (PG_FUNCTION_ARGS)
Datum date_ge (PG_FUNCTION_ARGS)
Datum date_cmp (PG_FUNCTION_ARGS)
Datum date_sortsupport (PG_FUNCTION_ARGS)
static Datum date_decrement (Relation rel, Datum existing, bool *underflow)
static Datum date_increment (Relation rel, Datum existing, bool *overflow)
Datum date_skipsupport (PG_FUNCTION_ARGS)
Datum hashdate (PG_FUNCTION_ARGS)
Datum hashdateextended (PG_FUNCTION_ARGS)
Datum date_finite (PG_FUNCTION_ARGS)
Datum date_larger (PG_FUNCTION_ARGS)
Datum date_smaller (PG_FUNCTION_ARGS)
Datum date_mi (PG_FUNCTION_ARGS)
Datum date_pli (PG_FUNCTION_ARGS)
Datum date_mii (PG_FUNCTION_ARGS)
Timestamp date2timestamp_opt_overflow (DateADT dateVal, int *overflow)
static TimestampTz date2timestamp (DateADT dateVal)
TimestampTz date2timestamptz_opt_overflow (DateADT dateVal, int *overflow)
static TimestampTz date2timestamptz (DateADT dateVal)
double date2timestamp_no_overflow (DateADT dateVal)
int32 date_cmp_timestamp_internal (DateADT dateVal, Timestamp dt2)
Datum date_eq_timestamp (PG_FUNCTION_ARGS)
Datum date_ne_timestamp (PG_FUNCTION_ARGS)
Datum date_lt_timestamp (PG_FUNCTION_ARGS)
Datum date_gt_timestamp (PG_FUNCTION_ARGS)
Datum date_le_timestamp (PG_FUNCTION_ARGS)
Datum date_ge_timestamp (PG_FUNCTION_ARGS)
Datum date_cmp_timestamp (PG_FUNCTION_ARGS)
int32 date_cmp_timestamptz_internal (DateADT dateVal, TimestampTz dt2)
Datum date_eq_timestamptz (PG_FUNCTION_ARGS)
Datum date_ne_timestamptz (PG_FUNCTION_ARGS)
Datum date_lt_timestamptz (PG_FUNCTION_ARGS)
Datum date_gt_timestamptz (PG_FUNCTION_ARGS)
Datum date_le_timestamptz (PG_FUNCTION_ARGS)
Datum date_ge_timestamptz (PG_FUNCTION_ARGS)
Datum date_cmp_timestamptz (PG_FUNCTION_ARGS)
Datum timestamp_eq_date (PG_FUNCTION_ARGS)
Datum timestamp_ne_date (PG_FUNCTION_ARGS)
Datum timestamp_lt_date (PG_FUNCTION_ARGS)
Datum timestamp_gt_date (PG_FUNCTION_ARGS)
Datum timestamp_le_date (PG_FUNCTION_ARGS)
Datum timestamp_ge_date (PG_FUNCTION_ARGS)
Datum timestamp_cmp_date (PG_FUNCTION_ARGS)
Datum timestamptz_eq_date (PG_FUNCTION_ARGS)
Datum timestamptz_ne_date (PG_FUNCTION_ARGS)
Datum timestamptz_lt_date (PG_FUNCTION_ARGS)
Datum timestamptz_gt_date (PG_FUNCTION_ARGS)
Datum timestamptz_le_date (PG_FUNCTION_ARGS)
Datum timestamptz_ge_date (PG_FUNCTION_ARGS)
Datum timestamptz_cmp_date (PG_FUNCTION_ARGS)
Datum in_range_date_interval (PG_FUNCTION_ARGS)
Datum extract_date (PG_FUNCTION_ARGS)
Datum date_pl_interval (PG_FUNCTION_ARGS)
Datum date_mi_interval (PG_FUNCTION_ARGS)
Datum date_timestamp (PG_FUNCTION_ARGS)
Datum timestamp_date (PG_FUNCTION_ARGS)
Datum date_timestamptz (PG_FUNCTION_ARGS)
Datum timestamptz_date (PG_FUNCTION_ARGS)
Datum time_in (PG_FUNCTION_ARGS)
int tm2time (struct pg_tm *tm, fsec_t fsec, TimeADT *result)
bool time_overflows (int hour, int min, int sec, fsec_t fsec)
bool float_time_overflows (int hour, int min, double sec)
int time2tm (TimeADT time, struct pg_tm *tm, fsec_t *fsec)
Datum time_out (PG_FUNCTION_ARGS)
Datum time_recv (PG_FUNCTION_ARGS)
Datum time_send (PG_FUNCTION_ARGS)
Datum timetypmodin (PG_FUNCTION_ARGS)
Datum timetypmodout (PG_FUNCTION_ARGS)
Datum make_time (PG_FUNCTION_ARGS)
Datum time_support (PG_FUNCTION_ARGS)
Datum time_scale (PG_FUNCTION_ARGS)
void AdjustTimeForTypmod (TimeADT *time, int32 typmod)
Datum time_eq (PG_FUNCTION_ARGS)
Datum time_ne (PG_FUNCTION_ARGS)
Datum time_lt (PG_FUNCTION_ARGS)
Datum time_le (PG_FUNCTION_ARGS)
Datum time_gt (PG_FUNCTION_ARGS)
Datum time_ge (PG_FUNCTION_ARGS)
Datum time_cmp (PG_FUNCTION_ARGS)
Datum time_hash (PG_FUNCTION_ARGS)
Datum time_hash_extended (PG_FUNCTION_ARGS)
Datum time_larger (PG_FUNCTION_ARGS)
Datum time_smaller (PG_FUNCTION_ARGS)
Datum overlaps_time (PG_FUNCTION_ARGS)
Datum timestamp_time (PG_FUNCTION_ARGS)
Datum timestamptz_time (PG_FUNCTION_ARGS)
Datum datetime_timestamp (PG_FUNCTION_ARGS)
Datum time_interval (PG_FUNCTION_ARGS)
Datum interval_time (PG_FUNCTION_ARGS)
Datum time_mi_time (PG_FUNCTION_ARGS)
Datum time_pl_interval (PG_FUNCTION_ARGS)
Datum time_mi_interval (PG_FUNCTION_ARGS)
Datum in_range_time_interval (PG_FUNCTION_ARGS)
static Datum time_part_common (PG_FUNCTION_ARGS, bool retnumeric)
Datum time_part (PG_FUNCTION_ARGS)
Datum extract_time (PG_FUNCTION_ARGS)
int tm2timetz (struct pg_tm *tm, fsec_t fsec, int tz, TimeTzADT *result)
Datum timetz_in (PG_FUNCTION_ARGS)
Datum timetz_out (PG_FUNCTION_ARGS)
Datum timetz_recv (PG_FUNCTION_ARGS)
Datum timetz_send (PG_FUNCTION_ARGS)
Datum timetztypmodin (PG_FUNCTION_ARGS)
Datum timetztypmodout (PG_FUNCTION_ARGS)
int timetz2tm (TimeTzADT *time, struct pg_tm *tm, fsec_t *fsec, int *tzp)
Datum timetz_scale (PG_FUNCTION_ARGS)
static int timetz_cmp_internal (TimeTzADT *time1, TimeTzADT *time2)
Datum timetz_eq (PG_FUNCTION_ARGS)
Datum timetz_ne (PG_FUNCTION_ARGS)
Datum timetz_lt (PG_FUNCTION_ARGS)
Datum timetz_le (PG_FUNCTION_ARGS)
Datum timetz_gt (PG_FUNCTION_ARGS)
Datum timetz_ge (PG_FUNCTION_ARGS)
Datum timetz_cmp (PG_FUNCTION_ARGS)
Datum timetz_hash (PG_FUNCTION_ARGS)
Datum timetz_hash_extended (PG_FUNCTION_ARGS)
Datum timetz_larger (PG_FUNCTION_ARGS)
Datum timetz_smaller (PG_FUNCTION_ARGS)
Datum timetz_pl_interval (PG_FUNCTION_ARGS)
Datum timetz_mi_interval (PG_FUNCTION_ARGS)
Datum in_range_timetz_interval (PG_FUNCTION_ARGS)
Datum overlaps_timetz (PG_FUNCTION_ARGS)
Datum timetz_time (PG_FUNCTION_ARGS)
Datum time_timetz (PG_FUNCTION_ARGS)
Datum timestamptz_timetz (PG_FUNCTION_ARGS)
Datum datetimetz_timestamptz (PG_FUNCTION_ARGS)
static Datum timetz_part_common (PG_FUNCTION_ARGS, bool retnumeric)
Datum timetz_part (PG_FUNCTION_ARGS)
Datum extract_timetz (PG_FUNCTION_ARGS)
Datum timetz_zone (PG_FUNCTION_ARGS)
Datum timetz_izone (PG_FUNCTION_ARGS)
Datum timetz_at_local (PG_FUNCTION_ARGS)

TIMEADT_GT

TIMEADT_LT

TIMETZ_GT

TIMETZ_LT

AdjustTimeForTypmod()

Definition at line 1710 of file date.c.

1711{

1720 };

1721

1730 };

1731

1733 {

1735 *time = ((*time + TimeOffsets[typmod]) / TimeScales[typmod]) *

1736 TimeScales[typmod];

1737 else

1738 *time = -((((-*time) + TimeOffsets[typmod]) / TimeScales[typmod]) *

1739 TimeScales[typmod]);

1740 }

1741}

#define MAX_TIME_PRECISION

References INT64CONST, and MAX_TIME_PRECISION.

Referenced by executeDateTimeMethod(), GetSQLCurrentTime(), GetSQLLocalTime(), parse_datetime(), time_in(), time_recv(), time_scale(), timetz_in(), timetz_recv(), and timetz_scale().

anytime_typmod_check()

int32 anytime_typmod_check ( bool istz,
int32 typmod
)

Definition at line 72 of file date.c.

73{

74 if (typmod < 0)

76 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

77 errmsg("TIME(%d)%s precision must not be negative",

78 typmod, (istz ? " WITH TIME ZONE" : ""))));

80 {

82 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

83 errmsg("TIME(%d)%s precision reduced to maximum allowed, %d",

84 typmod, (istz ? " WITH TIME ZONE" : ""),

87 }

88

89 return typmod;

90}

int errcode(int sqlerrcode)

int errmsg(const char *fmt,...)

#define ereport(elevel,...)

References ereport, errcode(), errmsg(), ERROR, MAX_TIME_PRECISION, and WARNING.

Referenced by anytime_typmodin(), executeDateTimeMethod(), and transformSQLValueFunction().

anytime_typmodin()

anytime_typmodout()

static char * anytime_typmodout ( bool istz, int32 typmod ) static

Definition at line 94 of file date.c.

95{

96 const char *tz = istz ? " with time zone" : " without time zone";

97

98 if (typmod >= 0)

99 return psprintf("(%d)%s", (int) typmod, tz);

100 else

102}

char * pstrdup(const char *in)

char * psprintf(const char *fmt,...)

References psprintf(), and pstrdup().

Referenced by timetypmodout(), and timetztypmodout().

date2timestamp()

date2timestamp_no_overflow()

double date2timestamp_no_overflow ( DateADT dateVal )

date2timestamp_opt_overflow()

Definition at line 629 of file date.c.

630{

632

633 if (overflow)

634 *overflow = 0;

635

640 else

641 {

642

643

644

645

647 {

648 if (overflow)

649 {

650 *overflow = 1;

652 return result;

653 }

654 else

655 {

657 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

658 errmsg("date out of range for timestamp")));

659 }

660 }

661

662

664 }

665

666 return result;

667}

#define TIMESTAMP_NOBEGIN(j)

#define TIMESTAMP_END_JULIAN

#define POSTGRES_EPOCH_JDATE

#define TIMESTAMP_NOEND(j)

References DATE_IS_NOBEGIN, DATE_IS_NOEND, ereport, errcode(), errmsg(), ERROR, POSTGRES_EPOCH_JDATE, TIMESTAMP_END_JULIAN, TIMESTAMP_NOBEGIN, TIMESTAMP_NOEND, and USECS_PER_DAY.

Referenced by date2timestamp(), and date_cmp_timestamp_internal().

date2timestamptz()

date2timestamptz_opt_overflow()

Definition at line 689 of file date.c.

690{

693 *tm = &tt;

694 int tz;

695

696 if (overflow)

697 *overflow = 0;

698

703 else

704 {

705

706

707

708

710 {

711 if (overflow)

712 {

713 *overflow = 1;

715 return result;

716 }

717 else

718 {

720 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

721 errmsg("date out of range for timestamp")));

722 }

723 }

724

731

733

734

735

736

737

739 {

740 if (overflow)

741 {

743 {

744 *overflow = -1;

746 }

747 else

748 {

749 *overflow = 1;

751 }

752 }

753 else

754 {

756 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

757 errmsg("date out of range for timestamp")));

758 }

759 }

760 }

761

762 return result;

763}

int DetermineTimeZoneOffset(struct pg_tm *tm, pg_tz *tzp)

void j2date(int jd, int *year, int *month, int *day)

#define IS_VALID_TIMESTAMP(t)

PGDLLIMPORT pg_tz * session_timezone

References DATE_IS_NOBEGIN, DATE_IS_NOEND, DetermineTimeZoneOffset(), ereport, errcode(), errmsg(), ERROR, IS_VALID_TIMESTAMP, j2date(), MIN_TIMESTAMP, POSTGRES_EPOCH_JDATE, session_timezone, TIMESTAMP_END_JULIAN, TIMESTAMP_NOBEGIN, TIMESTAMP_NOEND, tm, pg_tm::tm_hour, pg_tm::tm_mday, pg_tm::tm_min, pg_tm::tm_mon, pg_tm::tm_sec, pg_tm::tm_year, USECS_PER_DAY, and USECS_PER_SEC.

Referenced by date2timestamptz(), and date_cmp_timestamptz_internal().

date_cmp()

date_cmp_timestamp()

date_cmp_timestamp_internal()

Definition at line 808 of file date.c.

809{

811 int overflow;

812

814 if (overflow > 0)

815 {

816

818 }

819 Assert(overflow == 0);

820

822}

int timestamp_cmp_internal(Timestamp dt1, Timestamp dt2)

#define TIMESTAMP_IS_NOEND(j)

Assert(PointerIsAligned(start, uint64))

References Assert(), date2timestamp_opt_overflow(), timestamp_cmp_internal(), and TIMESTAMP_IS_NOEND.

Referenced by cmpDateToTimestamp(), date_cmp_timestamp(), date_eq_timestamp(), date_ge_timestamp(), date_gt_timestamp(), date_le_timestamp(), date_lt_timestamp(), date_ne_timestamp(), timestamp_cmp_date(), timestamp_eq_date(), timestamp_ge_date(), timestamp_gt_date(), timestamp_le_date(), timestamp_lt_date(), and timestamp_ne_date().

date_cmp_timestamptz()

date_cmp_timestamptz_internal()

Definition at line 888 of file date.c.

889{

891 int overflow;

892

894 if (overflow > 0)

895 {

896

898 }

899 if (overflow < 0)

900 {

901

903 }

904

906}

#define TIMESTAMP_IS_NOBEGIN(j)

#define timestamptz_cmp_internal(dt1, dt2)

References date2timestamptz_opt_overflow(), TIMESTAMP_IS_NOBEGIN, TIMESTAMP_IS_NOEND, and timestamptz_cmp_internal.

Referenced by cmpDateToTimestampTz(), date_cmp_timestamptz(), date_eq_timestamptz(), date_ge_timestamptz(), date_gt_timestamptz(), date_le_timestamptz(), date_lt_timestamptz(), date_ne_timestamptz(), timestamptz_cmp_date(), timestamptz_eq_date(), timestamptz_ge_date(), timestamptz_gt_date(), timestamptz_le_date(), timestamptz_lt_date(), and timestamptz_ne_date().

date_decrement()

date_eq()

date_eq_timestamp()

date_eq_timestamptz()

date_finite()

date_ge()

date_ge_timestamp()

date_ge_timestamptz()

date_gt()

date_gt_timestamp()

date_gt_timestamptz()

date_in()

Definition at line 114 of file date.c.

115{

117 Node *escontext = fcinfo->context;

121 *tm = &tt;

122 int tzp;

123 int dtype;

124 int nf;

125 int dterr;

130

133 if (dterr == 0)

135 &dtype, tm, &fsec, &tzp, &extra);

136 if (dterr != 0)

137 {

140 }

141

142 switch (dtype)

143 {

145 break;

146

149 break;

150

154

158

159 default:

162 }

163

164

167 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

168 errmsg("date out of range: \"%s\"", str)));

169

171

172

175 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

176 errmsg("date out of range: \"%s\"", str)));

177

179}

int ParseDateTime(const char *timestr, char *workbuf, size_t buflen, char **field, int *ftype, int maxfields, int *numfields)

void DateTimeParseError(int dterr, DateTimeErrorExtra *extra, const char *str, const char *datatype, Node *escontext)

int DecodeDateTime(char **field, int *ftype, int nf, int *dtype, struct pg_tm *tm, fsec_t *fsec, int *tzp, DateTimeErrorExtra *extra)

int date2j(int year, int month, int day)

void GetEpochTime(struct pg_tm *tm)

#define IS_VALID_JULIAN(y, m, d)

#define PG_RETURN_DATEADT(x)

#define ereturn(context, dummy_value,...)

#define PG_GETARG_CSTRING(n)

References date2j(), DATE_NOBEGIN, DATE_NOEND, DateTimeParseError(), DecodeDateTime(), DTERR_BAD_FORMAT, DTK_DATE, DTK_EARLY, DTK_EPOCH, DTK_LATE, ereturn, errcode(), errmsg(), GetEpochTime(), IS_VALID_DATE, IS_VALID_JULIAN, MAXDATEFIELDS, MAXDATELEN, ParseDateTime(), PG_GETARG_CSTRING, PG_RETURN_DATEADT, PG_RETURN_NULL, POSTGRES_EPOCH_JDATE, str, tm, pg_tm::tm_mday, pg_tm::tm_mon, and pg_tm::tm_year.

date_increment()

date_larger()

date_le()

date_le_timestamp()

date_le_timestamptz()

date_lt()

date_lt_timestamp()

date_lt_timestamptz()

date_mi()

date_mi_interval()

date_mii()

Definition at line 593 of file date.c.

594{

598

601

602 result = dateVal - days;

603

604

605 if ((days >= 0 ? (result > dateVal) : (result < dateVal)) ||

608 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

609 errmsg("date out of range")));

610

612}

#define PG_GETARG_INT32(n)

References DATE_NOT_FINITE, days, ereport, errcode(), errmsg(), ERROR, IS_VALID_DATE, PG_GETARG_DATEADT, PG_GETARG_INT32, and PG_RETURN_DATEADT.

date_ne()

date_ne_timestamp()

date_ne_timestamptz()

date_out()

Definition at line 185 of file date.c.

186{

188 char *result;

190 *tm = &tt;

192

195 else

196 {

200 }

201

204}

void EncodeDateOnly(struct pg_tm *tm, int style, char *str)

void EncodeSpecialDate(DateADT dt, char *str)

#define PG_RETURN_CSTRING(x)

References buf, DATE_NOT_FINITE, DateStyle, EncodeDateOnly(), EncodeSpecialDate(), j2date(), MAXDATELEN, PG_GETARG_DATEADT, PG_RETURN_CSTRING, POSTGRES_EPOCH_JDATE, pstrdup(), tm, pg_tm::tm_mday, pg_tm::tm_mon, and pg_tm::tm_year.

Referenced by ExecGetJsonValueItemString().

date_pl_interval()

date_pli()

Definition at line 569 of file date.c.

570{

574

577

578 result = dateVal + days;

579

580

581 if ((days >= 0 ? (result < dateVal) : (result > dateVal)) ||

584 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

585 errmsg("date out of range")));

586

588}

References DATE_NOT_FINITE, days, ereport, errcode(), errmsg(), ERROR, IS_VALID_DATE, PG_GETARG_DATEADT, PG_GETARG_INT32, and PG_RETURN_DATEADT.

date_recv()

Definition at line 210 of file date.c.

211{

214

216

217

219 ;

222 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

223 errmsg("date out of range")));

224

226}

#define PG_GETARG_POINTER(n)

unsigned int pq_getmsgint(StringInfo msg, int b)

StringInfoData * StringInfo

References buf, DATE_NOT_FINITE, ereport, errcode(), errmsg(), ERROR, IS_VALID_DATE, PG_GETARG_POINTER, PG_RETURN_DATEADT, and pq_getmsgint().

date_send()

date_skipsupport()

Definition at line 499 of file date.c.

500{

502

507

509}

static Datum date_decrement(Relation rel, Datum existing, bool *underflow)

static Datum date_increment(Relation rel, Datum existing, bool *overflow)

struct SkipSupportData * SkipSupport

SkipSupportIncDec decrement

SkipSupportIncDec increment

References date_decrement(), date_increment(), DateADTGetDatum(), DATEVAL_NOBEGIN, DATEVAL_NOEND, SkipSupportData::decrement, SkipSupportData::high_elem, SkipSupportData::increment, SkipSupportData::low_elem, PG_GETARG_POINTER, and PG_RETURN_VOID.

date_smaller()

date_sortsupport()

date_timestamp()

date_timestamptz()

datetime_timestamp()

Definition at line 2031 of file date.c.

2032{

2036

2039 {

2040 result += time;

2043 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

2044 errmsg("timestamp out of range")));

2045 }

2046

2048}

#define TIMESTAMP_NOT_FINITE(j)

#define PG_GETARG_TIMEADT(n)

References date2timestamp(), ereport, errcode(), errmsg(), ERROR, IS_VALID_TIMESTAMP, PG_GETARG_DATEADT, PG_GETARG_TIMEADT, PG_RETURN_TIMESTAMP, and TIMESTAMP_NOT_FINITE.

datetimetz_timestamptz()

Definition at line 2951 of file date.c.

2952{

2956

2961 else

2962 {

2963

2964

2965

2966

2967

2970 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

2971 errmsg("date out of range for timestamp")));

2973

2974

2975

2976

2977

2980 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

2981 errmsg("date out of range for timestamp")));

2982 }

2983

2985}

#define PG_GETARG_TIMETZADT_P(n)

References DATE_IS_NOBEGIN, DATE_IS_NOEND, ereport, errcode(), errmsg(), ERROR, IS_VALID_TIMESTAMP, PG_GETARG_DATEADT, PG_GETARG_TIMETZADT_P, PG_RETURN_TIMESTAMP, POSTGRES_EPOCH_JDATE, TimeTzADT::time, TIMESTAMP_END_JULIAN, TIMESTAMP_NOBEGIN, TIMESTAMP_NOEND, USECS_PER_DAY, USECS_PER_SEC, and TimeTzADT::zone.

EncodeSpecialDate()

void EncodeSpecialDate ( DateADT dt,
char * str
)

extract_date()

Definition at line 1131 of file date.c.

1132{

1135 int64 intresult;

1138 char *lowunits;

1139 int year,

1140 mon,

1141 mday;

1142

1145 false);

1146

1150

1152 {

1153 switch (val)

1154 {

1155

1164 break;

1165

1166

1179 else

1184 default:

1186 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),

1187 errmsg("unit \"%s\" not supported for type %s",

1189 }

1190 }

1192 {

1194

1195 switch (val)

1196 {

1198 intresult = mday;

1199 break;

1200

1202 intresult = mon;

1203 break;

1204

1206 intresult = (mon - 1) / 3 + 1;

1207 break;

1208

1211 break;

1212

1214 if (year > 0)

1215 intresult = year;

1216 else

1217

1218 intresult = year - 1;

1219 break;

1220

1222

1223 if (year >= 0)

1224 intresult = year / 10;

1225 else

1226 intresult = -((8 - (year - 1)) / 10);

1227 break;

1228

1230

1231 if (year > 0)

1232 intresult = (year + 99) / 100;

1233 else

1234 intresult = -((99 - (year - 1)) / 100);

1235 break;

1236

1238

1239 if (year > 0)

1240 intresult = (year + 999) / 1000;

1241 else

1242 intresult = -((999 - (year - 1)) / 1000);

1243 break;

1244

1247 break;

1248

1251

1252 if (intresult <= 0)

1253 intresult -= 1;

1254 break;

1255

1260 intresult = 7;

1261 break;

1262

1264 intresult = date2j(year, mon, mday) - date2j(year, 1, 1) + 1;

1265 break;

1266

1267 default:

1269 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),

1270 errmsg("unit \"%s\" not supported for type %s",

1272 intresult = 0;

1273 }

1274 }

1276 {

1277 switch (val)

1278 {

1281 break;

1282

1283 default:

1285 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),

1286 errmsg("unit \"%s\" not supported for type %s",

1288 intresult = 0;

1289 }

1290 }

1291 else

1292 {

1294 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

1295 errmsg("unit \"%s\" not recognized for type %s",

1297 intresult = 0;

1298 }

1299

1301}

int DecodeUnits(int field, const char *lowtoken, int *val)

int DecodeSpecial(int field, const char *lowtoken, int *val)

Numeric int64_to_numeric(int64 val)

Datum numeric_in(PG_FUNCTION_ARGS)

int date2isoweek(int year, int mon, int mday)

int date2isoyear(int year, int mon, int mday)

#define PG_GETARG_TEXT_PP(n)

#define DirectFunctionCall3(func, arg1, arg2, arg3)

char * format_type_be(Oid type_oid)

static Numeric DatumGetNumeric(Datum X)

#define PG_RETURN_NUMERIC(x)

static Datum ObjectIdGetDatum(Oid X)

static Datum CStringGetDatum(const char *X)

static Datum Int32GetDatum(int32 X)

char * downcase_truncate_identifier(const char *ident, int len, bool warn)

#define VARSIZE_ANY_EXHDR(PTR)

References CStringGetDatum(), date2isoweek(), date2isoyear(), date2j(), DATE_IS_NOBEGIN, DATE_NOT_FINITE, DatumGetNumeric(), DecodeSpecial(), DecodeUnits(), DirectFunctionCall3, downcase_truncate_identifier(), DTK_CENTURY, DTK_DAY, DTK_DECADE, DTK_DOW, DTK_DOY, DTK_EPOCH, DTK_ISODOW, DTK_ISOYEAR, DTK_JULIAN, DTK_MILLENNIUM, DTK_MONTH, DTK_QUARTER, DTK_WEEK, DTK_YEAR, ereport, errcode(), errmsg(), ERROR, format_type_be(), Int32GetDatum(), int64_to_numeric(), InvalidOid, j2date(), j2day(), numeric_in(), ObjectIdGetDatum(), PG_GETARG_DATEADT, PG_GETARG_TEXT_PP, PG_RETURN_NULL, PG_RETURN_NUMERIC, POSTGRES_EPOCH_JDATE, RESERV, SECS_PER_DAY, type, UNITS, UNIX_EPOCH_JDATE, UNKNOWN_FIELD, val, VARDATA_ANY, and VARSIZE_ANY_EXHDR.

extract_time()

Definition at line 2314 of file date.c.

2315{

2317}

static Datum time_part_common(PG_FUNCTION_ARGS, bool retnumeric)

References time_part_common().

extract_timetz()

Definition at line 3115 of file date.c.

3116{

3118}

static Datum timetz_part_common(PG_FUNCTION_ARGS, bool retnumeric)

References timetz_part_common().

float_time_overflows()

bool float_time_overflows ( int hour,
int min,
double sec
)

GetSQLCurrentDate()

GetSQLCurrentTime()

Definition at line 350 of file date.c.

351{

354 *tm = &tt;

356 int tz;

357

359

363 return result;

364}

void GetCurrentTimeUsec(struct pg_tm *tm, fsec_t *fsec, int *tzp)

int tm2timetz(struct pg_tm *tm, fsec_t fsec, int tz, TimeTzADT *result)

void AdjustTimeForTypmod(TimeADT *time, int32 typmod)

References AdjustTimeForTypmod(), GetCurrentTimeUsec(), palloc(), TimeTzADT::time, tm, and tm2timetz().

Referenced by ExecEvalSQLValueFunction().

GetSQLLocalTime()

hashdate()

hashdateextended()

in_range_date_interval()

Definition at line 1104 of file date.c.

1105{

1113

1114

1117

1124}

Datum in_range_timestamp_interval(PG_FUNCTION_ARGS)

#define PG_GETARG_BOOL(n)

#define DirectFunctionCall5(func, arg1, arg2, arg3, arg4, arg5)

static Datum BoolGetDatum(bool X)

static Datum IntervalPGetDatum(const Interval *X)

References BoolGetDatum(), date2timestamp(), DirectFunctionCall5, in_range_timestamp_interval(), IntervalPGetDatum(), PG_GETARG_BOOL, PG_GETARG_DATEADT, PG_GETARG_INTERVAL_P, TimestampGetDatum(), and val.

in_range_time_interval()

Definition at line 2163 of file date.c.

2164{

2171

2172

2173

2174

2175

2176

2177 if (offset->time < 0)

2179 (errcode(ERRCODE_INVALID_PRECEDING_OR_FOLLOWING_SIZE),

2180 errmsg("invalid preceding or following size in window function")));

2181

2182

2183

2184

2185

2186

2187

2188

2189 if (sub)

2190 sum = base - offset->time;

2193

2194 if (less)

2196 else

2198}

static bool pg_add_s64_overflow(int64 a, int64 b, int64 *result)

References ereport, errcode(), errmsg(), ERROR, pg_add_s64_overflow(), PG_GETARG_BOOL, PG_GETARG_INTERVAL_P, PG_GETARG_TIMEADT, PG_RETURN_BOOL, Interval::time, and val.

in_range_timetz_interval()

Definition at line 2715 of file date.c.

2716{

2723

2724

2725

2726

2727

2728

2729 if (offset->time < 0)

2731 (errcode(ERRCODE_INVALID_PRECEDING_OR_FOLLOWING_SIZE),

2732 errmsg("invalid preceding or following size in window function")));

2733

2734

2735

2736

2737

2738

2739

2740

2741 if (sub)

2746

2747 if (less)

2749 else

2751}

static int timetz_cmp_internal(TimeTzADT *time1, TimeTzADT *time2)

References ereport, errcode(), errmsg(), ERROR, pg_add_s64_overflow(), PG_GETARG_BOOL, PG_GETARG_INTERVAL_P, PG_GETARG_TIMETZADT_P, PG_RETURN_BOOL, Interval::time, TimeTzADT::time, timetz_cmp_internal(), val, and TimeTzADT::zone.

interval_time()

make_date()

Definition at line 246 of file date.c.

247{

250 int dterr;

251 bool bc = false;

252

256

257

259 {

261

262 bc = true;

265 (errcode(ERRCODE_DATETIME_FIELD_OVERFLOW),

266 errmsg("date field value out of range: %d-%02d-%02d",

269 }

270

272

273 if (dterr != 0)

275 (errcode(ERRCODE_DATETIME_FIELD_OVERFLOW),

276 errmsg("date field value out of range: %d-%02d-%02d",

278

279

282 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

283 errmsg("date out of range: %d-%02d-%02d",

285

287

288

291 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

292 errmsg("date out of range: %d-%02d-%02d",

294

296}

int ValidateDate(int fmask, bool isjulian, bool is2digits, bool bc, struct pg_tm *tm)

static bool pg_neg_s32_overflow(int32 a, int32 *result)

References date2j(), DTK_DATE_M, ereport, errcode(), errmsg(), ERROR, IS_VALID_DATE, IS_VALID_JULIAN, PG_GETARG_INT32, pg_neg_s32_overflow(), PG_RETURN_DATEADT, POSTGRES_EPOCH_JDATE, tm, pg_tm::tm_mday, pg_tm::tm_mon, pg_tm::tm_year, and ValidateDate().

make_time()

Definition at line 1642 of file date.c.

1643{

1648

1649

1652 (errcode(ERRCODE_DATETIME_FIELD_OVERFLOW),

1653 errmsg("time field value out of range: %d:%02d:%02g",

1654 tm_hour, tm_min, sec)));

1655

1656

1659

1661}

bool float_time_overflows(int hour, int min, double sec)

#define PG_GETARG_FLOAT8(n)

References ereport, errcode(), errmsg(), ERROR, float_time_overflows(), MINS_PER_HOUR, PG_GETARG_FLOAT8, PG_GETARG_INT32, PG_RETURN_TIMEADT, SECS_PER_MINUTE, pg_tm::tm_hour, pg_tm::tm_min, and USECS_PER_SEC.

overlaps_time()

Definition at line 1848 of file date.c.

1849{

1850

1851

1852

1853

1862

1863#define TIMEADT_GT(t1,t2) \

1864 (DatumGetTimeADT(t1) > DatumGetTimeADT(t2))

1865#define TIMEADT_LT(t1,t2) \

1866 (DatumGetTimeADT(t1) < DatumGetTimeADT(t2))

1867

1868

1869

1870

1871

1872

1873 if (ts1IsNull)

1874 {

1875 if (te1IsNull)

1877

1878 ts1 = te1;

1879 te1IsNull = true;

1880 }

1881 else if (!te1IsNull)

1882 {

1884 {

1886

1887 ts1 = te1;

1888 te1 = tt;

1889 }

1890 }

1891

1892

1893 if (ts2IsNull)

1894 {

1895 if (te2IsNull)

1897

1898 ts2 = te2;

1899 te2IsNull = true;

1900 }

1901 else if (!te2IsNull)

1902 {

1904 {

1906

1907 ts2 = te2;

1908 te2 = tt;

1909 }

1910 }

1911

1912

1913

1914

1915

1917 {

1918

1919

1920

1921

1922 if (te2IsNull)

1926 if (te1IsNull)

1928

1929

1930

1931

1932

1934 }

1936 {

1937

1938 if (te1IsNull)

1942 if (te2IsNull)

1944

1945

1946

1947

1948

1950 }

1951 else

1952 {

1953

1954

1955

1956

1957 if (te1IsNull || te2IsNull)

1960 }

1961

1962#undef TIMEADT_GT

1963#undef TIMEADT_LT

1964}

#define TIMEADT_GT(t1, t2)

#define TIMEADT_LT(t1, t2)

#define PG_GETARG_DATUM(n)

References PG_ARGISNULL, PG_GETARG_DATUM, PG_RETURN_BOOL, PG_RETURN_NULL, TIMEADT_GT, and TIMEADT_LT.

overlaps_timetz()

Definition at line 2760 of file date.c.

2761{

2762

2763

2764

2765

2774

2775#define TIMETZ_GT(t1,t2) \

2776 DatumGetBool(DirectFunctionCall2(timetz_gt,t1,t2))

2777#define TIMETZ_LT(t1,t2) \

2778 DatumGetBool(DirectFunctionCall2(timetz_lt,t1,t2))

2779

2780

2781

2782

2783

2784

2785 if (ts1IsNull)

2786 {

2787 if (te1IsNull)

2789

2790 ts1 = te1;

2791 te1IsNull = true;

2792 }

2793 else if (!te1IsNull)

2794 {

2796 {

2798

2799 ts1 = te1;

2800 te1 = tt;

2801 }

2802 }

2803

2804

2805 if (ts2IsNull)

2806 {

2807 if (te2IsNull)

2809

2810 ts2 = te2;

2811 te2IsNull = true;

2812 }

2813 else if (!te2IsNull)

2814 {

2816 {

2818

2819 ts2 = te2;

2820 te2 = tt;

2821 }

2822 }

2823

2824

2825

2826

2827

2829 {

2830

2831

2832

2833

2834 if (te2IsNull)

2838 if (te1IsNull)

2840

2841

2842

2843

2844

2846 }

2848 {

2849

2850 if (te1IsNull)

2854 if (te2IsNull)

2856

2857

2858

2859

2860

2862 }

2863 else

2864 {

2865

2866

2867

2868

2869 if (te1IsNull || te2IsNull)

2872 }

2873

2874#undef TIMETZ_GT

2875#undef TIMETZ_LT

2876}

#define TIMETZ_GT(t1, t2)

#define TIMETZ_LT(t1, t2)

References PG_ARGISNULL, PG_GETARG_DATUM, PG_RETURN_BOOL, PG_RETURN_NULL, TIMETZ_GT, and TIMETZ_LT.

time2tm()

time_cmp()

time_eq()

time_ge()

time_gt()

time_hash()

Definition at line 1812 of file date.c.

1813{

1815}

Datum hashint8(PG_FUNCTION_ARGS)

References hashint8().

time_hash_extended()

time_in()

Definition at line 1439 of file date.c.

1440{

1442#ifdef NOT_USED

1444#endif

1446 Node *escontext = fcinfo->context;

1449 struct pg_tm tt,

1450 *tm = &tt;

1451 int tz;

1452 int nf;

1453 int dterr;

1456 int dtype;

1459

1462 if (dterr == 0)

1464 &dtype, tm, &fsec, &tz, &extra);

1465 if (dterr != 0)

1466 {

1469 }

1470

1473

1475}

int DecodeTimeOnly(char **field, int *ftype, int nf, int *dtype, struct pg_tm *tm, fsec_t *fsec, int *tzp, DateTimeErrorExtra *extra)

References AdjustTimeForTypmod(), DateTimeParseError(), DecodeTimeOnly(), MAXDATEFIELDS, MAXDATELEN, ParseDateTime(), PG_GETARG_CSTRING, PG_GETARG_INT32, PG_GETARG_OID, PG_RETURN_NULL, PG_RETURN_TIMEADT, str, tm, and tm2time().

time_interval()

time_larger()

time_le()

time_lt()

time_mi_interval()

Definition at line 2140 of file date.c.

2141{

2145

2148 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

2149 errmsg("cannot subtract infinite interval from time")));

2150

2151 result = time - span->time;

2155

2157}

References ereport, errcode(), errmsg(), ERROR, INT64CONST, INTERVAL_NOT_FINITE, PG_GETARG_INTERVAL_P, PG_GETARG_TIMEADT, PG_RETURN_TIMEADT, Interval::time, and USECS_PER_DAY.

time_mi_time()

time_ne()

time_out()

Definition at line 1566 of file date.c.

1567{

1569 char *result;

1570 struct pg_tm tt,

1571 *tm = &tt;

1574

1577

1580}

void EncodeTimeOnly(struct pg_tm *tm, fsec_t fsec, bool print_tz, int tz, int style, char *str)

int time2tm(TimeADT time, struct pg_tm *tm, fsec_t *fsec)

References buf, DateStyle, EncodeTimeOnly(), MAXDATELEN, PG_GETARG_TIMEADT, PG_RETURN_CSTRING, pstrdup(), time2tm(), and tm.

Referenced by ExecGetJsonValueItemString().

time_overflows()

bool time_overflows ( int hour,
int min,
int sec,
fsec_t fsec
)

time_part()

time_part_common()

Definition at line 2205 of file date.c.

2206{

2209 int64 intresult;

2212 char *lowunits;

2213

2216 false);

2217

2221

2223 {

2225 struct pg_tm tt,

2226 *tm = &tt;

2227

2229

2230 switch (val)

2231 {

2234 break;

2235

2237 if (retnumeric)

2238

2239

2240

2241

2243 else

2245 break;

2246

2248 if (retnumeric)

2249

2250

2251

2252

2254 else

2256 break;

2257

2260 break;

2261

2264 break;

2265

2277 default:

2279 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),

2280 errmsg("unit \"%s\" not supported for type %s",

2282 intresult = 0;

2283 }

2284 }

2286 {

2287 if (retnumeric)

2289 else

2291 }

2292 else

2293 {

2295 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

2296 errmsg("unit \"%s\" not recognized for type %s",

2298 intresult = 0;

2299 }

2300

2301 if (retnumeric)

2303 else

2305}

Numeric int64_div_fast_to_numeric(int64 val1, int log10val2)

#define PG_RETURN_FLOAT8(x)

References DecodeSpecial(), DecodeUnits(), downcase_truncate_identifier(), DTK_CENTURY, DTK_DAY, DTK_DECADE, DTK_EPOCH, DTK_HOUR, DTK_ISOYEAR, DTK_MICROSEC, DTK_MILLENNIUM, DTK_MILLISEC, DTK_MINUTE, DTK_MONTH, DTK_QUARTER, DTK_SECOND, DTK_TZ, DTK_TZ_HOUR, DTK_TZ_MINUTE, DTK_YEAR, ereport, errcode(), errmsg(), ERROR, format_type_be(), int64_div_fast_to_numeric(), int64_to_numeric(), INT64CONST, PG_GETARG_TEXT_PP, PG_GETARG_TIMEADT, PG_RETURN_FLOAT8, PG_RETURN_NUMERIC, RESERV, time2tm(), tm, pg_tm::tm_hour, pg_tm::tm_min, pg_tm::tm_sec, type, UNITS, UNKNOWN_FIELD, val, VARDATA_ANY, and VARSIZE_ANY_EXHDR.

Referenced by extract_time(), and time_part().

time_pl_interval()

Definition at line 2117 of file date.c.

2118{

2122

2125 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

2126 errmsg("cannot add infinite interval to time")));

2127

2128 result = time + span->time;

2132

2134}

References ereport, errcode(), errmsg(), ERROR, INT64CONST, INTERVAL_NOT_FINITE, PG_GETARG_INTERVAL_P, PG_GETARG_TIMEADT, PG_RETURN_TIMEADT, Interval::time, and USECS_PER_DAY.

time_recv()

Definition at line 1586 of file date.c.

1587{

1589

1590#ifdef NOT_USED

1592#endif

1595

1597

1600 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

1601 errmsg("time out of range")));

1602

1604

1606}

int64 pq_getmsgint64(StringInfo msg)

References AdjustTimeForTypmod(), buf, ereport, errcode(), errmsg(), ERROR, INT64CONST, PG_GETARG_INT32, PG_GETARG_OID, PG_GETARG_POINTER, PG_RETURN_TIMEADT, pq_getmsgint64(), and USECS_PER_DAY.

time_scale()

time_send()

time_smaller()

time_support()

time_timetz()

Definition at line 2893 of file date.c.

2894{

2897 struct pg_tm tt,

2898 *tm = &tt;

2900 int tz;

2901

2905

2907

2908 result->time = time;

2909 result->zone = tz;

2910

2912}

#define PG_RETURN_TIMETZADT_P(x)

References DetermineTimeZoneOffset(), GetCurrentDateTime(), palloc(), PG_GETARG_TIMEADT, PG_RETURN_TIMETZADT_P, session_timezone, TimeTzADT::time, time2tm(), tm, and TimeTzADT::zone.

Referenced by castTimeToTimeTz(), and executeDateTimeMethod().

timestamp_cmp_date()

timestamp_date()

Definition at line 1362 of file date.c.

1363{

1366 struct pg_tm tt,

1367 *tm = &tt;

1369

1374 else

1375 {

1378 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

1379 errmsg("timestamp out of range")));

1380

1382 }

1383

1385}

int timestamp2tm(Timestamp dt, int *tzp, struct pg_tm *tm, fsec_t *fsec, const char **tzn, pg_tz *attimezone)

References date2j(), DATE_NOBEGIN, DATE_NOEND, ereport, errcode(), errmsg(), ERROR, PG_GETARG_TIMESTAMP, PG_RETURN_DATEADT, POSTGRES_EPOCH_JDATE, timestamp2tm(), TIMESTAMP_IS_NOBEGIN, TIMESTAMP_IS_NOEND, tm, pg_tm::tm_mday, pg_tm::tm_mon, and pg_tm::tm_year.

Referenced by executeDateTimeMethod().

timestamp_eq_date()

timestamp_ge_date()

timestamp_gt_date()

timestamp_le_date()

timestamp_lt_date()

timestamp_ne_date()

timestamp_time()

Definition at line 1970 of file date.c.

1971{

1974 struct pg_tm tt,

1975 *tm = &tt;

1977

1980

1983 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

1984 errmsg("timestamp out of range")));

1985

1986

1987

1988

1989

1992

1994}

References ereport, errcode(), errmsg(), ERROR, MINS_PER_HOUR, PG_GETARG_TIMESTAMP, PG_RETURN_NULL, PG_RETURN_TIMEADT, SECS_PER_MINUTE, timestamp2tm(), TIMESTAMP_NOT_FINITE, tm, pg_tm::tm_hour, pg_tm::tm_min, pg_tm::tm_sec, and USECS_PER_SEC.

Referenced by executeDateTimeMethod().

timestamptz_cmp_date()

timestamptz_date()

Definition at line 1407 of file date.c.

1408{

1411 struct pg_tm tt,

1412 *tm = &tt;

1414 int tz;

1415

1420 else

1421 {

1424 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

1425 errmsg("timestamp out of range")));

1426

1428 }

1429

1431}

References date2j(), DATE_NOBEGIN, DATE_NOEND, ereport, errcode(), errmsg(), ERROR, PG_GETARG_TIMESTAMP, PG_RETURN_DATEADT, POSTGRES_EPOCH_JDATE, timestamp2tm(), TIMESTAMP_IS_NOBEGIN, TIMESTAMP_IS_NOEND, tm, pg_tm::tm_mday, pg_tm::tm_mon, and pg_tm::tm_year.

Referenced by executeDateTimeMethod().

timestamptz_eq_date()

timestamptz_ge_date()

timestamptz_gt_date()

timestamptz_le_date()

timestamptz_lt_date()

timestamptz_ne_date()

timestamptz_time()

Definition at line 2000 of file date.c.

2001{

2004 struct pg_tm tt,

2005 *tm = &tt;

2006 int tz;

2008

2011

2014 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

2015 errmsg("timestamp out of range")));

2016

2017

2018

2019

2020

2023

2025}

References ereport, errcode(), errmsg(), ERROR, MINS_PER_HOUR, PG_GETARG_TIMESTAMP, PG_RETURN_NULL, PG_RETURN_TIMEADT, SECS_PER_MINUTE, timestamp2tm(), TIMESTAMP_NOT_FINITE, tm, pg_tm::tm_hour, pg_tm::tm_min, pg_tm::tm_sec, and USECS_PER_SEC.

Referenced by executeDateTimeMethod().

timestamptz_timetz()

Definition at line 2919 of file date.c.

2920{

2923 struct pg_tm tt,

2924 *tm = &tt;

2925 int tz;

2927

2930

2933 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

2934 errmsg("timestamp out of range")));

2935

2937

2939

2941}

References ereport, errcode(), errmsg(), ERROR, palloc(), PG_GETARG_TIMESTAMP, PG_RETURN_NULL, PG_RETURN_TIMETZADT_P, timestamp2tm(), TIMESTAMP_NOT_FINITE, tm, and tm2timetz().

Referenced by executeDateTimeMethod().

timetypmodin()

timetypmodout()

timetz2tm()

Definition at line 2468 of file date.c.

2469{

2471

2478

2479 if (tzp != NULL)

2480 *tzp = time->zone;

2481

2482 return 0;

2483}

References TimeTzADT::time, tm, pg_tm::tm_hour, pg_tm::tm_min, pg_tm::tm_sec, USECS_PER_HOUR, USECS_PER_MINUTE, USECS_PER_SEC, and TimeTzADT::zone.

Referenced by JsonEncodeDateTime(), timetz_out(), and timetz_part_common().

timetz_at_local()

timetz_cmp()

timetz_cmp_internal()

Definition at line 2508 of file date.c.

2509{

2511 t2;

2512

2513

2516

2517 if (t1 > t2)

2518 return 1;

2519 if (t1 < t2)

2520 return -1;

2521

2522

2523

2524

2525

2526 if (time1->zone > time2->zone)

2527 return 1;

2528 if (time1->zone < time2->zone)

2529 return -1;

2530

2531 return 0;

2532}

References TimeTzADT::time, USECS_PER_SEC, and TimeTzADT::zone.

Referenced by in_range_timetz_interval(), timetz_cmp(), timetz_eq(), timetz_ge(), timetz_gt(), timetz_larger(), timetz_le(), timetz_lt(), timetz_ne(), and timetz_smaller().

timetz_eq()

timetz_ge()

timetz_gt()

timetz_hash()

timetz_hash_extended()

timetz_in()

Definition at line 2338 of file date.c.

2339{

2341#ifdef NOT_USED

2343#endif

2345 Node *escontext = fcinfo->context;

2348 struct pg_tm tt,

2349 *tm = &tt;

2350 int tz;

2351 int nf;

2352 int dterr;

2355 int dtype;

2358

2361 if (dterr == 0)

2363 &dtype, tm, &fsec, &tz, &extra);

2364 if (dterr != 0)

2365 {

2367 escontext);

2369 }

2370

2374

2376}

References AdjustTimeForTypmod(), DateTimeParseError(), DecodeTimeOnly(), MAXDATEFIELDS, MAXDATELEN, palloc(), ParseDateTime(), PG_GETARG_CSTRING, PG_GETARG_INT32, PG_GETARG_OID, PG_RETURN_NULL, PG_RETURN_TIMETZADT_P, str, TimeTzADT::time, tm, and tm2timetz().

timetz_izone()

Definition at line 3187 of file date.c.

3188{

3192 int tz;

3193

3196 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

3197 errmsg("interval time zone \"%s\" must be finite",

3200

3201 if (zone->month != 0 || zone->day != 0)

3203 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

3204 errmsg("interval time zone \"%s\" must not include months or days",

3207

3209

3211

3213

3218

3219 result->zone = tz;

3220

3222}

Datum interval_out(PG_FUNCTION_ARGS)

if(TABLE==NULL||TABLE_index==NULL)

static char * DatumGetCString(Datum X)

References DatumGetCString(), DirectFunctionCall1, ereport, errcode(), errmsg(), ERROR, if(), INT64CONST, INTERVAL_NOT_FINITE, interval_out(), palloc(), PG_GETARG_INTERVAL_P, PG_GETARG_TIMETZADT_P, PG_RETURN_TIMETZADT_P, PointerGetDatum(), TimeTzADT::time, USECS_PER_DAY, USECS_PER_SEC, and TimeTzADT::zone.

timetz_larger()

timetz_le()

timetz_lt()

timetz_mi_interval()

Definition at line 2688 of file date.c.

2689{

2693

2696 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

2697 errmsg("cannot subtract infinite interval from time")));

2698

2700

2705

2707

2709}

References ereport, errcode(), errmsg(), ERROR, INT64CONST, INTERVAL_NOT_FINITE, palloc(), PG_GETARG_INTERVAL_P, PG_GETARG_TIMETZADT_P, PG_RETURN_TIMETZADT_P, Interval::time, TimeTzADT::time, USECS_PER_DAY, and TimeTzADT::zone.

timetz_ne()

timetz_out()

Definition at line 2379 of file date.c.

2380{

2382 char *result;

2383 struct pg_tm tt,

2384 *tm = &tt;

2386 int tz;

2388

2391

2394}

int timetz2tm(TimeTzADT *time, struct pg_tm *tm, fsec_t *fsec, int *tzp)

References buf, DateStyle, EncodeTimeOnly(), MAXDATELEN, PG_GETARG_TIMETZADT_P, PG_RETURN_CSTRING, pstrdup(), timetz2tm(), and tm.

Referenced by ExecGetJsonValueItemString().

timetz_part()

timetz_part_common()

Definition at line 2992 of file date.c.

2993{

2996 int64 intresult;

2999 char *lowunits;

3000

3003 false);

3004

3008

3010 {

3011 int tz;

3013 struct pg_tm tt,

3014 *tm = &tt;

3015

3017

3018 switch (val)

3019 {

3021 intresult = -tz;

3022 break;

3023

3026 break;

3027

3030 break;

3031

3034 break;

3035

3037 if (retnumeric)

3038

3039

3040

3041

3043 else

3045 break;

3046

3048 if (retnumeric)

3049

3050

3051

3052

3054 else

3056 break;

3057

3060 break;

3061

3064 break;

3065

3073 default:

3075 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),

3076 errmsg("unit \"%s\" not supported for type %s",

3078 intresult = 0;

3079 }

3080 }

3082 {

3083 if (retnumeric)

3084

3085

3086

3087

3089 else

3091 }

3092 else

3093 {

3095 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

3096 errmsg("unit \"%s\" not recognized for type %s",

3098 intresult = 0;

3099 }

3100

3101 if (retnumeric)

3103 else

3105}

References DecodeSpecial(), DecodeUnits(), downcase_truncate_identifier(), DTK_CENTURY, DTK_DAY, DTK_DECADE, DTK_EPOCH, DTK_HOUR, DTK_MICROSEC, DTK_MILLENNIUM, DTK_MILLISEC, DTK_MINUTE, DTK_MONTH, DTK_QUARTER, DTK_SECOND, DTK_TZ, DTK_TZ_HOUR, DTK_TZ_MINUTE, DTK_YEAR, ereport, errcode(), errmsg(), ERROR, format_type_be(), int64_div_fast_to_numeric(), int64_to_numeric(), INT64CONST, MINS_PER_HOUR, PG_GETARG_TEXT_PP, PG_GETARG_TIMETZADT_P, PG_RETURN_FLOAT8, PG_RETURN_NUMERIC, RESERV, SECS_PER_HOUR, SECS_PER_MINUTE, TimeTzADT::time, timetz2tm(), tm, pg_tm::tm_hour, pg_tm::tm_min, pg_tm::tm_sec, type, UNITS, UNKNOWN_FIELD, val, VARDATA_ANY, VARSIZE_ANY_EXHDR, and TimeTzADT::zone.

Referenced by extract_timetz(), and timetz_part().

timetz_pl_interval()

Definition at line 2661 of file date.c.

2662{

2666

2669 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

2670 errmsg("cannot add infinite interval to time")));

2671

2673

2678

2680

2682}

References ereport, errcode(), errmsg(), ERROR, INT64CONST, INTERVAL_NOT_FINITE, palloc(), PG_GETARG_INTERVAL_P, PG_GETARG_TIMETZADT_P, PG_RETURN_TIMETZADT_P, Interval::time, TimeTzADT::time, USECS_PER_DAY, and TimeTzADT::zone.

timetz_recv()

Definition at line 2400 of file date.c.

2401{

2403

2404#ifdef NOT_USED

2406#endif

2409

2411

2413

2416 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

2417 errmsg("time out of range")));

2418

2420

2421

2424 (errcode(ERRCODE_INVALID_TIME_ZONE_DISPLACEMENT_VALUE),

2425 errmsg("time zone displacement out of range")));

2426

2428

2430}

References AdjustTimeForTypmod(), buf, ereport, errcode(), errmsg(), ERROR, INT64CONST, palloc(), PG_GETARG_INT32, PG_GETARG_OID, PG_GETARG_POINTER, PG_RETURN_TIMETZADT_P, pq_getmsgint(), pq_getmsgint64(), TimeTzADT::time, TZDISP_LIMIT, USECS_PER_DAY, and TimeTzADT::zone.

timetz_scale()

timetz_send()

timetz_smaller()

timetz_time()

timetz_zone()

Definition at line 3125 of file date.c.

3126{

3130 int tz;

3135

3136

3137

3138

3140

3142

3144 {

3145

3146 tz = -val;

3147 }

3149 {

3150

3152 int isdst;

3153

3155 }

3156 else

3157 {

3158

3162

3165 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),

3166 errmsg("timestamp out of range")));

3167 }

3168

3170

3172

3177

3178 result->zone = tz;

3179

3181}

int DetermineTimeZoneAbbrevOffsetTS(TimestampTz ts, const char *abbr, pg_tz *tzp, int *isdst)

int DecodeTimezoneName(const char *tzname, int *offset, pg_tz **tz)

Datum now(PG_FUNCTION_ARGS)

#define TZNAME_FIXED_OFFSET

void text_to_cstring_buffer(const text *src, char *dst, size_t dst_len)

TimestampTz GetCurrentTransactionStartTimestamp(void)

References DecodeTimezoneName(), DetermineTimeZoneAbbrevOffsetTS(), ereport, errcode(), errmsg(), ERROR, GetCurrentTransactionStartTimestamp(), if(), INT64CONST, now(), palloc(), PG_GETARG_TEXT_PP, PG_GETARG_TIMETZADT_P, PG_RETURN_TIMETZADT_P, text_to_cstring_buffer(), TimeTzADT::time, timestamp2tm(), tm, type, TZ_STRLEN_MAX, TZNAME_DYNTZ, TZNAME_FIXED_OFFSET, USECS_PER_DAY, USECS_PER_SEC, val, and TimeTzADT::zone.

Referenced by timetz_at_local().

timetztypmodin()

timetztypmodout()

tm2time()

tm2timetz()

Definition at line 2328 of file date.c.

2329{

2332 result->zone = tz;

2333

2334 return 0;

2335}

References MINS_PER_HOUR, SECS_PER_MINUTE, TimeTzADT::time, tm, pg_tm::tm_hour, pg_tm::tm_min, pg_tm::tm_sec, USECS_PER_SEC, and TimeTzADT::zone.

Referenced by GetSQLCurrentTime(), parse_datetime(), timestamptz_timetz(), and timetz_in().